diff --git a/bi/polyfill.js b/bi/polyfill.js
index 1da80799f..f493c89a5 100644
--- a/bi/polyfill.js
+++ b/bi/polyfill.js
@@ -1,93 +1,93 @@
-if(![].indexOf){
- /**
- * 检查指定的值是否在数组中
- * @param {Object} o 要检查的值
- * @return {Number} o在数组中的索引(如果不在数组中则返回-1)
- */
- Array.prototype.indexOf = function (o) {
- for (var i = 0, len = this.length; i < len; i++) {
- if (_.isEqual(o, this[i])) {
- return i;
- }
- }
- return -1;
- }
-}
-if(![].lastIndexOf){
- /**
- * 检查指定的值是否在数组中
- * ie67不支持数组的这个方法
- * @param {Object} o 要检查的值
- * @return {Number} o在数组中的索引(如果不在数组中则返回-1)
- */
- Array.prototype.lastIndexOf = function (o) {
- for (var len = this.length, i = len - 1; i >= 0; i--) {
- if (_.isEqual(o, this[i])) {
- return i;
- }
- }
- return -1;
- }
-}/**
- * 特殊情况
- * Created by wang on 15/6/23.
- */
-//解决console未定义问题 guy
-window.console = window.console || (function () {
- var c = {};
- c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile
- = c.clear = c.exception = c.trace = c.assert = function () {
- };
- return c;
- })();
-/*
- * 前端缓存
- */
-window.localStorage || (window.localStorage = {
- items: {},
- setItem: function (k, v) {
- BI.Cache.addCookie(k, v);
- },
- getItem: function (k) {
- return BI.Cache.getCookie(k);
- },
- removeItem: function (k) {
- BI.Cache.deleteCookie(k);
- },
- key: function () {
-
- },
- clear: function () {
- this.items = {};
- }
-});//修复ie9下sort方法的bug
-!function (window) {
- var ua = window.navigator.userAgent.toLowerCase(),
- reg = /msie|applewebkit.+safari/;
- if (reg.test(ua)) {
- var _sort = Array.prototype.sort;
- Array.prototype.sort = function (fn) {
- if (!!fn && typeof fn === 'function') {
- if (this.length < 2) {
- return this;
- }
- var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0;
- for (; i < l; i++) {
- for (j = i + 1; j < l; j++) {
- t = fn.call(this, this[i], this[j]);
- r = (typeof t === 'number' ? t :
- !!t ? 1 : 0) > 0;
- if (r === true) {
- tmp = this[i];
- this[i] = this[j];
- this[j] = tmp;
- }
- }
- }
- return this;
- } else {
- return _sort.call(this);
- }
- };
- }
+if(![].indexOf){
+ /**
+ * 检查指定的值是否在数组中
+ * @param {Object} o 要检查的值
+ * @return {Number} o在数组中的索引(如果不在数组中则返回-1)
+ */
+ Array.prototype.indexOf = function (o) {
+ for (var i = 0, len = this.length; i < len; i++) {
+ if (_.isEqual(o, this[i])) {
+ return i;
+ }
+ }
+ return -1;
+ }
+}
+if(![].lastIndexOf){
+ /**
+ * 检查指定的值是否在数组中
+ * ie67不支持数组的这个方法
+ * @param {Object} o 要检查的值
+ * @return {Number} o在数组中的索引(如果不在数组中则返回-1)
+ */
+ Array.prototype.lastIndexOf = function (o) {
+ for (var len = this.length, i = len - 1; i >= 0; i--) {
+ if (_.isEqual(o, this[i])) {
+ return i;
+ }
+ }
+ return -1;
+ }
+}/**
+ * 特殊情况
+ * Created by wang on 15/6/23.
+ */
+//解决console未定义问题 guy
+window.console = window.console || (function () {
+ var c = {};
+ c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile
+ = c.clear = c.exception = c.trace = c.assert = function () {
+ };
+ return c;
+ })();
+/*
+ * 前端缓存
+ */
+window.localStorage || (window.localStorage = {
+ items: {},
+ setItem: function (k, v) {
+ BI.Cache.addCookie(k, v);
+ },
+ getItem: function (k) {
+ return BI.Cache.getCookie(k);
+ },
+ removeItem: function (k) {
+ BI.Cache.deleteCookie(k);
+ },
+ key: function () {
+
+ },
+ clear: function () {
+ this.items = {};
+ }
+});//修复ie9下sort方法的bug
+!function (window) {
+ var ua = window.navigator.userAgent.toLowerCase(),
+ reg = /msie|applewebkit.+safari/;
+ if (reg.test(ua)) {
+ var _sort = Array.prototype.sort;
+ Array.prototype.sort = function (fn) {
+ if (!!fn && typeof fn === 'function') {
+ if (this.length < 2) {
+ return this;
+ }
+ var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0;
+ for (; i < l; i++) {
+ for (j = i + 1; j < l; j++) {
+ t = fn.call(this, this[i], this[j]);
+ r = (typeof t === 'number' ? t :
+ !!t ? 1 : 0) > 0;
+ if (r === true) {
+ tmp = this[i];
+ this[i] = this[j];
+ this[j] = tmp;
+ }
+ }
+ }
+ return this;
+ } else {
+ return _sort.call(this);
+ }
+ };
+ }
}(window);
\ No newline at end of file
diff --git a/bi/widget.js b/bi/widget.js
index 89c141e2c..79c275717 100644
--- a/bi/widget.js
+++ b/bi/widget.js
@@ -1,16131 +1,17182 @@
-/**
- *
- * Created by GUY on 2016/5/26.
- * @class BI.SequenceTableTreeNumber
- * @extends BI.Widget
- */
-BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-sequence-table-tree-number",
- isNeedFreeze: false,
- startSequence: 1,//开始的序号
- scrollTop: 0,
- headerRowSize: 25,
- rowSize: 25,
-
- sequenceHeaderCreator: null,
-
- header: [],
- items: [], //二维数组
-
- //交叉表头
- crossHeader: [],
- crossItems: []
- });
- },
-
- _init: function () {
- BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.vCurr = 1;
- this.hCurr = 1;
- this.tasks = [];
- this.renderedCells = [];
- this.renderedKeys = [];
-
- this.container = BI.createWidget({
- type: "bi.absolute",
- width: 60,
- scrollable: false
- });
-
- this.scrollContainer = BI.createWidget({
- type: "bi.vertical",
- scrollable: false,
- scrolly: false,
- items: [this.container]
- });
-
- this.headerContainer = BI.createWidget({
- type: "bi.absolute",
- cls: "bi-border",
- width: 58,
- scrollable: false
- });
-
- this.layout = BI.createWidget({
- type: "bi.vtape",
- element: this,
- items: [{
- el: this.headerContainer,
- height: this._getHeaderHeight() - 2
- }, {el: {type: "bi.layout"}, height: 2}, {
- el: this.scrollContainer
- }]
- });
- //缓存第一行对应的序号
- this.start = this.options.startSequence;
- this.cache = {};
- this._nextState();
-
- this._populate();
- },
-
- _getNextSequence: function (nodes) {
- var self = this;
- var start = this.start;
- var cnt = this.start;
-
- function track(node) {
- //如果已经有缓存了就不改计数了,复杂表会出现这种情况
- self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt);
- cnt++;
- }
-
- BI.each(nodes, function (i, node) {
- if (BI.isNotEmptyArray(node.children)) {
- BI.each(node.children, function (index, child) {
- if (index === 0) {
- if (self.cache[child.text || child.value]) {
- start = cnt = self.cache[child.text || child.value];
- }
- }
- track(child)
- });
- }
- });
- this.start = cnt;
- return start;
- },
-
- _getStart: function (nodes) {
- var self = this;
- var start = this.start;
- BI.some(nodes, function (i, node) {
- if (BI.isNotEmptyArray(node.children)) {
- return BI.some(node.children, function (index, child) {
- if (index === 0) {
- if (self.cache[child.text || child.value]) {
- start = self.cache[child.text || child.value];
- return true;
- }
- }
- });
- }
- });
- return start;
- },
-
- _formatNumber: function (nodes) {
- var self = this, o = this.options;
- var result = [];
- var count = this._getStart(nodes);
-
- function getLeafCount(node) {
- var cnt = 0;
- if (BI.isNotEmptyArray(node.children)) {
- BI.each(node.children, function (index, child) {
- cnt += getLeafCount(child);
- });
- if (/**node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) {
- cnt++;
- }
- } else {
- cnt++;
- }
- return cnt;
- }
-
- var start = 0, top = 0;
- BI.each(nodes, function (i, node) {
- if (BI.isArray(node.children)) {
- BI.each(node.children, function (index, child) {
- var cnt = getLeafCount(child);
- result.push({
- text: count++,
- start: start,
- top: top,
- cnt: cnt,
- index: index,
- height: cnt * o.rowSize
- });
- start += cnt;
- top += cnt * o.rowSize;
- });
- if (BI.isNotEmptyArray(node.values)) {
- result.push({
- text: BI.i18nText("BI-Summary_Values"),
- start: start++,
- top: top,
- cnt: 1,
- isSummary: true,
- height: o.rowSize
- });
- top += o.rowSize;
- }
- }
- });
- return result;
- },
-
- _layout: function () {
- var self = this, o = this.options;
- var headerHeight = this._getHeaderHeight() - 2;
- var items = this.layout.attr("items");
- if (o.isNeedFreeze === false) {
- items[0].height = 0;
- items[1].height = 0;
- } else if (o.isNeedFreeze === true) {
- items[0].height = headerHeight;
- items[1].height = 2;
- }
- this.layout.attr("items", items);
- this.layout.resize();
- try {
- this.scrollContainer.element.scrollTop(o.scrollTop);
- } catch (e) {
-
- }
- },
-
- _getHeaderHeight: function () {
- var o = this.options;
- return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0));
- },
-
- _nextState: function () {
- var o = this.options;
- this._getNextSequence(o.items);
- },
-
- _prevState: function () {
- var self = this, o = this.options;
- var firstChild;
- BI.some(o.items, function (i, node) {
- if (BI.isNotEmptyArray(node.children)) {
- return BI.some(node.children, function (j, child) {
- firstChild = child;
- return true;
- });
- }
- });
- if (firstChild && BI.isNotEmptyObject(this.cache)) {
- this.start = this.cache[firstChild.text || firstChild.value];
- } else {
- this.start = 1;
- }
- this._nextState();
- },
-
- _getMaxScrollTop: function (numbers) {
- var cnt = 0;
- BI.each(numbers, function (i, number) {
- cnt += number.cnt;
- });
- return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth());
- },
-
- _createHeader: function () {
- var o = this.options;
- BI.createWidget({
- type: "bi.absolute",
- element: this.headerContainer,
- items: [{
- el: o.sequenceHeaderCreator || {
- type: "bi.table_style_cell",
- cls: "sequence-table-title-cell",
- styleGetter: o.headerCellStyleGetter,
- text: BI.i18nText("BI-Number_Index")
- },
- left: 0,
- top: 0,
- right: 0,
- bottom: 0
- }]
- });
- },
-
- _calculateChildrenToRender: function () {
- var self = this, o = this.options;
-
- var renderedCells = [], renderedKeys = [];
- var numbers = this._formatNumber(o.items);
- var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0);
- BI.each(numbers, function (i, number) {
- intervalTree.set(i, number.height);
- });
- var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers));
- var index = intervalTree.greatestLowerBound(scrollTop);
- var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0));
- var height = offsetTop;
- var bodyHeight = o.height - this._getHeaderHeight();
- while (height < bodyHeight && index < numbers.length) {
- renderedKeys.push(index);
- offsetTop += numbers[index].height;
- height += numbers[index].height;
- index++;
- }
-
- BI.each(renderedKeys, function (i, key) {
- var index = BI.deepIndexOf(self.renderedKeys, key);
- if (index > -1) {
- if (numbers[key].height !== self.renderedCells[index]._height) {
- self.renderedCells[index]._height = numbers[key].height;
- self.renderedCells[index].el.setHeight(numbers[key].height);
- }
- if (numbers[key].top !== self.renderedCells[index].top) {
- self.renderedCells[index].top = numbers[key].top;
- self.renderedCells[index].el.element.css("top", numbers[key].top + "px");
- }
- renderedCells.push(self.renderedCells[index]);
- } else {
- var child = BI.createWidget(BI.extend({
- type: "bi.table_style_cell",
- cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",
- width: 60,
- styleGetter: numbers[key].isSummary === true ? function () {
- return o.summaryCellStyleGetter(true);
- } : function (key) {
- return function () {
- return o.sequenceCellStyleGetter(key);
- }
- }(numbers[key].index)
- }, numbers[key]));
- renderedCells.push({
- el: child,
- left: 0,
- top: numbers[key].top,
- _height: numbers[key].height
- });
- }
- });
-
- //已存在的, 需要添加的和需要删除的
- var existSet = {}, addSet = {}, deleteArray = [];
- BI.each(renderedKeys, function (i, key) {
- if (BI.deepContains(self.renderedKeys, key)) {
- existSet[i] = key;
- } else {
- addSet[i] = key;
- }
- });
- BI.each(this.renderedKeys, function (i, key) {
- if (BI.deepContains(existSet, key)) {
- return;
- }
- if (BI.deepContains(addSet, key)) {
- return;
- }
- deleteArray.push(i);
- });
- BI.each(deleteArray, function (i, index) {
- self.renderedCells[index].el.destroy();
- });
- var addedItems = [];
- BI.each(addSet, function (index) {
- addedItems.push(renderedCells[index])
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: addedItems
- });
- this.renderedCells = renderedCells;
- this.renderedKeys = renderedKeys;
-
- this.container.setHeight(intervalTree.sumUntil(numbers.length));
- },
-
- _restore: function () {
- BI.each(this.renderedCells, function (i, cell) {
- cell.el.destroy();
- });
- this.renderedCells = [];
- this.renderedKeys = [];
- },
-
- _populate: function () {
- var self = this;
- BI.each(this.tasks, function (i, task) {
- task.apply(self);
- });
- this.tasks = [];
- this.headerContainer.empty();
- this._createHeader();
- this._layout();
- this._calculateChildrenToRender();
- },
-
- setVerticalScroll: function (scrollTop) {
- if (this.options.scrollTop !== scrollTop) {
- this.options.scrollTop = scrollTop;
- try {
- this.scrollContainer.element.scrollTop(scrollTop);
- } catch (e) {
-
- }
- }
- },
-
- getVerticalScroll: function () {
- return this.options.scrollTop;
- },
-
- setVPage: function (v) {
- if (v <= 1) {
- this.cache = {};
- this.start = this.options.startSequence;
- this._restore();
- this.tasks.push(this._nextState);
- } else if (v === this.vCurr + 1) {
- this.tasks.push(this._nextState);
- } else if (v === this.vCurr - 1) {
- this.tasks.push(this._prevState);
- }
- this.vCurr = v;
- },
-
- setHPage: function (v) {
- if (v !== this.hCurr) {
- this.tasks.push(this._prevState);
- }
- this.hCurr = v;
- },
-
- restore: function () {
- this._restore();
- },
-
- populate: function (items, header, crossItems, crossHeader) {
- var o = this.options;
- if (items && items !== this.options.items) {
- o.items = items;
- this._restore();
- this.tasks.push(this._prevState);
- }
- if (header && header !== this.options.header) {
- o.header = header;
- }
- if (crossItems && crossItems !== this.options.crossItems) {
- o.crossItems = crossItems;
- }
- if (crossHeader && crossHeader !== this.options.crossHeader) {
- o.crossHeader = crossHeader;
- }
- this._populate();
- }
-});
-BI.shortcut('bi.sequence_table_tree_number', BI.SequenceTableTreeNumber);/**
- * 自适应布局
- *
- * 1、resize
- * 2、吸附
- * 3、当前组件在最上方
- * 4、可以撤销
- * 5、上下之间插入组件
- *
- * Created by GUY on 2016/2/23.
- * @class BI.AdaptiveArrangement
- * @extends BI.Widget
- */
-BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-adaptive-arrangement",
- resizable: true,
- layoutType: BI.Arrangement.LAYOUT_TYPE.FREE,
- items: []
- });
- },
-
- _init: function () {
- BI.AdaptiveArrangement.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.arrangement = BI.createWidget({
- type: "bi.arrangement",
- element: this,
- layoutType: o.layoutType,
- items: o.items
- });
- this.arrangement.on(BI.Arrangement.EVENT_SCROLL, function () {
- self.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL, arguments);
- });
- this.zIndex = 0;
- BI.each(o.items, function (i, item) {
- self._initResizable(item.el);
- });
-
- $(document).mousedown(function (e) {
- BI.each(self.getAllRegions(), function (i, region) {
- if (region.el.element.find(e.target).length === 0) {
- region.el.element.removeClass("selected");
- }
- });
- });
- BI.ResizeDetector.addResizeListener(this, function () {
- self.arrangement.resize();
- self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
- });
- },
-
- _isEqual: function () {
- return this.arrangement._isEqual.apply(this.arrangement, arguments);
- },
-
- _setSelect: function (item) {
- if (!item.element.hasClass("selected")) {
- item.element.css("zIndex", ++this.zIndex);
- BI.each(this.getAllRegions(), function (i, region) {
- region.el.element.removeClass("selected");
- });
- item.element.addClass("selected");
- }
- },
-
- _initResizable: function (item) {
- var self = this, o = this.options;
- item.element.css("zIndex", ++this.zIndex);
- item.element.mousedown(function () {
- self._setSelect(item)
- });
- // o.resizable && item.element.resizable({
- // handles: "e, s, se",
- // minWidth: 20,
- // minHeight: 20,
- // autoHide: true,
- // helper: "bi-resizer",
- // start: function () {
- // item.element.css("zIndex", ++self.zIndex);
- // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE);
- // },
- // resize: function (e, ui) {
- // // self._resize(item.attr("id"), ui.size);
- // self._resize(item.attr("id"), e, ui.size, ui.position);
- // },
- // stop: function (e, ui) {
- // self._stopResize(item.attr("id"), ui.size);
- // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size);
- // self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
- // }
- // });
- },
-
- // _resize: function (name, e, size, position) {
- // var self = this;
- // this.scrollInterval(e, false, true, function (changedSize) {
- // size.width += changedSize.offsetX;
- // size.height += changedSize.offsetY;
- // var containerWidth = self.arrangement.container.element.width();
- // var containerHeight = self.arrangement.container.element.height();
- // self.arrangement.container.element.width(containerWidth + changedSize.offsetX);
- // self.arrangement.container.element.height(containerHeight + changedSize.offsetY);
- // switch (self.getLayoutType()) {
- // case BI.Arrangement.LAYOUT_TYPE.FREE:
- // break;
- // case BI.Arrangement.LAYOUT_TYPE.GRID:
- // self.setRegionSize(name, size);
- // break;
- // }
- // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size);
- // });
- // },
- //
- // _stopResize: function (name, size) {
- // var self = this;
- // this.scrollEnd();
- // switch (this.getLayoutType()) {
- // case BI.Arrangement.LAYOUT_TYPE.FREE:
- // this.setRegionSize(name, size);
- // break;
- // case BI.Arrangement.LAYOUT_TYPE.GRID:
- // this.setRegionSize(name, size);
- // break;
- // }
- // },
-
- _getScrollOffset: function () {
- return this.arrangement._getScrollOffset();
- },
-
- getClientWidth: function () {
- return this.arrangement.getClientWidth();
- },
-
- getClientHeight: function () {
- return this.arrangement.getClientHeight();
- },
-
- addRegion: function (region, position) {
- this._initResizable(region.el);
- this._setSelect(region.el);
- var self = this, flag;
- var old = this.arrangement.getAllRegions();
- if (flag = this.arrangement.addRegion(region, position)) {
- this._old = old;
- }
- return flag;
- },
-
- deleteRegion: function (name) {
- var flag;
- var old = this.getAllRegions();
- if (flag = this.arrangement.deleteRegion(name)) {
- this._old = old;
- } else {
- this._old = this.getAllRegions();
- this.relayout();
- }
- return flag;
- },
-
- setRegionSize: function (name, size) {
- var flag;
- var old = this.getAllRegions();
- if (flag = this.arrangement.setRegionSize(name, size)) {
- this._old = old;
- }
- return flag;
- },
-
- setPosition: function (position, size) {
- var self = this;
- return this.arrangement.setPosition(position, size);
- },
-
- setRegionPosition: function (name, position) {
- var region = this.getRegionByName(name);
- return this.arrangement.setRegionPosition(name, position);
- },
-
- setDropPosition: function (position, size) {
- return this.arrangement.setDropPosition(position, size);
- },
-
- scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
- var self = this;
- var map = {
- top: [-1, 0],
- bottom: [1, 0],
- left: [0, -1],
- right: [0, 1]
- };
- var clientSize = this.element.bounds();
-
- function scrollTo(direction, callback) {
- if (direction === "") {
- self.lastActiveRegion = "";
- if (self._scrollInterval) {
- clearInterval(self._scrollInterval);
- self._scrollInterval = null;
- }
- return;
- }
- if (self.lastActiveRegion !== direction) {
- self.lastActiveRegion = direction;
- if (self._scrollInterval) {
- clearInterval(self._scrollInterval);
- self._scrollInterval = null;
- }
- self._scrollInterval = setInterval(function () {
- var offset = self._getScrollOffset();
- var t = offset.top + map[direction][0] * 40;
- var l = offset.left + map[direction][1] * 40;
- if (t < 0 || l < 0) {
- return;
- }
- callback({
- offsetX: map[direction][1] * 40,
- offsetY: map[direction][0] * 40
- });
- self.scrollTo({
- top: t,
- left: l
- });
- }, 300);
- }
- }
-
- cb({
- offsetX: 0,
- offsetY: 0
- });
- var offset = this.element.offset();
- var p = {
- left: e.pageX - offset.left,
- top: e.pageY - offset.top
- };
- //向上滚
- if (isBorderScroll && p.top >= 0 && p.top <= 30) {
- scrollTo("top", cb)
- }
- //向下滚
- else if (isBorderScroll && p.top >= clientSize.height - 30 && p.top <= clientSize.height) {
- scrollTo("bottom", cb)
- }
- //向左滚
- else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
- scrollTo("left", cb)
- }
- //向右滚
- else if (isBorderScroll && p.left >= clientSize.width - 30 && p.left <= clientSize.width) {
- scrollTo("right", cb)
- } else {
- if (isOverflowScroll === true) {
- if (p.top < 0) {
- scrollTo("top", cb);
- }
- else if (p.top > clientSize.height) {
- scrollTo("bottom", cb);
- }
- else if (p.left < 0) {
- scrollTo("left", cb);
- }
- else if (p.left > clientSize.width) {
- scrollTo("right", cb);
- } else {
- scrollTo("", cb);
- }
- } else {
- scrollTo("", cb);
- }
- }
- },
-
- scrollEnd: function () {
- this.lastActiveRegion = "";
- if (this._scrollInterval) {
- clearInterval(this._scrollInterval);
- this._scrollInterval = null;
- }
- },
-
- scrollTo: function (scroll) {
- this.arrangement.scrollTo(scroll);
- },
-
- zoom: function (ratio) {
- this.arrangement.zoom(ratio);
- },
-
- resize: function () {
- this.arrangement.resize();
- },
-
- relayout: function () {
- return this.arrangement.relayout();
- },
-
- setLayoutType: function (type) {
- var self = this;
- this.arrangement.setLayoutType(type);
- },
-
- getLayoutType: function () {
- return this.arrangement.getLayoutType();
- },
-
- getLayoutRatio: function () {
- return this.arrangement.getLayoutRatio();
- },
-
- getHelper: function () {
- return this.arrangement.getHelper();
- },
-
- getRegionByName: function (name) {
- return this.arrangement.getRegionByName(name);
- },
-
- getAllRegions: function () {
- return this.arrangement.getAllRegions();
- },
-
- revoke: function () {
- if (this._old) {
- this.populate(BI.toArray(this._old));
- }
- },
-
- populate: function (items) {
- var self = this;
- BI.each(items, function (i, item) {
- self._initResizable(item.el);
- });
- this.arrangement.populate(items);
- }
-});
-BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE";
-BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_RESIZE";
-BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE";
-BI.AdaptiveArrangement.EVENT_RESIZE = "AdaptiveArrangement.EVENT_RESIZE";
-BI.AdaptiveArrangement.EVENT_SCROLL = "AdaptiveArrangement.EVENT_SCROLL";
-BI.shortcut('bi.adaptive_arrangement', BI.AdaptiveArrangement);/**
- * Arrangement的block面板
- *
- * Created by GUY on 2016/3/1.
- * @class BI.ArrangementBlock
- * @extends BI.Widget
- */
-BI.ArrangementBlock = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-arrangement-block bi-mask"
- });
- }
-});
-BI.shortcut('bi.arrangement_block', BI.ArrangementBlock);/**
- * Arrangement的drop面板
- *
- * Created by GUY on 2016/3/1.
- * @class BI.ArrangementDroppable
- * @extends BI.Widget
- */
-BI.ArrangementDroppable = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-arrangement-droppable bi-resizer"
- });
- }
-});
-BI.shortcut('bi.arrangement_droppable', BI.ArrangementDroppable);/**
- * 布局
- *
- * Created by GUY on 2016/2/23.
- * @class BI.Arrangement
- * @extends BI.Widget
- */
-BI.Arrangement = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-arrangement",
- layoutType: BI.Arrangement.LAYOUT_TYPE.GRID,
- items: []
- });
- },
-
- _init: function () {
- BI.Arrangement.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.arrangement = BI.createWidget({
- type: "bi.arrangement_droppable",
- cls: "arrangement-block",
- invisible: true
- });
- this.block = BI.createWidget({
- type: "bi.arrangement_block",
- invisible: true
- });
- this.container = BI.createWidget({
- type: "bi.absolute",
- items: o.items.concat([this.block, this.arrangement])
- });
-
- this.scrollContainer = BI.createWidget({
- type: "bi.adaptive",
- width: "100%",
- height: "100%",
- scrollable: true,
- items: [this.container]
- });
- this.scrollContainer.element.scroll(function () {
- self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
- scrollLeft: self.scrollContainer.element.scrollLeft(),
- scrollTop: self.scrollContainer.element.scrollTop(),
- clientWidth: self.scrollContainer.element[0].clientWidth,
- clientHeight: self.scrollContainer.element[0].clientHeight
- });
- });
-
- BI.createWidget({
- type: "bi.adaptive",
- element: this,
- items: [this.scrollContainer]
- });
- this.regions = {};
- if (o.items.length > 0) {
- BI.nextTick(function () {
- self.populate(o.items);
- });
- }
- },
-
- ////初始化操作////
- _calculateRegions: function (items) {
- var self = this, o = this.options;
- this.regions = {};
- BI.each(items, function (i, item) {
- var region = self._createOneRegion(item);
- self.regions[region.id] = region;
- });
- },
-
- _isEqual: function (num1, num2) {
- return Math.abs(num1 - num2) < 2;
- },
-
- _isLessThan: function (num1, num2) {
- return num1 < num2 && !this._isEqual(num1, num2);
- },
-
- _isMoreThan: function (num1, num2) {
- return num1 > num2 && !this._isEqual(num1, num2);
- },
-
- _isLessThanEqual: function (num1, num2) {
- return num1 <= num2 || this._isEqual(num1, num2);
- },
-
- _isMoreThanEqual: function (num1, num2) {
- return num1 >= num2 || this._isEqual(num1, num2);
- },
-
- //获取占有的最大Region
- _getRegionOccupied: function (regions) {
- var self = this, o = this.options;
- if (BI.size(regions || this.regions) <= 0) {
- return {
- left: 0,
- top: 0,
- width: 0,
- height: 0
- }
- }
- var minLeft = BI.MAX, maxLeft = BI.MIN, minTop = BI.MAX, maxTop = BI.MIN;
- BI.each(regions || this.regions, function (id, region) {
- minLeft = Math.min(minLeft, region.left);
- maxLeft = Math.max(maxLeft, region.left + region.width);
- minTop = Math.min(minTop, region.top);
- maxTop = Math.max(maxTop, region.top + region.height);
- });
- return {
- left: minLeft,
- top: minTop,
- width: maxLeft - minLeft,
- height: maxTop - minTop
- }
- },
-
- //两个区域的交叉面积
- _getCrossArea: function (region1, region2) {
- if (region1.left <= region2.left) {
- if (region1.top <= region2.top) {
- if (region1.top + region1.height > region2.top && region1.left + region1.width > region2.left) {
- if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region1.left + region1.width, region2.left)) {
- return 0;
- }
- return (region1.top + region1.height - region2.top) * (region1.left + region1.width - region2.left);
- }
- } else {
- if (region2.top + region2.height > region1.top && region1.left + region1.width > region2.left) {
- if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region1.left + region1.width, region2.left)) {
- return 0;
- }
- return (region2.top + region2.height - region1.top) * (region1.left + region1.width - region2.left);
- }
- }
- } else {
- if (region1.top <= region2.top) {
- if (region1.top + region1.height > region2.top && region2.left + region2.width > region1.left) {
- if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region2.left + region2.width, region1.left)) {
- return 0;
- }
- return (region1.top + region1.height - region2.top) * (region2.left + region2.width - region1.left);
- }
- } else {
- if (region2.top + region2.height > region1.top && region2.left + region2.width > region1.left) {
- if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region2.left + region2.width, region1.left)) {
- return 0;
- }
- return (region2.top + region2.height - region1.top) * (region2.left + region2.width - region1.left);
- }
- }
- }
- return 0;
- },
-
- //是否有覆盖的组件
- _isRegionOverlay: function (regions) {
- var reg = [];
- BI.each(regions || this.regions, function (id, region) {
- reg.push(new BI.Region(region.left, region.top, region.width, region.height));
- });
- for (var i = 0, len = reg.length; i < len; i++) {
- for (var j = i + 1; j < len; j++) {
- var area1 = {
- left: reg[i].x,
- top: reg[i].y,
- width: reg[i].w,
- height: reg[i].h
- };
- var area2 = {
- left: reg[j].x,
- top: reg[j].y,
- width: reg[j].w,
- height: reg[j].h
- };
- if (reg[i].isIntersects(reg[j]) && this._getCrossArea(area1, area2) > 1) {
- return true;
- }
- }
- }
- return false;
- },
-
- //布局是否是优良的
- _isArrangeFine: function (regions) {
- switch (this.options.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- return true;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- // if (this._isRegionOverlay()) {
- // return false;
- // }
- }
- return true;
- },
-
- _getRegionNames: function (regions) {
- var names = [];
- BI.each(regions || this.regions, function (i, region) {
- names.push(region.id || region.attr("id"));
- });
- return names;
- },
-
- _getRegionsByNames: function (names, regions) {
- names = BI.isArray(names) ? names : [names];
- regions = regions || this.regions;
- if (BI.isArray(regions)) {
- var result = [];
- BI.each(regions, function (i, region) {
- if (names.contains(region.id || region.attr("id"))) {
- result.push(region);
- }
- });
- } else {
- var result = {};
- BI.each(names, function (i, name) {
- result[name] = regions[name];
- });
- }
- return result;
- },
-
- _cloneRegion: function (regions) {
- var clone = {};
- BI.each(regions || this.regions, function (id, region) {
- clone[id] = {};
- clone[id].el = region.el;
- clone[id].id = region.id;
- clone[id].left = region.left;
- clone[id].top = region.top;
- clone[id].width = region.width;
- clone[id].height = region.height;
- });
- return clone;
- },
-
- //测试合法性
- _test: function (regions) {
- var self = this;
- return !BI.any(regions || this.regions, function (i, region) {
- if (BI.isNaN(region.width) || BI.isNaN(region.height) || region.width <= 21 || region.height <= 21) {
- return true;
- }
- })
- },
-
- _getScrollOffset: function () {
- return {
- left: this.scrollContainer.element[0].scrollLeft,
- top: this.scrollContainer.element[0].scrollTop
- }
- },
-
- ////操作////
- _createOneRegion: function (item) {
- var el = BI.createWidget(item.el);
- el.setVisible(true);
- return {
- id: el.attr("id"),
- left: item.left,
- top: item.top,
- width: item.width,
- height: item.height,
- el: el
- }
- },
-
- _applyRegion: function (regions) {
- var self = this, o = this.options;
- BI.each(regions || this.regions, function (i, region) {
- region.el.element.css({
- left: region.left,
- top: region.top,
- width: region.width,
- height: region.height
- });
- });
- this._applyContainer();
- this.ratio = this.getLayoutRatio();
- },
-
- _renderRegion: function () {
- var self = this;
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: BI.toArray(this.regions)
- });
- },
-
- getClientWidth: function () {
- return this.scrollContainer.element[0].clientWidth;
- },
-
- getClientHeight: function () {
- return this.scrollContainer.element[0].clientHeight;
- },
-
- _applyContainer: function () {
- //先掩藏后显示能够明确滚动条是否出现
- this.scrollContainer.element.css("overflow", "hidden");
- var occupied = this._getRegionOccupied();
- this.container.element.width(occupied.left + occupied.width).height(occupied.top + occupied.height);
- this.scrollContainer.element.css("overflow", "auto");
- return occupied;
- },
-
- _modifyRegion: function (regions) {
- BI.each(this.regions, function (id, region) {
- if (regions[id]) {
- region.left = regions[id].left;
- region.top = regions[id].top;
- region.width = regions[id].width;
- region.height = regions[id].height;
- }
- });
- },
-
- _addRegion: function (item) {
- var region = this._createOneRegion(item);
- this.regions[region.id] = region;
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: [region]
- });
- },
-
- _deleteRegionByName: function (name) {
- this.regions[name].el.setVisible(false);
- delete this.regions[name];
- },
-
- _setArrangeSize: function (size) {
- this.arrangement.element.css({
- left: size.left,
- top: size.top,
- width: size.width,
- height: size.height
- })
- },
-
- //Grid
- _getOneWidthPortion: function () {
- return this.getClientWidth() / BI.Arrangement.PORTION;
- },
- _getOneHeightPortion: function () {
- return this.getClientHeight() / BI.Arrangement.H_PORTION;
- },
-
- _getGridPositionAndSize: function (position) {
- var perWidth = this._getOneWidthPortion();
- var perHeight = this._getOneHeightPortion();
- var widthPortion = Math.round(position.width / perWidth);
- var leftPortion = Math.round(position.left / perWidth);
- var topPortion = Math.round(position.top / perHeight);
- var heightPortion = Math.round(position.height / perHeight);
- // if (leftPortion > BI.Arrangement.PORTION) {
- // leftPortion = BI.Arrangement.PORTION;
- // }
- // if (widthPortion > BI.Arrangement.PORTION) {
- // widthPortion = BI.Arrangement.PORTION;
- // }
- // if (leftPortion + widthPortion > BI.Arrangement.PORTION) {
- // leftPortion = BI.Arrangement.PORTION - widthPortion;
- // }
- if (widthPortion === 0) {
- widthPortion = 1;
- }
- if (heightPortion === 0) {
- heightPortion = 1;
- }
- return {
- x: leftPortion,
- y: topPortion,
- w: widthPortion,
- h: heightPortion
- }
- },
-
- _getBlockPositionAndSize: function (position) {
- var perWidth = this._getOneWidthPortion();
- var perHeight = this._getOneHeightPortion();
- return {
- left: position.x * perWidth,
- top: position.y * perHeight,
- width: position.w * perWidth,
- height: position.h * perHeight
- };
- },
-
- _getLayoutsByRegions: function (regions) {
- var self = this;
- var result = [];
- BI.each(regions || this.regions, function (id, region) {
- result.push(BI.extend(self._getGridPositionAndSize(region), {
- i: region.id
- }))
- });
- return result;
- },
-
- _getLayoutIndexByName: function (layout, name) {
- return BI.findIndex(layout, function (i, l) {
- return l.i === name;
- });
- },
-
- _setBlockPositionAndSize: function (size) {
- this.block.element.css({
- left: size.left,
- top: size.top,
- width: size.width,
- height: size.height
- });
- },
-
- _getRegionsByLayout: function (layout) {
- var self = this;
- var regions = {};
- BI.each(layout, function (i, ly) {
- regions[ly.i] = BI.extend(self._getBlockPositionAndSize(ly), {
- id: ly.i
- });
- });
- return regions;
- },
-
- _setRegionsByLayout: function (regions, layout) {
- var self = this;
- regions || (regions = this.regions);
- BI.each(layout, function (i, ly) {
- if (regions[ly.i]) {
- BI.extend(regions[ly.i], self._getBlockPositionAndSize(ly));
- }
- });
- return regions;
- },
-
- _moveElement: function (layout, l, x, y, isUserAction) {
- var self = this;
- if (l._static) {
- return layout;
- }
-
- if (l.y === y && l.x === x) {
- return layout;
- }
-
- var movingUp = y && l.y > y;
- if (typeof x === 'number') {
- l.x = x;
- }
- if (typeof y === 'number') {
- l.y = y;
- }
- l.moved = true;
-
- var sorted = this._sortLayoutItemsByRowCol(layout);
- if (movingUp) {
- sorted = sorted.reverse();
- }
- var collisions = getAllCollisions(sorted, l);
-
- for (var i = 0, len = collisions.length; i < len; i++) {
- var collision = collisions[i];
- if (collision.moved) {
- continue;
- }
-
- if (l.y > collision.y && l.y - collision.y > collision.h / 4) {
- continue;
- }
-
- if (collision._static) {
- layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction);
- } else {
- layout = this._moveElementAwayFromCollision(layout, l, collision, isUserAction);
- }
- }
-
- return layout;
-
- function getAllCollisions(layout, layoutItem) {
- return BI.filter(layout, function (i, l) {
- return self._collides(l, layoutItem);
- });
- }
- },
-
- _sortLayoutItemsByRowCol: function (layout) {
- return [].concat(layout).sort(function (a, b) {
- if (a.y > b.y || (a.y === b.y && a.x > b.x)) {
- return 1;
- }
- return -1;
- });
- },
-
- _collides: function (l1, l2) {
- if (l1 === l2) {
- return false;
- } // same element
- if (l1.x + l1.w <= l2.x) {
- return false;
- } // l1 is left of l2
- if (l1.x >= l2.x + l2.w) {
- return false;
- } // l1 is right of l2
- if (l1.y + l1.h <= l2.y) {
- return false;
- } // l1 is above l2
- if (l1.y >= l2.y + l2.h) {
- return false;
- } // l1 is below l2
- return true; // boxes overlap
- },
-
- _getFirstCollision: function (layout, layoutItem) {
- for (var i = 0, len = layout.length; i < len; i++) {
- if (this._collides(layout[i], layoutItem)) {
- return layout[i];
- }
- }
- },
-
- _moveElementAwayFromCollision: function (layout, collidesWith,
- itemToMove, isUserAction) {
- if (isUserAction) {
- var fakeItem = {
- x: itemToMove.x,
- y: itemToMove.y,
- w: itemToMove.w,
- h: itemToMove.h,
- i: '-1'
- };
- fakeItem.y = Math.max(collidesWith.y - itemToMove.h, 0);
- if (!this._getFirstCollision(layout, fakeItem)) {
- return this._moveElement(layout, itemToMove, undefined, fakeItem.y);
- }
- }
-
- return this._moveElement(layout, itemToMove, undefined, itemToMove.y + 1);
- },
-
- _compactItem: function (compareWith, l, verticalCompact) {
- if (verticalCompact) {
- while (l.y > 0 && !this._getFirstCollision(compareWith, l)) {
- l.y--;
- }
- }
-
- var collides;
- while ((collides = this._getFirstCollision(compareWith, l))) {
- l.y = collides.y + collides.h;
- }
- return l;
- },
-
- compact: function (layout, verticalCompact) {
- var compareWith = getStatics(layout);
- var sorted = this._sortLayoutItemsByRowCol(layout);
- var out = [];
-
- for (var i = 0, len = sorted.length; i < len; i++) {
- var l = sorted[i];
-
- if (!l._static) {
- l = this._compactItem(compareWith, l, verticalCompact);
-
- compareWith.push(l);
- }
-
- out[layout.indexOf(l)] = l;
-
- l.moved = false;
- }
-
- return out;
- function getStatics(layout) {
- return BI.filter(layout, function (i, l) {
- return l._static;
- });
- }
- },
-
- ////公有方法////
- getRegionByName: function (name) {
- var obj = {};
- obj[name] = this.regions[name];
- return this._cloneRegion(obj)[name];
- },
-
- getAllRegions: function () {
- return BI.toArray(this._cloneRegion());
- },
-
- getHelper: function () {
- var helper = BI.createWidget({
- type: "bi.layout",
- width: 18,
- height: 18,
- cls: "arrangement-helper bi-border"
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [helper]
- });
- return helper;
- },
-
- _start: function () {
- if (this.options.layoutType === BI.Arrangement.LAYOUT_TYPE.GRID) {
- this.block.setVisible(true);
- } else {
- this.arrangement.setVisible(true);
- }
- },
-
- _stop: function () {
- this.arrangement.setVisible(false);
- this.block.setVisible(false);
- },
-
- ////公有操作////
- setLayoutType: function (type) {
- var self = this, o = this.options;
- if (type !== o.layoutType) {
- o.layoutType = type;
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- this.relayout();
- break;
- }
- }
- },
-
- getLayoutType: function () {
- return this.options.layoutType;
- },
-
- getLayoutRatio: function () {
- var occupied = this._getRegionOccupied();
- var width = this.getClientWidth(), height = this.getClientHeight();
- return {
- x: BI.parseFloat(BI.contentFormat((occupied.left + occupied.width) / width, "#.##;-#.##")),
- y: BI.parseFloat(BI.contentFormat((occupied.top + occupied.height) / height, "#.##;-#.##"))
- }
- },
-
- addRegion: function (region, position) {
- if (position) {
- this.setPosition(position, region);
- }
- var self = this, o = this.options;
- if (!this.position) {
- return false;
- }
- var test = this._cloneRegion();
- BI.each(this.position.regions, function (i, region) {
- test[region.id].left = region.left;
- test[region.id].top = region.top;
- test[region.id].width = region.width;
- test[region.id].height = region.height;
-
- });
- var item = BI.extend({}, region, {
- left: this.position.insert.left,
- top: this.position.insert.top,
- width: this.position.insert.width,
- height: this.position.insert.height
- });
- var added = this._createOneRegion(item);
- test[added.id] = added;
- if (this._test(test)) {
- delete test[added.id];
- this._modifyRegion(test);
- this._addRegion(item);
- this._populate(this.getAllRegions());
- return true;
- }
- return false;
- },
-
- deleteRegion: function (name) {
- if (!this.regions[name]) {
- return false;
- }
- var self = this, o = this.options;
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- this._deleteRegionByName(name);
- this._populate(this.getAllRegions());
- return true;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- this._deleteRegionByName(name);
- this._populate(this.getAllRegions());
- this.resize();
- return true;
- }
- return false;
- },
-
- setRegionSize: function (name, size) {
- var self = this, o = this.options;
- var flag = false;
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- var clone = this._cloneRegion();
- BI.extend(clone[name], {
- width: size.width,
- height: size.height
- });
- if (this._test(clone)) {
- this._modifyRegion(clone);
- flag = true;
- }
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- var clone = this._cloneRegion();
- BI.extend(clone[name], {
- width: size.width,
- height: size.height
- });
- if (this._test(clone)) {
- var layout = this._getLayoutsByRegions(clone);
- layout = this.compact(layout, true);
- var regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- flag = true;
- }
- break;
- }
- this._applyRegion();
- return flag;
- },
-
- setPosition: function (position, size) {
- var self = this, o = this.options;
- var insert, regions = [], cur;
- if (position.left < 0 || position.top < 0) {
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- this.resize();
- break;
- }
- this._stop();
- this.position = null;
- return null;
- }
- var offset = this._getScrollOffset();
- position = {
- left: position.left + offset.left,
- top: position.top + offset.top
- };
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- var insert = {
- top: position.top < 0 ? 0 : position.top,
- left: position.left < 0 ? 0 : position.left,
- width: size.width,
- height: size.height
- };
- this.position = {
- insert: insert
- };
- this._setArrangeSize(insert);
- this._start();
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- var p = {
- top: position.top < 0 ? 0 : position.top,
- left: position.left < 0 ? 0 : position.left,
- width: size.width,
- height: size.height
- };
- this._setArrangeSize(p);
- var cur = this._getGridPositionAndSize(p);
- var layout = [{
- x: 0, y: BI.MAX, w: cur.w, h: cur.h, i: cur.i
- }].concat(this._getLayoutsByRegions());
- layout = this._moveElement(layout, layout[0], cur.x, cur.y, true);
- layout = this.compact(layout, true);
- var regions = this._setRegionsByLayout(this._cloneRegion(), layout);
- var insert = this._getBlockPositionAndSize(layout[0]);
- this.position = {
- insert: insert,
- regions: regions
- };
- this._applyRegion(regions);
- this._setBlockPositionAndSize(insert);
- this._start();
- break;
- }
- return this.position;
- },
-
- setRegionPosition: function (name, position) {
- var self = this, o = this.options;
- var offset = this._getScrollOffset();
- position = BI.extend(position, {
- left: position.left + offset.left,
- top: position.top + offset.top
- });
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- BI.extend(this.regions[name], {
- left: position.left < 0 ? 0 : position.left,
- top: position.top < 0 ? 0 : position.top
- });
- this._applyRegion();
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- if (!position.stop) {
- BI.extend(this.regions[name], {
- left: position.left < 0 ? 0 : position.left,
- top: position.top < 0 ? 0 : position.top
- });
- var cloned = this._cloneRegion();
- var cur = this._getGridPositionAndSize(BI.extend(cloned[name], {
- left: position.left < 0 ? 0 : position.left,
- top: position.top < 0 ? 0 : position.top
- }));
- var x = cur.x, y = cur.y;
- cur = BI.extend(cur, {
- x: 0, y: BI.MAX, i: -1
- });
- delete cloned[name];
- var layout = this._getLayoutsByRegions(cloned);
- layout = this._moveElement([cur].concat(layout), cur, x, y, true);
- layout = this.compact(layout, true);
- var regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- this._applyRegion();
-
- this._setBlockPositionAndSize(this._getBlockPositionAndSize(cur));
- this.block.setVisible(true);
- } else {
- BI.extend(this.regions[name], {
- left: position.left < 0 ? 0 : position.left,
- top: position.top < 0 ? 0 : position.top
- });
- var cloned = this._cloneRegion();
- var layout = this._getLayoutsByRegions(cloned);
- layout = this.compact(layout, true);
- var regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- this._applyRegion();
- this.block.setVisible(false);
- }
- break;
- }
- },
-
- setDropPosition: function (position, size) {
- var self = this;
- this.arrangement.setVisible(true);
- var offset = this._getScrollOffset();
- this._setArrangeSize(BI.extend({}, size, {
- left: position.left + offset.left,
- top: position.top + offset.top
- }));
- return function () {
- self.arrangement.setVisible(false);
- }
- },
-
- scrollTo: function (scroll) {
- this.scrollContainer.element.scrollTop(scroll.top);
- this.scrollContainer.element.scrollLeft(scroll.left);
- },
-
- zoom: function (ratio) {
- var self = this, o = this.options;
- if (!ratio) {
- return;
- }
- var occupied = this._applyContainer();
- switch (this.getLayoutType()) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- if (this._isArrangeFine()) {
- var width = this.getClientWidth();
- var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width);
- //var yRatio = ratio.y * height / (occupied.top + occupied.height);
- var regions = this._cloneRegion();
- BI.each(regions, function (i, region) {
- region.left = region.left * xRatio;
- //region.top = region.top * yRatio;
- region.width = region.width * xRatio;
- //region.height = region.height * yRatio;
- });
- if (this._test(regions)) {
- this._modifyRegion(regions);
- this._applyRegion();
- }
- this.resize();
- // } else {
- this.relayout();
- }
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- if (this._isArrangeFine()) {
- var width = this.getClientWidth(), height = this.getClientHeight();
- var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width);
- var yRatio = (ratio.y || 1) * height / (occupied.top + occupied.height);
- var regions = this._cloneRegion();
- BI.each(regions, function (i, region) {
- region.left = region.left * xRatio;
- region.width = region.width * xRatio;
- region.top = region.top * yRatio;
- region.height = region.height * yRatio;
- //做一下自适应布局到网格布局的兼容
- var perWidth = self._getOneWidthPortion();
- var widthPortion = Math.round(region.width / perWidth);
- var leftPortion = Math.round(region.left / perWidth);
- var comparePortion = Math.round((region.width + region.left) / perWidth);
- if (leftPortion + widthPortion !== comparePortion) {
- region.left = leftPortion * perWidth;
- region.width = comparePortion * perWidth - region.left;
- }
- });
- if (this._test(regions)) {
- var layout = this._getLayoutsByRegions(regions);
- layout = this.compact(layout, true);
- regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- this._applyRegion();
- }
- } else {
- this.relayout();
- }
- break;
- }
- },
-
- resize: function () {
- var self = this, o = this.options;
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- this.zoom(this.ratio);
- var regions = this._cloneRegion();
- var layout = this._getLayoutsByRegions(regions);
- layout = this.compact(layout, true);
- regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- this._applyRegion();
- break;
- }
- },
-
- relayout: function () {
- var self = this, o = this.options;
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- if (!this._isArrangeFine()) {
- var perHeight = this._getOneHeightPortion();
- var width = this.getClientWidth(), height = this.getClientHeight();
- var regions = this._cloneRegion();
- var clone = BI.toArray(regions);
- clone.sort(function (r1, r2) {
- if (self._isEqual(r1.top, r2.top)) {
- return r1.left - r2.left;
- }
- return r1.top - r2.top;
- });
- var count = clone.length;
- var cols = 4, rows = Math.floor((count - 1) / 4 + 1);
- var w = width / cols, h = height / rows;
- var store = {};
- BI.each(clone, function (i, region) {
- var row = Math.floor(i / 4), col = i % 4;
- BI.extend(region, {
- top: row * perHeight * 6,
- left: col * w,
- width: w,
- height: perHeight * 6
- });
- if (!store[row]) {
- store[row] = {};
- }
- store[row][col] = region;
- });
- //非4的倍数
- // if (count % 4 !== 0) {
- // var lasts = store[rows - 1];
- // var perWidth = width / (count % 4);
- // BI.each(lasts, function (i, region) {
- // BI.extend(region, {
- // left: BI.parseInt(i) * perWidth,
- // width: perWidth
- // });
- // });
- // }
- if (this._test(clone)) {
- var layout = this._getLayoutsByRegions(regions);
- layout = this.compact(layout, true);
- regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- this._populate(clone);
- }
- } else {
- this.resize();
- }
- break;
- }
- },
-
- _populate: function (items) {
- this._stop();
- this._calculateRegions(items);
- this._applyRegion();
- },
-
- populate: function (items) {
- var self = this;
- BI.each(this.regions, function (name, region) {
- self.regions[name].el.setVisible(false);
- delete self.regions[name];
- });
- this._populate(items);
- this._renderRegion();
- }
-});
-BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL";
-BI.extend(BI.Arrangement, {
- PORTION: 36,
- H_PORTION: 18,
- LAYOUT_TYPE: {
- GRID: 0,
- FREE: 1
- }
-});
-BI.shortcut('bi.arrangement', BI.Arrangement);/**
- * 表关联树
- *
- * Created by GUY on 2015/12/15.
- * @class BI.BranchRelation
- * @extends BI.Widget
- */
-BI.BranchRelation = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.BranchRelation.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-branch-relation-tree",
- items: [],
-
- centerOffset: 0,//重心偏移量
- direction: BI.Direction.Bottom,
- align: BI.VerticalAlign.Top
- })
- },
-
- _init: function () {
- BI.BranchRelation.superclass._init.apply(this, arguments);
- this.populate(this.options.items);
- },
-
- //树分层
- _stratification: function () {
- var levels = [];
- this.tree.recursion(function (node, route) {
- //node.isRoot = route.length <= 1;
- node.leaf = node.isLeaf();
- if (!levels[route.length - 1]) {
- levels[route.length - 1] = [];
- }
- levels[route.length - 1].push(node);
- });
- return levels;
- },
-
- //计算所有节点的叶子结点个数
- _calculateLeaves: function () {
- var count = 0;
-
- function track(node) {
- var c = 0;
- if (node.isLeaf()) {
- return 1;
- }
- BI.each(node.getChildren(), function (i, child) {
- c += track(child);
- });
- node.set("leaves", c);
- return c;
- }
-
- count = track(this.tree.getRoot());
- return count;
- },
-
- //树平移
- _translate: function (levels) {
- var adjust = [];
- var maxLevel = levels.length;
- BI.each(levels, function (i, nodes) {
- if (!adjust[i]) {
- adjust[i] = [];
- }
- BI.each(nodes, function (j, node) {
- if (node.isLeaf() && i < maxLevel - 1) {
- var newNode = new BI.Node(BI.UUID());
- //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot;
- newNode.isNew = true;
- //把node向下一层移
- var tar = 0;
- if (j > 0) {
- var c = nodes[j - 1].getLastChild();
- tar = levels[i + 1].indexOf(c) + 1;
- }
- levels[i + 1].splice(tar, 0, node);
- //新增一个临时树节点
- var index = node.parent.getChildIndex(node.id);
- node.parent.removeChildByIndex(index);
- node.parent.addChild(newNode, index);
- newNode.addChild(node);
- adjust[i].push(newNode);
- nodes[j] = newNode;
- } else {
- adjust[i].push(node);
- }
- })
- });
- return adjust;
- },
-
- //树补白
- _fill: function (levels) {
- var adjust = [];
- var maxLevel = levels.length;
- BI.each(levels, function (i, nodes) {
- if (!adjust[i]) {
- adjust[i] = [];
- }
- BI.each(nodes, function (j, node) {
- if (node.isLeaf() && i < maxLevel - 1) {
- var newNode = new BI.Node(BI.UUID());
- newNode.leaf = true;
- newNode.width = node.width;
- newNode.height = node.height;
- newNode.isNew = true;
- //把node向下一层移
- var tar = 0;
- if (j > 0) {
- var c = nodes[j - 1].getLastChild();
- tar = levels[i + 1].indexOf(c) + 1;
- }
- levels[i + 1].splice(tar, 0, newNode);
- //新增一个临时树节点
- node.addChild(newNode);
- }
- adjust[i].push(node);
- })
- });
- return adjust;
- },
-
- //树调整
- _adjust: function (adjust) {
- while (true) {
- var isAllNeedAjust = false;
- BI.backEach(adjust, function (i, nodes) {
- BI.each(nodes, function (j, node) {
- if (!node.isNew) {
- var needAdjust = true;
- BI.any(node.getChildren(), function (k, n) {
- if (!n.isNew) {
- needAdjust = false;
- return true;
- }
- });
- if (!node.isLeaf() && needAdjust === true) {
- var allChilds = [];
- BI.each(node.getChildren(), function (k, n) {
- allChilds = allChilds.concat(n.getChildren());
- });
- node.removeAllChilds();
- BI.each(allChilds, function (k, c) {
- node.addChild(c);
- });
- var newNode = new BI.Node(BI.UUID());
- //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot;
- newNode.isNew = true;
- var index = node.parent.getChildIndex(node.id);
- node.parent.removeChildByIndex(index);
- node.parent.addChild(newNode, index);
- newNode.addChild(node);
- isAllNeedAjust = true;
- }
- }
- })
- });
- if (isAllNeedAjust === false) {
- break;
- } else {//树重构
- adjust = this._stratification();
- }
- }
- return adjust;
- },
-
- _calculateWidth: function () {
- var o = this.options;
- var width = 0;
-
- function track1(node) {
- var w = 0;
- if (node.isLeaf()) {
- return node.width;
- }
- BI.each(node.getChildren(), function (i, child) {
- w += track1(child);
- });
- return w;
- }
-
- function track2(node) {
- var w = 0;
- if (node.isLeaf()) {
- return node.height;
- }
- BI.each(node.getChildren(), function (i, child) {
- w += track2(child);
- });
- return w;
- }
-
- if (this._isVertical()) {
- width = track1(this.tree.getRoot());
- } else {
- width = track2(this.tree.getRoot());
- }
-
- return width;
- },
-
- _isVertical: function () {
- var o = this.options;
- return o.direction === BI.Direction.Top || o.direction === BI.Direction.Bottom;
- },
-
- _calculateHeight: function () {
- var o = this.options;
- var height = 0;
-
- function track1(node) {
- var h = 0;
- BI.each(node.getChildren(), function (i, child) {
- h = Math.max(h, track1(child));
- });
- return h + (node.height || 0);
- }
-
- function track2(node) {
- var h = 0;
- BI.each(node.getChildren(), function (i, child) {
- h = Math.max(h, track2(child));
- });
- return h + (node.width || 0);
- }
-
- if (this._isVertical()) {
- height = track1(this.tree.getRoot());
- } else {
- height = track2(this.tree.getRoot());
- }
- return height;
- },
-
- _calculateXY: function (levels) {
- var o = this.options;
- var width = this._calculateWidth();
- var height = this._calculateHeight();
- var levelCount = levels.length;
- var allLeavesCount = this._calculateLeaves();
- //计算坐标
- var xy = {};
- var levelHeight = height / levelCount;
- BI.each(levels, function (i, nodes) {
- //计算权重
- var weights = [];
- BI.each(nodes, function (j, node) {
- weights[j] = (node.get("leaves") || 1) / allLeavesCount;
- });
- BI.each(nodes, function (j, node) {
- //求前j个元素的权重
- var weight = BI.sum(weights.slice(0, j));
- //求坐标
- var x = weight * width + weights[j] * width / 2;
- var y = i * levelHeight + levelHeight / 2;
- xy[node.id] = {x: x, y: y};
- })
- });
- return xy;
- },
-
- _stroke: function (levels, xy) {
- var height = this._calculateHeight();
- var levelCount = levels.length;
- var levelHeight = height / levelCount;
- var self = this, o = this.options;
- switch (o.direction) {
- case BI.Direction.Top:
- BI.each(levels, function (i, nodes) {
- BI.each(nodes, function (j, node) {
- if (node.getChildrenLength() > 0 && !node.leaf) {
- var path = "";
- var start = xy[node.id];
- var split = start.y + levelHeight / 2;
- path += "M" + start.x + "," + (start.y + o.centerOffset) + "L" + start.x + "," + split;
- var end = [];
- BI.each(node.getChildren(), function (t, c) {
- var e = end[t] = xy[c.id];
- path += "M" + e.x + "," + (e.y + o.centerOffset) + "L" + e.x + "," + split;
- });
- if (end.length > 0) {
- path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split;
- }
- self.svg.path(path).attr("stroke", "#d4dadd");
- }
- })
- });
- break;
- case BI.Direction.Bottom:
- BI.each(levels, function (i, nodes) {
- BI.each(nodes, function (j, node) {
- if (node.getChildrenLength() > 0 && !node.leaf) {
- var path = "";
- var start = xy[node.id];
- var split = start.y - levelHeight / 2;
- path += "M" + start.x + "," + (start.y - o.centerOffset) + "L" + start.x + "," + split;
- var end = [];
- BI.each(node.getChildren(), function (t, c) {
- var e = end[t] = xy[c.id];
- path += "M" + e.x + "," + (e.y - o.centerOffset) + "L" + e.x + "," + split;
- });
- if (end.length > 0) {
- path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split;
- }
- self.svg.path(path).attr("stroke", "#d4dadd");
- }
- })
- });
- break;
- case BI.Direction.Left:
- BI.each(levels, function (i, nodes) {
- BI.each(nodes, function (j, node) {
- if (node.getChildrenLength() > 0 && !node.leaf) {
- var path = "";
- var start = xy[node.id];
- var split = start.y + levelHeight / 2;
- path += "M" + (start.y + o.centerOffset) + "," + start.x + "L" + split + "," + start.x;
- var end = [];
- BI.each(node.getChildren(), function (t, c) {
- var e = end[t] = xy[c.id];
- path += "M" + (e.y + o.centerOffset) + "," + e.x + "L" + split + "," + e.x;
- });
- if (end.length > 0) {
- path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x;
- }
- self.svg.path(path).attr("stroke", "#d4dadd");
- }
- })
- });
- break;
- case BI.Direction.Right:
- BI.each(levels, function (i, nodes) {
- BI.each(nodes, function (j, node) {
- if (node.getChildrenLength() > 0 && !node.leaf) {
- var path = "";
- var start = xy[node.id];
- var split = start.y - levelHeight / 2;
- path += "M" + (start.y - o.centerOffset) + "," + start.x + "L" + split + "," + start.x;
- var end = [];
- BI.each(node.getChildren(), function (t, c) {
- var e = end[t] = xy[c.id];
- path += "M" + (e.y - o.centerOffset) + "," + e.x + "L" + split + "," + e.x;
- });
- if (end.length > 0) {
- path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x;
- }
- self.svg.path(path).attr("stroke", "#d4dadd");
- }
- })
- });
- break;
- }
- },
-
- _createBranches: function (levels) {
- var self = this, o = this.options;
- if (o.direction === BI.Direction.Bottom || o.direction === BI.Direction.Right) {
- levels = levels.reverse();
- }
- var xy = this._calculateXY(levels);
- //画图
- this._stroke(levels, xy);
- },
-
- _isNeedAdjust: function () {
- var o = this.options;
- return o.direction === BI.Direction.Top && o.align === BI.VerticalAlign.Bottom || o.direction === BI.Direction.Bottom && o.align === BI.VerticalAlign.Top
- || o.direction === BI.Direction.Left && o.align === BI.HorizontalAlign.Right || o.direction === BI.Direction.Right && o.align === BI.HorizontalAlign.Left
- },
-
- setValue: function (value) {
-
- },
-
- getValue: function () {
-
- },
-
- _transformToTreeFormat: function (sNodes) {
- var i, l;
- if (!sNodes) {
- return [];
- }
-
- if (BI.isArray(sNodes)) {
- var r = [];
- var tmpMap = [];
- for (i = 0, l = sNodes.length; i < l; i++) {
- tmpMap[sNodes[i].id] = sNodes[i];
- }
- for (i = 0, l = sNodes.length; i < l; i++) {
- if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) {
- if (!tmpMap[sNodes[i].pId].children) {
- tmpMap[sNodes[i].pId].children = [];
- }
- tmpMap[sNodes[i].pId].children.push(sNodes[i]);
- } else {
- r.push(sNodes[i]);
- }
- }
- return r;
- } else {
- return [sNodes];
- }
- },
-
- populate: function (items) {
- var self = this, o = this.options;
- o.items = items || [];
- this.empty();
- items = this._transformToTreeFormat(o.items);
- this.tree = new BI.Tree();
- this.tree.initTree(items);
-
- this.svg = BI.createWidget({
- type: "bi.svg"
- });
-
- //树分层
- var levels = this._stratification();
-
- if (this._isNeedAdjust()) {
- //树平移
- var adjust = this._translate(levels);
- //树调整
- adjust = this._adjust(adjust);
-
- this._createBranches(adjust);
- } else {
- var adjust = this._fill(levels);
-
- this._createBranches(adjust);
- }
-
- var container = BI.createWidget({
- type: "bi.layout",
- width: this._isVertical() ? this._calculateWidth() : this._calculateHeight(),
- height: this._isVertical() ? this._calculateHeight() : this._calculateWidth()
- });
- BI.createWidget({
- type: "bi.absolute",
- element: container,
- items: [{
- el: this.svg,
- top: 0,
- left: 0,
- right: 0,
- bottom: 0
- }]
- });
- if (this._isVertical()) {
- items = [{
- type: "bi.handstand_branch_tree",
- expander: {
- direction: o.direction
- },
- el: {
- layouts: [{
- type: "bi.horizontal_adapt",
- verticalAlign: o.align
- }]
- },
- items: items
- }]
- } else {
- items = [{
- type: "bi.branch_tree",
- expander: {
- direction: o.direction
- },
- el: {
- layouts: [{
- type: "bi.vertical"
- }, {
- type: o.align === BI.HorizontalAlign.Left ? "bi.left" : "bi.right"
- }]
- },
- items: items
- }]
- }
- BI.createWidget({
- type: "bi.adaptive",
- element: container,
- items: items
- });
- BI.createWidget({
- type: "bi.center_adapt",
- scrollable: true,
- element: this,
- items: [container]
- });
- }
-});
-BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE";
-BI.shortcut("bi.branch_relation", BI.BranchRelation);/**
- * 日期控件中的月份下拉框
- *
- * Created by GUY on 2015/9/7.
- * @class BI.MonthDateCombo
- * @extends BI.Trigger
- */
-BI.MonthDateCombo = BI.inherit(BI.Trigger, {
- _defaultConfig: function() {
- return BI.extend( BI.MonthDateCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-month-combo",
- height: 25
- });
- },
- _init: function() {
- BI.MonthDateCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.date_triangle_trigger"
- });
-
- this.popup = BI.createWidget({
- type: "bi.month_popup"
- });
-
- this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){
- self.setValue(self.popup.getValue());
- })
-
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- offsetStyle: "center",
- element: this,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- minWidth: 85,
- stopPropagation: false,
- el: this.popup
- }
- })
- this.combo.on(BI.Combo.EVENT_CHANGE, function(){
- self.combo.hideView();
- self.fireEvent(BI.MonthDateCombo.EVENT_CHANGE);
- });
- },
-
- setValue: function(v){
- this.trigger.setValue(v + 1);
- this.popup.setValue(v);
- },
-
- getValue: function(){
- return this.popup.getValue();
- }
-});
-BI.MonthDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.month_date_combo', BI.MonthDateCombo);/**
- * 年份下拉框
- *
- * Created by GUY on 2015/9/7.
- * @class BI.YearDateCombo
- * @extends BI.Trigger
- */
-BI.YearDateCombo = BI.inherit(BI.Trigger, {
- _defaultConfig: function() {
- return BI.extend( BI.YearDateCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-year-combo",
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- height: 25
- });
- },
- _init: function() {
- BI.YearDateCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.date_triangle_trigger"
- });
-
- this.popup = BI.createWidget({
- type: "bi.year_popup",
- min: o.min,
- max: o.max
- });
-
- this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.YearDateCombo.EVENT_CHANGE);
- })
-
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- offsetStyle: "center",
- element: this,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- minWidth: 85,
- stopPropagation: false,
- el: this.popup
- }
- })
- this.combo.on(BI.Combo.EVENT_CHANGE, function(){
- self.fireEvent(BI.YearDateCombo.EVENT_CHANGE);
- })
- },
-
- setValue: function(v){
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function(){
- return this.popup.getValue();
- }
-});
-BI.YearDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.year_date_combo', BI.YearDateCombo);/**
- * Created by GUY on 2015/9/7.
- * @class BI.DatePicker
- * @extends BI.Widget
- */
-BI.DatePicker = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: "bi-date-picker bi-background",
- height: 25,
- min: '1900-01-01', //最小日期
- max: '2099-12-31' //最大日期
- })
- },
-
- _init: function () {
- BI.DatePicker.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this._year = new Date().getFullYear();
- this._month = new Date().getMonth();
- this.left = BI.createWidget({
- type: "bi.icon_button",
- cls: "pre-page-h-font",
- width: 25,
- height: 25
- });
- this.left.on(BI.IconButton.EVENT_CHANGE, function () {
- if (self._month === 0) {
- self.setValue({
- year: self.year.getValue() - 1,
- month: 11
- })
- } else {
- self.setValue({
- year: self.year.getValue(),
- month: self.month.getValue() - 1
- })
- }
- self.fireEvent(BI.DatePicker.EVENT_CHANGE);
- });
-
- this.right = BI.createWidget({
- type: "bi.icon_button",
- cls: "next-page-h-font",
- width: 25,
- height: 25
- });
-
- this.right.on(BI.IconButton.EVENT_CHANGE, function () {
- if (self._month === 11) {
- self.setValue({
- year: self.year.getValue() + 1,
- month: 0
- })
- } else {
- self.setValue({
- year: self.year.getValue(),
- month: self.month.getValue() + 1
- })
- }
- self.fireEvent(BI.DatePicker.EVENT_CHANGE);
- });
-
- this.year = BI.createWidget({
- type: "bi.year_date_combo",
- min: o.min,
- max: o.max
- });
- this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () {
- self.setValue({
- year: self.year.getValue(),
- month: self.month.getValue()
- });
- self.fireEvent(BI.DatePicker.EVENT_CHANGE);
- })
- this.month = BI.createWidget({
- type: "bi.month_date_combo"
- });
- this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () {
- self.setValue({
- year: self.year.getValue(),
- month: self.month.getValue()
- });
- self.fireEvent(BI.DatePicker.EVENT_CHANGE);
- });
-
- BI.createWidget({
- type: "bi.htape",
- element: this,
- items: [{
- el: this.left,
- width: 25
- }, {
- type: "bi.center_adapt",
- items: [{
- type: "bi.horizontal",
- width: 100,
- items: [this.year, this.month]
- }]
- }, {
- el: this.right,
- width: 25
- }]
- })
- this.setValue({
- year: this._year,
- month: this._month
- })
- },
-
- setValue: function (ob) {
- this._year = ob.year;
- this._month = ob.month;
- this.year.setValue(ob.year);
- this.month.setValue(ob.month);
- },
-
- getValue: function () {
- return {
- year: this.year.getValue(),
- month: this.month.getValue()
- }
- }
-});
-BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE"
-BI.shortcut("bi.date_picker", BI.DatePicker);/**
- * Created by GUY on 2015/9/7.
- * @class BI.DateCalendarPopup
- * @extends BI.Widget
- */
-BI.DateCalendarPopup = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: "bi-date-calendar-popup",
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- selectedTime: null
- })
- },
-
- _createNav: function (v) {
- var date = BI.Calendar.getDateJSONByPage(v);
- var calendar = BI.createWidget({
- type: "bi.calendar",
- logic: {
- dynamic: true
- },
- min: this.options.min,
- max: this.options.max,
- year: date.year,
- month: date.month,
- day: this.selectedTime.day
- });
- return calendar;
- },
-
- _init: function () {
- BI.DateCalendarPopup.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.today = new Date();
- this._year = this.today.getFullYear();
- this._month = this.today.getMonth();
- this._day = this.today.getDate();
-
- this.selectedTime = o.selectedTime || {
- year: this._year,
- month: this._month,
- day: this._day
- };
- this.datePicker = BI.createWidget({
- type: "bi.date_picker",
- min: o.min,
- max: o.max
- });
-
- this.calendar = BI.createWidget({
- direction: "top",
- element: this,
- logic: {
- dynamic: true
- },
- type: "bi.navigation",
- tab: this.datePicker,
- cardCreator: BI.bind(this._createNav, this),
-
- afterCardCreated: function () {
-
- },
-
- afterCardShow: function () {
- this.setValue(self.selectedTime);
- }
- });
-
- this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
- self.selectedTime = self.datePicker.getValue();
- self.selectedTime.day = 1;
- self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
- });
-
- this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
- self.selectedTime = self.calendar.getValue();
- self.setValue(self.selectedTime);
- self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
- });
- },
-
- setValue: function (timeOb) {
- this.datePicker.setValue(timeOb);
- this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb));
- this.calendar.setValue(timeOb);
- this.selectedTime = timeOb;
- },
-
- getValue: function () {
- return this.selectedTime;
- }
-});
-BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);/**
- * 日期控件中的年份或月份trigger
- *
- * Created by GUY on 2015/9/7.
- * @class BI.DateTriangleTrigger
- * @extends BI.Trigger
- */
-BI.DateTriangleTrigger = BI.inherit(BI.Trigger, {
- _const: {
- height: 25,
- iconWidth: 16,
- iconHeight: 13
- },
-
- _defaultConfig: function() {
- return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer",
- height: 25
- });
- },
- _init: function() {
- BI.DateTriangleTrigger.superclass._init.apply(this, arguments);
- var o = this.options, c = this._const;
- this.text = BI.createWidget({
- type: "bi.label",
- cls: "list-item-text",
- textAlign: "right",
- text: o.text,
- value: o.value,
- height: c.height
- })
- this.icon = BI.createWidget({
- type: "bi.icon",
- width: c.iconWidth,
- height: c.iconHeight
- });
-
- BI.createWidget({
- type: "bi.center_adapt",
- element: this,
- items: [{
- type: "bi.center_adapt",
- width: 50,
- height: c.height,
- items: [this.text, this.icon]
- }]
- })
- },
-
- setValue: function(v){
- this.text.setValue(v);
- },
-
- getValue: function(){
- return this.text.getValue();
- },
-
- setText: function(v){
- this.text.setText(v);
- },
-
- getText: function(){
- return this.item.getText();
- },
-
- getKey: function(){
-
- }
-});
-BI.shortcut('bi.date_triangle_trigger', BI.DateTriangleTrigger);/**
- * 日期下拉框
- *
- * Created by GUY on 2015/9/7.
- * @class BI.DateCombo
- * @extends BI.Widget
- */
-BI.DateCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-date-combo bi-border",
- height: 30
- });
- },
- _init: function () {
- BI.DateCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.date_trigger"
- });
-
- this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
- self.combo.toggle();
- });
-
- this.popup = BI.createWidget({
- type: "bi.date_calendar_popup"
- });
-
- this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- toggle: false,
- element: this,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- width: 270,
- el: this.popup,
- stopPropagation: false
- }
- })
- },
-
- setValue: function (v) {
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- }
-});
-BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, {
- _const: {
- hgap: 4,
- vgap: 2,
- triggerWidth: 30,
- yearLength: 4,
- yearMonthLength: 7
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-date-trigger",
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- height: 25
- });
- },
- _init: function () {
- BI.DateTrigger.superclass._init.apply(this, arguments);
- var self = this, o = this.options, c = this._const;
- this.editor = BI.createWidget({
- type: "bi.sign_editor",
- height: o.height,
- validationChecker: function (v) {
- var date = v.match(/\d+/g);
- self._autoAppend(v, date);
- return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({
- year: date[0],
- month: date[1],
- day: date[2]
- });
- },
- quitChecker: function () {
- return false;
- },
- hgap: c.hgap,
- vgap: c.vgap,
- allowBlank: true,
- watermark: BI.i18nText("BI-Basic_Unrestricted"),
- errorText: function () {
- if (self.editor.isEditing()) {
- return BI.i18nText("BI-Date_Trigger_Error_Text");
- }
- return BI.i18nText("BI-Year_Trigger_Invalid_Text");
- }
- });
- this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
- self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN)
- });
- this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
- self.fireEvent(BI.DateTrigger.EVENT_FOCUS);
- });
- this.editor.on(BI.SignEditor.EVENT_STOP, function () {
- self.fireEvent(BI.DateTrigger.EVENT_STOP);
- });
- this.editor.on(BI.SignEditor.EVENT_VALID, function () {
- self.fireEvent(BI.DateTrigger.EVENT_VALID);
- });
- this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
- self.fireEvent(BI.DateTrigger.EVENT_ERROR);
- });
- this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
- var value = self.editor.getValue();
- if (BI.isNotNull(value)) {
- self.editor.setState(value);
- }
-
- if (BI.isNotEmptyString(value)) {
- var date = value.split("-");
- self.store_value = {
- type: BI.DateTrigger.MULTI_DATE_CALENDAR,
- value:{
- year: date[0] | 0,
- month: date[1] - 1,
- day: date[2] | 0
- }
- };
- }
- self.fireEvent(BI.DateTrigger.EVENT_CONFIRM);
- });
- this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
- if (self.editor.isValid()) {
- self.editor.blur();
- }
- });
- this.editor.on(BI.SignEditor.EVENT_START, function () {
- self.fireEvent(BI.DateTrigger.EVENT_START);
- });
- this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
- self.fireEvent(BI.DateTrigger.EVENT_CHANGE);
- });
- BI.createWidget({
- type: "bi.htape",
- element: this,
- items: [{
- el: BI.createWidget(),
- width: 30
- }, {
- el: this.editor
- }]
- })
- },
- _dateCheck: function (date) {
- return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date;
- },
- _checkVoid: function (obj) {
- return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0];
- },
- _autoAppend: function (v, dateObj) {
- var self = this;
- var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d");
- var yearCheck = function (v) {
- return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max;
- };
- var monthCheck = function (v) {
- return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max;
- };
- if (BI.isNotNull(dateObj) && Date.checkLegal(v)) {
- switch (v.length) {
- case this._const.yearLength:
- if (yearCheck(v)) {
- this.editor.setValue(v + "-");
- }
- break;
- case this._const.yearMonthLength:
- if (monthCheck(v)) {
- this.editor.setValue(v + "-");
- }
- break;
- }
- }
- },
-
- setValue: function (v) {
- var type, value, self = this;
- var date = new Date();
- this.store_value = v;
- if (BI.isNotNull(v)) {
- type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value;
- if(BI.isNull(value)){
- value = v;
- }
- }
- var _setInnerValue = function (date, text) {
- var dateStr = date.print("%Y-%x-%e");
- self.editor.setState(dateStr);
- self.editor.setValue(dateStr);
- self.setTitle(text + ":" + dateStr);
- };
- switch (type) {
- case BI.DateTrigger.MULTI_DATE_YEAR_PREV:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];
- date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate());
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];
- date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate());
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];
- date = new Date(date.getFullYear(), 0, 1);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_YEAR_END:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];
- date = new Date(date.getFullYear(), 11, 31);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];
- date = new Date().getBeforeMulQuarter(value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];
- date = new Date().getAfterMulQuarter(value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];
- date = new Date().getQuarterStartDate();
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_QUARTER_END:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];
- date = new Date().getQuarterEndDate();
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_MONTH_PREV:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];
- date = new Date().getBeforeMultiMonth(value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];
- date = new Date().getAfterMultiMonth(value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];
- date = new Date(date.getFullYear(), date.getMonth(), 1);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_MONTH_END:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];
- date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate());
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_WEEK_PREV:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];
- date = date.getOffsetDate(-7 * value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];
- date = date.getOffsetDate(7 * value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_DAY_PREV:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];
- date = date.getOffsetDate(-1 * value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_DAY_AFTER:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];
- date = date.getOffsetDate(1 * value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_DAY_TODAY:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];
- date = new Date();
- _setInnerValue(date, text);
- break;
- default:
- if (BI.isNull(value) || BI.isNull(value.day)) {
- this.editor.setState("");
- this.editor.setValue("");
- this.setTitle("");
- } else {
- var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day;
- this.editor.setState(dateStr);
- this.editor.setValue(dateStr);
- this.setTitle(dateStr);
- }
- break;
- }
- },
-
- getKey: function () {
- return this.editor.getValue();
- },
- getValue: function () {
- return this.store_value;
- }
-
-});
-
-BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1;
-BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2;
-BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3;
-BI.DateTrigger.MULTI_DATE_YEAR_END = 4;
-
-BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5;
-BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6;
-BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7;
-BI.DateTrigger.MULTI_DATE_MONTH_END = 8;
-
-BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9;
-BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10;
-BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11;
-BI.DateTrigger.MULTI_DATE_QUARTER_END = 12;
-
-BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13;
-BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14;
-
-BI.DateTrigger.MULTI_DATE_DAY_PREV = 15;
-BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16;
-BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17;
-
-BI.DateTrigger.MULTI_DATE_PARAM = 18;
-BI.DateTrigger.MULTI_DATE_CALENDAR = 19;
-
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {};
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End");
-
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End");
-
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End");
-
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next");
-
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today");
-
-BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
-BI.DateTrigger.EVENT_START = "EVENT_START";
-BI.DateTrigger.EVENT_STOP = "EVENT_STOP";
-BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
-BI.DateTrigger.EVENT_VALID = "EVENT_VALID";
-BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR";
-BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
-BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
-BI.shortcut("bi.date_trigger", BI.DateTrigger);/**
- * Created by zcf on 2017/2/20.
- */
-BI.DatePaneWidget = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: "bi-date-pane-widget",
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- selectedTime: null
- })
- },
- _init: function () {
- BI.DatePaneWidget.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.today = new Date();
- this._year = this.today.getFullYear();
- this._month = this.today.getMonth();
-
- this.selectedTime = o.selectedTime || {
- year: this._year,
- month: this._month
- };
-
- this.datePicker = BI.createWidget({
- type: "bi.date_picker",
- min: o.min,
- max: o.max
- });
- this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
- self.selectedTime = self.datePicker.getValue();
- // self.selectedTime.day = 1;
- self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
- });
-
- this.calendar = BI.createWidget({
- direction: "top",
- element: this,
- logic: {
- dynamic: false
- },
- type: "bi.navigation",
- tab: this.datePicker,
- cardCreator: BI.bind(this._createNav, this)
-
- // afterCardCreated: function () {
- //
- // },
- //
- // afterCardShow: function () {
- // // this.setValue(self.selectedTime);
- // }
- });
- this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
- self.selectedTime = self.calendar.getValue();
- self.calendar.empty();
- self.setValue(self.selectedTime);
- self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
- });
-
- },
-
- _createNav: function (v) {
- var date = BI.Calendar.getDateJSONByPage(v);
- var calendar = BI.createWidget({
- type: "bi.calendar",
- logic: {
- dynamic: false
- },
- min: this.options.min,
- max: this.options.max,
- year: date.year,
- month: date.month,
- day: this.selectedTime.day
- });
- return calendar;
- },
-
- _getNewCurrentDate: function () {
- var today = new Date();
- return {
- year: today.getFullYear(),
- month: today.getMonth()
- }
- },
-
- _setCalenderValue: function (date) {
- this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date));
- this.calendar.setValue(date);
- this.selectedTime = date;
- },
-
- _setDatePicker: function (timeOb) {
- if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) {
- this.datePicker.setValue(this._getNewCurrentDate());
- } else {
- this.datePicker.setValue(timeOb);
- }
- },
-
- _setCalendar: function (timeOb) {
- if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) {
- this.calendar.empty();
- this._setCalenderValue(this._getNewCurrentDate());
- } else {
- this._setCalenderValue(timeOb)
- }
- },
-
- setValue: function (timeOb) {
- this._setDatePicker(timeOb);
- this._setCalendar(timeOb);
- },
-
- getValue: function () {
- return this.selectedTime;
- }
-
-});
-BI.shortcut("bi.date_pane_widget", BI.DatePaneWidget);/**
- * 带有方向的pathchooser
- *
- * Created by GUY on 2016/4/21.
- * @class BI.DirectionPathChooser
- * @extends BI.Widget
- */
-BI.DirectionPathChooser = BI.inherit(BI.Widget, {
-
- _const: {
- lineColor: "#808080",
- selectLineColor: "#009de3"
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.DirectionPathChooser.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-excel-table",
- items: []
- });
- },
-
- _init: function () {
- BI.DirectionPathChooser.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.pathChooser = BI.createWidget({
- type: "bi.path_chooser",
- element: this,
- items: o.items
- });
- this.pathChooser.on(BI.PathChooser.EVENT_CHANGE, function (start, index) {
- //self._unselectAllArrows();
- self._setValue(start, index);
- self.fireEvent(BI.DirectionPathChooser.EVENT_CHANGE);
- });
- this._drawArrows();
-
- },
-
- _unselectAllArrows: function () {
- var self = this, lineColor = this._const.lineColor;
- BI.each(this.arrows, function (region, rs) {
- BI.each(rs, function (idx, arrows) {
- BI.each(arrows, function (i, arrow) {
- arrow.attr({fill: lineColor, stroke: lineColor});
- });
- });
- });
- },
-
- _drawOneArrow: function (dot, direction) {
- //0,1,2,3 上右下左
- var lineColor = this._const.lineColor;
- var selectLineColor = this._const.selectLineColor;
- var svg = this.pathChooser.svg;
- var path = "";
- switch (direction) {
- case 0:
- path = "M" + dot.x + "," + dot.y
- + "L" + (dot.x - 3) + "," + (dot.y + 5)
- + "L" + (dot.x + 3) + "," + (dot.y + 5)
- + "L" + dot.x + "," + dot.y;
- break;
- case 1:
- path = "M" + dot.x + "," + dot.y
- + "L" + (dot.x - 5) + "," + (dot.y - 3)
- + "L" + (dot.x - 5) + "," + (dot.y + 3)
- + "L" + dot.x + "," + dot.y;
- break;
- case 2:
- path = "M" + dot.x + "," + dot.y
- + "L" + (dot.x - 3) + "," + (dot.y - 5)
- + "L" + (dot.x + 3) + "," + (dot.y - 5)
- + "L" + dot.x + "," + dot.y;
- break;
- case 3:
- path = "M" + dot.x + "," + dot.y
- + "L" + (dot.x + 5) + "," + (dot.y - 3)
- + "L" + (dot.x + 5) + "," + (dot.y + 3)
- + "L" + dot.x + "," + dot.y;
- break;
- }
- return svg.path(path).attr({fill: lineColor, stroke: lineColor});
- },
-
- _drawArrows: function () {
- var self = this, o = this.options;
- var routes = this.pathChooser.routes;
- var pathes = this.pathChooser.pathes;
- var store = this.pathChooser.store;
- this.arrows = {};
- BI.each(routes, function (region, ps) {
- self.arrows[region] = [];
- BI.each(ps, function (idx, path) {
- self.arrows[region][idx] = [];
- var dots = pathes[region][idx];
- BI.each(dots, function (i, dot) {
- if (i > 0 && i < dots.length - 1) {
- var arrow;
- if (dot.y === dots[i - 1].y) {
- if (dots[i + 1].y != dot.y) {
- if (store[path[path.length - 2]].direction === -1) {
- if (i - 1 > 0) {
- arrow = self._drawOneArrow(dots[i - 1], 3);
- }
- } else {
- arrow = self._drawOneArrow(dots[i], 1);
- }
- }
- } else if (dot.x === dots[i - 1].x) {
- if (dot.y > dots[i - 1].y) {
- if (store[BI.first(path)].direction === -1) {
- arrow = self._drawOneArrow(dots[i - 1], 0);
- } else {
- arrow = self._drawOneArrow(dot, 2);
- }
- } else {
- if (store[path[path.length - 2]].direction === -1) {
- arrow = self._drawOneArrow(dots[i - 1], 2);
- } else {
- arrow = self._drawOneArrow(dot, 0);
- }
- }
- }
- if (arrow) {
- self.arrows[region][idx].push(arrow);
- }
- }
- });
- BI.each(path, function (i, node) {
- if (i !== 0) {
- var arrow;
- var from = path[i - 1];
- if (store[from].direction === -1) {
- var regionIndex = self.pathChooser.getRegionIndexById(from);
- var x = getXoffsetByRegionIndex(regionIndex, -1);
- var y = getYByXoffset(dots, x);
- arrow = self._drawOneArrow({x: x, y: y}, 3);
- } else {
- var regionIndex = self.pathChooser.getRegionIndexById(node);
- var x = getXoffsetByRegionIndex(regionIndex);
- var y = getYByXoffset(dots, x);
- arrow = self._drawOneArrow({x: x, y: y}, 1);
- }
- if (arrow) {
- self.arrows[region][idx].push(arrow);
- }
- }
- });
- })
- });
-
- function getXoffsetByRegionIndex(regionIndex, diregion) {
- if (diregion === -1) {
- return 100 * (regionIndex + 1) - 20;
- }
- return 100 * regionIndex + 20;
- }
-
- function getYByXoffset(dots, xoffset) {
- var finded = BI.find(dots, function (i, dot) {
- if (i > 0) {
- if (dots[i - 1].x < xoffset && dots[i].x > xoffset) {
- return true;
- }
- }
- });
- return finded.y;
- }
- },
-
- _setValue: function (start, index) {
- var self = this;
- var lineColor = this._const.lineColor;
- var selectLineColor = this._const.selectLineColor;
- var routes = this.pathChooser.routes;
- var starts = this.pathChooser.start;
- var each = [start];
- if (starts.contains(start)) {
- each = starts;
- }
- BI.each(each, function (i, s) {
- BI.each(self.arrows[s], function (j, arrows) {
- BI.each(arrows, function (k, arrow) {
- arrow.attr({fill: lineColor, stroke: lineColor}).toFront();
- });
- });
- });
- BI.each(this.arrows[start][index], function (i, arrow) {
- arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront();
- });
- var current = BI.last(routes[start][index]);
- while (current && routes[current] && routes[current].length === 1) {
- BI.each(self.arrows[current][0], function (i, arrow) {
- arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront();
- });
- current = BI.last(routes[current][0]);
- }
- },
-
- setValue: function (v) {
- this.pathChooser.setValue(v);
- this._unselectAllArrows();
- var routes = this.pathChooser.routes;
- var nodes = BI.keys(routes), self = this;
- var result = [], array = [];
- BI.each(v, function (i, val) {
- if (BI.contains(nodes, val)) {
- if (array.length > 0) {
- array.push(val);
- result.push(array);
- array = [];
- }
- }
- array.push(val);
- });
- if (array.length > 0) {
- result.push(array);
- }
- //画这n条路径
- BI.each(result, function (idx, path) {
- var start = path[0];
- var index = BI.findIndex(routes[start], function (idx, p) {
- if (BI.isEqual(path, p)) {
- return true;
- }
- });
- if (index >= 0) {
- self._setValue(start, index);
- }
- });
- },
-
- getValue: function () {
- return this.pathChooser.getValue();
- },
-
- populate: function (items) {
- this.pathChooser.populate(items);
- this._drawArrows();
- }
-});
-BI.DirectionPathChooser.EVENT_CHANGE = "DirectionPathChooser.EVENT_CHANGE";
-BI.shortcut('bi.direction_path_chooser', BI.DirectionPathChooser);/**
- * Created by roy on 15/8/14.
- */
-BI.DownListCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-down-list-combo",
- invalid: false,
- height: 25,
- items: [],
- adjustLength: 0,
- direction: "bottom",
- trigger: "click",
- el: {}
- })
- },
-
- _init: function () {
- BI.DownListCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.popupview = BI.createWidget({
- type: "bi.down_list_popup",
- items: o.items,
- chooseType: o.chooseType
- });
-
- this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) {
- self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
- self.downlistcombo.hideView();
- });
-
- this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
- self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
- self.downlistcombo.hideView();
- });
-
-
- this.downlistcombo = BI.createWidget({
- element: this,
- type: 'bi.combo',
- trigger: o.trigger,
- isNeedAdjustWidth: false,
- adjustLength: o.adjustLength,
- direction: o.direction,
- el: BI.createWidget(o.el, {
- type: "bi.icon_trigger",
- extraCls: o.iconCls ? o.iconCls : "pull-down-font",
- width: o.width,
- height: o.height
- }),
- popup: {
- el: this.popupview,
- stopPropagation: true,
- maxHeight: 1000
- }
- });
-
- this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
- });
- },
-
- hideView: function () {
- this.downlistcombo.hideView();
- },
-
- showView: function () {
- this.downlistcombo.showView();
- },
-
- populate: function (items) {
- this.popupview.populate(items);
- },
-
- setValue: function (v) {
- this.popupview.setValue(v);
- },
- getValue: function () {
- return this.popupview.getValue()
- }
-});
-BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
-BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-
-BI.shortcut("bi.down_list_combo", BI.DownListCombo);/**
- * Created by roy on 15/9/6.
- */
-BI.DownListGroup = BI.inherit(BI.Widget, {
- constants: {
- iconCls: "check-mark-ha-font"
- },
- _defaultConfig: function () {
- return BI.extend(BI.DownListGroup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-down-list-group",
- items: [
- {
- el: {}
- }
- ]
- })
- },
- _init: function () {
- BI.DownListGroup.superclass._init.apply(this, arguments);
- var o = this.options, self = this;
-
- this.downlistgroup = BI.createWidget({
- element: this,
- type: "bi.button_tree",
- items: o.items,
- chooseType: 0,//0单选,1多选
- layouts: [{
- type: "bi.vertical",
- hgap: 0,
- vgap: 0
- }]
- });
- this.downlistgroup.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if(type === BI.Events.CLICK) {
- self.fireEvent(BI.DownListGroup.EVENT_CHANGE, arguments);
- }
- })
- },
- getValue:function(){
- return this.downlistgroup.getValue();
- },
- setValue:function(v){
- this.downlistgroup.setValue(v);
- }
-
-
-})
-BI.DownListGroup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.down_list_group", BI.DownListGroup);BI.DownListItem = BI.inherit(BI.Single, {
- _defaultConfig: function () {
- var conf = BI.DownListItem.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: "bi-down-list-item bi-list-item-active",
- cls: "",
- height: 25,
- logic: {
- dynamic: true
- },
- selected: false,
- iconHeight: null,
- iconWidth: null,
- textHgap: 0,
- textVgap: 0,
- textLgap: 0,
- textRgap: 0
- })
- },
- _init: function () {
- BI.DownListItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.text = BI.createWidget({
- type: "bi.icon_text_item",
- element: this,
- height: o.height,
- text: o.text,
- value: o.value,
- logic: o.logic,
- selected: o.selected,
- disabled: o.disabled,
- iconHeight: o.iconHeight,
- iconWidth: o.iconWidth,
- textHgap: o.textHgap,
- textVgap: o.textVgap,
- textLgap: o.textLgap,
- textRgap: o.textRgap,
- father: o.father
- });
- this.text.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.text.on(BI.IconTextItem.EVENT_CHANGE, function () {
- self.fireEvent(BI.DownListItem.EVENT_CHANGE);
- });
- // this.setSelected(o.selected);
- },
-
- doRedMark: function () {
- this.text.doRedMark.apply(this.text, arguments);
- },
-
- unRedMark: function () {
- this.text.unRedMark.apply(this.text, arguments);
- },
-
- isSelected: function () {
- return this.text.isSelected();
- },
-
- setSelected: function (b) {
- this.text.setSelected(b);
- // if (b === true) {
- // this.element.addClass("dot-e-font");
- // } else {
- // this.element.removeClass("dot-e-font");
- // }
- },
-
- setValue: function (v) {
- this.text.setValue(v);
- },
-
- getValue: function () {
- return this.text.getValue();
- }
-});
-BI.DownListItem.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inherit(BI.BasicButton, {
- _defaultConfig: function () {
- var conf = BI.DownListGroupItem.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: (conf.baseCls || "") + " bi-down-list-group-item",
- logic: {
- dynamic: false
- },
- // invalid: true,
- iconCls1: "dot-e-font",
- iconCls2: "pull-right-e-font"
- })
- },
- _init: function () {
- BI.DownListGroupItem.superclass._init.apply(this, arguments);
- var o = this.options;
- var self = this;
- this.text = BI.createWidget({
- type: "bi.label",
- cls: "list-group-item-text",
- textAlign: "left",
- text: o.text,
- value: o.value,
- height: o.height
- });
-
- this.icon1 = BI.createWidget({
- type: "bi.icon_button",
- cls: o.iconCls1,
- width: 25,
- forceNotSelected: true
- });
-
- this.icon2 = BI.createWidget({
- type: "bi.icon_button",
- cls: o.iconCls2,
- width: 25,
- forceNotSelected: true
- });
-
- var blank = BI.createWidget({
- type: "bi.layout",
- width: 25
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.icon2,
- top: 0,
- bottom: 0,
- right: 0
- }]
- });
-
- BI.createWidget(BI.extend({
- element: this
- }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
- items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank)
- }))));
-
- this.element.hover(function () {
- if (self.isEnabled()) {
- self.hover();
- }
- }, function () {
- if (self.isEnabled()) {
- self.dishover()
- }
- });
- },
-
- hover: function () {
- BI.DownListGroupItem.superclass.hover.apply(this, arguments);
- this.icon1.element.addClass("hover");
- this.icon2.element.addClass("hover");
-
- },
-
- dishover: function () {
- BI.DownListGroupItem.superclass.dishover.apply(this, arguments);
- this.icon1.element.removeClass("hover");
- this.icon2.element.removeClass("hover");
- },
-
- doClick: function () {
- BI.DownListGroupItem.superclass.doClick.apply(this, arguments);
- if (this.isValid()) {
- this.fireEvent(BI.DownListGroupItem.EVENT_CHANGE, this.getValue());
- }
- },
-
- doRedMark: function () {
- this.text.doRedMark.apply(this.text, arguments);
- },
-
- unRedMark: function () {
- this.text.unRedMark.apply(this.text, arguments);
- },
-
- setValue: function (v) {
- var self = this, o = this.options;
- v = BI.isArray(v) ? v : [v];
- BI.find(v, function (idx, value) {
- if (BI.contains(o.childValues, value)) {
- self.icon1.setSelected(true);
- return true;
- } else {
- self.icon1.setSelected(false);
- }
- })
- }
-});
-BI.DownListGroupItem.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem);/**
- * Created by roy on 15/9/8.
- * 处理popup中的item分组样式
- * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项
- */
-BI.DownListPopup = BI.inherit(BI.Pane, {
- constants: {
- nextIcon: "pull-right-e-font",
- height: 25,
- iconHeight: 12,
- iconWidth: 12,
- hgap: 0,
- vgap: 0,
- border: 1
- },
- _defaultConfig: function () {
- var conf = BI.DownListPopup.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: "bi-down-list-popup",
- items: [],
- chooseType: BI.Selection.Multi
- })
- },
- _init: function () {
- BI.DownListPopup.superclass._init.apply(this, arguments);
- this.singleValues = [];
- this.childValueMap = {};
- this.fatherValueMap = {};
- var self = this, o = this.options, children = this._createChildren(o.items);
- this.popup = BI.createWidget({
- type: "bi.button_tree",
- items: BI.createItems(children,
- {}, {
- adjustLength: -2
- }
- ),
- layouts: [{
- type: "bi.vertical",
- hgap: this.constants.hgap,
- vgap: this.constants.vgap
- }],
- chooseType: o.chooseType
- });
-
- this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) {
- var changedValue = value;
- if (BI.isNotNull(self.childValueMap[value])) {
- changedValue = self.childValueMap[value];
- self.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, self.fatherValueMap[value])
- } else {
- self.fireEvent(BI.DownListPopup.EVENT_CHANGE, changedValue, object);
- }
-
-
- if (!self.singleValues.contains(changedValue)) {
- var item = self.getValue();
- var result = [];
- BI.each(item, function (i, valueObject) {
- if (valueObject.value != changedValue) {
- result.push(valueObject);
- }
- });
- self.setValue(result);
- }
-
- });
-
- BI.createWidget({
- type: "bi.vertical",
- element: this,
- items: [this.popup]
- });
-
- },
- _createChildren: function (items) {
- var self = this, result = [];
- BI.each(items, function (i, it) {
- var item_done = {
- type: "bi.down_list_group",
- items: []
- };
-
- BI.each(it, function (i, item) {
- if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) {
- item.type = "bi.combo_group";
- item.cls = "down-list-group";
- item.trigger = "hover";
- item.isNeedAdjustWidth = false;
- item.el.title = item.el.title || item.el.text;
- item.el.type = "bi.down_list_group_item";
- item.el.logic = {
- dynamic: true
- };
- item.el.height = self.constants.height;
- item.el.iconCls2 = self.constants.nextIcon;
- item.popup = {
- lgap: 4,
- el: {
- type: "bi.button_tree",
- chooseType: 0,
- layouts: [{
- type: "bi.vertical"
- }]
-
- }
- };
- item.el.childValues = [];
- BI.each(item.children, function (i, child) {
- var fatherValue = BI.deepClone(item.el.value);
- var childValue = BI.deepClone(child.value);
- self.singleValues.push(child.value);
- child.type = "bi.down_list_item";
- child.extraCls = " child-down-list-item";
- child.title = child.title || child.text;
- child.textRgap = 10;
- child.isNeedAdjustWidth = false;
- child.logic = {
- dynamic: true
- };
- child.father = fatherValue;
- self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
- self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
- child.value = self._createChildValue(fatherValue, childValue);
- item.el.childValues.push(child.value);
- })
- } else {
- item.type = "bi.down_list_item";
- item.title = item.title || item.text;
- item.textRgap = 10;
- item.isNeedAdjustWidth = false;
- item.logic = {
- dynamic: true
- }
- }
- var el_done = {};
- el_done.el = item;
- item_done.items.push(el_done);
- });
- if (self._isGroup(item_done.items)) {
- BI.each(item_done.items, function (i, item) {
- self.singleValues.push(item.el.value);
- })
- }
-
- result.push(item_done);
- if (self._needSpliter(i, items.length)) {
- var spliter_container = BI.createWidget({
- type: "bi.vertical",
- items: [{
- el: {
- type: "bi.layout",
- cls: "bi-down-list-spliter bi-border-top cursor-pointer",
- height: 0
- }
-
- }],
- cls: "bi-down-list-spliter-container cursor-pointer",
- lgap: 10,
- rgap: 10
- });
- result.push(spliter_container);
- }
- });
- return result;
- },
-
- _isGroup: function (i) {
- return i.length > 1;
- },
-
- _needSpliter: function (i, itemLength) {
- return i < itemLength - 1;
- },
-
- _createChildValue: function (fatherValue, childValue) {
- return fatherValue + "_" + childValue
- },
-
- populate: function (items) {
- BI.DownListPopup.superclass.populate.apply(this, arguments);
- var self = this;
- self.childValueMap = {};
- self.fatherValueMap = {};
- self.singleValues = [];
- var children = self._createChildren(items);
- var popupItem = BI.createItems(children,
- {}, {
- adjustLength: -2
- }
- );
- self.popup.populate(popupItem);
- },
-
- setValue: function (valueItem) {
- var self = this;
- var valueArray = [];
- BI.each(valueItem, function (i, item) {
- var value;
- if (BI.isNotNull(item.childValue)) {
- value = self._createChildValue(item.value, item.childValue);
- } else {
- value = item.value;
- }
- valueArray.push(value);
- }
- );
- this.popup.setValue(valueArray);
- },
-
- getValue: function () {
- var self = this, result = [];
- var values = this.popup.getValue();
- BI.each(values, function (i, value) {
- var valueItem = {};
- if (BI.isNotNull(self.childValueMap[value])) {
- var fartherValue = self.fatherValueMap[value];
- valueItem.childValue = self.childValueMap[value];
- valueItem.value = fartherValue;
- } else {
- valueItem.value = value;
- }
- result.push(valueItem);
- });
- return result;
- }
-
-
-});
-
-BI.DownListPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.DownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
-BI.shortcut("bi.down_list_popup", BI.DownListPopup);/**
- *
- * Created by GUY on 2016/3/28.
- * @class BI.ExcelTableCell
- * @extends BI.Widget
- */
-BI.ExcelTableCell = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ExcelTableCell.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-excel-table-cell",
- text: ""
- });
- },
-
- _init: function () {
- BI.ExcelTableCell.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- BI.createWidget({
- type: "bi.label",
- element: this,
- textAlign: "left",
- whiteSpace: "normal",
- height: this.options.height,
- text: this.options.text,
- value: this.options.value
- })
- }
-});
-BI.shortcut('bi.excel_table_cell', BI.ExcelTableCell);/**
- *
- * Created by GUY on 2016/3/28.
- * @class BI.ExcelTableHeaderCell
- * @extends BI.Widget
- */
-BI.ExcelTableHeaderCell = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ExcelTableHeaderCell.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-excel-table-header-cell bi-background",
- text: ""
- });
- },
-
- _init: function () {
- BI.ExcelTableHeaderCell.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- BI.createWidget({
- type: "bi.label",
- element: this,
- textAlign: BI.HorizontalAlign.Center,
- whiteSpace: "normal",
- height: this.options.height,
- text: this.options.text,
- value: this.options.value
- })
- }
-});
-BI.shortcut('bi.excel_table_header_cell', BI.ExcelTableHeaderCell);/**
- * Excel表格
- *
- * Created by GUY on 2016/3/28.
- * @class BI.ExcelTable
- * @extends BI.Widget
- */
-BI.ExcelTable = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-excel-table",
- el: {
- type: "bi.responsive_table"
- },
-
- isNeedResize: false,
- isResizeAdapt: true,
-
- isNeedMerge: false,//是否需要合并单元格
- mergeCols: [], //合并的单元格列号
- mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
- return BI.isEqual(row1, row2);
- },
-
- columnSize: [],
- headerRowSize: 37,
- footerRowSize: 37,
- rowSize: 37,
-
- regionColumnSize: false,
-
- items: [] //二维数组
- });
- },
-
- _init: function () {
- BI.ExcelTable.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- var mergeCols = [];
- BI.each(o.mergeCols, function (i, col) {
- mergeCols.push(col + 1);
- });
- this.table = BI.createWidget(o.el, {
- type: "bi.table_view",
- element: this,
-
- isNeedFreeze: false,
-
- isNeedMerge: o.isNeedMerge,
- mergeCols: mergeCols,
- mergeRule: o.mergeRule,
-
- columnSize: [""].concat(o.columnSize),
- headerRowSize: 18,
- rowSize: o.rowSize,
-
- regionColumnSize: o.regionColumnSize || [82, ""]
- });
-
- if (BI.isNotEmptyArray(o.items)) {
- this.populate(o.items);
- }
- BI.nextTick(function () {
- self.setRegionColumnSize(o.regionColumnSize || [82, ""]);
- });
- },
-
- resize: function () {
- this.table.resize();
- },
-
- setColumnSize: function (columnSize) {
- this.table.setColumnSize(columnSize);
- },
-
- getColumnSize: function () {
- return this.table.getColumnSize();
- },
-
- getCalculateColumnSize: function () {
- return this.table.getCalculateColumnSize();
- },
-
- setHeaderColumnSize: function (columnSize) {
- this.table.setHeaderColumnSize(columnSize);
- },
-
- setRegionColumnSize: function (columnSize) {
- this.table.setRegionColumnSize(columnSize);
- },
-
- getRegionColumnSize: function () {
- return this.table.getRegionColumnSize();
- },
-
- getCalculateRegionColumnSize: function () {
- return this.table.getCalculateRegionColumnSize();
- },
-
- getCalculateRegionRowSize: function () {
- return this.table.getCalculateRegionRowSize();
- },
-
- getClientRegionColumnSize: function () {
- return this.table.getClientRegionColumnSize();
- },
-
- getScrollRegionColumnSize: function () {
- return this.table.getScrollRegionColumnSize();
- },
-
- getScrollRegionRowSize: function () {
- return this.table.getScrollRegionRowSize();
- },
-
- hasVerticalScroll: function () {
- return this.table.hasVerticalScroll();
- },
-
- setVerticalScroll: function (scrollTop) {
- this.table.setVerticalScroll(scrollTop);
- },
-
- setLeftHorizontalScroll: function (scrollLeft) {
- this.table.setLeftHorizontalScroll(scrollLeft);
- },
-
- setRightHorizontalScroll: function (scrollLeft) {
- this.table.setRightHorizontalScroll(scrollLeft);
- },
-
- getVerticalScroll: function () {
- return this.table.getVerticalScroll();
- },
-
- getLeftHorizontalScroll: function () {
- return this.table.getLeftHorizontalScroll();
- },
-
- getRightHorizontalScroll: function () {
- return this.table.getRightHorizontalScroll();
- },
-
- getColumns: function () {
- return this.table.getColumns();
- },
-
- resizeHeader: function () {
- this.table.resize();
- this.table._resizeHeader && this.table._resizeHeader();
- },
-
- attr: function (key,value) {
- var self = this;
- if (BI.isObject(key)) {
- BI.each(key, function (k, v) {
- self.attr(k, v);
- });
- return;
- }
- BI.ExcelTable.superclass.attr.apply(this, arguments);
- switch (key){
- case "mergeCols":
- var mCols = [];
- BI.each(value, function (i, col) {
- mCols.push(col + 1);
- });
- value=mCols;
- break;
- }
- this.table.attr.apply(this.table, arguments);
- },
-
- populate: function (rows) {
- var self = this;
- var columnSize = this.getColumnSize();
- var items = [];
- var header = [{
- type: "bi.excel_table_header_cell"
- }];
- if (BI.isNotNull(rows)) {
- BI.each(columnSize, function (i, size) {
- header.push({
- type: "bi.excel_table_header_cell",
- text: BI.int2Abc(i + 1)
- });
- });
- BI.each(rows, function (i, row) {
- items.push([{
- type: "bi.excel_table_header_cell",
- text: (i + 1)
- }].concat(row));
- });
- }
- this.table.populate(items, [header]);
- },
-
- destroy: function () {
- this.table.destroy();
- BI.ExcelTable.superclass.destroy.apply(this, arguments);
- }
-});
-BI.shortcut('bi.excel_table', BI.ExcelTable);/**
- * 文件管理控件组
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerButtonGroup
- * @extends BI.Widget
- */
-BI.FileManagerButtonGroup = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-button_group",
- items: []
- })
- },
-
- _init: function () {
- BI.FileManagerButtonGroup.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.button_group = BI.createWidget({
- type: "bi.button_tree",
- element: this,
- chooseType: BI.Selection.Multi,
- items: this._formatItems(o.items),
- layouts: [{
- type: "bi.vertical"
- }]
- });
- this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- },
-
- _formatItems: function (items) {
- var self = this, o = this.options;
- BI.each(items, function (i, item) {
- if (item.children && item.children.length > 0) {
- item.type = "bi.file_manager_folder_item";
- } else {
- item.type = "bi.file_manager_file_item";
- }
- });
- return items;
- },
-
- setValue: function (v) {
- this.button_group.setValue(v);
- },
-
- getValue: function () {
- return this.button_group.getValue();
- },
-
- getNotSelectedValue: function () {
- return this.button_group.getNotSelectedValue();
- },
-
- getAllLeaves: function () {
- return this.button_group.getAllLeaves();
- },
-
- getAllButtons: function () {
- return this.button_group.getAllButtons();
- },
-
- getSelectedButtons: function () {
- return this.button_group.getSelectedButtons();
- },
-
- getNotSelectedButtons: function () {
- return this.button_group.getNotSelectedButtons();
- },
-
- populate: function (items) {
- this.button_group.populate(this._formatItems(items));
- }
-});
-BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/**
- * 文件管理控件
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManager
- * @extends BI.Widget
- */
-BI.FileManager = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager",
- el: {},
- items: []
- })
- },
-
- _init: function () {
- BI.FileManager.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.tree = new BI.Tree();
- var items = BI.Tree.transformToTreeFormat(o.items);
- this.tree.initTree(items);
- this.selectedValues = [];
- this.nav = BI.createWidget({
- type: "bi.file_manager_nav",
- items: BI.deepClone(items)
- });
- this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) {
- if (value == "-1") {//根节点
- self.populate({children: self.tree.toJSON()});
- } else {
- var node = self.tree.search(obj.attr("id"));
- self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)}));
- }
- self.setValue(self.selectedValues);
- });
- this.list = BI.createWidget(o.el, {
- type: "bi.file_manager_list",
- items: items
- });
- this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) {
- if (type === BI.Events.CHANGE) {
- var node = self.tree.search(obj.attr("id"));
- self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)}));
- } else if (type === BI.Events.CLICK) {
- var values = [];
- if (obj instanceof BI.MultiSelectBar) {
- var t = self.list.getValue();
- selected = t.type === BI.Selection.All;
- values = BI.concat(t.assist, t.value);
- } else {
- values = obj.getAllLeaves();
- }
- BI.each(values, function (i, v) {
- if (selected === true) {
- self.selectedValues.pushDistinct(v);
- } else {
- self.selectedValues.remove(v);
- }
- });
- }
- self.setValue(self.selectedValues);
- });
-
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.list,
- left: 0,
- right: 0,
- top: 0,
- bottom: 10
- }, {
- el: this.nav,
- left: 40,
- right: 100,
- top: 0
- }]
- });
- },
-
- setValue: function (value) {
- this.selectedValues = value || [];
- this.list.setValue(this.selectedValues);
- },
-
- getValue: function () {
- var obj = this.list.getValue();
- var res = obj.type === BI.Selection.All ? obj.assist : obj.value;
- res.pushDistinctArray(this.selectedValues);
- return res;
- },
-
- _populate: function (items) {
- this.list.populate(items);
- },
-
- getSelectedValue: function () {
- return this.nav.getValue()[0];
- },
-
- getSelectedId: function () {
- return this.nav.getId()[0];
- },
-
- populate: function (node) {
- var clone = BI.deepClone(node);
- this._populate(node.children);
- this.nav.populate(clone);
- }
-});
-BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE";
-BI.shortcut("bi.file_manager", BI.FileManager);/**
- * 文件管理控件
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerFileItem
- * @extends BI.Single
- */
-BI.FileManagerFileItem = BI.inherit(BI.Single, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom",
- height: 30
- })
- },
-
- _init: function () {
- BI.FileManagerFileItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.checked = BI.createWidget({
- type: "bi.multi_select_bar",
- text: "",
- width: 36,
- height: o.height
- });
- this.checked.on(BI.Controller.EVENT_CHANGE, function () {
- arguments[2] = self;
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- BI.createWidget({
- type: "bi.htape",
- element: this,
- items: [{
- el: this.checked,
- width: 36
- }, {
- el: {
- type: "bi.icon_button",
- cls: "create-by-me-file-font"
- },
- width: 20
- }, {
- el: {
- type: "bi.label",
- textAlign: "left",
- height: o.height,
- text: o.text,
- value: o.value
- }
- }]
- })
- },
-
- getAllLeaves: function(){
- return [this.options.value];
- },
-
- isSelected: function () {
- return this.checked.isSelected();
- },
-
- setSelected: function (v) {
- this.checked.setSelected(v);
- }
-});
-BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/**
- * 文件管理控件
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerFolderItem
- * @extends BI.Single
- */
-BI.FileManagerFolderItem = BI.inherit(BI.Single, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom",
- height: 30
- })
- },
-
- _init: function () {
- BI.FileManagerFolderItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.checked = BI.createWidget({
- type: "bi.multi_select_bar",
- text: "",
- width: 36,
- height: o.height
- });
- this.checked.on(BI.Controller.EVENT_CHANGE, function () {
- arguments[2] = self;
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.button = BI.createWidget({
- type: "bi.text_button",
- textAlign: "left",
- height: o.height,
- text: o.text,
- value: o.value
- });
- this.button.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self);
- });
-
- this.tree = new BI.Tree();
- this.tree.initTree([{
- id: o.id,
- children: o.children
- }]);
- this.selectValue = [];
-
- BI.createWidget({
- type: "bi.htape",
- element: this,
- items: [{
- el: this.checked,
- width: 36
- }, {
- el: {
- type: "bi.icon_button",
- cls: "create-by-me-folder-font"
- },
- width: 20
- }, {
- el: this.button
- }]
- })
- },
-
- setAllSelected: function (v) {
- this.checked.setSelected(v);
- this.selectValue = [];
- },
-
- setHalfSelected: function (v) {
- this.checked.setHalfSelected(v);
- if(!v){
- this.selectValue = [];
- }
- },
-
- setValue: function (v) {
- var self = this, o = this.options;
- var isHalf = false;
- var selectValue = [];
- this.tree.traverse(function (node) {
- if (node.isLeaf()) {
- if (BI.contains(v, node.get("data").value)) {
- selectValue.push(node.get("data").value);
- } else {
- isHalf = true;
- }
- }
- });
- this.setAllSelected(selectValue.length > 0 && !isHalf);
- this.setHalfSelected(selectValue.length > 0 && isHalf);
- if (this.checked.isHalfSelected()) {
- this.selectValue = selectValue;
- }
- },
-
- getAllButtons: function () {
- return [this];
- },
-
- getAllLeaves: function () {
- var o = this.options;
- var res = [];
- this.tree.traverse(function (node) {
- if (node.isLeaf()) {
- res.push(node.get("data").value)
- }
- });
- return res;
- },
-
- getNotSelectedValue: function () {
- var self = this, o = this.options;
- var res = [];
- var isAllSelected = this.checked.isSelected();
- if (isAllSelected === true) {
- return res;
- }
- var isHalfSelected = this.checked.isHalfSelected();
- this.tree.traverse(function (node) {
- if (node.isLeaf()) {
- var v = node.get("data").value;
- if (isHalfSelected === true) {
- if (!BI.contains(self.selectValue, node.get("data").value)) {
- res.push(v);
- }
- } else {
- res.push(v);
- }
- }
- });
- return res;
- },
-
- getValue: function () {
- var res = [];
- if (this.checked.isSelected()) {
- this.tree.traverse(function (node) {
- if (node.isLeaf()) {
- res.push(node.get("data").value);
- }
- });
- return res;
- }
- if (this.checked.isHalfSelected()) {
- return this.selectValue;
- }
- return [];
- }
-});
-BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/**
- * 文件管理控件列表
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerList
- * @extends BI.Widget
- */
-BI.FileManagerList = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-list",
- el: {},
- items: []
- })
- },
-
- _init: function () {
- BI.FileManagerList.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.list = BI.createWidget({
- type: "bi.select_list",
- element: this,
- items: o.items,
- toolbar: {
- type: "bi.multi_select_bar",
- height: 40,
- text: ""
- },
- el: {
- type: "bi.list_pane",
- el: BI.isWidget(o.el) ? o.el : BI.extend({
- type: "bi.file_manager_button_group"
- }, o.el)
- }
- });
- this.list.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- },
-
- setValue: function (v) {
- this.list.setValue({
- value: v
- });
- },
-
- getValue: function () {
- return this.list.getValue();
- },
-
- populate: function (items) {
- this.list.populate(items);
- this.list.setToolBarVisible(true);
- }
-});
-BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_list", BI.FileManagerList);/**
- * 文件管理导航按钮
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerNavButton
- * @extends BI.Widget
- */
-BI.FileManagerNavButton = BI.inherit(BI.Widget, {
-
- _const: {
- normal_color: "#ffffff",
- select_color: "#f4f4f4"
- },
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-nav-button",
- selected: false,
- height: 40
- })
- },
-
- _init: function () {
- BI.FileManagerNavButton.superclass._init.apply(this, arguments);
- var self = this, o = this.options, c = this._const;
- this.button = BI.createWidget({
- type: "bi.text_button",
- cls: "file-manager-nav-button-text bi-card",
- once: true,
- selected: o.selected,
- text: o.text,
- title: o.text,
- value: o.value,
- height: o.height,
- lgap: 20,
- rgap: 10
- });
- this.button.on(BI.Controller.EVENT_CHANGE, function () {
- arguments[2] = self;
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- var svg = BI.createWidget({
- type: "bi.svg",
- cls: "file-manager-nav-button-triangle",
- width: 15,
- height: o.height
- });
- var path = svg.path("M0,0L15,20L0,40").attr({
- "stroke": c.select_color,
- "fill": o.selected ? c.select_color : c.normal_color
- });
- this.button.on(BI.TextButton.EVENT_CHANGE, function () {
- if (this.isSelected()) {
- path.attr("fill", c.select_color);
- } else {
- path.attr("fill", c.normal_color);
- }
- });
- BI.createWidget({
- type: "bi.default",
- element: this,
- items: [this.button]
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: svg,
- right: -15,
- top: 0,
- bottom: 0
- }]
- })
- },
-
- isSelected: function () {
- return this.button.isSelected();
- },
-
- setValue: function (v) {
- this.button.setValue(v);
- },
-
- getValue: function () {
- return this.button.getValue();
- },
-
- populate: function (items) {
-
- }
-});
-BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/**
- * 文件管理导航
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerNav
- * @extends BI.Widget
- */
-BI.FileManagerNav = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-nav bi-border-left",
- height: 40,
- items: []
- })
- },
-
- _init: function () {
- BI.FileManagerNav.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.tree = new BI.Tree();
- this.refreshTreeData(o.items);
- this.tree.getRoot().set("data", {
- text: BI.i18nText("BI-Created_By_Me"),
- value: BI.FileManagerNav.ROOT_CREATE_BY_ME,
- id: BI.FileManagerNav.ROOT_CREATE_BY_ME
- });
- this.button_group = BI.createWidget({
- type: "bi.button_group",
- element: this,
- items: [{
- type: "bi.file_manager_nav_button",
- text: BI.i18nText("BI-Created_By_Me"),
- selected: true,
- id: BI.FileManagerNav.ROOT_CREATE_BY_ME,
- value: BI.FileManagerNav.ROOT_CREATE_BY_ME
- }],
- layouts: [{
- type: "bi.horizontal"
- }]
- });
- this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) {
- self.fireEvent(BI.FileManagerNav.EVENT_CHANGE, arguments);
- });
- },
-
- _getAllParents: function (id) {
- var node, res = [];
- if (!id) {
- node = this.tree.getRoot();
- } else {
- node = this.tree.search(id);
- }
- while (node.parent) {
- res.push(node);
- node = node.parent;
- }
- res.push(node);
- return res.reverse();
- },
-
- _formatNodes: function (nodes) {
- var res = [];
- BI.each(nodes, function (i, node) {
- res.push(BI.extend({
- type: "bi.file_manager_nav_button",
- id: node.id
- }, node.get("data")));
- });
- BI.last(res).selected = true;
- return res;
- },
-
- getValue: function () {
- return this.button_group.getValue();
- },
-
- getId: function () {
- var ids = [];
- BI.each(this.button_group.getSelectedButtons(), function (i, btn) {
- ids.push(btn.attr("id"));
- });
- return ids;
- },
-
- refreshTreeData: function(items){
- this.tree.initTree(BI.Tree.transformToTreeFormat(items));
- this.tree.getRoot().set("data", {
- text: BI.i18nText("BI-Created_By_Me"),
- value: BI.FileManagerNav.ROOT_CREATE_BY_ME,
- id: BI.FileManagerNav.ROOT_CREATE_BY_ME
- });
- },
-
- populate: function (node) {
- var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id);
- this.button_group.populate(this._formatNodes(parents));
- }
-});
-BI.extend(BI.FileManagerNav, {
- ROOT_CREATE_BY_ME: "-1"
-});
-BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/**
- * Created by windy on 2017/3/13.
- * 数值微调器
- */
-BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-fine-tuning-number-editor bi-border",
- value: -1
- })
- },
-
- _init: function () {
- BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.editor = BI.createWidget({
- type: "bi.sign_editor",
- value: this._alertInEditorValue(o.value),
- errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
- validationChecker: function(v){
- return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1;
- }
- });
- this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
- self._finetuning(0);
- self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
- });
- this.topBtn = BI.createWidget({
- type: "bi.icon_button",
- trigger: "lclick,",
- cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
- });
- this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
- self._finetuning(1);
- self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
- });
- this.bottomBtn = BI.createWidget({
- type: "bi.icon_button",
- trigger: "lclick,",
- cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
- });
- this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
- self._finetuning(-1);
- self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
- });
- this._finetuning(0);
- BI.createWidget({
- type: "bi.htape",
- element: this,
- items: [this.editor, {
- el: {
- type: "bi.grid",
- columns: 1,
- rows: 2,
- items: [{
- column: 0,
- row: 0,
- el: this.topBtn
- }, {
- column: 0,
- row: 1,
- el: this.bottomBtn
- }]
- },
- width: 30
- }]
- });
- },
-
- _alertOutEditorValue: function(v){
- return v === BI.i18nText("BI-Basic_Auto") ? -1 : v;
- },
-
- _alertInEditorValue: function(v){
- return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v;
- },
-
- //微调
- _finetuning: function(add){
- var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
- this.editor.setValue(this._alertInEditorValue(v + add));
- this.bottomBtn.setEnable((v + add) > -1);
- },
-
- getValue: function () {
- var v = this.editor.getValue();
- return this._alertOutEditorValue(v);
- },
-
- setValue: function (v) {
- this.editor.setValue(this._alertInEditorValue(v));
- this._finetuning(0);
- }
-
-});
-BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/**
- * 交互行为布局
- *
- *
- * Created by GUY on 2016/7/23.
- * @class BI.InteractiveArrangement
- * @extends BI.Widget
- */
-BI.InteractiveArrangement = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-interactive-arrangement",
- resizable: true,
- layoutType: BI.Arrangement.LAYOUT_TYPE.GRID,
- items: []
- });
- },
-
- _init: function () {
- BI.InteractiveArrangement.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.arrangement = BI.createWidget({
- type: "bi.adaptive_arrangement",
- element: this,
- resizable: o.resizable,
- layoutType: o.layoutType,
- items: o.items
- });
- this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL, function () {
- self.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL, arguments);
- });
- this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE, function () {
- self.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE, arguments);
- });
-
- this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, function (id, size) {
- var p = self._getRegionClientPosition(id);
- self.draw({
- left: p.left,
- top: p.top
- }, size, id);
- });
- this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, function (id, size) {
- self.stopDraw();
- self.setRegionSize(id, size);
- });
-
- this.tags = [];
-
- },
-
- _isEqual: function (num1, num2) {
- return this.arrangement._isEqual(num1, num2);
- },
-
- _getScrollOffset: function () {
- return this.arrangement._getScrollOffset();
- },
-
- _positionAt: function (position, regions) {
- var self = this;
- regions = regions || this.getAllRegions();
- var left = [], center = [], right = [], top = [], middle = [], bottom = [];
- BI.each(regions, function (i, region) {
- var client = self._getRegionClientPosition(region.id);
- if (Math.abs(client.left - position.left) <= 3) {
- left.push(region);
- }
- if (Math.abs(client.left + client.width / 2 - position.left) <= 3) {
- center.push(region);
- }
- if (Math.abs(client.left + client.width - position.left) <= 3) {
- right.push(region);
- }
- if (Math.abs(client.top - position.top) <= 3) {
- top.push(region);
- }
- if (Math.abs(client.top + client.height / 2 - position.top) <= 3) {
- middle.push(region);
- }
- if (Math.abs(client.top + client.height - position.top) <= 3) {
- bottom.push(region);
- }
- });
- return {
- left: left,
- center: center,
- right: right,
- top: top,
- middle: middle,
- bottom: bottom
- }
- },
-
- _getRegionClientPosition: function (name) {
- var region = this.getRegionByName(name);
- var offset = this.arrangement._getScrollOffset();
- return {
- top: region.top - offset.top,
- left: region.left - offset.left,
- width: region.width,
- height: region.height,
- id: region.id
- }
- },
-
- _vAlign: function (position, regions) {
- var self = this;
- var vs = this._positionAt(position, regions);
- var positions = [];
- var l;
- if (vs.left.length > 0) {
- l = this._getRegionClientPosition(vs.left[0].id).left;
- } else if (vs.right.length > 0) {
- var temp = this._getRegionClientPosition(vs.right[0].id);
- l = temp.left + temp.width;
- }
- var rs = vs.left.concat(vs.right);
- BI.each(rs, function (i, region) {
- var p = self._getRegionClientPosition(region.id);
- if (self._isEqual(p.left, l) || self._isEqual(p.left + p.width, l)) {
- var topPoint = {
- top: p.top + p.height / 2,
- left: l
- };
- positions.push({
- id: region.id,
- start: topPoint,
- end: {
- left: l,
- top: position.top
- }
- });
- }
- });
- return positions;
- },
-
- _leftAlign: function (position, size, regions) {
- var self = this;
- return this._vAlign({
- left: position.left,
- top: position.top + size.height / 2
- }, regions);
- },
-
- _rightAlign: function (position, size, regions) {
- var self = this;
- return this._vAlign({
- left: position.left + size.width,
- top: position.top + size.height / 2
- }, regions);
- },
-
- _hAlign: function (position, regions) {
- var self = this;
- var hs = this._positionAt(position, regions);
- var positions = [];
- var t;
- if (hs.top.length > 0) {
- var temp = this._getRegionClientPosition(hs.top[0].id);
- t = temp.top;
- } else if (hs.bottom.length > 0) {
- var temp = this._getRegionClientPosition(hs.bottom[0].id);
- t = temp.top + temp.height;
- }
- var rs = hs.top.concat(hs.bottom);
- BI.each(rs, function (i, region) {
- var p = self._getRegionClientPosition(region.id);
- if (self._isEqual(p.top, t) || self._isEqual(p.top + p.height, t)) {
- var leftPoint = {
- top: t,
- left: p.left + p.width / 2
- };
- positions.push({
- id: p.id,
- start: leftPoint,
- end: {
- left: position.left,
- top: t
- }
- });
- }
- });
- return positions;
- },
-
- _topAlign: function (position, size, regions) {
- var self = this;
- return this._hAlign({
- left: position.left + size.width / 2,
- top: position.top
- }, regions);
- },
-
- _bottomAlign: function (position, size, regions) {
- var self = this;
- return this._hAlign({
- left: position.left + size.width / 2,
- top: position.top + size.height
- }, regions);
- },
-
- _centerAlign: function (position, size, regions) {
- var self = this;
- var cs = this._positionAt({
- left: position.left + size.width / 2,
- top: position.top + size.height / 2
- }, regions);
- var positions = [];
- var l;
- if (cs.center.length > 0) {
- var temp = this._getRegionClientPosition(cs.center[0].id);
- l = temp.left + temp.width / 2;
- }
- BI.each(cs.center, function (i, region) {
- var p = self._getRegionClientPosition(region.id);
- if (self._isEqual(p.left + p.width / 2, l)) {
- var topPoint = {
- top: p.top + p.height / 2,
- left: p.left + p.width / 2
- };
- positions.push({
- id: p.id,
- start: topPoint,
- end: {
- left: l,
- top: position.top + size.height / 2
- }
- });
- }
- });
- return positions;
- },
-
- _middleAlign: function (position, size, regions) {
- var self = this;
- var cs = this._positionAt({
- left: position.left + size.width / 2,
- top: position.top + size.height / 2
- }, regions);
- var positions = [];
- var t;
- if (cs.middle.length > 0) {
- var temp = this._getRegionClientPosition(cs.middle[0].id);
- t = temp.top + temp.height / 2;
- }
- BI.each(cs.middle, function (i, region) {
- var p = self._getRegionClientPosition(region.id);
- if (self._isEqual(p.top + p.height / 2, t)) {
- var topPoint = {
- top: p.top + p.height / 2,
- left: p.left + p.width / 2
- };
- positions.push({
- id: p.id,
- start: topPoint,
- end: {
- left: position.left + size.width / 2,
- top: t
- }
- });
- }
- });
- return positions;
- },
-
-
- _drawOneTag: function (start, end) {
- var s = BI.createWidget({
- type: "bi.icon_button",
- //invisible: true,
- width: 13,
- height: 13,
- cls: "drag-tag-font interactive-arrangement-dragtag-icon"
- });
- var e = BI.createWidget({
- type: "bi.icon_button",
- //invisible: true,
- width: 13,
- height: 13,
- cls: "drag-tag-font interactive-arrangement-dragtag-icon"
- });
- if (this._isEqual(start.left, end.left)) {
- var line = BI.createWidget({
- type: "bi.layout",
- //invisible: true,
- cls: "interactive-arrangement-dragtag-line",
- width: 1,
- height: Math.abs(start.top - end.top)
- });
- } else {
- var line = BI.createWidget({
- type: "bi.layout",
- //invisible: true,
- cls: "interactive-arrangement-dragtag-line",
- height: 1,
- width: Math.abs(start.left - end.left)
- });
- }
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: s,
- left: start.left - 6,
- top: start.top - 7
- }, {
- el: e,
- left: end.left - 6,
- top: end.top - 7
- }, {
- el: line,
- left: Math.min(start.left, end.left),
- top: Math.min(start.top, end.top)
- }]
- });
- this.tags.push(s);
- this.tags.push(e);
- this.tags.push(line);
- },
-
- stopDraw: function () {
- BI.each(this.tags, function (i, w) {
- w.destroy();
- });
- this.tags = [];
- },
-
- _getRegionExcept: function (name, regions) {
- var other = [];
- BI.each(regions || this.getAllRegions(), function (i, region) {
- if (!(name && region.id === name)) {
- other.push(region);
- }
- });
- return other;
- },
-
- getClientWidth: function () {
- return this.arrangement.getClientWidth();
- },
-
- getClientHeight: function () {
- return this.arrangement.getClientHeight();
- },
-
- getPosition: function (name, position, size) {
- var regions = this.getAllRegions();
- var me;
- if (name) {
- me = this._getRegionClientPosition(name);
- }
- var other = this._getRegionExcept(name, regions);
- position = position || {
- left: me.left,
- top: me.top
- };
- size = size || {
- width: me.width,
- height: me.height
- };
- var left = this._leftAlign(position, size, other);
- var right = this._rightAlign(position, size, other);
- var top = this._topAlign(position, size, other, other);
- var bottom = this._bottomAlign(position, size, other);
- var center = this._centerAlign(position, size, other);
- var middle = this._middleAlign(position, size, other);
-
- BI.each(center, function (i, pos) {
- position.left = pos.end.left - size.width / 2;
- });
- BI.each(right, function (i, pos) {
- position.left = pos.end.left - size.width;
- });
- BI.each(left, function (i, pos) {
- position.left = pos.end.left;
- });
- BI.each(middle, function (i, pos) {
- position.top = pos.end.top - size.height / 2;
- });
- BI.each(bottom, function (i, pos) {
- position.top = pos.end.top - size.height;
- });
- BI.each(top, function (i, pos) {
- position.top = pos.end.top;
- });
- return position;
- },
-
- //position不动 变size
- getSize: function (name, position, size) {
- var regions = this.getAllRegions();
- var me;
- if (name) {
- me = this._getRegionClientPosition(name);
- }
- var other = this._getRegionExcept(name, regions);
- position = position || {
- left: me.left,
- top: me.top
- };
- size = size || {
- width: me.width,
- height: me.height
- };
- var left = this._leftAlign(position, size, other);
- var right = this._rightAlign(position, size, other);
- var top = this._topAlign(position, size, other, other);
- var bottom = this._bottomAlign(position, size, other);
- var center = this._centerAlign(position, size, other);
- var middle = this._middleAlign(position, size, other);
-
- BI.each(center, function (i, pos) {
- size.width = (pos.end.left - position.left) * 2;
- });
- BI.each(right, function (i, pos) {
- size.width = pos.end.left - position.left;
- });
- BI.each(left, function (i, pos) {
- });
- BI.each(middle, function (i, pos) {
- size.height = (pos.end.top - position.top) * 2;
- });
- BI.each(bottom, function (i, pos) {
- size.height = pos.end.top - position.top;
- });
- BI.each(top, function (i, pos) {
- });
- return size;
- },
-
- draw: function (position, size, name) {
- var self = this;
- this.stopDraw();
- switch (this.getLayoutType()) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- var other = this._getRegionExcept(name);
- var left = this._leftAlign(position, size, other);
- var right = this._rightAlign(position, size, other);
- var top = this._topAlign(position, size, other);
- var bottom = this._bottomAlign(position, size, other);
- var center = this._centerAlign(position, size, other);
- var middle = this._middleAlign(position, size, other);
-
- BI.each(center, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- BI.each(right, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- BI.each(left, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- BI.each(middle, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- BI.each(bottom, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- BI.each(top, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- break;
- }
- },
-
- addRegion: function (region, position) {
- this.stopDraw();
- return this.arrangement.addRegion(region, position);
- },
-
- deleteRegion: function (name) {
- return this.arrangement.deleteRegion(name);
- },
-
- setRegionSize: function (name, size) {
- size = this.getSize(name, null, size);
- return this.arrangement.setRegionSize(name, size);
- },
-
- setPosition: function (position, size) {
- var self = this;
- this.stopDraw();
- if (position.left > 0 && position.top > 0) {
- switch (this.getLayoutType()) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- position = this.getPosition(null, position, size);
- this.draw(position, size);
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- break;
- }
- }
- var at = this.arrangement.setPosition(position, size);
- return at;
- },
-
- setRegionPosition: function (name, position) {
- if (position.left > 0 && position.top > 0) {
- switch (this.getLayoutType()) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- position = this.getPosition(name, position);
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- break;
- }
- }
- return this.arrangement.setRegionPosition(name, position);
- },
-
- setDropPosition: function (position, size) {
- var self = this;
- this.stopDraw();
- if (position.left > 0 && position.top > 0) {
- switch (this.getLayoutType()) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- position = this.getPosition(null, position, size);
- this.draw(position, size);
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- break;
- }
- }
- var callback = self.arrangement.setDropPosition(position, size);
- return function () {
- callback();
- self.stopDraw();
- }
- },
-
- scrollInterval: function () {
- this.arrangement.scrollInterval.apply(this.arrangement, arguments);
- },
-
- scrollEnd: function () {
- this.arrangement.scrollEnd.apply(this.arrangement, arguments);
- },
-
- scrollTo: function (scroll) {
- this.arrangement.scrollTo(scroll);
- },
-
- zoom: function (ratio) {
- this.arrangement.zoom(ratio);
- },
-
- resize: function () {
- return this.arrangement.resize();
- },
-
- relayout: function () {
- return this.arrangement.relayout();
- },
-
- setLayoutType: function (type) {
- this.arrangement.setLayoutType(type);
- },
-
- getLayoutType: function () {
- return this.arrangement.getLayoutType();
- },
-
- getLayoutRatio: function () {
- return this.arrangement.getLayoutRatio();
- },
-
- getHelper: function () {
- return this.arrangement.getHelper();
- },
-
- getRegionByName: function (name) {
- return this.arrangement.getRegionByName(name);
- },
-
- getAllRegions: function () {
- return this.arrangement.getAllRegions();
- },
-
- revoke: function () {
- return this.arrangement.revoke();
- },
-
- populate: function (items) {
- var self = this;
- this.arrangement.populate(items);
- }
-});
-BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE";
-BI.InteractiveArrangement.EVENT_SCROLL = "InteractiveArrangement.EVENT_SCROLL";
-BI.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/**
- * 月份下拉框
- *
- * Created by GUY on 2015/8/28.
- * @class BI.MonthCombo
- * @extends BI.Trigger
- */
-BI.MonthCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-month-combo",
- behaviors: {},
- height: 25
- });
- },
- _init: function () {
- BI.MonthCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.month_trigger"
- });
-
- this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) {
- if (this.getKey() && this.getKey() !== self.storeValue) {
- self.setValue(this.getValue());
- } else if (!this.getKey()) {
- self.setValue();
- }
- self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
- });
- this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () {
- self.storeValue = this.getKey();
- });
- this.trigger.on(BI.MonthTrigger.EVENT_START, function () {
- self.combo.hideView();
- });
- this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- });
- this.trigger.on(BI.MonthTrigger.EVENT_CHANGE, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- });
-
- this.popup = BI.createWidget({
- type: "bi.month_popup",
- behaviors: o.behaviors
- });
- this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- minWidth: 85,
- el: this.popup
- }
- });
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW);
- });
- },
-
- setValue: function (v) {
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- }
-});
-
-BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.month_combo', BI.MonthCombo);/**
- * 月份展示面板
- *
- * Created by GUY on 2015/9/2.
- * @class BI.MonthPopup
- * @extends BI.Trigger
- */
-BI.MonthPopup = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-month-popup",
- behaviors: {}
- });
- },
-
- _init: function () {
- BI.MonthPopup.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- //纵向排列月
- var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11];
- var items = [];
- items.push(month.slice(0, 2));
- items.push(month.slice(2, 4));
- items.push(month.slice(4, 6));
- items.push(month.slice(6, 8));
- items.push(month.slice(8, 10));
- items.push(month.slice(10, 12));
- items = BI.map(items, function (i, item) {
- return BI.map(item, function (j, td) {
- return {
- type: "bi.text_item",
- cls: "bi-list-item-active",
- textAlign: "center",
- whiteSpace: "nowrap",
- once: false,
- forceSelected: true,
- height: 23,
- width: 38,
- value: td,
- text: td + 1
- };
- });
- });
-
- this.month = BI.createWidget({
- type: "bi.button_group",
- element: this,
- behaviors: o.behaviors,
- items: BI.createItems(items, {}),
- layouts: [BI.LogicFactory.createLogic("table", BI.extend({
- dynamic: true
- }, {
- columns: 2,
- rows: 6,
- columnSize: [1 / 2, 1 / 2],
- rowSize: 25
- })), {
- type: "bi.center_adapt",
- vgap: 1,
- hgap: 2
- }]
- });
-
- this.month.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if (type === BI.Events.CLICK) {
- self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
- }
- })
- },
-
- getValue: function () {
- return this.month.getValue()[0];
- },
-
- setValue: function (v) {
- this.month.setValue([v]);
- }
-});
-BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.month_popup", BI.MonthPopup);/**
- * 月份trigger
- *
- * Created by GUY on 2015/8/21.
- * @class BI.MonthTrigger
- * @extends BI.Trigger
- */
-BI.MonthTrigger = BI.inherit(BI.Trigger, {
- _const: {
- hgap: 4,
- vgap: 2,
- triggerWidth: 25,
- errorText: BI.i18nText("BI-Month_Trigger_Error_Text")
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-month-trigger bi-border",
- height: 25
- });
- },
- _init: function () {
- BI.MonthTrigger.superclass._init.apply(this, arguments);
- var self = this, o = this.options, c = this._const;
- this.editor = BI.createWidget({
- type: "bi.sign_editor",
- height: o.height,
- validationChecker: function (v) {
- return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 12);
- },
- quitChecker: function (v) {
- return false;
- },
- hgap: c.hgap,
- vgap: c.vgap,
- allowBlank: true,
- errorText: c.errorText
- });
- this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
- self.fireEvent(BI.MonthTrigger.EVENT_FOCUS);
- });
- this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
- self.fireEvent(BI.MonthTrigger.EVENT_CHANGE);
- });
- this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
- var value = self.editor.getValue();
- if (BI.isNotNull(value)) {
- self.editor.setValue(value);
- self.editor.setTitle(value);
- }
- self.fireEvent(BI.MonthTrigger.EVENT_CONFIRM);
- });
- this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
- if (self.editor.isValid()) {
- self.editor.blur();
- }
- });
- this.editor.on(BI.SignEditor.EVENT_START, function () {
- self.fireEvent(BI.MonthTrigger.EVENT_START);
- });
- this.editor.on(BI.SignEditor.EVENT_STOP, function () {
- self.fireEvent(BI.MonthTrigger.EVENT_STOP);
- });
- BI.createWidget({
- element: this,
- type: 'bi.htape',
- items: [
- {
- el: this.editor
- }, {
- el: {
- type: "bi.text_button",
- text: BI.i18nText("BI-Multi_Date_Month"),
- baseCls: "bi-trigger-month-text",
- width: c.triggerWidth
- },
- width: c.triggerWidth
- }, {
- el: {
- type: "bi.trigger_icon_button",
- width: c.triggerWidth
- },
- width: c.triggerWidth
- }
- ]
- });
- },
- setValue: function (v) {
- if(BI.isNotNull(v)){
- this.editor.setState(v + 1);
- this.editor.setValue(v + 1);
- this.editor.setTitle(v + 1);
- return;
- }
- this.editor.setState();
- this.editor.setValue();
- this.editor.setTitle();
- },
- getKey: function () {
- return this.editor.getValue() | 0;
- },
- getValue: function () {
- return this.editor.getValue() - 1;
- }
-});
-BI.MonthTrigger.EVENT_FOCUS = "EVENT_FOCUS";
-BI.MonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.MonthTrigger.EVENT_START = "EVENT_START";
-BI.MonthTrigger.EVENT_STOP = "EVENT_STOP";
-BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.month_trigger", BI.MonthTrigger);/**
- * @class BI.MultiLayerSelectTreeCombo
- * @extends BI.Widget
- */
-BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSelectTreeCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer_select_tree-combo",
- isDefaultInit: false,
- height: 30,
- text: "",
- items: []
- });
- },
-
- _init: function () {
- BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.single_tree_trigger",
- text: o.text,
- height: o.height,
- items: o.items
- });
-
- this.popup = BI.createWidget({
- type: "bi.multilayer_select_tree_popup",
- isDefaultInit: o.isDefaultInit,
- items: o.items
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- adjustLength: 2,
- el: this.trigger,
- popup: {
- el: this.popup
- }
- });
-
- this.combo.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE);
- });
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- },
-
- populate: function (items) {
- this.combo.populate(items);
- }
-});
-BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
- * guy
- * 二级树
- * @class BI.MultiLayerSelectLevelTree
- * @extends BI.Select
- */
-BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSelectLevelTree.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer-select-level-tree",
- isDefaultInit: false,
- items: [],
- itemsCreator: BI.emptyFn
- })
- },
-
- _init: function () {
- BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments);
-
- this.initTree(this.options.items);
- },
-
- _formatItems: function (nodes, layer) {
- var self = this;
- BI.each(nodes, function (i, node) {
- var extend = {};
- node.layer = layer;
- if (!BI.isKey(node.id)) {
- node.id = BI.UUID();
- }
- if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
- switch (i) {
- case 0 :
- extend.type = "bi.multilayer_select_tree_first_plus_group_node";
- break;
- case nodes.length - 1 :
- extend.type = "bi.multilayer_select_tree_last_plus_group_node";
- break;
- default :
- extend.type = "bi.multilayer_select_tree_mid_plus_group_node";
- break;
- }
- BI.defaults(node, extend);
-
- self._formatItems(node.children, layer + 1);
- } else {
- switch (i) {
- case nodes.length - 1:
- extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
- break;
- default :
- extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
- }
- BI.defaults(node, extend);
- }
- });
- return nodes;
- },
-
- _assertId: function (sNodes) {
- BI.each(sNodes, function (i, node) {
- node.id = node.id || BI.UUID();
- });
- },
-
- //构造树结构,
- initTree: function (nodes) {
- var self = this, o = this.options;
- this.empty();
- this._assertId(nodes);
- this.tree = BI.createWidget({
- type: "bi.custom_tree",
- element: this,
- expander: {
- type: "bi.select_tree_expander",
- isDefaultInit: o.isDefaultInit,
- el: {},
- popup: {
- type: "bi.custom_tree"
- }
- },
-
- items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
- itemsCreator: o.itemsCreator,
-
- el: {
- type: "bi.button_tree",
- chooseType: BI.Selection.Single,
- layouts: [{
- type: "bi.vertical"
- }]
- }
- });
- this.tree.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if (type === BI.Events.CLICK) {
- self.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, arguments);
- }
- })
- },
-
- populate: function (nodes) {
- this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0));
- },
-
- setValue: function (v) {
- this.tree.setValue(v);
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- getAllLeaves: function () {
- return this.tree.getAllLeaves();
- },
-
- getNodeById: function (id) {
- return this.tree.getNodeById(id);
- },
-
- getNodeByValue: function (id) {
- return this.tree.getNodeByValue(id);
- }
-});
-BI.MultiLayerSelectLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
-
-BI.shortcut("bi.multilayer_select_level_tree", BI.MultiLayerSelectLevelTree);/**
- * Created by GUY on 2016/1/26.
- *
- * @class BI.MultiLayerSelectTreePopup
- * @extends BI.Pane
- */
-
-BI.MultiLayerSelectTreePopup = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer-select-tree-popup",
- tipText: BI.i18nText("BI-No_Selected_Item"),
- isDefaultInit: false,
- itemsCreator: BI.emptyFn,
- items: []
- });
- },
-
- _init: function () {
- BI.MultiLayerSelectTreePopup.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- this.tree = BI.createWidget({
- type: 'bi.multilayer_select_level_tree',
- isDefaultInit: o.isDefaultInit,
- items: o.items,
- itemsCreator: o.itemsCreator
- });
-
- BI.createWidget({
- type: "bi.vertical",
- scrolly: false,
- scrollable: true,
- element: this,
- items: [this.tree]
- });
-
- this.tree.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE);
- });
-
- this.check();
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.tree.setValue(v);
- },
-
- populate: function (items) {
- BI.MultiLayerSelectTreePopup.superclass.populate.apply(this, arguments);
- this.tree.populate(items);
- }
-});
-
-BI.MultiLayerSelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.multilayer_select_tree_popup", BI.MultiLayerSelectTreePopup);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSelectTreeFirstPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active",
- layer: 0,//第几层级
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.select_tree_first_plus_group_node",
- cls: "bi-list-item-none",
- stopPropagation: true,
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.setSelected(self.isSelected());
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- isOnce: function () {
- return true;
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- isSelected: function () {
- return this.node.isSelected();
- },
-
- setSelected: function (b) {
- BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this, arguments);
- this.node.setSelected(b);
- },
-
- doClick: function () {
- BI.NodeButton.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
- this.node.setOpened(v);
- }
-});
-
-BI.shortcut("bi.multilayer_select_tree_first_plus_group_node", BI.MultiLayerSelectTreeFirstPlusGroupNode);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSelectTreeLastPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-select-tree-last-plus-group-node bi-list-item-active",
- layer: 0,//第几层级
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.select_tree_last_plus_group_node",
- cls: "bi-list-item-none",
- stopPropagation: true,
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.setSelected(self.isSelected());
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- isSelected: function () {
- return this.node.isSelected();
- },
-
- setSelected: function (b) {
- BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this, arguments);
- this.node.setSelected(b);
- },
-
- doClick: function () {
- BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
- this.node.setOpened(v);
- }
-});
-
-BI.shortcut("bi.multilayer_select_tree_last_plus_group_node", BI.MultiLayerSelectTreeLastPlusGroupNode);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSelectTreeMidPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active",
- layer: 0,//第几层级
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.select_tree_mid_plus_group_node",
- cls: "bi-list-item-none",
- stopPropagation: true,
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.setSelected(self.isSelected());
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- isSelected: function () {
- return this.node.isSelected();
- },
-
- setSelected: function (b) {
- BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this, arguments);
- this.node.setSelected(b);
- },
-
- doClick: function () {
- BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
- this.node.setOpened(v);
- }
-});
-
-BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node", BI.MultiLayerSelectTreeMidPlusGroupNode);/**
- * 多层级下拉单选树
- * Created by GUY on 2016/1/26.
- *
- * @class BI.MultiLayerSingleTreeCombo
- * @extends BI.Widget
- */
-BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer-singletree-combo",
- isDefaultInit: false,
- height: 30,
- text: "",
- itemsCreator: BI.emptyFn,
- items: []
- });
- },
-
- _init: function () {
- BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.single_tree_trigger",
- text: o.text,
- height: o.height,
- items: o.items
- });
-
- this.popup = BI.createWidget({
- type: "bi.multilayer_single_tree_popup",
- isDefaultInit: o.isDefaultInit,
- items: o.items
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- adjustLength: 2,
- el: this.trigger,
- popup: {
- el: this.popup
- }
- });
-
- this.combo.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE);
- });
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- },
-
- populate: function (items) {
- this.combo.populate(items);
- }
-});
-
-BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
- * guy
- * 二级树
- * @class BI.MultiLayerSingleLevelTree
- * @extends BI.Single
- */
-BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleLevelTree.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer-single-level-tree",
- isDefaultInit: false,
- items: [],
- itemsCreator: BI.emptyFn
- })
- },
-
- _init: function () {
- BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments);
-
- this.initTree(this.options.items);
- },
-
- _formatItems: function (nodes, layer) {
- var self = this;
- BI.each(nodes, function (i, node) {
- var extend = {};
- node.layer = layer;
- if (!BI.isKey(node.id)) {
- node.id = BI.UUID();
- }
- if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
- switch (i) {
- case 0 :
- extend.type = "bi.multilayer_single_tree_first_plus_group_node";
- break;
- case nodes.length - 1 :
- extend.type = "bi.multilayer_single_tree_last_plus_group_node";
- break;
- default :
- extend.type = "bi.multilayer_single_tree_mid_plus_group_node";
- break;
- }
- BI.defaults(node, extend);
-
- self._formatItems(node.children, layer + 1);
- } else {
- switch (i) {
- case nodes.length - 1:
- extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
- break;
- default :
- extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
- }
- BI.defaults(node, extend);
- }
- });
- return nodes;
- },
-
- _assertId: function (sNodes) {
- BI.each(sNodes, function (i, node) {
- node.id = node.id || BI.UUID();
- });
- },
-
- //构造树结构,
- initTree: function (nodes) {
- var self = this, o = this.options;
- this.empty();
- this._assertId(nodes);
- this.tree = BI.createWidget({
- type: "bi.custom_tree",
- element: this,
- expander: {
- isDefaultInit: o.isDefaultInit,
- el: {},
- popup: {
- type: "bi.custom_tree"
- }
- },
-
- items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
- itemsCreator: function (op, callback) {
- o.itemsCreator(op, function (items) {
- callback(BI.Tree.transformToTreeFormat(items), 0)
- })
- },
-
- el: {
- type: "bi.button_tree",
- chooseType: BI.Selection.Single,
- layouts: [{
- type: "bi.vertical"
- }]
- }
- });
- this.tree.on(BI.Controller.EVENT_CHANGE, function (type, v) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if (type === BI.Events.CLICK) {
- self.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, v);
- }
- })
- },
-
- populate: function (nodes) {
- this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0));
- },
-
- setValue: function (v) {
- this.tree.setValue(v);
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- getAllLeaves: function () {
- return this.tree.getAllLeaves();
- },
-
- getNodeById: function (id) {
- return this.tree.getNodeById(id);
- },
-
- getNodeByValue: function (id) {
- return this.tree.getNodeByValue(id);
- }
-});
-BI.MultiLayerSingleLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
-
-BI.shortcut("bi.multilayer_single_level_tree", BI.MultiLayerSingleLevelTree);
-/**
- * Created by GUY on 2016/1/26.
- *
- * @class BI.MultiLayerSingleTreePopup
- * @extends BI.Pane
- */
-
-BI.MultiLayerSingleTreePopup = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer-singletree-popup",
- tipText: BI.i18nText("BI-No_Selected_Item"),
- isDefaultInit: false,
- itemsCreator: BI.emptyFn,
- items: []
- });
- },
-
- _init: function () {
- BI.MultiLayerSingleTreePopup.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- this.tree = BI.createWidget({
- type: 'bi.multilayer_single_level_tree',
- isDefaultInit: o.isDefaultInit,
- items: o.items,
- itemsCreator: o.itemsCreator
- });
-
- BI.createWidget({
- type: "bi.vertical",
- scrolly: false,
- scrollable: true,
- element: this,
- items: [this.tree]
- });
-
- this.tree.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE);
- });
-
- this.check();
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.tree.setValue(v);
- },
-
- populate: function (items) {
- BI.MultiLayerSingleTreePopup.superclass.populate.apply(this, arguments);
- this.tree.populate(items);
- }
-});
-
-BI.MultiLayerSingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.multilayer_single_tree_popup", BI.MultiLayerSingleTreePopup);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeFirstPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSingleTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-single-tree-first-plus-group-node bi-list-item",
- layer: 0,//第几层级
- id: "",
- pId: "",
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.first_plus_group_node",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.node)) {
- this.node.setOpened(v);
- }
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_first_plus_group_node", BI.MultiLayerSingleTreeFirstPlusGroupNode);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeLastPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSingleTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-single-tree-last-plus-group-node bi-list-item",
- layer: 0,//第几层级
- id: "",
- pId: "",
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.last_plus_group_node",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.node)) {
- this.node.setOpened(v);
- }
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_last_plus_group_node", BI.MultiLayerSingleTreeLastPlusGroupNode);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeMidPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSingleTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-single-tree-mid-plus-group-node bi-list-item",
- layer: 0,//第几层级
- id: "",
- pId: "",
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.mid_plus_group_node",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.node)) {
- this.node.setOpened(v);
- }
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/**
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeFirstTreeLeafItem
- * @extends BI.BasicButton
- */
-BI.MultiLayerSingleTreeFirstTreeLeafItem = BI.inherit(BI.BasicButton, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-multilayer-single-tree-first-tree-leaf-item bi-list-item-active",
- logic: {
- dynamic: false
- },
- layer: 0,
- id: "",
- pId: "",
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.item = BI.createWidget({
- type: "bi.first_tree_leaf_item",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.item);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.item.doRedMark.apply(this.item, arguments);
- },
-
- unRedMark: function () {
- this.item.unRedMark.apply(this.item, arguments);
- },
-
- doHighLight: function () {
- this.item.doHighLight.apply(this.item, arguments);
- },
-
- unHighLight: function () {
- this.item.unHighLight.apply(this.item, arguments);
- },
-
- getId: function () {
- return this.options.id;
- },
-
- getPId: function () {
- return this.options.pId;
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this, arguments);
- this.item.setSelected(this.isSelected());
- },
-
- setSelected: function (v) {
- BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this, arguments);
- this.item.setSelected(v);
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item", BI.MultiLayerSingleTreeFirstTreeLeafItem);/**
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeLastTreeLeafItem
- * @extends BI.BasicButton
- */
-BI.MultiLayerSingleTreeLastTreeLeafItem = BI.inherit(BI.BasicButton, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-multilayer-single-tree-last-tree-leaf-item bi-list-item-active",
- logic: {
- dynamic: false
- },
- layer: 0,
- id: "",
- pId: "",
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.item = BI.createWidget({
- type: "bi.last_tree_leaf_item",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.item);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.item.doRedMark.apply(this.item, arguments);
- },
-
- unRedMark: function () {
- this.item.unRedMark.apply(this.item, arguments);
- },
-
- doHighLight: function () {
- this.item.doHighLight.apply(this.item, arguments);
- },
-
- unHighLight: function () {
- this.item.unHighLight.apply(this.item, arguments);
- },
-
- getId: function () {
- return this.options.id;
- },
-
- getPId: function () {
- return this.options.pId;
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this, arguments);
- this.item.setSelected(this.isSelected());
- },
-
- setSelected: function (v) {
- BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this, arguments);
- this.item.setSelected(v);
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item", BI.MultiLayerSingleTreeLastTreeLeafItem);/**
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeMidTreeLeafItem
- * @extends BI.BasicButton
- */
-BI.MultiLayerSingleTreeMidTreeLeafItem = BI.inherit(BI.BasicButton, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-multilayer-single-tree-mid-tree-leaf-item bi-list-item-active",
- logic: {
- dynamic: false
- },
- layer: 0,
- id: "",
- pId: "",
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.item = BI.createWidget({
- type: "bi.mid_tree_leaf_item",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.item);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.item.doRedMark.apply(this.item, arguments);
- },
-
- unRedMark: function () {
- this.item.unRedMark.apply(this.item, arguments);
- },
-
- doHighLight: function () {
- this.item.doHighLight.apply(this.item, arguments);
- },
-
- unHighLight: function () {
- this.item.unHighLight.apply(this.item, arguments);
- },
-
- getId: function () {
- return this.options.id;
- },
-
- getPId: function () {
- return this.options.pId;
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this, arguments);
- this.item.setSelected(this.isSelected());
- },
-
- setSelected: function (v) {
- BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this, arguments);
- this.item.setSelected(v);
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item", BI.MultiLayerSingleTreeMidTreeLeafItem);/**
- *
- * @class BI.MultiSelectCheckPane
- * @extends BI.Widget
- */
-BI.MultiSelectCheckPane = BI.inherit(BI.Widget, {
-
- constants: {
- height: 25,
- lgap: 10,
- tgap: 5
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-select-check-pane bi-background",
- items: [],
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- onClickContinueSelect: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiSelectCheckPane.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
-
- this.storeValue = {};
- this.display = BI.createWidget({
- type: 'bi.display_selected_list',
- items: opts.items,
- itemsCreator: function (op, callback) {
- op = BI.extend(op || {}, {
- selectedValues: self.storeValue.value
- });
- if (self.storeValue.type === BI.Selection.Multi) {
- callback({
- items: BI.map(self.storeValue.value, function (i, v) {
- var txt = opts.valueFormatter(v) || v;
- return {
- text: txt,
- value: v,
- title: txt
- }
- })
- });
- return;
- }
- opts.itemsCreator(op, callback);
- }
- });
-
- this.continueSelect = BI.createWidget({
- type: 'bi.text_button',
- text: BI.i18nText('BI-Continue_Select'),
- cls: 'multi-select-check-selected bi-high-light'
- });
-
- this.continueSelect.on(BI.TextButton.EVENT_CHANGE, function () {
- opts.onClickContinueSelect();
- });
-
- BI.createWidget({
- type: 'bi.vtape',
- element: this,
- items: [{
- height: this.constants.height,
- el: {
- type: 'bi.left',
- cls: 'multi-select-continue-select',
- items: [
- {
- el: {
- type: "bi.label",
- text: BI.i18nText('BI-Selected_Data')
- },
- lgap: this.constants.lgap,
- tgap: this.constants.tgap
- },
- {
- el: this.continueSelect,
- lgap: this.constants.lgap,
- tgap: this.constants.tgap
- }]
- }
- }, {
- height: 'fill',
- el: this.display
- }]
- });
- },
-
- setValue: function (v) {
- this.storeValue = v || {};
- },
-
- empty: function () {
- this.display.empty();
- },
-
- populate: function () {
- this.display.populate.apply(this.display, arguments);
- }
-});
-
-BI.shortcut("bi.multi_select_check_pane", BI.MultiSelectCheckPane);/**
- *
- *
- * 查看已选弹出层的展示面板
- * @class BI.DisplaySelectedList
- * @extends BI.Widget
- */
-BI.DisplaySelectedList = BI.inherit(BI.Pane, {
-
- constants: {
- height: 25,
- lgap: 10
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-display-list",
- itemsCreator: BI.emptyFn,
- items: []
- });
- },
-
- _init: function () {
- BI.DisplaySelectedList.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
-
- this.hasNext = false;
-
- this.button_group = BI.createWidget({
- type: "bi.list_pane",
- element: this,
- el: {
- type: "bi.loader",
- isDefaultInit: false,
- logic: {
- dynamic: true,
- scrolly: true
- },
- items: this._createItems(opts.items),
- chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
- layouts: [{
- type: "bi.vertical",
- lgap: 10
- }]
- },
- itemsCreator: function (options, callback) {
-
- opts.itemsCreator(options, function (ob) {
- self.hasNext = !!ob.hasNext;
- callback(self._createItems(ob.items));
- })
- },
- hasNext: function () {
- return self.hasNext;
- }
- });
- },
-
- _createItems: function (items) {
- return BI.createItems(items, {
- type: 'bi.icon_text_item',
- cls: 'cursor-default check-font display-list-item bi-tips',
- once: true,
- invalid: true,
- selected: true,
- height: this.constants.height,
- logic: {
- dynamic: true
- }
- });
- },
-
- empty: function () {
- this.button_group.empty();
- },
-
- populate: function (items) {
- if (arguments.length === 0) {
- this.button_group.populate();
- } else {
- this.button_group.populate(this._createItems(items));
- }
- }
-});
-
-BI.shortcut('bi.display_selected_list', BI.DisplaySelectedList);/**
- *
- * @class BI.MultiSelectCombo
- * @extends BI.Single
- */
-BI.MultiSelectCombo = BI.inherit(BI.Single, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-combo',
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- height: 28
- });
- },
-
- _init: function () {
- BI.MultiSelectCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- var assertShowValue = function () {
- BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
- self.trigger.getSearcher().setState(self.storeValue);
- self.trigger.getCounter().setButtonChecked(self.storeValue);
- };
- this.storeValue = {};
-
- this.trigger = BI.createWidget({
- type: "bi.multi_select_trigger",
- height: o.height,
- // adapter: this.popup,
- masker: {
- offset: {
- left: 1,
- top: 1,
- right: 2,
- bottom: 33
- }
- },
- valueFormatter: o.valueFormatter,
- itemsCreator: function (op, callback) {
- o.itemsCreator(op, function (res) {
- if (op.times === 1 && BI.isNotNull(op.keywords)) {
- //预防trigger内部把当前的storeValue改掉
- self.trigger.setValue(BI.deepClone(self.getValue()));
- }
- callback.apply(self, arguments);
- });
- }
- });
-
- this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
- self._setStartValue("");
- this.getSearcher().setValue(self.storeValue);
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
- self._setStartValue("");
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
- if (this.getSearcher().hasMatched()) {
- var keyword = this.getSearcher().getKeyword();
- self._join({
- type: BI.Selection.Multi,
- value: [keyword]
- }, function () {
- self.combo.setValue(self.storeValue);
- self._setStartValue(keyword);
- assertShowValue();
- self.populate();
- self._setStartValue("");
- })
- }
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
- var last = BI.last(keywords);
- keywords = BI.initial(keywords || []);
- if (keywords.length > 0) {
- self._joinKeywords(keywords, function () {
- if (BI.isEndWithBlank(last)) {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- self.combo.populate();
- self._setStartValue("");
- } else {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- }
- });
- }
- });
-
- this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
- if (obj instanceof BI.MultiSelectBar) {
- self._joinAll(this.getValue(), function () {
- assertShowValue();
- });
- } else {
- self._join(this.getValue(), function () {
- assertShowValue();
- });
- }
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
- this.getCounter().setValue(self.storeValue);
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- toggle: false,
- el: this.trigger,
- adjustLength: 1,
- popup: {
- type: 'bi.multi_select_popup_view',
- ref: function () {
- self.popup = this;
- self.trigger.setAdapter(this);
- },
- listeners: [{
- eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
- action: function () {
- self.storeValue = this.getValue();
- self._adjust(function () {
- assertShowValue();
- });
- }
- }, {
- eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,
- action: function () {
- self._defaultState();
- }
- }, {
- eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,
- action: function () {
- self.setValue();
- self._defaultState();
- }
- }],
- itemsCreator: o.itemsCreator,
- valueFormatter: o.valueFormatter,
- onLoaded: function () {
- BI.nextTick(function () {
- self.combo.adjustWidth();
- self.combo.adjustHeight();
- self.trigger.getCounter().adjustView();
- self.trigger.getSearcher().adjustView();
- });
- }
- },
- hideChecker: function (e) {
- return triggerBtn.element.find(e.target).length === 0;
- }
- });
-
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- this.setValue(self.storeValue);
- BI.nextTick(function () {
- self.populate();
- });
- });
- this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
- //important:关闭弹出时又可能没有退出编辑状态
- self.trigger.stopEditing();
- self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
- });
-
- var triggerBtn = BI.createWidget({
- type: "bi.trigger_icon_button",
- width: o.height,
- height: o.height,
- cls: "multi-select-trigger-icon-button bi-border-left"
- });
- triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
- self.trigger.getCounter().hideView();
- if (self.combo.isViewVisible()) {
- self.combo.hideView();
- } else {
- self.combo.showView();
- }
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.combo,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- }, {
- el: triggerBtn,
- right: 0,
- top: 0,
- bottom: 0
- }]
- })
- },
-
- _defaultState: function () {
- this.trigger.stopEditing();
- this.combo.hideView();
- },
-
- _assertValue: function (val) {
- val || (val = {});
- val.type || (val.type = BI.Selection.Multi);
- val.value || (val.value = []);
- },
-
- _makeMap: function (values) {
- return BI.makeObject(values || []);
- },
-
- _joinKeywords: function (keywords, callback) {
- var self = this, o = this.options;
- this._assertValue(this.storeValue);
- o.itemsCreator({
- type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
- keywords: keywords
- }, function (ob) {
- var values = BI.pluck(ob.items, "value");
- digest(values);
- });
-
- function digest(items) {
- var selectedMap = self._makeMap(items);
- BI.each(keywords, function (i, val) {
- if (BI.isNotNull(selectedMap[val])) {
- self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
- }
- });
- self._adjust(callback);
- }
- },
-
- _joinAll: function (res, callback) {
- var self = this, o = this.options;
- this._assertValue(res);
- o.itemsCreator({
- type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
- keywords: [this.trigger.getKey()]
- }, function (ob) {
- var items = BI.pluck(ob.items, "value");
- if (self.storeValue.type === res.type) {
- var change = false;
- var map = self._makeMap(self.storeValue.value);
- BI.each(items, function (i, v) {
- if (BI.isNotNull(map[v])) {
- change = true;
- delete map[v];
- }
- });
- change && (self.storeValue.value = BI.values(map));
- self._adjust(callback);
- return;
- }
- var selectedMap = self._makeMap(self.storeValue.value);
- var notSelectedMap = self._makeMap(res.value);
- var newItems = [];
- BI.each(items, function (i, item) {
- if (BI.isNotNull(selectedMap[items[i]])) {
- delete selectedMap[items[i]];
- }
- if (BI.isNull(notSelectedMap[items[i]])) {
- newItems.push(item);
- }
- });
- self.storeValue.value = newItems.concat(BI.values(selectedMap));
- self._adjust(callback);
- })
- },
-
- _adjust: function (callback) {
- var self = this, o = this.options;
- if (!this._count) {
- o.itemsCreator({
- type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
- }, function (res) {
- self._count = res.count;
- adjust();
- callback();
- });
- } else {
- adjust();
- callback();
- }
- function adjust() {
- if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
- self.storeValue = {
- type: BI.Selection.Multi,
- value: []
- }
- } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
- self.storeValue = {
- type: BI.Selection.All,
- value: []
- }
- }
- }
- },
-
- _join: function (res, callback) {
- var self = this, o = this.options;
- this._assertValue(res);
- this._assertValue(this.storeValue);
- if (this.storeValue.type === res.type) {
- var map = this._makeMap(this.storeValue.value);
- BI.each(res.value, function (i, v) {
- if (!map[v]) {
- self.storeValue.value.push(v);
- map[v] = v;
- }
- });
- var change = false;
- BI.each(res.assist, function (i, v) {
- if (BI.isNotNull(map[v])) {
- change = true;
- delete map[v];
- }
- });
- change && (this.storeValue.value = BI.values(map));
- self._adjust(callback);
- return;
- }
- this._joinAll(res, callback);
- },
-
- _setStartValue: function (value) {
- this._startValue = value;
- this.popup.setStartValue(value);
- },
-
- setValue: function (v) {
- this.storeValue = v || {};
- this._assertValue(this.storeValue);
- this.combo.setValue(this.storeValue);
- },
-
- getValue: function () {
- return this.storeValue;
- },
-
- populate: function () {
- this._count = null;
- this.combo.populate.apply(this.combo, arguments);
- }
-});
-
-BI.extend(BI.MultiSelectCombo, {
- REQ_GET_DATA_LENGTH: 0,
- REQ_GET_ALL_DATA: -1
-});
-
-BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-
-BI.shortcut('bi.multi_select_combo', BI.MultiSelectCombo);/**
- * 多选加载数据面板
- * Created by guy on 15/11/2.
- * @class BI.MultiSelectLoader
- * @extends Widget
- */
-BI.MultiSelectLoader = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectLoader.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-loader',
- logic: {
- dynamic: true
- },
- el: {
- height: 400
- },
- valueFormatter: BI.emptyFn,
- itemsCreator: BI.emptyFn,
- onLoaded: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiSelectLoader.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
- var hasNext = false;
-
- this.button_group = BI.createWidget({
- type: "bi.select_list",
- element: this,
- logic: opts.logic,
- el: BI.extend({
- onLoaded: opts.onLoaded,
- el: {
- type: "bi.loader",
- isDefaultInit: false,
- logic: {
- dynamic: true,
- scrolly: true
- },
- el: {
- chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
- behaviors: {
- redmark: function () {
- return true;
- }
- },
- layouts: [{
- type: "bi.vertical"
- }]
- }
- }
- }, opts.el),
- itemsCreator: function (op, callback) {
- var startValue = self._startValue;
- self.storeValue && (op = BI.extend(op || {}, {
- selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi
- ? self.storeValue.value.concat(startValue) : self.storeValue.value
- }));
- opts.itemsCreator(op, function (ob) {
- hasNext = ob.hasNext;
- var firstItems = [];
- if (op.times === 1 && self.storeValue) {
- var json = BI.map(self.storeValue.value, function (i, v) {
- var txt = opts.valueFormatter(v) || v;
- return {
- text: txt,
- value: v,
- title: txt,
- selected: self.storeValue.type === BI.Selection.Multi
- }
- });
- if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) {
- var txt = opts.valueFormatter(startValue) || startValue;
- json.unshift({
- text: txt,
- value: startValue,
- title: txt,
- selected: true
- })
- }
- firstItems = self._createItems(json);
- }
- callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
- if (op.times === 1 && self.storeValue) {
- BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue);
- self.setValue(self.storeValue);
- }
- (op.times === 1) && self._scrollToTop();
- });
- },
- hasNext: function () {
- return hasNext;
- }
- });
- this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE, arguments);
- });
- },
-
- _createItems: function (items) {
- return BI.createItems(items, {
- type: "bi.multi_select_item",
- logic: this.options.logic,
- height: 25,
- selected: this.isAllSelected()
- })
- },
-
- _scrollToTop: function () {
- var self = this;
- BI.delay(function () {
- self.button_group.element.scrollTop(0);
- }, 30);
- },
-
- isAllSelected: function () {
- return this.button_group.isAllSelected();
- },
-
- _assertValue: function (val) {
- val || (val = {});
- val.type || (val.type = BI.Selection.Multi);
- val.value || (val.value = []);
- },
-
- setStartValue: function (v) {
- this._startValue = v;
- },
-
- setValue: function (v) {
- this.storeValue = v || {};
- this._assertValue(this.storeValue);
- this.button_group.setValue(this.storeValue);
- },
-
- getValue: function () {
- return this.button_group.getValue();
- },
-
- getAllButtons: function () {
- return this.button_group.getAllButtons();
- },
-
- empty: function () {
- this.button_group.empty();
- },
-
- populate: function (items) {
- this.button_group.populate.apply(this.button_group, arguments);
- },
-
- resetHeight: function (h) {
- this.button_group.resetHeight(h);
- },
-
- resetWidth: function (w) {
- this.button_group.resetWidth(w);
- }
-});
-
-BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.multi_select_loader', BI.MultiSelectLoader);/**
- * 带加载的多选下拉面板
- * @class BI.MultiSelectPopupView
- * @extends Widget
- */
-BI.MultiSelectPopupView = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-popup-view',
- maxWidth: 'auto',
- minWidth: 135,
- maxHeight: 400,
- valueFormatter: BI.emptyFn,
- itemsCreator: BI.emptyFn,
- onLoaded: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiSelectPopupView.superclass._init.apply(this, arguments);
- var self = this, opts = this.options;
-
- this.loader = BI.createWidget({
- type: "bi.multi_select_loader",
- itemsCreator: opts.itemsCreator,
- valueFormatter: opts.valueFormatter,
- onLoaded: opts.onLoaded
- });
-
- this.popupView = BI.createWidget({
- type: "bi.multi_popup_view",
- stopPropagation: false,
- maxWidth: opts.maxWidth,
- minWidth: opts.minWidth,
- maxHeight: opts.maxHeight,
- element: this,
- buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')],
- el: this.loader
- });
-
- this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE);
- });
- this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
- switch (index) {
- case 0:
- self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR);
- break;
- case 1:
- self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM);
- break;
- }
- });
- },
-
- isAllSelected: function () {
- return this.loader.isAllSelected();
- },
-
- setStartValue: function (v) {
- this.loader.setStartValue(v);
- },
-
- setValue: function (v) {
- this.popupView.setValue(v);
- },
-
- getValue: function () {
- return this.popupView.getValue();
- },
-
- populate: function (items) {
- this.popupView.populate.apply(this.popupView, arguments);
- },
-
- resetHeight: function (h) {
- this.popupView.resetHeight(h);
- },
-
- resetWidth: function (w) {
- this.popupView.resetWidth(w);
- }
-});
-
-BI.MultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE";
-BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
-BI.MultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
-
-
-BI.shortcut('bi.multi_select_popup_view', BI.MultiSelectPopupView);/**
- *
- * 复选下拉框
- * @class BI.MultiSelectTrigger
- * @extends BI.Trigger
- */
-
-BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
-
- constants: {
- height: 14,
- rgap: 4,
- lgap: 4
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-select-trigger bi-border",
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- searcher: {},
- switcher: {},
-
- adapter: null,
- masker: {}
- });
- },
-
- _init: function () {
- BI.MultiSelectTrigger.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
- if (o.height) {
- this.setHeight(o.height - 2);
- }
-
- this.searcher = BI.createWidget(o.searcher, {
- type: "bi.multi_select_searcher",
- height: o.height,
- itemsCreator: o.itemsCreator,
- valueFormatter: o.valueFormatter,
- popup: {},
- adapter: o.adapter,
- masker: o.masker
- });
- this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_START);
- });
- this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE);
- });
- this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING, arguments);
- });
- this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_STOP);
- });
- this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE, arguments);
- });
- this.numberCounter = BI.createWidget(o.switcher, {
- type: 'bi.multi_select_check_selected_switcher',
- valueFormatter: o.valueFormatter,
- itemsCreator: o.itemsCreator,
- adapter: o.adapter,
- masker: o.masker
- });
- this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK);
- });
- this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
- });
-
- var wrapNumberCounter = BI.createWidget({
- type: 'bi.right_vertical_adapt',
- hgap: 4,
- items: [{
- el: this.numberCounter
- }]
- });
-
- var wrapper = BI.createWidget({
- type: 'bi.htape',
- element: this,
- items: [
- {
- el: this.searcher,
- width: 'fill'
- }, {
- el: wrapNumberCounter,
- width: 0
- }, {
- el: BI.createWidget(),
- width: 30
- }]
- });
-
- this.numberCounter.on(BI.Events.VIEW, function (b) {
- BI.nextTick(function () {//自动调整宽度
- wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
- wrapper.resize();
- });
- });
-
- this.element.click(function (e) {
- if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) {
- self.numberCounter.hideView();
- }
- });
- },
-
- getCounter: function () {
- return this.numberCounter;
- },
-
- getSearcher: function () {
- return this.searcher;
- },
-
- stopEditing: function () {
- this.searcher.stopSearch();
- this.numberCounter.hideView();
- },
-
- setAdapter: function (adapter) {
- this.searcher.setAdapter(adapter);
- this.numberCounter.setAdapter(adapter);
- },
-
- setValue: function (ob) {
- this.searcher.setValue(ob);
- this.numberCounter.setValue(ob);
- },
-
- getKey: function () {
- return this.searcher.getKey();
- },
-
- getValue: function () {
- return this.searcher.getValue();
- }
-});
-
-BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
-BI.MultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
-BI.MultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE";
-BI.MultiSelectTrigger.EVENT_START = "EVENT_START";
-BI.MultiSelectTrigger.EVENT_STOP = "EVENT_STOP";
-BI.MultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE";
-BI.MultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
-
-BI.shortcut('bi.multi_select_trigger', BI.MultiSelectTrigger);/**
- * 多选加载数据搜索loader面板
- * Created by guy on 15/11/4.
- * @class BI.MultiSelectSearchLoader
- * @extends Widget
- */
-BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-search-loader',
- itemsCreator: BI.emptyFn,
- keywordGetter: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- });
- },
-
- _init: function () {
- BI.MultiSelectSearchLoader.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
- var hasNext = false;
-
- this.button_group = BI.createWidget({
- type: "bi.select_list",
- element: this,
- logic: {
- dynamic: false
- },
- el: {
- tipText: BI.i18nText("BI-No_Select"),
- el: {
- type: "bi.loader",
- isDefaultInit: false,
- logic: {
- dynamic: true,
- scrolly: true
- },
- el: {
- chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
- behaviors: {
- redmark: function () {
- return true;
- }
- },
- layouts: [{
- type: "bi.vertical"
- }]
- }
- }
- },
- itemsCreator: function (op, callback) {
- self.storeValue && (op = BI.extend(op || {}, {
- selectedValues: self.storeValue.value
- }));
- opts.itemsCreator(op, function (ob) {
- var keyword = ob.keyword = opts.keywordGetter();
- hasNext = ob.hasNext;
- var firstItems = [];
- if (op.times === 1 && self.storeValue) {
- var json = self._filterValues(self.storeValue);
- firstItems = self._createItems(json);
- }
- callback(firstItems.concat(self._createItems(ob.items)), keyword);
- if (op.times === 1 && self.storeValue) {
- self.setValue(self.storeValue);
- }
- });
- },
- hasNext: function () {
- return hasNext;
- }
- });
- this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE, arguments);
- });
- },
-
- _createItems: function (items) {
- return BI.createItems(items, {
- type: "bi.multi_select_item",
- logic: {
- dynamic: false
- },
- height: 25,
- selected: this.isAllSelected()
- })
- },
-
- isAllSelected: function () {
- return this.button_group.isAllSelected();
- },
-
- _filterValues: function (src) {
- var o = this.options;
- var keyword = o.keywordGetter();
- var values = BI.deepClone(src.value) || [];
- var newValues = BI.map(values, function (i, v) {
- return {
- text: o.valueFormatter(v) || v,
- value: v
- };
- });
- if (BI.isKey(keyword)) {
- var search = BI.Func.getSearchResult(newValues, keyword);
- values = search.matched.concat(search.finded);
- }
- return BI.map(values, function (i, v) {
- return {
- text: v.text,
- title: v.text,
- value: v.value,
- selected: src.type === BI.Selection.All
- }
- })
- },
-
- setValue: function (v) {
- //暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
- this.storeValue = BI.deepClone(v);
- this.button_group.setValue(v);
- },
-
- getValue: function () {
- return this.button_group.getValue();
- },
-
- getAllButtons: function () {
- return this.button_group.getAllButtons();
- },
-
- empty: function () {
- this.button_group.empty();
- },
-
- populate: function (items) {
- this.button_group.populate.apply(this.button_group, arguments);
- },
-
- resetHeight: function (h) {
- this.button_group.resetHeight(h);
- },
-
- resetWidth: function (w) {
- this.button_group.resetWidth(w);
- }
-});
-
-BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.multi_select_search_loader', BI.MultiSelectSearchLoader);/**
- *
- * 在搜索框中输入文本弹出的面板
- * @class BI.MultiSelectSearchPane
- * @extends Widget
- */
-
-BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
-
- constants: {
- height: 25,
- lgap: 10,
- tgap: 5
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-select-search-pane bi-card",
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- keywordGetter: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiSelectSearchPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.tooltipClick = BI.createWidget({
- type: "bi.label",
- invisible: true,
- text: BI.i18nText('BI-Click_Blank_To_Select'),
- cls: 'multi-select-toolbar',
- height: this.constants.height
- });
-
- this.loader = BI.createWidget({
- type: "bi.multi_select_search_loader",
- keywordGetter: o.keywordGetter,
- valueFormatter: o.valueFormatter,
- itemsCreator: function (op, callback) {
- o.itemsCreator.apply(self, [op, function (res) {
- callback(res);
- self.setKeyword(o.keywordGetter());
- }]);
- }
- });
- this.loader.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.resizer = BI.createWidget({
- type: "bi.vtape",
- element: this,
- items: [{
- el: this.tooltipClick,
- height: 0
- }, {
- el: this.loader
- }]
- });
- this.tooltipClick.setVisible(false);
- },
-
- setKeyword: function (keyword) {
- var btn;
- var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue());
- if (isVisible !== this.tooltipClick.isVisible()) {
- this.tooltipClick.setVisible(isVisible);
- this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0);
- this.resizer.resize();
- }
- },
-
- isAllSelected: function () {
- return this.loader.isAllSelected();
- },
-
- hasMatched: function () {
- return this.tooltipClick.isVisible();
- },
-
- setValue: function (v) {
- this.loader.setValue(v);
- },
-
- getValue: function () {
- return this.loader.getValue();
- },
-
- empty: function () {
- this.loader.empty();
- },
-
- populate: function (items) {
- this.loader.populate.apply(this.loader, arguments);
- }
-});
-
-BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
-
-BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);/**
- * 查看已选按钮
- * Created by guy on 15/11/3.
- * @class BI.MultiSelectCheckSelectedButton
- * @extends BI.Single
- */
-BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, {
-
- _const: {
- checkSelected: BI.i18nText('BI-Check_Selected')
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-check-selected-button bi-high-light',
- itemsCreator: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments);
- var self = this;
- this.numberCounter = BI.createWidget({
- type: 'bi.text_button',
- element: this,
- hgap: 4,
- text: "0",
- textAlign: 'center',
- textHeight: 15
- });
- this.numberCounter.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.numberCounter.on(BI.TextButton.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
- });
-
- this.numberCounter.element.hover(function () {
- self.numberCounter.setTag(self.numberCounter.getText());
- self.numberCounter.setText(self._const.checkSelected);
- }, function () {
- self.numberCounter.setText(self.numberCounter.getTag());
- });
- this.setVisible(false);
- },
-
- setValue: function (ob) {
- var self = this, o = this.options;
- ob || (ob = {});
- ob.type || (ob.type = BI.Selection.Multi);
- ob.value || (ob.value = []);
- if (ob.type === BI.Selection.All) {
- o.itemsCreator({
- type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
- }, function (res) {
- var length = res.count - ob.value.length;
- BI.nextTick(function(){
- self.numberCounter.setText(length);
- self.setVisible(length > 0);
- });
- });
- return;
- }
- BI.nextTick(function(){
- self.numberCounter.setText(ob.value.length);
- self.setVisible(ob.value.length > 0);
- })
- },
-
- getValue: function () {
-
- }
-});
-
-BI.MultiSelectCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.multi_select_check_selected_button', BI.MultiSelectCheckSelectedButton);/**
- * 多选输入框
- * Created by guy on 15/11/3.
- * @class BI.MultiSelectEditor
- * @extends Widget
- */
-BI.MultiSelectEditor = BI.inherit(BI.Widget, {
-
- _const: {
- checkSelected: BI.i18nText('BI-Check_Selected')
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectEditor.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-editor',
- el: {}
- });
- },
-
- _init: function () {
- BI.MultiSelectEditor.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.editor = BI.createWidget(o.el, {
- type: 'bi.state_editor',
- element: this,
- height: o.height,
- watermark: BI.i18nText('BI-Basic_Search'),
- allowBlank: true
- });
-
- this.editor.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.editor.on(BI.StateEditor.EVENT_PAUSE, function () {
- self.fireEvent(BI.MultiSelectEditor.EVENT_PAUSE);
- });
- this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () {
-
- });
- },
-
- focus: function () {
- this.editor.focus();
- },
-
- blur: function () {
- this.editor.blur();
- },
-
- setState: function (state) {
- this.editor.setState(state);
- },
-
- setValue: function (v) {
- this.editor.setValue(v);
- },
-
- getValue: function () {
- var v = this.editor.getState();
- if (BI.isArray(v) && v.length > 0) {
- return v[v.length - 1];
- } else {
- return "";
- }
- },
-
- getKeywords: function () {
- var val = this.editor.getLastValidValue();
- var keywords = val.match(/[\S]+/g);
- if (BI.isEndWithBlank(val)) {
- return keywords.concat([' ']);
- }
- return keywords;
- },
-
- populate: function (items) {
-
- }
-});
-BI.MultiSelectEditor.EVENT_PAUSE = "MultiSelectEditor.EVENT_PAUSE";
-BI.shortcut('bi.multi_select_editor', BI.MultiSelectEditor);/**
- * searcher
- * Created by guy on 15/11/3.
- * @class BI.MultiSelectSearcher
- * @extends Widget
- */
-BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-searcher',
- itemsCreator: BI.emptyFn,
- el: {},
- popup: {},
- valueFormatter: BI.emptyFn,
- adapter: null,
- masker: {}
- });
- },
-
- _init: function () {
- BI.MultiSelectSearcher.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.editor = BI.createWidget(o.el, {
- type: 'bi.multi_select_editor',
- height: o.height
- });
-
- this.searcher = BI.createWidget({
- type: "bi.searcher",
- element: this,
- height: o.height,
- isAutoSearch: false,
- isAutoSync: false,
- onSearch: function (op, callback) {
- callback();
- },
- el: this.editor,
-
- popup: BI.extend({
- type: "bi.multi_select_search_pane",
- valueFormatter: o.valueFormatter,
- keywordGetter: function () {
- return self.editor.getValue();
- },
- itemsCreator: function (op, callback) {
- op.keyword = self.editor.getValue();
- this.setKeyword(op.keyword);
- o.itemsCreator(op, callback);
- }
- }, o.popup),
-
- adapter: o.adapter,
- masker: o.masker
- });
- this.searcher.on(BI.Searcher.EVENT_START, function () {
- self.fireEvent(BI.MultiSelectSearcher.EVENT_START);
- });
- this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
- if (this.hasMatched()) {
-
- }
- self.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE);
- });
- this.searcher.on(BI.Searcher.EVENT_STOP, function () {
- self.fireEvent(BI.MultiSelectSearcher.EVENT_STOP);
- });
- this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE, arguments);
- });
- this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
- var keywords = this.getKeywords();
- self.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING, keywords);
- });
- },
-
- adjustView: function () {
- this.searcher.adjustView();
- },
-
- isSearching: function () {
- return this.searcher.isSearching();
- },
-
- stopSearch: function () {
- this.searcher.stopSearch();
- },
-
- getKeyword: function () {
- return this.editor.getValue();
- },
-
- hasMatched: function () {
- return this.searcher.hasMatched();
- },
-
- hasChecked: function () {
- return this.searcher.getView() && this.searcher.getView().hasChecked();
- },
-
- setAdapter: function (adapter) {
- this.searcher.setAdapter(adapter);
- },
-
- setState: function (ob) {
- var o = this.options;
- ob || (ob = {});
- ob.value || (ob.value = []);
- if (ob.type === BI.Selection.All) {
- if (BI.size(ob.assist) === 1) {
- this.editor.setState(o.valueFormatter(ob.assist[0] + "") || (ob.assist[0] + ""));
- } else {
- this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All);
- }
- } else {
- if (BI.size(ob.value) === 1) {
- this.editor.setState(o.valueFormatter(ob.value[0] + "") || (ob.value[0] + ""));
- } else {
- this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None);
- }
- }
- },
-
- setValue: function (ob) {
- this.setState(ob);
- this.searcher.setValue(ob);
- },
-
- getKey: function () {
- return this.editor.getValue();
- },
-
- getValue: function () {
- return this.searcher.getValue();
- },
-
- populate: function (items) {
- this.searcher.populate.apply(this.searcher, arguments);
- }
-});
-
-BI.MultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.MultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE";
-BI.MultiSelectSearcher.EVENT_START = "EVENT_START";
-BI.MultiSelectSearcher.EVENT_STOP = "EVENT_STOP";
-BI.MultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE";
-BI.MultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.shortcut('bi.multi_select_searcher', BI.MultiSelectSearcher);/**
- * 查看已选switcher
- * Created by guy on 15/11/3.
- * @class BI.MultiSelectCheckSelectedSwitcher
- * @extends Widget
- */
-BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectCheckSelectedSwitcher.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-check-selected-switcher',
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- el: {},
- popup: {},
- adapter: null,
- masker: {}
- });
- },
-
- _init: function () {
- BI.MultiSelectCheckSelectedSwitcher.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.button = BI.createWidget(o.el, {
- type: "bi.multi_select_check_selected_button",
- itemsCreator: o.itemsCreator
- });
- this.button.on(BI.Events.VIEW, function () {
- self.fireEvent(BI.Events.VIEW, arguments);
- });
- this.switcher = BI.createWidget({
- type: "bi.switcher",
- toggle: false,
- element: this,
- el: this.button,
- popup: BI.extend({
- type: "bi.multi_select_check_pane",
- valueFormatter: o.valueFormatter,
- itemsCreator: o.itemsCreator,
- onClickContinueSelect: function () {
- self.switcher.hideView();
- }
- }, o.popup),
- adapter: o.adapter,
- masker: o.masker
- });
- this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE, function () {
- self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE);
- });
- this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW);
- });
- this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW, function () {
- var me = this;
- BI.nextTick(function () {
- me.populate();
- });
- });
-
- this.switcher.element.click(function (e) {
- e.stopPropagation();
- });
- },
-
- adjustView: function () {
- this.switcher.adjustView();
- },
-
- hideView: function () {
- this.switcher.empty();
- this.switcher.hideView();
- },
-
- setAdapter: function (adapter) {
- this.switcher.setAdapter(adapter);
- },
-
- setValue: function (v) {
- this.switcher.setValue(v);
- },
-
- setButtonChecked: function (v) {
- this.button.setValue(v)
- },
-
- getValue: function () {
-
- },
-
- populate: function (items) {
- this.switcher.populate.apply(this.switcher, arguments);
- }
-});
-
-BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE";
-BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/**
- * Created by zcf_1 on 2017/5/2.
- */
-BI.MultiSelectList = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-list',
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn
- })
- },
- _init: function () {
- BI.MultiSelectList.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
- this.storeValue = {};
-
- var assertShowValue = function () {
- BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
- // self.trigger.setValue(self.storeValue);
- };
-
- this.adapter = BI.createWidget({
- type: "bi.multi_select_loader",
- cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom",
- itemsCreator: o.itemsCreator,
- valueFormatter: o.valueFormatter,
- // onLoaded: o.onLoaded,
- el: {
- height: ""
- }
- });
- this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
- self.storeValue = this.getValue();
- self._adjust(function () {
- assertShowValue();
- self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
- });
- });
-
- this.searcherPane = BI.createWidget({
- type: "bi.multi_select_search_pane",
- cls: "bi-border-left bi-border-right bi-border-bottom",
- valueFormatter: o.valueFormatter,
- keywordGetter: function () {
- return self.trigger.getKeyword();
- },
- itemsCreator: function (op, callback) {
- op.keyword = self.trigger.getKeyword();
- this.setKeyword(op.keyword);
- o.itemsCreator(op, callback);
- }
- });
- this.searcherPane.setVisible(false);
-
- this.trigger = BI.createWidget({
- type: "bi.searcher",
- isAutoSearch: false,
- isAutoSync: false,
- onSearch: function (op, callback) {
- callback();
- },
- adapter: this.adapter,
- popup: this.searcherPane,
- height: 200,
- masker: false,
- listeners: [{
- eventName: BI.Searcher.EVENT_START,
- action: function () {
- self._showSearcherPane();
- self._setStartValue("");
- this.setValue(BI.deepClone(self.storeValue));
- }
- }, {
- eventName: BI.Searcher.EVENT_STOP,
- action: function () {
- self._showAdapter();
- self._setStartValue("");
- self.adapter.setValue(self.storeValue);
- //需要刷新回到初始界面,否则搜索的结果不能放在最前面
- self.adapter.populate();
- }
- }, {
- eventName: BI.Searcher.EVENT_PAUSE,
- action: function () {
- if (this.hasMatched()) {
- var keyword = this.getKeyword();
- self._join({
- type: BI.Selection.Multi,
- value: [keyword]
- }, function () {
- self._showAdapter();
- self.adapter.setValue(self.storeValue);
- self._setStartValue(keyword);
- assertShowValue();
- self._setStartValue("");
- self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
- })
- } else {
- self._showAdapter();
- }
- }
- }, {
- eventName: BI.Searcher.EVENT_SEARCHING,
- action: function () {
- var keywords = this.getKeyword();
- var last = BI.last(keywords);
- keywords = BI.initial(keywords || []);
- if (keywords.length > 0) {
- self._joinKeywords(keywords, function () {
- if (BI.isEndWithBlank(last)) {
- self.adapter.setValue(self.storeValue);
- assertShowValue();
- self.adapter.populate();
- self._setStartValue("");
- } else {
- self.adapter.setValue(self.storeValue);
- assertShowValue();
- }
- });
- }
- }
- }, {
- eventName: BI.Searcher.EVENT_CHANGE,
- action: function (value, obj) {
- if (obj instanceof BI.MultiSelectBar) {
- self._joinAll(this.getValue(), function () {
- assertShowValue();
- });
- } else {
- self._join(this.getValue(), function () {//安徽省 北京
- assertShowValue();
- });
- }
- }
- }]
- });
-
- BI.createWidget({
- type: "bi.vtape",
- element: this,
- items: [{
- el: this.trigger,
- height: 30
- }, {
- el: this.adapter,
- height: "fill"
- }]
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.searcherPane,
- top: 30,
- bottom: 0,
- left: 0,
- right: 0
- }]
- })
- },
-
- _showAdapter: function () {
- this.adapter.setVisible(true);
- this.searcherPane.setVisible(false);
- },
-
- _showSearcherPane: function () {
- this.searcherPane.setVisible(true);
- this.adapter.setVisible(false);
- },
-
- _defaultState: function () {
- this.trigger.stopEditing();
- },
-
- _assertValue: function (val) {
- val || (val = {});
- val.type || (val.type = BI.Selection.Multi);
- val.value || (val.value = []);
- },
-
- _makeMap: function (values) {
- return BI.makeObject(values || []);
- },
-
- _joinKeywords: function (keywords, callback) {
- var self = this, o = this.options;
- this._assertValue(this.storeValue);
- if (!this._allData) {
- o.itemsCreator({
- type: BI.MultiSelectList.REQ_GET_ALL_DATA
- }, function (ob) {
- self._allData = BI.pluck(ob.items, "value");
- digest(self._allData);
- })
- } else {
- digest(this._allData)
- }
-
- function digest(items) {
- var selectedMap = self._makeMap(items);
- BI.each(keywords, function (i, val) {
- if (BI.isNotNull(selectedMap[val])) {
- self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
- }
- });
- self._adjust(callback);
- }
- },
-
- _joinAll: function (res, callback) {
- var self = this, o = this.options;
- this._assertValue(res);
- o.itemsCreator({
- type: BI.MultiSelectList.REQ_GET_ALL_DATA,
- keyword: self.trigger.getKeyword()
- }, function (ob) {
- var items = BI.pluck(ob.items, "value");
- if (self.storeValue.type === res.type) {
- var change = false;
- var map = self._makeMap(self.storeValue.value);
- BI.each(items, function (i, v) {
- if (BI.isNotNull(map[v])) {
- change = true;
- delete map[v];
- }
- });
- change && (self.storeValue.value = BI.values(map));
- self._adjust(callback);
- return;
- }
- var selectedMap = self._makeMap(self.storeValue.value);
- var notSelectedMap = self._makeMap(res.value);
- var newItems = [];
- BI.each(items, function (i, item) {
- if (BI.isNotNull(selectedMap[items[i]])) {
- delete selectedMap[items[i]];
- }
- if (BI.isNull(notSelectedMap[items[i]])) {
- newItems.push(item);
- }
- });
- self.storeValue.value = newItems.concat(BI.values(selectedMap));
- self._adjust(callback);
- })
- },
-
- _adjust: function (callback) {
- var self = this, o = this.options;
- if (!this._count) {
- o.itemsCreator({
- type: BI.MultiSelectList.REQ_GET_DATA_LENGTH
- }, function (res) {
- self._count = res.count;
- adjust();
- callback();
- });
- } else {
- adjust();
- callback();
- }
- function adjust() {
- if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
- self.storeValue = {
- type: BI.Selection.Multi,
- value: []
- }
- } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
- self.storeValue = {
- type: BI.Selection.All,
- value: []
- }
- }
- }
- },
-
- _join: function (res, callback) {
- var self = this, o = this.options;
- this._assertValue(res);
- this._assertValue(this.storeValue);
- if (this.storeValue.type === res.type) {
- var map = this._makeMap(this.storeValue.value);
- BI.each(res.value, function (i, v) {
- if (!map[v]) {
- self.storeValue.value.push(v);
- map[v] = v;
- }
- });
- var change = false;
- BI.each(res.assist, function (i, v) {
- if (BI.isNotNull(map[v])) {
- change = true;
- delete map[v];
- }
- });
- change && (this.storeValue.value = BI.values(map));
- self._adjust(callback);
- return;
- }
- this._joinAll(res, callback);
- },
-
- _setStartValue: function (value) {
- this._startValue = value;
- this.adapter.setStartValue(value);
- },
-
- isAllSelected: function () {
- return this.adapter.isAllSelected();
- },
-
- resize: function () {
- // this.trigger.getCounter().adjustView();
- // this.trigger.adjustView();
- },
- setValue: function (v) {
- this.storeValue = v || {};
- this._assertValue(this.storeValue);
- this.adapter.setValue(this.storeValue);
- this.trigger.setValue(this.storeValue);
- },
-
- getValue: function () {
- return this.storeValue;
- },
-
- populate: function () {
- this._count = null;
- this._allData = null;
- this.adapter.populate.apply(this.adapter, arguments);
- this.trigger.populate.apply(this.trigger, arguments);
- }
-});
-
-BI.extend(BI.MultiSelectList, {
- REQ_GET_DATA_LENGTH: 0,
- REQ_GET_ALL_DATA: -1
-});
-
-BI.MultiSelectList.EVENT_CHANGE = "BI.MultiSelectList.EVENT_CHANGE";
-BI.shortcut("bi.multi_select_list", BI.MultiSelectList);/**
- * Created by zcf_1 on 2017/5/11.
- */
-BI.MultiSelectTree = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-tree',
- itemsCreator: BI.emptyFn
- })
- },
-
- _init: function () {
- BI.MultiSelectTree.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.storeValue = {value: {}};
-
- this.adapter = BI.createWidget({
- type: "bi.multi_select_tree_popup",
- itemsCreator: o.itemsCreator
- });
- this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
- if (self.searcher.isSearching()) {
- self.storeValue = {value: self.searcherPane.getValue()};
- } else {
- self.storeValue = {value: self.adapter.getValue()};
- }
- self.setSelectedValue(self.storeValue.value);
- self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
- });
-
- //搜索中的时候用的是parttree,同adapter中的synctree不一样
- this.searcherPane = BI.createWidget({
- type: "bi.multi_tree_search_pane",
- cls: "bi-border-left bi-border-right bi-border-bottom",
- keywordGetter: function () {
- return self.searcher.getKeyword();
- },
- itemsCreator: function (op, callback) {
- op.keyword = self.searcher.getKeyword();
- o.itemsCreator(op, callback);
- }
- });
- this.searcherPane.setVisible(false);
-
- this.searcher = BI.createWidget({
- type: "bi.searcher",
- isAutoSearch: false,
- isAutoSync: false,
- onSearch: function (op, callback) {
- callback({
- keyword: self.searcher.getKeyword()
- });
- },
- adapter: this.adapter,
- popup: this.searcherPane,
- masker: false,
- listeners: [{
- eventName: BI.Searcher.EVENT_START,
- action: function () {
- self._showSearcherPane();
- // self.storeValue = {value: self.adapter.getValue()};
- // self.searcherPane.setSelectedValue(self.storeValue.value);
- }
- }, {
- eventName: BI.Searcher.EVENT_STOP,
- action: function () {
- self._showAdapter();
- // self.storeValue = {value: self.searcherPane.getValue()};
- // self.adapter.setSelectedValue(self.storeValue.value);
- BI.nextTick(function () {
- self.adapter.populate();
- });
- }
- }, {
- eventName: BI.Searcher.EVENT_CHANGE,
- action: function () {
- if (self.searcher.isSearching()) {
- self.storeValue = {value: self.searcherPane.getValue()};
- } else {
- self.storeValue = {value: self.adapter.getValue()};
- }
- self.setSelectedValue(self.storeValue.value);
- self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
- }
- }, {
- eventName: BI.Searcher.EVENT_PAUSE,
- action: function () {
- self._showAdapter();
- }
- }]
- });
-
- BI.createWidget({
- type: "bi.vtape",
- element: this,
- items: [{
- el: this.searcher,
- height: 30
- }, {
- el: this.adapter,
- height: "fill"
- }]
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.searcherPane,
- top: 30,
- bottom: 0,
- left: 0,
- right: 0
- }]
- })
-
- },
-
- _showAdapter: function () {
- this.adapter.setVisible(true);
- this.searcherPane.setVisible(false);
- },
-
- _showSearcherPane: function () {
- this.searcherPane.setVisible(true);
- this.adapter.setVisible(false);
- },
-
- resize: function () {
-
- },
-
- setSelectedValue: function (v) {
- this.storeValue.value = v || {};
- this.adapter.setSelectedValue(v);
- this.searcherPane.setSelectedValue(v);
- this.searcher.setValue({
- value: v || {}
- });
- },
-
- setValue: function (v) {
- this.adapter.setValue(v);
- },
-
- stopSearch: function () {
- this.searcher.stopSearch();
- },
-
- updateValue: function (v) {
- this.adapter.updateValue(v);
- },
-
- getValue: function () {
- return this.storeValue.value;
- },
-
- populate: function () {
- this.searcher.populate.apply(this.searcher, arguments);
- this.adapter.populate.apply(this.adapter, arguments);
- }
-});
-BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
-BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
- * Created by zcf on 2016/12/21.
- */
-BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom",
- itemsCreator: BI.emptyFn
- });
- },
- _init: function () {
- BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.popup = BI.createWidget({
- type: "bi.async_tree",
- element: this,
- itemsCreator: o.itemsCreator
- });
- this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
- self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)
- });
- this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)
- });
- },
-
- hasChecked: function () {
- return this.popup.hasChecked();
- },
-
- getValue: function () {
- return this.popup.getValue();
- },
-
- setValue: function (v) {
- v || (v = {});
- this.popup.setValue(v);
- },
-
- setSelectedValue: function (v) {
- v || (v = {});
- this.popup.setSelectedValue(v);
- },
-
- updateValue: function (v) {
- this.popup.updateValue(v);
- this.popup.refresh();
- },
-
- populate: function (config) {
- this.popup.stroke(config);
- }
-
-});
-BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
-BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
-BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);/**
- *
- * @class BI.MultiTreeCheckPane
- * @extends BI.Pane
- */
-BI.MultiTreeCheckPane = BI.inherit(BI.Pane, {
-
- constants: {
- height: 25,
- lgap: 10,
- tgap: 5
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-tree-check-pane bi-background",
- onClickContinueSelect: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiTreeCheckPane.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
-
- this.selectedValues = {};
-
- var continueSelect = BI.createWidget({
- type: 'bi.text_button',
- text: BI.i18nText('BI-Continue_Select'),
- cls: 'multi-tree-check-selected'
- });
- continueSelect.on(BI.TextButton.EVENT_CHANGE, function () {
- opts.onClickContinueSelect();
- BI.nextTick(function () {
- self.empty();
- });
- });
-
- var backToPopup = BI.createWidget({
- type: 'bi.left',
- cls: 'multi-tree-continue-select',
- items: [
- {
- el: {
- type: "bi.label",
- text: BI.i18nText('BI-Selected_Data')
- },
- lgap: this.constants.lgap,
- tgap: this.constants.tgap
- },
- {
- el: continueSelect,
- lgap: this.constants.lgap,
- tgap: this.constants.tgap
- }]
- });
-
- this.display = BI.createWidget({
- type: "bi.display_tree",
- cls: "bi-multi-tree-display",
- itemsCreator: function (op, callback) {
- op.type = BI.TreeView.REQ_TYPE_GET_SELECTED_DATA;
- opts.itemsCreator(op, callback);
- }
- });
-
- this.display.on(BI.Events.AFTERINIT, function () {
- self.fireEvent(BI.Events.AFTERINIT);
- });
-
- this.display.on(BI.TreeView.EVENT_INIT, function () {
- backToPopup.setVisible(false);
- });
-
- this.display.on(BI.TreeView.EVENT_AFTERINIT, function () {
- backToPopup.setVisible(true);
- });
-
- BI.createWidget({
- type: 'bi.vtape',
- element: this,
- items: [{
- height: this.constants.height,
- el: backToPopup
- }, {
- height: 'fill',
- el: this.display
- }]
- });
-
- },
-
- empty: function () {
- this.display.empty();
- },
-
- populate: function (configs) {
- this.display.stroke(configs);
- },
-
- setValue: function (v) {
- v || (v = {});
- this.display.setSelectedValue(v.value);
- },
-
- getValue: function () {
-
- }
-});
-
-BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK";
-
-
-BI.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/**
- *
- * @class BI.MultiTreeCombo
- * @extends BI.Single
- */
-
-BI.MultiTreeCombo = BI.inherit(BI.Single, {
-
- constants: {
- offset: {
- top: 1,
- left: 1,
- right: 2,
- bottom: 33
- }
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-tree-combo',
- itemsCreator: BI.emptyFn,
- height: 25
- });
- },
-
- _init: function () {
- BI.MultiTreeCombo.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- var isInit = false;
- var want2showCounter = false;
-
- this.trigger = BI.createWidget({
- type: "bi.multi_select_trigger",
- height: o.height,
- // adapter: this.popup,
- masker: {
- offset: this.constants.offset
- },
- searcher: {
- type: "bi.multi_tree_searcher",
- itemsCreator: o.itemsCreator
- },
- switcher: {
- el: {
- type: "bi.multi_tree_check_selected_button"
- },
- popup: {
- type: "bi.multi_tree_check_pane",
- itemsCreator: o.itemsCreator
- }
- }
-
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- toggle: false,
- el: this.trigger,
- adjustLength: 1,
- popup: {
- type: 'bi.multi_tree_popup_view',
- ref: function () {
- self.popup = this;
- self.trigger.setAdapter(this);
- },
- listeners: [{
- eventName: BI.MultiTreePopup.EVENT_AFTERINIT,
- action: function () {
- self.trigger.getCounter().adjustView();
- isInit = true;
- if (want2showCounter === true) {
- showCounter();
- }
- }
- }, {
- eventName: BI.MultiTreePopup.EVENT_CHANGE,
- action: function () {
- change = true;
- var val = {
- type: BI.Selection.Multi,
- value: this.hasChecked() ? {1: 1} : {}
- };
- self.trigger.getSearcher().setState(val);
- self.trigger.getCounter().setButtonChecked(val);
- }
- }, {
- eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM,
- action: function () {
- self.combo.hideView();
- }
- }, {
- eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR,
- action: function () {
- clear = true;
- self.setValue();
- self._defaultState();
- }
- }],
- itemsCreator: o.itemsCreator,
- onLoaded: function () {
- BI.nextTick(function () {
- self.trigger.getCounter().adjustView();
- self.trigger.getSearcher().adjustView();
- });
- }
- },
- hideChecker: function (e) {
- return triggerBtn.element.find(e.target).length === 0;
- }
- });
-
- this.storeValue = {value: {}};
- var change = false;
- var clear = false; //标识当前是否点击了清空
-
- var isSearching = function () {
- return self.trigger.getSearcher().isSearching();
- };
-
- var isPopupView = function () {
- return self.combo.isViewVisible();
- };
-
- this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
- self.storeValue = {value: self.combo.getValue()};
- this.setValue(self.storeValue);
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
- self.storeValue = {value: this.getValue()};
- self.combo.setValue(self.storeValue);
- BI.nextTick(function () {
- if (isPopupView()) {
- self.combo.populate();
- }
- });
- });
- function showCounter() {
- if (isSearching()) {
- self.storeValue = {value: self.trigger.getValue()};
- } else if (isPopupView()) {
- self.storeValue = {value: self.combo.getValue()};
- }
- self.trigger.setValue(self.storeValue);
- }
-
- this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
- if (want2showCounter === false) {
- want2showCounter = true;
- }
- if (isInit === true) {
- want2showCounter = null;
- showCounter();
- }
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () {
- self.combo.toggle();
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- });
-
- this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
- var val = {
- type: BI.Selection.Multi,
- value: this.getSearcher().hasChecked() ? {1: 1} : {}
- };
- this.getSearcher().setState(val);
- this.getCounter().setButtonChecked(val);
- });
-
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- if (isSearching()) {
- return;
- }
- if (change === true) {
- self.storeValue = {value: self.combo.getValue()};
- change = false;
- }
- self.combo.setValue(self.storeValue);
- self.populate();
-
- });
- this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () {
- if (isSearching()) {
- self.trigger.stopEditing();
- self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
- }else{
- if (isPopupView()) {
- self.trigger.stopEditing();
- self.storeValue = {value: self.combo.getValue()};
- if (clear === true) {
- self.storeValue = {value: {}};
- }
- self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
- }
- }
- clear = false;
- change = false;
- });
-
- var triggerBtn = BI.createWidget({
- type: "bi.trigger_icon_button",
- width: o.height,
- height: o.height,
- cls: "multi-select-trigger-icon-button bi-border-left"
- });
- triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
- self.trigger.getCounter().hideView();
- if (self.combo.isViewVisible()) {
- self.combo.hideView();
- } else {
- self.combo.showView();
- }
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.combo,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- }, {
- el: triggerBtn,
- right: 0,
- top: 0,
- bottom: 0
- }]
- })
- },
-
- _defaultState: function () {
- this.trigger.stopEditing();
- this.combo.hideView();
- },
-
- setValue: function (v) {
- this.storeValue.value = v || {};
- this.combo.setValue({
- value: v || {}
- });
- },
-
- getValue: function () {
- return this.storeValue.value;
- },
-
- populate: function () {
- this.combo.populate.apply(this.combo, arguments);
- }
-});
-
-BI.MultiTreeCombo.EVENT_CONFIRM = "MultiTreeCombo.EVENT_CONFIRM";
-
-BI.shortcut('bi.multi_tree_combo', BI.MultiTreeCombo);/**
- * 带加载的多选下拉面板
- * @class BI.MultiTreePopup
- * @extends BI.Pane
- */
-BI.MultiTreePopup = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-tree-popup',
- maxWidth: 'auto',
- minWidth: 100,
- maxHeight: 400,
- onLoaded: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiTreePopup.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
-
- this.selectedValues = {};
-
- this.tree = BI.createWidget({
- type: "bi.async_tree",
- height: 400,
- cls:"popup-view-tree",
- itemsCreator: opts.itemsCreator,
- onLoaded: opts.onLoaded
- });
-
- this.popupView = BI.createWidget({
- type: "bi.multi_popup_view",
- element: this,
- stopPropagation: false,
- maxWidth: opts.maxWidth,
- minWidth: opts.minWidth,
- maxHeight: opts.maxHeight,
- buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')],
- el: this.tree
- });
-
- this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
- switch (index) {
- case 0:
- self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR);
- break;
- case 1:
- self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM);
- break;
- }
- });
-
- this.tree.on(BI.TreeView.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiTreePopup.EVENT_CHANGE);
- });
-
- this.tree.on(BI.TreeView.EVENT_AFTERINIT, function () {
- self.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT);
- });
-
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- setValue: function (v) {
- v || (v = {});
- this.tree.setSelectedValue(v.value);
- },
-
- populate: function (config) {
- this.tree.stroke(config);
- },
-
- hasChecked: function () {
- return this.tree.hasChecked();
- },
-
- resetHeight: function (h) {
- this.popupView.resetHeight(h);
- },
-
- resetWidth: function (w) {
- this.popupView.resetWidth(w);
- }
-});
-
-BI.MultiTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.MultiTreePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
-BI.MultiTreePopup.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
-BI.MultiTreePopup.EVENT_AFTERINIT = "EVENT_AFTERINIT";
-
-
-BI.shortcut('bi.multi_tree_popup_view', BI.MultiTreePopup);/**
- *
- * 在搜索框中输入文本弹出的面板
- * @class BI.MultiTreeSearchPane
- * @extends BI.Pane
- */
-
-BI.MultiTreeSearchPane = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-tree-search-pane bi-card",
- itemsCreator: BI.emptyFn,
- keywordGetter: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiTreeSearchPane.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
-
- this.partTree = BI.createWidget({
- type: "bi.part_tree",
- element: this,
- tipText: BI.i18nText("BI-No_Select"),
- itemsCreator: function (op, callback) {
- op.keyword = opts.keywordGetter();
- opts.itemsCreator(op, callback);
- }
- });
-
- this.partTree.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.partTree.on(BI.TreeView.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE);
- });
- },
-
- hasChecked: function () {
- return this.partTree.hasChecked();
- },
-
- setValue: function (v) {
- this.setSelectedValue(v.value);
- },
-
- setSelectedValue: function (v) {
- v || (v = {});
- this.partTree.setSelectedValue(v);
- },
-
- getValue: function () {
- return this.partTree.getValue();
- },
-
- empty: function () {
- this.partTree.empty();
- },
-
- populate: function (op) {
- this.partTree.stroke.apply(this.partTree, arguments);
- }
-});
-
-BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
-
-BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
-BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
-
-BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane);/**
- * 查看已选按钮
- * Created by guy on 15/11/3.
- * @class BI.MultiTreeCheckSelectedButton
- * @extends BI.Single
- */
-BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, {
-
- _const: {
- checkSelected: BI.i18nText('BI-Check_Selected')
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreeCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-tree-check-selected-button',
- itemsCreator: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiTreeCheckSelectedButton.superclass._init.apply(this, arguments);
- var self = this;
- this.indicator = BI.createWidget({
- type: 'bi.icon_button',
- cls: 'check-font trigger-check-selected',
- width: 15,
- height: 15,
- stopPropagation: true
- });
-
- this.checkSelected = BI.createWidget({
- type: 'bi.text_button',
- cls: "trigger-check-selected",
- invisible: true,
- hgap: 4,
- text: this._const.checkSelected,
- textAlign: 'center',
- textHeight: 15
- });
- this.checkSelected.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.checkSelected.on(BI.TextButton.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
- });
-
- BI.createWidget({
- type: "bi.horizontal",
- element: this,
- items: [this.indicator, this.checkSelected]
- })
-
- this.element.hover(function () {
- self.indicator.setVisible(false);
- self.checkSelected.setVisible(true);
- }, function () {
- self.indicator.setVisible(true);
- self.checkSelected.setVisible(false);
- });
- this.setVisible(false);
- },
-
- setValue: function (v) {
- v || (v = {});
- this.setVisible(BI.size(v.value) > 0);
- }
-});
-
-BI.MultiTreeCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.multi_tree_check_selected_button', BI.MultiTreeCheckSelectedButton);/**
- * searcher
- * Created by guy on 15/11/3.
- * @class BI.MultiTreeSearcher
- * @extends Widget
- */
-BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-tree-searcher',
- itemsCreator: BI.emptyFn,
- popup: {},
-
- adapter: null,
- masker: {}
- });
- },
-
- _init: function () {
- BI.MultiTreeSearcher.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.editor = BI.createWidget({
- type: 'bi.multi_select_editor',
- height: o.height,
- el: {
- type: "bi.simple_state_editor",
- height: o.height
- }
- });
-
- this.searcher = BI.createWidget({
- type: "bi.searcher",
- element: this,
- isAutoSearch: false,
- isAutoSync: false,
- onSearch: function (op, callback) {
- callback({
- keyword: self.editor.getValue()
- });
- },
- el: this.editor,
-
- popup: BI.extend({
- type: "bi.multi_tree_search_pane",
- keywordGetter: function () {
- return self.editor.getValue();
- },
- itemsCreator: function (op, callback) {
- op.keyword = self.editor.getValue();
- o.itemsCreator(op, callback);
- }
- }, o.popup),
-
- adapter: o.adapter,
- masker: o.masker
- });
- this.searcher.on(BI.Searcher.EVENT_START, function () {
- self.fireEvent(BI.MultiTreeSearcher.EVENT_START);
- });
- this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
- if (this.hasMatched()) {
-
- }
- self.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE);
- });
- this.searcher.on(BI.Searcher.EVENT_STOP, function () {
- self.fireEvent(BI.MultiTreeSearcher.EVENT_STOP);
- });
- this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE, arguments);
- });
- },
-
- adjustView: function () {
- this.searcher.adjustView();
- },
-
- setAdapter: function (adapter) {
- this.searcher.setAdapter(adapter);
- },
-
- isSearching: function () {
- return this.searcher.isSearching();
- },
-
- stopSearch: function () {
- this.searcher.stopSearch();
- },
-
- getKeyword: function () {
- return this.editor.getValue();
- },
-
- hasMatched: function () {
- return this.searcher.hasMatched();
- },
-
- hasChecked: function () {
- return this.searcher.getView() && this.searcher.getView().hasChecked();
- },
-
- setState: function (ob) {
- ob || (ob = {});
- ob.value || (ob.value = []);
- if (ob.type === BI.Selection.All) {
- this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All);
- } else {
- this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None);
- }
- },
-
- setValue: function (ob) {
- this.setState(ob);
- this.searcher.setValue(ob);
- },
-
- getKey: function () {
- return this.editor.getValue();
- },
-
- getValue: function () {
- return this.searcher.getValue();
- },
-
- populate: function (items) {
- this.searcher.populate.apply(this.searcher, arguments);
- }
-});
-
-BI.MultiTreeSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE";
-BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
-BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
-BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
-BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);//小于号的值为:0,小于等于号的值为:1
-//closeMIn:最小值的符号,closeMax:最大值的符号
-/**
- * Created by roy on 15/9/17.
- *
- */
-BI.NumericalInterval = BI.inherit(BI.Single, {
- constants: {
- typeError: "typeBubble",
- numberError: "numberBubble",
- signalError: "signalBubble",
- editorWidth: 114,
- columns: 5,
- width: 30,
- rows: 1,
- numberErrorCls: "number-error",
- border: 1,
- less: 0,
- less_equal: 1,
- numTip: ""
- },
- _defaultConfig: function () {
- var conf = BI.NumericalInterval.superclass._defaultConfig.apply(this, arguments)
- return BI.extend(conf, {
- extraCls: "bi-numerical-interval",
- height: 25,
- validation: "valid"
- })
- },
- _init: function () {
- var self = this, c = this.constants, o = this.options;
- BI.NumericalInterval.superclass._init.apply(this, arguments)
- this.smallEditor = BI.createWidget({
- type: "bi.editor",
- height: o.height - 2,
- watermark: BI.i18nText("BI-Basic_Unrestricted"),
- allowBlank: true,
- value: o.min,
- level: "warning",
- tipType: "warning",
- quitChecker: function () {
- return false;
- },
- validationChecker: function (v) {
- if (!BI.isNumeric(v)) {
- self.smallEditorBubbleType = c.typeError;
- return false;
- }
- return true;
- },
- cls: "numerical-interval-small-editor bi-border-top bi-border-bottom bi-border-left"
- });
-
- this.smallTip = BI.createWidget({
- type: "bi.label",
- text: o.numTip,
- height: o.height - 2,
- invisible: true
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this.smallEditor.element,
- items: [{
- el: this.smallTip,
- top: 0,
- right: 5
- }]
- });
-
- this.bigEditor = BI.createWidget({
- type: "bi.editor",
- height: o.height - 2,
- watermark: BI.i18nText("BI-Basic_Unrestricted"),
- allowBlank: true,
- value: o.max,
- level: "warning",
- tipType: "warning",
- quitChecker: function () {
- return false;
- },
- validationChecker: function (v) {
- if (!BI.isNumeric(v)) {
- self.bigEditorBubbleType = c.typeError;
- return false;
- }
- return true;
- },
- cls: "numerical-interval-big-editor bi-border-top bi-border-bottom bi-border-right"
- });
-
- this.bigTip = BI.createWidget({
- type: "bi.label",
- text: o.numTip,
- height: o.height - 2,
- invisible: true
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this.bigEditor.element,
- items: [{
- el: this.bigTip,
- top: 0,
- right: 5
- }]
- });
-
- //this.smallCombo = BI.createWidget({
- // type: "bi.numerical_interval_combo",
- // cls: "numerical-interval-small-combo",
- // height: o.height,
- // value: o.closemin ? 1 : 0,
- // offsetStyle: "left"
- //});
- //
- //this.bigCombo = BI.createWidget({
- // type: "bi.numerical_interval_combo",
- // cls: "numerical-interval-big-combo",
- // height: o.height,
- // value: o.closemax ? 1 : 0,
- // offsetStyle: "left"
- //});
- this.smallCombo = BI.createWidget({
- type: "bi.icon_combo",
- cls: "numerical-interval-small-combo bi-border",
- height: o.height - 2,
- items: [{
- text: "(" + BI.i18nText("BI-Less_Than") + ")",
- iconClass: "less-font",
- value: 0
- }, {
- text: "(" + BI.i18nText("BI-Less_And_Equal") + ")",
- value: 1,
- iconClass: "less-equal-font"
- }]
- });
- if (o.closemin === true) {
- this.smallCombo.setValue(1);
- } else {
- this.smallCombo.setValue(0);
- }
- this.bigCombo = BI.createWidget({
- type: "bi.icon_combo",
- cls: "numerical-interval-big-combo bi-border",
- height: o.height - 2,
- items: [{
- text: "(" + BI.i18nText("BI-Less_Than") + ")",
- iconClass: "less-font",
- value: 0
- }, {
- text: "(" + BI.i18nText("BI-Less_And_Equal") + ")",
- value: 1,
- iconClass: "less-equal-font"
- }]
- });
- if (o.closemax === true) {
- this.bigCombo.setValue(1);
- } else {
- this.bigCombo.setValue(0);
- }
- this.label = BI.createWidget({
- type: "bi.label",
- text: BI.i18nText("BI-Basic_Value"),
- textHeight: o.height - c.border * 2,
- width: c.width - c.border * 2,
- height: o.height - c.border * 2,
- level: "warning",
- tipType: "warning"
- });
- this.left = BI.createWidget({
- type: "bi.htape",
- items: [{
- el: self.smallEditor
- }, {
- el: self.smallCombo,
- width: c.width - c.border * 2
- }]
-
- });
- this.right = BI.createWidget({
- type: "bi.htape",
- items: [{
- el: self.bigCombo,
- width: c.width - c.border * 2
- }, {
- el: self.bigEditor
- }]
- });
-
-
- BI.createWidget({
- element: self,
- type: "bi.center",
- hgap: 15,
- height: o.height,
- items: [
- {
- type: "bi.absolute",
- items: [{
- el: self.left,
- left: -15,
- right: 0,
- top: 0,
- bottom: 0
- }]
- }, {
- type: "bi.absolute",
- items: [{
- el: self.right,
- left: 0,
- right: -15,
- top: 0,
- bottom: 0
- }]
- }
- ]
- });
-
- BI.createWidget({
- element: self,
- type: "bi.horizontal_auto",
- items: [
- self.label
- ]
- });
-
-
- self._setValidEvent(self.bigEditor, c.bigEditor);
- self._setValidEvent(self.smallEditor, c.smallEditor);
- self._setErrorEvent(self.bigEditor, c.bigEditor);
- self._setErrorEvent(self.smallEditor, c.smallEditor);
- self._setBlurEvent(self.bigEditor);
- self._setBlurEvent(self.smallEditor);
- self._setFocusEvent(self.bigEditor);
- self._setFocusEvent(self.smallEditor);
- self._setComboValueChangedEvent(self.bigCombo);
- self._setComboValueChangedEvent(self.smallCombo);
- self._setEditorValueChangedEvent(self.bigEditor);
- self._setEditorValueChangedEvent(self.smallEditor);
- },
-
- _checkValidation: function () {
- var self = this, c = this.constants, o = this.options;
- self._setTitle("");
- BI.Bubbles.hide(c.typeError);
- BI.Bubbles.hide(c.numberError);
- BI.Bubbles.hide(c.signalError);
- if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) {
- self.element.removeClass("number-error");
- o.validation = "invalid";
- return c.typeError;
- } else {
- if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) {
- self.element.removeClass("number-error");
- o.validation = "valid";
- return "";
- } else {
- var smallValue = parseFloat(self.smallEditor.getValue()), bigValue = parseFloat(self.bigEditor.getValue()),
- bigComboValue = self.bigCombo.getValue(), smallComboValue = self.smallCombo.getValue();
- if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) {
- if (smallValue > bigValue) {
- self.element.addClass("number-error");
- o.validation = "invalid";
- return c.numberError;
- } else {
- self.element.removeClass("number-error");
- o.validation = "valid";
- return "";
- }
- } else {
- if (smallValue > bigValue) {
- self.element.addClass("number-error");
- o.validation = "invalid";
- return c.numberError;
- } else if (smallValue === bigValue) {
- self.element.addClass("number-error");
- o.validation = "invalid";
- return c.signalError;
- } else {
- self.element.removeClass("number-error");
- o.validation = "valid";
- return "";
- }
- }
- }
-
- }
- },
-
- _setTitle: function (v) {
- var self = this;
- self.bigEditor.setTitle(v);
- self.smallEditor.setTitle(v);
- self.label.setTitle(v);
- },
-
- _setFocusEvent: function (w) {
- var self = this, c = this.constants;
- w.on(BI.Editor.EVENT_FOCUS, function () {
- self._setTitle("");
- switch (self._checkValidation()) {
- case c.typeError:
- BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
- offsetStyle: "center"
- });
- break;
- case c.numberError:
- BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
- offsetStyle: "center"
- });
- break;
- case c.signalError:
- BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
- offsetStyle: "center"
- });
- break;
- default :
- return
- }
-
- })
- },
- _setBlurEvent: function (w) {
- var c = this.constants, self = this;
- w.on(BI.Editor.EVENT_BLUR, function () {
- BI.Bubbles.hide(c.typeError);
- BI.Bubbles.hide(c.numberError);
- BI.Bubbles.hide(c.signalError);
- switch (self._checkValidation()) {
- case c.typeError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));
- break;
- case c.numberError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));
- break;
- case c.signalError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));
- break;
- default:
- self._setTitle("");
- }
- })
- },
-
- _setErrorEvent: function (w) {
- var c = this.constants, self = this
- w.on(BI.Editor.EVENT_ERROR, function () {
- self._checkValidation();
- BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
- offsetStyle: "center"
- });
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- })
- },
-
-
- _setValidEvent: function (w) {
- var self = this, c = this.constants;
- w.on(BI.Editor.EVENT_VALID, function () {
- switch (self._checkValidation()) {
- case c.numberError:
- BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
- offsetStyle: "center"
- });
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- break;
- case c.signalError:
- BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
- offsetStyle: "center"
- });
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- break;
- default:
- self.fireEvent(BI.NumericalInterval.EVENT_VALID);
- }
- })
- },
-
-
- _setEditorValueChangedEvent: function (w) {
- var self = this, c = this.constants;
- w.on(BI.Editor.EVENT_CHANGE, function () {
- switch (self._checkValidation()) {
- case c.typeError:
- BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
- offsetStyle: "center"
- });
- break;
- case c.numberError:
- BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
- offsetStyle: "center"
- });
- break;
- case c.signalError:
- BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
- offsetStyle: "center"
- });
- break;
- default :
- break;
- }
- self.fireEvent(BI.NumericalInterval.EVENT_CHANGE);
- });
- },
-
- _setComboValueChangedEvent: function (w) {
- var self = this, c = this.constants;
- w.on(BI.IconCombo.EVENT_CHANGE, function () {
- switch (self._checkValidation()) {
- case c.typeError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- break;
- case c.numberError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- break;
- case c.signalError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- break;
- default :
- self.fireEvent(BI.NumericalInterval.EVENT_CHANGE);
- self.fireEvent(BI.NumericalInterval.EVENT_VALID);
- }
- })
- },
-
- isStateValid: function () {
- return this.options.validation === "valid";
- },
-
- setMinEnable: function (b) {
- this.smallEditor.setEnable(b);
- },
-
- setCloseMinEnable: function (b) {
- this.smallCombo.setEnable(b);
- },
-
- setMaxEnable: function (b) {
- this.bigEditor.setEnable(b);
- },
-
- setCloseMaxEnable: function (b) {
- this.bigCombo.setEnable(b);
- },
-
- showNumTip: function () {
- this.smallTip.setVisible(true);
- this.bigTip.setVisible(true);
- },
-
- hideNumTip: function () {
- this.smallTip.setVisible(false);
- this.bigTip.setVisible(false);
- },
-
- setNumTip: function(numTip) {
- this.smallTip.setText(numTip);
- this.bigTip.setText(numTip);
- },
-
- getNumTip: function() {
- return this.smallTip.getText();
- },
-
- setValue: function (data) {
- data = data || {};
- var self = this, combo_value;
- if (BI.isNumeric(data.min) || BI.isEmptyString(data.min)) {
- self.smallEditor.setValue(data.min);
- }
-
- if (!BI.isNotNull(data.min)) {
- self.smallEditor.setValue("");
- }
-
- if (BI.isNumeric(data.max) || BI.isEmptyString(data.max)) {
- self.bigEditor.setValue(data.max);
- }
-
- if (!BI.isNotNull(data.max)) {
- self.bigEditor.setValue("");
- }
-
- if (!BI.isNull(data.closemin)) {
- if (data.closemin === true) {
- combo_value = 1
- } else {
- combo_value = 0
- }
- self.smallCombo.setValue(combo_value);
- }
-
- if (!BI.isNull(data.closemax)) {
- if (data.closemax === true) {
- combo_value = 1
- } else {
- combo_value = 0
- }
- self.bigCombo.setValue(combo_value);
- }
- },
-
-
- getValue: function () {
- var self = this, value = {}, minComboValue = self.smallCombo.getValue(), maxComboValue = self.bigCombo.getValue();
- value.min = self.smallEditor.getValue();
- value.max = self.bigEditor.getValue();
- if (minComboValue[0] === 0) {
- value.closemin = false
- } else {
- value.closemin = true
- }
-
- if (maxComboValue[0] === 0) {
- value.closemax = false
- } else {
- value.closemax = true
- }
- return value;
- }
-});
-BI.NumericalInterval.EVENT_CHANGE = "EVENT_CHANGE";
-BI.NumericalInterval.EVENT_VALID = "EVENT_VALID";
-BI.NumericalInterval.EVENT_ERROR = "EVENT_ERROR";
-BI.shortcut("bi.numerical_interval", BI.NumericalInterval);/**
- *
- * 表格
- *
- * Created by GUY on 2015/9/22.
- * @class BI.PageTableCell
- * @extends BI.Single
- */
-BI.PageTableCell = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-page-table-cell",
- text: "",
- title: ""
- })
- },
-
- _init: function () {
- BI.PageTableCell.superclass._init.apply(this, arguments);
- var label = BI.createWidget({
- type: "bi.label",
- element: this,
- textAlign: "left",
- whiteSpace: "nowrap",
- height: this.options.height,
- text: this.options.text,
- title: this.options.title,
- value: this.options.value,
- lgap: 5,
- rgap: 5
- });
-
- if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) {
- this.element.css(this.options.styles);
- }
- }
-});
-
-BI.shortcut("bi.page_table_cell", BI.PageTableCell);/**
- * 分页表格
- *
- * Created by GUY on 2016/2/15.
- * @class BI.PageTable
- * @extends BI.Widget
- */
-BI.PageTable = BI.inherit(BI.Widget, {
-
- _const: {
- scrollWidth: 18,
- minScrollWidth: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-page-table",
- el: {
- type: "bi.sequence_table"
- },
- pager: {
- horizontal: {
- pages: false, //总页数
- curr: 1, //初始化当前页, pages为数字时可用
-
- hasPrev: BI.emptyFn,
- hasNext: BI.emptyFn,
- firstPage: 1,
- lastPage: BI.emptyFn
- },
- vertical: {
- pages: false, //总页数
- curr: 1, //初始化当前页, pages为数字时可用
-
- hasPrev: BI.emptyFn,
- hasNext: BI.emptyFn,
- firstPage: 1,
- lastPage: BI.emptyFn
- }
- },
-
- itemsCreator: BI.emptyFn,
-
- isNeedFreeze: false,//是否需要冻结单元格
- freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
-
- isNeedMerge: false,//是否需要合并单元格
- mergeCols: [], //合并的单元格列号
- mergeRule: BI.emptyFn,
-
- columnSize: [],
- minColumnSize: [],
- maxColumnSize: [],
- headerRowSize: 25,
- rowSize: 25,
-
- regionColumnSize: [],
-
- headerCellStyleGetter: BI.emptyFn,
- summaryCellStyleGetter: BI.emptyFn,
- sequenceCellStyleGetter: BI.emptyFn,
-
- header: [],
- items: [], //二维数组
-
- //交叉表头
- crossHeader: [],
- crossItems: []
- });
- },
-
- _init: function () {
- BI.PageTable.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.hCurr = 1;
- this.vCurr = 1;
-
- this.table = BI.createWidget(o.el, {
- type: "bi.sequence_table",
- width: o.width,
- height: o.height && o.height - 30,
-
- isNeedResize: true,
- isResizeAdapt: false,
-
- isNeedFreeze: o.isNeedFreeze,
- freezeCols: o.freezeCols,
-
- isNeedMerge: o.isNeedMerge,
- mergeCols: o.mergeCols,
- mergeRule: o.mergeRule,
-
- columnSize: o.columnSize,
- minColumnSize: o.minColumnSize,
- maxColumnSize: o.maxColumnSize,
- headerRowSize: o.headerRowSize,
- rowSize: o.rowSize,
-
- regionColumnSize: o.regionColumnSize,
-
- headerCellStyleGetter: o.headerCellStyleGetter,
- summaryCellStyleGetter: o.summaryCellStyleGetter,
- sequenceCellStyleGetter: o.sequenceCellStyleGetter,
-
- header: o.header,
- items: o.items,
- //交叉表头
- crossHeader: o.crossHeader,
- crossItems: o.crossItems
- });
-
- this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
- self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
- o.regionColumnSize = this.getRegionColumnSize();
- o.columnSize = this.getColumnSize();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
- o.regionColumnSize = this.getRegionColumnSize();
- o.columnSize = this.getColumnSize();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
- });
-
- this.pager = BI.createWidget(o.pager, {
- type: "bi.direction_pager",
- height: 30
- });
- this.pager.on(BI.Pager.EVENT_CHANGE, function () {
- var vpage = this.getVPage && this.getVPage();
- if (BI.isNull(vpage)) {
- vpage = this.getCurrentPage();
- }
- var hpage = this.getHPage && this.getHPage();
- o.itemsCreator({
- vpage: vpage,
- hpage: hpage
- }, function (items, header, crossItems, crossHeader) {
- self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage);
- self.table.setHPage && self.table.setHPage(hpage);
- self.populate.apply(self, arguments);
- });
- });
-
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.table,
- left: 0,
- top: 0
- }, {
- el: this.pager,
- left: 0,
- right: 0,
- bottom: 0
- }]
- })
- },
-
- setHPage: function (v) {
- this.hCurr = v;
- this.pager.setHPage && this.pager.setHPage(v);
- this.table.setHPage && this.table.setHPage(v);
- },
-
- setVPage: function (v) {
- this.vCurr = v;
- this.pager.setVPage && this.pager.setVPage(v);
- this.table.setVPage && this.table.setVPage(v);
- },
-
- getHPage: function () {
- var hpage = this.pager.getHPage && this.pager.getHPage();
- if (BI.isNotNull(hpage)) {
- return hpage;
- }
- hpage = this.pager.getCurrentPage && this.pager.getCurrentPage();
- if (BI.isNotNull(hpage)) {
- return hpage;
- }
- return this.hpage;
- },
-
- getVPage: function () {
- var vpage = this.pager.getVPage && this.pager.getVPage();
- if (BI.isNotNull(vpage)) {
- return vpage;
- }
- vpage = this.pager.getCurrentPage && this.pager.getCurrentPage();
- if (BI.isNotNull(vpage)) {
- return vpage;
- }
- return this.vpage;
- },
-
- setWidth: function (width) {
- BI.PageTable.superclass.setWidth.apply(this, arguments);
- this.table.setWidth(width);
- },
-
- setHeight: function (height) {
- BI.PageTable.superclass.setHeight.apply(this, arguments);
- var showPager = false;
- if (this.pager.alwaysShowPager) {
- showPager = true;
- } else if (this.pager.hasHNext && this.pager.hasHNext()) {
- showPager = true;
- } else if (this.pager.hasHPrev && this.pager.hasHPrev()) {
- showPager = true;
- } else if (this.pager.hasVNext && this.pager.hasVNext()) {
- showPager = true;
- } else if (this.pager.hasVPrev && this.pager.hasVPrev()) {
- showPager = true;
- } else if (this.pager.hasNext && this.pager.hasNext()) {
- showPager = true;
- } else if (this.pager.hasPrev && this.pager.hasPrev()) {
- showPager = true;
- }
- this.table.setHeight(height - (showPager ? 30 : 0));
- },
-
- setColumnSize: function (columnSize) {
- this.options.columnSize = columnSize;
- this.table.setColumnSize(columnSize);
- },
-
- getColumnSize: function () {
- return this.table.getColumnSize();
- },
-
- setRegionColumnSize: function (columnSize) {
- this.options.columnSize = columnSize;
- this.table.setRegionColumnSize(columnSize);
- },
-
- getRegionColumnSize: function () {
- return this.table.getRegionColumnSize();
- },
-
- getVerticalScroll: function () {
- return this.table.getVerticalScroll();
- },
-
- setLeftHorizontalScroll: function (scrollLeft) {
- this.table.setLeftHorizontalScroll(scrollLeft);
- },
-
- setRightHorizontalScroll: function (scrollLeft) {
- this.table.setRightHorizontalScroll(scrollLeft);
- },
-
- setVerticalScroll: function (scrollTop) {
- this.table.setVerticalScroll(scrollTop);
- },
-
- restore: function () {
- this.table.restore();
- },
-
- attr: function () {
- BI.PageTable.superclass.attr.apply(this, arguments);
- this.table.attr.apply(this.table, arguments);
- },
-
- populate: function () {
- this.pager.populate();
- this.table.populate.apply(this.table, arguments);
- },
-
- destroy: function () {
- this.table.destroy();
- this.pager && this.pager.destroy();
- BI.PageTable.superclass.destroy.apply(this, arguments);
- }
-});
-BI.shortcut('bi.page_table', BI.PageTable);/**
- * 路径选择
- *
- * Created by GUY on 2015/12/4.
- * @class BI.PathChooser
- * @extends BI.Widget
- */
-BI.PathChooser = BI.inherit(BI.Widget, {
-
- _const: {
- lineColor: "#d4dadd",
- selectLineColor: "#3f8ce8"
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-path-chooser",
- items: []
- })
- },
-
- _init: function () {
- BI.PathChooser.superclass._init.apply(this, arguments);
- this.populate(this.options.items);
- },
-
- _createRegions: function (regions) {
- var self = this;
- this.regions = BI.createWidgets(BI.map(regions, function (i, region) {
- return {
- type: "bi.path_region",
- title: self.texts[region] || region
- }
- }));
- this.regionMap = {};
- BI.each(regions, function (i, region) {
- self.regionMap[region] = i;
- });
- this.container = BI.createWidget({
- type: "bi.horizontal",
- verticalAlign: "top",
- scrollx: false,
- scrolly: false,
- hgap: 10,
- items: this.regions
- });
- BI.createWidget({
- type: "bi.vertical_adapt",
- element: this,
- scrollable: true,
- hgap: 10,
- items: [this.container]
- });
- },
-
- getRegionIndexById: function (id) {
- var node = this.store[id];
- var regionType = node.get("region");
- return this.regionMap[regionType];
- },
-
- _drawPath: function (start, offset, index) {
- var self = this;
- var starts = [];
- if (BI.contains(this.start, start)) {
- starts = this.start;
- } else {
- starts = [start];
- }
-
- BI.each(starts, function (i, s) {
- BI.each(self.radios[s], function (i, rad) {
- rad.setSelected(false);
- });
- BI.each(self.lines[s], function (i, line) {
- line.attr("stroke", self._const.lineColor);
- });
- BI.each(self.regionIndexes[s], function (i, idx) {
- self.regions[idx].reset();
- });
- });
-
- BI.each(this.routes[start][index], function (i, id) {
- var regionIndex = self.getRegionIndexById(id);
- self.regions[regionIndex].setSelect(offset + index, id);
- });
- var current = BI.last(this.routes[start][index]);
-
- while (current && this.routes[current] && this.routes[current].length === 1) {
- BI.each(this.routes[current][0], function (i, id) {
- var regionIndex = self.getRegionIndexById(id);
- self.regions[regionIndex].setSelect(0, id);
- });
- this.lines[current][0].attr("stroke", self._const.selectLineColor).toFront();
- current = BI.last(this.routes[current][0]);
- }
- this.lines[start][index].attr("stroke", self._const.selectLineColor).toFront();
- this.radios[start] && this.radios[start][index] && this.radios[start][index].setSelected(true);
- },
-
- _drawRadio: function (start, offset, index, x, y) {
- var self = this;
- var radio = BI.createWidget({
- type: "bi.radio",
- cls: "path-chooser-radio",
- selected: offset + index === 0,
- start: start,
- index: index
- });
- radio.on(BI.Radio.EVENT_CHANGE, function () {
- self._drawPath(start, offset, index);
- self.fireEvent(BI.PathChooser.EVENT_CHANGE, start, index);
- });
- if (!this.radios[start]) {
- this.radios[start] = [];
- }
- this.radios[start].push(radio);
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: [{
- el: radio,
- left: x - 6.5,
- top: y - 6.5
- }]
- })
- },
-
- _drawLine: function (start, lines) {
- var self = this;
- if (!this.lines[start]) {
- this.lines[start] = [];
- }
- if (!this.pathes[start]) {
- this.pathes[start] = [];
- }
- var startRegionIndex = this.getRegionIndexById(start);
- //start所在的位置,然后接着往下画其他的路径
- var offset = this.regions[startRegionIndex].getIndexByValue(start);
- BI.each(lines, function (i, line) {
- self.pathes[start][i] = [];
- var idx = i + offset;
- var path = "";
- var stop = 47.5 + 29 * idx;
- var sleft = 50 + 100 * startRegionIndex;
- var radioStartX = sleft, radioStartY = stop;
- var etop = stop;
- var endRegionIndex = self.getRegionIndexById(BI.last(line));
- var endOffset = self.regions[endRegionIndex].getIndexByValue(BI.last(line));
- var eleft = 50 + 100 * endRegionIndex;
- if (BI.contains(self.start, start)) {
- radioStartX = sleft - 50;
- path += "M" + (sleft - 50) + "," + stop;
- self.pathes[start][i].push({
- x: sleft - 50,
- y: stop
- })
- } else if (idx === 0) {
- radioStartX = sleft + 50;
- path += "M" + sleft + "," + stop;
- self.pathes[start][i].push({
- x: sleft,
- y: stop
- })
- } else {
- radioStartX = sleft + 50;
- path += "M" + sleft + "," + 47.5 + "L" + (sleft + 50) + "," + 47.5 + "L" + (sleft + 50) + "," + stop;
- self.pathes[start][i].push({
- x: sleft,
- y: 47.5
- });
- self.pathes[start][i].push({
- x: sleft + 50,
- y: 47.5
- });
- self.pathes[start][i].push({
- x: sleft + 50,
- y: stop
- });
- }
- if (idx > 0) {
- var endY = endOffset * 29 + 47.5;
- path += "L" + (eleft - 50) + "," + etop + "L" + (eleft - 50) + "," + endY + "L" + eleft + "," + endY;
- self.pathes[start][i].push({
- x: eleft - 50,
- y: etop
- });
- self.pathes[start][i].push({
- x: eleft - 50,
- y: endY
- });
- self.pathes[start][i].push({
- x: eleft,
- y: endY
- });
- } else {
- path += "L" + eleft + "," + etop;
- self.pathes[start][i].push({
- x: eleft,
- y: etop
- });
- }
-
- var graph = self.svg.path(path)
- .attr({
- stroke: idx === 0 ? self._const.selectLineColor : self._const.lineColor,
- 'stroke-dasharray': '-'
- });
- self.lines[start].push(graph);
- if (lines.length > 1) {
- self.lines[start][0].toFront();
- }
- //第一个元素无论有多少个都要显示radio
- if (BI.contains(self.start, start)) {
- self.lines[self.regions[0].getValueByIndex(0)][0].toFront();
- }
- if (lines.length > 1 || BI.contains(self.start, start)) {
- self._drawRadio(start, offset, i, radioStartX, radioStartY);
- }
- });
- },
-
- _drawLines: function (routes) {
- var self = this;
- this.lines = {};
- this.pathes = {};
- this.radios = {};
- this.regionIndexes = {};
- BI.each(routes, function (k, route) {
- if (!self.regionIndexes[k]) {
- self.regionIndexes[k] = [];
- }
- BI.each(route, function (i, rs) {
- BI.each(rs, function (j, id) {
- var regionIndex = self.getRegionIndexById(id);
- if (!BI.contains(self.regionIndexes[k], regionIndex)) {
- self.regionIndexes[k].push(regionIndex);
- }
- });
- })
- });
- BI.each(routes, function (k, route) {
- self._drawLine(k, route);
- });
- },
-
- _pushNodes: function (nodes) {
- var self = this;
- var indexes = [];
- for (var i = 0; i < nodes.length; i++) {
- var id = nodes[i];
- var index = self.getRegionIndexById(id);
- indexes.push(index);
- var region = self.regions[index];
- if (i === nodes.length - 1) {
- if (!region.hasItem(id)) {
- region.addItem(id, self.texts[id]);
- }
- break;
- }
- if (i > 0 || BI.contains(self.start, id)) {
- region.addItem(id, self.texts[id]);
- }
- }
- for (var i = BI.first(indexes); i < BI.last(indexes); i++) {
- if (!BI.contains(indexes, i)) {
- self.regions[i].addItem("");
- }
- }
- },
-
- _createNodes: function () {
- var self = this, o = this.options;
- this.store = {};
- this.texts = {};
- this.start = [];
- this.end = [];
- BI.each(o.items, function (i, item) {
- self.start.push(BI.first(item).value);
- self.end.push(BI.last(item).value);
- });
- this.start = BI.uniq(this.start);
- this.end = BI.uniq(this.end);
- var regions = [];
- var tree = new BI.Tree();
- var branches = {}, max = 0;
- BI.each(o.items, function (i, items) {
- BI.each(items, function (j, item) {
- if (!BI.has(branches, item.value)) {
- branches[item.value] = 0;
- }
- branches[item.value]++;
- max = Math.max(max, branches[item.value]);
- var prev = {};
- if (j > 0) {
- prev = items[j - 1];
- }
- var parent = self.store[prev.value || ""];
- var node = self.store[item.value] || new BI.Node(item.value);
- node.set(item);
- self.store[item.value] = node;
- self.texts[item.value] = item.text;
- self.texts[item.region] = item.regionText;
- parent = BI.isNull(parent) ? tree.getRoot() : parent;
- if (parent.getChildIndex(item.value) === -1) {
- tree.addNode(parent, node);
- }
- })
- });
-
- //算出区域列表
- tree.traverse(function (node) {
- BI.each(node.getChildren(), function (i, child) {
- if (BI.contains(regions, child.get("region"))) {
- var index1 = BI.indexOf(regions, node.get("region"));
- var index2 = BI.indexOf(regions, child.get("region"));
- //交换区域
- if (index1 > index2) {
- var t = regions[index2];
- for (var j = index2; j < index1; j++) {
- regions[j] = regions[j + 1];
- }
- regions[index1] = t;
- }
- } else {
- regions.push(child.get("region"));
- }
- });
- });
- this._createRegions(regions);
-
- //算出节点
- BI.each(branches, function (k, branch) {
- if (branch < max) {
- delete branches[k];
- }
- });
-
- //过滤节点
- var nodes = [];
- var n = tree.getRoot();
- while (n && n.getChildrenLength() === 1) {
- if (BI.has(branches, n.getChildren()[0].id)) {
- delete branches[n.getChildren()[0].id];
- n = n.getChildren()[0];
- } else {
- n = null;
- }
- }
- tree.traverse(function (node) {
- if (BI.has(branches, node.id)) {
- nodes.push(node.id);
- delete branches[node.id];
- }
- });
-
- //填充节点
- var routes = {};
- var s, e;
- for (var i = 0, len = nodes.length; i < len + 1; i++) {
- if (len === 0) {
- s = [];
- BI.each(this.start, function (i, id) {
- s.push(tree.search(id));
- });
- e = [];
- BI.each(this.end, function (i, id) {
- e.push(tree.search(id));
- });
- } else if (i === len) {
- s = e;
- e = [];
- BI.each(this.end, function (i, id) {
- e.push(tree.search(id));
- });
- } else if (i === 0) {
- s = [];
- BI.each(this.start, function (i, id) {
- s.push(tree.search(id));
- });
- e = [tree.search(nodes[i])];
- } else {
- s = [tree.search(e[0] || tree.getRoot(), nodes[i - 1])];
- e = [tree.search(s[0], nodes[i])];
- }
- BI.each(s, function (i, n) {
- tree._recursion(n, [n.id], function (node, route) {
- if (BI.contains(e, node)) {
- if (!routes[n.id]) {
- routes[n.id] = [];
- }
- routes[n.id].push(route);
- self._pushNodes(route);
- if (e.length <= 1) {
- return true;
- }
- }
- })
- });
- }
- this.routes = routes;
- this._drawLines(routes);
- },
-
- _unselectAllPath: function () {
- var self = this;
- BI.each(this.radios, function (idx, rad) {
- BI.each(rad, function (i, r) {
- r.setSelected(false);
- });
- });
- BI.each(this.lines, function (idx, line) {
- BI.each(line, function (i, li) {
- li.attr("stroke", self._const.lineColor);
- });
- });
- BI.each(this.regions, function (idx, region) {
- region.reset();
- });
- },
-
- populate: function (items) {
- this.options.items = items || [];
- var self = this;
- this.empty();
- if (this.options.items.length <= 0) {
- return;
- }
- this.svg = BI.createWidget({
- type: "bi.svg"
- });
- this._createNodes();
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: [{
- el: this.svg,
- top: 0,
- left: 0,
- right: 0,
- bottom: 0
- }]
- });
- },
-
- setValue: function (v) {
- this._unselectAllPath();
- var nodes = BI.keys(this.routes), self = this;
- var result = [], array = [];
- BI.each(v, function (i, val) {
- if (BI.contains(nodes, val)) {
- if (array.length > 0) {
- array.push(val);
- result.push(array);
- array = [];
- }
- }
- array.push(val);
- });
- if (array.length > 0) {
- result.push(array);
- }
- //画这n条路径
- BI.each(result, function (idx, path) {
- var start = path[0];
- var index = BI.findIndex(self.routes[start], function (idx, p) {
- if (BI.isEqual(path, p)) {
- return true;
- }
- });
- if (index >= 0) {
- var startRegionIndex = self.getRegionIndexById(start);
- var offset = self.regions[startRegionIndex].getIndexByValue(start);
- self._drawPath(start, offset, index);
- }
- });
- },
-
- getValue: function () {
- var path = [];
- BI.each(this.regions, function (i, region) {
- var val = region.getValue();
- if (BI.isKey(val)) {
- path.push(val);
- }
- });
- return path;
- }
-});
-BI.PathChooser.EVENT_CHANGE = "PathChooser.EVENT_CHANGE";
-BI.shortcut("bi.path_chooser", BI.PathChooser);/**
- * 路径选择区域
- *
- * Created by GUY on 2015/12/4.
- * @class BI.PathRegion
- * @extends BI.Widget
- */
-BI.PathRegion = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-path-region bi-background",
- width: 80,
- title: ""
- })
- },
-
- _init: function () {
- BI.PathRegion.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.zIndex = 100;
- var title = BI.createWidget({
- type: "bi.label",
- text: o.title,
- title: o.title,
- height: 30
- });
- title.element.css("zIndex", this.zIndex--);
- this.items = [];
- this.vertical = BI.createWidget({
- type: "bi.vertical",
- element: this,
- bgap: 5,
- hgap: 10,
- items: [title]
- })
- },
-
- hasItem: function (val) {
- return BI.any(this.items, function (i, item) {
- return val === item.getValue();
- });
- },
-
- addItem: function (value, text) {
- if (BI.isKey(value)) {
- var label = BI.createWidget({
- type: "bi.label",
- cls: "path-region-label bi-card bi-border bi-list-item-select",
- text: text,
- value: value,
- title: text || value,
- height: 22
- });
- } else {
- var label = BI.createWidget({
- type: "bi.layout",
- height: 24
- });
- }
- label.element.css("zIndex", this.zIndex--);
- this.items.push(label);
- this.vertical.addItem(label);
- if (this.items.length === 1) {
- this.setSelect(0, value);
- }
- },
-
- reset: function () {
- BI.each(this.items, function (i, item) {
- item.element.removeClass("active");
- });
- },
-
- setSelect: function (index, value) {
- this.reset();
- if (this.items.length <= 0) {
- return;
- }
- if (this.items.length === 1) {
- this.items[0].element.addClass("active");
- return;
- }
- if (this.items[index].attr("value") === value) {
- this.items[index].element.addClass("active");
- }
- },
-
- setValue: function (value) {
- this.setSelect(this.getIndexByValue(value), value);
- },
-
- getValueByIndex: function (idx) {
- return this.items[idx].attr("value");
- },
-
- getIndexByValue: function (value) {
- return BI.findIndex(this.items, function (i, item) {
- return item.attr("value") === value;
- });
- },
-
- getValue: function () {
- var res;
- BI.any(this.items, function (i, item) {
- if (item.element.hasClass("active")) {
- res = item.getValue();
- return true;
- }
- });
- return res;
- }
-});
-BI.PathRegion.EVENT_CHANGE = "PathRegion.EVENT_CHANGE";
-BI.shortcut("bi.path_region", BI.PathRegion);/**
- * 预览表列
- *
- * Created by GUY on 2015/12/25.
- * @class BI.PreviewTableCell
- * @extends BI.Widget
- */
-BI.PreviewTableCell = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-preview-table-cell",
- text: ""
- });
- },
-
- _init: function () {
- BI.PreviewTableCell.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- BI.createWidget({
- type: "bi.label",
- element: this,
- textAlign: "left",
- whiteSpace: "normal",
- height: this.options.height,
- text: this.options.text,
- value: this.options.value
- })
- }
-});
-BI.shortcut('bi.preview_table_cell', BI.PreviewTableCell);/**
- * 预览表
- *
- * Created by GUY on 2015/12/25.
- * @class BI.PreviewTableHeaderCell
- * @extends BI.Widget
- */
-BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-preview-table-header-cell",
- text: ""
- });
- },
-
- _init: function () {
- BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- BI.createWidget({
- type: "bi.label",
- element: this,
- textAlign: "left",
- whiteSpace: "normal",
- height: this.options.height,
- text: this.options.text,
- value: this.options.value
- })
- }
-});
-BI.shortcut('bi.preview_table_header_cell', BI.PreviewTableHeaderCell);/**
- * 预览表
- *
- * Created by GUY on 2015/12/25.
- * @class BI.PreviewTable
- * @extends BI.Widget
- */
-BI.PreviewTable = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-preview-table",
- isNeedFreeze: false,
- freezeCols: [],
- rowSize: null,
- columnSize: [],
- headerRowSize: 30,
- header: [],
- items: []
- });
- },
-
- _init: function () {
- BI.PreviewTable.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.table = BI.createWidget({
- type: "bi.table_view",
- element: this,
- isNeedResize: false,
-
- isResizeAdapt: false,
-
- isNeedFreeze: o.isNeedFreeze,
- freezeCols: o.freezeCols,
-
- rowSize: o.rowSize,
- columnSize: o.columnSize,
- headerRowSize: o.headerRowSize,
-
- header: BI.map(o.header, function (i, items) {
- return BI.map(items, function (j, item) {
- return BI.extend({
- type: "bi.preview_table_header_cell"
- }, item);
- });
- }),
- items: BI.map(o.items, function (i, items) {
- return BI.map(items, function (j, item) {
- return BI.extend({
- type: "bi.preview_table_cell"
- }, item);
- });
- })
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
- self._adjustColumns();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
- self._adjustColumns();
- });
- },
-
- //是否有自适应调节的列,即列宽为""
- _hasAdaptCol: function (columnSize) {
- return BI.any(columnSize, function (i, size) {
- return size === "";
- })
- },
-
- _isPercentage: function (columnSize) {
- return columnSize[0] <= 1;
- },
-
- _adjustColumns: function () {
- var self = this, o = this.options;
- if (o.isNeedFreeze === true) {
- //如果存在百分比的情况
- if (this._isPercentage(o.columnSize)) {
- if (this._hasAdaptCol(o.columnSize)) {
- var findCols = [], remain = 0;
- BI.each(o.columnSize, function (i, size) {
- if (size === "") {
- findCols.push(i);
- } else {
- remain += size;
- }
- });
- remain = 1 - remain;
- var average = remain / findCols.length;
- BI.each(findCols, function (i, col) {
- o.columnSize[col] = average;
- });
- }
- var isRight = BI.first(o.freezeCols) !== 0;
- var freezeSize = [], notFreezeSize = [];
- BI.each(o.columnSize, function (i, size) {
- if (o.freezeCols.contains(i)) {
- freezeSize.push(size);
- } else {
- notFreezeSize.push(size);
- }
- });
- var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize);
- BI.each(freezeSize, function (i, size) {
- freezeSize[i] = size / sumFreezeSize;
- });
- BI.each(notFreezeSize, function (i, size) {
- notFreezeSize[i] = size / sumNotFreezeSize;
- });
- this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]);
- this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize)));
- }
- } else {
- //如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100%
- if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) {
- this.table.setRegionColumnSize(["100%"]);
- }
- }
- },
-
- setColumnSize: function (columnSize) {
- return this.table.setColumnSize(columnSize);
- },
-
- getColumnSize: function () {
- return this.table.getColumnSize();
- },
-
- getCalculateColumnSize: function () {
- return this.table.getCalculateColumnSize();
- },
-
- setHeaderColumnSize: function (columnSize) {
- return this.table.setHeaderColumnSize(columnSize);
- },
-
- setRegionColumnSize: function (columnSize) {
- return this.table.setRegionColumnSize(columnSize);
- },
-
- getRegionColumnSize: function () {
- return this.table.getRegionColumnSize();
- },
-
- getCalculateRegionColumnSize: function () {
- return this.table.getCalculateRegionColumnSize();
- },
-
- getCalculateRegionRowSize: function () {
- return this.table.getCalculateRegionRowSize();
- },
-
- getClientRegionColumnSize: function () {
- return this.table.getClientRegionColumnSize();
- },
-
- getScrollRegionColumnSize: function () {
- return this.table.getScrollRegionColumnSize()
- },
-
- getScrollRegionRowSize: function () {
- return this.table.getScrollRegionRowSize()
- },
-
- hasVerticalScroll: function () {
- return this.table.hasVerticalScroll();
- },
-
- setVerticalScroll: function (scrollTop) {
- return this.table.setVerticalScroll(scrollTop);
- },
-
- setLeftHorizontalScroll: function (scrollLeft) {
- return this.table.setLeftHorizontalScroll(scrollLeft)
- },
-
- setRightHorizontalScroll: function (scrollLeft) {
- return this.table.setRightHorizontalScroll(scrollLeft);
- },
-
- getVerticalScroll: function () {
- return this.table.getVerticalScroll();
- },
-
- getLeftHorizontalScroll: function () {
- return this.table.getLeftHorizontalScroll();
- },
-
- getRightHorizontalScroll: function () {
- return this.table.getRightHorizontalScroll();
- },
-
- getColumns: function () {
- return this.table.getColumns();
- },
-
- populate: function (items, header) {
- this.table.populate(items, header);
- }
-});
-BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE";
-BI.shortcut('bi.preview_table', BI.PreviewTable);/**
- * 季度下拉框
- *
- * Created by GUY on 2015/8/28.
- * @class BI.QuarterCombo
- * @extends BI.Widget
- */
-BI.QuarterCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-quarter-combo",
- behaviors: {},
- height: 25
- });
- },
- _init: function () {
- BI.QuarterCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.storeValue = "";
- this.trigger = BI.createWidget({
- type: "bi.quarter_trigger"
- });
-
- this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS, function () {
- self.storeValue = this.getKey();
- });
- this.trigger.on(BI.QuarterTrigger.EVENT_CHANGE, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- });
- this.trigger.on(BI.QuarterTrigger.EVENT_START, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- });
- this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- });
- this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () {
- if (self.combo.isViewVisible()) {
- return;
- }
- if (this.getKey() && this.getKey() !== self.storeValue) {
- self.setValue(this.getKey());
- } else if (!this.getKey()) {
- self.setValue();
- }
- self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
- });
- this.popup = BI.createWidget({
- type: "bi.quarter_popup",
- behaviors: o.behaviors
- });
-
- this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- minWidth: 85,
- el: this.popup
- }
- });
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW);
- });
- },
-
- setValue: function (v) {
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue() || "";
- }
-});
-
-BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.quarter_combo', BI.QuarterCombo);/**
- * 季度展示面板
- *
- * Created by GUY on 2015/9/2.
- * @class BI.QuarterPopup
- * @extends BI.Trigger
- */
-BI.QuarterPopup = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-quarter-popup",
- behaviors: {}
- });
- },
-
- _init: function () {
- BI.QuarterPopup.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- var items = [{
- text: Date._QN[01],
- value: 1
- }, {
- text: Date._QN[2],
- value: 2
- }, {
- text: Date._QN[3],
- value: 3
- }, {
- text: Date._QN[4],
- value: 4
- }];
- items = BI.map(items, function (j, item) {
- return BI.extend(item, {
- type: "bi.text_item",
- cls: "bi-list-item-active",
- textAlign: "left",
- whiteSpace: "nowrap",
- once: false,
- forceSelected: true,
- height: 25
- });
- });
-
- this.quarter = BI.createWidget({
- type: "bi.button_group",
- element: this,
- behaviors: o.behaviors,
- items: BI.createItems(items, {}),
- layouts: [{
- type: "bi.vertical"
- }]
- });
-
- this.quarter.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if (type === BI.Events.CLICK) {
- self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
- }
- })
- },
-
- getValue: function () {
- return this.quarter.getValue()[0];
- },
-
- setValue: function (v) {
- this.quarter.setValue([v]);
- }
-});
-BI.QuarterPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.quarter_popup", BI.QuarterPopup);/**
- * 季度trigger
- *
- * Created by GUY on 2015/8/21.
- * @class BI.QuarterTrigger
- * @extends BI.Trigger
- */
-BI.QuarterTrigger = BI.inherit(BI.Trigger, {
- _const: {
- hgap: 4,
- vgap: 2,
- triggerWidth: 30,
- textWidth: 40,
- errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text")
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-quarter-trigger bi-border",
- height: 25
- });
- },
- _init: function () {
- BI.QuarterTrigger.superclass._init.apply(this, arguments);
- var self = this, o = this.options, c = this._const;
- this.editor = BI.createWidget({
- type: "bi.sign_editor",
- height: o.height,
- validationChecker: function (v) {
- return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 4);
- },
- quitChecker: function (v) {
- return false;
- },
- hgap: c.hgap,
- vgap: c.vgap,
- allowBlank: true,
- errorText: c.errorText
- });
- this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
- self.fireEvent(BI.QuarterTrigger.EVENT_FOCUS);
- });
- this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
- self.fireEvent(BI.QuarterTrigger.EVENT_CHANGE);
- });
- this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
- var value = self.editor.getValue();
- if (BI.isNotNull(value)) {
- self.editor.setValue(value);
- self.editor.setTitle(value);
- }
- self.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM);
- });
- this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
- if (self.editor.isValid()) {
- self.editor.blur();
- }
- });
- this.editor.on(BI.SignEditor.EVENT_START, function () {
- self.fireEvent(BI.QuarterTrigger.EVENT_START);
- });
- this.editor.on(BI.SignEditor.EVENT_STOP, function () {
- self.fireEvent(BI.QuarterTrigger.EVENT_STOP);
- });
-
- BI.createWidget({
- element: this,
- type: 'bi.htape',
- items: [
- {
- el: this.editor
- }, {
- el: {
- type: "bi.text_button",
- baseCls: "bi-trigger-quarter-text",
- text: BI.i18nText("BI-Multi_Date_Quarter"),
- width: c.textWidth
- },
- width: c.textWidth
- }, {
- el: {
- type: "bi.trigger_icon_button",
- width: c.triggerWidth
- },
- width: c.triggerWidth
- }
- ]
- });
- },
-
- setValue: function (v) {
- this.editor.setState(v);
- this.editor.setValue(v);
- this.editor.setTitle(v);
- },
-
- getKey: function () {
- return this.editor.getValue();
- }
-});
-BI.QuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS";
-BI.QuarterTrigger.EVENT_CHANGE = "EVENT_CHANGE";
-BI.QuarterTrigger.EVENT_START = "EVENT_START";
-BI.QuarterTrigger.EVENT_STOP = "EVENT_STOP";
-BI.QuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.shortcut("bi.quarter_trigger", BI.QuarterTrigger);/**
- * 关联视图字段Item
- *
- * Created by GUY on 2015/12/23.
- * @class BI.RelationViewItem
- * @extends BI.Widget
- */
-BI.RelationViewItem = BI.inherit(BI.BasicButton, {
-
- _defaultConfig: function () {
- return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-relation-view-item bi-list-item-active",
- height: 25,
- hoverIn: BI.emptyFn,
- hoverOut: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.RelationViewItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.element.hover(o.hoverIn, o.hoverOut);
- var items = [];
- if (o.isPrimary) {
- items.push({
- type: "bi.icon",
- width: 16,
- height: 16,
- title: BI.i18nText("BI-Primary_Key")
- });
- }
- items.push({
- type: "bi.label",
- text: o.text,
- value: o.value,
- height: o.height,
- textAlign: "left",
- width: o.isPrimary ? 70 : 90
- });
- BI.createWidget({
- type: "bi.vertical_adapt",
- element: this,
- items: items,
- cls: "primary-key-font",
- lgap: 5
- });
- },
-
- enableHover: function (opt) {
- BI.RelationViewRegion.superclass.enableHover.apply(this, [{
- container: "body"
- }]);
- },
-
- setSelected: function (b) {
- this.element[b ? "addClass" : "removeClass"]("active");
- }
-});
-BI.shortcut('bi.relation_view_item', BI.RelationViewItem);/**
- * 关联视图
- *
- * Created by GUY on 2015/12/22.
- * @class BI.RelationView
- * @extends BI.Widget
- */
-BI.RelationView = BI.inherit(BI.Widget, {
-
- _const: {
- lineColor: "#c4c6c6",
- selectLineColor: "#009de3"
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-relation-view",
- items: []
- });
- },
-
- _init: function () {
- BI.RelationView.superclass._init.apply(this, arguments);
- this.populate(this.options.items);
- },
-
- _calculateWidths: function () {
- var widths = [];
- BI.each(this.views, function (i, items) {
- BI.each(items, function (j, obj) {
- if (!widths[j]) {
- widths[j] = BI.MIN;
- }
- widths[j] = Math.max(widths[j], obj.getWidth());
- })
- });
- return widths;
- },
-
- _calculateHeights: function () {
- var heights = BI.makeArray(BI.size(this.views), BI.MIN);
- BI.each(this.views, function (i, items) {
- BI.each(items, function (j, obj) {
- heights[i] = Math.max(heights[i], obj.getHeight());
- })
- });
- return heights;
- },
-
- _hoverIn: function (target) {
- var self = this, c = this._const;
- BI.each(this.relations, function (start, rs) {
- BI.each(rs, function (end, relation) {
- if (relation[0].primary.value === target || relation[0].foreign.value === target) {
- self.lines[start][end].attr("stroke", c.selectLineColor).toFront();
- self.storeViews[start].setValue(relation[0].primary.value);
- self.storeViews[end].setValue(relation[0].foreign.value);
- }
- });
- });
- },
-
- _hoverOut: function (target) {
- var self = this, c = this._const;
- BI.each(this.relations, function (start, rs) {
- BI.each(rs, function (end, relation) {
- if (relation[0].primary.value === target || relation[0].foreign.value === target) {
- self.lines[start][end].attr("stroke", c.lineColor);
- self.storeViews[start].setValue([]);
- self.storeViews[end].setValue([]);
- }
- });
- });
- },
-
- previewRelationTables: function(relationTables, show) {
- if (!show) {
- BI.each(this.storeViews, function (i, view) {
- view.toggleRegion(true);
- view.setPreviewSelected(false);
- });
- BI.each(this.lines, function (i, lines) {
- BI.each(lines, function (j, line) {
- line.show();
- });
- });
- return;
- }
- BI.each(this.storeViews, function (id, view) {
- if (!relationTables.contains(id)) {
- view.toggleRegion(false);
- } else {
- view.setPreviewSelected(true);
- }
- });
- BI.each(this.lines, function (id, lines) {
- BI.each(lines, function (cId, line) {
- if (!relationTables.contains(id) || !relationTables.contains(cId)) {
- line.hide();
- }
- });
- });
- },
-
- populate: function (items) {
- var self = this, o = this.options, c = this._const;
- o.items = items || [];
- this.empty();
- this.svg = BI.createWidget({
- type: "bi.svg"
- });
-
- //算出所有的区域和关联
- var regions = this.regions = {}, relations = this.relations = {};
- BI.each(items, function (i, item) {
- var pr = item.primary.region, fr = item.foreign && item.foreign.region;
- if (pr && !relations[pr]) {
- relations[pr] = {};
- }
- if (pr && fr && !relations[pr][fr]) {
- relations[pr][fr] = [];
- }
- if (pr && !regions[pr]) {
- regions[pr] = [];
- }
- if (fr && !regions[fr]) {
- regions[fr] = [];
- }
- if (pr && !BI.deepContains(regions[pr], item.primary)) {
- regions[pr].push(item.primary);
- }
- if (fr && !BI.deepContains(regions[fr], item.foreign)) {
- regions[fr].push(item.foreign);
- }
- pr && fr && relations[pr][fr].push(item);
- });
- //求拓扑
- var topology = [];
- var rs = BI.clone(regions), store = {};
- while (!BI.isEmpty(rs)) {
- var clone = BI.clone(rs);
- BI.each(o.items, function (i, item) {
- if (!store[item.primary.region]) {
- delete clone[item.foreign && item.foreign.region];
- }
- });
- topology.push(BI.keys(clone));
- BI.extend(store, clone);
- BI.each(clone, function (k, v) {
- delete rs[k];
- });
- }
- //构建视图
- var views = this.views = {}, storeViews = this.storeViews = {}, indexes = this.indexes = {};
- var verticals = [];
- BI.each(topology, function (i, items) {
- if (!views[i]) {
- views[i] = {};
- }
- var horizontal = [];
- BI.each(items, function (j, region) {
- var items = regions[region];
- views[i][j] = storeViews[region] = BI.createWidget({
- type: "bi.relation_view_region_container",
- value: region,
- header: items[0].regionTitle,
- text: items.length > 0 ? items[0].regionText : "",
- handler: items.length > 0 ? items[0].regionHandler : BI.emptyFn,
- items: items,
- belongPackage: items.length > 0 ? items[0].belongPackage : true
- });
- if (BI.isNotNull(items[0]) && BI.isNotNull(items[0].keyword)) {
- views[i][j].doRedMark(items[0].keyword);
- }
- views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN, function (v) {
- self._hoverIn(v);
- });
- views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, function (v) {
- self._hoverOut(v);
- });
- views[i][j].on(BI.RelationViewRegionContainer.EVENT_PREVIEW, function (v) {
- self.fireEvent(BI.RelationView.EVENT_PREVIEW, region, v);
- });
- indexes[region] = {i: i, j: j};
- horizontal.push(views[i][j]);
- });
- verticals.push({
- type: "bi.horizontal",
- items: horizontal
- })
- });
-
- //求每一行的高度
- var heights = this._calculateHeights();
-
- //求每一列的宽度
- var widths = this._calculateWidths();
-
- //求相对宽度和高度
- var offsetWidths = [0], offsetHeights = [0];
- BI.each(heights, function (i, h) {
- if (i === 0) {
- return;
- }
- offsetHeights[i] = offsetHeights[i - 1] + heights[i - 1];
- });
- BI.each(widths, function (i, w) {
- if (i === 0) {
- return;
- }
- offsetWidths[i] = offsetWidths[i - 1] + widths[i - 1];
- });
-
- //画线
- var lines = this.lines = {};//缓存所有的线
- BI.each(relations, function (start, rs) {
- BI.each(rs, function (end, relation) {
- var startIndex = indexes[start], endIndex = indexes[end];
- var top = 0, right = 1, bottom = 2, left = 3;
- var startDirection = bottom, endDirection = top;
- // if (startIndex.j > endIndex.j) {
- // startDirection = left;
- // endDirection = right;
- // } else if (startIndex.j < endIndex.j) {
- // startDirection = right;
- // endDirection = left;
- // } else if (startIndex.i < endIndex.i) {
- // startDirection = bottom;
- // endDirection = top;
- // } else if (startIndex.i > endIndex.i) {
- // startDirection = top;
- // endDirection = bottom;
- // }
- var draw = function (i, j, direction, isForeign) {
- var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2;
- var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2;
- var path = "", position;
- switch (direction) {
- case top:
- position = isForeign ? views[i][j].getTopRightPosition() : views[i][j].getTopLeftPosition();
- x += position.x;
- y += position.y;
- path = "M" + x + "," + y + "L" + x + "," + (y - 10);
- y -= 10;
- break;
- case right:
- position = views[i][j].getRightPosition();
- x += position.x;
- y += position.y;
- path = "M" + x + "," + y + "L" + (x + 10) + "," + y;
- x += 10;
- break;
- case bottom:
- position = views[i][j].getBottomPosition();
- x += position.x;
- y += position.y;
- path = "M" + x + "," + y + "L" + x + "," + (y + 10);
- y += 10;
- break;
- case left:
- position = views[i][j].getLeftPosition();
- x += position.x;
- y += position.y;
- path = "M" + x + "," + y + "L" + (x - 10) + "," + y;
- x -= 10;
- break;
- }
- return {x: x, y: y, path: path};
- };
- var path = "";
- var si = draw(startIndex.i, startIndex.j, startDirection);
- var ei = draw(endIndex.i, endIndex.j, endDirection, true);
- path += si.path + ei.path;
- if (!lines[start]) {
- lines[start] = {};
- }
- path += "M" + si.x + "," + si.y + "L" + ei.x + "," + ei.y;
- var line = lines[start][end] = self.svg.path(path)
- .attr({"stroke": c.lineColor, "stroke-width": "2"})
- .hover(function () {
- line.attr("stroke", c.selectLineColor).toFront();
- storeViews[start].setValue(relation[0].primary.value);
- storeViews[end].setValue(relation[0].foreign.value);
- }, function () {
- line.attr("stroke", c.lineColor);
- storeViews[start].setValue([]);
- storeViews[end].setValue([]);
- });
- });
- });
- var container = BI.createWidget();
- BI.createWidget({
- type: "bi.vertical",
- element: container,
- items: verticals
- });
- BI.createWidget({
- type: "bi.absolute",
- element: container,
- items: [{
- el: this.svg,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- }]
- });
-
- BI.createWidget({
- type: "bi.center_adapt",
- scrollable: true,
- element: this,
- items: [container]
- });
- }
-});
-BI.RelationView.EVENT_CHANGE = "RelationView.EVENT_CHANGE";
-BI.RelationView.EVENT_PREVIEW = "EVENT_PREVIEW";
-BI.shortcut('bi.relation_view', BI.RelationView);/**
- * Created by Young's on 2017/3/10.
- */
-BI.RelationViewRegionContainer = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-relation-view-region-container",
- width: 150
- });
- },
-
- _init: function () {
- BI.RelationViewRegionContainer.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.region = BI.createWidget({
- type: "bi.relation_view_region",
- value: o.value,
- header: o.header,
- text: o.text,
- handler: o.handler,
- items: o.items,
- belongPackage: o.belongPackage
- });
- this.region.on(BI.RelationViewRegion.EVENT_PREVIEW, function (v) {
- self.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW, v);
- });
- this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN, function (v) {
- self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN, v);
- });
- this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT, function (v) {
- self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, v);
- });
- BI.createWidget({
- type: "bi.vertical",
- element: this,
- items: [this.region],
- width: this.region.getWidth(),
- height: this.region.getHeight()
- });
- },
-
- doRedMark: function () {
- this.region.doRedMark.apply(this.region, arguments);
- },
-
- unRedMark: function () {
- this.region.unRedMark.apply(this.region, arguments);
- },
-
- getWidth: function () {
- return this.region.getWidth();
- },
-
- getHeight: function () {
- return this.region.getHeight();
- },
-
- //获取上方开始划线的位置
- getTopLeftPosition: function () {
- return this.region.getTopLeftPosition();
- },
-
- getTopRightPosition: function () {
- return this.region.getTopRightPosition();
- },
-
- getBottomPosition: function () {
- return this.region.getBottomPosition();
- },
-
- getLeftPosition: function () {
- return this.region.getLeftPosition();
- },
-
- getRightPosition: function () {
- return this.region.getRightPosition();
- },
-
- setValue: function (v) {
- this.region.setValue(v);
- },
-
- toggleRegion: function (v) {
- v === true ? this.region.element.fadeIn() : this.region.element.fadeOut();
- },
-
- setPreviewSelected: function(v) {
- this.region.setPreviewSelected(v);
- }
-});
-BI.RelationViewRegionContainer.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN";
-BI.RelationViewRegionContainer.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT";
-BI.RelationViewRegionContainer.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW";
-BI.shortcut("bi.relation_view_region_container", BI.RelationViewRegionContainer);/**
- * 关联视图
- *
- * Created by GUY on 2015/12/23.
- * @class BI.RelationViewRegion
- * @extends BI.BasicButton
- */
-BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
-
- _defaultConfig: function () {
- return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-relation-view-region cursor-pointer",
- width: 150,
- text: "",
- value: "",
- header: "",
- items: [],
- belongPackage: true
- });
- },
-
- _init: function () {
- BI.RelationViewRegion.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.preview = BI.createWidget({
- type: "bi.icon_button",
- cls: "relation-table-preview-font",
- width: 25,
- height: 25,
- stopPropagation: true
- });
- this.preview.on(BI.IconButton.EVENT_CHANGE, function () {
- self.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW, this.isSelected());
- });
-
- this.title = BI.createWidget({
- type: "bi.label",
- height: 25,
- width: 70,
- text: o.text,
- value: o.value,
- textAlign: "left"
- });
- //title放body上
- if (BI.isKey(o.header)) {
- this.title.setTitle(o.header, {
- container: "body"
- })
- }
-
- this.button_group = BI.createWidget({
- type: "bi.button_group",
- items: this._createItems(o.items),
- layouts: [{
- type: "bi.vertical"
- }]
- });
-
- BI.createWidget({
- type: "bi.vertical",
- element: this,
- items: [{
- type: "bi.vertical",
- cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"),
- items: [{
- type: "bi.vertical_adapt",
- cls: "relation-view-region-title bi-border-bottom",
- items: [this.preview, this.title]
- }, this.button_group]
- }],
- hgap: 25,
- vgap: 20
- })
- },
-
- _createItems: function (items) {
- var self = this;
- return BI.map(items, function (i, item) {
- return BI.extend(item, {
- type: "bi.relation_view_item",
- hoverIn: function () {
- self.setValue(item.value);
- self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value);
- },
- hoverOut: function () {
- self.setValue([]);
- self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT, item.value);
- }
- })
- });
- },
-
- doRedMark: function () {
- this.title.doRedMark.apply(this.title, arguments);
- },
-
- unRedMark: function () {
- this.title.unRedMark.apply(this.title, arguments);
- },
-
- getWidth: function () {
- return this.options.width;
- },
-
- getHeight: function () {
- return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3;
- },
-
- //获取上方开始划线的位置
- getTopLeftPosition: function () {
- return {
- x: 25 + 10,
- y: 20
- }
- },
-
- getTopRightPosition: function () {
- return {
- x: this.getWidth() - 25 - 10,
- y: 20
- }
- },
-
- getBottomPosition: function () {
- return {
- x: 25 + 10,
- y: this.getHeight() - 20
- }
- },
-
- getLeftPosition: function () {
- return {
- x: 25,
- y: 20 + 10
- }
- },
-
- getRightPosition: function () {
- return {
- x: this.getWidth() - 25,
- y: 20 + 10
- }
- },
-
- setValue: function (v) {
- this.button_group.setValue(v);
- },
-
- setPreviewSelected: function(v) {
- this.preview.setSelected(v);
- }
-});
-BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN";
-BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT";
-BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW";
-BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/**
- * 自适应宽度的表格
- *
- * Created by GUY on 2016/2/3.
- * @class BI.ResponisveTable
- * @extends BI.Widget
- */
-BI.ResponisveTable = BI.inherit(BI.Widget, {
-
- _const: {
- perColumnSize: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-responsive-table",
- isNeedFreeze: false,//是否需要冻结单元格
- freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
-
- isNeedMerge: false,//是否需要合并单元格
- mergeCols: [], //合并的单元格列号
- mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
- return BI.isEqual(row1, row2);
- },
-
- columnSize: [],
- headerRowSize: 25,
- footerRowSize: 25,
- rowSize: 25,
-
- regionColumnSize: false,
-
- header: [],
- footer: false,
- items: [], //二维数组
-
- //交叉表头
- crossHeader: [],
- crossItems: []
- });
- },
-
- _init: function () {
- BI.ResponisveTable.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.table = BI.createWidget({
- type: "bi.table_view",
- element: this,
-
- isNeedFreeze: o.isNeedFreeze,
- freezeCols: o.freezeCols,
-
- isNeedMerge: o.isNeedMerge,
- mergeCols: o.mergeCols,
- mergeRule: o.mergeRule,
-
- columnSize: o.columnSize,
- headerRowSize: o.headerRowSize,
- footerRowSize: o.footerRowSize,
- rowSize: o.rowSize,
-
- regionColumnSize: o.regionColumnSize,
-
- header: o.header,
- footer: o.footer,
- items: o.items,
- //交叉表头
- crossHeader: o.crossHeader,
- crossItems: o.crossItems
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
- self._initRegionSize();
- self.table.resize();
- self._resizeHeader();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
- self._resizeRegion();
- self._resizeHeader();
- self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
- self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () {
- self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () {
- //important:在冻结并自适应列宽的情况下要随时变更表头宽度
- if (o.isNeedResize === true && self._isAdaptiveColumn()) {
- self._resizeHeader();
- }
- self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
- self._resizeHeader();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
- });
-
- this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () {
- self._resizeBody();
- self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () {
- self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
- self._resizeRegion();
- self._resizeHeader();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
- });
- },
-
- _initRegionSize: function () {
- var o = this.options;
- if (o.isNeedFreeze === true) {
- var regionColumnSize = this.table.getRegionColumnSize();
- var maxWidth = this.table.element.width();
- if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) {
- var freezeCols = o.freezeCols;
- if (freezeCols.length === 0) {
- this.table.setRegionColumnSize([0, "fill"]);
- } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) {
- var size = maxWidth / 3;
- if (freezeCols.length > o.columnSize.length / 2) {
- size = maxWidth * 2 / 3;
- }
- this.table.setRegionColumnSize([size, "fill"]);
- } else {
- this.table.setRegionColumnSize(["fill", 0]);
- }
- }
- }
- },
-
- _getBlockSize: function () {
- var o = this.options;
- var columnSize = this.table.getCalculateColumnSize();
- if (o.isNeedFreeze === true) {
- var columnSizeLeft = [], columnSizeRight = [];
- BI.each(columnSize, function (i, size) {
- if (o.freezeCols.contains(i)) {
- columnSizeLeft.push(size);
- } else {
- columnSizeRight.push(size);
- }
- });
- //因为有边框,所以加上数组长度的参数调整
- var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length,
- sumRight = BI.sum(columnSizeRight) + columnSizeRight.length;
- return {
- sumLeft: sumLeft,
- sumRight: sumRight,
- left: columnSizeLeft,
- right: columnSizeRight
- }
- }
- return {
- size: columnSize,
- sum: BI.sum(columnSize) + columnSize.length
- };
- },
-
- _isAdaptiveColumn: function (columnSize) {
- return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05);
- },
-
- _resizeHeader: function () {
- var self = this, o = this.options;
- if (o.isNeedFreeze === true) {
- //若是当前处于自适应调节阶段
- if (this._isAdaptiveColumn()) {
- var columnSize = this.table.getCalculateColumnSize();
- this.table.setHeaderColumnSize(columnSize);
- } else {
- var regionColumnSize = this.table.getClientRegionColumnSize();
- var block = this._getBlockSize();
- var sumLeft = block.sumLeft, sumRight = block.sumRight;
- var columnSizeLeft = block.left, columnSizeRight = block.right;
- columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft;
- columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight;
-
- var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight);
- newLeft[newLeft.length - 1] = "";
- newRight[newRight.length - 1] = "";
- this.table.setColumnSize(newLeft.concat(newRight));
-
- block = self._getBlockSize();
- if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) {
- columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1]
- }
- if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) {
- columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1]
- }
-
- self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight));
- }
- } else {
- if (!this._isAdaptiveColumn()) {
- var regionColumnSize = this.table.getClientRegionColumnSize();
- var block = this._getBlockSize();
- var sum = block.sum;
- var size = block.size;
-
- size[size.length - 1] += regionColumnSize[0] - sum;
-
- var newSize = BI.clone(size);
- newSize[newSize.length - 1] = "";
- this.table.setColumnSize(newSize);
- block = this._getBlockSize();
-
- if (size[size.length - 1] < block.size[block.size.length - 1]) {
- size[size.length - 1] = block.size[block.size.length - 1]
- }
- this.table.setColumnSize(size);
- }
- }
- },
-
- _resizeBody: function () {
- if (this._isAdaptiveColumn()) {
- var columnSize = this.table.getCalculateColumnSize();
- this.setColumnSize(columnSize);
- }
- },
-
- _adjustRegion: function () {
- var o = this.options;
- var regionColumnSize = this.table.getCalculateRegionColumnSize();
- if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
- var block = this._getBlockSize();
- var sumLeft = block.sumLeft, sumRight = block.sumRight;
- if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) {
- this.table.setRegionColumnSize([sumLeft, "fill"]);
- }
- this._resizeRegion();
- }
- },
-
- _resizeRegion: function () {
- var o = this.options;
- var regionColumnSize = this.table.getCalculateRegionColumnSize();
- if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
- var maxWidth = this.table.element.width();
- if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) {
- var freezeCols = o.freezeCols;
- var size = maxWidth / 3;
- if (freezeCols.length > o.columnSize.length / 2) {
- size = maxWidth * 2 / 3;
- }
- this.table.setRegionColumnSize([size, "fill"]);
- }
- }
- },
-
-
- resize: function () {
- this.table.resize();
- this._resizeRegion();
- this._resizeHeader();
- },
-
- setColumnSize: function (columnSize) {
- this.table.setColumnSize(columnSize);
- this._adjustRegion();
- this._resizeHeader();
- },
-
- getColumnSize: function () {
- return this.table.getColumnSize();
- },
-
- getCalculateColumnSize: function () {
- return this.table.getCalculateColumnSize();
- },
-
- setHeaderColumnSize: function (columnSize) {
- this.table.setHeaderColumnSize(columnSize);
- this._adjustRegion();
- this._resizeHeader();
- },
-
- setRegionColumnSize: function (columnSize) {
- this.table.setRegionColumnSize(columnSize);
- this._resizeHeader();
- },
-
- getRegionColumnSize: function () {
- return this.table.getRegionColumnSize();
- },
-
- getCalculateRegionColumnSize: function () {
- return this.table.getCalculateRegionColumnSize();
- },
-
- getCalculateRegionRowSize: function () {
- return this.table.getCalculateRegionRowSize();
- },
-
- getClientRegionColumnSize: function () {
- return this.table.getClientRegionColumnSize();
- },
-
- getScrollRegionColumnSize: function () {
- return this.table.getScrollRegionColumnSize();
- },
-
- getScrollRegionRowSize: function () {
- return this.table.getScrollRegionRowSize();
- },
-
- hasVerticalScroll: function () {
- return this.table.hasVerticalScroll();
- },
-
- setVerticalScroll: function (scrollTop) {
- this.table.setVerticalScroll(scrollTop);
- },
-
- setLeftHorizontalScroll: function (scrollLeft) {
- this.table.setLeftHorizontalScroll(scrollLeft);
- },
-
- setRightHorizontalScroll: function (scrollLeft) {
- this.table.setRightHorizontalScroll(scrollLeft);
- },
-
- getVerticalScroll: function () {
- return this.table.getVerticalScroll();
- },
-
- getLeftHorizontalScroll: function () {
- return this.table.getLeftHorizontalScroll();
- },
-
- getRightHorizontalScroll: function () {
- return this.table.getRightHorizontalScroll();
- },
-
- getColumns: function () {
- return this.table.getColumns();
- },
-
- attr: function () {
- BI.ResponisveTable.superclass.attr.apply(this, arguments);
- this.table.attr.apply(this.table, arguments);
- },
-
- populate: function (items) {
- var self = this, o = this.options;
- this.table.populate.apply(this.table, arguments);
- if (o.isNeedFreeze === true) {
- BI.nextTick(function () {
- self._initRegionSize();
- self.table.resize();
- self._resizeHeader();
- });
- }
- }
-});
-BI.shortcut('bi.responsive_table', BI.ResponisveTable);/**
- * 加号表示的组节点
- * Created by GUY on 2015/9/6.
- * @class BI.SelectTreeFirstPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: (conf.baseCls || "") + " bi-select-tree-first-plus-group-node bi-list-item-active",
- logic: {
- dynamic: false
- },
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.checkbox = BI.createWidget({
- type: "bi.first_tree_node_checkbox",
- stopPropagation: true
- });
- this.text = BI.createWidget({
- type: "bi.label",
- textAlign: "left",
- whiteSpace: "nowrap",
- textHeight: o.height,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {
- if (this.isSelected()) {
- self.triggerExpand();
- } else {
- self.triggerCollapse();
- }
- }
- });
- var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
- var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
- width: 25,
- el: this.checkbox
- }, this.text);
- BI.createWidget(BI.extend({
- element: this
- }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
- items: items
- }))));
- },
-
- isOnce: function () {
- return true;
- },
-
- doRedMark: function () {
- this.text.doRedMark.apply(this.text, arguments);
- },
-
- unRedMark: function () {
- this.text.unRedMark.apply(this.text, arguments);
- },
-
- doClick: function () {
- BI.NodeButton.superclass.doClick.apply(this, arguments);
- },
-
- setOpened: function (v) {
- BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.checkbox)) {
- this.checkbox.setSelected(v);
- }
- }
-});
-
-BI.shortcut("bi.select_tree_first_plus_group_node", BI.SelectTreeFirstPlusGroupNode);/**
- * 加号表示的组节点
- * Created by GUY on 2015/9/6.
- * @class BI.SelectTreeLastPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: (conf.baseCls || "") + " bi-select-tree-last-plus-group-node bi-list-item-active",
- logic: {
- dynamic: false
- },
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.checkbox = BI.createWidget({
- type: "bi.last_tree_node_checkbox",
- stopPropagation: true
- })
- this.text = BI.createWidget({
- type: "bi.label",
- textAlign: "left",
- whiteSpace: "nowrap",
- textHeight: o.height,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {
- if (this.isSelected()) {
- self.triggerExpand();
- } else {
- self.triggerCollapse();
- }
- }
- });
- var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
- var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
- width: 25,
- el: this.checkbox
- }, this.text);
- BI.createWidget(BI.extend({
- element: this
- }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
- items: items
- }))));
- },
-
- isOnce: function () {
- return true;
- },
-
- doRedMark: function () {
- this.text.doRedMark.apply(this.text, arguments);
- },
-
- unRedMark: function () {
- this.text.unRedMark.apply(this.text, arguments);
- },
-
- doClick: function () {
- BI.NodeButton.superclass.doClick.apply(this, arguments);
- },
-
- setOpened: function (v) {
- BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.checkbox)) {
- this.checkbox.setSelected(v);
- }
- }
-});
-
-BI.shortcut("bi.select_tree_last_plus_group_node", BI.SelectTreeLastPlusGroupNode);/**
- * 加号表示的组节点
- * Created by GUY on 2015/9/6.
- * @class BI.SelectTreeMidPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: (conf.baseCls || "") + " bi-select-tree-mid-plus-group-node bi-list-item-active",
- logic: {
- dynamic: false
- },
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.checkbox = BI.createWidget({
- type: "bi.mid_tree_node_checkbox",
- stopPropagation: true
- });
- this.text = BI.createWidget({
- type: "bi.label",
- textAlign: "left",
- whiteSpace: "nowrap",
- textHeight: o.height,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {
- if (this.isSelected()) {
- self.triggerExpand();
- } else {
- self.triggerCollapse();
- }
- }
- });
- var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
- var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
- width: 25,
- el: this.checkbox
- }, this.text);
- BI.createWidget(BI.extend({
- element: this
- }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
- items: items
- }))));
- },
-
- isOnce: function () {
- return true;
- },
-
- doRedMark: function () {
- this.text.doRedMark.apply(this.text, arguments);
- },
-
- unRedMark: function () {
- this.text.unRedMark.apply(this.text, arguments);
- },
-
- doClick: function () {
- BI.NodeButton.superclass.doClick.apply(this, arguments);
- },
-
- setOpened: function (v) {
- BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.checkbox)) {
- this.checkbox.setSelected(v);
- }
- }
-});
-
-BI.shortcut("bi.select_tree_mid_plus_group_node", BI.SelectTreeMidPlusGroupNode);/**
- * @class BI.SelectTreeCombo
- * @extends BI.Widget
- */
-BI.SelectTreeCombo = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SelectTreeCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-select-tree-combo",
- height: 30,
- text: "",
- items: []
- });
- },
-
- _init: function () {
- BI.SelectTreeCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.single_tree_trigger",
- text: o.text,
- height: o.height,
- items: o.items
- });
-
- this.popup = BI.createWidget({
- type: "bi.select_tree_popup",
- items: o.items
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- adjustLength: 2,
- el: this.trigger,
- popup: {
- el: this.popup
- }
- });
-
- this.combo.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- });
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- },
-
- populate: function (items) {
- this.combo.populate(items);
- }
-});
-
-
-BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo);/**
- * @class BI.SelectTreeExpander
- * @extends BI.Widget
- */
-BI.SelectTreeExpander = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-select-tree-expander",
- trigger: "click",
- toggle: true,
- direction: "bottom",
- isDefaultInit: true,
- el: {},
- popup: {}
- });
- },
-
- _init: function () {
- BI.SelectTreeExpander.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget(BI.extend({stopPropagation: true}, o.el));
- this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {
- if (this.isSelected()) {
- self.expander.setValue([]);
- }
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.expander = BI.createWidget({
- type: "bi.expander",
- element: this,
- trigger: o.trigger,
- toggle: o.toggle,
- direction: o.direction,
- isDefaultInit: o.isDefaultInit,
- el: this.trigger,
- popup: o.popup
- });
- this.expander.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {
- self.trigger.setSelected(false);
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- },
-
- setValue: function (v) {
- if (BI.contains(v, this.trigger.getValue())) {
- this.trigger.setSelected(true);
- this.expander.setValue([]);
- } else {
- this.trigger.setSelected(false);
- this.expander.setValue(v);
- }
- },
-
- getValue: function () {
- if (this.trigger.isSelected()) {
- return [this.trigger.getValue()];
- }
- return this.expander.getValue();
- },
-
- populate: function (items) {
- this.expander.populate(items);
- }
-});
-
-BI.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);/**
- * @class BI.SelectTreePopup
- * @extends BI.Pane
- */
-
-BI.SelectTreePopup = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-select-tree-popup",
- tipText: BI.i18nText("BI-No_Selected_Item"),
- items: []
- });
- },
-
- _formatItems: function (nodes, layer) {
- var self = this;
- BI.each(nodes, function (i, node) {
- var extend = {layer: layer};
- node.id = node.id || BI.UUID();
- if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
- switch (i) {
- case 0 :
- extend.type = "bi.select_tree_first_plus_group_node";
- break;
- case nodes.length - 1 :
- extend.type = "bi.select_tree_last_plus_group_node";
- break;
- default :
- extend.type = "bi.select_tree_mid_plus_group_node";
- break;
- }
- BI.defaults(node, extend);
- self._formatItems(node.children);
- } else {
- switch (i) {
- case nodes.length - 1:
- extend.type = "bi.last_tree_leaf_item";
- break;
- default :
- extend.type = "bi.mid_tree_leaf_item";
- }
- BI.defaults(node, extend);
- }
- });
- return nodes;
- },
-
- _init: function () {
- BI.SelectTreePopup.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- this.tree = BI.createWidget({
- type: 'bi.level_tree',
- expander: {
- type: "bi.select_tree_expander",
- isDefaultInit: true
- },
- items: this._formatItems(BI.Tree.transformToTreeFormat(o.items)),
- chooseType: BI.Selection.Single
- });
-
- BI.createWidget({
- type: "bi.vertical",
- element: this,
- items: [this.tree]
- });
-
- this.tree.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.tree.on(BI.LevelTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.SelectTreePopup.EVENT_CHANGE);
- });
-
- this.check();
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.tree.setValue(v);
- },
-
- populate: function (items) {
- BI.SelectTreePopup.superclass.populate.apply(this, arguments);
- this.tree.populate(items);
- }
-});
-
-BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.select_tree_popup", BI.SelectTreePopup);/**
- *
- * Created by GUY on 2016/8/10.
- * @class BI.SequenceTableDynamicNumber
- * @extends BI.SequenceTableTreeNumber
- */
-BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-sequence-table-dynamic-number"
- });
- },
-
- _init: function () {
- BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments);
- },
-
- _formatNumber: function (nodes) {
- var self = this, o = this.options;
- var result = [];
- var count = this._getStart(nodes);
-
- function getLeafCount(node) {
- var cnt = 0;
- if (BI.isNotEmptyArray(node.children)) {
- BI.each(node.children, function (index, child) {
- cnt += getLeafCount(child);
- });
- if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) {
- cnt++;
- }
- } else {
- cnt++;
- }
- return cnt;
- }
-
- var start = 0, top = 0;
- BI.each(nodes, function (i, node) {
- if (BI.isArray(node.children)) {
- BI.each(node.children, function (index, child) {
- var cnt = getLeafCount(child);
- result.push({
- text: count++,
- start: start,
- top: top,
- cnt: cnt,
- index: index,
- height: cnt * o.rowSize
- });
- start += cnt;
- top += cnt * o.rowSize;
- });
- if (BI.isNotEmptyArray(node.values)) {
- result.push({
- text: BI.i18nText("BI-Summary_Values"),
- start: start++,
- top: top,
- cnt: 1,
- isSummary: true,
- height: o.rowSize
- });
- top += o.rowSize;
- }
- }
- });
- return result;
- }
-});
-BI.shortcut('bi.sequence_table_dynamic_number', BI.SequenceTableDynamicNumber);/**
- *
- * Created by GUY on 2016/5/26.
- * @class BI.SequenceTableListNumber
- * @extends BI.Widget
- */
-BI.SequenceTableListNumber = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-sequence-table-list-number",
- isNeedFreeze: false,
- scrollTop: 0,
- startSequence: 1,//开始的序号
- headerRowSize: 25,
- rowSize: 25,
-
- sequenceHeaderCreator: null,
-
- header: [],
- items: [], //二维数组
-
- //交叉表头
- crossHeader: [],
- crossItems: [],
-
- pageSize: 20
- });
- },
-
- _init: function () {
- BI.SequenceTableListNumber.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.start = o.startSequence;
- this.renderedCells = [];
- this.renderedKeys = [];
-
- this.container = BI.createWidget({
- type: "bi.absolute",
- width: 60,
- scrollable: false
- });
-
- this.scrollContainer = BI.createWidget({
- type: "bi.vertical",
- scrollable: false,
- scrolly: false,
- items: [this.container]
- });
-
- this.headerContainer = BI.createWidget({
- type: "bi.absolute",
- cls: "bi-border",
- width: 58,
- scrollable: false
- });
-
- this.layout = BI.createWidget({
- type: "bi.vtape",
- element: this,
- items: [{
- el: this.headerContainer,
- height: o.headerRowSize * o.header.length - 2
- }, {
- el: {type: "bi.layout"},
- height: 2
- }, {
- el: this.scrollContainer
- }]
- });
- this._populate();
- },
-
- _layout: function () {
- var self = this, o = this.options;
- var headerHeight = o.headerRowSize * o.header.length - 2;
- var items = this.layout.attr("items");
- if (o.isNeedFreeze === false) {
- items[0].height = 0;
- items[1].height = 0;
- } else if (o.isNeedFreeze === true) {
- items[0].height = headerHeight;
- items[1].height = 2;
- }
- this.layout.attr("items", items);
- this.layout.resize();
- this.container.setHeight(o.items.length * o.rowSize);
- try {
- this.scrollContainer.element.scrollTop(o.scrollTop);
- } catch (e) {
-
- }
- },
-
- _createHeader: function () {
- var o = this.options;
- BI.createWidget({
- type: "bi.absolute",
- element: this.headerContainer,
- items: [{
- el: o.sequenceHeaderCreator || {
- type: "bi.table_style_cell",
- cls: "sequence-table-title-cell",
- styleGetter: o.headerCellStyleGetter,
- text: BI.i18nText("BI-Number_Index")
- },
- left: 0,
- top: 0,
- right: 0,
- bottom: 0
- }]
- });
- },
-
- _calculateChildrenToRender: function () {
- var self = this, o = this.options;
- var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth());
- var start = Math.floor(scrollTop / o.rowSize);
- var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize);
- var renderedCells = [], renderedKeys = [];
- for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) {
- var index = BI.deepIndexOf(this.renderedKeys, this.start + i);
- var top = i * o.rowSize;
- if (index > -1) {
- if (o.rowSize !== this.renderedCells[index]._height) {
- this.renderedCells[index]._height = o.rowSize;
- this.renderedCells[index].el.setHeight(o.rowSize);
- }
- if (this.renderedCells[index].top !== top) {
- this.renderedCells[index].top = top;
- this.renderedCells[index].el.element.css("top", top + "px");
- }
- renderedCells.push(this.renderedCells[index]);
- } else {
- var child = BI.createWidget(BI.extend({
- type: "bi.table_style_cell",
- cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",
- width: 60,
- height: o.rowSize,
- text: this.start + i,
- styleGetter: function (index) {
- return function () {
- return o.sequenceCellStyleGetter(self.start + i - 1);
- }
- }(cnt)
- }));
- renderedCells.push({
- el: child,
- left: 0,
- top: top,
- _height: o.rowSize
- });
- }
- renderedKeys.push(this.start + i);
- }
-
- //已存在的, 需要添加的和需要删除的
- var existSet = {}, addSet = {}, deleteArray = [];
- BI.each(renderedKeys, function (i, key) {
- if (BI.deepContains(self.renderedKeys, key)) {
- existSet[i] = key;
- } else {
- addSet[i] = key;
- }
- });
- BI.each(this.renderedKeys, function (i, key) {
- if (BI.deepContains(existSet, key)) {
- return;
- }
- if (BI.deepContains(addSet, key)) {
- return;
- }
- deleteArray.push(i);
- });
- BI.each(deleteArray, function (i, index) {
- self.renderedCells[index].el.destroy();
- });
- var addedItems = [];
- BI.each(addSet, function (index) {
- addedItems.push(renderedCells[index])
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: addedItems
- });
- this.renderedCells = renderedCells;
- this.renderedKeys = renderedKeys;
- },
-
- _populate: function () {
- this.headerContainer.empty();
- this._createHeader();
- this._layout();
- this._calculateChildrenToRender();
- },
-
- setVerticalScroll: function (scrollTop) {
- if (this.options.scrollTop !== scrollTop) {
- this.options.scrollTop = scrollTop;
- try {
- this.scrollContainer.element.scrollTop(scrollTop);
- } catch (e) {
-
- }
- }
- },
-
- getVerticalScroll: function () {
- return this.options.scrollTop;
- },
-
- setVPage: function (v) {
- v = v < 1 ? 1 : v;
- var o = this.options;
- this.start = (v - 1) * o.pageSize + 1;
- },
-
- _restore: function () {
- var o = this.options;
- BI.each(this.renderedCells, function (i, cell) {
- cell.el.destroy();
- });
- this.renderedCells = [];
- this.renderedKeys = [];
- },
-
- restore: function () {
- this._restore();
- },
-
- populate: function (items, header) {
- var o = this.options;
- if (items && items !== this.options.items) {
- o.items = items;
- this._restore();
- }
- if (header && header !== this.options.header) {
- o.header = header;
- }
- this._populate();
- }
-});
-BI.shortcut('bi.sequence_table_list_number', BI.SequenceTableListNumber);/**
- * 带有序号的表格
- *
- * Created by GUY on 2016/5/26.
- * @class BI.SequenceTable
- * @extends BI.Widget
- */
-BI.SequenceTable = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-sequence-table",
- el: {
- type: "bi.adaptive_table"
- },
-
- sequence: {},
-
- isNeedResize: true,
- isResizeAdapt: false,
-
- isNeedFreeze: false,//是否需要冻结单元格
- freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
-
- isNeedMerge: false,//是否需要合并单元格
- mergeCols: [], //合并的单元格列号
- mergeRule: BI.emptyFn,
-
- columnSize: [],
- minColumnSize: [],
- maxColumnSize: [],
- headerRowSize: 25,
- rowSize: 25,
-
- regionColumnSize: [],
-
- headerCellStyleGetter: BI.emptyFn,
- summaryCellStyleGetter: BI.emptyFn,
- sequenceCellStyleGetter: BI.emptyFn,
-
- header: [],
- items: [], //二维数组
-
- //交叉表头
- crossHeader: [],
- crossItems: [],
-
- showSequence: false,
- startSequence: 1//开始的序号
- });
- },
-
- _init: function () {
- BI.SequenceTable.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.sequence = BI.createWidget(o.sequence, {
- type: "bi.sequence_table_list_number",
- invisible: o.showSequence === false,
- startSequence: o.startSequence,
- isNeedFreeze: o.isNeedFreeze,
- header: o.header,
- items: o.items,
- crossHeader: o.crossHeader,
- crossItems: o.crossItems,
- headerRowSize: o.headerRowSize,
- rowSize: o.rowSize,
- width: 60,
- height: o.height && o.height - BI.GridTableScrollbar.SIZE,
-
- headerCellStyleGetter: o.headerCellStyleGetter,
- summaryCellStyleGetter: o.summaryCellStyleGetter,
- sequenceCellStyleGetter: o.sequenceCellStyleGetter
- });
- this.table = BI.createWidget(o.el, {
- type: "bi.adaptive_table",
- width: o.showSequence === true ? o.width - 60 : o.width,
- height: o.height,
- isNeedResize: o.isNeedResize,
- isResizeAdapt: o.isResizeAdapt,
-
- isNeedFreeze: o.isNeedFreeze,
- freezeCols: o.freezeCols,
-
- isNeedMerge: o.isNeedMerge,
- mergeCols: o.mergeCols,
- mergeRule: o.mergeRule,
-
- columnSize: o.columnSize,
- minColumnSize: o.minColumnSize,
- maxColumnSize: o.maxColumnSize,
- headerRowSize: o.headerRowSize,
- rowSize: o.rowSize,
-
- regionColumnSize: o.regionColumnSize,
-
- headerCellStyleGetter: o.headerCellStyleGetter,
- summaryCellStyleGetter: o.summaryCellStyleGetter,
- sequenceCellStyleGetter: o.sequenceCellStyleGetter,
-
- header: o.header,
- items: o.items,
- //交叉表头
- crossHeader: o.crossHeader,
- crossItems: o.crossItems
- });
-
- this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) {
- if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) {
- self.sequence.setVerticalScroll(this.getVerticalScroll());
- self.sequence.populate();
- }
- self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
- o.regionColumnSize = this.getRegionColumnSize();
- o.columnSize = this.getColumnSize();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
- o.regionColumnSize = this.getRegionColumnSize();
- o.columnSize = this.getColumnSize();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
- });
-
- this.htape = BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.sequence,
- left: 0,
- top: 0
- }, {
- el: this.table,
- top: 0,
- left: o.showSequence === true ? 60 : 0
- }]
- });
- this._populate();
- },
-
- _populate: function () {
- var o = this.options;
- this.sequence.attr({
- items: o.items,
- header: o.header,
- crossItems: o.crossItems,
- crossHeader: o.crossHeader
- });
- if (o.showSequence === true) {
- this.sequence.setVisible(true);
- this.table.element.css("left", "60px");
- this.table.setWidth(o.width - 60);
- } else {
- this.sequence.setVisible(false);
- this.table.element.css("left", "0px");
- this.table.setWidth(o.width);
- }
- },
-
- setWidth: function (width) {
- BI.PageTable.superclass.setWidth.apply(this, arguments);
- this.table.setWidth(this.options.showSequence ? width - 60 : width);
- },
-
- setHeight: function (height) {
- BI.PageTable.superclass.setHeight.apply(this, arguments);
- this.table.setHeight(height);
- this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE);
- },
-
- setColumnSize: function (columnSize) {
- this.options.columnSize = columnSize;
- this.table.setColumnSize(columnSize);
- },
-
- getColumnSize: function () {
- return this.table.getColumnSize();
- },
-
- setRegionColumnSize: function (columnSize) {
- this.options.columnSize = columnSize;
- this.table.setRegionColumnSize(columnSize);
- },
-
- getRegionColumnSize: function () {
- return this.table.getRegionColumnSize();
- },
-
- hasLeftHorizontalScroll: function () {
- return this.table.hasLeftHorizontalScroll();
- },
-
- hasRightHorizontalScroll: function () {
- return this.table.hasRightHorizontalScroll();
- },
-
- setLeftHorizontalScroll: function (scrollLeft) {
- this.table.setLeftHorizontalScroll(scrollLeft);
- },
-
- setRightHorizontalScroll: function (scrollLeft) {
- this.table.setRightHorizontalScroll(scrollLeft);
- },
-
- setVerticalScroll: function (scrollTop) {
- this.table.setVerticalScroll(scrollTop);
- this.sequence.setVerticalScroll(scrollTop);
- },
-
- getVerticalScroll: function () {
- return this.table.getVerticalScroll();
- },
-
- setVPage: function (page) {
- this.sequence.setVPage && this.sequence.setVPage(page);
- },
-
- setHPage: function (page) {
- this.sequence.setHPage && this.sequence.setHPage(page);
- },
-
- attr: function () {
- BI.SequenceTable.superclass.attr.apply(this, arguments);
- this.table.attr.apply(this.table, arguments);
- this.sequence.attr.apply(this.sequence, arguments);
- },
-
- restore: function () {
- this.table.restore();
- this.sequence.restore();
- },
-
- populate: function (items, header, crossItems, crossHeader) {
- var o = this.options;
- if (items) {
- o.items = items;
- }
- if (header) {
- o.header = header;
- }
- if (crossItems) {
- o.crossItems = crossItems;
- }
- if (crossHeader) {
- o.crossHeader = crossHeader;
- }
- this._populate();
- this.table.populate.apply(this.table, arguments);
- this.sequence.populate.apply(this.sequence, arguments);
- this.sequence.setVerticalScroll(this.table.getVerticalScroll());
- },
-
- destroy: function () {
- this.table.destroy();
- BI.SequenceTable.superclass.destroy.apply(this, arguments);
- }
-});
-BI.shortcut('bi.sequence_table', BI.SequenceTable);/**
- * @class BI.SingleTreeCombo
- * @extends BI.Widget
- */
-BI.SingleTreeCombo = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-single-tree-combo",
- trigger: {},
- height: 30,
- text: "",
- items: []
- });
- },
-
- _init: function () {
- BI.SingleTreeCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget(BI.extend({
- type: "bi.single_tree_trigger",
- text: o.text,
- height: o.height,
- items: o.items
- }, o.trigger));
-
- this.popup = BI.createWidget({
- type: "bi.single_tree_popup",
- items: o.items
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- adjustLength: 2,
- el: this.trigger,
- popup: {
- el: this.popup
- }
- });
-
- this.combo.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments);
- });
-
- this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE);
- });
- },
-
- populate: function (items) {
- this.combo.populate(items);
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- }
-});
-
-BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE";
-BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/**
- * @class BI.SingleTreePopup
- * @extends BI.Pane
- */
-
-BI.SingleTreePopup = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-single-tree-popup",
- tipText: BI.i18nText("BI-No_Selected_Item"),
- items: []
- });
- },
-
- _init: function () {
- BI.SingleTreePopup.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- this.tree = BI.createWidget({
- type: 'bi.level_tree',
- expander: {
- isDefaultInit: true
- },
- items: o.items,
- chooseType: BI.Selection.Single
- });
-
- BI.createWidget({
- type: "bi.vertical",
- element: this,
- items: [this.tree]
- });
-
- this.tree.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.tree.on(BI.LevelTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.SingleTreePopup.EVENT_CHANGE);
- });
-
- this.check();
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.tree.setValue(v);
- },
-
- populate: function (items) {
- BI.SingleTreePopup.superclass.populate.apply(this, arguments);
- this.tree.populate(items);
- }
-});
-
-BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.single_tree_popup", BI.SingleTreePopup);/**
- * @class BI.SingleTreeTrigger
- * @extends BI.Trigger
- */
-
-BI.SingleTreeTrigger = BI.inherit(BI.Trigger, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-single-tree-trigger",
- height: 30,
- text: "",
- items: []
- });
- },
-
- _init: function () {
- BI.SingleTreeTrigger.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.select_text_trigger",
- element: this,
- text: o.text,
- items: o.items,
- height: o.height
- });
- },
-
- _checkTitle: function () {
- var self = this, val = this.getValue();
- BI.any(this.options.items, function (i, item) {
- if (val.contains(item.value)) {
- self.trigger.setTitle(item.text || item.value);
- return true;
- }
- });
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.options.value = v;
- this.trigger.setValue(v);
- this._checkTitle();
- },
-
- getValue: function () {
- return this.options.value || [];
- },
-
- populate: function (items) {
- BI.SingleTreeTrigger.superclass.populate.apply(this, arguments);
- this.trigger.populate(items);
- }
-
-});
-
-BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);/**
- * 可以单选多选切换的树
- *
- * Created by GUY on 2015/12/21.
- * @class BI.SwitchTree
- * @extends BI.Widget
- */
-BI.SwitchTree = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-switch-tree",
- items: []
- });
- },
-
- _init: function () {
- BI.SwitchTree.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.tab = BI.createWidget({
- type: "bi.tab",
- element: this,
- tab: null,
- defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect,
- cardCreator: BI.bind(this._createTree, this)
- });
- },
-
- _createTree: function (type) {
- var self = this, o = this.options;
- switch (type) {
- case BI.SwitchTree.SelectType.SingleSelect:
- this.levelTree = BI.createWidget({
- type: "bi.multilayer_single_level_tree",
- isDefaultInit: true,
- items: BI.deepClone(o.items)
- });
- this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments);
- });
- return this.levelTree;
- case BI.SwitchTree.SelectType.MultiSelect:
- this.tree = BI.createWidget({
- type: "bi.simple_tree",
- items: this._removeIsParent(BI.deepClone(o.items))
- });
- this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () {
- self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments);
- });
- return this.tree;
- }
- },
-
- _removeIsParent: function(items) {
- BI.each(items, function(i, item) {
- BI.isNotNull(item.isParent) && delete item.isParent;
- });
- return items;
- },
-
- switchSelect: function () {
- switch (this.getSelect()) {
- case BI.SwitchTree.SelectType.SingleSelect:
- this.setSelect(BI.SwitchTree.SelectType.MultiSelect);
- break;
- case BI.SwitchTree.SelectType.MultiSelect:
- this.setSelect(BI.SwitchTree.SelectType.SingleSelect);
- break;
- }
- },
-
- setSelect: function (v) {
- this.tab.setSelect(v);
- },
-
- getSelect: function () {
- return this.tab.getSelect();
- },
-
- setValue: function (v) {
- this.storeValue = v;
- switch (this.getSelect()) {
- case BI.SwitchTree.SelectType.SingleSelect:
- this.levelTree.setValue(v);
- break;
- case BI.SwitchTree.SelectType.MultiSelect:
- this.tree.setValue(v);
- break;
- }
- },
-
- getValue: function () {
- return this.tab.getValue();
- },
-
- populate: function (items) {
- this.options.items = items;
- if (BI.isNotNull(this.levelTree)) {
- this.levelTree.populate(BI.deepClone(items));
- }
- if (BI.isNotNull(this.tree)) {
- this.tree.populate(this._removeIsParent(BI.deepClone(items)));
- }
- }
-});
-BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE";
-BI.SwitchTree.SelectType = {
- SingleSelect: BI.Selection.Single,
- MultiSelect: BI.Selection.Multi
-};
-BI.shortcut('bi.switch_tree', BI.SwitchTree);
-/**
- * 年份下拉框
- *
- * Created by GUY on 2015/8/28.
- * @class BI.YearCombo
- * @extends BI.Widget
- */
-BI.YearCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-year-combo",
- behaviors: {},
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- height: 25
- });
- },
- _init: function () {
- BI.YearCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.storeValue = "";
- this.trigger = BI.createWidget({
- type: "bi.year_trigger",
- min: o.min,
- max: o.max
- });
- this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () {
- self.storeValue = this.getKey();
- });
- this.trigger.on(BI.YearTrigger.EVENT_START, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- });
- this.trigger.on(BI.YearTrigger.EVENT_STOP, function () {
- self.combo.showView();
- });
- this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- });
- this.trigger.on(BI.YearTrigger.EVENT_CONFIRM, function () {
- if (self.combo.isViewVisible()) {
- return;
- }
- if (this.getKey() && this.getKey() !== self.storeValue) {
- self.setValue(this.getKey());
- } else if (!this.getKey()) {
- self.setValue();
- }
- self.fireEvent(BI.YearCombo.EVENT_CONFIRM);
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- destroyWhenHide: true,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- minWidth: 85,
- stopPropagation: false,
- el: {
- type: "bi.year_popup",
- ref: function () {
- self.popup = this;
- },
- listeners: [{
- eventName: BI.YearPopup.EVENT_CHANGE,
- action: function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.YearCombo.EVENT_CONFIRM);
- }
- }],
- behaviors: o.behaviors,
- min: o.min,
- max: o.max
- }
- }
- });
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- var value = self.trigger.getKey();
- if (BI.isNotNull(value)) {
- self.popup.setValue(value);
- } else if (!value && value !== self.storeValue) {
- self.popup.setValue(self.storeValue);
- } else {
- self.setValue();
- }
- self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW);
- });
- },
-
- setValue: function (v) {
- this.combo.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- }
-});
-BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.year_combo', BI.YearCombo);/**
- * 年份展示面板
- *
- * Created by GUY on 2015/9/2.
- * @class BI.YearPopup
- * @extends BI.Trigger
- */
-BI.YearPopup = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-year-popup",
- behaviors: {},
- min: '1900-01-01', //最小日期
- max: '2099-12-31' //最大日期
- });
- },
-
- _createYearCalendar: function (v) {
- var o = this.options, y = this._year;
-
- var calendar = BI.createWidget({
- type: "bi.year_calendar",
- behaviors: o.behaviors,
- min: o.min,
- max: o.max,
- logic: {
- dynamic: true
- },
- year: y + v * 12
- });
- calendar.setValue(this._year);
- return calendar;
- },
-
- _init: function () {
- BI.YearPopup.superclass._init.apply(this, arguments);
- var self = this;
-
- this.selectedYear = this._year = new Date().getFullYear();
-
- var backBtn = BI.createWidget({
- type: "bi.icon_button",
- cls: "pre-page-h-font",
- width: 25,
- height: 25,
- value: -1
- });
-
- var preBtn = BI.createWidget({
- type: "bi.icon_button",
- cls: "next-page-h-font",
- width: 25,
- height: 25,
- value: 1
- });
-
- this.navigation = BI.createWidget({
- type: "bi.navigation",
- element: this,
- single: true,
- logic: {
- dynamic: true
- },
- tab: {
- cls: "year-popup-navigation bi-high-light bi-border-top",
- height: 25,
- items: [backBtn, preBtn]
- },
- cardCreator: BI.bind(this._createYearCalendar, this),
-
- afterCardShow: function () {
- this.setValue(self.selectedYear);
- var calendar = this.getSelectedCard();
- backBtn.setEnable(!calendar.isFrontYear());
- preBtn.setEnable(!calendar.isFinalYear());
- }
- });
-
- this.navigation.on(BI.Navigation.EVENT_CHANGE, function () {
- self.selectedYear = this.getValue();
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear);
- });
- },
-
- getValue: function () {
- return this.selectedYear;
- },
-
- setValue: function (v) {
- var o = this.options;
- if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) {
- v = new Date().getFullYear();
- this.selectedYear = "";
- this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
- this.navigation.setValue("");
- } else {
- this.selectedYear = v;
- this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
- this.navigation.setValue(v);
- }
- }
-});
-BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.year_popup", BI.YearPopup);/**
- * 年份trigger
- *
- * Created by GUY on 2015/8/21.
- * @class BI.YearTrigger
- * @extends BI.Trigger
- */
-BI.YearTrigger = BI.inherit(BI.Trigger, {
- _const: {
- hgap: 4,
- vgap: 2,
- triggerWidth: 25,
- errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
- errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text")
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-year-trigger bi-border",
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- height: 25
- });
- },
- _init: function () {
- BI.YearTrigger.superclass._init.apply(this, arguments);
- var self = this, o = this.options, c = this._const;
- this.editor = BI.createWidget({
- type: "bi.sign_editor",
- height: o.height,
- validationChecker: function (v) {
- self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid);
- return v === "" || (BI.isPositiveInteger(v) && !Date.checkVoid(v, 1, 1, o.min, o.max)[0]);
- },
- quitChecker: function (v) {
- return false;
- },
- hgap: c.hgap,
- vgap: c.vgap,
- allowBlank: true,
- errorText: c.errorText
- })
- this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
- self.fireEvent(BI.YearTrigger.EVENT_FOCUS);
- });
- this.editor.on(BI.SignEditor.EVENT_STOP, function () {
- self.fireEvent(BI.YearTrigger.EVENT_STOP);
- });
- this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
- var value = self.editor.getValue();
- if (BI.isNotNull(value)) {
- self.editor.setValue(value);
- self.editor.setTitle(value);
- }
- self.fireEvent(BI.YearTrigger.EVENT_CONFIRM);
- });
- this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
- if (self.editor.isValid()) {
- self.editor.blur();
- }
- });
- this.editor.on(BI.SignEditor.EVENT_START, function () {
- self.fireEvent(BI.YearTrigger.EVENT_START);
- });
- this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
- self.fireEvent(BI.YearTrigger.EVENT_ERROR);
- });
- BI.createWidget({
- element: this,
- type: 'bi.htape',
- items: [
- {
- el: this.editor
- }, {
- el: {
- type: "bi.text_button",
- baseCls: "bi-trigger-year-text",
- text: BI.i18nText("BI-Multi_Date_Year"),
- width: c.triggerWidth
- },
- width: c.triggerWidth
- }, {
- el: {
- type: "bi.trigger_icon_button",
- width: c.triggerWidth
- },
- width: c.triggerWidth
- }
- ]
- });
- },
- setValue: function (v) {
- this.editor.setState(v);
- this.editor.setValue(v);
- this.editor.setTitle(v);
- },
- getKey: function () {
- return this.editor.getValue() | 0;
- }
-});
-BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS";
-BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR";
-BI.YearTrigger.EVENT_START = "EVENT_START";
-BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.YearTrigger.EVENT_STOP = "EVENT_STOP";
-BI.shortcut("bi.year_trigger", BI.YearTrigger);/**
- * 年份 + 月份下拉框
- *
- * @class BI.YearMonthCombo
- * @extends BI.Widget
- */
-BI.YearMonthCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-year-month-combo",
- yearBehaviors: {},
- monthBehaviors: {},
- height: 25
- });
- },
- _init: function () {
- BI.YearMonthCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.year = BI.createWidget({
- type: "bi.year_combo",
- behaviors: o.yearBehaviors
- });
-
- this.month = BI.createWidget({
- type: "bi.month_combo",
- behaviors: o.monthBehaviors
- });
-
- this.year.on(BI.YearCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
- });
- this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW);
- });
-
- this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
- });
- this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW);
- });
-
- BI.createWidget({
- type: "bi.center",
- element: this,
- hgap: 5,
- items: [this.year, this.month]
- });
-
- },
-
- setValue: function (v) {
- v = v || {};
- this.month.setValue(v.month);
- this.year.setValue(v.year);
- },
-
- getValue: function () {
- return {
- year: this.year.getValue(),
- month: this.month.getValue()
- };
- }
-});
-BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/**
- * 年份 + 月份下拉框
- *
- * @class BI.YearQuarterCombo
- * @extends BI.Widget
- */
-BI.YearQuarterCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-year-quarter-combo",
- yearBehaviors: {},
- quarterBehaviors: {},
- height: 25
- });
- },
- _init: function () {
- BI.YearQuarterCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.year = BI.createWidget({
- type: "bi.year_combo",
- behaviors: o.yearBehaviors
- });
-
- this.quarter = BI.createWidget({
- type: "bi.quarter_combo",
- behaviors: o.quarterBehaviors
- });
-
- this.year.on(BI.YearCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM);
- });
- this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
- });
-
- this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM);
- });
- this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
- });
-
- BI.createWidget({
- type: "bi.center",
- element: this,
- hgap: 5,
- items: [this.year, this.quarter]
- });
-
- },
-
- setValue: function (v) {
- v = v || {};
- this.quarter.setValue(v.quarter);
- this.year.setValue(v.year);
- },
-
- getValue: function () {
- return {
- year: this.year.getValue(),
- quarter: this.quarter.getValue()
- };
- }
-});
-BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/**
- * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AbstractAllValueChooser
- * @extends BI.Widget
- */
-BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
-
- _const: {
- perPage: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), {
- width: 200,
- height: 30,
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _valueFormatter: function (v) {
- var text = v;
- if (BI.isNotNull(this.items)) {
- BI.some(this.items, function (i, item) {
- if (item.value === v) {
- text = item.text;
- return true;
- }
- });
- }
- return text;
- },
-
- _itemsCreator: function (options, callback) {
- var self = this, o = this.options;
- if (!o.cache || !this.items) {
- o.itemsCreator({}, function (items) {
- self.items = items;
- call(items);
- });
- } else {
- call(this.items);
- }
- function call(items) {
- var keywords = (options.keywords || []).slice();
- if (options.keyword) {
- keywords.push(options.keyword);
- }
- BI.each(keywords, function (i, kw) {
- var search = BI.Func.getSearchResult(items, kw);
- items = search.matched.concat(search.finded);
- });
- if (options.selectedValues) {//过滤
- var filter = BI.makeObject(options.selectedValues, true);
- items = BI.filter(items, function (i, ob) {
- return !filter[ob.value];
- });
- }
- if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
- callback({
- items: items
- });
- return;
- }
- if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
- callback({count: items.length});
- return;
- }
- callback({
- items: items,
- hasNext: false
- });
- }
- }
-});/**
- * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AllValueChooserCombo
- * @extends BI.AbstractAllValueChooser
- */
-BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-all-value-chooser-combo",
- width: 200,
- height: 30,
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _init: function () {
- BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
- this.items = o.items;
- }
- this.combo = BI.createWidget({
- type: 'bi.multi_select_combo',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
- width: o.width,
- height: o.height
- });
-
- this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
- });
- },
-
- setValue: function (v) {
- this.combo.setValue({
- type: BI.Selection.Multi,
- value: v || []
- });
- },
-
- getValue: function () {
- var val = this.combo.getValue() || {};
- if (val.type === BI.Selection.All) {
- return val.assist;
- }
- return val.value || [];
- },
-
- populate: function () {
- this.combo.populate.apply(this, arguments);
- }
-});
-BI.AllValueChooserCombo.EVENT_CONFIRM = "AllValueChooserCombo.EVENT_CONFIRM";
-BI.shortcut('bi.all_value_chooser_combo', BI.AllValueChooserCombo);/**
- * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AllValueChooserPane
- * @extends BI.AbstractAllValueChooser
- */
-BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-all-value-chooser-pane",
- width: 200,
- height: 30,
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _init: function () {
- BI.AllValueChooserPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
- this.items = o.items;
- }
- this.list = BI.createWidget({
- type: 'bi.multi_select_list',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
- width: o.width,
- height: o.height
- });
-
- this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE);
- });
- },
-
- setValue: function (v) {
- this.list.setValue({
- type: BI.Selection.Multi,
- value: v || []
- });
- },
-
- getValue: function () {
- var val = this.list.getValue() || {};
- if (val.type === BI.Selection.All) {
- return val.assist;
- }
- return val.value || [];
- },
-
- populate: function () {
- this.list.populate.apply(this.list, arguments);
- }
-});
-BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE";
-BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
-
- _const: {
- perPage: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), {
- items: null,
- itemsCreator: BI.emptyFn
- });
- },
-
- _initData: function (items) {
- this.items = items;
- var nodes = BI.Tree.treeFormat(items);
- this.tree = new BI.Tree();
- this.tree.initTree(nodes);
- },
-
- _itemsCreator: function (options, callback) {
- var self = this, o = this.options;
- if (!this.items) {
- o.itemsCreator({}, function (items) {
- self._initData(items);
- call();
- });
- } else {
- call();
- }
- function call() {
- switch (options.type) {
- case BI.TreeView.REQ_TYPE_INIT_DATA:
- self._reqInitTreeNode(options, callback);
- break;
- case BI.TreeView.REQ_TYPE_ADJUST_DATA:
- self._reqAdjustTreeNode(options, callback);
- break;
- case BI.TreeView.REQ_TYPE_SELECT_DATA:
- self._reqSelectedTreeNode(options, callback);
- break;
- case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA:
- self._reqDisplayTreeNode(options, callback);
- break;
- default :
- self._reqTreeNode(options, callback);
- break;
- }
- }
- },
-
- _reqDisplayTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var selectedValues = op.selectedValues;
-
- if (selectedValues == null || BI.isEmpty(selectedValues)) {
- callback({});
- return;
- }
-
- doCheck([], this.tree.getRoot(), selectedValues);
-
- callback({
- items: result
- });
-
- function doCheck(parentValues, node, selected) {
- if (selected == null || BI.isEmpty(selected)) {
- BI.each(node.getChildren(), function (i, child) {
- var newParents = BI.clone(parentValues);
- newParents.push(child.value);
- var llen = self._getChildCount(newParents);
- createOneJson(child, node.id, llen);
- doCheck(newParents, child, {});
- });
- return;
- }
- BI.each(selected, function (k) {
- var node = self._getTreeNode(parentValues, k);
- var newParents = BI.clone(parentValues);
- newParents.push(node.value);
- createOneJson(node, node.parent && node.parent.id, getCount(selected[k], newParents));
- doCheck(newParents, node, selected[k]);
- })
- }
-
- function getCount(jo, parentValues) {
- if (jo == null) {
- return 0;
- }
- if (BI.isEmpty(jo)) {
- return self._getChildCount(parentValues);
- }
-
- return BI.size(jo);
- }
-
- function createOneJson(node, pId, llen) {
- result.push({
- id: node.id,
- pId: pId,
- text: node.text + (llen > 0 ? ("(" + BI.i18nText("BI-Basic_Altogether") + llen + BI.i18nText("BI-Basic_Count") + ")") : ""),
- value: node.value,
- open: true
- });
- }
- },
-
- _reqSelectedTreeNode: function (op, callback) {
- var self = this;
- var selectedValues = BI.deepClone(op.selectedValues);
- var notSelectedValue = op.notSelectedValue || {};
- var keyword = op.keyword || "";
- var parentValues = op.parentValues || [];
-
- if (selectedValues == null || BI.isEmpty(selectedValues)) {
- callback({});
- return;
- }
-
- dealWithSelectedValues(selectedValues);
- callback(selectedValues);
-
-
- function dealWithSelectedValues(selectedValues) {
- var p = parentValues.concat(notSelectedValue);
- //存储的值中存在这个值就把它删掉
- //例如选中了中国-江苏-南京, 取消中国或江苏或南京
- if (canFindKey(selectedValues, p)) {
- //如果搜索的值在父亲链中
- if (isSearchValueInParent(p)) {
- //例如选中了 中国-江苏, 搜索江苏, 取消江苏
- //例如选中了 中国-江苏, 搜索江苏, 取消中国
- self._deleteNode(selectedValues, p);
- } else {
- var searched = [];
- var finded = search(parentValues, notSelectedValue, [], searched);
- if (finded && BI.isNotEmptyArray(searched)) {
- BI.each(searched, function (i, arr) {
- var node = self._getNode(selectedValues, arr);
- if (node) {
- //例如选中了 中国-江苏-南京,搜索南京,取消中国
- self._deleteNode(selectedValues, arr);
- } else {
- //例如选中了 中国-江苏,搜索南京,取消中国
- expandSelectedValue(selectedValues, arr, BI.last(arr));
- }
- })
- }
- }
- }
-
- //存储的值中不存在这个值,但父亲节点是全选的情况
- //例如选中了中国-江苏,取消南京
- //important 选中了中国-江苏,取消了江苏,但是搜索的是南京
- if (isChild(selectedValues, p)) {
- var result = [], finded = false;
- //如果parentValues中有匹配的值,说明搜索结果不在当前值下
- if (isSearchValueInParent(p)) {
- finded = true;
- } else {
- //从当前值开始搜
- finded = search(parentValues, notSelectedValue, result);
- p = parentValues;
- }
-
- if (finded === true) {
- //去掉点击的节点之后的结果集
- expandSelectedValue(selectedValues, p, notSelectedValue);
- //添加去掉搜索的结果集
- if (result.length > 0) {
- BI.each(result, function (i, strs) {
- self._buildTree(selectedValues, strs);
- })
- }
- }
- }
-
- }
-
- function expandSelectedValue(selectedValues, parents, notSelectedValue) {
- var next = selectedValues;
- var childrenCount = [];
- var path = [];
- //去掉点击的节点之后的结果集
- BI.some(parents, function (i, v) {
- var t = next[v];
- if (t == null) {
- if (i === 0) {
- return true;
- }
- if (BI.isEmpty(next)) {
- var split = parents.slice(0, i);
- var expanded = self._getChildren(split);
- path.push(split);
- childrenCount.push(expanded.length);
- //如果只有一个值且取消的就是这个值
- if (i === parents.length - 1 && expanded.length === 1 && expanded[0] === notSelectedValue) {
- for (var j = childrenCount.length - 1; j >= 0; j--) {
- if (childrenCount[j] === 1) {
- self._deleteNode(selectedValues, path[j]);
- } else {
- break;
- }
- }
- } else {
- BI.each(expanded, function (m, child) {
- if (i === parents.length - 1 && child.value === notSelectedValue) {
- return true;
- }
- next[child.value] = {};
- });
- }
- next = next[v];
- } else {
- return true;
- // next = {};
- // next[v] = {};
- }
- } else {
- next = t;
- }
- });
- }
-
- function search(parents, current, result, searched) {
- var newParents = BI.clone(parents);
- newParents.push(current);
- if (self._isMatch(current, keyword)) {
- searched && searched.push(newParents);
- return true;
- }
-
- var children = self._getChildren(newParents);
-
- var notSearch = [];
- var can = false;
-
- BI.each(children, function (i, child) {
- if (search(newParents, child.value, result, searched)) {
- can = true;
- } else {
- notSearch.push(child.value);
- }
- });
- if (can === true) {
- BI.each(notSearch, function (i, v) {
- var next = BI.clone(newParents);
- next.push(v);
- result.push(next);
- });
- }
- return can;
- }
-
- function isSearchValueInParent(parentValues) {
- for (var i = 0, len = parentValues.length; i < len; i++) {
- if (self._isMatch(parentValues[i], keyword)) {
- return true;
- }
- }
- return false;
- }
-
- function canFindKey(selectedValues, parents) {
- var t = selectedValues;
- for (var i = 0; i < parents.length; i++) {
- var v = parents[i];
- t = t[v];
- if (t == null) {
- return false;
- }
- }
- return true;
- }
-
- function isChild(selectedValues, parents) {
- var t = selectedValues;
- for (var i = 0; i < parents.length; i++) {
- var v = parents[i];
- if (!BI.has(t, v)) {
- return false;
- }
- t = t[v];
- if (BI.isEmpty(t)) {
- return true;
- }
- }
- return false;
- }
- },
-
- _reqAdjustTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var selectedValues = op.selectedValues;
- if (selectedValues == null || BI.isEmpty(selectedValues)) {
- callback({});
- return;
- }
- BI.each(selectedValues, function (k, v) {
- result.push([k]);
- });
-
- dealWithSelectedValues(selectedValues, []);
-
- var jo = {};
- BI.each(result, function (i, strs) {
- self._buildTree(jo, strs);
- });
- callback(jo);
-
- function dealWithSelectedValues(selected, parents) {
- if (selected == null || BI.isEmpty(selected)) {
- return true;
- }
- var can = true;
- BI.each(selected, function (k, v) {
- var p = BI.clone(parents);
- p.push(k);
- if (!dealWithSelectedValues(selected[k], p)) {
- BI.each(selected[k], function (nk, nv) {
- var t = BI.clone(p);
- t.push(nk);
- result.push(t);
- });
- can = false;
- }
- });
- return can && isAllSelected(selected, parents);
- }
-
- function isAllSelected(selected, parents) {
- return BI.isEmpty(selected) || self._getChildCount(parents) === BI.size(selected);
- }
- },
-
- _reqInitTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var keyword = op.keyword || "";
- var selectedValues = op.selectedValues;
- var lastSearchValue = op.lastSearchValue || "";
- var output = search();
- BI.nextTick(function () {
- callback({
- hasNext: output.length > self._const.perPage,
- items: result,
- lastSearchValue: BI.last(output)
- })
- });
-
- function search() {
- var children = self._getChildren([]);
- var start = children.length;
- if (lastSearchValue !== "") {
- for (var j = 0, len = start; j < len; j++) {
- if (children[j].value === lastSearchValue) {
- start = j + 1;
- break;
- }
- }
- } else {
- start = 0;
- }
- var output = [];
- for (var i = start, len = children.length; i < len; i++) {
- if (output.length < self._const.perPage) {
- var find = nodeSearch(1, [], children[i].value, false, result);
- } else if (output.length === self._const.perPage) {
- var find = nodeSearch(1, [], children[i].value, false, []);
- }
- if (find[0] === true) {
- output.push(children[i].value);
- }
- if (output.length > self._const.perPage) {
- break;
- }
- }
- return output;
- }
-
- function nodeSearch(deep, parentValues, current, isAllSelect, result) {
- if (self._isMatch(current, keyword)) {
- var checked = isAllSelect || isSelected(parentValues, current);
- createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
- return [true, checked];
- }
- var newParents = BI.clone(parentValues);
- newParents.push(current);
- var children = self._getChildren(newParents);
-
- var can = false, checked = false;
-
- var isCurAllSelected = isAllSelect || isAllSelected(parentValues, current);
- BI.each(children, function (i, child) {
- var state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result);
- if (state[1] === true) {
- checked = true;
- }
- if (state[0] === true) {
- can = true;
- }
- });
- if (can === true) {
- checked = isCurAllSelected || (isSelected(parentValues, current) && checked);
- createOneJson(parentValues, current, true, checked, false, false, result);
- }
- return [can, checked];
- }
-
- function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
- var node = self._getTreeNode(parentValues, value)
- result.push({
- id: node.id,
- pId: node.pId,
- text: node.text,
- value: node.value,
- title: node.title,
- isParent: node.getChildrenLength() > 0,
- open: isOpen,
- checked: checked,
- halfCheck: half,
- flag: flag
- });
- }
-
- function isHalf(parentValues, value) {
- var find = findSelectedObj(parentValues);
- if (find == null) {
- return null;
- }
- return BI.any(find, function (v, ob) {
- if (v === value) {
- if (ob != null && !BI.isEmpty(ob)) {
- return true;
- }
- }
- });
- }
-
- function isAllSelected(parentValues, value) {
- var find = findSelectedObj(parentValues);
- if (find == null) {
- return null;
- }
- return BI.any(find, function (v, ob) {
- if (v === value) {
- if (ob != null && BI.isEmpty(ob)) {
- return true;
- }
- }
- });
- }
-
- function isSelected(parentValues, value) {
- var find = findSelectedObj(parentValues);
- if (find == null) {
- return false;
- }
- return BI.any(find, function (v) {
- if (v === value) {
- return true;
- }
- });
- }
-
- function findSelectedObj(parentValues) {
- var find = selectedValues;
- if (find == null) {
- return null;
- }
- BI.every(parentValues, function (i, v) {
- find = find[v];
- if (find == null) {
- return false;
- }
- return true;
- });
- return find;
- }
- },
-
- _reqTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var times = op.times;
- var checkState = op.checkState || {};
- var parentValues = op.parentValues || [];
- var selectedValues = op.selectedValues || {};
- var valueMap = {};
- // if (judgeState(parentValues, selectedValues, checkState)) {
- valueMap = dealWidthSelectedValue(parentValues, selectedValues);
- // }
- var nodes = this._getChildren(parentValues);
- for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) {
- var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState);
- result.push({
- id: nodes[i].id,
- pId: nodes[i].pId,
- value: nodes[i].value,
- text: nodes[i].text,
- times: 1,
- isParent: nodes[i].getChildrenLength() > 0,
- checked: state[0],
- halfCheck: state[1]
- })
- }
- BI.nextTick(function () {
- callback({
- items: result,
- hasNext: nodes.length > times * self._const.perPage
- });
- });
-
- function judgeState(parentValues, selected_value, checkState) {
- var checked = checkState.checked, half = checkState.half;
- if (parentValues.length > 0 && !checked) {
- return false;
- }
- return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value));
- }
-
- function dealWidthSelectedValue(parentValues, selectedValues) {
- var valueMap = {};
- BI.each(parentValues, function (i, v) {
- selectedValues = selectedValues[v] || {};
- });
- BI.each(selectedValues, function (value, obj) {
- if (BI.isNull(obj)) {
- valueMap[value] = [0, 0];
- return;
- }
- if (BI.isEmpty(obj)) {
- valueMap[value] = [2, 0];
- return;
- }
- var nextNames = {};
- BI.each(obj, function (t, o) {
- if (BI.isNull(o) || BI.isEmpty(o)) {
- nextNames[t] = true;
- }
- });
- valueMap[value] = [1, BI.size(nextNames)];
- });
- return valueMap;
- }
-
- function getCheckState(current, parentValues, valueMap, checkState) {
- var checked = checkState.checked, half = checkState.half;
- var tempCheck = false, halfCheck = false;
- if (BI.has(valueMap, current)) {
- //可能是半选
- if (valueMap[current][0] === 1) {
- var values = BI.clone(parentValues);
- values.push(current);
- var childCount = self._getChildCount(values);
- if (childCount > 0 && childCount !== valueMap[current][1]) {
- halfCheck = true;
- }
- } else if (valueMap[current][0] === 2) {
- tempCheck = true;
- }
- }
- var check;
- if (!checked && !halfCheck && !tempCheck) {
- check = BI.has(valueMap, current);
- } else {
- check = ((tempCheck || checked) && !half) || BI.has(valueMap, current);
- }
- return [check, halfCheck];
- }
- },
-
- _getNode: function (selectedValues, parentValues) {
- var pNode = selectedValues;
- for (var i = 0, len = parentValues.length; i < len; i++) {
- if (pNode == null) {
- return null;
- }
- pNode = pNode[parentValues[i]];
- }
- return pNode;
- },
-
- _deleteNode: function (selectedValues, values) {
- var name = values[values.length - 1];
- var p = values.slice(0, values.length - 1);
- var pNode = this._getNode(selectedValues, p);
- if (pNode != null && pNode[name]) {
- delete pNode[name];
- //递归删掉空父节点
- while (p.length > 0 && BI.isEmpty(pNode)) {
- name = p[p.length - 1];
- p = p.slice(0, p.length - 1);
- pNode = this._getNode(selectedValues, p);
- if (pNode != null) {
- delete pNode[name];
- }
- }
- }
- },
-
- _buildTree: function (jo, values) {
- var t = jo;
- BI.each(values, function (i, v) {
- if (!BI.has(t, v)) {
- t[v] = {};
- }
- t = t[v];
- });
- },
-
- _isMatch: function (value, keyword) {
- var finded = BI.Func.getSearchResult([value], keyword);
- return finded.finded.length > 0 || finded.matched.length > 0;
- },
-
- _getTreeNode: function (parentValues, v) {
- var self = this;
- var findedParentNode;
- var index = 0;
- this.tree.traverse(function (node) {
- if (self.tree.isRoot(node)) {
- return;
- }
- if (index > parentValues.length) {
- return false;
- }
- if (index === parentValues.length && node.value === v) {
- findedParentNode = node;
- return false;
- }
- if (node.value === parentValues[index]) {
- index++;
- return;
- }
- return true;
- });
- return findedParentNode;
- },
-
- _getChildren: function (parentValues) {
- if (parentValues.length > 0) {
- var value = BI.last(parentValues);
- var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value);
- } else {
- var parent = this.tree.getRoot();
- }
- return parent.getChildren();
- },
-
- _getChildCount: function (parentValues) {
- return this._getChildren(parentValues).length;
- }
-});/**
- * 简单的复选下拉树控件, 适用于数据量少的情况
- *
- * Created by GUY on 2015/10/29.
- * @class BI.TreeValueChooserCombo
- * @extends BI.Widget
- */
-BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-tree-value-chooser-combo",
- width: 200,
- height: 30,
- items: null,
- itemsCreator: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.TreeValueChooserCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
- this._initData(o.items);
- }
- this.combo = BI.createWidget({
- type: 'bi.multi_tree_combo',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- width: o.width,
- height: o.height
- });
-
- this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM);
- });
- },
-
- setValue: function (v) {
- this.combo.setValue(v);
- },
-
- getValue: function () {
- return this.combo.getValue();
- },
-
- populate: function () {
- this.combo.populate.apply(this.combo, arguments);
- }
-});
-BI.TreeValueChooserCombo.EVENT_CONFIRM = "TreeValueChooserCombo.EVENT_CONFIRM";
-BI.shortcut('bi.tree_value_chooser_combo', BI.TreeValueChooserCombo);/**
- * 简单的复选下拉树控件, 适用于数据量少的情况
- *
- * Created by GUY on 2015/10/29.
- * @class BI.TreeValueChooserPane
- * @extends BI.AbstractTreeValueChooser
- */
-BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-tree-value-chooser-pane",
- items: null,
- itemsCreator: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.TreeValueChooserPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.pane = BI.createWidget({
- type: 'bi.multi_select_tree',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this)
- });
-
- this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE);
- });
- if (BI.isNotNull(o.items)) {
- this._initData(o.items);
- this.populate();
- }
- },
-
- setSelectedValue: function (v) {
- this.pane.setSelectedValue(v);
- },
-
- setValue: function (v) {
- this.pane.setValue(v);
- },
-
- getValue: function () {
- return this.pane.getValue();
- },
-
- populate: function () {
- this.pane.populate.apply(this.pane, arguments);
- }
-});
-BI.TreeValueChooserPane.EVENT_CHANGE = "TreeValueChooserPane.EVENT_CHANGE";
-BI.shortcut('bi.tree_value_chooser_pane', BI.TreeValueChooserPane);/**
- * 简单的复选下拉框控件, 适用于数据量少的情况
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AbstractValueChooser
- * @extends BI.Widget
- */
-BI.AbstractValueChooser = BI.inherit(BI.Widget, {
-
- _const: {
- perPage: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), {
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _valueFormatter: function (v) {
- var text = v;
- if (BI.isNotNull(this.items)) {
- BI.some(this.items, function (i, item) {
- if (item.value === v) {
- text = item.text;
- return true;
- }
- });
- }
- return text;
- },
-
- _getItemsByTimes: function (items, times) {
- var res = [];
- for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
- res.push(items[i]);
- }
- return res;
- },
-
- _hasNextByTimes: function (items, times) {
- return times * this._const.perPage < items.length;
- },
-
- _itemsCreator: function (options, callback) {
- var self = this, o = this.options;
- if (!o.cache || !this.items) {
- o.itemsCreator({}, function (items) {
- self.items = items;
- call(items);
- });
- } else {
- call(this.items);
- }
- function call(items) {
- var keywords = (options.keywords || []).slice();
- if (options.keyword) {
- keywords.push(options.keyword);
- }
- BI.each(keywords, function (i, kw) {
- var search = BI.Func.getSearchResult(items, kw);
- items = search.matched.concat(search.finded);
- });
- if (options.selectedValues) {//过滤
- var filter = BI.makeObject(options.selectedValues, true);
- items = BI.filter(items, function (i, ob) {
- return !filter[ob.value];
- });
- }
- if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
- callback({
- items: items
- });
- return;
- }
- if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
- callback({count: items.length});
- return;
- }
- callback({
- items: self._getItemsByTimes(items, options.times),
- hasNext: self._hasNextByTimes(items, options.times)
- });
- }
- }
-});/**
- * 简单的复选下拉框控件, 适用于数据量少的情况
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.ValueChooserCombo
- * @extends BI.Widget
- */
-BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-value-chooser-combo",
- width: 200,
- height: 30,
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _init: function () {
- BI.ValueChooserCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
- this.items = o.items;
- }
- this.combo = BI.createWidget({
- type: 'bi.multi_select_combo',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
- width: o.width,
- height: o.height
- });
-
- this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM);
- });
- },
-
- setValue: function (v) {
- this.combo.setValue(v);
- },
-
- getValue: function () {
- var val = this.combo.getValue() || {};
- return {
- type: val.type,
- value: val.value
- }
- },
-
- populate: function () {
- this.combo.populate.apply(this, arguments);
- }
-});
-BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM";
-BI.shortcut('bi.value_chooser_combo', BI.ValueChooserCombo);/**
- * 简单的复选下拉框控件, 适用于数据量少的情况
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.ValueChooserPane
- * @extends BI.Widget
- */
-BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-value-chooser-pane",
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _init: function () {
- BI.ValueChooserPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.list = BI.createWidget({
- type: 'bi.multi_select_list',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this)
- });
-
- this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE);
- });
- if (BI.isNotNull(o.items)) {
- this.items = o.items;
- this.populate();
- }
- },
-
- setValue: function (v) {
- this.list.setValue(v);
- },
-
- getValue: function () {
- var val = this.list.getValue() || {};
- return {
- type: val.type,
- value: val.value
- }
- },
-
- populate: function () {
- this.list.populate.apply(this.list, arguments);
- }
-});
-BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
+/**
+ *
+ * Created by GUY on 2016/5/26.
+ * @class BI.SequenceTableTreeNumber
+ * @extends BI.Widget
+ */
+BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-sequence-table-tree-number",
+ isNeedFreeze: false,
+ startSequence: 1,//开始的序号
+ scrollTop: 0,
+ headerRowSize: 25,
+ rowSize: 25,
+
+ sequenceHeaderCreator: null,
+
+ header: [],
+ items: [], //二维数组
+
+ //交叉表头
+ crossHeader: [],
+ crossItems: []
+ });
+ },
+
+ _init: function () {
+ BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.vCurr = 1;
+ this.hCurr = 1;
+ this.tasks = [];
+ this.renderedCells = [];
+ this.renderedKeys = [];
+
+ this.container = BI.createWidget({
+ type: "bi.absolute",
+ width: 60,
+ scrollable: false
+ });
+
+ this.scrollContainer = BI.createWidget({
+ type: "bi.vertical",
+ scrollable: false,
+ scrolly: false,
+ items: [this.container]
+ });
+
+ this.headerContainer = BI.createWidget({
+ type: "bi.absolute",
+ cls: "bi-border",
+ width: 58,
+ scrollable: false
+ });
+
+ this.layout = BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.headerContainer,
+ height: this._getHeaderHeight() - 2
+ }, {el: {type: "bi.layout"}, height: 2}, {
+ el: this.scrollContainer
+ }]
+ });
+ //缓存第一行对应的序号
+ this.start = this.options.startSequence;
+ this.cache = {};
+ this._nextState();
+
+ this._populate();
+ },
+
+ _getNextSequence: function (nodes) {
+ var self = this;
+ var start = this.start;
+ var cnt = this.start;
+
+ function track(node) {
+ //如果已经有缓存了就不改计数了,复杂表会出现这种情况
+ self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt);
+ cnt++;
+ }
+
+ BI.each(nodes, function (i, node) {
+ if (BI.isNotEmptyArray(node.children)) {
+ BI.each(node.children, function (index, child) {
+ if (index === 0) {
+ if (self.cache[child.text || child.value]) {
+ start = cnt = self.cache[child.text || child.value];
+ }
+ }
+ track(child)
+ });
+ }
+ });
+ this.start = cnt;
+ return start;
+ },
+
+ _getStart: function (nodes) {
+ var self = this;
+ var start = this.start;
+ BI.some(nodes, function (i, node) {
+ if (BI.isNotEmptyArray(node.children)) {
+ return BI.some(node.children, function (index, child) {
+ if (index === 0) {
+ if (self.cache[child.text || child.value]) {
+ start = self.cache[child.text || child.value];
+ return true;
+ }
+ }
+ });
+ }
+ });
+ return start;
+ },
+
+ _formatNumber: function (nodes) {
+ var self = this, o = this.options;
+ var result = [];
+ var count = this._getStart(nodes);
+
+ function getLeafCount(node) {
+ var cnt = 0;
+ if (BI.isNotEmptyArray(node.children)) {
+ BI.each(node.children, function (index, child) {
+ cnt += getLeafCount(child);
+ });
+ if (/**node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) {
+ cnt++;
+ }
+ } else {
+ cnt++;
+ }
+ return cnt;
+ }
+
+ var start = 0, top = 0;
+ BI.each(nodes, function (i, node) {
+ if (BI.isArray(node.children)) {
+ BI.each(node.children, function (index, child) {
+ var cnt = getLeafCount(child);
+ result.push({
+ text: count++,
+ start: start,
+ top: top,
+ cnt: cnt,
+ index: index,
+ height: cnt * o.rowSize
+ });
+ start += cnt;
+ top += cnt * o.rowSize;
+ });
+ if (BI.isNotEmptyArray(node.values)) {
+ result.push({
+ text: BI.i18nText("BI-Summary_Values"),
+ start: start++,
+ top: top,
+ cnt: 1,
+ isSummary: true,
+ height: o.rowSize
+ });
+ top += o.rowSize;
+ }
+ }
+ });
+ return result;
+ },
+
+ _layout: function () {
+ var self = this, o = this.options;
+ var headerHeight = this._getHeaderHeight() - 2;
+ var items = this.layout.attr("items");
+ if (o.isNeedFreeze === false) {
+ items[0].height = 0;
+ items[1].height = 0;
+ } else if (o.isNeedFreeze === true) {
+ items[0].height = headerHeight;
+ items[1].height = 2;
+ }
+ this.layout.attr("items", items);
+ this.layout.resize();
+ try {
+ this.scrollContainer.element.scrollTop(o.scrollTop);
+ } catch (e) {
+
+ }
+ },
+
+ _getHeaderHeight: function () {
+ var o = this.options;
+ return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0));
+ },
+
+ _nextState: function () {
+ var o = this.options;
+ this._getNextSequence(o.items);
+ },
+
+ _prevState: function () {
+ var self = this, o = this.options;
+ var firstChild;
+ BI.some(o.items, function (i, node) {
+ if (BI.isNotEmptyArray(node.children)) {
+ return BI.some(node.children, function (j, child) {
+ firstChild = child;
+ return true;
+ });
+ }
+ });
+ if (firstChild && BI.isNotEmptyObject(this.cache)) {
+ this.start = this.cache[firstChild.text || firstChild.value];
+ } else {
+ this.start = 1;
+ }
+ this._nextState();
+ },
+
+ _getMaxScrollTop: function (numbers) {
+ var cnt = 0;
+ BI.each(numbers, function (i, number) {
+ cnt += number.cnt;
+ });
+ return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth());
+ },
+
+ _createHeader: function () {
+ var o = this.options;
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.headerContainer,
+ items: [{
+ el: o.sequenceHeaderCreator || {
+ type: "bi.table_style_cell",
+ cls: "sequence-table-title-cell",
+ styleGetter: o.headerCellStyleGetter,
+ text: BI.i18nText("BI-Number_Index")
+ },
+ left: 0,
+ top: 0,
+ right: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _calculateChildrenToRender: function () {
+ var self = this, o = this.options;
+
+ var renderedCells = [], renderedKeys = [];
+ var numbers = this._formatNumber(o.items);
+ var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0);
+ BI.each(numbers, function (i, number) {
+ intervalTree.set(i, number.height);
+ });
+ var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers));
+ var index = intervalTree.greatestLowerBound(scrollTop);
+ var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0));
+ var height = offsetTop;
+ var bodyHeight = o.height - this._getHeaderHeight();
+ while (height < bodyHeight && index < numbers.length) {
+ renderedKeys.push(index);
+ offsetTop += numbers[index].height;
+ height += numbers[index].height;
+ index++;
+ }
+
+ BI.each(renderedKeys, function (i, key) {
+ var index = BI.deepIndexOf(self.renderedKeys, key);
+ if (index > -1) {
+ if (numbers[key].height !== self.renderedCells[index]._height) {
+ self.renderedCells[index]._height = numbers[key].height;
+ self.renderedCells[index].el.setHeight(numbers[key].height);
+ }
+ if (numbers[key].top !== self.renderedCells[index].top) {
+ self.renderedCells[index].top = numbers[key].top;
+ self.renderedCells[index].el.element.css("top", numbers[key].top + "px");
+ }
+ renderedCells.push(self.renderedCells[index]);
+ } else {
+ var child = BI.createWidget(BI.extend({
+ type: "bi.table_style_cell",
+ cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",
+ width: 60,
+ styleGetter: numbers[key].isSummary === true ? function () {
+ return o.summaryCellStyleGetter(true);
+ } : function (key) {
+ return function () {
+ return o.sequenceCellStyleGetter(key);
+ }
+ }(numbers[key].index)
+ }, numbers[key]));
+ renderedCells.push({
+ el: child,
+ left: 0,
+ top: numbers[key].top,
+ _height: numbers[key].height
+ });
+ }
+ });
+
+ //已存在的, 需要添加的和需要删除的
+ var existSet = {}, addSet = {}, deleteArray = [];
+ BI.each(renderedKeys, function (i, key) {
+ if (BI.deepContains(self.renderedKeys, key)) {
+ existSet[i] = key;
+ } else {
+ addSet[i] = key;
+ }
+ });
+ BI.each(this.renderedKeys, function (i, key) {
+ if (BI.deepContains(existSet, key)) {
+ return;
+ }
+ if (BI.deepContains(addSet, key)) {
+ return;
+ }
+ deleteArray.push(i);
+ });
+ BI.each(deleteArray, function (i, index) {
+ self.renderedCells[index].el.destroy();
+ });
+ var addedItems = [];
+ BI.each(addSet, function (index) {
+ addedItems.push(renderedCells[index])
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: addedItems
+ });
+ this.renderedCells = renderedCells;
+ this.renderedKeys = renderedKeys;
+
+ this.container.setHeight(intervalTree.sumUntil(numbers.length));
+ },
+
+ _restore: function () {
+ BI.each(this.renderedCells, function (i, cell) {
+ cell.el.destroy();
+ });
+ this.renderedCells = [];
+ this.renderedKeys = [];
+ },
+
+ _populate: function () {
+ var self = this;
+ BI.each(this.tasks, function (i, task) {
+ task.apply(self);
+ });
+ this.tasks = [];
+ this.headerContainer.empty();
+ this._createHeader();
+ this._layout();
+ this._calculateChildrenToRender();
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ if (this.options.scrollTop !== scrollTop) {
+ this.options.scrollTop = scrollTop;
+ try {
+ this.scrollContainer.element.scrollTop(scrollTop);
+ } catch (e) {
+
+ }
+ }
+ },
+
+ getVerticalScroll: function () {
+ return this.options.scrollTop;
+ },
+
+ setVPage: function (v) {
+ if (v <= 1) {
+ this.cache = {};
+ this.start = this.options.startSequence;
+ this._restore();
+ this.tasks.push(this._nextState);
+ } else if (v === this.vCurr + 1) {
+ this.tasks.push(this._nextState);
+ } else if (v === this.vCurr - 1) {
+ this.tasks.push(this._prevState);
+ }
+ this.vCurr = v;
+ },
+
+ setHPage: function (v) {
+ if (v !== this.hCurr) {
+ this.tasks.push(this._prevState);
+ }
+ this.hCurr = v;
+ },
+
+ restore: function () {
+ this._restore();
+ },
+
+ populate: function (items, header, crossItems, crossHeader) {
+ var o = this.options;
+ if (items && items !== this.options.items) {
+ o.items = items;
+ this._restore();
+ this.tasks.push(this._prevState);
+ }
+ if (header && header !== this.options.header) {
+ o.header = header;
+ }
+ if (crossItems && crossItems !== this.options.crossItems) {
+ o.crossItems = crossItems;
+ }
+ if (crossHeader && crossHeader !== this.options.crossHeader) {
+ o.crossHeader = crossHeader;
+ }
+ this._populate();
+ }
+});
+BI.shortcut('bi.sequence_table_tree_number', BI.SequenceTableTreeNumber);/**
+ * 自适应布局
+ *
+ * 1、resize
+ * 2、吸附
+ * 3、当前组件在最上方
+ * 4、可以撤销
+ * 5、上下之间插入组件
+ *
+ * Created by GUY on 2016/2/23.
+ * @class BI.AdaptiveArrangement
+ * @extends BI.Widget
+ */
+BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-adaptive-arrangement",
+ resizable: true,
+ layoutType: BI.Arrangement.LAYOUT_TYPE.FREE,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.AdaptiveArrangement.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.arrangement = BI.createWidget({
+ type: "bi.arrangement",
+ element: this,
+ layoutType: o.layoutType,
+ items: o.items
+ });
+ this.arrangement.on(BI.Arrangement.EVENT_SCROLL, function () {
+ self.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL, arguments);
+ });
+ this.zIndex = 0;
+ BI.each(o.items, function (i, item) {
+ self._initResizable(item.el);
+ });
+
+ $(document).mousedown(function (e) {
+ BI.each(self.getAllRegions(), function (i, region) {
+ if (region.el.element.find(e.target).length === 0) {
+ region.el.element.removeClass("selected");
+ }
+ });
+ });
+ BI.ResizeDetector.addResizeListener(this, function () {
+ self.arrangement.resize();
+ self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
+ });
+ },
+
+ _isEqual: function () {
+ return this.arrangement._isEqual.apply(this.arrangement, arguments);
+ },
+
+ _setSelect: function (item) {
+ if (!item.element.hasClass("selected")) {
+ item.element.css("zIndex", ++this.zIndex);
+ BI.each(this.getAllRegions(), function (i, region) {
+ region.el.element.removeClass("selected");
+ });
+ item.element.addClass("selected");
+ }
+ },
+
+ _initResizable: function (item) {
+ var self = this, o = this.options;
+ item.element.css("zIndex", ++this.zIndex);
+ item.element.mousedown(function () {
+ self._setSelect(item)
+ });
+ // o.resizable && item.element.resizable({
+ // handles: "e, s, se",
+ // minWidth: 20,
+ // minHeight: 20,
+ // autoHide: true,
+ // helper: "bi-resizer",
+ // start: function () {
+ // item.element.css("zIndex", ++self.zIndex);
+ // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE);
+ // },
+ // resize: function (e, ui) {
+ // // self._resize(item.attr("id"), ui.size);
+ // self._resize(item.attr("id"), e, ui.size, ui.position);
+ // },
+ // stop: function (e, ui) {
+ // self._stopResize(item.attr("id"), ui.size);
+ // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size);
+ // self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
+ // }
+ // });
+ },
+
+ // _resize: function (name, e, size, position) {
+ // var self = this;
+ // this.scrollInterval(e, false, true, function (changedSize) {
+ // size.width += changedSize.offsetX;
+ // size.height += changedSize.offsetY;
+ // var containerWidth = self.arrangement.container.element.width();
+ // var containerHeight = self.arrangement.container.element.height();
+ // self.arrangement.container.element.width(containerWidth + changedSize.offsetX);
+ // self.arrangement.container.element.height(containerHeight + changedSize.offsetY);
+ // switch (self.getLayoutType()) {
+ // case BI.Arrangement.LAYOUT_TYPE.FREE:
+ // break;
+ // case BI.Arrangement.LAYOUT_TYPE.GRID:
+ // self.setRegionSize(name, size);
+ // break;
+ // }
+ // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size);
+ // });
+ // },
+ //
+ // _stopResize: function (name, size) {
+ // var self = this;
+ // this.scrollEnd();
+ // switch (this.getLayoutType()) {
+ // case BI.Arrangement.LAYOUT_TYPE.FREE:
+ // this.setRegionSize(name, size);
+ // break;
+ // case BI.Arrangement.LAYOUT_TYPE.GRID:
+ // this.setRegionSize(name, size);
+ // break;
+ // }
+ // },
+
+ _getScrollOffset: function () {
+ return this.arrangement._getScrollOffset();
+ },
+
+ getClientWidth: function () {
+ return this.arrangement.getClientWidth();
+ },
+
+ getClientHeight: function () {
+ return this.arrangement.getClientHeight();
+ },
+
+ addRegion: function (region, position) {
+ this._initResizable(region.el);
+ this._setSelect(region.el);
+ var self = this, flag;
+ var old = this.arrangement.getAllRegions();
+ if (flag = this.arrangement.addRegion(region, position)) {
+ this._old = old;
+ }
+ return flag;
+ },
+
+ deleteRegion: function (name) {
+ var flag;
+ var old = this.getAllRegions();
+ if (flag = this.arrangement.deleteRegion(name)) {
+ this._old = old;
+ } else {
+ this._old = this.getAllRegions();
+ this.relayout();
+ }
+ return flag;
+ },
+
+ setRegionSize: function (name, size) {
+ var flag;
+ var old = this.getAllRegions();
+ if (flag = this.arrangement.setRegionSize(name, size)) {
+ this._old = old;
+ }
+ return flag;
+ },
+
+ setPosition: function (position, size) {
+ var self = this;
+ return this.arrangement.setPosition(position, size);
+ },
+
+ setRegionPosition: function (name, position) {
+ var region = this.getRegionByName(name);
+ return this.arrangement.setRegionPosition(name, position);
+ },
+
+ setDropPosition: function (position, size) {
+ return this.arrangement.setDropPosition(position, size);
+ },
+
+ scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
+ var self = this;
+ var map = {
+ top: [-1, 0],
+ bottom: [1, 0],
+ left: [0, -1],
+ right: [0, 1]
+ };
+ var clientSize = this.element.bounds();
+
+ function scrollTo(direction, callback) {
+ if (direction === "") {
+ self.lastActiveRegion = "";
+ if (self._scrollInterval) {
+ clearInterval(self._scrollInterval);
+ self._scrollInterval = null;
+ }
+ return;
+ }
+ if (self.lastActiveRegion !== direction) {
+ self.lastActiveRegion = direction;
+ if (self._scrollInterval) {
+ clearInterval(self._scrollInterval);
+ self._scrollInterval = null;
+ }
+ self._scrollInterval = setInterval(function () {
+ var offset = self._getScrollOffset();
+ var t = offset.top + map[direction][0] * 40;
+ var l = offset.left + map[direction][1] * 40;
+ if (t < 0 || l < 0) {
+ return;
+ }
+ callback({
+ offsetX: map[direction][1] * 40,
+ offsetY: map[direction][0] * 40
+ });
+ self.scrollTo({
+ top: t,
+ left: l
+ });
+ }, 300);
+ }
+ }
+
+ cb({
+ offsetX: 0,
+ offsetY: 0
+ });
+ var offset = this.element.offset();
+ var p = {
+ left: e.pageX - offset.left,
+ top: e.pageY - offset.top
+ };
+ //向上滚
+ if (isBorderScroll && p.top >= 0 && p.top <= 30) {
+ scrollTo("top", cb)
+ }
+ //向下滚
+ else if (isBorderScroll && p.top >= clientSize.height - 30 && p.top <= clientSize.height) {
+ scrollTo("bottom", cb)
+ }
+ //向左滚
+ else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
+ scrollTo("left", cb)
+ }
+ //向右滚
+ else if (isBorderScroll && p.left >= clientSize.width - 30 && p.left <= clientSize.width) {
+ scrollTo("right", cb)
+ } else {
+ if (isOverflowScroll === true) {
+ if (p.top < 0) {
+ scrollTo("top", cb);
+ }
+ else if (p.top > clientSize.height) {
+ scrollTo("bottom", cb);
+ }
+ else if (p.left < 0) {
+ scrollTo("left", cb);
+ }
+ else if (p.left > clientSize.width) {
+ scrollTo("right", cb);
+ } else {
+ scrollTo("", cb);
+ }
+ } else {
+ scrollTo("", cb);
+ }
+ }
+ },
+
+ scrollEnd: function () {
+ this.lastActiveRegion = "";
+ if (this._scrollInterval) {
+ clearInterval(this._scrollInterval);
+ this._scrollInterval = null;
+ }
+ },
+
+ scrollTo: function (scroll) {
+ this.arrangement.scrollTo(scroll);
+ },
+
+ zoom: function (ratio) {
+ this.arrangement.zoom(ratio);
+ },
+
+ resize: function () {
+ this.arrangement.resize();
+ },
+
+ relayout: function () {
+ return this.arrangement.relayout();
+ },
+
+ setLayoutType: function (type) {
+ var self = this;
+ this.arrangement.setLayoutType(type);
+ },
+
+ getLayoutType: function () {
+ return this.arrangement.getLayoutType();
+ },
+
+ getLayoutRatio: function () {
+ return this.arrangement.getLayoutRatio();
+ },
+
+ getHelper: function () {
+ return this.arrangement.getHelper();
+ },
+
+ getRegionByName: function (name) {
+ return this.arrangement.getRegionByName(name);
+ },
+
+ getAllRegions: function () {
+ return this.arrangement.getAllRegions();
+ },
+
+ revoke: function () {
+ if (this._old) {
+ this.populate(BI.toArray(this._old));
+ }
+ },
+
+ populate: function (items) {
+ var self = this;
+ BI.each(items, function (i, item) {
+ self._initResizable(item.el);
+ });
+ this.arrangement.populate(items);
+ }
+});
+BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE";
+BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_RESIZE";
+BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE";
+BI.AdaptiveArrangement.EVENT_RESIZE = "AdaptiveArrangement.EVENT_RESIZE";
+BI.AdaptiveArrangement.EVENT_SCROLL = "AdaptiveArrangement.EVENT_SCROLL";
+BI.shortcut('bi.adaptive_arrangement', BI.AdaptiveArrangement);/**
+ * Arrangement的block面板
+ *
+ * Created by GUY on 2016/3/1.
+ * @class BI.ArrangementBlock
+ * @extends BI.Widget
+ */
+BI.ArrangementBlock = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-arrangement-block bi-mask"
+ });
+ }
+});
+BI.shortcut('bi.arrangement_block', BI.ArrangementBlock);/**
+ * Arrangement的drop面板
+ *
+ * Created by GUY on 2016/3/1.
+ * @class BI.ArrangementDroppable
+ * @extends BI.Widget
+ */
+BI.ArrangementDroppable = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-arrangement-droppable bi-resizer"
+ });
+ }
+});
+BI.shortcut('bi.arrangement_droppable', BI.ArrangementDroppable);/**
+ * 布局
+ *
+ * Created by GUY on 2016/2/23.
+ * @class BI.Arrangement
+ * @extends BI.Widget
+ */
+BI.Arrangement = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-arrangement",
+ layoutType: BI.Arrangement.LAYOUT_TYPE.GRID,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.Arrangement.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.arrangement = BI.createWidget({
+ type: "bi.arrangement_droppable",
+ cls: "arrangement-block",
+ invisible: true
+ });
+ this.block = BI.createWidget({
+ type: "bi.arrangement_block",
+ invisible: true
+ });
+ this.container = BI.createWidget({
+ type: "bi.absolute",
+ items: o.items.concat([this.block, this.arrangement])
+ });
+
+ this.scrollContainer = BI.createWidget({
+ type: "bi.adaptive",
+ width: "100%",
+ height: "100%",
+ scrollable: true,
+ items: [this.container]
+ });
+ this.scrollContainer.element.scroll(function () {
+ self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
+ scrollLeft: self.scrollContainer.element.scrollLeft(),
+ scrollTop: self.scrollContainer.element.scrollTop(),
+ clientWidth: self.scrollContainer.element[0].clientWidth,
+ clientHeight: self.scrollContainer.element[0].clientHeight
+ });
+ });
+
+ BI.createWidget({
+ type: "bi.adaptive",
+ element: this,
+ items: [this.scrollContainer]
+ });
+ this.regions = {};
+ if (o.items.length > 0) {
+ BI.nextTick(function () {
+ self.populate(o.items);
+ });
+ }
+ },
+
+ ////初始化操作////
+ _calculateRegions: function (items) {
+ var self = this, o = this.options;
+ this.regions = {};
+ BI.each(items, function (i, item) {
+ var region = self._createOneRegion(item);
+ self.regions[region.id] = region;
+ });
+ },
+
+ _isEqual: function (num1, num2) {
+ return Math.abs(num1 - num2) < 2;
+ },
+
+ _isLessThan: function (num1, num2) {
+ return num1 < num2 && !this._isEqual(num1, num2);
+ },
+
+ _isMoreThan: function (num1, num2) {
+ return num1 > num2 && !this._isEqual(num1, num2);
+ },
+
+ _isLessThanEqual: function (num1, num2) {
+ return num1 <= num2 || this._isEqual(num1, num2);
+ },
+
+ _isMoreThanEqual: function (num1, num2) {
+ return num1 >= num2 || this._isEqual(num1, num2);
+ },
+
+ //获取占有的最大Region
+ _getRegionOccupied: function (regions) {
+ var self = this, o = this.options;
+ if (BI.size(regions || this.regions) <= 0) {
+ return {
+ left: 0,
+ top: 0,
+ width: 0,
+ height: 0
+ }
+ }
+ var minLeft = BI.MAX, maxLeft = BI.MIN, minTop = BI.MAX, maxTop = BI.MIN;
+ BI.each(regions || this.regions, function (id, region) {
+ minLeft = Math.min(minLeft, region.left);
+ maxLeft = Math.max(maxLeft, region.left + region.width);
+ minTop = Math.min(minTop, region.top);
+ maxTop = Math.max(maxTop, region.top + region.height);
+ });
+ return {
+ left: minLeft,
+ top: minTop,
+ width: maxLeft - minLeft,
+ height: maxTop - minTop
+ }
+ },
+
+ //两个区域的交叉面积
+ _getCrossArea: function (region1, region2) {
+ if (region1.left <= region2.left) {
+ if (region1.top <= region2.top) {
+ if (region1.top + region1.height > region2.top && region1.left + region1.width > region2.left) {
+ if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region1.left + region1.width, region2.left)) {
+ return 0;
+ }
+ return (region1.top + region1.height - region2.top) * (region1.left + region1.width - region2.left);
+ }
+ } else {
+ if (region2.top + region2.height > region1.top && region1.left + region1.width > region2.left) {
+ if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region1.left + region1.width, region2.left)) {
+ return 0;
+ }
+ return (region2.top + region2.height - region1.top) * (region1.left + region1.width - region2.left);
+ }
+ }
+ } else {
+ if (region1.top <= region2.top) {
+ if (region1.top + region1.height > region2.top && region2.left + region2.width > region1.left) {
+ if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region2.left + region2.width, region1.left)) {
+ return 0;
+ }
+ return (region1.top + region1.height - region2.top) * (region2.left + region2.width - region1.left);
+ }
+ } else {
+ if (region2.top + region2.height > region1.top && region2.left + region2.width > region1.left) {
+ if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region2.left + region2.width, region1.left)) {
+ return 0;
+ }
+ return (region2.top + region2.height - region1.top) * (region2.left + region2.width - region1.left);
+ }
+ }
+ }
+ return 0;
+ },
+
+ //是否有覆盖的组件
+ _isRegionOverlay: function (regions) {
+ var reg = [];
+ BI.each(regions || this.regions, function (id, region) {
+ reg.push(new BI.Region(region.left, region.top, region.width, region.height));
+ });
+ for (var i = 0, len = reg.length; i < len; i++) {
+ for (var j = i + 1; j < len; j++) {
+ var area1 = {
+ left: reg[i].x,
+ top: reg[i].y,
+ width: reg[i].w,
+ height: reg[i].h
+ };
+ var area2 = {
+ left: reg[j].x,
+ top: reg[j].y,
+ width: reg[j].w,
+ height: reg[j].h
+ };
+ if (reg[i].isIntersects(reg[j]) && this._getCrossArea(area1, area2) > 1) {
+ return true;
+ }
+ }
+ }
+ return false;
+ },
+
+ //布局是否是优良的
+ _isArrangeFine: function (regions) {
+ switch (this.options.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ return true;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ // if (this._isRegionOverlay()) {
+ // return false;
+ // }
+ }
+ return true;
+ },
+
+ _getRegionNames: function (regions) {
+ var names = [];
+ BI.each(regions || this.regions, function (i, region) {
+ names.push(region.id || region.attr("id"));
+ });
+ return names;
+ },
+
+ _getRegionsByNames: function (names, regions) {
+ names = BI.isArray(names) ? names : [names];
+ regions = regions || this.regions;
+ if (BI.isArray(regions)) {
+ var result = [];
+ BI.each(regions, function (i, region) {
+ if (names.contains(region.id || region.attr("id"))) {
+ result.push(region);
+ }
+ });
+ } else {
+ var result = {};
+ BI.each(names, function (i, name) {
+ result[name] = regions[name];
+ });
+ }
+ return result;
+ },
+
+ _cloneRegion: function (regions) {
+ var clone = {};
+ BI.each(regions || this.regions, function (id, region) {
+ clone[id] = {};
+ clone[id].el = region.el;
+ clone[id].id = region.id;
+ clone[id].left = region.left;
+ clone[id].top = region.top;
+ clone[id].width = region.width;
+ clone[id].height = region.height;
+ });
+ return clone;
+ },
+
+ //测试合法性
+ _test: function (regions) {
+ var self = this;
+ return !BI.any(regions || this.regions, function (i, region) {
+ if (BI.isNaN(region.width) || BI.isNaN(region.height) || region.width <= 21 || region.height <= 21) {
+ return true;
+ }
+ })
+ },
+
+ _getScrollOffset: function () {
+ return {
+ left: this.scrollContainer.element[0].scrollLeft,
+ top: this.scrollContainer.element[0].scrollTop
+ }
+ },
+
+ ////操作////
+ _createOneRegion: function (item) {
+ var el = BI.createWidget(item.el);
+ el.setVisible(true);
+ return {
+ id: el.attr("id"),
+ left: item.left,
+ top: item.top,
+ width: item.width,
+ height: item.height,
+ el: el
+ }
+ },
+
+ _applyRegion: function (regions) {
+ var self = this, o = this.options;
+ BI.each(regions || this.regions, function (i, region) {
+ region.el.element.css({
+ left: region.left,
+ top: region.top,
+ width: region.width,
+ height: region.height
+ });
+ });
+ this._applyContainer();
+ this.ratio = this.getLayoutRatio();
+ },
+
+ _renderRegion: function () {
+ var self = this;
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: BI.toArray(this.regions)
+ });
+ },
+
+ getClientWidth: function () {
+ return this.scrollContainer.element[0].clientWidth;
+ },
+
+ getClientHeight: function () {
+ return this.scrollContainer.element[0].clientHeight;
+ },
+
+ _applyContainer: function () {
+ //先掩藏后显示能够明确滚动条是否出现
+ this.scrollContainer.element.css("overflow", "hidden");
+ var occupied = this._getRegionOccupied();
+ this.container.element.width(occupied.left + occupied.width).height(occupied.top + occupied.height);
+ this.scrollContainer.element.css("overflow", "auto");
+ return occupied;
+ },
+
+ _modifyRegion: function (regions) {
+ BI.each(this.regions, function (id, region) {
+ if (regions[id]) {
+ region.left = regions[id].left;
+ region.top = regions[id].top;
+ region.width = regions[id].width;
+ region.height = regions[id].height;
+ }
+ });
+ },
+
+ _addRegion: function (item) {
+ var region = this._createOneRegion(item);
+ this.regions[region.id] = region;
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: [region]
+ });
+ },
+
+ _deleteRegionByName: function (name) {
+ this.regions[name].el.setVisible(false);
+ delete this.regions[name];
+ },
+
+ _setArrangeSize: function (size) {
+ this.arrangement.element.css({
+ left: size.left,
+ top: size.top,
+ width: size.width,
+ height: size.height
+ })
+ },
+
+ //Grid
+ _getOneWidthPortion: function () {
+ return this.getClientWidth() / BI.Arrangement.PORTION;
+ },
+ _getOneHeightPortion: function () {
+ return this.getClientHeight() / BI.Arrangement.H_PORTION;
+ },
+
+ _getGridPositionAndSize: function (position) {
+ var perWidth = this._getOneWidthPortion();
+ var perHeight = this._getOneHeightPortion();
+ var widthPortion = Math.round(position.width / perWidth);
+ var leftPortion = Math.round(position.left / perWidth);
+ var topPortion = Math.round(position.top / perHeight);
+ var heightPortion = Math.round(position.height / perHeight);
+ // if (leftPortion > BI.Arrangement.PORTION) {
+ // leftPortion = BI.Arrangement.PORTION;
+ // }
+ // if (widthPortion > BI.Arrangement.PORTION) {
+ // widthPortion = BI.Arrangement.PORTION;
+ // }
+ // if (leftPortion + widthPortion > BI.Arrangement.PORTION) {
+ // leftPortion = BI.Arrangement.PORTION - widthPortion;
+ // }
+ if (widthPortion === 0) {
+ widthPortion = 1;
+ }
+ if (heightPortion === 0) {
+ heightPortion = 1;
+ }
+ return {
+ x: leftPortion,
+ y: topPortion,
+ w: widthPortion,
+ h: heightPortion
+ }
+ },
+
+ _getBlockPositionAndSize: function (position) {
+ var perWidth = this._getOneWidthPortion();
+ var perHeight = this._getOneHeightPortion();
+ return {
+ left: position.x * perWidth,
+ top: position.y * perHeight,
+ width: position.w * perWidth,
+ height: position.h * perHeight
+ };
+ },
+
+ _getLayoutsByRegions: function (regions) {
+ var self = this;
+ var result = [];
+ BI.each(regions || this.regions, function (id, region) {
+ result.push(BI.extend(self._getGridPositionAndSize(region), {
+ i: region.id
+ }))
+ });
+ return result;
+ },
+
+ _getLayoutIndexByName: function (layout, name) {
+ return BI.findIndex(layout, function (i, l) {
+ return l.i === name;
+ });
+ },
+
+ _setBlockPositionAndSize: function (size) {
+ this.block.element.css({
+ left: size.left,
+ top: size.top,
+ width: size.width,
+ height: size.height
+ });
+ },
+
+ _getRegionsByLayout: function (layout) {
+ var self = this;
+ var regions = {};
+ BI.each(layout, function (i, ly) {
+ regions[ly.i] = BI.extend(self._getBlockPositionAndSize(ly), {
+ id: ly.i
+ });
+ });
+ return regions;
+ },
+
+ _setRegionsByLayout: function (regions, layout) {
+ var self = this;
+ regions || (regions = this.regions);
+ BI.each(layout, function (i, ly) {
+ if (regions[ly.i]) {
+ BI.extend(regions[ly.i], self._getBlockPositionAndSize(ly));
+ }
+ });
+ return regions;
+ },
+
+ _moveElement: function (layout, l, x, y, isUserAction) {
+ var self = this;
+ if (l._static) {
+ return layout;
+ }
+
+ if (l.y === y && l.x === x) {
+ return layout;
+ }
+
+ var movingUp = y && l.y > y;
+ if (typeof x === 'number') {
+ l.x = x;
+ }
+ if (typeof y === 'number') {
+ l.y = y;
+ }
+ l.moved = true;
+
+ var sorted = this._sortLayoutItemsByRowCol(layout);
+ if (movingUp) {
+ sorted = sorted.reverse();
+ }
+ var collisions = getAllCollisions(sorted, l);
+
+ for (var i = 0, len = collisions.length; i < len; i++) {
+ var collision = collisions[i];
+ if (collision.moved) {
+ continue;
+ }
+
+ if (l.y > collision.y && l.y - collision.y > collision.h / 4) {
+ continue;
+ }
+
+ if (collision._static) {
+ layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction);
+ } else {
+ layout = this._moveElementAwayFromCollision(layout, l, collision, isUserAction);
+ }
+ }
+
+ return layout;
+
+ function getAllCollisions(layout, layoutItem) {
+ return BI.filter(layout, function (i, l) {
+ return self._collides(l, layoutItem);
+ });
+ }
+ },
+
+ _sortLayoutItemsByRowCol: function (layout) {
+ return [].concat(layout).sort(function (a, b) {
+ if (a.y > b.y || (a.y === b.y && a.x > b.x)) {
+ return 1;
+ }
+ return -1;
+ });
+ },
+
+ _collides: function (l1, l2) {
+ if (l1 === l2) {
+ return false;
+ } // same element
+ if (l1.x + l1.w <= l2.x) {
+ return false;
+ } // l1 is left of l2
+ if (l1.x >= l2.x + l2.w) {
+ return false;
+ } // l1 is right of l2
+ if (l1.y + l1.h <= l2.y) {
+ return false;
+ } // l1 is above l2
+ if (l1.y >= l2.y + l2.h) {
+ return false;
+ } // l1 is below l2
+ return true; // boxes overlap
+ },
+
+ _getFirstCollision: function (layout, layoutItem) {
+ for (var i = 0, len = layout.length; i < len; i++) {
+ if (this._collides(layout[i], layoutItem)) {
+ return layout[i];
+ }
+ }
+ },
+
+ _moveElementAwayFromCollision: function (layout, collidesWith,
+ itemToMove, isUserAction) {
+ if (isUserAction) {
+ var fakeItem = {
+ x: itemToMove.x,
+ y: itemToMove.y,
+ w: itemToMove.w,
+ h: itemToMove.h,
+ i: '-1'
+ };
+ fakeItem.y = Math.max(collidesWith.y - itemToMove.h, 0);
+ if (!this._getFirstCollision(layout, fakeItem)) {
+ return this._moveElement(layout, itemToMove, undefined, fakeItem.y);
+ }
+ }
+
+ return this._moveElement(layout, itemToMove, undefined, itemToMove.y + 1);
+ },
+
+ _compactItem: function (compareWith, l, verticalCompact) {
+ if (verticalCompact) {
+ while (l.y > 0 && !this._getFirstCollision(compareWith, l)) {
+ l.y--;
+ }
+ }
+
+ var collides;
+ while ((collides = this._getFirstCollision(compareWith, l))) {
+ l.y = collides.y + collides.h;
+ }
+ return l;
+ },
+
+ compact: function (layout, verticalCompact) {
+ var compareWith = getStatics(layout);
+ var sorted = this._sortLayoutItemsByRowCol(layout);
+ var out = [];
+
+ for (var i = 0, len = sorted.length; i < len; i++) {
+ var l = sorted[i];
+
+ if (!l._static) {
+ l = this._compactItem(compareWith, l, verticalCompact);
+
+ compareWith.push(l);
+ }
+
+ out[layout.indexOf(l)] = l;
+
+ l.moved = false;
+ }
+
+ return out;
+ function getStatics(layout) {
+ return BI.filter(layout, function (i, l) {
+ return l._static;
+ });
+ }
+ },
+
+ ////公有方法////
+ getRegionByName: function (name) {
+ var obj = {};
+ obj[name] = this.regions[name];
+ return this._cloneRegion(obj)[name];
+ },
+
+ getAllRegions: function () {
+ return BI.toArray(this._cloneRegion());
+ },
+
+ getHelper: function () {
+ var helper = BI.createWidget({
+ type: "bi.layout",
+ width: 18,
+ height: 18,
+ cls: "arrangement-helper bi-border"
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [helper]
+ });
+ return helper;
+ },
+
+ _start: function () {
+ if (this.options.layoutType === BI.Arrangement.LAYOUT_TYPE.GRID) {
+ this.block.setVisible(true);
+ } else {
+ this.arrangement.setVisible(true);
+ }
+ },
+
+ _stop: function () {
+ this.arrangement.setVisible(false);
+ this.block.setVisible(false);
+ },
+
+ ////公有操作////
+ setLayoutType: function (type) {
+ var self = this, o = this.options;
+ if (type !== o.layoutType) {
+ o.layoutType = type;
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ this.relayout();
+ break;
+ }
+ }
+ },
+
+ getLayoutType: function () {
+ return this.options.layoutType;
+ },
+
+ getLayoutRatio: function () {
+ var occupied = this._getRegionOccupied();
+ var width = this.getClientWidth(), height = this.getClientHeight();
+ return {
+ x: BI.parseFloat(BI.contentFormat((occupied.left + occupied.width) / width, "#.##;-#.##")),
+ y: BI.parseFloat(BI.contentFormat((occupied.top + occupied.height) / height, "#.##;-#.##"))
+ }
+ },
+
+ addRegion: function (region, position) {
+ if (position) {
+ this.setPosition(position, region);
+ }
+ var self = this, o = this.options;
+ if (!this.position) {
+ return false;
+ }
+ var test = this._cloneRegion();
+ BI.each(this.position.regions, function (i, region) {
+ test[region.id].left = region.left;
+ test[region.id].top = region.top;
+ test[region.id].width = region.width;
+ test[region.id].height = region.height;
+
+ });
+ var item = BI.extend({}, region, {
+ left: this.position.insert.left,
+ top: this.position.insert.top,
+ width: this.position.insert.width,
+ height: this.position.insert.height
+ });
+ var added = this._createOneRegion(item);
+ test[added.id] = added;
+ if (this._test(test)) {
+ delete test[added.id];
+ this._modifyRegion(test);
+ this._addRegion(item);
+ this._populate(this.getAllRegions());
+ return true;
+ }
+ return false;
+ },
+
+ deleteRegion: function (name) {
+ if (!this.regions[name]) {
+ return false;
+ }
+ var self = this, o = this.options;
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ this._deleteRegionByName(name);
+ this._populate(this.getAllRegions());
+ return true;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ this._deleteRegionByName(name);
+ this._populate(this.getAllRegions());
+ this.resize();
+ return true;
+ }
+ return false;
+ },
+
+ setRegionSize: function (name, size) {
+ var self = this, o = this.options;
+ var flag = false;
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ var clone = this._cloneRegion();
+ BI.extend(clone[name], {
+ width: size.width,
+ height: size.height
+ });
+ if (this._test(clone)) {
+ this._modifyRegion(clone);
+ flag = true;
+ }
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ var clone = this._cloneRegion();
+ BI.extend(clone[name], {
+ width: size.width,
+ height: size.height
+ });
+ if (this._test(clone)) {
+ var layout = this._getLayoutsByRegions(clone);
+ layout = this.compact(layout, true);
+ var regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ flag = true;
+ }
+ break;
+ }
+ this._applyRegion();
+ return flag;
+ },
+
+ setPosition: function (position, size) {
+ var self = this, o = this.options;
+ var insert, regions = [], cur;
+ if (position.left < 0 || position.top < 0) {
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ this.resize();
+ break;
+ }
+ this._stop();
+ this.position = null;
+ return null;
+ }
+ var offset = this._getScrollOffset();
+ position = {
+ left: position.left + offset.left,
+ top: position.top + offset.top
+ };
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ var insert = {
+ top: position.top < 0 ? 0 : position.top,
+ left: position.left < 0 ? 0 : position.left,
+ width: size.width,
+ height: size.height
+ };
+ this.position = {
+ insert: insert
+ };
+ this._setArrangeSize(insert);
+ this._start();
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ var p = {
+ top: position.top < 0 ? 0 : position.top,
+ left: position.left < 0 ? 0 : position.left,
+ width: size.width,
+ height: size.height
+ };
+ this._setArrangeSize(p);
+ var cur = this._getGridPositionAndSize(p);
+ var layout = [{
+ x: 0, y: BI.MAX, w: cur.w, h: cur.h, i: cur.i
+ }].concat(this._getLayoutsByRegions());
+ layout = this._moveElement(layout, layout[0], cur.x, cur.y, true);
+ layout = this.compact(layout, true);
+ var regions = this._setRegionsByLayout(this._cloneRegion(), layout);
+ var insert = this._getBlockPositionAndSize(layout[0]);
+ this.position = {
+ insert: insert,
+ regions: regions
+ };
+ this._applyRegion(regions);
+ this._setBlockPositionAndSize(insert);
+ this._start();
+ break;
+ }
+ return this.position;
+ },
+
+ setRegionPosition: function (name, position) {
+ var self = this, o = this.options;
+ var offset = this._getScrollOffset();
+ position = BI.extend(position, {
+ left: position.left + offset.left,
+ top: position.top + offset.top
+ });
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ BI.extend(this.regions[name], {
+ left: position.left < 0 ? 0 : position.left,
+ top: position.top < 0 ? 0 : position.top
+ });
+ this._applyRegion();
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ if (!position.stop) {
+ BI.extend(this.regions[name], {
+ left: position.left < 0 ? 0 : position.left,
+ top: position.top < 0 ? 0 : position.top
+ });
+ var cloned = this._cloneRegion();
+ var cur = this._getGridPositionAndSize(BI.extend(cloned[name], {
+ left: position.left < 0 ? 0 : position.left,
+ top: position.top < 0 ? 0 : position.top
+ }));
+ var x = cur.x, y = cur.y;
+ cur = BI.extend(cur, {
+ x: 0, y: BI.MAX, i: -1
+ });
+ delete cloned[name];
+ var layout = this._getLayoutsByRegions(cloned);
+ layout = this._moveElement([cur].concat(layout), cur, x, y, true);
+ layout = this.compact(layout, true);
+ var regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ this._applyRegion();
+
+ this._setBlockPositionAndSize(this._getBlockPositionAndSize(cur));
+ this.block.setVisible(true);
+ } else {
+ BI.extend(this.regions[name], {
+ left: position.left < 0 ? 0 : position.left,
+ top: position.top < 0 ? 0 : position.top
+ });
+ var cloned = this._cloneRegion();
+ var layout = this._getLayoutsByRegions(cloned);
+ layout = this.compact(layout, true);
+ var regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ this._applyRegion();
+ this.block.setVisible(false);
+ }
+ break;
+ }
+ },
+
+ setDropPosition: function (position, size) {
+ var self = this;
+ this.arrangement.setVisible(true);
+ var offset = this._getScrollOffset();
+ this._setArrangeSize(BI.extend({}, size, {
+ left: position.left + offset.left,
+ top: position.top + offset.top
+ }));
+ return function () {
+ self.arrangement.setVisible(false);
+ }
+ },
+
+ scrollTo: function (scroll) {
+ this.scrollContainer.element.scrollTop(scroll.top);
+ this.scrollContainer.element.scrollLeft(scroll.left);
+ },
+
+ zoom: function (ratio) {
+ var self = this, o = this.options;
+ if (!ratio) {
+ return;
+ }
+ var occupied = this._applyContainer();
+ switch (this.getLayoutType()) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ if (this._isArrangeFine()) {
+ var width = this.getClientWidth();
+ var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width);
+ //var yRatio = ratio.y * height / (occupied.top + occupied.height);
+ var regions = this._cloneRegion();
+ BI.each(regions, function (i, region) {
+ region.left = region.left * xRatio;
+ //region.top = region.top * yRatio;
+ region.width = region.width * xRatio;
+ //region.height = region.height * yRatio;
+ });
+ if (this._test(regions)) {
+ this._modifyRegion(regions);
+ this._applyRegion();
+ }
+ this.resize();
+ // } else {
+ this.relayout();
+ }
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ if (this._isArrangeFine()) {
+ var width = this.getClientWidth(), height = this.getClientHeight();
+ var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width);
+ var yRatio = (ratio.y || 1) * height / (occupied.top + occupied.height);
+ var regions = this._cloneRegion();
+ BI.each(regions, function (i, region) {
+ region.left = region.left * xRatio;
+ region.width = region.width * xRatio;
+ region.top = region.top * yRatio;
+ region.height = region.height * yRatio;
+ //做一下自适应布局到网格布局的兼容
+ var perWidth = self._getOneWidthPortion();
+ var widthPortion = Math.round(region.width / perWidth);
+ var leftPortion = Math.round(region.left / perWidth);
+ var comparePortion = Math.round((region.width + region.left) / perWidth);
+ if (leftPortion + widthPortion !== comparePortion) {
+ region.left = leftPortion * perWidth;
+ region.width = comparePortion * perWidth - region.left;
+ }
+ });
+ if (this._test(regions)) {
+ var layout = this._getLayoutsByRegions(regions);
+ layout = this.compact(layout, true);
+ regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ this._applyRegion();
+ }
+ } else {
+ this.relayout();
+ }
+ break;
+ }
+ },
+
+ resize: function () {
+ var self = this, o = this.options;
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ this.zoom(this.ratio);
+ var regions = this._cloneRegion();
+ var layout = this._getLayoutsByRegions(regions);
+ layout = this.compact(layout, true);
+ regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ this._applyRegion();
+ break;
+ }
+ },
+
+ relayout: function () {
+ var self = this, o = this.options;
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ if (!this._isArrangeFine()) {
+ var perHeight = this._getOneHeightPortion();
+ var width = this.getClientWidth(), height = this.getClientHeight();
+ var regions = this._cloneRegion();
+ var clone = BI.toArray(regions);
+ clone.sort(function (r1, r2) {
+ if (self._isEqual(r1.top, r2.top)) {
+ return r1.left - r2.left;
+ }
+ return r1.top - r2.top;
+ });
+ var count = clone.length;
+ var cols = 4, rows = Math.floor((count - 1) / 4 + 1);
+ var w = width / cols, h = height / rows;
+ var store = {};
+ BI.each(clone, function (i, region) {
+ var row = Math.floor(i / 4), col = i % 4;
+ BI.extend(region, {
+ top: row * perHeight * 6,
+ left: col * w,
+ width: w,
+ height: perHeight * 6
+ });
+ if (!store[row]) {
+ store[row] = {};
+ }
+ store[row][col] = region;
+ });
+ //非4的倍数
+ // if (count % 4 !== 0) {
+ // var lasts = store[rows - 1];
+ // var perWidth = width / (count % 4);
+ // BI.each(lasts, function (i, region) {
+ // BI.extend(region, {
+ // left: BI.parseInt(i) * perWidth,
+ // width: perWidth
+ // });
+ // });
+ // }
+ if (this._test(clone)) {
+ var layout = this._getLayoutsByRegions(regions);
+ layout = this.compact(layout, true);
+ regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ this._populate(clone);
+ }
+ } else {
+ this.resize();
+ }
+ break;
+ }
+ },
+
+ _populate: function (items) {
+ this._stop();
+ this._calculateRegions(items);
+ this._applyRegion();
+ },
+
+ populate: function (items) {
+ var self = this;
+ BI.each(this.regions, function (name, region) {
+ self.regions[name].el.setVisible(false);
+ delete self.regions[name];
+ });
+ this._populate(items);
+ this._renderRegion();
+ }
+});
+BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL";
+BI.extend(BI.Arrangement, {
+ PORTION: 36,
+ H_PORTION: 18,
+ LAYOUT_TYPE: {
+ GRID: 0,
+ FREE: 1
+ }
+});
+BI.shortcut('bi.arrangement', BI.Arrangement);/**
+ * 表关联树
+ *
+ * Created by GUY on 2015/12/15.
+ * @class BI.BranchRelation
+ * @extends BI.Widget
+ */
+BI.BranchRelation = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.BranchRelation.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-branch-relation-tree",
+ items: [],
+
+ centerOffset: 0,//重心偏移量
+ direction: BI.Direction.Bottom,
+ align: BI.VerticalAlign.Top
+ })
+ },
+
+ _init: function () {
+ BI.BranchRelation.superclass._init.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ //树分层
+ _stratification: function () {
+ var levels = [];
+ this.tree.recursion(function (node, route) {
+ //node.isRoot = route.length <= 1;
+ node.leaf = node.isLeaf();
+ if (!levels[route.length - 1]) {
+ levels[route.length - 1] = [];
+ }
+ levels[route.length - 1].push(node);
+ });
+ return levels;
+ },
+
+ //计算所有节点的叶子结点个数
+ _calculateLeaves: function () {
+ var count = 0;
+
+ function track(node) {
+ var c = 0;
+ if (node.isLeaf()) {
+ return 1;
+ }
+ BI.each(node.getChildren(), function (i, child) {
+ c += track(child);
+ });
+ node.set("leaves", c);
+ return c;
+ }
+
+ count = track(this.tree.getRoot());
+ return count;
+ },
+
+ //树平移
+ _translate: function (levels) {
+ var adjust = [];
+ var maxLevel = levels.length;
+ BI.each(levels, function (i, nodes) {
+ if (!adjust[i]) {
+ adjust[i] = [];
+ }
+ BI.each(nodes, function (j, node) {
+ if (node.isLeaf() && i < maxLevel - 1) {
+ var newNode = new BI.Node(BI.UUID());
+ //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot;
+ newNode.isNew = true;
+ //把node向下一层移
+ var tar = 0;
+ if (j > 0) {
+ var c = nodes[j - 1].getLastChild();
+ tar = levels[i + 1].indexOf(c) + 1;
+ }
+ levels[i + 1].splice(tar, 0, node);
+ //新增一个临时树节点
+ var index = node.parent.getChildIndex(node.id);
+ node.parent.removeChildByIndex(index);
+ node.parent.addChild(newNode, index);
+ newNode.addChild(node);
+ adjust[i].push(newNode);
+ nodes[j] = newNode;
+ } else {
+ adjust[i].push(node);
+ }
+ })
+ });
+ return adjust;
+ },
+
+ //树补白
+ _fill: function (levels) {
+ var adjust = [];
+ var maxLevel = levels.length;
+ BI.each(levels, function (i, nodes) {
+ if (!adjust[i]) {
+ adjust[i] = [];
+ }
+ BI.each(nodes, function (j, node) {
+ if (node.isLeaf() && i < maxLevel - 1) {
+ var newNode = new BI.Node(BI.UUID());
+ newNode.leaf = true;
+ newNode.width = node.width;
+ newNode.height = node.height;
+ newNode.isNew = true;
+ //把node向下一层移
+ var tar = 0;
+ if (j > 0) {
+ var c = nodes[j - 1].getLastChild();
+ tar = levels[i + 1].indexOf(c) + 1;
+ }
+ levels[i + 1].splice(tar, 0, newNode);
+ //新增一个临时树节点
+ node.addChild(newNode);
+ }
+ adjust[i].push(node);
+ })
+ });
+ return adjust;
+ },
+
+ //树调整
+ _adjust: function (adjust) {
+ while (true) {
+ var isAllNeedAjust = false;
+ BI.backEach(adjust, function (i, nodes) {
+ BI.each(nodes, function (j, node) {
+ if (!node.isNew) {
+ var needAdjust = true;
+ BI.any(node.getChildren(), function (k, n) {
+ if (!n.isNew) {
+ needAdjust = false;
+ return true;
+ }
+ });
+ if (!node.isLeaf() && needAdjust === true) {
+ var allChilds = [];
+ BI.each(node.getChildren(), function (k, n) {
+ allChilds = allChilds.concat(n.getChildren());
+ });
+ node.removeAllChilds();
+ BI.each(allChilds, function (k, c) {
+ node.addChild(c);
+ });
+ var newNode = new BI.Node(BI.UUID());
+ //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot;
+ newNode.isNew = true;
+ var index = node.parent.getChildIndex(node.id);
+ node.parent.removeChildByIndex(index);
+ node.parent.addChild(newNode, index);
+ newNode.addChild(node);
+ isAllNeedAjust = true;
+ }
+ }
+ })
+ });
+ if (isAllNeedAjust === false) {
+ break;
+ } else {//树重构
+ adjust = this._stratification();
+ }
+ }
+ return adjust;
+ },
+
+ _calculateWidth: function () {
+ var o = this.options;
+ var width = 0;
+
+ function track1(node) {
+ var w = 0;
+ if (node.isLeaf()) {
+ return node.width;
+ }
+ BI.each(node.getChildren(), function (i, child) {
+ w += track1(child);
+ });
+ return w;
+ }
+
+ function track2(node) {
+ var w = 0;
+ if (node.isLeaf()) {
+ return node.height;
+ }
+ BI.each(node.getChildren(), function (i, child) {
+ w += track2(child);
+ });
+ return w;
+ }
+
+ if (this._isVertical()) {
+ width = track1(this.tree.getRoot());
+ } else {
+ width = track2(this.tree.getRoot());
+ }
+
+ return width;
+ },
+
+ _isVertical: function () {
+ var o = this.options;
+ return o.direction === BI.Direction.Top || o.direction === BI.Direction.Bottom;
+ },
+
+ _calculateHeight: function () {
+ var o = this.options;
+ var height = 0;
+
+ function track1(node) {
+ var h = 0;
+ BI.each(node.getChildren(), function (i, child) {
+ h = Math.max(h, track1(child));
+ });
+ return h + (node.height || 0);
+ }
+
+ function track2(node) {
+ var h = 0;
+ BI.each(node.getChildren(), function (i, child) {
+ h = Math.max(h, track2(child));
+ });
+ return h + (node.width || 0);
+ }
+
+ if (this._isVertical()) {
+ height = track1(this.tree.getRoot());
+ } else {
+ height = track2(this.tree.getRoot());
+ }
+ return height;
+ },
+
+ _calculateXY: function (levels) {
+ var o = this.options;
+ var width = this._calculateWidth();
+ var height = this._calculateHeight();
+ var levelCount = levels.length;
+ var allLeavesCount = this._calculateLeaves();
+ //计算坐标
+ var xy = {};
+ var levelHeight = height / levelCount;
+ BI.each(levels, function (i, nodes) {
+ //计算权重
+ var weights = [];
+ BI.each(nodes, function (j, node) {
+ weights[j] = (node.get("leaves") || 1) / allLeavesCount;
+ });
+ BI.each(nodes, function (j, node) {
+ //求前j个元素的权重
+ var weight = BI.sum(weights.slice(0, j));
+ //求坐标
+ var x = weight * width + weights[j] * width / 2;
+ var y = i * levelHeight + levelHeight / 2;
+ xy[node.id] = {x: x, y: y};
+ })
+ });
+ return xy;
+ },
+
+ _stroke: function (levels, xy) {
+ var height = this._calculateHeight();
+ var levelCount = levels.length;
+ var levelHeight = height / levelCount;
+ var self = this, o = this.options;
+ switch (o.direction) {
+ case BI.Direction.Top:
+ BI.each(levels, function (i, nodes) {
+ BI.each(nodes, function (j, node) {
+ if (node.getChildrenLength() > 0 && !node.leaf) {
+ var path = "";
+ var start = xy[node.id];
+ var split = start.y + levelHeight / 2;
+ path += "M" + start.x + "," + (start.y + o.centerOffset) + "L" + start.x + "," + split;
+ var end = [];
+ BI.each(node.getChildren(), function (t, c) {
+ var e = end[t] = xy[c.id];
+ path += "M" + e.x + "," + (e.y + o.centerOffset) + "L" + e.x + "," + split;
+ });
+ if (end.length > 0) {
+ path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split;
+ }
+ self.svg.path(path).attr("stroke", "#d4dadd");
+ }
+ })
+ });
+ break;
+ case BI.Direction.Bottom:
+ BI.each(levels, function (i, nodes) {
+ BI.each(nodes, function (j, node) {
+ if (node.getChildrenLength() > 0 && !node.leaf) {
+ var path = "";
+ var start = xy[node.id];
+ var split = start.y - levelHeight / 2;
+ path += "M" + start.x + "," + (start.y - o.centerOffset) + "L" + start.x + "," + split;
+ var end = [];
+ BI.each(node.getChildren(), function (t, c) {
+ var e = end[t] = xy[c.id];
+ path += "M" + e.x + "," + (e.y - o.centerOffset) + "L" + e.x + "," + split;
+ });
+ if (end.length > 0) {
+ path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split;
+ }
+ self.svg.path(path).attr("stroke", "#d4dadd");
+ }
+ })
+ });
+ break;
+ case BI.Direction.Left:
+ BI.each(levels, function (i, nodes) {
+ BI.each(nodes, function (j, node) {
+ if (node.getChildrenLength() > 0 && !node.leaf) {
+ var path = "";
+ var start = xy[node.id];
+ var split = start.y + levelHeight / 2;
+ path += "M" + (start.y + o.centerOffset) + "," + start.x + "L" + split + "," + start.x;
+ var end = [];
+ BI.each(node.getChildren(), function (t, c) {
+ var e = end[t] = xy[c.id];
+ path += "M" + (e.y + o.centerOffset) + "," + e.x + "L" + split + "," + e.x;
+ });
+ if (end.length > 0) {
+ path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x;
+ }
+ self.svg.path(path).attr("stroke", "#d4dadd");
+ }
+ })
+ });
+ break;
+ case BI.Direction.Right:
+ BI.each(levels, function (i, nodes) {
+ BI.each(nodes, function (j, node) {
+ if (node.getChildrenLength() > 0 && !node.leaf) {
+ var path = "";
+ var start = xy[node.id];
+ var split = start.y - levelHeight / 2;
+ path += "M" + (start.y - o.centerOffset) + "," + start.x + "L" + split + "," + start.x;
+ var end = [];
+ BI.each(node.getChildren(), function (t, c) {
+ var e = end[t] = xy[c.id];
+ path += "M" + (e.y - o.centerOffset) + "," + e.x + "L" + split + "," + e.x;
+ });
+ if (end.length > 0) {
+ path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x;
+ }
+ self.svg.path(path).attr("stroke", "#d4dadd");
+ }
+ })
+ });
+ break;
+ }
+ },
+
+ _createBranches: function (levels) {
+ var self = this, o = this.options;
+ if (o.direction === BI.Direction.Bottom || o.direction === BI.Direction.Right) {
+ levels = levels.reverse();
+ }
+ var xy = this._calculateXY(levels);
+ //画图
+ this._stroke(levels, xy);
+ },
+
+ _isNeedAdjust: function () {
+ var o = this.options;
+ return o.direction === BI.Direction.Top && o.align === BI.VerticalAlign.Bottom || o.direction === BI.Direction.Bottom && o.align === BI.VerticalAlign.Top
+ || o.direction === BI.Direction.Left && o.align === BI.HorizontalAlign.Right || o.direction === BI.Direction.Right && o.align === BI.HorizontalAlign.Left
+ },
+
+ setValue: function (value) {
+
+ },
+
+ getValue: function () {
+
+ },
+
+ _transformToTreeFormat: function (sNodes) {
+ var i, l;
+ if (!sNodes) {
+ return [];
+ }
+
+ if (BI.isArray(sNodes)) {
+ var r = [];
+ var tmpMap = [];
+ for (i = 0, l = sNodes.length; i < l; i++) {
+ tmpMap[sNodes[i].id] = sNodes[i];
+ }
+ for (i = 0, l = sNodes.length; i < l; i++) {
+ if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) {
+ if (!tmpMap[sNodes[i].pId].children) {
+ tmpMap[sNodes[i].pId].children = [];
+ }
+ tmpMap[sNodes[i].pId].children.push(sNodes[i]);
+ } else {
+ r.push(sNodes[i]);
+ }
+ }
+ return r;
+ } else {
+ return [sNodes];
+ }
+ },
+
+ populate: function (items) {
+ var self = this, o = this.options;
+ o.items = items || [];
+ this.empty();
+ items = this._transformToTreeFormat(o.items);
+ this.tree = new BI.Tree();
+ this.tree.initTree(items);
+
+ this.svg = BI.createWidget({
+ type: "bi.svg"
+ });
+
+ //树分层
+ var levels = this._stratification();
+
+ if (this._isNeedAdjust()) {
+ //树平移
+ var adjust = this._translate(levels);
+ //树调整
+ adjust = this._adjust(adjust);
+
+ this._createBranches(adjust);
+ } else {
+ var adjust = this._fill(levels);
+
+ this._createBranches(adjust);
+ }
+
+ var container = BI.createWidget({
+ type: "bi.layout",
+ width: this._isVertical() ? this._calculateWidth() : this._calculateHeight(),
+ height: this._isVertical() ? this._calculateHeight() : this._calculateWidth()
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: container,
+ items: [{
+ el: this.svg,
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }]
+ });
+ if (this._isVertical()) {
+ items = [{
+ type: "bi.handstand_branch_tree",
+ expander: {
+ direction: o.direction
+ },
+ el: {
+ layouts: [{
+ type: "bi.horizontal_adapt",
+ verticalAlign: o.align
+ }]
+ },
+ items: items
+ }]
+ } else {
+ items = [{
+ type: "bi.branch_tree",
+ expander: {
+ direction: o.direction
+ },
+ el: {
+ layouts: [{
+ type: "bi.vertical"
+ }, {
+ type: o.align === BI.HorizontalAlign.Left ? "bi.left" : "bi.right"
+ }]
+ },
+ items: items
+ }]
+ }
+ BI.createWidget({
+ type: "bi.adaptive",
+ element: container,
+ items: items
+ });
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: true,
+ element: this,
+ items: [container]
+ });
+ }
+});
+BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE";
+BI.shortcut("bi.branch_relation", BI.BranchRelation);/**
+ * 日期控件中的月份下拉框
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.MonthDateCombo
+ * @extends BI.Trigger
+ */
+BI.MonthDateCombo = BI.inherit(BI.Trigger, {
+ _defaultConfig: function() {
+ return BI.extend( BI.MonthDateCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-month-combo",
+ height: 25
+ });
+ },
+ _init: function() {
+ BI.MonthDateCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.date_triangle_trigger"
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.month_popup"
+ });
+
+ this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){
+ self.setValue(self.popup.getValue());
+ })
+
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ offsetStyle: "center",
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ stopPropagation: false,
+ el: this.popup
+ }
+ })
+ this.combo.on(BI.Combo.EVENT_CHANGE, function(){
+ self.combo.hideView();
+ self.fireEvent(BI.MonthDateCombo.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function(v){
+ this.trigger.setValue(v + 1);
+ this.popup.setValue(v);
+ },
+
+ getValue: function(){
+ return this.popup.getValue();
+ }
+});
+BI.MonthDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.month_date_combo', BI.MonthDateCombo);/**
+ * 年份下拉框
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.YearDateCombo
+ * @extends BI.Trigger
+ */
+BI.YearDateCombo = BI.inherit(BI.Trigger, {
+ _defaultConfig: function() {
+ return BI.extend( BI.YearDateCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-combo",
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ height: 25
+ });
+ },
+ _init: function() {
+ BI.YearDateCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.date_triangle_trigger"
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.year_popup",
+ min: o.min,
+ max: o.max
+ });
+
+ this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.YearDateCombo.EVENT_CHANGE);
+ })
+
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ offsetStyle: "center",
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ stopPropagation: false,
+ el: this.popup
+ }
+ })
+ this.combo.on(BI.Combo.EVENT_CHANGE, function(){
+ self.fireEvent(BI.YearDateCombo.EVENT_CHANGE);
+ })
+ },
+
+ setValue: function(v){
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function(){
+ return this.popup.getValue();
+ }
+});
+BI.YearDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.year_date_combo', BI.YearDateCombo);/**
+ * Created by GUY on 2015/9/7.
+ * @class BI.DatePicker
+ * @extends BI.Widget
+ */
+BI.DatePicker = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-date-picker bi-background",
+ height: 25,
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31' //最大日期
+ })
+ },
+
+ _init: function () {
+ BI.DatePicker.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this._year = new Date().getFullYear();
+ this._month = new Date().getMonth();
+ this.left = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "pre-page-h-font",
+ width: 25,
+ height: 25
+ });
+ this.left.on(BI.IconButton.EVENT_CHANGE, function () {
+ if (self._month === 0) {
+ self.setValue({
+ year: self.year.getValue() - 1,
+ month: 11
+ })
+ } else {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue() - 1
+ })
+ }
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ });
+
+ this.right = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "next-page-h-font",
+ width: 25,
+ height: 25
+ });
+
+ this.right.on(BI.IconButton.EVENT_CHANGE, function () {
+ if (self._month === 11) {
+ self.setValue({
+ year: self.year.getValue() + 1,
+ month: 0
+ })
+ } else {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue() + 1
+ })
+ }
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ });
+
+ this.year = BI.createWidget({
+ type: "bi.year_date_combo",
+ min: o.min,
+ max: o.max
+ });
+ this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue()
+ });
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ })
+ this.month = BI.createWidget({
+ type: "bi.month_date_combo"
+ });
+ this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue()
+ });
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: this.left,
+ width: 25
+ }, {
+ type: "bi.center_adapt",
+ items: [{
+ type: "bi.horizontal",
+ width: 100,
+ items: [this.year, this.month]
+ }]
+ }, {
+ el: this.right,
+ width: 25
+ }]
+ })
+ this.setValue({
+ year: this._year,
+ month: this._month
+ })
+ },
+
+ setValue: function (ob) {
+ this._year = ob.year;
+ this._month = ob.month;
+ this.year.setValue(ob.year);
+ this.month.setValue(ob.month);
+ },
+
+ getValue: function () {
+ return {
+ year: this.year.getValue(),
+ month: this.month.getValue()
+ }
+ }
+});
+BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE"
+BI.shortcut("bi.date_picker", BI.DatePicker);/**
+ * Created by GUY on 2015/9/7.
+ * @class BI.DateCalendarPopup
+ * @extends BI.Widget
+ */
+BI.DateCalendarPopup = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-date-calendar-popup",
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ selectedTime: null
+ })
+ },
+
+ _createNav: function (v) {
+ var date = BI.Calendar.getDateJSONByPage(v);
+ var calendar = BI.createWidget({
+ type: "bi.calendar",
+ logic: {
+ dynamic: true
+ },
+ min: this.options.min,
+ max: this.options.max,
+ year: date.year,
+ month: date.month,
+ day: this.selectedTime.day
+ });
+ return calendar;
+ },
+
+ _init: function () {
+ BI.DateCalendarPopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.today = new Date();
+ this._year = this.today.getFullYear();
+ this._month = this.today.getMonth();
+ this._day = this.today.getDate();
+
+ this.selectedTime = o.selectedTime || {
+ year: this._year,
+ month: this._month,
+ day: this._day
+ };
+ this.datePicker = BI.createWidget({
+ type: "bi.date_picker",
+ min: o.min,
+ max: o.max
+ });
+
+ this.calendar = BI.createWidget({
+ direction: "top",
+ element: this,
+ logic: {
+ dynamic: true
+ },
+ type: "bi.navigation",
+ tab: this.datePicker,
+ cardCreator: BI.bind(this._createNav, this),
+
+ afterCardCreated: function () {
+
+ },
+
+ afterCardShow: function () {
+ this.setValue(self.selectedTime);
+ }
+ });
+
+ this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
+ self.selectedTime = self.datePicker.getValue();
+ self.selectedTime.day = 1;
+ self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
+ });
+
+ this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedTime = self.calendar.getValue();
+ self.setValue(self.selectedTime);
+ self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (timeOb) {
+ this.datePicker.setValue(timeOb);
+ this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb));
+ this.calendar.setValue(timeOb);
+ this.selectedTime = timeOb;
+ },
+
+ getValue: function () {
+ return this.selectedTime;
+ }
+});
+BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);/**
+ * 日期控件中的年份或月份trigger
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.DateTriangleTrigger
+ * @extends BI.Trigger
+ */
+BI.DateTriangleTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ height: 25,
+ iconWidth: 16,
+ iconHeight: 13
+ },
+
+ _defaultConfig: function() {
+ return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer",
+ height: 25
+ });
+ },
+ _init: function() {
+ BI.DateTriangleTrigger.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "right",
+ text: o.text,
+ value: o.value,
+ height: c.height
+ })
+ this.icon = BI.createWidget({
+ type: "bi.icon",
+ width: c.iconWidth,
+ height: c.iconHeight
+ });
+
+ BI.createWidget({
+ type: "bi.center_adapt",
+ element: this,
+ items: [{
+ type: "bi.center_adapt",
+ width: 50,
+ height: c.height,
+ items: [this.text, this.icon]
+ }]
+ })
+ },
+
+ setValue: function(v){
+ this.text.setValue(v);
+ },
+
+ getValue: function(){
+ return this.text.getValue();
+ },
+
+ setText: function(v){
+ this.text.setText(v);
+ },
+
+ getText: function(){
+ return this.item.getText();
+ },
+
+ getKey: function(){
+
+ }
+});
+BI.shortcut('bi.date_triangle_trigger', BI.DateTriangleTrigger);/**
+ * 日期下拉框
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.DateCombo
+ * @extends BI.Widget
+ */
+BI.DateCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-date-combo bi-border",
+ height: 30
+ });
+ },
+ _init: function () {
+ BI.DateCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.date_trigger"
+ });
+
+ this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
+ self.combo.toggle();
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.date_calendar_popup"
+ });
+
+ this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ width: 270,
+ el: this.popup,
+ stopPropagation: false
+ }
+ })
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ triggerWidth: 30,
+ yearLength: 4,
+ yearMonthLength: 7
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-date-trigger",
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.DateTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ var date = v.match(/\d+/g);
+ self._autoAppend(v, date);
+ return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({
+ year: date[0],
+ month: date[1],
+ day: date[2]
+ });
+ },
+ quitChecker: function () {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ errorText: function () {
+ if (self.editor.isEditing()) {
+ return BI.i18nText("BI-Date_Trigger_Error_Text");
+ }
+ return BI.i18nText("BI-Year_Trigger_Invalid_Text");
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN)
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_STOP);
+ });
+ this.editor.on(BI.SignEditor.EVENT_VALID, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_VALID);
+ });
+ this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_ERROR);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setState(value);
+ }
+
+ if (BI.isNotEmptyString(value)) {
+ var date = value.split("-");
+ self.store_value = {
+ type: BI.DateTrigger.MULTI_DATE_CALENDAR,
+ value:{
+ year: date[0] | 0,
+ month: date[1] - 1,
+ day: date[2] | 0
+ }
+ };
+ }
+ self.fireEvent(BI.DateTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_CHANGE);
+ });
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: BI.createWidget(),
+ width: 30
+ }, {
+ el: this.editor
+ }]
+ })
+ },
+ _dateCheck: function (date) {
+ return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date;
+ },
+ _checkVoid: function (obj) {
+ return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0];
+ },
+ _autoAppend: function (v, dateObj) {
+ var self = this;
+ var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d");
+ var yearCheck = function (v) {
+ return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max;
+ };
+ var monthCheck = function (v) {
+ return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max;
+ };
+ if (BI.isNotNull(dateObj) && Date.checkLegal(v)) {
+ switch (v.length) {
+ case this._const.yearLength:
+ if (yearCheck(v)) {
+ this.editor.setValue(v + "-");
+ }
+ break;
+ case this._const.yearMonthLength:
+ if (monthCheck(v)) {
+ this.editor.setValue(v + "-");
+ }
+ break;
+ }
+ }
+ },
+
+ setValue: function (v) {
+ var type, value, self = this;
+ var date = new Date();
+ this.store_value = v;
+ if (BI.isNotNull(v)) {
+ type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value;
+ if(BI.isNull(value)){
+ value = v;
+ }
+ }
+ var _setInnerValue = function (date, text) {
+ var dateStr = date.print("%Y-%x-%e");
+ self.editor.setState(dateStr);
+ self.editor.setValue(dateStr);
+ self.setTitle(text + ":" + dateStr);
+ };
+ switch (type) {
+ case BI.DateTrigger.MULTI_DATE_YEAR_PREV:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];
+ date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate());
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];
+ date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate());
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];
+ date = new Date(date.getFullYear(), 0, 1);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_YEAR_END:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];
+ date = new Date(date.getFullYear(), 11, 31);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];
+ date = new Date().getBeforeMulQuarter(value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];
+ date = new Date().getAfterMulQuarter(value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];
+ date = new Date().getQuarterStartDate();
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_QUARTER_END:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];
+ date = new Date().getQuarterEndDate();
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_MONTH_PREV:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];
+ date = new Date().getBeforeMultiMonth(value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];
+ date = new Date().getAfterMultiMonth(value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];
+ date = new Date(date.getFullYear(), date.getMonth(), 1);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_MONTH_END:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];
+ date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate());
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_WEEK_PREV:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];
+ date = date.getOffsetDate(-7 * value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];
+ date = date.getOffsetDate(7 * value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_DAY_PREV:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];
+ date = date.getOffsetDate(-1 * value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_DAY_AFTER:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];
+ date = date.getOffsetDate(1 * value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_DAY_TODAY:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];
+ date = new Date();
+ _setInnerValue(date, text);
+ break;
+ default:
+ if (BI.isNull(value) || BI.isNull(value.day)) {
+ this.editor.setState("");
+ this.editor.setValue("");
+ this.setTitle("");
+ } else {
+ var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day;
+ this.editor.setState(dateStr);
+ this.editor.setValue(dateStr);
+ this.setTitle(dateStr);
+ }
+ break;
+ }
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+ getValue: function () {
+ return this.store_value;
+ }
+
+});
+
+BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1;
+BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2;
+BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3;
+BI.DateTrigger.MULTI_DATE_YEAR_END = 4;
+
+BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5;
+BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6;
+BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7;
+BI.DateTrigger.MULTI_DATE_MONTH_END = 8;
+
+BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9;
+BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10;
+BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11;
+BI.DateTrigger.MULTI_DATE_QUARTER_END = 12;
+
+BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13;
+BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14;
+
+BI.DateTrigger.MULTI_DATE_DAY_PREV = 15;
+BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16;
+BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17;
+
+BI.DateTrigger.MULTI_DATE_PARAM = 18;
+BI.DateTrigger.MULTI_DATE_CALENDAR = 19;
+
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {};
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End");
+
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End");
+
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End");
+
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next");
+
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today");
+
+BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.DateTrigger.EVENT_START = "EVENT_START";
+BI.DateTrigger.EVENT_STOP = "EVENT_STOP";
+BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DateTrigger.EVENT_VALID = "EVENT_VALID";
+BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR";
+BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.shortcut("bi.date_trigger", BI.DateTrigger);/**
+ * Created by zcf on 2017/2/20.
+ */
+BI.DatePaneWidget = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-date-pane-widget",
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ selectedTime: null
+ })
+ },
+ _init: function () {
+ BI.DatePaneWidget.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.today = new Date();
+ this._year = this.today.getFullYear();
+ this._month = this.today.getMonth();
+
+ this.selectedTime = o.selectedTime || {
+ year: this._year,
+ month: this._month
+ };
+
+ this.datePicker = BI.createWidget({
+ type: "bi.date_picker",
+ min: o.min,
+ max: o.max
+ });
+ this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
+ self.selectedTime = self.datePicker.getValue();
+ // self.selectedTime.day = 1;
+ self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
+ });
+
+ this.calendar = BI.createWidget({
+ direction: "top",
+ element: this,
+ logic: {
+ dynamic: false
+ },
+ type: "bi.navigation",
+ tab: this.datePicker,
+ cardCreator: BI.bind(this._createNav, this)
+
+ // afterCardCreated: function () {
+ //
+ // },
+ //
+ // afterCardShow: function () {
+ // // this.setValue(self.selectedTime);
+ // }
+ });
+ this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedTime = self.calendar.getValue();
+ self.calendar.empty();
+ self.setValue(self.selectedTime);
+ self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
+ });
+
+ },
+
+ _createNav: function (v) {
+ var date = BI.Calendar.getDateJSONByPage(v);
+ var calendar = BI.createWidget({
+ type: "bi.calendar",
+ logic: {
+ dynamic: false
+ },
+ min: this.options.min,
+ max: this.options.max,
+ year: date.year,
+ month: date.month,
+ day: this.selectedTime.day
+ });
+ return calendar;
+ },
+
+ _getNewCurrentDate: function () {
+ var today = new Date();
+ return {
+ year: today.getFullYear(),
+ month: today.getMonth()
+ }
+ },
+
+ _setCalenderValue: function (date) {
+ this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date));
+ this.calendar.setValue(date);
+ this.selectedTime = date;
+ },
+
+ _setDatePicker: function (timeOb) {
+ if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) {
+ this.datePicker.setValue(this._getNewCurrentDate());
+ } else {
+ this.datePicker.setValue(timeOb);
+ }
+ },
+
+ _setCalendar: function (timeOb) {
+ if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) {
+ this.calendar.empty();
+ this._setCalenderValue(this._getNewCurrentDate());
+ } else {
+ this._setCalenderValue(timeOb)
+ }
+ },
+
+ setValue: function (timeOb) {
+ this._setDatePicker(timeOb);
+ this._setCalendar(timeOb);
+ },
+
+ getValue: function () {
+ return this.selectedTime;
+ }
+
+});
+BI.shortcut("bi.date_pane_widget", BI.DatePaneWidget);/**
+ * 带有方向的pathchooser
+ *
+ * Created by GUY on 2016/4/21.
+ * @class BI.DirectionPathChooser
+ * @extends BI.Widget
+ */
+BI.DirectionPathChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ lineColor: "#808080",
+ selectLineColor: "#009de3"
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DirectionPathChooser.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-excel-table",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.DirectionPathChooser.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.pathChooser = BI.createWidget({
+ type: "bi.path_chooser",
+ element: this,
+ items: o.items
+ });
+ this.pathChooser.on(BI.PathChooser.EVENT_CHANGE, function (start, index) {
+ //self._unselectAllArrows();
+ self._setValue(start, index);
+ self.fireEvent(BI.DirectionPathChooser.EVENT_CHANGE);
+ });
+ this._drawArrows();
+
+ },
+
+ _unselectAllArrows: function () {
+ var self = this, lineColor = this._const.lineColor;
+ BI.each(this.arrows, function (region, rs) {
+ BI.each(rs, function (idx, arrows) {
+ BI.each(arrows, function (i, arrow) {
+ arrow.attr({fill: lineColor, stroke: lineColor});
+ });
+ });
+ });
+ },
+
+ _drawOneArrow: function (dot, direction) {
+ //0,1,2,3 上右下左
+ var lineColor = this._const.lineColor;
+ var selectLineColor = this._const.selectLineColor;
+ var svg = this.pathChooser.svg;
+ var path = "";
+ switch (direction) {
+ case 0:
+ path = "M" + dot.x + "," + dot.y
+ + "L" + (dot.x - 3) + "," + (dot.y + 5)
+ + "L" + (dot.x + 3) + "," + (dot.y + 5)
+ + "L" + dot.x + "," + dot.y;
+ break;
+ case 1:
+ path = "M" + dot.x + "," + dot.y
+ + "L" + (dot.x - 5) + "," + (dot.y - 3)
+ + "L" + (dot.x - 5) + "," + (dot.y + 3)
+ + "L" + dot.x + "," + dot.y;
+ break;
+ case 2:
+ path = "M" + dot.x + "," + dot.y
+ + "L" + (dot.x - 3) + "," + (dot.y - 5)
+ + "L" + (dot.x + 3) + "," + (dot.y - 5)
+ + "L" + dot.x + "," + dot.y;
+ break;
+ case 3:
+ path = "M" + dot.x + "," + dot.y
+ + "L" + (dot.x + 5) + "," + (dot.y - 3)
+ + "L" + (dot.x + 5) + "," + (dot.y + 3)
+ + "L" + dot.x + "," + dot.y;
+ break;
+ }
+ return svg.path(path).attr({fill: lineColor, stroke: lineColor});
+ },
+
+ _drawArrows: function () {
+ var self = this, o = this.options;
+ var routes = this.pathChooser.routes;
+ var pathes = this.pathChooser.pathes;
+ var store = this.pathChooser.store;
+ this.arrows = {};
+ BI.each(routes, function (region, ps) {
+ self.arrows[region] = [];
+ BI.each(ps, function (idx, path) {
+ self.arrows[region][idx] = [];
+ var dots = pathes[region][idx];
+ BI.each(dots, function (i, dot) {
+ if (i > 0 && i < dots.length - 1) {
+ var arrow;
+ if (dot.y === dots[i - 1].y) {
+ if (dots[i + 1].y != dot.y) {
+ if (store[path[path.length - 2]].direction === -1) {
+ if (i - 1 > 0) {
+ arrow = self._drawOneArrow(dots[i - 1], 3);
+ }
+ } else {
+ arrow = self._drawOneArrow(dots[i], 1);
+ }
+ }
+ } else if (dot.x === dots[i - 1].x) {
+ if (dot.y > dots[i - 1].y) {
+ if (store[BI.first(path)].direction === -1) {
+ arrow = self._drawOneArrow(dots[i - 1], 0);
+ } else {
+ arrow = self._drawOneArrow(dot, 2);
+ }
+ } else {
+ if (store[path[path.length - 2]].direction === -1) {
+ arrow = self._drawOneArrow(dots[i - 1], 2);
+ } else {
+ arrow = self._drawOneArrow(dot, 0);
+ }
+ }
+ }
+ if (arrow) {
+ self.arrows[region][idx].push(arrow);
+ }
+ }
+ });
+ BI.each(path, function (i, node) {
+ if (i !== 0) {
+ var arrow;
+ var from = path[i - 1];
+ if (store[from].direction === -1) {
+ var regionIndex = self.pathChooser.getRegionIndexById(from);
+ var x = getXoffsetByRegionIndex(regionIndex, -1);
+ var y = getYByXoffset(dots, x);
+ arrow = self._drawOneArrow({x: x, y: y}, 3);
+ } else {
+ var regionIndex = self.pathChooser.getRegionIndexById(node);
+ var x = getXoffsetByRegionIndex(regionIndex);
+ var y = getYByXoffset(dots, x);
+ arrow = self._drawOneArrow({x: x, y: y}, 1);
+ }
+ if (arrow) {
+ self.arrows[region][idx].push(arrow);
+ }
+ }
+ });
+ })
+ });
+
+ function getXoffsetByRegionIndex(regionIndex, diregion) {
+ if (diregion === -1) {
+ return 100 * (regionIndex + 1) - 20;
+ }
+ return 100 * regionIndex + 20;
+ }
+
+ function getYByXoffset(dots, xoffset) {
+ var finded = BI.find(dots, function (i, dot) {
+ if (i > 0) {
+ if (dots[i - 1].x < xoffset && dots[i].x > xoffset) {
+ return true;
+ }
+ }
+ });
+ return finded.y;
+ }
+ },
+
+ _setValue: function (start, index) {
+ var self = this;
+ var lineColor = this._const.lineColor;
+ var selectLineColor = this._const.selectLineColor;
+ var routes = this.pathChooser.routes;
+ var starts = this.pathChooser.start;
+ var each = [start];
+ if (starts.contains(start)) {
+ each = starts;
+ }
+ BI.each(each, function (i, s) {
+ BI.each(self.arrows[s], function (j, arrows) {
+ BI.each(arrows, function (k, arrow) {
+ arrow.attr({fill: lineColor, stroke: lineColor}).toFront();
+ });
+ });
+ });
+ BI.each(this.arrows[start][index], function (i, arrow) {
+ arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront();
+ });
+ var current = BI.last(routes[start][index]);
+ while (current && routes[current] && routes[current].length === 1) {
+ BI.each(self.arrows[current][0], function (i, arrow) {
+ arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront();
+ });
+ current = BI.last(routes[current][0]);
+ }
+ },
+
+ setValue: function (v) {
+ this.pathChooser.setValue(v);
+ this._unselectAllArrows();
+ var routes = this.pathChooser.routes;
+ var nodes = BI.keys(routes), self = this;
+ var result = [], array = [];
+ BI.each(v, function (i, val) {
+ if (BI.contains(nodes, val)) {
+ if (array.length > 0) {
+ array.push(val);
+ result.push(array);
+ array = [];
+ }
+ }
+ array.push(val);
+ });
+ if (array.length > 0) {
+ result.push(array);
+ }
+ //画这n条路径
+ BI.each(result, function (idx, path) {
+ var start = path[0];
+ var index = BI.findIndex(routes[start], function (idx, p) {
+ if (BI.isEqual(path, p)) {
+ return true;
+ }
+ });
+ if (index >= 0) {
+ self._setValue(start, index);
+ }
+ });
+ },
+
+ getValue: function () {
+ return this.pathChooser.getValue();
+ },
+
+ populate: function (items) {
+ this.pathChooser.populate(items);
+ this._drawArrows();
+ }
+});
+BI.DirectionPathChooser.EVENT_CHANGE = "DirectionPathChooser.EVENT_CHANGE";
+BI.shortcut('bi.direction_path_chooser', BI.DirectionPathChooser);/**
+ * Created by roy on 15/8/14.
+ */
+BI.DownListCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-down-list-combo",
+ invalid: false,
+ height: 25,
+ items: [],
+ adjustLength: 0,
+ direction: "bottom",
+ el: {}
+ })
+ },
+
+ _init: function () {
+ BI.DownListCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.popupview = BI.createWidget({
+ type: "bi.down_list_popup",
+ items: o.items,
+ chooseType: o.chooseType
+ });
+
+ this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) {
+ self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
+ self.downlistcombo.hideView();
+ });
+
+ this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
+ self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
+ self.downlistcombo.hideView();
+ });
+
+
+ this.downlistcombo = BI.createWidget({
+ element: this,
+ type: 'bi.combo',
+ isNeedAdjustWidth: false,
+ adjustLength: o.adjustLength,
+ direction: o.direction,
+ el: BI.createWidget(o.el, {
+ type: "bi.icon_trigger",
+ extraCls: o.iconCls ? o.iconCls : "pull-down-font",
+ width: o.width,
+ height: o.height
+ }),
+ popup: {
+ el: this.popupview,
+ stopPropagation: true,
+ maxHeight: 1000
+ }
+ });
+
+ this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ hideView: function () {
+ this.downlistcombo.hideView();
+ },
+
+ showView: function () {
+ this.downlistcombo.showView();
+ },
+
+ populate: function (items) {
+ this.popupview.populate(items);
+ },
+
+ setValue: function (v) {
+ this.popupview.setValue(v);
+ },
+ getValue: function () {
+ return this.popupview.getValue()
+ }
+});
+BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
+BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+
+BI.shortcut("bi.down_list_combo", BI.DownListCombo);/**
+ * Created by roy on 15/9/6.
+ */
+BI.DownListGroup = BI.inherit(BI.Widget, {
+ constants: {
+ iconCls: "check-mark-ha-font"
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.DownListGroup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-down-list-group",
+ items: [
+ {
+ el: {}
+ }
+ ]
+ })
+ },
+ _init: function () {
+ BI.DownListGroup.superclass._init.apply(this, arguments);
+ var o = this.options, self = this;
+
+ this.downlistgroup = BI.createWidget({
+ element: this,
+ type: "bi.button_tree",
+ items: o.items,
+ chooseType: 0,//0单选,1多选
+ layouts: [{
+ type: "bi.vertical",
+ hgap: 0,
+ vgap: 0
+ }]
+ });
+ this.downlistgroup.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if(type === BI.Events.CLICK) {
+ self.fireEvent(BI.DownListGroup.EVENT_CHANGE, arguments);
+ }
+ })
+ },
+ getValue:function(){
+ return this.downlistgroup.getValue();
+ },
+ setValue:function(v){
+ this.downlistgroup.setValue(v);
+ }
+
+
+})
+BI.DownListGroup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.down_list_group", BI.DownListGroup);BI.DownListItem = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.DownListItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-down-list-item bi-list-item-active",
+ cls: "",
+ height: 25,
+ logic: {
+ dynamic: true
+ },
+ selected: false,
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ })
+ },
+ _init: function () {
+ BI.DownListItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.text = BI.createWidget({
+ type: "bi.icon_text_item",
+ element: this,
+ height: o.height,
+ text: o.text,
+ value: o.value,
+ logic: o.logic,
+ selected: o.selected,
+ disabled: o.disabled,
+ iconHeight: o.iconHeight,
+ iconWidth: o.iconWidth,
+ textHgap: o.textHgap,
+ textVgap: o.textVgap,
+ textLgap: o.textLgap,
+ textRgap: o.textRgap,
+ father: o.father
+ });
+ this.text.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.text.on(BI.IconTextItem.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DownListItem.EVENT_CHANGE);
+ });
+ // this.setSelected(o.selected);
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ isSelected: function () {
+ return this.text.isSelected();
+ },
+
+ setSelected: function (b) {
+ this.text.setSelected(b);
+ // if (b === true) {
+ // this.element.addClass("dot-e-font");
+ // } else {
+ // this.element.removeClass("dot-e-font");
+ // }
+ },
+
+ setValue: function (v) {
+ this.text.setValue(v);
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ }
+});
+BI.DownListItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ var conf = BI.DownListGroupItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-down-list-group-item",
+ logic: {
+ dynamic: false
+ },
+ // invalid: true,
+ iconCls1: "dot-e-font",
+ iconCls2: "pull-right-e-font"
+ })
+ },
+ _init: function () {
+ BI.DownListGroupItem.superclass._init.apply(this, arguments);
+ var o = this.options;
+ var self = this;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-group-item-text",
+ textAlign: "left",
+ text: o.text,
+ value: o.value,
+ height: o.height
+ });
+
+ this.icon1 = BI.createWidget({
+ type: "bi.icon_button",
+ cls: o.iconCls1,
+ width: 25,
+ forceNotSelected: true
+ });
+
+ this.icon2 = BI.createWidget({
+ type: "bi.icon_button",
+ cls: o.iconCls2,
+ width: 25,
+ forceNotSelected: true
+ });
+
+ var blank = BI.createWidget({
+ type: "bi.layout",
+ width: 25
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.icon2,
+ top: 0,
+ bottom: 0,
+ right: 0
+ }]
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank)
+ }))));
+
+ this.element.hover(function () {
+ if (self.isEnabled()) {
+ self.hover();
+ }
+ }, function () {
+ if (self.isEnabled()) {
+ self.dishover()
+ }
+ });
+ },
+
+ hover: function () {
+ BI.DownListGroupItem.superclass.hover.apply(this, arguments);
+ this.icon1.element.addClass("hover");
+ this.icon2.element.addClass("hover");
+
+ },
+
+ dishover: function () {
+ BI.DownListGroupItem.superclass.dishover.apply(this, arguments);
+ this.icon1.element.removeClass("hover");
+ this.icon2.element.removeClass("hover");
+ },
+
+ doClick: function () {
+ BI.DownListGroupItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.DownListGroupItem.EVENT_CHANGE, this.getValue());
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ setValue: function (v) {
+ var self = this, o = this.options;
+ v = BI.isArray(v) ? v : [v];
+ BI.find(v, function (idx, value) {
+ if (BI.contains(o.childValues, value)) {
+ self.icon1.setSelected(true);
+ return true;
+ } else {
+ self.icon1.setSelected(false);
+ }
+ })
+ }
+});
+BI.DownListGroupItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem);/**
+ * Created by roy on 15/9/8.
+ * 处理popup中的item分组样式
+ * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项
+ */
+BI.DownListPopup = BI.inherit(BI.Pane, {
+ constants: {
+ nextIcon: "pull-right-e-font",
+ height: 25,
+ iconHeight: 12,
+ iconWidth: 12,
+ hgap: 0,
+ vgap: 0,
+ border: 1
+ },
+ _defaultConfig: function () {
+ var conf = BI.DownListPopup.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-down-list-popup",
+ items: [],
+ chooseType: BI.Selection.Multi
+ })
+ },
+ _init: function () {
+ BI.DownListPopup.superclass._init.apply(this, arguments);
+ this.singleValues = [];
+ this.childValueMap = {};
+ this.fatherValueMap = {};
+ var self = this, o = this.options, children = this._createChildren(o.items);
+ this.popup = BI.createWidget({
+ type: "bi.button_tree",
+ items: BI.createItems(children,
+ {}, {
+ adjustLength: -2
+ }
+ ),
+ layouts: [{
+ type: "bi.vertical",
+ hgap: this.constants.hgap,
+ vgap: this.constants.vgap
+ }],
+ chooseType: o.chooseType
+ });
+
+ this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) {
+ var changedValue = value;
+ if (BI.isNotNull(self.childValueMap[value])) {
+ changedValue = self.childValueMap[value];
+ self.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, self.fatherValueMap[value])
+ } else {
+ self.fireEvent(BI.DownListPopup.EVENT_CHANGE, changedValue, object);
+ }
+
+
+ if (!self.singleValues.contains(changedValue)) {
+ var item = self.getValue();
+ var result = [];
+ BI.each(item, function (i, valueObject) {
+ if (valueObject.value != changedValue) {
+ result.push(valueObject);
+ }
+ });
+ self.setValue(result);
+ }
+
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.popup]
+ });
+
+ },
+ _createChildren: function (items) {
+ var self = this, result = [];
+ BI.each(items, function (i, it) {
+ var item_done = {
+ type: "bi.down_list_group",
+ items: []
+ };
+
+ BI.each(it, function (i, item) {
+ if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) {
+ item.type = "bi.combo_group";
+ item.cls = "down-list-group";
+ item.trigger = "hover";
+ item.isNeedAdjustWidth = false;
+ item.el.title = item.el.title || item.el.text;
+ item.el.type = "bi.down_list_group_item";
+ item.el.logic = {
+ dynamic: true
+ };
+ item.el.height = self.constants.height;
+ item.el.iconCls2 = self.constants.nextIcon;
+ item.popup = {
+ lgap: 4,
+ el: {
+ type: "bi.button_tree",
+ chooseType: 0,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+
+ }
+ };
+ item.el.childValues = [];
+ BI.each(item.children, function (i, child) {
+ var fatherValue = BI.deepClone(item.el.value);
+ var childValue = BI.deepClone(child.value);
+ self.singleValues.push(child.value);
+ child.type = "bi.down_list_item";
+ child.extraCls = " child-down-list-item";
+ child.title = child.title || child.text;
+ child.textRgap = 10;
+ child.isNeedAdjustWidth = false;
+ child.logic = {
+ dynamic: true
+ };
+ child.father = fatherValue;
+ self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
+ self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
+ child.value = self._createChildValue(fatherValue, childValue);
+ item.el.childValues.push(child.value);
+ })
+ } else {
+ item.type = "bi.down_list_item";
+ item.title = item.title || item.text;
+ item.textRgap = 10;
+ item.isNeedAdjustWidth = false;
+ item.logic = {
+ dynamic: true
+ }
+ }
+ var el_done = {};
+ el_done.el = item;
+ item_done.items.push(el_done);
+ });
+ if (self._isGroup(item_done.items)) {
+ BI.each(item_done.items, function (i, item) {
+ self.singleValues.push(item.el.value);
+ })
+ }
+
+ result.push(item_done);
+ if (self._needSpliter(i, items.length)) {
+ var spliter_container = BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ el: {
+ type: "bi.layout",
+ cls: "bi-down-list-spliter bi-border-top cursor-pointer",
+ height: 0
+ }
+
+ }],
+ cls: "bi-down-list-spliter-container cursor-pointer",
+ lgap: 10,
+ rgap: 10
+ });
+ result.push(spliter_container);
+ }
+ });
+ return result;
+ },
+
+ _isGroup: function (i) {
+ return i.length > 1;
+ },
+
+ _needSpliter: function (i, itemLength) {
+ return i < itemLength - 1;
+ },
+
+ _createChildValue: function (fatherValue, childValue) {
+ return fatherValue + "_" + childValue
+ },
+
+ populate: function (items) {
+ BI.DownListPopup.superclass.populate.apply(this, arguments);
+ var self = this;
+ self.childValueMap = {};
+ self.fatherValueMap = {};
+ self.singleValues = [];
+ var children = self._createChildren(items);
+ var popupItem = BI.createItems(children,
+ {}, {
+ adjustLength: -2
+ }
+ );
+ self.popup.populate(popupItem);
+ },
+
+ setValue: function (valueItem) {
+ var self = this;
+ var valueArray = [];
+ BI.each(valueItem, function (i, item) {
+ var value;
+ if (BI.isNotNull(item.childValue)) {
+ value = self._createChildValue(item.value, item.childValue);
+ } else {
+ value = item.value;
+ }
+ valueArray.push(value);
+ }
+ );
+ this.popup.setValue(valueArray);
+ },
+
+ getValue: function () {
+ var self = this, result = [];
+ var values = this.popup.getValue();
+ BI.each(values, function (i, value) {
+ var valueItem = {};
+ if (BI.isNotNull(self.childValueMap[value])) {
+ var fartherValue = self.fatherValueMap[value];
+ valueItem.childValue = self.childValueMap[value];
+ valueItem.value = fartherValue;
+ } else {
+ valueItem.value = value;
+ }
+ result.push(valueItem);
+ });
+ return result;
+ }
+
+
+});
+
+BI.DownListPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
+BI.shortcut("bi.down_list_popup", BI.DownListPopup);/**
+ *
+ * Created by GUY on 2016/3/28.
+ * @class BI.ExcelTableCell
+ * @extends BI.Widget
+ */
+BI.ExcelTableCell = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ExcelTableCell.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-excel-table-cell",
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.ExcelTableCell.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: "left",
+ whiteSpace: "normal",
+ height: this.options.height,
+ text: this.options.text,
+ value: this.options.value
+ })
+ }
+});
+BI.shortcut('bi.excel_table_cell', BI.ExcelTableCell);/**
+ *
+ * Created by GUY on 2016/3/28.
+ * @class BI.ExcelTableHeaderCell
+ * @extends BI.Widget
+ */
+BI.ExcelTableHeaderCell = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ExcelTableHeaderCell.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-excel-table-header-cell bi-background",
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.ExcelTableHeaderCell.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: BI.HorizontalAlign.Center,
+ whiteSpace: "normal",
+ height: this.options.height,
+ text: this.options.text,
+ value: this.options.value
+ })
+ }
+});
+BI.shortcut('bi.excel_table_header_cell', BI.ExcelTableHeaderCell);/**
+ * Excel表格
+ *
+ * Created by GUY on 2016/3/28.
+ * @class BI.ExcelTable
+ * @extends BI.Widget
+ */
+BI.ExcelTable = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-excel-table",
+ el: {
+ type: "bi.responsive_table"
+ },
+
+ isNeedResize: false,
+ isResizeAdapt: true,
+
+ isNeedMerge: false,//是否需要合并单元格
+ mergeCols: [], //合并的单元格列号
+ mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
+ return BI.isEqual(row1, row2);
+ },
+
+ columnSize: [],
+ headerRowSize: 37,
+ footerRowSize: 37,
+ rowSize: 37,
+
+ regionColumnSize: false,
+
+ items: [] //二维数组
+ });
+ },
+
+ _init: function () {
+ BI.ExcelTable.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var mergeCols = [];
+ BI.each(o.mergeCols, function (i, col) {
+ mergeCols.push(col + 1);
+ });
+ this.table = BI.createWidget(o.el, {
+ type: "bi.table_view",
+ element: this,
+
+ isNeedFreeze: false,
+
+ isNeedMerge: o.isNeedMerge,
+ mergeCols: mergeCols,
+ mergeRule: o.mergeRule,
+
+ columnSize: [""].concat(o.columnSize),
+ headerRowSize: 18,
+ rowSize: o.rowSize,
+
+ regionColumnSize: o.regionColumnSize || [82, ""]
+ });
+
+ if (BI.isNotEmptyArray(o.items)) {
+ this.populate(o.items);
+ }
+ BI.nextTick(function () {
+ self.setRegionColumnSize(o.regionColumnSize || [82, ""]);
+ });
+ },
+
+ resize: function () {
+ this.table.resize();
+ },
+
+ setColumnSize: function (columnSize) {
+ this.table.setColumnSize(columnSize);
+ },
+
+ getColumnSize: function () {
+ return this.table.getColumnSize();
+ },
+
+ getCalculateColumnSize: function () {
+ return this.table.getCalculateColumnSize();
+ },
+
+ setHeaderColumnSize: function (columnSize) {
+ this.table.setHeaderColumnSize(columnSize);
+ },
+
+ setRegionColumnSize: function (columnSize) {
+ this.table.setRegionColumnSize(columnSize);
+ },
+
+ getRegionColumnSize: function () {
+ return this.table.getRegionColumnSize();
+ },
+
+ getCalculateRegionColumnSize: function () {
+ return this.table.getCalculateRegionColumnSize();
+ },
+
+ getCalculateRegionRowSize: function () {
+ return this.table.getCalculateRegionRowSize();
+ },
+
+ getClientRegionColumnSize: function () {
+ return this.table.getClientRegionColumnSize();
+ },
+
+ getScrollRegionColumnSize: function () {
+ return this.table.getScrollRegionColumnSize();
+ },
+
+ getScrollRegionRowSize: function () {
+ return this.table.getScrollRegionRowSize();
+ },
+
+ hasVerticalScroll: function () {
+ return this.table.hasVerticalScroll();
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ this.table.setVerticalScroll(scrollTop);
+ },
+
+ setLeftHorizontalScroll: function (scrollLeft) {
+ this.table.setLeftHorizontalScroll(scrollLeft);
+ },
+
+ setRightHorizontalScroll: function (scrollLeft) {
+ this.table.setRightHorizontalScroll(scrollLeft);
+ },
+
+ getVerticalScroll: function () {
+ return this.table.getVerticalScroll();
+ },
+
+ getLeftHorizontalScroll: function () {
+ return this.table.getLeftHorizontalScroll();
+ },
+
+ getRightHorizontalScroll: function () {
+ return this.table.getRightHorizontalScroll();
+ },
+
+ getColumns: function () {
+ return this.table.getColumns();
+ },
+
+ resizeHeader: function () {
+ this.table.resize();
+ this.table._resizeHeader && this.table._resizeHeader();
+ },
+
+ attr: function (key,value) {
+ var self = this;
+ if (BI.isObject(key)) {
+ BI.each(key, function (k, v) {
+ self.attr(k, v);
+ });
+ return;
+ }
+ BI.ExcelTable.superclass.attr.apply(this, arguments);
+ switch (key){
+ case "mergeCols":
+ var mCols = [];
+ BI.each(value, function (i, col) {
+ mCols.push(col + 1);
+ });
+ value=mCols;
+ break;
+ }
+ this.table.attr.apply(this.table, arguments);
+ },
+
+ populate: function (rows) {
+ var self = this;
+ var columnSize = this.getColumnSize();
+ var items = [];
+ var header = [{
+ type: "bi.excel_table_header_cell"
+ }];
+ if (BI.isNotNull(rows)) {
+ BI.each(columnSize, function (i, size) {
+ header.push({
+ type: "bi.excel_table_header_cell",
+ text: BI.int2Abc(i + 1)
+ });
+ });
+ BI.each(rows, function (i, row) {
+ items.push([{
+ type: "bi.excel_table_header_cell",
+ text: (i + 1)
+ }].concat(row));
+ });
+ }
+ this.table.populate(items, [header]);
+ },
+
+ destroy: function () {
+ this.table.destroy();
+ BI.ExcelTable.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.shortcut('bi.excel_table', BI.ExcelTable);/**
+ * 文件管理控件组
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerButtonGroup
+ * @extends BI.Widget
+ */
+BI.FileManagerButtonGroup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-button_group",
+ items: []
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerButtonGroup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.button_group = BI.createWidget({
+ type: "bi.button_tree",
+ element: this,
+ chooseType: BI.Selection.Multi,
+ items: this._formatItems(o.items),
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _formatItems: function (items) {
+ var self = this, o = this.options;
+ BI.each(items, function (i, item) {
+ if (item.children && item.children.length > 0) {
+ item.type = "bi.file_manager_folder_item";
+ } else {
+ item.type = "bi.file_manager_file_item";
+ }
+ });
+ return items;
+ },
+
+ setValue: function (v) {
+ this.button_group.setValue(v);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getNotSelectedValue: function () {
+ return this.button_group.getNotSelectedValue();
+ },
+
+ getAllLeaves: function () {
+ return this.button_group.getAllLeaves();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ getSelectedButtons: function () {
+ return this.button_group.getSelectedButtons();
+ },
+
+ getNotSelectedButtons: function () {
+ return this.button_group.getNotSelectedButtons();
+ },
+
+ populate: function (items) {
+ this.button_group.populate(this._formatItems(items));
+ }
+});
+BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/**
+ * 文件管理控件
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManager
+ * @extends BI.Widget
+ */
+BI.FileManager = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager",
+ el: {},
+ items: []
+ })
+ },
+
+ _init: function () {
+ BI.FileManager.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.tree = new BI.Tree();
+ var items = BI.Tree.transformToTreeFormat(o.items);
+ this.tree.initTree(items);
+ this.selectedValues = [];
+ this.nav = BI.createWidget({
+ type: "bi.file_manager_nav",
+ items: BI.deepClone(items)
+ });
+ this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) {
+ if (value == "-1") {//根节点
+ self.populate({children: self.tree.toJSON()});
+ } else {
+ var node = self.tree.search(obj.attr("id"));
+ self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)}));
+ }
+ self.setValue(self.selectedValues);
+ });
+ this.list = BI.createWidget(o.el, {
+ type: "bi.file_manager_list",
+ items: items
+ });
+ this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) {
+ if (type === BI.Events.CHANGE) {
+ var node = self.tree.search(obj.attr("id"));
+ self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)}));
+ } else if (type === BI.Events.CLICK) {
+ var values = [];
+ if (obj instanceof BI.MultiSelectBar) {
+ var t = self.list.getValue();
+ selected = t.type === BI.Selection.All;
+ values = BI.concat(t.assist, t.value);
+ } else {
+ values = obj.getAllLeaves();
+ }
+ BI.each(values, function (i, v) {
+ if (selected === true) {
+ self.selectedValues.pushDistinct(v);
+ } else {
+ self.selectedValues.remove(v);
+ }
+ });
+ }
+ self.setValue(self.selectedValues);
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.list,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 10
+ }, {
+ el: this.nav,
+ left: 40,
+ right: 100,
+ top: 0
+ }]
+ });
+ },
+
+ setValue: function (value) {
+ this.selectedValues = value || [];
+ this.list.setValue(this.selectedValues);
+ },
+
+ getValue: function () {
+ var obj = this.list.getValue();
+ var res = obj.type === BI.Selection.All ? obj.assist : obj.value;
+ res.pushDistinctArray(this.selectedValues);
+ return res;
+ },
+
+ _populate: function (items) {
+ this.list.populate(items);
+ },
+
+ getSelectedValue: function () {
+ return this.nav.getValue()[0];
+ },
+
+ getSelectedId: function () {
+ return this.nav.getId()[0];
+ },
+
+ populate: function (node) {
+ var clone = BI.deepClone(node);
+ this._populate(node.children);
+ this.nav.populate(clone);
+ }
+});
+BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE";
+BI.shortcut("bi.file_manager", BI.FileManager);/**
+ * 文件管理控件
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerFileItem
+ * @extends BI.Single
+ */
+BI.FileManagerFileItem = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom",
+ height: 30
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerFileItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checked = BI.createWidget({
+ type: "bi.multi_select_bar",
+ text: "",
+ width: 36,
+ height: o.height
+ });
+ this.checked.on(BI.Controller.EVENT_CHANGE, function () {
+ arguments[2] = self;
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: this.checked,
+ width: 36
+ }, {
+ el: {
+ type: "bi.icon_button",
+ cls: "create-by-me-file-font"
+ },
+ width: 20
+ }, {
+ el: {
+ type: "bi.label",
+ textAlign: "left",
+ height: o.height,
+ text: o.text,
+ value: o.value
+ }
+ }]
+ })
+ },
+
+ getAllLeaves: function(){
+ return [this.options.value];
+ },
+
+ isSelected: function () {
+ return this.checked.isSelected();
+ },
+
+ setSelected: function (v) {
+ this.checked.setSelected(v);
+ }
+});
+BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/**
+ * 文件管理控件
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerFolderItem
+ * @extends BI.Single
+ */
+BI.FileManagerFolderItem = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom",
+ height: 30
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerFolderItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checked = BI.createWidget({
+ type: "bi.multi_select_bar",
+ text: "",
+ width: 36,
+ height: o.height
+ });
+ this.checked.on(BI.Controller.EVENT_CHANGE, function () {
+ arguments[2] = self;
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button = BI.createWidget({
+ type: "bi.text_button",
+ textAlign: "left",
+ height: o.height,
+ text: o.text,
+ value: o.value
+ });
+ this.button.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self);
+ });
+
+ this.tree = new BI.Tree();
+ this.tree.initTree([{
+ id: o.id,
+ children: o.children
+ }]);
+ this.selectValue = [];
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: this.checked,
+ width: 36
+ }, {
+ el: {
+ type: "bi.icon_button",
+ cls: "create-by-me-folder-font"
+ },
+ width: 20
+ }, {
+ el: this.button
+ }]
+ })
+ },
+
+ setAllSelected: function (v) {
+ this.checked.setSelected(v);
+ this.selectValue = [];
+ },
+
+ setHalfSelected: function (v) {
+ this.checked.setHalfSelected(v);
+ if(!v){
+ this.selectValue = [];
+ }
+ },
+
+ setValue: function (v) {
+ var self = this, o = this.options;
+ var isHalf = false;
+ var selectValue = [];
+ this.tree.traverse(function (node) {
+ if (node.isLeaf()) {
+ if (BI.contains(v, node.get("data").value)) {
+ selectValue.push(node.get("data").value);
+ } else {
+ isHalf = true;
+ }
+ }
+ });
+ this.setAllSelected(selectValue.length > 0 && !isHalf);
+ this.setHalfSelected(selectValue.length > 0 && isHalf);
+ if (this.checked.isHalfSelected()) {
+ this.selectValue = selectValue;
+ }
+ },
+
+ getAllButtons: function () {
+ return [this];
+ },
+
+ getAllLeaves: function () {
+ var o = this.options;
+ var res = [];
+ this.tree.traverse(function (node) {
+ if (node.isLeaf()) {
+ res.push(node.get("data").value)
+ }
+ });
+ return res;
+ },
+
+ getNotSelectedValue: function () {
+ var self = this, o = this.options;
+ var res = [];
+ var isAllSelected = this.checked.isSelected();
+ if (isAllSelected === true) {
+ return res;
+ }
+ var isHalfSelected = this.checked.isHalfSelected();
+ this.tree.traverse(function (node) {
+ if (node.isLeaf()) {
+ var v = node.get("data").value;
+ if (isHalfSelected === true) {
+ if (!BI.contains(self.selectValue, node.get("data").value)) {
+ res.push(v);
+ }
+ } else {
+ res.push(v);
+ }
+ }
+ });
+ return res;
+ },
+
+ getValue: function () {
+ var res = [];
+ if (this.checked.isSelected()) {
+ this.tree.traverse(function (node) {
+ if (node.isLeaf()) {
+ res.push(node.get("data").value);
+ }
+ });
+ return res;
+ }
+ if (this.checked.isHalfSelected()) {
+ return this.selectValue;
+ }
+ return [];
+ }
+});
+BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/**
+ * 文件管理控件列表
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerList
+ * @extends BI.Widget
+ */
+BI.FileManagerList = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-list",
+ el: {},
+ items: []
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerList.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.list = BI.createWidget({
+ type: "bi.select_list",
+ element: this,
+ items: o.items,
+ toolbar: {
+ type: "bi.multi_select_bar",
+ height: 40,
+ text: ""
+ },
+ el: {
+ type: "bi.list_pane",
+ el: BI.isWidget(o.el) ? o.el : BI.extend({
+ type: "bi.file_manager_button_group"
+ }, o.el)
+ }
+ });
+ this.list.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ },
+
+ setValue: function (v) {
+ this.list.setValue({
+ value: v
+ });
+ },
+
+ getValue: function () {
+ return this.list.getValue();
+ },
+
+ populate: function (items) {
+ this.list.populate(items);
+ this.list.setToolBarVisible(true);
+ }
+});
+BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_list", BI.FileManagerList);/**
+ * 文件管理导航按钮
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerNavButton
+ * @extends BI.Widget
+ */
+BI.FileManagerNavButton = BI.inherit(BI.Widget, {
+
+ _const: {
+ normal_color: "#ffffff",
+ select_color: "#f4f4f4"
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-nav-button",
+ selected: false,
+ height: 40
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerNavButton.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.button = BI.createWidget({
+ type: "bi.text_button",
+ cls: "file-manager-nav-button-text bi-card",
+ once: true,
+ selected: o.selected,
+ text: o.text,
+ title: o.text,
+ value: o.value,
+ height: o.height,
+ lgap: 20,
+ rgap: 10
+ });
+ this.button.on(BI.Controller.EVENT_CHANGE, function () {
+ arguments[2] = self;
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ var svg = BI.createWidget({
+ type: "bi.svg",
+ cls: "file-manager-nav-button-triangle",
+ width: 15,
+ height: o.height
+ });
+ var path = svg.path("M0,0L15,20L0,40").attr({
+ "stroke": c.select_color,
+ "fill": o.selected ? c.select_color : c.normal_color
+ });
+ this.button.on(BI.TextButton.EVENT_CHANGE, function () {
+ if (this.isSelected()) {
+ path.attr("fill", c.select_color);
+ } else {
+ path.attr("fill", c.normal_color);
+ }
+ });
+ BI.createWidget({
+ type: "bi.default",
+ element: this,
+ items: [this.button]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: svg,
+ right: -15,
+ top: 0,
+ bottom: 0
+ }]
+ })
+ },
+
+ isSelected: function () {
+ return this.button.isSelected();
+ },
+
+ setValue: function (v) {
+ this.button.setValue(v);
+ },
+
+ getValue: function () {
+ return this.button.getValue();
+ },
+
+ populate: function (items) {
+
+ }
+});
+BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/**
+ * 文件管理导航
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerNav
+ * @extends BI.Widget
+ */
+BI.FileManagerNav = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-nav bi-border-left",
+ height: 40,
+ items: []
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerNav.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.tree = new BI.Tree();
+ this.refreshTreeData(o.items);
+ this.tree.getRoot().set("data", {
+ text: BI.i18nText("BI-Created_By_Me"),
+ value: BI.FileManagerNav.ROOT_CREATE_BY_ME,
+ id: BI.FileManagerNav.ROOT_CREATE_BY_ME
+ });
+ this.button_group = BI.createWidget({
+ type: "bi.button_group",
+ element: this,
+ items: [{
+ type: "bi.file_manager_nav_button",
+ text: BI.i18nText("BI-Created_By_Me"),
+ selected: true,
+ id: BI.FileManagerNav.ROOT_CREATE_BY_ME,
+ value: BI.FileManagerNav.ROOT_CREATE_BY_ME
+ }],
+ layouts: [{
+ type: "bi.horizontal"
+ }]
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) {
+ self.fireEvent(BI.FileManagerNav.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _getAllParents: function (id) {
+ var node, res = [];
+ if (!id) {
+ node = this.tree.getRoot();
+ } else {
+ node = this.tree.search(id);
+ }
+ while (node.parent) {
+ res.push(node);
+ node = node.parent;
+ }
+ res.push(node);
+ return res.reverse();
+ },
+
+ _formatNodes: function (nodes) {
+ var res = [];
+ BI.each(nodes, function (i, node) {
+ res.push(BI.extend({
+ type: "bi.file_manager_nav_button",
+ id: node.id
+ }, node.get("data")));
+ });
+ BI.last(res).selected = true;
+ return res;
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getId: function () {
+ var ids = [];
+ BI.each(this.button_group.getSelectedButtons(), function (i, btn) {
+ ids.push(btn.attr("id"));
+ });
+ return ids;
+ },
+
+ refreshTreeData: function(items){
+ this.tree.initTree(BI.Tree.transformToTreeFormat(items));
+ this.tree.getRoot().set("data", {
+ text: BI.i18nText("BI-Created_By_Me"),
+ value: BI.FileManagerNav.ROOT_CREATE_BY_ME,
+ id: BI.FileManagerNav.ROOT_CREATE_BY_ME
+ });
+ },
+
+ populate: function (node) {
+ var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id);
+ this.button_group.populate(this._formatNodes(parents));
+ }
+});
+BI.extend(BI.FileManagerNav, {
+ ROOT_CREATE_BY_ME: "-1"
+});
+BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/**
+ * Created by windy on 2017/3/13.
+ * 数值微调器
+ */
+BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-fine-tuning-number-editor bi-border",
+ value: -1
+ })
+ },
+
+ _init: function () {
+ BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ value: this._alertInEditorValue(o.value),
+ errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
+ validationChecker: function(v){
+ return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1;
+ }
+ });
+ this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
+ self._finetuning(0);
+ self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
+ });
+ this.topBtn = BI.createWidget({
+ type: "bi.icon_button",
+ trigger: "lclick,",
+ cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
+ });
+ this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
+ self._finetuning(1);
+ self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
+ });
+ this.bottomBtn = BI.createWidget({
+ type: "bi.icon_button",
+ trigger: "lclick,",
+ cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
+ });
+ this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
+ self._finetuning(-1);
+ self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
+ });
+ this._finetuning(0);
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [this.editor, {
+ el: {
+ type: "bi.grid",
+ columns: 1,
+ rows: 2,
+ items: [{
+ column: 0,
+ row: 0,
+ el: this.topBtn
+ }, {
+ column: 0,
+ row: 1,
+ el: this.bottomBtn
+ }]
+ },
+ width: 30
+ }]
+ });
+ },
+
+ _alertOutEditorValue: function(v){
+ return v === BI.i18nText("BI-Basic_Auto") ? -1 : v;
+ },
+
+ _alertInEditorValue: function(v){
+ return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v;
+ },
+
+ //微调
+ _finetuning: function(add){
+ var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
+ this.editor.setValue(this._alertInEditorValue(v + add));
+ this.bottomBtn.setEnable((v + add) > -1);
+ },
+
+ getValue: function () {
+ var v = this.editor.getValue();
+ return this._alertOutEditorValue(v);
+ },
+
+ setValue: function (v) {
+ this.editor.setValue(this._alertInEditorValue(v));
+ this._finetuning(0);
+ }
+
+});
+BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/**
+ * 交互行为布局
+ *
+ *
+ * Created by GUY on 2016/7/23.
+ * @class BI.InteractiveArrangement
+ * @extends BI.Widget
+ */
+BI.InteractiveArrangement = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-interactive-arrangement",
+ resizable: true,
+ layoutType: BI.Arrangement.LAYOUT_TYPE.GRID,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.InteractiveArrangement.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.arrangement = BI.createWidget({
+ type: "bi.adaptive_arrangement",
+ element: this,
+ resizable: o.resizable,
+ layoutType: o.layoutType,
+ items: o.items
+ });
+ this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL, function () {
+ self.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL, arguments);
+ });
+ this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE, function () {
+ self.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE, arguments);
+ });
+
+ this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, function (id, size) {
+ var p = self._getRegionClientPosition(id);
+ self.draw({
+ left: p.left,
+ top: p.top
+ }, size, id);
+ });
+ this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, function (id, size) {
+ self.stopDraw();
+ self.setRegionSize(id, size);
+ });
+
+ this.tags = [];
+
+ },
+
+ _isEqual: function (num1, num2) {
+ return this.arrangement._isEqual(num1, num2);
+ },
+
+ _getScrollOffset: function () {
+ return this.arrangement._getScrollOffset();
+ },
+
+ _positionAt: function (position, regions) {
+ var self = this;
+ regions = regions || this.getAllRegions();
+ var left = [], center = [], right = [], top = [], middle = [], bottom = [];
+ BI.each(regions, function (i, region) {
+ var client = self._getRegionClientPosition(region.id);
+ if (Math.abs(client.left - position.left) <= 3) {
+ left.push(region);
+ }
+ if (Math.abs(client.left + client.width / 2 - position.left) <= 3) {
+ center.push(region);
+ }
+ if (Math.abs(client.left + client.width - position.left) <= 3) {
+ right.push(region);
+ }
+ if (Math.abs(client.top - position.top) <= 3) {
+ top.push(region);
+ }
+ if (Math.abs(client.top + client.height / 2 - position.top) <= 3) {
+ middle.push(region);
+ }
+ if (Math.abs(client.top + client.height - position.top) <= 3) {
+ bottom.push(region);
+ }
+ });
+ return {
+ left: left,
+ center: center,
+ right: right,
+ top: top,
+ middle: middle,
+ bottom: bottom
+ }
+ },
+
+ _getRegionClientPosition: function (name) {
+ var region = this.getRegionByName(name);
+ var offset = this.arrangement._getScrollOffset();
+ return {
+ top: region.top - offset.top,
+ left: region.left - offset.left,
+ width: region.width,
+ height: region.height,
+ id: region.id
+ }
+ },
+
+ _vAlign: function (position, regions) {
+ var self = this;
+ var vs = this._positionAt(position, regions);
+ var positions = [];
+ var l;
+ if (vs.left.length > 0) {
+ l = this._getRegionClientPosition(vs.left[0].id).left;
+ } else if (vs.right.length > 0) {
+ var temp = this._getRegionClientPosition(vs.right[0].id);
+ l = temp.left + temp.width;
+ }
+ var rs = vs.left.concat(vs.right);
+ BI.each(rs, function (i, region) {
+ var p = self._getRegionClientPosition(region.id);
+ if (self._isEqual(p.left, l) || self._isEqual(p.left + p.width, l)) {
+ var topPoint = {
+ top: p.top + p.height / 2,
+ left: l
+ };
+ positions.push({
+ id: region.id,
+ start: topPoint,
+ end: {
+ left: l,
+ top: position.top
+ }
+ });
+ }
+ });
+ return positions;
+ },
+
+ _leftAlign: function (position, size, regions) {
+ var self = this;
+ return this._vAlign({
+ left: position.left,
+ top: position.top + size.height / 2
+ }, regions);
+ },
+
+ _rightAlign: function (position, size, regions) {
+ var self = this;
+ return this._vAlign({
+ left: position.left + size.width,
+ top: position.top + size.height / 2
+ }, regions);
+ },
+
+ _hAlign: function (position, regions) {
+ var self = this;
+ var hs = this._positionAt(position, regions);
+ var positions = [];
+ var t;
+ if (hs.top.length > 0) {
+ var temp = this._getRegionClientPosition(hs.top[0].id);
+ t = temp.top;
+ } else if (hs.bottom.length > 0) {
+ var temp = this._getRegionClientPosition(hs.bottom[0].id);
+ t = temp.top + temp.height;
+ }
+ var rs = hs.top.concat(hs.bottom);
+ BI.each(rs, function (i, region) {
+ var p = self._getRegionClientPosition(region.id);
+ if (self._isEqual(p.top, t) || self._isEqual(p.top + p.height, t)) {
+ var leftPoint = {
+ top: t,
+ left: p.left + p.width / 2
+ };
+ positions.push({
+ id: p.id,
+ start: leftPoint,
+ end: {
+ left: position.left,
+ top: t
+ }
+ });
+ }
+ });
+ return positions;
+ },
+
+ _topAlign: function (position, size, regions) {
+ var self = this;
+ return this._hAlign({
+ left: position.left + size.width / 2,
+ top: position.top
+ }, regions);
+ },
+
+ _bottomAlign: function (position, size, regions) {
+ var self = this;
+ return this._hAlign({
+ left: position.left + size.width / 2,
+ top: position.top + size.height
+ }, regions);
+ },
+
+ _centerAlign: function (position, size, regions) {
+ var self = this;
+ var cs = this._positionAt({
+ left: position.left + size.width / 2,
+ top: position.top + size.height / 2
+ }, regions);
+ var positions = [];
+ var l;
+ if (cs.center.length > 0) {
+ var temp = this._getRegionClientPosition(cs.center[0].id);
+ l = temp.left + temp.width / 2;
+ }
+ BI.each(cs.center, function (i, region) {
+ var p = self._getRegionClientPosition(region.id);
+ if (self._isEqual(p.left + p.width / 2, l)) {
+ var topPoint = {
+ top: p.top + p.height / 2,
+ left: p.left + p.width / 2
+ };
+ positions.push({
+ id: p.id,
+ start: topPoint,
+ end: {
+ left: l,
+ top: position.top + size.height / 2
+ }
+ });
+ }
+ });
+ return positions;
+ },
+
+ _middleAlign: function (position, size, regions) {
+ var self = this;
+ var cs = this._positionAt({
+ left: position.left + size.width / 2,
+ top: position.top + size.height / 2
+ }, regions);
+ var positions = [];
+ var t;
+ if (cs.middle.length > 0) {
+ var temp = this._getRegionClientPosition(cs.middle[0].id);
+ t = temp.top + temp.height / 2;
+ }
+ BI.each(cs.middle, function (i, region) {
+ var p = self._getRegionClientPosition(region.id);
+ if (self._isEqual(p.top + p.height / 2, t)) {
+ var topPoint = {
+ top: p.top + p.height / 2,
+ left: p.left + p.width / 2
+ };
+ positions.push({
+ id: p.id,
+ start: topPoint,
+ end: {
+ left: position.left + size.width / 2,
+ top: t
+ }
+ });
+ }
+ });
+ return positions;
+ },
+
+
+ _drawOneTag: function (start, end) {
+ var s = BI.createWidget({
+ type: "bi.icon_button",
+ //invisible: true,
+ width: 13,
+ height: 13,
+ cls: "drag-tag-font interactive-arrangement-dragtag-icon"
+ });
+ var e = BI.createWidget({
+ type: "bi.icon_button",
+ //invisible: true,
+ width: 13,
+ height: 13,
+ cls: "drag-tag-font interactive-arrangement-dragtag-icon"
+ });
+ if (this._isEqual(start.left, end.left)) {
+ var line = BI.createWidget({
+ type: "bi.layout",
+ //invisible: true,
+ cls: "interactive-arrangement-dragtag-line",
+ width: 1,
+ height: Math.abs(start.top - end.top)
+ });
+ } else {
+ var line = BI.createWidget({
+ type: "bi.layout",
+ //invisible: true,
+ cls: "interactive-arrangement-dragtag-line",
+ height: 1,
+ width: Math.abs(start.left - end.left)
+ });
+ }
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: s,
+ left: start.left - 6,
+ top: start.top - 7
+ }, {
+ el: e,
+ left: end.left - 6,
+ top: end.top - 7
+ }, {
+ el: line,
+ left: Math.min(start.left, end.left),
+ top: Math.min(start.top, end.top)
+ }]
+ });
+ this.tags.push(s);
+ this.tags.push(e);
+ this.tags.push(line);
+ },
+
+ stopDraw: function () {
+ BI.each(this.tags, function (i, w) {
+ w.destroy();
+ });
+ this.tags = [];
+ },
+
+ _getRegionExcept: function (name, regions) {
+ var other = [];
+ BI.each(regions || this.getAllRegions(), function (i, region) {
+ if (!(name && region.id === name)) {
+ other.push(region);
+ }
+ });
+ return other;
+ },
+
+ getClientWidth: function () {
+ return this.arrangement.getClientWidth();
+ },
+
+ getClientHeight: function () {
+ return this.arrangement.getClientHeight();
+ },
+
+ getPosition: function (name, position, size) {
+ var regions = this.getAllRegions();
+ var me;
+ if (name) {
+ me = this._getRegionClientPosition(name);
+ }
+ var other = this._getRegionExcept(name, regions);
+ position = position || {
+ left: me.left,
+ top: me.top
+ };
+ size = size || {
+ width: me.width,
+ height: me.height
+ };
+ var left = this._leftAlign(position, size, other);
+ var right = this._rightAlign(position, size, other);
+ var top = this._topAlign(position, size, other, other);
+ var bottom = this._bottomAlign(position, size, other);
+ var center = this._centerAlign(position, size, other);
+ var middle = this._middleAlign(position, size, other);
+
+ BI.each(center, function (i, pos) {
+ position.left = pos.end.left - size.width / 2;
+ });
+ BI.each(right, function (i, pos) {
+ position.left = pos.end.left - size.width;
+ });
+ BI.each(left, function (i, pos) {
+ position.left = pos.end.left;
+ });
+ BI.each(middle, function (i, pos) {
+ position.top = pos.end.top - size.height / 2;
+ });
+ BI.each(bottom, function (i, pos) {
+ position.top = pos.end.top - size.height;
+ });
+ BI.each(top, function (i, pos) {
+ position.top = pos.end.top;
+ });
+ return position;
+ },
+
+ //position不动 变size
+ getSize: function (name, position, size) {
+ var regions = this.getAllRegions();
+ var me;
+ if (name) {
+ me = this._getRegionClientPosition(name);
+ }
+ var other = this._getRegionExcept(name, regions);
+ position = position || {
+ left: me.left,
+ top: me.top
+ };
+ size = size || {
+ width: me.width,
+ height: me.height
+ };
+ var left = this._leftAlign(position, size, other);
+ var right = this._rightAlign(position, size, other);
+ var top = this._topAlign(position, size, other, other);
+ var bottom = this._bottomAlign(position, size, other);
+ var center = this._centerAlign(position, size, other);
+ var middle = this._middleAlign(position, size, other);
+
+ BI.each(center, function (i, pos) {
+ size.width = (pos.end.left - position.left) * 2;
+ });
+ BI.each(right, function (i, pos) {
+ size.width = pos.end.left - position.left;
+ });
+ BI.each(left, function (i, pos) {
+ });
+ BI.each(middle, function (i, pos) {
+ size.height = (pos.end.top - position.top) * 2;
+ });
+ BI.each(bottom, function (i, pos) {
+ size.height = pos.end.top - position.top;
+ });
+ BI.each(top, function (i, pos) {
+ });
+ return size;
+ },
+
+ draw: function (position, size, name) {
+ var self = this;
+ this.stopDraw();
+ switch (this.getLayoutType()) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ var other = this._getRegionExcept(name);
+ var left = this._leftAlign(position, size, other);
+ var right = this._rightAlign(position, size, other);
+ var top = this._topAlign(position, size, other);
+ var bottom = this._bottomAlign(position, size, other);
+ var center = this._centerAlign(position, size, other);
+ var middle = this._middleAlign(position, size, other);
+
+ BI.each(center, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ BI.each(right, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ BI.each(left, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ BI.each(middle, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ BI.each(bottom, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ BI.each(top, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ break;
+ }
+ },
+
+ addRegion: function (region, position) {
+ this.stopDraw();
+ return this.arrangement.addRegion(region, position);
+ },
+
+ deleteRegion: function (name) {
+ return this.arrangement.deleteRegion(name);
+ },
+
+ setRegionSize: function (name, size) {
+ size = this.getSize(name, null, size);
+ return this.arrangement.setRegionSize(name, size);
+ },
+
+ setPosition: function (position, size) {
+ var self = this;
+ this.stopDraw();
+ if (position.left > 0 && position.top > 0) {
+ switch (this.getLayoutType()) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ position = this.getPosition(null, position, size);
+ this.draw(position, size);
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ break;
+ }
+ }
+ var at = this.arrangement.setPosition(position, size);
+ return at;
+ },
+
+ setRegionPosition: function (name, position) {
+ if (position.left > 0 && position.top > 0) {
+ switch (this.getLayoutType()) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ position = this.getPosition(name, position);
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ break;
+ }
+ }
+ return this.arrangement.setRegionPosition(name, position);
+ },
+
+ setDropPosition: function (position, size) {
+ var self = this;
+ this.stopDraw();
+ if (position.left > 0 && position.top > 0) {
+ switch (this.getLayoutType()) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ position = this.getPosition(null, position, size);
+ this.draw(position, size);
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ break;
+ }
+ }
+ var callback = self.arrangement.setDropPosition(position, size);
+ return function () {
+ callback();
+ self.stopDraw();
+ }
+ },
+
+ scrollInterval: function () {
+ this.arrangement.scrollInterval.apply(this.arrangement, arguments);
+ },
+
+ scrollEnd: function () {
+ this.arrangement.scrollEnd.apply(this.arrangement, arguments);
+ },
+
+ scrollTo: function (scroll) {
+ this.arrangement.scrollTo(scroll);
+ },
+
+ zoom: function (ratio) {
+ this.arrangement.zoom(ratio);
+ },
+
+ resize: function () {
+ return this.arrangement.resize();
+ },
+
+ relayout: function () {
+ return this.arrangement.relayout();
+ },
+
+ setLayoutType: function (type) {
+ this.arrangement.setLayoutType(type);
+ },
+
+ getLayoutType: function () {
+ return this.arrangement.getLayoutType();
+ },
+
+ getLayoutRatio: function () {
+ return this.arrangement.getLayoutRatio();
+ },
+
+ getHelper: function () {
+ return this.arrangement.getHelper();
+ },
+
+ getRegionByName: function (name) {
+ return this.arrangement.getRegionByName(name);
+ },
+
+ getAllRegions: function () {
+ return this.arrangement.getAllRegions();
+ },
+
+ revoke: function () {
+ return this.arrangement.revoke();
+ },
+
+ populate: function (items) {
+ var self = this;
+ this.arrangement.populate(items);
+ }
+});
+BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE";
+BI.InteractiveArrangement.EVENT_SCROLL = "InteractiveArrangement.EVENT_SCROLL";
+BI.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/**
+ * Created by zcf on 2016/9/26.
+ * Make some change by dailer on 2017/7/17
+ */
+BI.IntervalSlider = BI.inherit(BI.Widget, {
+ _constant: {
+ EDITOR_WIDTH: 58,
+ EDITOR_R_GAP: 60,
+ EDITOR_HEIGHT: 30,
+ HEIGHT: 28,
+ SLIDER_WIDTH_HALF: 15,
+ SLIDER_WIDTH: 30,
+ SLIDER_HEIGHT: 30,
+ TRACK_HEIGHT: 24
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.IntervalSlider.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-slider bi-slider-track"
+ })
+ },
+
+ _init: function () {
+ BI.IntervalSlider.superclass._init.apply(this, arguments);
+
+ var self = this;
+ var c = this._constant;
+ this.enable = false;
+ this.valueOne = "";
+ this.valueTwo = "";
+ this.calculation = new BI.AccurateCalculationModel();
+
+ this.backgroundTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "background-track",
+ height: c.TRACK_HEIGHT
+ });
+ this.grayTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "gray-track",
+ height: 8
+ });
+ this.blueTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "blue-track bi-high-light-background",
+ height: 8
+ });
+ this.track = this._createTrackWrapper();
+
+ this.labelOne = BI.createWidget({
+ type: "bi.sign_editor",
+ cls: "slider-editor-button",
+ errorText: "",
+ allowBlank: false,
+ height: c.HEIGHT,
+ width: c.EDITOR_WIDTH,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () {
+ var v = BI.parseFloat(this.getValue());
+ self.valueOne = v;
+ var percent = self._getPercentByValue(v);
+ var significantPercent = BI.parseFloat(percent.toFixed(1)); //分成1000份
+ self._setLabelOnePosition(significantPercent);
+ self._setSliderOnePosition(significantPercent);
+ self._setBlueTrack();
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ });
+ this.labelOne.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.labelOne.element.addClass("bi-border");
+ });
+ this.labelOne.on(BI.SignEditor.EVENT_BLUR, function () {
+ self.labelOne.element.removeClass("bi-border");
+ });
+
+ this.labelTwo = BI.createWidget({
+ type: "bi.sign_editor",
+ cls: "slider-editor-button",
+ errorText: "",
+ allowBlank: false,
+ height: c.HEIGHT,
+ width: c.EDITOR_WIDTH,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () {
+ var v = BI.parseFloat(this.getValue());
+ self.valueTwo = v;
+ var percent = self._getPercentByValue(v);
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setLabelTwoPosition(significantPercent);
+ self._setSliderTwoPosition(significantPercent);
+ self._setBlueTrack();
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ });
+ this.labelTwo.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.labelTwo.element.addClass("bi-border");
+ });
+ this.labelTwo.on(BI.SignEditor.EVENT_BLUR, function () {
+ self.labelTwo.element.removeClass("bi-border");
+ });
+
+ this.sliderOne = BI.createWidget({
+ type: "bi.single_slider_slider"
+ });
+ this.sliderOne.element.draggable({
+ axis: "x",
+ containment: this.grayTrack.element,
+ scroll: false,
+ drag: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setLabelOnePosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.labelOne.setValue(v);
+ self.valueOne = v;
+ self._setBlueTrack();
+ },
+ stop: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderOnePosition(significantPercent);
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ }
+ });
+
+ this.sliderTwo = BI.createWidget({
+ type: "bi.single_slider_slider"
+ });
+ this.sliderTwo.element.draggable({
+ axis: "x",
+ containment: this.grayTrack.element,
+ scroll: false,
+ drag: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setLabelTwoPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.labelTwo.setValue(v);
+ self.valueTwo = v;
+ self._setBlueTrack();
+ },
+ stop: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderTwoPosition(significantPercent);
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ }
+ });
+ this._setVisible(false);
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.track,
+ width: "100%",
+ height: c.TRACK_HEIGHT
+ }]
+ }],
+ hgap: 7,
+ height: c.TRACK_HEIGHT
+ },
+ top: 33,
+ left: 0,
+ width: "100%"
+ },
+ this._createLabelWrapper(),
+ this._createSliderWrapper()
+ ]
+ })
+ },
+
+ _createLabelWrapper: function () {
+ var c = this._constant;
+ return {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.labelOne,
+ top: 0,
+ left: "0%"
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: this.labelTwo,
+ top: 0,
+ left: "100%"
+ }]
+ }],
+ rgap: c.EDITOR_R_GAP,
+ height: 90
+ },
+ top: 0,
+ left: 0,
+ width: "100%"
+ }
+ },
+
+ _createSliderWrapper: function () {
+ var c = this._constant;
+ return {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.sliderOne,
+ top: 0,
+ left: "0%"
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: this.sliderTwo,
+ top: 0,
+ left: "100%"
+ }]
+ }],
+ hgap: c.SLIDER_WIDTH_HALF,
+ height: c.SLIDER_HEIGHT
+ },
+ top: 30,
+ left: 0,
+ width: "100%"
+ }
+ },
+
+ _createTrackWrapper: function () {
+ return BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: this.backgroundTrack,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.grayTrack,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }, {
+ el: this.blueTrack,
+ top: 0,
+ left: 0,
+ width: "0%"
+ }]
+ }],
+ hgap: 8,
+ height: 8
+ },
+ top: 8,
+ left: 0,
+ width: "100%"
+ }]
+ })
+ },
+
+ _checkValidation: function (v) {
+ return BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)
+ },
+
+ _checkOverlap: function () {
+ var labelOneLeft = this.labelOne.element[0].offsetLeft;
+ var labelTwoLeft = this.labelTwo.element[0].offsetLeft;
+ if (labelOneLeft <= labelTwoLeft) {
+ if ((labelTwoLeft - labelOneLeft) < 90) {
+ this.labelTwo.element.css({
+ "top": 60
+ });
+ } else {
+ this.labelTwo.element.css({
+ "top": 0
+ });
+ }
+ } else {
+ if ((labelOneLeft - labelTwoLeft) < 90) {
+ this.labelTwo.element.css({
+ "top": 60
+ });
+ } else {
+ this.labelTwo.element.css({
+ "top": 0
+ });
+ }
+ }
+ },
+
+ _setLabelOnePosition: function (percent) {
+ this.labelOne.element.css({
+ "left": percent + "%"
+ });
+ this._checkOverlap();
+ },
+
+ _setLabelTwoPosition: function (percent) {
+ this.labelTwo.element.css({
+ "left": percent + "%"
+ });
+ this._checkOverlap();
+ },
+
+ _setSliderOnePosition: function (percent) {
+ this.sliderOne.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setSliderTwoPosition: function (percent) {
+ this.sliderTwo.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setBlueTrackLeft: function (percent) {
+ this.blueTrack.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setBlueTrackWidth: function (percent) {
+ this.blueTrack.element.css({
+ "width": percent + "%"
+ });
+ },
+
+ _setBlueTrack: function () {
+ var percentOne = this._getPercentByValue(this.labelOne.getValue());
+ var percentTwo = this._getPercentByValue(this.labelTwo.getValue());
+ if (percentOne <= percentTwo) {
+ this._setBlueTrackLeft(percentOne);
+ this._setBlueTrackWidth(percentTwo - percentOne);
+ } else {
+ this._setBlueTrackLeft(percentTwo);
+ this._setBlueTrackWidth(percentOne - percentTwo);
+ }
+ },
+
+ _setAllPosition: function (one, two) {
+ this._setSliderOnePosition(one);
+ this._setLabelOnePosition(one);
+ this._setSliderTwoPosition(two);
+ this._setLabelTwoPosition(two);
+ this._setBlueTrack();
+ },
+
+ _setVisible: function (visible) {
+ this.sliderOne.setVisible(visible);
+ this.sliderTwo.setVisible(visible);
+ this.labelOne.setVisible(visible);
+ this.labelTwo.setVisible(visible);
+ },
+
+ _setErrorText: function () {
+ var errorText = BI.i18nText("BI-Please_Enter") + this.min + "-" + this.max + BI.i18nText("BI-Basic_De") + BI.i18nText("BI-Basic_Number");
+ this.labelOne.setErrorText(errorText);
+ this.labelTwo.setErrorText(errorText);
+ },
+
+ _getGrayTrackLength: function () {
+ return this.grayTrack.element[0].scrollWidth
+ },
+
+ //其中取max-min后保留4为有效数字后的值的小数位数为最终value的精度
+ _getValueByPercent: function (percent) { //return (((max-min)*percent)/100+min)
+ var sub = this.calculation.accurateSubtraction(this.max, this.min);
+ var mul = this.calculation.accurateMultiplication(sub, percent);
+ var div = this.calculation.accurateDivisionTenExponent(mul, 2);
+ if (this.precision >= 0) {
+ return BI.parseFloat(this.calculation.accurateAddition(div, this.min).toFixed(this.precision));
+ } else {
+ return BI.parseFloat(this.calculation.accurateAddition(div, this.min) - this.calculation.accurateAddition(div, this.min) % (Math.pow(10, (-1) * this.precision)));
+ }
+ },
+
+ _getPercentByValue: function (v) {
+ return (v - this.min) * 100 / (this.max - this.min);
+ },
+
+ _setDraggableEnable: function (enable) {
+ if (enable) {
+ this.sliderOne.element.draggable("enable");
+ this.sliderTwo.element.draggable("enable")
+ } else {
+ this.sliderOne.element.draggable("disable");
+ this.sliderTwo.element.draggable("disable")
+ }
+ },
+
+
+ getValue: function () {
+ if (this.valueOne <= this.valueTwo) {
+ return {
+ min: this.valueOne,
+ max: this.valueTwo
+ }
+ } else {
+ return {
+ min: this.valueTwo,
+ max: this.valueOne
+ }
+ }
+ },
+
+ setMinAndMax: function (v) {
+ var minNumber = BI.parseFloat(v.min);
+ var maxNumber = BI.parseFloat(v.max);
+ if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber >= minNumber)) {
+ this.min = minNumber;
+ this.max = maxNumber;
+ this.valueOne = minNumber;
+ this.valueTwo = maxNumber;
+ //计算每一份值的精度(最大值和最小值的差值保留4为有效数字后的精度)
+ //如果差值的整数位数大于4,toPrecision得到的是科学计数法1234 => 1.2e+3
+ var sub = this.calculation.accurateSubtraction(this.max, this.min);
+ var pre = sub.toPrecision(4);
+ if(pre.indexOf("e") > -1 ){
+ this.precision = 3 - pre.charAt(pre.length - 1);
+ }else{
+ var arr = pre.split(".");
+ if(arr.length>1){
+ this.precision = arr[1].length;
+ }else{
+ this.precision=0;
+ }
+ }
+ this._setDraggableEnable(true);
+ }
+ if (maxNumber === minNumber) {
+ this._setDraggableEnable(false);
+ }
+ },
+
+ setValue: function (v) {
+ var valueOne = BI.parseFloat(v.min);
+ var valueTwo = BI.parseFloat(v.max);
+ if (!isNaN(valueOne) && !isNaN(valueTwo)) {
+ if (this._checkValidation(valueOne)) {
+ this.valueOne = valueOne;
+ }
+ if (this._checkValidation(valueTwo)) {
+ this.valueTwo = valueTwo;
+ }
+ if (valueOne < this.min) {
+ this.valueOne = this.min;
+ }
+ if (valueTwo > this.max) {
+ this.valueTwo = this.max;
+ }
+ }
+ },
+
+ reset: function () {
+ this._setVisible(false);
+ this.enable = false;
+ this.valueOne = "";
+ this.valueTwo = "";
+ this.min = NaN;
+ this.max = NaN;
+ this._setBlueTrackWidth(0);
+ },
+
+ populate: function () {
+ if (!isNaN(this.min) && !isNaN(this.max)) {
+ this.enable = true;
+ this._setVisible(true);
+ this._setErrorText();
+ if ((BI.isNumeric(this.valueOne) || BI.isNotEmptyString(this.valueOne)) && (BI.isNumeric(this.valueTwo) || BI.isNotEmptyString(this.valueTwo))) {
+ this.labelOne.setValue(this.valueOne);
+ this.labelTwo.setValue(this.valueTwo);
+ this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo));
+ } else {
+ this.labelOne.setValue(this.min);
+ this.labelTwo.setValue(this.max);
+ this._setAllPosition(0, 100)
+ }
+ }
+ }
+});
+BI.IntervalSlider.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.interval_slider", BI.IntervalSlider);/**
+ * Created by zcf on 2017/3/1.
+ * 万恶的IEEE-754
+ * 使用字符串精确计算含小数加法、减法、乘法和10的指数倍除法,支持负数
+ */
+BI.AccurateCalculationModel = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.AccurateCalculationModel.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: ""
+ })
+ },
+
+ _init: function () {
+ BI.AccurateCalculationModel.superclass._init.apply(this, arguments);
+ },
+
+ _getMagnitude: function (n) {
+ var magnitude = "1";
+ for (var i = 0; i < n; i++) {
+ magnitude += "0";
+ }
+ return BI.parseInt(magnitude);
+ },
+
+ _formatDecimal: function (stringNumber1, stringNumber2) {
+ if (stringNumber1.numDecimalLength === stringNumber2.numDecimalLength) {
+ return;
+ }
+ var magnitudeDiff = stringNumber1.numDecimalLength - stringNumber2.numDecimalLength;
+ if (magnitudeDiff > 0) {
+ var needAddZero = stringNumber2
+ } else {
+ var needAddZero = stringNumber1;
+ magnitudeDiff = (0 - magnitudeDiff);
+ }
+ for (var i = 0; i < magnitudeDiff; i++) {
+ if (needAddZero.numDecimal === "0" && i === 0) {
+ continue
+ }
+ needAddZero.numDecimal += "0"
+ }
+ },
+
+ _stringNumberFactory: function (num) {
+ var strNum = num.toString();
+ var numStrArray = strNum.split(".");
+ var numInteger = numStrArray[0];
+ if (numStrArray.length === 1) {
+ var numDecimal = "0";
+ var numDecimalLength = 0;
+ } else {
+ var numDecimal = numStrArray[1];
+ var numDecimalLength = numStrArray[1].length;
+ }
+ return {
+ "numInteger": numInteger,
+ "numDecimal": numDecimal,
+ "numDecimalLength": numDecimalLength
+ }
+ },
+
+ _accurateSubtraction: function (num1, num2) {//num1-num2 && num1>num2
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ //整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) - BI.parseInt(stringNumber2.numInteger);
+ //小数部分
+ this._formatDecimal(stringNumber1, stringNumber2);
+ var decimalMaxLength = getDecimalMaxLength(stringNumber1, stringNumber2);
+
+ if (BI.parseInt(stringNumber1.numDecimal) >= BI.parseInt(stringNumber2.numDecimal)) {
+ var decimalResultTemp = (BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
+ var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
+ } else {//否则借位
+ integerResult--;
+ var borrow = this._getMagnitude(decimalMaxLength);
+ var decimalResultTemp = (borrow + BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
+ var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
+ }
+ var result = integerResult + "." + decimalResult;
+ return BI.parseFloat(result);
+
+ function getDecimalMaxLength(num1, num2) {
+ if (num1.numDecimal.length >= num2.numDecimal.length) {
+ return num1.numDecimal.length
+ }
+ return num2.numDecimal.length
+ }
+
+ function addZero(resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp
+ }
+ },
+
+ _accurateAddition: function (num1, num2) {//加法结合律
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ //整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) + BI.parseInt(stringNumber2.numInteger);
+ //小数部分
+ this._formatDecimal(stringNumber1, stringNumber2);
+
+ var decimalResult = (BI.parseInt(stringNumber1.numDecimal) + BI.parseInt(stringNumber2.numDecimal)).toString();
+
+ if (decimalResult !== "0") {
+ if (decimalResult.length <= stringNumber1.numDecimal.length) {
+ decimalResult = addZero(decimalResult, stringNumber1.numDecimal.length)
+ } else {
+ integerResult++;//进一
+ decimalResult = decimalResult.slice(1);
+ }
+ }
+ var result = integerResult + "." + decimalResult;
+ return BI.parseFloat(result);
+
+ function addZero(resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp
+ }
+ },
+
+ _accurateMultiplication: function (num1, num2) {//乘法分配律
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ //整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numInteger);
+ //num1的小数和num2的整数
+ var dec1Int2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numInteger), stringNumber1.numDecimalLength);
+ //num1的整数和num2的小数
+ var int1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numDecimal), stringNumber2.numDecimalLength);
+ //小数*小数
+ var dec1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numDecimal), (stringNumber1.numDecimalLength + stringNumber2.numDecimalLength));
+
+ return this._accurateAddition(this._accurateAddition(this._accurateAddition(integerResult, dec1Int2), int1dec2), dec1dec2);
+ },
+
+ _accurateDivisionTenExponent: function (num, n) {// num/10^n && n>0
+ var stringNumber = this._stringNumberFactory(num);
+ if (stringNumber.numInteger.length > n) {
+ var integerResult = stringNumber.numInteger.slice(0, (stringNumber.numInteger.length - n));
+ var partDecimalResult = stringNumber.numInteger.slice(-n);
+ } else {
+ var integerResult = "0";
+ var partDecimalResult = addZero(stringNumber.numInteger, n);
+ }
+ var result = integerResult + "." + partDecimalResult + stringNumber.numDecimal;
+ return BI.parseFloat(result);
+
+ function addZero(resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp
+ }
+ },
+
+ accurateSubtraction: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ if (num1 >= num2) {
+ return this._accurateSubtraction(num1, num2)
+ }
+ return -this._accurateSubtraction(num2, num1)
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return this._accurateAddition(num1, -num2)
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return -this._accurateAddition(-num1, num2)
+ }
+ if (num1 < 0 && num2 < 0) {
+ if (num1 >= num2) {
+ return this._accurateSubtraction(-num2, -num1)
+ }
+ return this._accurateSubtraction(-num1, -num2)
+ }
+ },
+
+ accurateAddition: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ return this._accurateAddition(num1, num2)
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return this.accurateSubtraction(num1, -num2)
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return this.accurateSubtraction(num2, -num1)
+ }
+ if (num1 < 0 && num2 < 0) {
+ return -this._accurateAddition(-num1, -num2)
+ }
+ },
+
+ accurateMultiplication: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ return this._accurateMultiplication(num1, num2)
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return -this._accurateMultiplication(num1, -num2)
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return -this._accurateMultiplication(-num1, num2)
+ }
+ if (num1 < 0 && num2 < 0) {
+ return this._accurateMultiplication(-num1, -num2)
+ }
+ },
+
+ accurateDivisionTenExponent: function (num1, n) {
+ if (num1 >= 0) {
+ return this._accurateDivisionTenExponent(num1, n);
+ }
+ return -this._accurateDivisionTenExponent(-num1, n);
+ }
+});/**
+ * 月份下拉框
+ *
+ * Created by GUY on 2015/8/28.
+ * @class BI.MonthCombo
+ * @extends BI.Trigger
+ */
+BI.MonthCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-month-combo",
+ behaviors: {},
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.MonthCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.month_trigger"
+ });
+
+ this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) {
+ if (this.getKey() && this.getKey() !== self.storeValue) {
+ self.setValue(this.getValue());
+ } else if (!this.getKey()) {
+ self.setValue();
+ }
+ self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () {
+ self.storeValue = this.getKey();
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_START, function () {
+ self.combo.hideView();
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_CHANGE, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.month_popup",
+ behaviors: o.behaviors
+ });
+ this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ el: this.popup
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+
+BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.month_combo', BI.MonthCombo);/**
+ * 月份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.MonthPopup
+ * @extends BI.Trigger
+ */
+BI.MonthPopup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-month-popup",
+ behaviors: {}
+ });
+ },
+
+ _init: function () {
+ BI.MonthPopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ //纵向排列月
+ var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11];
+ var items = [];
+ items.push(month.slice(0, 2));
+ items.push(month.slice(2, 4));
+ items.push(month.slice(4, 6));
+ items.push(month.slice(6, 8));
+ items.push(month.slice(8, 10));
+ items.push(month.slice(10, 12));
+ items = BI.map(items, function (i, item) {
+ return BI.map(item, function (j, td) {
+ return {
+ type: "bi.text_item",
+ cls: "bi-list-item-active",
+ textAlign: "center",
+ whiteSpace: "nowrap",
+ once: false,
+ forceSelected: true,
+ height: 23,
+ width: 38,
+ value: td,
+ text: td + 1
+ };
+ });
+ });
+
+ this.month = BI.createWidget({
+ type: "bi.button_group",
+ element: this,
+ behaviors: o.behaviors,
+ items: BI.createItems(items, {}),
+ layouts: [BI.LogicFactory.createLogic("table", BI.extend({
+ dynamic: true
+ }, {
+ columns: 2,
+ rows: 6,
+ columnSize: [1 / 2, 1 / 2],
+ rowSize: 25
+ })), {
+ type: "bi.center_adapt",
+ vgap: 1,
+ hgap: 2
+ }]
+ });
+
+ this.month.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
+ }
+ })
+ },
+
+ getValue: function () {
+ return this.month.getValue()[0];
+ },
+
+ setValue: function (v) {
+ this.month.setValue([v]);
+ }
+});
+BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.month_popup", BI.MonthPopup);/**
+ * 月份trigger
+ *
+ * Created by GUY on 2015/8/21.
+ * @class BI.MonthTrigger
+ * @extends BI.Trigger
+ */
+BI.MonthTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ triggerWidth: 25,
+ errorText: BI.i18nText("BI-Month_Trigger_Error_Text")
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-month-trigger bi-border",
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.MonthTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 12);
+ },
+ quitChecker: function (v) {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ errorText: c.errorText
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_CHANGE);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setValue(value);
+ self.editor.setTitle(value);
+ }
+ self.fireEvent(BI.MonthTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_STOP);
+ });
+ BI.createWidget({
+ element: this,
+ type: 'bi.htape',
+ items: [
+ {
+ el: this.editor
+ }, {
+ el: {
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Multi_Date_Month"),
+ baseCls: "bi-trigger-month-text",
+ width: c.triggerWidth
+ },
+ width: c.triggerWidth
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: c.triggerWidth
+ },
+ width: c.triggerWidth
+ }
+ ]
+ });
+ },
+ setValue: function (v) {
+ if(BI.isNotNull(v)){
+ this.editor.setState(v + 1);
+ this.editor.setValue(v + 1);
+ this.editor.setTitle(v + 1);
+ return;
+ }
+ this.editor.setState();
+ this.editor.setValue();
+ this.editor.setTitle();
+ },
+ getKey: function () {
+ return this.editor.getValue() | 0;
+ },
+ getValue: function () {
+ return this.editor.getValue() - 1;
+ }
+});
+BI.MonthTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.MonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.MonthTrigger.EVENT_START = "EVENT_START";
+BI.MonthTrigger.EVENT_STOP = "EVENT_STOP";
+BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.month_trigger", BI.MonthTrigger);/**
+ * @class BI.MultiLayerSelectTreeCombo
+ * @extends BI.Widget
+ */
+BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSelectTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer_select_tree-combo",
+ isDefaultInit: false,
+ height: 30,
+ text: "",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.multilayer_select_tree_popup",
+ isDefaultInit: o.isDefaultInit,
+ items: o.items
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ }
+});
+BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
+ * guy
+ * 二级树
+ * @class BI.MultiLayerSelectLevelTree
+ * @extends BI.Select
+ */
+BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSelectLevelTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-select-level-tree",
+ isDefaultInit: false,
+ items: [],
+ itemsCreator: BI.emptyFn
+ })
+ },
+
+ _init: function () {
+ BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments);
+
+ this.initTree(this.options.items);
+ },
+
+ _formatItems: function (nodes, layer) {
+ var self = this;
+ BI.each(nodes, function (i, node) {
+ var extend = {};
+ node.layer = layer;
+ if (!BI.isKey(node.id)) {
+ node.id = BI.UUID();
+ }
+ if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
+ switch (i) {
+ case 0 :
+ extend.type = "bi.multilayer_select_tree_first_plus_group_node";
+ break;
+ case nodes.length - 1 :
+ extend.type = "bi.multilayer_select_tree_last_plus_group_node";
+ break;
+ default :
+ extend.type = "bi.multilayer_select_tree_mid_plus_group_node";
+ break;
+ }
+ BI.defaults(node, extend);
+
+ self._formatItems(node.children, layer + 1);
+ } else {
+ switch (i) {
+ case nodes.length - 1:
+ extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
+ break;
+ default :
+ extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
+ }
+ BI.defaults(node, extend);
+ }
+ });
+ return nodes;
+ },
+
+ _assertId: function (sNodes) {
+ BI.each(sNodes, function (i, node) {
+ node.id = node.id || BI.UUID();
+ });
+ },
+
+ //构造树结构,
+ initTree: function (nodes) {
+ var self = this, o = this.options;
+ this.empty();
+ this._assertId(nodes);
+ this.tree = BI.createWidget({
+ type: "bi.custom_tree",
+ element: this,
+ expander: {
+ type: "bi.select_tree_expander",
+ isDefaultInit: o.isDefaultInit,
+ el: {},
+ popup: {
+ type: "bi.custom_tree"
+ }
+ },
+
+ items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
+ itemsCreator: o.itemsCreator,
+
+ el: {
+ type: "bi.button_tree",
+ chooseType: BI.Selection.Single,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ });
+ this.tree.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, arguments);
+ }
+ })
+ },
+
+ populate: function (nodes) {
+ this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0));
+ },
+
+ setValue: function (v) {
+ this.tree.setValue(v);
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ getAllLeaves: function () {
+ return this.tree.getAllLeaves();
+ },
+
+ getNodeById: function (id) {
+ return this.tree.getNodeById(id);
+ },
+
+ getNodeByValue: function (id) {
+ return this.tree.getNodeByValue(id);
+ }
+});
+BI.MultiLayerSelectLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.multilayer_select_level_tree", BI.MultiLayerSelectLevelTree);/**
+ * Created by GUY on 2016/1/26.
+ *
+ * @class BI.MultiLayerSelectTreePopup
+ * @extends BI.Pane
+ */
+
+BI.MultiLayerSelectTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-select-tree-popup",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ isDefaultInit: false,
+ itemsCreator: BI.emptyFn,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSelectTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: 'bi.multilayer_select_level_tree',
+ isDefaultInit: o.isDefaultInit,
+ items: o.items,
+ itemsCreator: o.itemsCreator
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ scrollable: true,
+ element: this,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.MultiLayerSelectTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.MultiLayerSelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_select_tree_popup", BI.MultiLayerSelectTreePopup);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSelectTreeFirstPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.select_tree_first_plus_group_node",
+ cls: "bi-list-item-none",
+ stopPropagation: true,
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_select_tree_first_plus_group_node", BI.MultiLayerSelectTreeFirstPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSelectTreeLastPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-select-tree-last-plus-group-node bi-list-item-active",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.select_tree_last_plus_group_node",
+ cls: "bi-list-item-none",
+ stopPropagation: true,
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_select_tree_last_plus_group_node", BI.MultiLayerSelectTreeLastPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSelectTreeMidPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.select_tree_mid_plus_group_node",
+ cls: "bi-list-item-none",
+ stopPropagation: true,
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node", BI.MultiLayerSelectTreeMidPlusGroupNode);/**
+ * 多层级下拉单选树
+ * Created by GUY on 2016/1/26.
+ *
+ * @class BI.MultiLayerSingleTreeCombo
+ * @extends BI.Widget
+ */
+BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-singletree-combo",
+ isDefaultInit: false,
+ height: 30,
+ text: "",
+ itemsCreator: BI.emptyFn,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.multilayer_single_tree_popup",
+ isDefaultInit: o.isDefaultInit,
+ items: o.items
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ }
+});
+
+BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
+ * guy
+ * 二级树
+ * @class BI.MultiLayerSingleLevelTree
+ * @extends BI.Single
+ */
+BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleLevelTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-single-level-tree",
+ isDefaultInit: false,
+ items: [],
+ itemsCreator: BI.emptyFn
+ })
+ },
+
+ _init: function () {
+ BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments);
+
+ this.initTree(this.options.items);
+ },
+
+ _formatItems: function (nodes, layer) {
+ var self = this;
+ BI.each(nodes, function (i, node) {
+ var extend = {};
+ node.layer = layer;
+ if (!BI.isKey(node.id)) {
+ node.id = BI.UUID();
+ }
+ if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
+ switch (i) {
+ case 0 :
+ extend.type = "bi.multilayer_single_tree_first_plus_group_node";
+ break;
+ case nodes.length - 1 :
+ extend.type = "bi.multilayer_single_tree_last_plus_group_node";
+ break;
+ default :
+ extend.type = "bi.multilayer_single_tree_mid_plus_group_node";
+ break;
+ }
+ BI.defaults(node, extend);
+
+ self._formatItems(node.children, layer + 1);
+ } else {
+ switch (i) {
+ case nodes.length - 1:
+ extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
+ break;
+ default :
+ extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
+ }
+ BI.defaults(node, extend);
+ }
+ });
+ return nodes;
+ },
+
+ _assertId: function (sNodes) {
+ BI.each(sNodes, function (i, node) {
+ node.id = node.id || BI.UUID();
+ });
+ },
+
+ //构造树结构,
+ initTree: function (nodes) {
+ var self = this, o = this.options;
+ this.empty();
+ this._assertId(nodes);
+ this.tree = BI.createWidget({
+ type: "bi.custom_tree",
+ element: this,
+ expander: {
+ isDefaultInit: o.isDefaultInit,
+ el: {},
+ popup: {
+ type: "bi.custom_tree"
+ }
+ },
+
+ items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (items) {
+ callback(BI.Tree.transformToTreeFormat(items), 0)
+ })
+ },
+
+ el: {
+ type: "bi.button_tree",
+ chooseType: BI.Selection.Single,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ });
+ this.tree.on(BI.Controller.EVENT_CHANGE, function (type, v) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, v);
+ }
+ })
+ },
+
+ populate: function (nodes) {
+ this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0));
+ },
+
+ setValue: function (v) {
+ this.tree.setValue(v);
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ getAllLeaves: function () {
+ return this.tree.getAllLeaves();
+ },
+
+ getNodeById: function (id) {
+ return this.tree.getNodeById(id);
+ },
+
+ getNodeByValue: function (id) {
+ return this.tree.getNodeByValue(id);
+ }
+});
+BI.MultiLayerSingleLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.multilayer_single_level_tree", BI.MultiLayerSingleLevelTree);
+/**
+ * Created by GUY on 2016/1/26.
+ *
+ * @class BI.MultiLayerSingleTreePopup
+ * @extends BI.Pane
+ */
+
+BI.MultiLayerSingleTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-singletree-popup",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ isDefaultInit: false,
+ itemsCreator: BI.emptyFn,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSingleTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: 'bi.multilayer_single_level_tree',
+ isDefaultInit: o.isDefaultInit,
+ items: o.items,
+ itemsCreator: o.itemsCreator
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ scrollable: true,
+ element: this,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.MultiLayerSingleTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.MultiLayerSingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_single_tree_popup", BI.MultiLayerSingleTreePopup);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeFirstPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSingleTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-single-tree-first-plus-group-node bi-list-item",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.first_plus_group_node",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.node)) {
+ this.node.setOpened(v);
+ }
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_first_plus_group_node", BI.MultiLayerSingleTreeFirstPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeLastPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSingleTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-single-tree-last-plus-group-node bi-list-item",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.last_plus_group_node",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.node)) {
+ this.node.setOpened(v);
+ }
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_last_plus_group_node", BI.MultiLayerSingleTreeLastPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeMidPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSingleTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-single-tree-mid-plus-group-node bi-list-item",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.mid_plus_group_node",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.node)) {
+ this.node.setOpened(v);
+ }
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/**
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeFirstTreeLeafItem
+ * @extends BI.BasicButton
+ */
+BI.MultiLayerSingleTreeFirstTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multilayer-single-tree-first-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ layer: 0,
+ id: "",
+ pId: "",
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.item = BI.createWidget({
+ type: "bi.first_tree_leaf_item",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.item);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.item.doRedMark.apply(this.item, arguments);
+ },
+
+ unRedMark: function () {
+ this.item.unRedMark.apply(this.item, arguments);
+ },
+
+ doHighLight: function () {
+ this.item.doHighLight.apply(this.item, arguments);
+ },
+
+ unHighLight: function () {
+ this.item.unHighLight.apply(this.item, arguments);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.item.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.item.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item", BI.MultiLayerSingleTreeFirstTreeLeafItem);/**
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeLastTreeLeafItem
+ * @extends BI.BasicButton
+ */
+BI.MultiLayerSingleTreeLastTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multilayer-single-tree-last-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ layer: 0,
+ id: "",
+ pId: "",
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.item = BI.createWidget({
+ type: "bi.last_tree_leaf_item",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.item);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.item.doRedMark.apply(this.item, arguments);
+ },
+
+ unRedMark: function () {
+ this.item.unRedMark.apply(this.item, arguments);
+ },
+
+ doHighLight: function () {
+ this.item.doHighLight.apply(this.item, arguments);
+ },
+
+ unHighLight: function () {
+ this.item.unHighLight.apply(this.item, arguments);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.item.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.item.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item", BI.MultiLayerSingleTreeLastTreeLeafItem);/**
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeMidTreeLeafItem
+ * @extends BI.BasicButton
+ */
+BI.MultiLayerSingleTreeMidTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multilayer-single-tree-mid-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ layer: 0,
+ id: "",
+ pId: "",
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.item = BI.createWidget({
+ type: "bi.mid_tree_leaf_item",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.item);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.item.doRedMark.apply(this.item, arguments);
+ },
+
+ unRedMark: function () {
+ this.item.unRedMark.apply(this.item, arguments);
+ },
+
+ doHighLight: function () {
+ this.item.doHighLight.apply(this.item, arguments);
+ },
+
+ unHighLight: function () {
+ this.item.unHighLight.apply(this.item, arguments);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.item.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.item.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item", BI.MultiLayerSingleTreeMidTreeLeafItem);/**
+ *
+ * @class BI.MultiSelectCheckPane
+ * @extends BI.Widget
+ */
+BI.MultiSelectCheckPane = BI.inherit(BI.Widget, {
+
+ constants: {
+ height: 25,
+ lgap: 10,
+ tgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-check-pane bi-background",
+ items: [],
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ onClickContinueSelect: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCheckPane.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.storeValue = {};
+ this.display = BI.createWidget({
+ type: 'bi.display_selected_list',
+ items: opts.items,
+ itemsCreator: function (op, callback) {
+ op = BI.extend(op || {}, {
+ selectedValues: self.storeValue.value
+ });
+ if (self.storeValue.type === BI.Selection.Multi) {
+ callback({
+ items: BI.map(self.storeValue.value, function (i, v) {
+ var txt = opts.valueFormatter(v) || v;
+ return {
+ text: txt,
+ value: v,
+ title: txt
+ }
+ })
+ });
+ return;
+ }
+ opts.itemsCreator(op, callback);
+ }
+ });
+
+ this.continueSelect = BI.createWidget({
+ type: 'bi.text_button',
+ text: BI.i18nText('BI-Continue_Select'),
+ cls: 'multi-select-check-selected bi-high-light'
+ });
+
+ this.continueSelect.on(BI.TextButton.EVENT_CHANGE, function () {
+ opts.onClickContinueSelect();
+ });
+
+ BI.createWidget({
+ type: 'bi.vtape',
+ element: this,
+ items: [{
+ height: this.constants.height,
+ el: {
+ type: 'bi.left',
+ cls: 'multi-select-continue-select',
+ items: [
+ {
+ el: {
+ type: "bi.label",
+ text: BI.i18nText('BI-Selected_Data')
+ },
+ lgap: this.constants.lgap,
+ tgap: this.constants.tgap
+ },
+ {
+ el: this.continueSelect,
+ lgap: this.constants.lgap,
+ tgap: this.constants.tgap
+ }]
+ }
+ }, {
+ height: 'fill',
+ el: this.display
+ }]
+ });
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ },
+
+ empty: function () {
+ this.display.empty();
+ },
+
+ populate: function () {
+ this.display.populate.apply(this.display, arguments);
+ }
+});
+
+BI.shortcut("bi.multi_select_check_pane", BI.MultiSelectCheckPane);/**
+ *
+ *
+ * 查看已选弹出层的展示面板
+ * @class BI.DisplaySelectedList
+ * @extends BI.Widget
+ */
+BI.DisplaySelectedList = BI.inherit(BI.Pane, {
+
+ constants: {
+ height: 25,
+ lgap: 10
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-display-list",
+ itemsCreator: BI.emptyFn,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.DisplaySelectedList.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.hasNext = false;
+
+ this.button_group = BI.createWidget({
+ type: "bi.list_pane",
+ element: this,
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ items: this._createItems(opts.items),
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ layouts: [{
+ type: "bi.vertical",
+ lgap: 10
+ }]
+ },
+ itemsCreator: function (options, callback) {
+
+ opts.itemsCreator(options, function (ob) {
+ self.hasNext = !!ob.hasNext;
+ callback(self._createItems(ob.items));
+ })
+ },
+ hasNext: function () {
+ return self.hasNext;
+ }
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: 'bi.icon_text_item',
+ cls: 'cursor-default check-font display-list-item bi-tips',
+ once: true,
+ invalid: true,
+ selected: true,
+ height: this.constants.height,
+ logic: {
+ dynamic: true
+ }
+ });
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ if (arguments.length === 0) {
+ this.button_group.populate();
+ } else {
+ this.button_group.populate(this._createItems(items));
+ }
+ }
+});
+
+BI.shortcut('bi.display_selected_list', BI.DisplaySelectedList);/**
+ *
+ * @class BI.MultiSelectCombo
+ * @extends BI.Single
+ */
+BI.MultiSelectCombo = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-combo',
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ height: 28
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
+ self.trigger.getSearcher().setState(self.storeValue);
+ self.trigger.getCounter().setButtonChecked(self.storeValue);
+ };
+ this.storeValue = {};
+
+ this.trigger = BI.createWidget({
+ type: "bi.multi_select_trigger",
+ height: o.height,
+ // adapter: this.popup,
+ masker: {
+ offset: {
+ left: 1,
+ top: 1,
+ right: 2,
+ bottom: 33
+ }
+ },
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (res) {
+ if (op.times === 1 && BI.isNotNull(op.keywords)) {
+ //预防trigger内部把当前的storeValue改掉
+ self.trigger.setValue(BI.deepClone(self.getValue()));
+ }
+ callback.apply(self, arguments);
+ });
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
+ self._setStartValue("");
+ this.getSearcher().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
+ self._setStartValue("");
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
+ if (this.getSearcher().hasMatched()) {
+ var keyword = this.getSearcher().getKeyword();
+ self._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ self.combo.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.populate();
+ self._setStartValue("");
+ })
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ self.combo.populate();
+ self._setStartValue("");
+ } else {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ });
+ } else {
+ self._join(this.getValue(), function () {
+ assertShowValue();
+ });
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
+ this.getCounter().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ el: this.trigger,
+ adjustLength: 1,
+ popup: {
+ type: 'bi.multi_select_popup_view',
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
+ action: function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ });
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,
+ action: function () {
+ self._defaultState();
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,
+ action: function () {
+ self.setValue();
+ self._defaultState();
+ }
+ }],
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.combo.adjustWidth();
+ self.combo.adjustHeight();
+ self.trigger.getCounter().adjustView();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ }
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ this.setValue(self.storeValue);
+ BI.nextTick(function () {
+ self.populate();
+ });
+ });
+ this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ //important:关闭弹出时又可能没有退出编辑状态
+ self.trigger.stopEditing();
+ self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "multi-select-trigger-icon-button bi-border-left"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ self.trigger.getCounter().hideView();
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ })
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
+ keywords: keywords
+ }, function (ob) {
+ var values = BI.pluck(ob.items, "value");
+ digest(values);
+ });
+
+ function digest(items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
+ keywords: [this.trigger.getKey()]
+ }, function (ob) {
+ var items = BI.pluck(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ self._adjust(callback);
+ })
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ if (!this._count) {
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ self._count = res.count;
+ adjust();
+ callback();
+ });
+ } else {
+ adjust();
+ callback();
+ }
+ function adjust() {
+ if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.Multi,
+ value: []
+ }
+ } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.All,
+ value: []
+ }
+ }
+ }
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.popup.setStartValue(value);
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.combo.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ populate: function () {
+ this._count = null;
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+
+BI.extend(BI.MultiSelectCombo, {
+ REQ_GET_DATA_LENGTH: 0,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+
+BI.shortcut('bi.multi_select_combo', BI.MultiSelectCombo);/**
+ * 多选加载数据面板
+ * Created by guy on 15/11/2.
+ * @class BI.MultiSelectLoader
+ * @extends Widget
+ */
+BI.MultiSelectLoader = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-loader',
+ logic: {
+ dynamic: true
+ },
+ el: {
+ height: 400
+ },
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectLoader.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+ var hasNext = false;
+
+ this.button_group = BI.createWidget({
+ type: "bi.select_list",
+ element: this,
+ logic: opts.logic,
+ el: BI.extend({
+ onLoaded: opts.onLoaded,
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ el: {
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ }
+ }, opts.el),
+ itemsCreator: function (op, callback) {
+ var startValue = self._startValue;
+ self.storeValue && (op = BI.extend(op || {}, {
+ selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi
+ ? self.storeValue.value.concat(startValue) : self.storeValue.value
+ }));
+ opts.itemsCreator(op, function (ob) {
+ hasNext = ob.hasNext;
+ var firstItems = [];
+ if (op.times === 1 && self.storeValue) {
+ var json = BI.map(self.storeValue.value, function (i, v) {
+ var txt = opts.valueFormatter(v) || v;
+ return {
+ text: txt,
+ value: v,
+ title: txt,
+ selected: self.storeValue.type === BI.Selection.Multi
+ }
+ });
+ if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) {
+ var txt = opts.valueFormatter(startValue) || startValue;
+ json.unshift({
+ text: txt,
+ value: startValue,
+ title: txt,
+ selected: true
+ })
+ }
+ firstItems = self._createItems(json);
+ }
+ callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
+ if (op.times === 1 && self.storeValue) {
+ BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue);
+ self.setValue(self.storeValue);
+ }
+ (op.times === 1) && self._scrollToTop();
+ });
+ },
+ hasNext: function () {
+ return hasNext;
+ }
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: "bi.multi_select_item",
+ logic: this.options.logic,
+ height: 25,
+ selected: this.isAllSelected()
+ })
+ },
+
+ _scrollToTop: function () {
+ var self = this;
+ BI.delay(function () {
+ self.button_group.element.scrollTop(0);
+ }, 30);
+ },
+
+ isAllSelected: function () {
+ return this.button_group.isAllSelected();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ setStartValue: function (v) {
+ this._startValue = v;
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.button_group.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.button_group.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.button_group.resetWidth(w);
+ }
+});
+
+BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.multi_select_loader', BI.MultiSelectLoader);/**
+ * 带加载的多选下拉面板
+ * @class BI.MultiSelectPopupView
+ * @extends Widget
+ */
+BI.MultiSelectPopupView = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-popup-view',
+ maxWidth: 'auto',
+ minWidth: 135,
+ maxHeight: 400,
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectPopupView.superclass._init.apply(this, arguments);
+ var self = this, opts = this.options;
+
+ this.loader = BI.createWidget({
+ type: "bi.multi_select_loader",
+ itemsCreator: opts.itemsCreator,
+ valueFormatter: opts.valueFormatter,
+ onLoaded: opts.onLoaded
+ });
+
+ this.popupView = BI.createWidget({
+ type: "bi.multi_popup_view",
+ stopPropagation: false,
+ maxWidth: opts.maxWidth,
+ minWidth: opts.minWidth,
+ maxHeight: opts.maxHeight,
+ element: this,
+ buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')],
+ el: this.loader
+ });
+
+ this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE);
+ });
+ this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
+ switch (index) {
+ case 0:
+ self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM);
+ break;
+ }
+ });
+ },
+
+ isAllSelected: function () {
+ return this.loader.isAllSelected();
+ },
+
+ setStartValue: function (v) {
+ this.loader.setStartValue(v);
+ },
+
+ setValue: function (v) {
+ this.popupView.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popupView.getValue();
+ },
+
+ populate: function (items) {
+ this.popupView.populate.apply(this.popupView, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.popupView.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.popupView.resetWidth(w);
+ }
+});
+
+BI.MultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.MultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+
+
+BI.shortcut('bi.multi_select_popup_view', BI.MultiSelectPopupView);/**
+ *
+ * 复选下拉框
+ * @class BI.MultiSelectTrigger
+ * @extends BI.Trigger
+ */
+
+BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
+
+ constants: {
+ height: 14,
+ rgap: 4,
+ lgap: 4
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-trigger bi-border",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ searcher: {},
+ switcher: {},
+
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectTrigger.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ if (o.height) {
+ this.setHeight(o.height - 2);
+ }
+
+ this.searcher = BI.createWidget(o.searcher, {
+ type: "bi.multi_select_searcher",
+ height: o.height,
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ popup: {},
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_START);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING, arguments);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_STOP);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE, arguments);
+ });
+ this.numberCounter = BI.createWidget(o.switcher, {
+ type: 'bi.multi_select_check_selected_switcher',
+ valueFormatter: o.valueFormatter,
+ itemsCreator: o.itemsCreator,
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK);
+ });
+ this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
+ });
+
+ var wrapNumberCounter = BI.createWidget({
+ type: 'bi.right_vertical_adapt',
+ hgap: 4,
+ items: [{
+ el: this.numberCounter
+ }]
+ });
+
+ var wrapper = BI.createWidget({
+ type: 'bi.htape',
+ element: this,
+ items: [
+ {
+ el: this.searcher,
+ width: 'fill'
+ }, {
+ el: wrapNumberCounter,
+ width: 0
+ }, {
+ el: BI.createWidget(),
+ width: 30
+ }]
+ });
+
+ this.numberCounter.on(BI.Events.VIEW, function (b) {
+ BI.nextTick(function () {//自动调整宽度
+ wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
+ wrapper.resize();
+ });
+ });
+
+ this.element.click(function (e) {
+ if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) {
+ self.numberCounter.hideView();
+ }
+ });
+ },
+
+ getCounter: function () {
+ return this.numberCounter;
+ },
+
+ getSearcher: function () {
+ return this.searcher;
+ },
+
+ stopEditing: function () {
+ this.searcher.stopSearch();
+ this.numberCounter.hideView();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ this.numberCounter.setAdapter(adapter);
+ },
+
+ setValue: function (ob) {
+ this.searcher.setValue(ob);
+ this.numberCounter.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.searcher.getKey();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ }
+});
+
+BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+BI.MultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
+BI.MultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectTrigger.EVENT_START = "EVENT_START";
+BI.MultiSelectTrigger.EVENT_STOP = "EVENT_STOP";
+BI.MultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE";
+BI.MultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
+
+BI.shortcut('bi.multi_select_trigger', BI.MultiSelectTrigger);/**
+ * 多选加载数据搜索loader面板
+ * Created by guy on 15/11/4.
+ * @class BI.MultiSelectSearchLoader
+ * @extends Widget
+ */
+BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-search-loader',
+ itemsCreator: BI.emptyFn,
+ keywordGetter: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectSearchLoader.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+ var hasNext = false;
+
+ this.button_group = BI.createWidget({
+ type: "bi.select_list",
+ element: this,
+ logic: {
+ dynamic: false
+ },
+ el: {
+ tipText: BI.i18nText("BI-No_Select"),
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ el: {
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ }
+ },
+ itemsCreator: function (op, callback) {
+ self.storeValue && (op = BI.extend(op || {}, {
+ selectedValues: self.storeValue.value
+ }));
+ opts.itemsCreator(op, function (ob) {
+ var keyword = ob.keyword = opts.keywordGetter();
+ hasNext = ob.hasNext;
+ var firstItems = [];
+ if (op.times === 1 && self.storeValue) {
+ var json = self._filterValues(self.storeValue);
+ firstItems = self._createItems(json);
+ }
+ callback(firstItems.concat(self._createItems(ob.items)), keyword);
+ if (op.times === 1 && self.storeValue) {
+ self.setValue(self.storeValue);
+ }
+ });
+ },
+ hasNext: function () {
+ return hasNext;
+ }
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: "bi.multi_select_item",
+ logic: {
+ dynamic: false
+ },
+ height: 25,
+ selected: this.isAllSelected()
+ })
+ },
+
+ isAllSelected: function () {
+ return this.button_group.isAllSelected();
+ },
+
+ _filterValues: function (src) {
+ var o = this.options;
+ var keyword = o.keywordGetter();
+ var values = BI.deepClone(src.value) || [];
+ var newValues = BI.map(values, function (i, v) {
+ return {
+ text: o.valueFormatter(v) || v,
+ value: v
+ };
+ });
+ if (BI.isKey(keyword)) {
+ var search = BI.Func.getSearchResult(newValues, keyword);
+ values = search.matched.concat(search.finded);
+ }
+ return BI.map(values, function (i, v) {
+ return {
+ text: v.text,
+ title: v.text,
+ value: v.value,
+ selected: src.type === BI.Selection.All
+ }
+ })
+ },
+
+ setValue: function (v) {
+ //暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
+ this.storeValue = BI.deepClone(v);
+ this.button_group.setValue(v);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.button_group.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.button_group.resetWidth(w);
+ }
+});
+
+BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.multi_select_search_loader', BI.MultiSelectSearchLoader);/**
+ *
+ * 在搜索框中输入文本弹出的面板
+ * @class BI.MultiSelectSearchPane
+ * @extends Widget
+ */
+
+BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
+
+ constants: {
+ height: 25,
+ lgap: 10,
+ tgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-search-pane bi-card",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ keywordGetter: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectSearchPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.tooltipClick = BI.createWidget({
+ type: "bi.label",
+ invisible: true,
+ text: BI.i18nText('BI-Click_Blank_To_Select'),
+ cls: 'multi-select-toolbar',
+ height: this.constants.height
+ });
+
+ this.loader = BI.createWidget({
+ type: "bi.multi_select_search_loader",
+ keywordGetter: o.keywordGetter,
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator.apply(self, [op, function (res) {
+ callback(res);
+ self.setKeyword(o.keywordGetter());
+ }]);
+ }
+ });
+ this.loader.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.resizer = BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.tooltipClick,
+ height: 0
+ }, {
+ el: this.loader
+ }]
+ });
+ this.tooltipClick.setVisible(false);
+ },
+
+ setKeyword: function (keyword) {
+ var btn;
+ var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue());
+ if (isVisible !== this.tooltipClick.isVisible()) {
+ this.tooltipClick.setVisible(isVisible);
+ this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0);
+ this.resizer.resize();
+ }
+ },
+
+ isAllSelected: function () {
+ return this.loader.isAllSelected();
+ },
+
+ hasMatched: function () {
+ return this.tooltipClick.isVisible();
+ },
+
+ setValue: function (v) {
+ this.loader.setValue(v);
+ },
+
+ getValue: function () {
+ return this.loader.getValue();
+ },
+
+ empty: function () {
+ this.loader.empty();
+ },
+
+ populate: function (items) {
+ this.loader.populate.apply(this.loader, arguments);
+ }
+});
+
+BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);/**
+ * 查看已选按钮
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectCheckSelectedButton
+ * @extends BI.Single
+ */
+BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, {
+
+ _const: {
+ checkSelected: BI.i18nText('BI-Check_Selected')
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-check-selected-button bi-high-light',
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments);
+ var self = this;
+ this.numberCounter = BI.createWidget({
+ type: 'bi.text_button',
+ element: this,
+ hgap: 4,
+ text: "0",
+ textAlign: 'center',
+ textHeight: 15
+ });
+ this.numberCounter.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.numberCounter.on(BI.TextButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
+ });
+
+ this.numberCounter.element.hover(function () {
+ self.numberCounter.setTag(self.numberCounter.getText());
+ self.numberCounter.setText(self._const.checkSelected);
+ }, function () {
+ self.numberCounter.setText(self.numberCounter.getTag());
+ });
+ this.setVisible(false);
+ },
+
+ setValue: function (ob) {
+ var self = this, o = this.options;
+ ob || (ob = {});
+ ob.type || (ob.type = BI.Selection.Multi);
+ ob.value || (ob.value = []);
+ if (ob.type === BI.Selection.All) {
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ var length = res.count - ob.value.length;
+ BI.nextTick(function(){
+ self.numberCounter.setText(length);
+ self.setVisible(length > 0);
+ });
+ });
+ return;
+ }
+ BI.nextTick(function(){
+ self.numberCounter.setText(ob.value.length);
+ self.setVisible(ob.value.length > 0);
+ })
+ },
+
+ getValue: function () {
+
+ }
+});
+
+BI.MultiSelectCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.multi_select_check_selected_button', BI.MultiSelectCheckSelectedButton);/**
+ * 多选输入框
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectEditor
+ * @extends Widget
+ */
+BI.MultiSelectEditor = BI.inherit(BI.Widget, {
+
+ _const: {
+ checkSelected: BI.i18nText('BI-Check_Selected')
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectEditor.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-editor',
+ el: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.el, {
+ type: 'bi.state_editor',
+ element: this,
+ height: o.height,
+ watermark: BI.i18nText('BI-Basic_Search'),
+ allowBlank: true
+ });
+
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.editor.on(BI.StateEditor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.MultiSelectEditor.EVENT_PAUSE);
+ });
+ this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () {
+
+ });
+ },
+
+ focus: function () {
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ },
+
+ setState: function (state) {
+ this.editor.setState(state);
+ },
+
+ setValue: function (v) {
+ this.editor.setValue(v);
+ },
+
+ getValue: function () {
+ var v = this.editor.getState();
+ if (BI.isArray(v) && v.length > 0) {
+ return v[v.length - 1];
+ } else {
+ return "";
+ }
+ },
+
+ getKeywords: function () {
+ var val = this.editor.getLastValidValue();
+ var keywords = val.match(/[\S]+/g);
+ if (BI.isEndWithBlank(val)) {
+ return keywords.concat([' ']);
+ }
+ return keywords;
+ },
+
+ populate: function (items) {
+
+ }
+});
+BI.MultiSelectEditor.EVENT_PAUSE = "MultiSelectEditor.EVENT_PAUSE";
+BI.shortcut('bi.multi_select_editor', BI.MultiSelectEditor);/**
+ * searcher
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectSearcher
+ * @extends Widget
+ */
+BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-searcher',
+ itemsCreator: BI.emptyFn,
+ el: {},
+ popup: {},
+ valueFormatter: BI.emptyFn,
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectSearcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.el, {
+ type: 'bi.multi_select_editor',
+ height: o.height
+ });
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ element: this,
+ height: o.height,
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback();
+ },
+ el: this.editor,
+
+ popup: BI.extend({
+ type: "bi.multi_select_search_pane",
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.editor.getValue();
+ },
+ itemsCreator: function (op, callback) {
+ op.keyword = self.editor.getValue();
+ this.setKeyword(op.keyword);
+ o.itemsCreator(op, callback);
+ }
+ }, o.popup),
+
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.Searcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_START);
+ });
+ this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
+ if (this.hasMatched()) {
+
+ }
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.Searcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_STOP);
+ });
+ this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE, arguments);
+ });
+ this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
+ var keywords = this.getKeywords();
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING, keywords);
+ });
+ },
+
+ adjustView: function () {
+ this.searcher.adjustView();
+ },
+
+ isSearching: function () {
+ return this.searcher.isSearching();
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ getKeyword: function () {
+ return this.editor.getValue();
+ },
+
+ hasMatched: function () {
+ return this.searcher.hasMatched();
+ },
+
+ hasChecked: function () {
+ return this.searcher.getView() && this.searcher.getView().hasChecked();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ },
+
+ setState: function (ob) {
+ var o = this.options;
+ ob || (ob = {});
+ ob.value || (ob.value = []);
+ if (ob.type === BI.Selection.All) {
+ if (BI.size(ob.assist) === 1) {
+ this.editor.setState(o.valueFormatter(ob.assist[0] + "") || (ob.assist[0] + ""));
+ } else {
+ this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All);
+ }
+ } else {
+ if (BI.size(ob.value) === 1) {
+ this.editor.setState(o.valueFormatter(ob.value[0] + "") || (ob.value[0] + ""));
+ } else {
+ this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None);
+ }
+ }
+ },
+
+ setValue: function (ob) {
+ this.setState(ob);
+ this.searcher.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ },
+
+ populate: function (items) {
+ this.searcher.populate.apply(this.searcher, arguments);
+ }
+});
+
+BI.MultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.MultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectSearcher.EVENT_START = "EVENT_START";
+BI.MultiSelectSearcher.EVENT_STOP = "EVENT_STOP";
+BI.MultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE";
+BI.MultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.shortcut('bi.multi_select_searcher', BI.MultiSelectSearcher);/**
+ * 查看已选switcher
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectCheckSelectedSwitcher
+ * @extends Widget
+ */
+BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCheckSelectedSwitcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-check-selected-switcher',
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ el: {},
+ popup: {},
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCheckSelectedSwitcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.button = BI.createWidget(o.el, {
+ type: "bi.multi_select_check_selected_button",
+ itemsCreator: o.itemsCreator
+ });
+ this.button.on(BI.Events.VIEW, function () {
+ self.fireEvent(BI.Events.VIEW, arguments);
+ });
+ this.switcher = BI.createWidget({
+ type: "bi.switcher",
+ toggle: false,
+ element: this,
+ el: this.button,
+ popup: BI.extend({
+ type: "bi.multi_select_check_pane",
+ valueFormatter: o.valueFormatter,
+ itemsCreator: o.itemsCreator,
+ onClickContinueSelect: function () {
+ self.switcher.hideView();
+ }
+ }, o.popup),
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE);
+ });
+ this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW);
+ });
+ this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW, function () {
+ var me = this;
+ BI.nextTick(function () {
+ me.populate();
+ });
+ });
+
+ this.switcher.element.click(function (e) {
+ e.stopPropagation();
+ });
+ },
+
+ adjustView: function () {
+ this.switcher.adjustView();
+ },
+
+ hideView: function () {
+ this.switcher.empty();
+ this.switcher.hideView();
+ },
+
+ setAdapter: function (adapter) {
+ this.switcher.setAdapter(adapter);
+ },
+
+ setValue: function (v) {
+ this.switcher.setValue(v);
+ },
+
+ setButtonChecked: function (v) {
+ this.button.setValue(v)
+ },
+
+ getValue: function () {
+
+ },
+
+ populate: function (items) {
+ this.switcher.populate.apply(this.switcher, arguments);
+ }
+});
+
+BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE";
+BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/**
+ * Created by zcf_1 on 2017/5/2.
+ */
+BI.MultiSelectList = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-list',
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn
+ })
+ },
+ _init: function () {
+ BI.MultiSelectList.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ this.storeValue = {};
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
+ // self.trigger.setValue(self.storeValue);
+ };
+
+ this.adapter = BI.createWidget({
+ type: "bi.multi_select_loader",
+ cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom",
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ // onLoaded: o.onLoaded,
+ el: {
+ height: ""
+ }
+ });
+ this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
+ });
+ });
+
+ this.searcherPane = BI.createWidget({
+ type: "bi.multi_select_search_pane",
+ cls: "bi-border-left bi-border-right bi-border-bottom",
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.trigger.getKeyword();
+ },
+ itemsCreator: function (op, callback) {
+ op.keyword = self.trigger.getKeyword();
+ this.setKeyword(op.keyword);
+ o.itemsCreator(op, callback);
+ }
+ });
+ this.searcherPane.setVisible(false);
+
+ this.trigger = BI.createWidget({
+ type: "bi.searcher",
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback();
+ },
+ adapter: this.adapter,
+ popup: this.searcherPane,
+ height: 200,
+ masker: false,
+ listeners: [{
+ eventName: BI.Searcher.EVENT_START,
+ action: function () {
+ self._showSearcherPane();
+ self._setStartValue("");
+ this.setValue(BI.deepClone(self.storeValue));
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_STOP,
+ action: function () {
+ self._showAdapter();
+ self._setStartValue("");
+ self.adapter.setValue(self.storeValue);
+ //需要刷新回到初始界面,否则搜索的结果不能放在最前面
+ self.adapter.populate();
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_PAUSE,
+ action: function () {
+ if (this.hasMatched()) {
+ var keyword = this.getKeyword();
+ self._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ self._showAdapter();
+ self.adapter.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self._setStartValue("");
+ self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
+ })
+ } else {
+ self._showAdapter();
+ }
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_SEARCHING,
+ action: function () {
+ var keywords = this.getKeyword();
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.adapter.setValue(self.storeValue);
+ assertShowValue();
+ self.adapter.populate();
+ self._setStartValue("");
+ } else {
+ self.adapter.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_CHANGE,
+ action: function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ });
+ } else {
+ self._join(this.getValue(), function () {//安徽省 北京
+ assertShowValue();
+ });
+ }
+ }
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.trigger,
+ height: 30
+ }, {
+ el: this.adapter,
+ height: "fill"
+ }]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.searcherPane,
+ top: 30,
+ bottom: 0,
+ left: 0,
+ right: 0
+ }]
+ })
+ },
+
+ _showAdapter: function () {
+ this.adapter.setVisible(true);
+ this.searcherPane.setVisible(false);
+ },
+
+ _showSearcherPane: function () {
+ this.searcherPane.setVisible(true);
+ this.adapter.setVisible(false);
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ if (!this._allData) {
+ o.itemsCreator({
+ type: BI.MultiSelectList.REQ_GET_ALL_DATA
+ }, function (ob) {
+ self._allData = BI.pluck(ob.items, "value");
+ digest(self._allData);
+ })
+ } else {
+ digest(this._allData)
+ }
+
+ function digest(items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ o.itemsCreator({
+ type: BI.MultiSelectList.REQ_GET_ALL_DATA,
+ keyword: self.trigger.getKeyword()
+ }, function (ob) {
+ var items = BI.pluck(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ self._adjust(callback);
+ })
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ if (!this._count) {
+ o.itemsCreator({
+ type: BI.MultiSelectList.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ self._count = res.count;
+ adjust();
+ callback();
+ });
+ } else {
+ adjust();
+ callback();
+ }
+ function adjust() {
+ if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.Multi,
+ value: []
+ }
+ } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.All,
+ value: []
+ }
+ }
+ }
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.adapter.setStartValue(value);
+ },
+
+ isAllSelected: function () {
+ return this.adapter.isAllSelected();
+ },
+
+ resize: function () {
+ // this.trigger.getCounter().adjustView();
+ // this.trigger.adjustView();
+ },
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.adapter.setValue(this.storeValue);
+ this.trigger.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ populate: function () {
+ this._count = null;
+ this._allData = null;
+ this.adapter.populate.apply(this.adapter, arguments);
+ this.trigger.populate.apply(this.trigger, arguments);
+ }
+});
+
+BI.extend(BI.MultiSelectList, {
+ REQ_GET_DATA_LENGTH: 0,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.MultiSelectList.EVENT_CHANGE = "BI.MultiSelectList.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_list", BI.MultiSelectList);/**
+ * Created by zcf_1 on 2017/5/11.
+ */
+BI.MultiSelectTree = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-tree',
+ itemsCreator: BI.emptyFn
+ })
+ },
+
+ _init: function () {
+ BI.MultiSelectTree.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = {value: {}};
+
+ this.adapter = BI.createWidget({
+ type: "bi.multi_select_tree_popup",
+ itemsCreator: o.itemsCreator
+ });
+ this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
+ if (self.searcher.isSearching()) {
+ self.storeValue = {value: self.searcherPane.getValue()};
+ } else {
+ self.storeValue = {value: self.adapter.getValue()};
+ }
+ self.setSelectedValue(self.storeValue.value);
+ self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
+ });
+
+ //搜索中的时候用的是parttree,同adapter中的synctree不一样
+ this.searcherPane = BI.createWidget({
+ type: "bi.multi_tree_search_pane",
+ cls: "bi-border-left bi-border-right bi-border-bottom",
+ keywordGetter: function () {
+ return self.searcher.getKeyword();
+ },
+ itemsCreator: function (op, callback) {
+ op.keyword = self.searcher.getKeyword();
+ o.itemsCreator(op, callback);
+ }
+ });
+ this.searcherPane.setVisible(false);
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback({
+ keyword: self.searcher.getKeyword()
+ });
+ },
+ adapter: this.adapter,
+ popup: this.searcherPane,
+ masker: false,
+ listeners: [{
+ eventName: BI.Searcher.EVENT_START,
+ action: function () {
+ self._showSearcherPane();
+ // self.storeValue = {value: self.adapter.getValue()};
+ // self.searcherPane.setSelectedValue(self.storeValue.value);
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_STOP,
+ action: function () {
+ self._showAdapter();
+ // self.storeValue = {value: self.searcherPane.getValue()};
+ // self.adapter.setSelectedValue(self.storeValue.value);
+ BI.nextTick(function () {
+ self.adapter.populate();
+ });
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_CHANGE,
+ action: function () {
+ if (self.searcher.isSearching()) {
+ self.storeValue = {value: self.searcherPane.getValue()};
+ } else {
+ self.storeValue = {value: self.adapter.getValue()};
+ }
+ self.setSelectedValue(self.storeValue.value);
+ self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_PAUSE,
+ action: function () {
+ self._showAdapter();
+ }
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.searcher,
+ height: 30
+ }, {
+ el: this.adapter,
+ height: "fill"
+ }]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.searcherPane,
+ top: 30,
+ bottom: 0,
+ left: 0,
+ right: 0
+ }]
+ })
+
+ },
+
+ _showAdapter: function () {
+ this.adapter.setVisible(true);
+ this.searcherPane.setVisible(false);
+ },
+
+ _showSearcherPane: function () {
+ this.searcherPane.setVisible(true);
+ this.adapter.setVisible(false);
+ },
+
+ resize: function () {
+
+ },
+
+ setSelectedValue: function (v) {
+ this.storeValue.value = v || {};
+ this.adapter.setSelectedValue(v);
+ this.searcherPane.setSelectedValue(v);
+ this.searcher.setValue({
+ value: v || {}
+ });
+ },
+
+ setValue: function (v) {
+ this.adapter.setValue(v);
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ updateValue: function (v) {
+ this.adapter.updateValue(v);
+ },
+
+ getValue: function () {
+ return this.storeValue.value;
+ },
+
+ populate: function () {
+ this.searcher.populate.apply(this.searcher, arguments);
+ this.adapter.populate.apply(this.adapter, arguments);
+ }
+});
+BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
+ * Created by zcf on 2016/12/21.
+ */
+BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom",
+ itemsCreator: BI.emptyFn
+ });
+ },
+ _init: function () {
+ BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.popup = BI.createWidget({
+ type: "bi.async_tree",
+ element: this,
+ itemsCreator: o.itemsCreator
+ });
+ this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
+ self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)
+ });
+ this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)
+ });
+ },
+
+ hasChecked: function () {
+ return this.popup.hasChecked();
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.popup.setValue(v);
+ },
+
+ setSelectedValue: function (v) {
+ v || (v = {});
+ this.popup.setSelectedValue(v);
+ },
+
+ updateValue: function (v) {
+ this.popup.updateValue(v);
+ this.popup.refresh();
+ },
+
+ populate: function (config) {
+ this.popup.stroke(config);
+ }
+
+});
+BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
+BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);/**
+ *
+ * @class BI.MultiTreeCheckPane
+ * @extends BI.Pane
+ */
+BI.MultiTreeCheckPane = BI.inherit(BI.Pane, {
+
+ constants: {
+ height: 25,
+ lgap: 10,
+ tgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-tree-check-pane bi-background",
+ onClickContinueSelect: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeCheckPane.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.selectedValues = {};
+
+ var continueSelect = BI.createWidget({
+ type: 'bi.text_button',
+ text: BI.i18nText('BI-Continue_Select'),
+ cls: 'multi-tree-check-selected'
+ });
+ continueSelect.on(BI.TextButton.EVENT_CHANGE, function () {
+ opts.onClickContinueSelect();
+ BI.nextTick(function () {
+ self.empty();
+ });
+ });
+
+ var backToPopup = BI.createWidget({
+ type: 'bi.left',
+ cls: 'multi-tree-continue-select',
+ items: [
+ {
+ el: {
+ type: "bi.label",
+ text: BI.i18nText('BI-Selected_Data')
+ },
+ lgap: this.constants.lgap,
+ tgap: this.constants.tgap
+ },
+ {
+ el: continueSelect,
+ lgap: this.constants.lgap,
+ tgap: this.constants.tgap
+ }]
+ });
+
+ this.display = BI.createWidget({
+ type: "bi.display_tree",
+ cls: "bi-multi-tree-display",
+ itemsCreator: function (op, callback) {
+ op.type = BI.TreeView.REQ_TYPE_GET_SELECTED_DATA;
+ opts.itemsCreator(op, callback);
+ }
+ });
+
+ this.display.on(BI.Events.AFTERINIT, function () {
+ self.fireEvent(BI.Events.AFTERINIT);
+ });
+
+ this.display.on(BI.TreeView.EVENT_INIT, function () {
+ backToPopup.setVisible(false);
+ });
+
+ this.display.on(BI.TreeView.EVENT_AFTERINIT, function () {
+ backToPopup.setVisible(true);
+ });
+
+ BI.createWidget({
+ type: 'bi.vtape',
+ element: this,
+ items: [{
+ height: this.constants.height,
+ el: backToPopup
+ }, {
+ height: 'fill',
+ el: this.display
+ }]
+ });
+
+ },
+
+ empty: function () {
+ this.display.empty();
+ },
+
+ populate: function (configs) {
+ this.display.stroke(configs);
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.display.setSelectedValue(v.value);
+ },
+
+ getValue: function () {
+
+ }
+});
+
+BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK";
+
+
+BI.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/**
+ *
+ * @class BI.MultiTreeCombo
+ * @extends BI.Single
+ */
+
+BI.MultiTreeCombo = BI.inherit(BI.Single, {
+
+ constants: {
+ offset: {
+ top: 1,
+ left: 1,
+ right: 2,
+ bottom: 33
+ }
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-tree-combo',
+ itemsCreator: BI.emptyFn,
+ height: 25
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeCombo.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ var isInit = false;
+ var want2showCounter = false;
+
+ this.trigger = BI.createWidget({
+ type: "bi.multi_select_trigger",
+ height: o.height,
+ // adapter: this.popup,
+ masker: {
+ offset: this.constants.offset
+ },
+ searcher: {
+ type: "bi.multi_tree_searcher",
+ itemsCreator: o.itemsCreator
+ },
+ switcher: {
+ el: {
+ type: "bi.multi_tree_check_selected_button"
+ },
+ popup: {
+ type: "bi.multi_tree_check_pane",
+ itemsCreator: o.itemsCreator
+ }
+ }
+
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ el: this.trigger,
+ adjustLength: 1,
+ popup: {
+ type: 'bi.multi_tree_popup_view',
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.MultiTreePopup.EVENT_AFTERINIT,
+ action: function () {
+ self.trigger.getCounter().adjustView();
+ isInit = true;
+ if (want2showCounter === true) {
+ showCounter();
+ }
+ }
+ }, {
+ eventName: BI.MultiTreePopup.EVENT_CHANGE,
+ action: function () {
+ change = true;
+ var val = {
+ type: BI.Selection.Multi,
+ value: this.hasChecked() ? {1: 1} : {}
+ };
+ self.trigger.getSearcher().setState(val);
+ self.trigger.getCounter().setButtonChecked(val);
+ }
+ }, {
+ eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM,
+ action: function () {
+ self.combo.hideView();
+ }
+ }, {
+ eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR,
+ action: function () {
+ clear = true;
+ self.setValue();
+ self._defaultState();
+ }
+ }],
+ itemsCreator: o.itemsCreator,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.trigger.getCounter().adjustView();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ }
+ });
+
+ this.storeValue = {value: {}};
+ var change = false;
+ var clear = false; //标识当前是否点击了清空
+
+ var isSearching = function () {
+ return self.trigger.getSearcher().isSearching();
+ };
+
+ var isPopupView = function () {
+ return self.combo.isViewVisible();
+ };
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
+ self.storeValue = {value: self.combo.getValue()};
+ this.setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
+ self.storeValue = {value: this.getValue()};
+ self.combo.setValue(self.storeValue);
+ BI.nextTick(function () {
+ if (isPopupView()) {
+ self.combo.populate();
+ }
+ });
+ });
+ function showCounter() {
+ if (isSearching()) {
+ self.storeValue = {value: self.trigger.getValue()};
+ } else if (isPopupView()) {
+ self.storeValue = {value: self.combo.getValue()};
+ }
+ self.trigger.setValue(self.storeValue);
+ }
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
+ if (want2showCounter === false) {
+ want2showCounter = true;
+ }
+ if (isInit === true) {
+ want2showCounter = null;
+ showCounter();
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () {
+ self.combo.toggle();
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
+ var val = {
+ type: BI.Selection.Multi,
+ value: this.getSearcher().hasChecked() ? {1: 1} : {}
+ };
+ this.getSearcher().setState(val);
+ this.getCounter().setButtonChecked(val);
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ if (isSearching()) {
+ return;
+ }
+ if (change === true) {
+ self.storeValue = {value: self.combo.getValue()};
+ change = false;
+ }
+ self.combo.setValue(self.storeValue);
+ self.populate();
+
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () {
+ if (isSearching()) {
+ self.trigger.stopEditing();
+ self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
+ }else{
+ if (isPopupView()) {
+ self.trigger.stopEditing();
+ self.storeValue = {value: self.combo.getValue()};
+ if (clear === true) {
+ self.storeValue = {value: {}};
+ }
+ self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
+ }
+ }
+ clear = false;
+ change = false;
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "multi-select-trigger-icon-button bi-border-left"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ self.trigger.getCounter().hideView();
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ })
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ setValue: function (v) {
+ this.storeValue.value = v || {};
+ this.combo.setValue({
+ value: v || {}
+ });
+ },
+
+ getValue: function () {
+ return this.storeValue.value;
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+
+BI.MultiTreeCombo.EVENT_CONFIRM = "MultiTreeCombo.EVENT_CONFIRM";
+
+BI.shortcut('bi.multi_tree_combo', BI.MultiTreeCombo);/**
+ * 带加载的多选下拉面板
+ * @class BI.MultiTreePopup
+ * @extends BI.Pane
+ */
+BI.MultiTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-tree-popup',
+ maxWidth: 'auto',
+ minWidth: 100,
+ maxHeight: 400,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.selectedValues = {};
+
+ this.tree = BI.createWidget({
+ type: "bi.async_tree",
+ height: 400,
+ cls:"popup-view-tree",
+ itemsCreator: opts.itemsCreator,
+ onLoaded: opts.onLoaded
+ });
+
+ this.popupView = BI.createWidget({
+ type: "bi.multi_popup_view",
+ element: this,
+ stopPropagation: false,
+ maxWidth: opts.maxWidth,
+ minWidth: opts.minWidth,
+ maxHeight: opts.maxHeight,
+ buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')],
+ el: this.tree
+ });
+
+ this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
+ switch (index) {
+ case 0:
+ self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM);
+ break;
+ }
+ });
+
+ this.tree.on(BI.TreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiTreePopup.EVENT_CHANGE);
+ });
+
+ this.tree.on(BI.TreeView.EVENT_AFTERINIT, function () {
+ self.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT);
+ });
+
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.tree.setSelectedValue(v.value);
+ },
+
+ populate: function (config) {
+ this.tree.stroke(config);
+ },
+
+ hasChecked: function () {
+ return this.tree.hasChecked();
+ },
+
+ resetHeight: function (h) {
+ this.popupView.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.popupView.resetWidth(w);
+ }
+});
+
+BI.MultiTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiTreePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.MultiTreePopup.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+BI.MultiTreePopup.EVENT_AFTERINIT = "EVENT_AFTERINIT";
+
+
+BI.shortcut('bi.multi_tree_popup_view', BI.MultiTreePopup);/**
+ *
+ * 在搜索框中输入文本弹出的面板
+ * @class BI.MultiTreeSearchPane
+ * @extends BI.Pane
+ */
+
+BI.MultiTreeSearchPane = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-tree-search-pane bi-card",
+ itemsCreator: BI.emptyFn,
+ keywordGetter: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeSearchPane.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.partTree = BI.createWidget({
+ type: "bi.part_tree",
+ element: this,
+ tipText: BI.i18nText("BI-No_Select"),
+ itemsCreator: function (op, callback) {
+ op.keyword = opts.keywordGetter();
+ opts.itemsCreator(op, callback);
+ }
+ });
+
+ this.partTree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.partTree.on(BI.TreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE);
+ });
+ },
+
+ hasChecked: function () {
+ return this.partTree.hasChecked();
+ },
+
+ setValue: function (v) {
+ this.setSelectedValue(v.value);
+ },
+
+ setSelectedValue: function (v) {
+ v || (v = {});
+ this.partTree.setSelectedValue(v);
+ },
+
+ getValue: function () {
+ return this.partTree.getValue();
+ },
+
+ empty: function () {
+ this.partTree.empty();
+ },
+
+ populate: function (op) {
+ this.partTree.stroke.apply(this.partTree, arguments);
+ }
+});
+
+BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+
+BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane);/**
+ * 查看已选按钮
+ * Created by guy on 15/11/3.
+ * @class BI.MultiTreeCheckSelectedButton
+ * @extends BI.Single
+ */
+BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, {
+
+ _const: {
+ checkSelected: BI.i18nText('BI-Check_Selected')
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-tree-check-selected-button',
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeCheckSelectedButton.superclass._init.apply(this, arguments);
+ var self = this;
+ this.indicator = BI.createWidget({
+ type: 'bi.icon_button',
+ cls: 'check-font trigger-check-selected',
+ width: 15,
+ height: 15,
+ stopPropagation: true
+ });
+
+ this.checkSelected = BI.createWidget({
+ type: 'bi.text_button',
+ cls: "trigger-check-selected",
+ invisible: true,
+ hgap: 4,
+ text: this._const.checkSelected,
+ textAlign: 'center',
+ textHeight: 15
+ });
+ this.checkSelected.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.checkSelected.on(BI.TextButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
+ });
+
+ BI.createWidget({
+ type: "bi.horizontal",
+ element: this,
+ items: [this.indicator, this.checkSelected]
+ })
+
+ this.element.hover(function () {
+ self.indicator.setVisible(false);
+ self.checkSelected.setVisible(true);
+ }, function () {
+ self.indicator.setVisible(true);
+ self.checkSelected.setVisible(false);
+ });
+ this.setVisible(false);
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.setVisible(BI.size(v.value) > 0);
+ }
+});
+
+BI.MultiTreeCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.multi_tree_check_selected_button', BI.MultiTreeCheckSelectedButton);/**
+ * searcher
+ * Created by guy on 15/11/3.
+ * @class BI.MultiTreeSearcher
+ * @extends Widget
+ */
+BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-tree-searcher',
+ itemsCreator: BI.emptyFn,
+ popup: {},
+
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeSearcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: 'bi.multi_select_editor',
+ height: o.height,
+ el: {
+ type: "bi.simple_state_editor",
+ height: o.height
+ }
+ });
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ element: this,
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback({
+ keyword: self.editor.getValue()
+ });
+ },
+ el: this.editor,
+
+ popup: BI.extend({
+ type: "bi.multi_tree_search_pane",
+ keywordGetter: function () {
+ return self.editor.getValue();
+ },
+ itemsCreator: function (op, callback) {
+ op.keyword = self.editor.getValue();
+ o.itemsCreator(op, callback);
+ }
+ }, o.popup),
+
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.Searcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_START);
+ });
+ this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
+ if (this.hasMatched()) {
+
+ }
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.Searcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_STOP);
+ });
+ this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE, arguments);
+ });
+ },
+
+ adjustView: function () {
+ this.searcher.adjustView();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ },
+
+ isSearching: function () {
+ return this.searcher.isSearching();
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ getKeyword: function () {
+ return this.editor.getValue();
+ },
+
+ hasMatched: function () {
+ return this.searcher.hasMatched();
+ },
+
+ hasChecked: function () {
+ return this.searcher.getView() && this.searcher.getView().hasChecked();
+ },
+
+ setState: function (ob) {
+ ob || (ob = {});
+ ob.value || (ob.value = []);
+ if (ob.type === BI.Selection.All) {
+ this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All);
+ } else {
+ this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None);
+ }
+ },
+
+ setValue: function (ob) {
+ this.setState(ob);
+ this.searcher.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ },
+
+ populate: function (items) {
+ this.searcher.populate.apply(this.searcher, arguments);
+ }
+});
+
+BI.MultiTreeSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
+BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
+BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
+BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);//小于号的值为:0,小于等于号的值为:1
+//closeMIn:最小值的符号,closeMax:最大值的符号
+/**
+ * Created by roy on 15/9/17.
+ *
+ */
+BI.NumericalInterval = BI.inherit(BI.Single, {
+ constants: {
+ typeError: "typeBubble",
+ numberError: "numberBubble",
+ signalError: "signalBubble",
+ editorWidth: 114,
+ columns: 5,
+ width: 30,
+ rows: 1,
+ numberErrorCls: "number-error",
+ border: 1,
+ less: 0,
+ less_equal: 1,
+ numTip: ""
+ },
+ _defaultConfig: function () {
+ var conf = BI.NumericalInterval.superclass._defaultConfig.apply(this, arguments)
+ return BI.extend(conf, {
+ extraCls: "bi-numerical-interval",
+ height: 25,
+ validation: "valid"
+ })
+ },
+ _init: function () {
+ var self = this, c = this.constants, o = this.options;
+ BI.NumericalInterval.superclass._init.apply(this, arguments)
+ this.smallEditor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height - 2,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ allowBlank: true,
+ value: o.min,
+ level: "warning",
+ tipType: "warning",
+ quitChecker: function () {
+ return false;
+ },
+ validationChecker: function (v) {
+ if (!BI.isNumeric(v)) {
+ self.smallEditorBubbleType = c.typeError;
+ return false;
+ }
+ return true;
+ },
+ cls: "numerical-interval-small-editor bi-border-top bi-border-bottom bi-border-left"
+ });
+
+ this.smallTip = BI.createWidget({
+ type: "bi.label",
+ text: o.numTip,
+ height: o.height - 2,
+ invisible: true
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.smallEditor.element,
+ items: [{
+ el: this.smallTip,
+ top: 0,
+ right: 5
+ }]
+ });
+
+ this.bigEditor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height - 2,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ allowBlank: true,
+ value: o.max,
+ level: "warning",
+ tipType: "warning",
+ quitChecker: function () {
+ return false;
+ },
+ validationChecker: function (v) {
+ if (!BI.isNumeric(v)) {
+ self.bigEditorBubbleType = c.typeError;
+ return false;
+ }
+ return true;
+ },
+ cls: "numerical-interval-big-editor bi-border-top bi-border-bottom bi-border-right"
+ });
+
+ this.bigTip = BI.createWidget({
+ type: "bi.label",
+ text: o.numTip,
+ height: o.height - 2,
+ invisible: true
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.bigEditor.element,
+ items: [{
+ el: this.bigTip,
+ top: 0,
+ right: 5
+ }]
+ });
+
+ //this.smallCombo = BI.createWidget({
+ // type: "bi.numerical_interval_combo",
+ // cls: "numerical-interval-small-combo",
+ // height: o.height,
+ // value: o.closemin ? 1 : 0,
+ // offsetStyle: "left"
+ //});
+ //
+ //this.bigCombo = BI.createWidget({
+ // type: "bi.numerical_interval_combo",
+ // cls: "numerical-interval-big-combo",
+ // height: o.height,
+ // value: o.closemax ? 1 : 0,
+ // offsetStyle: "left"
+ //});
+ this.smallCombo = BI.createWidget({
+ type: "bi.icon_combo",
+ cls: "numerical-interval-small-combo bi-border",
+ height: o.height - 2,
+ items: [{
+ text: "(" + BI.i18nText("BI-Less_Than") + ")",
+ iconClass: "less-font",
+ value: 0
+ }, {
+ text: "(" + BI.i18nText("BI-Less_And_Equal") + ")",
+ value: 1,
+ iconClass: "less-equal-font"
+ }]
+ });
+ if (o.closemin === true) {
+ this.smallCombo.setValue(1);
+ } else {
+ this.smallCombo.setValue(0);
+ }
+ this.bigCombo = BI.createWidget({
+ type: "bi.icon_combo",
+ cls: "numerical-interval-big-combo bi-border",
+ height: o.height - 2,
+ items: [{
+ text: "(" + BI.i18nText("BI-Less_Than") + ")",
+ iconClass: "less-font",
+ value: 0
+ }, {
+ text: "(" + BI.i18nText("BI-Less_And_Equal") + ")",
+ value: 1,
+ iconClass: "less-equal-font"
+ }]
+ });
+ if (o.closemax === true) {
+ this.bigCombo.setValue(1);
+ } else {
+ this.bigCombo.setValue(0);
+ }
+ this.label = BI.createWidget({
+ type: "bi.label",
+ text: BI.i18nText("BI-Basic_Value"),
+ textHeight: o.height - c.border * 2,
+ width: c.width - c.border * 2,
+ height: o.height - c.border * 2,
+ level: "warning",
+ tipType: "warning"
+ });
+ this.left = BI.createWidget({
+ type: "bi.htape",
+ items: [{
+ el: self.smallEditor
+ }, {
+ el: self.smallCombo,
+ width: c.width - c.border * 2
+ }]
+
+ });
+ this.right = BI.createWidget({
+ type: "bi.htape",
+ items: [{
+ el: self.bigCombo,
+ width: c.width - c.border * 2
+ }, {
+ el: self.bigEditor
+ }]
+ });
+
+
+ BI.createWidget({
+ element: self,
+ type: "bi.center",
+ hgap: 15,
+ height: o.height,
+ items: [
+ {
+ type: "bi.absolute",
+ items: [{
+ el: self.left,
+ left: -15,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: self.right,
+ left: 0,
+ right: -15,
+ top: 0,
+ bottom: 0
+ }]
+ }
+ ]
+ });
+
+ BI.createWidget({
+ element: self,
+ type: "bi.horizontal_auto",
+ items: [
+ self.label
+ ]
+ });
+
+
+ self._setValidEvent(self.bigEditor, c.bigEditor);
+ self._setValidEvent(self.smallEditor, c.smallEditor);
+ self._setErrorEvent(self.bigEditor, c.bigEditor);
+ self._setErrorEvent(self.smallEditor, c.smallEditor);
+ self._setBlurEvent(self.bigEditor);
+ self._setBlurEvent(self.smallEditor);
+ self._setFocusEvent(self.bigEditor);
+ self._setFocusEvent(self.smallEditor);
+ self._setComboValueChangedEvent(self.bigCombo);
+ self._setComboValueChangedEvent(self.smallCombo);
+ self._setEditorValueChangedEvent(self.bigEditor);
+ self._setEditorValueChangedEvent(self.smallEditor);
+ },
+
+ _checkValidation: function () {
+ var self = this, c = this.constants, o = this.options;
+ self._setTitle("");
+ BI.Bubbles.hide(c.typeError);
+ BI.Bubbles.hide(c.numberError);
+ BI.Bubbles.hide(c.signalError);
+ if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) {
+ self.element.removeClass("number-error");
+ o.validation = "invalid";
+ return c.typeError;
+ } else {
+ if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) {
+ self.element.removeClass("number-error");
+ o.validation = "valid";
+ return "";
+ } else {
+ var smallValue = parseFloat(self.smallEditor.getValue()), bigValue = parseFloat(self.bigEditor.getValue()),
+ bigComboValue = self.bigCombo.getValue(), smallComboValue = self.smallCombo.getValue();
+ if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) {
+ if (smallValue > bigValue) {
+ self.element.addClass("number-error");
+ o.validation = "invalid";
+ return c.numberError;
+ } else {
+ self.element.removeClass("number-error");
+ o.validation = "valid";
+ return "";
+ }
+ } else {
+ if (smallValue > bigValue) {
+ self.element.addClass("number-error");
+ o.validation = "invalid";
+ return c.numberError;
+ } else if (smallValue === bigValue) {
+ self.element.addClass("number-error");
+ o.validation = "invalid";
+ return c.signalError;
+ } else {
+ self.element.removeClass("number-error");
+ o.validation = "valid";
+ return "";
+ }
+ }
+ }
+
+ }
+ },
+
+ _setTitle: function (v) {
+ var self = this;
+ self.bigEditor.setTitle(v);
+ self.smallEditor.setTitle(v);
+ self.label.setTitle(v);
+ },
+
+ _setFocusEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.Editor.EVENT_FOCUS, function () {
+ self._setTitle("");
+ switch (self._checkValidation()) {
+ case c.typeError:
+ BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ case c.numberError:
+ BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ case c.signalError:
+ BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ default :
+ return
+ }
+
+ })
+ },
+ _setBlurEvent: function (w) {
+ var c = this.constants, self = this;
+ w.on(BI.Editor.EVENT_BLUR, function () {
+ BI.Bubbles.hide(c.typeError);
+ BI.Bubbles.hide(c.numberError);
+ BI.Bubbles.hide(c.signalError);
+ switch (self._checkValidation()) {
+ case c.typeError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));
+ break;
+ case c.numberError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));
+ break;
+ case c.signalError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));
+ break;
+ default:
+ self._setTitle("");
+ }
+ })
+ },
+
+ _setErrorEvent: function (w) {
+ var c = this.constants, self = this
+ w.on(BI.Editor.EVENT_ERROR, function () {
+ self._checkValidation();
+ BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ })
+ },
+
+
+ _setValidEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.Editor.EVENT_VALID, function () {
+ switch (self._checkValidation()) {
+ case c.numberError:
+ BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ break;
+ case c.signalError:
+ BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ break;
+ default:
+ self.fireEvent(BI.NumericalInterval.EVENT_VALID);
+ }
+ })
+ },
+
+
+ _setEditorValueChangedEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.Editor.EVENT_CHANGE, function () {
+ switch (self._checkValidation()) {
+ case c.typeError:
+ BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ case c.numberError:
+ BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ case c.signalError:
+ BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ default :
+ break;
+ }
+ self.fireEvent(BI.NumericalInterval.EVENT_CHANGE);
+ });
+ },
+
+ _setComboValueChangedEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.IconCombo.EVENT_CHANGE, function () {
+ switch (self._checkValidation()) {
+ case c.typeError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ break;
+ case c.numberError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ break;
+ case c.signalError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ break;
+ default :
+ self.fireEvent(BI.NumericalInterval.EVENT_CHANGE);
+ self.fireEvent(BI.NumericalInterval.EVENT_VALID);
+ }
+ })
+ },
+
+ isStateValid: function () {
+ return this.options.validation === "valid";
+ },
+
+ setMinEnable: function (b) {
+ this.smallEditor.setEnable(b);
+ },
+
+ setCloseMinEnable: function (b) {
+ this.smallCombo.setEnable(b);
+ },
+
+ setMaxEnable: function (b) {
+ this.bigEditor.setEnable(b);
+ },
+
+ setCloseMaxEnable: function (b) {
+ this.bigCombo.setEnable(b);
+ },
+
+ showNumTip: function () {
+ this.smallTip.setVisible(true);
+ this.bigTip.setVisible(true);
+ },
+
+ hideNumTip: function () {
+ this.smallTip.setVisible(false);
+ this.bigTip.setVisible(false);
+ },
+
+ setNumTip: function(numTip) {
+ this.smallTip.setText(numTip);
+ this.bigTip.setText(numTip);
+ },
+
+ getNumTip: function() {
+ return this.smallTip.getText();
+ },
+
+ setValue: function (data) {
+ data = data || {};
+ var self = this, combo_value;
+ if (BI.isNumeric(data.min) || BI.isEmptyString(data.min)) {
+ self.smallEditor.setValue(data.min);
+ }
+
+ if (!BI.isNotNull(data.min)) {
+ self.smallEditor.setValue("");
+ }
+
+ if (BI.isNumeric(data.max) || BI.isEmptyString(data.max)) {
+ self.bigEditor.setValue(data.max);
+ }
+
+ if (!BI.isNotNull(data.max)) {
+ self.bigEditor.setValue("");
+ }
+
+ if (!BI.isNull(data.closemin)) {
+ if (data.closemin === true) {
+ combo_value = 1
+ } else {
+ combo_value = 0
+ }
+ self.smallCombo.setValue(combo_value);
+ }
+
+ if (!BI.isNull(data.closemax)) {
+ if (data.closemax === true) {
+ combo_value = 1
+ } else {
+ combo_value = 0
+ }
+ self.bigCombo.setValue(combo_value);
+ }
+ },
+
+
+ getValue: function () {
+ var self = this, value = {}, minComboValue = self.smallCombo.getValue(), maxComboValue = self.bigCombo.getValue();
+ value.min = self.smallEditor.getValue();
+ value.max = self.bigEditor.getValue();
+ if (minComboValue[0] === 0) {
+ value.closemin = false
+ } else {
+ value.closemin = true
+ }
+
+ if (maxComboValue[0] === 0) {
+ value.closemax = false
+ } else {
+ value.closemax = true
+ }
+ return value;
+ }
+});
+BI.NumericalInterval.EVENT_CHANGE = "EVENT_CHANGE";
+BI.NumericalInterval.EVENT_VALID = "EVENT_VALID";
+BI.NumericalInterval.EVENT_ERROR = "EVENT_ERROR";
+BI.shortcut("bi.numerical_interval", BI.NumericalInterval);/**
+ *
+ * 表格
+ *
+ * Created by GUY on 2015/9/22.
+ * @class BI.PageTableCell
+ * @extends BI.Single
+ */
+BI.PageTableCell = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-page-table-cell",
+ text: "",
+ title: ""
+ })
+ },
+
+ _init: function () {
+ BI.PageTableCell.superclass._init.apply(this, arguments);
+ var label = BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ height: this.options.height,
+ text: this.options.text,
+ title: this.options.title,
+ value: this.options.value,
+ lgap: 5,
+ rgap: 5
+ });
+
+ if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) {
+ this.element.css(this.options.styles);
+ }
+ }
+});
+
+BI.shortcut("bi.page_table_cell", BI.PageTableCell);/**
+ * 分页表格
+ *
+ * Created by GUY on 2016/2/15.
+ * @class BI.PageTable
+ * @extends BI.Widget
+ */
+BI.PageTable = BI.inherit(BI.Widget, {
+
+ _const: {
+ scrollWidth: 18,
+ minScrollWidth: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-page-table",
+ el: {
+ type: "bi.sequence_table"
+ },
+ pager: {
+ horizontal: {
+ pages: false, //总页数
+ curr: 1, //初始化当前页, pages为数字时可用
+
+ hasPrev: BI.emptyFn,
+ hasNext: BI.emptyFn,
+ firstPage: 1,
+ lastPage: BI.emptyFn
+ },
+ vertical: {
+ pages: false, //总页数
+ curr: 1, //初始化当前页, pages为数字时可用
+
+ hasPrev: BI.emptyFn,
+ hasNext: BI.emptyFn,
+ firstPage: 1,
+ lastPage: BI.emptyFn
+ }
+ },
+
+ itemsCreator: BI.emptyFn,
+
+ isNeedFreeze: false,//是否需要冻结单元格
+ freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
+
+ isNeedMerge: false,//是否需要合并单元格
+ mergeCols: [], //合并的单元格列号
+ mergeRule: BI.emptyFn,
+
+ columnSize: [],
+ minColumnSize: [],
+ maxColumnSize: [],
+ headerRowSize: 25,
+ rowSize: 25,
+
+ regionColumnSize: [],
+
+ headerCellStyleGetter: BI.emptyFn,
+ summaryCellStyleGetter: BI.emptyFn,
+ sequenceCellStyleGetter: BI.emptyFn,
+
+ header: [],
+ items: [], //二维数组
+
+ //交叉表头
+ crossHeader: [],
+ crossItems: []
+ });
+ },
+
+ _init: function () {
+ BI.PageTable.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.hCurr = 1;
+ this.vCurr = 1;
+
+ this.table = BI.createWidget(o.el, {
+ type: "bi.sequence_table",
+ width: o.width,
+ height: o.height && o.height - 30,
+
+ isNeedResize: true,
+ isResizeAdapt: false,
+
+ isNeedFreeze: o.isNeedFreeze,
+ freezeCols: o.freezeCols,
+
+ isNeedMerge: o.isNeedMerge,
+ mergeCols: o.mergeCols,
+ mergeRule: o.mergeRule,
+
+ columnSize: o.columnSize,
+ minColumnSize: o.minColumnSize,
+ maxColumnSize: o.maxColumnSize,
+ headerRowSize: o.headerRowSize,
+ rowSize: o.rowSize,
+
+ regionColumnSize: o.regionColumnSize,
+
+ headerCellStyleGetter: o.headerCellStyleGetter,
+ summaryCellStyleGetter: o.summaryCellStyleGetter,
+ sequenceCellStyleGetter: o.sequenceCellStyleGetter,
+
+ header: o.header,
+ items: o.items,
+ //交叉表头
+ crossHeader: o.crossHeader,
+ crossItems: o.crossItems
+ });
+
+ this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
+ self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
+ o.regionColumnSize = this.getRegionColumnSize();
+ o.columnSize = this.getColumnSize();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
+ o.regionColumnSize = this.getRegionColumnSize();
+ o.columnSize = this.getColumnSize();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
+ });
+
+ this.pager = BI.createWidget(o.pager, {
+ type: "bi.direction_pager",
+ height: 30
+ });
+ this.pager.on(BI.Pager.EVENT_CHANGE, function () {
+ var vpage = this.getVPage && this.getVPage();
+ if (BI.isNull(vpage)) {
+ vpage = this.getCurrentPage();
+ }
+ var hpage = this.getHPage && this.getHPage();
+ o.itemsCreator({
+ vpage: vpage,
+ hpage: hpage
+ }, function (items, header, crossItems, crossHeader) {
+ self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage);
+ self.table.setHPage && self.table.setHPage(hpage);
+ self.populate.apply(self, arguments);
+ });
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.table,
+ left: 0,
+ top: 0
+ }, {
+ el: this.pager,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }]
+ })
+ },
+
+ setHPage: function (v) {
+ this.hCurr = v;
+ this.pager.setHPage && this.pager.setHPage(v);
+ this.table.setHPage && this.table.setHPage(v);
+ },
+
+ setVPage: function (v) {
+ this.vCurr = v;
+ this.pager.setVPage && this.pager.setVPage(v);
+ this.table.setVPage && this.table.setVPage(v);
+ },
+
+ getHPage: function () {
+ var hpage = this.pager.getHPage && this.pager.getHPage();
+ if (BI.isNotNull(hpage)) {
+ return hpage;
+ }
+ hpage = this.pager.getCurrentPage && this.pager.getCurrentPage();
+ if (BI.isNotNull(hpage)) {
+ return hpage;
+ }
+ return this.hpage;
+ },
+
+ getVPage: function () {
+ var vpage = this.pager.getVPage && this.pager.getVPage();
+ if (BI.isNotNull(vpage)) {
+ return vpage;
+ }
+ vpage = this.pager.getCurrentPage && this.pager.getCurrentPage();
+ if (BI.isNotNull(vpage)) {
+ return vpage;
+ }
+ return this.vpage;
+ },
+
+ setWidth: function (width) {
+ BI.PageTable.superclass.setWidth.apply(this, arguments);
+ this.table.setWidth(width);
+ },
+
+ setHeight: function (height) {
+ BI.PageTable.superclass.setHeight.apply(this, arguments);
+ var showPager = false;
+ if (this.pager.alwaysShowPager) {
+ showPager = true;
+ } else if (this.pager.hasHNext && this.pager.hasHNext()) {
+ showPager = true;
+ } else if (this.pager.hasHPrev && this.pager.hasHPrev()) {
+ showPager = true;
+ } else if (this.pager.hasVNext && this.pager.hasVNext()) {
+ showPager = true;
+ } else if (this.pager.hasVPrev && this.pager.hasVPrev()) {
+ showPager = true;
+ } else if (this.pager.hasNext && this.pager.hasNext()) {
+ showPager = true;
+ } else if (this.pager.hasPrev && this.pager.hasPrev()) {
+ showPager = true;
+ }
+ this.table.setHeight(height - (showPager ? 30 : 0));
+ },
+
+ setColumnSize: function (columnSize) {
+ this.options.columnSize = columnSize;
+ this.table.setColumnSize(columnSize);
+ },
+
+ getColumnSize: function () {
+ return this.table.getColumnSize();
+ },
+
+ setRegionColumnSize: function (columnSize) {
+ this.options.columnSize = columnSize;
+ this.table.setRegionColumnSize(columnSize);
+ },
+
+ getRegionColumnSize: function () {
+ return this.table.getRegionColumnSize();
+ },
+
+ getVerticalScroll: function () {
+ return this.table.getVerticalScroll();
+ },
+
+ setLeftHorizontalScroll: function (scrollLeft) {
+ this.table.setLeftHorizontalScroll(scrollLeft);
+ },
+
+ setRightHorizontalScroll: function (scrollLeft) {
+ this.table.setRightHorizontalScroll(scrollLeft);
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ this.table.setVerticalScroll(scrollTop);
+ },
+
+ restore: function () {
+ this.table.restore();
+ },
+
+ attr: function () {
+ BI.PageTable.superclass.attr.apply(this, arguments);
+ this.table.attr.apply(this.table, arguments);
+ },
+
+ populate: function () {
+ this.pager.populate();
+ this.table.populate.apply(this.table, arguments);
+ },
+
+ destroy: function () {
+ this.table.destroy();
+ this.pager && this.pager.destroy();
+ BI.PageTable.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.shortcut('bi.page_table', BI.PageTable);/**
+ * 路径选择
+ *
+ * Created by GUY on 2015/12/4.
+ * @class BI.PathChooser
+ * @extends BI.Widget
+ */
+BI.PathChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ lineColor: "#d4dadd",
+ selectLineColor: "#3f8ce8"
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-path-chooser",
+ items: []
+ })
+ },
+
+ _init: function () {
+ BI.PathChooser.superclass._init.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _createRegions: function (regions) {
+ var self = this;
+ this.regions = BI.createWidgets(BI.map(regions, function (i, region) {
+ return {
+ type: "bi.path_region",
+ title: self.texts[region] || region
+ }
+ }));
+ this.regionMap = {};
+ BI.each(regions, function (i, region) {
+ self.regionMap[region] = i;
+ });
+ this.container = BI.createWidget({
+ type: "bi.horizontal",
+ verticalAlign: "top",
+ scrollx: false,
+ scrolly: false,
+ hgap: 10,
+ items: this.regions
+ });
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ element: this,
+ scrollable: true,
+ hgap: 10,
+ items: [this.container]
+ });
+ },
+
+ getRegionIndexById: function (id) {
+ var node = this.store[id];
+ var regionType = node.get("region");
+ return this.regionMap[regionType];
+ },
+
+ _drawPath: function (start, offset, index) {
+ var self = this;
+ var starts = [];
+ if (BI.contains(this.start, start)) {
+ starts = this.start;
+ } else {
+ starts = [start];
+ }
+
+ BI.each(starts, function (i, s) {
+ BI.each(self.radios[s], function (i, rad) {
+ rad.setSelected(false);
+ });
+ BI.each(self.lines[s], function (i, line) {
+ line.attr("stroke", self._const.lineColor);
+ });
+ BI.each(self.regionIndexes[s], function (i, idx) {
+ self.regions[idx].reset();
+ });
+ });
+
+ BI.each(this.routes[start][index], function (i, id) {
+ var regionIndex = self.getRegionIndexById(id);
+ self.regions[regionIndex].setSelect(offset + index, id);
+ });
+ var current = BI.last(this.routes[start][index]);
+
+ while (current && this.routes[current] && this.routes[current].length === 1) {
+ BI.each(this.routes[current][0], function (i, id) {
+ var regionIndex = self.getRegionIndexById(id);
+ self.regions[regionIndex].setSelect(0, id);
+ });
+ this.lines[current][0].attr("stroke", self._const.selectLineColor).toFront();
+ current = BI.last(this.routes[current][0]);
+ }
+ this.lines[start][index].attr("stroke", self._const.selectLineColor).toFront();
+ this.radios[start] && this.radios[start][index] && this.radios[start][index].setSelected(true);
+ },
+
+ _drawRadio: function (start, offset, index, x, y) {
+ var self = this;
+ var radio = BI.createWidget({
+ type: "bi.radio",
+ cls: "path-chooser-radio",
+ selected: offset + index === 0,
+ start: start,
+ index: index
+ });
+ radio.on(BI.Radio.EVENT_CHANGE, function () {
+ self._drawPath(start, offset, index);
+ self.fireEvent(BI.PathChooser.EVENT_CHANGE, start, index);
+ });
+ if (!this.radios[start]) {
+ this.radios[start] = [];
+ }
+ this.radios[start].push(radio);
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: [{
+ el: radio,
+ left: x - 6.5,
+ top: y - 6.5
+ }]
+ })
+ },
+
+ _drawLine: function (start, lines) {
+ var self = this;
+ if (!this.lines[start]) {
+ this.lines[start] = [];
+ }
+ if (!this.pathes[start]) {
+ this.pathes[start] = [];
+ }
+ var startRegionIndex = this.getRegionIndexById(start);
+ //start所在的位置,然后接着往下画其他的路径
+ var offset = this.regions[startRegionIndex].getIndexByValue(start);
+ BI.each(lines, function (i, line) {
+ self.pathes[start][i] = [];
+ var idx = i + offset;
+ var path = "";
+ var stop = 47.5 + 29 * idx;
+ var sleft = 50 + 100 * startRegionIndex;
+ var radioStartX = sleft, radioStartY = stop;
+ var etop = stop;
+ var endRegionIndex = self.getRegionIndexById(BI.last(line));
+ var endOffset = self.regions[endRegionIndex].getIndexByValue(BI.last(line));
+ var eleft = 50 + 100 * endRegionIndex;
+ if (BI.contains(self.start, start)) {
+ radioStartX = sleft - 50;
+ path += "M" + (sleft - 50) + "," + stop;
+ self.pathes[start][i].push({
+ x: sleft - 50,
+ y: stop
+ })
+ } else if (idx === 0) {
+ radioStartX = sleft + 50;
+ path += "M" + sleft + "," + stop;
+ self.pathes[start][i].push({
+ x: sleft,
+ y: stop
+ })
+ } else {
+ radioStartX = sleft + 50;
+ path += "M" + sleft + "," + 47.5 + "L" + (sleft + 50) + "," + 47.5 + "L" + (sleft + 50) + "," + stop;
+ self.pathes[start][i].push({
+ x: sleft,
+ y: 47.5
+ });
+ self.pathes[start][i].push({
+ x: sleft + 50,
+ y: 47.5
+ });
+ self.pathes[start][i].push({
+ x: sleft + 50,
+ y: stop
+ });
+ }
+ if (idx > 0) {
+ var endY = endOffset * 29 + 47.5;
+ path += "L" + (eleft - 50) + "," + etop + "L" + (eleft - 50) + "," + endY + "L" + eleft + "," + endY;
+ self.pathes[start][i].push({
+ x: eleft - 50,
+ y: etop
+ });
+ self.pathes[start][i].push({
+ x: eleft - 50,
+ y: endY
+ });
+ self.pathes[start][i].push({
+ x: eleft,
+ y: endY
+ });
+ } else {
+ path += "L" + eleft + "," + etop;
+ self.pathes[start][i].push({
+ x: eleft,
+ y: etop
+ });
+ }
+
+ var graph = self.svg.path(path)
+ .attr({
+ stroke: idx === 0 ? self._const.selectLineColor : self._const.lineColor,
+ 'stroke-dasharray': '-'
+ });
+ self.lines[start].push(graph);
+ if (lines.length > 1) {
+ self.lines[start][0].toFront();
+ }
+ //第一个元素无论有多少个都要显示radio
+ if (BI.contains(self.start, start)) {
+ self.lines[self.regions[0].getValueByIndex(0)][0].toFront();
+ }
+ if (lines.length > 1 || BI.contains(self.start, start)) {
+ self._drawRadio(start, offset, i, radioStartX, radioStartY);
+ }
+ });
+ },
+
+ _drawLines: function (routes) {
+ var self = this;
+ this.lines = {};
+ this.pathes = {};
+ this.radios = {};
+ this.regionIndexes = {};
+ BI.each(routes, function (k, route) {
+ if (!self.regionIndexes[k]) {
+ self.regionIndexes[k] = [];
+ }
+ BI.each(route, function (i, rs) {
+ BI.each(rs, function (j, id) {
+ var regionIndex = self.getRegionIndexById(id);
+ if (!BI.contains(self.regionIndexes[k], regionIndex)) {
+ self.regionIndexes[k].push(regionIndex);
+ }
+ });
+ })
+ });
+ BI.each(routes, function (k, route) {
+ self._drawLine(k, route);
+ });
+ },
+
+ _pushNodes: function (nodes) {
+ var self = this;
+ var indexes = [];
+ for (var i = 0; i < nodes.length; i++) {
+ var id = nodes[i];
+ var index = self.getRegionIndexById(id);
+ indexes.push(index);
+ var region = self.regions[index];
+ if (i === nodes.length - 1) {
+ if (!region.hasItem(id)) {
+ region.addItem(id, self.texts[id]);
+ }
+ break;
+ }
+ if (i > 0 || BI.contains(self.start, id)) {
+ region.addItem(id, self.texts[id]);
+ }
+ }
+ for (var i = BI.first(indexes); i < BI.last(indexes); i++) {
+ if (!BI.contains(indexes, i)) {
+ self.regions[i].addItem("");
+ }
+ }
+ },
+
+ _createNodes: function () {
+ var self = this, o = this.options;
+ this.store = {};
+ this.texts = {};
+ this.start = [];
+ this.end = [];
+ BI.each(o.items, function (i, item) {
+ self.start.push(BI.first(item).value);
+ self.end.push(BI.last(item).value);
+ });
+ this.start = BI.uniq(this.start);
+ this.end = BI.uniq(this.end);
+ var regions = [];
+ var tree = new BI.Tree();
+ var branches = {}, max = 0;
+ BI.each(o.items, function (i, items) {
+ BI.each(items, function (j, item) {
+ if (!BI.has(branches, item.value)) {
+ branches[item.value] = 0;
+ }
+ branches[item.value]++;
+ max = Math.max(max, branches[item.value]);
+ var prev = {};
+ if (j > 0) {
+ prev = items[j - 1];
+ }
+ var parent = self.store[prev.value || ""];
+ var node = self.store[item.value] || new BI.Node(item.value);
+ node.set(item);
+ self.store[item.value] = node;
+ self.texts[item.value] = item.text;
+ self.texts[item.region] = item.regionText;
+ parent = BI.isNull(parent) ? tree.getRoot() : parent;
+ if (parent.getChildIndex(item.value) === -1) {
+ tree.addNode(parent, node);
+ }
+ })
+ });
+
+ //算出区域列表
+ tree.traverse(function (node) {
+ BI.each(node.getChildren(), function (i, child) {
+ if (BI.contains(regions, child.get("region"))) {
+ var index1 = BI.indexOf(regions, node.get("region"));
+ var index2 = BI.indexOf(regions, child.get("region"));
+ //交换区域
+ if (index1 > index2) {
+ var t = regions[index2];
+ for (var j = index2; j < index1; j++) {
+ regions[j] = regions[j + 1];
+ }
+ regions[index1] = t;
+ }
+ } else {
+ regions.push(child.get("region"));
+ }
+ });
+ });
+ this._createRegions(regions);
+
+ //算出节点
+ BI.each(branches, function (k, branch) {
+ if (branch < max) {
+ delete branches[k];
+ }
+ });
+
+ //过滤节点
+ var nodes = [];
+ var n = tree.getRoot();
+ while (n && n.getChildrenLength() === 1) {
+ if (BI.has(branches, n.getChildren()[0].id)) {
+ delete branches[n.getChildren()[0].id];
+ n = n.getChildren()[0];
+ } else {
+ n = null;
+ }
+ }
+ tree.traverse(function (node) {
+ if (BI.has(branches, node.id)) {
+ nodes.push(node.id);
+ delete branches[node.id];
+ }
+ });
+
+ //填充节点
+ var routes = {};
+ var s, e;
+ for (var i = 0, len = nodes.length; i < len + 1; i++) {
+ if (len === 0) {
+ s = [];
+ BI.each(this.start, function (i, id) {
+ s.push(tree.search(id));
+ });
+ e = [];
+ BI.each(this.end, function (i, id) {
+ e.push(tree.search(id));
+ });
+ } else if (i === len) {
+ s = e;
+ e = [];
+ BI.each(this.end, function (i, id) {
+ e.push(tree.search(id));
+ });
+ } else if (i === 0) {
+ s = [];
+ BI.each(this.start, function (i, id) {
+ s.push(tree.search(id));
+ });
+ e = [tree.search(nodes[i])];
+ } else {
+ s = [tree.search(e[0] || tree.getRoot(), nodes[i - 1])];
+ e = [tree.search(s[0], nodes[i])];
+ }
+ BI.each(s, function (i, n) {
+ tree._recursion(n, [n.id], function (node, route) {
+ if (BI.contains(e, node)) {
+ if (!routes[n.id]) {
+ routes[n.id] = [];
+ }
+ routes[n.id].push(route);
+ self._pushNodes(route);
+ if (e.length <= 1) {
+ return true;
+ }
+ }
+ })
+ });
+ }
+ this.routes = routes;
+ this._drawLines(routes);
+ },
+
+ _unselectAllPath: function () {
+ var self = this;
+ BI.each(this.radios, function (idx, rad) {
+ BI.each(rad, function (i, r) {
+ r.setSelected(false);
+ });
+ });
+ BI.each(this.lines, function (idx, line) {
+ BI.each(line, function (i, li) {
+ li.attr("stroke", self._const.lineColor);
+ });
+ });
+ BI.each(this.regions, function (idx, region) {
+ region.reset();
+ });
+ },
+
+ populate: function (items) {
+ this.options.items = items || [];
+ var self = this;
+ this.empty();
+ if (this.options.items.length <= 0) {
+ return;
+ }
+ this.svg = BI.createWidget({
+ type: "bi.svg"
+ });
+ this._createNodes();
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: [{
+ el: this.svg,
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ setValue: function (v) {
+ this._unselectAllPath();
+ var nodes = BI.keys(this.routes), self = this;
+ var result = [], array = [];
+ BI.each(v, function (i, val) {
+ if (BI.contains(nodes, val)) {
+ if (array.length > 0) {
+ array.push(val);
+ result.push(array);
+ array = [];
+ }
+ }
+ array.push(val);
+ });
+ if (array.length > 0) {
+ result.push(array);
+ }
+ //画这n条路径
+ BI.each(result, function (idx, path) {
+ var start = path[0];
+ var index = BI.findIndex(self.routes[start], function (idx, p) {
+ if (BI.isEqual(path, p)) {
+ return true;
+ }
+ });
+ if (index >= 0) {
+ var startRegionIndex = self.getRegionIndexById(start);
+ var offset = self.regions[startRegionIndex].getIndexByValue(start);
+ self._drawPath(start, offset, index);
+ }
+ });
+ },
+
+ getValue: function () {
+ var path = [];
+ BI.each(this.regions, function (i, region) {
+ var val = region.getValue();
+ if (BI.isKey(val)) {
+ path.push(val);
+ }
+ });
+ return path;
+ }
+});
+BI.PathChooser.EVENT_CHANGE = "PathChooser.EVENT_CHANGE";
+BI.shortcut("bi.path_chooser", BI.PathChooser);/**
+ * 路径选择区域
+ *
+ * Created by GUY on 2015/12/4.
+ * @class BI.PathRegion
+ * @extends BI.Widget
+ */
+BI.PathRegion = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-path-region bi-background",
+ width: 80,
+ title: ""
+ })
+ },
+
+ _init: function () {
+ BI.PathRegion.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.zIndex = 100;
+ var title = BI.createWidget({
+ type: "bi.label",
+ text: o.title,
+ title: o.title,
+ height: 30
+ });
+ title.element.css("zIndex", this.zIndex--);
+ this.items = [];
+ this.vertical = BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ bgap: 5,
+ hgap: 10,
+ items: [title]
+ })
+ },
+
+ hasItem: function (val) {
+ return BI.any(this.items, function (i, item) {
+ return val === item.getValue();
+ });
+ },
+
+ addItem: function (value, text) {
+ if (BI.isKey(value)) {
+ var label = BI.createWidget({
+ type: "bi.label",
+ cls: "path-region-label bi-card bi-border bi-list-item-select",
+ text: text,
+ value: value,
+ title: text || value,
+ height: 22
+ });
+ } else {
+ var label = BI.createWidget({
+ type: "bi.layout",
+ height: 24
+ });
+ }
+ label.element.css("zIndex", this.zIndex--);
+ this.items.push(label);
+ this.vertical.addItem(label);
+ if (this.items.length === 1) {
+ this.setSelect(0, value);
+ }
+ },
+
+ reset: function () {
+ BI.each(this.items, function (i, item) {
+ item.element.removeClass("active");
+ });
+ },
+
+ setSelect: function (index, value) {
+ this.reset();
+ if (this.items.length <= 0) {
+ return;
+ }
+ if (this.items.length === 1) {
+ this.items[0].element.addClass("active");
+ return;
+ }
+ if (this.items[index].attr("value") === value) {
+ this.items[index].element.addClass("active");
+ }
+ },
+
+ setValue: function (value) {
+ this.setSelect(this.getIndexByValue(value), value);
+ },
+
+ getValueByIndex: function (idx) {
+ return this.items[idx].attr("value");
+ },
+
+ getIndexByValue: function (value) {
+ return BI.findIndex(this.items, function (i, item) {
+ return item.attr("value") === value;
+ });
+ },
+
+ getValue: function () {
+ var res;
+ BI.any(this.items, function (i, item) {
+ if (item.element.hasClass("active")) {
+ res = item.getValue();
+ return true;
+ }
+ });
+ return res;
+ }
+});
+BI.PathRegion.EVENT_CHANGE = "PathRegion.EVENT_CHANGE";
+BI.shortcut("bi.path_region", BI.PathRegion);/**
+ * 预览表列
+ *
+ * Created by GUY on 2015/12/25.
+ * @class BI.PreviewTableCell
+ * @extends BI.Widget
+ */
+BI.PreviewTableCell = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-preview-table-cell",
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.PreviewTableCell.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: "left",
+ whiteSpace: "normal",
+ height: this.options.height,
+ text: this.options.text,
+ value: this.options.value
+ })
+ }
+});
+BI.shortcut('bi.preview_table_cell', BI.PreviewTableCell);/**
+ * 预览表
+ *
+ * Created by GUY on 2015/12/25.
+ * @class BI.PreviewTableHeaderCell
+ * @extends BI.Widget
+ */
+BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-preview-table-header-cell",
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: "left",
+ whiteSpace: "normal",
+ height: this.options.height,
+ text: this.options.text,
+ value: this.options.value
+ })
+ }
+});
+BI.shortcut('bi.preview_table_header_cell', BI.PreviewTableHeaderCell);/**
+ * 预览表
+ *
+ * Created by GUY on 2015/12/25.
+ * @class BI.PreviewTable
+ * @extends BI.Widget
+ */
+BI.PreviewTable = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-preview-table",
+ isNeedFreeze: false,
+ freezeCols: [],
+ rowSize: null,
+ columnSize: [],
+ headerRowSize: 30,
+ header: [],
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.PreviewTable.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.table = BI.createWidget({
+ type: "bi.table_view",
+ element: this,
+ isNeedResize: false,
+
+ isResizeAdapt: false,
+
+ isNeedFreeze: o.isNeedFreeze,
+ freezeCols: o.freezeCols,
+
+ rowSize: o.rowSize,
+ columnSize: o.columnSize,
+ headerRowSize: o.headerRowSize,
+
+ header: BI.map(o.header, function (i, items) {
+ return BI.map(items, function (j, item) {
+ return BI.extend({
+ type: "bi.preview_table_header_cell"
+ }, item);
+ });
+ }),
+ items: BI.map(o.items, function (i, items) {
+ return BI.map(items, function (j, item) {
+ return BI.extend({
+ type: "bi.preview_table_cell"
+ }, item);
+ });
+ })
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
+ self._adjustColumns();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
+ self._adjustColumns();
+ });
+ },
+
+ //是否有自适应调节的列,即列宽为""
+ _hasAdaptCol: function (columnSize) {
+ return BI.any(columnSize, function (i, size) {
+ return size === "";
+ })
+ },
+
+ _isPercentage: function (columnSize) {
+ return columnSize[0] <= 1;
+ },
+
+ _adjustColumns: function () {
+ var self = this, o = this.options;
+ if (o.isNeedFreeze === true) {
+ //如果存在百分比的情况
+ if (this._isPercentage(o.columnSize)) {
+ if (this._hasAdaptCol(o.columnSize)) {
+ var findCols = [], remain = 0;
+ BI.each(o.columnSize, function (i, size) {
+ if (size === "") {
+ findCols.push(i);
+ } else {
+ remain += size;
+ }
+ });
+ remain = 1 - remain;
+ var average = remain / findCols.length;
+ BI.each(findCols, function (i, col) {
+ o.columnSize[col] = average;
+ });
+ }
+ var isRight = BI.first(o.freezeCols) !== 0;
+ var freezeSize = [], notFreezeSize = [];
+ BI.each(o.columnSize, function (i, size) {
+ if (o.freezeCols.contains(i)) {
+ freezeSize.push(size);
+ } else {
+ notFreezeSize.push(size);
+ }
+ });
+ var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize);
+ BI.each(freezeSize, function (i, size) {
+ freezeSize[i] = size / sumFreezeSize;
+ });
+ BI.each(notFreezeSize, function (i, size) {
+ notFreezeSize[i] = size / sumNotFreezeSize;
+ });
+ this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]);
+ this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize)));
+ }
+ } else {
+ //如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100%
+ if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) {
+ this.table.setRegionColumnSize(["100%"]);
+ }
+ }
+ },
+
+ setColumnSize: function (columnSize) {
+ return this.table.setColumnSize(columnSize);
+ },
+
+ getColumnSize: function () {
+ return this.table.getColumnSize();
+ },
+
+ getCalculateColumnSize: function () {
+ return this.table.getCalculateColumnSize();
+ },
+
+ setHeaderColumnSize: function (columnSize) {
+ return this.table.setHeaderColumnSize(columnSize);
+ },
+
+ setRegionColumnSize: function (columnSize) {
+ return this.table.setRegionColumnSize(columnSize);
+ },
+
+ getRegionColumnSize: function () {
+ return this.table.getRegionColumnSize();
+ },
+
+ getCalculateRegionColumnSize: function () {
+ return this.table.getCalculateRegionColumnSize();
+ },
+
+ getCalculateRegionRowSize: function () {
+ return this.table.getCalculateRegionRowSize();
+ },
+
+ getClientRegionColumnSize: function () {
+ return this.table.getClientRegionColumnSize();
+ },
+
+ getScrollRegionColumnSize: function () {
+ return this.table.getScrollRegionColumnSize()
+ },
+
+ getScrollRegionRowSize: function () {
+ return this.table.getScrollRegionRowSize()
+ },
+
+ hasVerticalScroll: function () {
+ return this.table.hasVerticalScroll();
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ return this.table.setVerticalScroll(scrollTop);
+ },
+
+ setLeftHorizontalScroll: function (scrollLeft) {
+ return this.table.setLeftHorizontalScroll(scrollLeft)
+ },
+
+ setRightHorizontalScroll: function (scrollLeft) {
+ return this.table.setRightHorizontalScroll(scrollLeft);
+ },
+
+ getVerticalScroll: function () {
+ return this.table.getVerticalScroll();
+ },
+
+ getLeftHorizontalScroll: function () {
+ return this.table.getLeftHorizontalScroll();
+ },
+
+ getRightHorizontalScroll: function () {
+ return this.table.getRightHorizontalScroll();
+ },
+
+ getColumns: function () {
+ return this.table.getColumns();
+ },
+
+ populate: function (items, header) {
+ this.table.populate(items, header);
+ }
+});
+BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE";
+BI.shortcut('bi.preview_table', BI.PreviewTable);/**
+ * 季度下拉框
+ *
+ * Created by GUY on 2015/8/28.
+ * @class BI.QuarterCombo
+ * @extends BI.Widget
+ */
+BI.QuarterCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-quarter-combo",
+ behaviors: {},
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.QuarterCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = "";
+ this.trigger = BI.createWidget({
+ type: "bi.quarter_trigger"
+ });
+
+ this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS, function () {
+ self.storeValue = this.getKey();
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_CHANGE, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_START, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () {
+ if (self.combo.isViewVisible()) {
+ return;
+ }
+ if (this.getKey() && this.getKey() !== self.storeValue) {
+ self.setValue(this.getKey());
+ } else if (!this.getKey()) {
+ self.setValue();
+ }
+ self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
+ });
+ this.popup = BI.createWidget({
+ type: "bi.quarter_popup",
+ behaviors: o.behaviors
+ });
+
+ this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ el: this.popup
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue() || "";
+ }
+});
+
+BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.quarter_combo', BI.QuarterCombo);/**
+ * 季度展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.QuarterPopup
+ * @extends BI.Trigger
+ */
+BI.QuarterPopup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-quarter-popup",
+ behaviors: {}
+ });
+ },
+
+ _init: function () {
+ BI.QuarterPopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var items = [{
+ text: Date._QN[01],
+ value: 1
+ }, {
+ text: Date._QN[2],
+ value: 2
+ }, {
+ text: Date._QN[3],
+ value: 3
+ }, {
+ text: Date._QN[4],
+ value: 4
+ }];
+ items = BI.map(items, function (j, item) {
+ return BI.extend(item, {
+ type: "bi.text_item",
+ cls: "bi-list-item-active",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ once: false,
+ forceSelected: true,
+ height: 25
+ });
+ });
+
+ this.quarter = BI.createWidget({
+ type: "bi.button_group",
+ element: this,
+ behaviors: o.behaviors,
+ items: BI.createItems(items, {}),
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ });
+
+ this.quarter.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
+ }
+ })
+ },
+
+ getValue: function () {
+ return this.quarter.getValue()[0];
+ },
+
+ setValue: function (v) {
+ this.quarter.setValue([v]);
+ }
+});
+BI.QuarterPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.quarter_popup", BI.QuarterPopup);/**
+ * 季度trigger
+ *
+ * Created by GUY on 2015/8/21.
+ * @class BI.QuarterTrigger
+ * @extends BI.Trigger
+ */
+BI.QuarterTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ triggerWidth: 30,
+ textWidth: 40,
+ errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text")
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-quarter-trigger bi-border",
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.QuarterTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 4);
+ },
+ quitChecker: function (v) {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ errorText: c.errorText
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_CHANGE);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setValue(value);
+ self.editor.setTitle(value);
+ }
+ self.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_STOP);
+ });
+
+ BI.createWidget({
+ element: this,
+ type: 'bi.htape',
+ items: [
+ {
+ el: this.editor
+ }, {
+ el: {
+ type: "bi.text_button",
+ baseCls: "bi-trigger-quarter-text",
+ text: BI.i18nText("BI-Multi_Date_Quarter"),
+ width: c.textWidth
+ },
+ width: c.textWidth
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: c.triggerWidth
+ },
+ width: c.triggerWidth
+ }
+ ]
+ });
+ },
+
+ setValue: function (v) {
+ this.editor.setState(v);
+ this.editor.setValue(v);
+ this.editor.setTitle(v);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ }
+});
+BI.QuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.QuarterTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.QuarterTrigger.EVENT_START = "EVENT_START";
+BI.QuarterTrigger.EVENT_STOP = "EVENT_STOP";
+BI.QuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.shortcut("bi.quarter_trigger", BI.QuarterTrigger);/**
+ * 关联视图字段Item
+ *
+ * Created by GUY on 2015/12/23.
+ * @class BI.RelationViewItem
+ * @extends BI.Widget
+ */
+BI.RelationViewItem = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-relation-view-item bi-list-item-active",
+ height: 25,
+ hoverIn: BI.emptyFn,
+ hoverOut: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.RelationViewItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.element.hover(o.hoverIn, o.hoverOut);
+ var items = [];
+ if (o.isPrimary) {
+ items.push({
+ type: "bi.icon",
+ width: 16,
+ height: 16,
+ title: BI.i18nText("BI-Primary_Key")
+ });
+ }
+ items.push({
+ type: "bi.label",
+ text: o.text,
+ value: o.value,
+ height: o.height,
+ textAlign: "left",
+ width: o.isPrimary ? 70 : 90
+ });
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ element: this,
+ items: items,
+ cls: "primary-key-font",
+ lgap: 5
+ });
+ },
+
+ enableHover: function (opt) {
+ BI.RelationViewRegion.superclass.enableHover.apply(this, [{
+ container: "body"
+ }]);
+ },
+
+ setSelected: function (b) {
+ this.element[b ? "addClass" : "removeClass"]("active");
+ }
+});
+BI.shortcut('bi.relation_view_item', BI.RelationViewItem);/**
+ * 关联视图
+ *
+ * Created by GUY on 2015/12/22.
+ * @class BI.RelationView
+ * @extends BI.Widget
+ */
+BI.RelationView = BI.inherit(BI.Widget, {
+
+ _const: {
+ lineColor: "#c4c6c6",
+ selectLineColor: "#009de3"
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-relation-view",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.RelationView.superclass._init.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _calculateWidths: function () {
+ var widths = [];
+ BI.each(this.views, function (i, items) {
+ BI.each(items, function (j, obj) {
+ if (!widths[j]) {
+ widths[j] = BI.MIN;
+ }
+ widths[j] = Math.max(widths[j], obj.getWidth());
+ })
+ });
+ return widths;
+ },
+
+ _calculateHeights: function () {
+ var heights = BI.makeArray(BI.size(this.views), BI.MIN);
+ BI.each(this.views, function (i, items) {
+ BI.each(items, function (j, obj) {
+ heights[i] = Math.max(heights[i], obj.getHeight());
+ })
+ });
+ return heights;
+ },
+
+ _hoverIn: function (target) {
+ var self = this, c = this._const;
+ BI.each(this.relations, function (start, rs) {
+ BI.each(rs, function (end, relation) {
+ if (relation[0].primary.value === target || relation[0].foreign.value === target) {
+ self.lines[start][end].attr("stroke", c.selectLineColor).toFront();
+ self.storeViews[start].setValue(relation[0].primary.value);
+ self.storeViews[end].setValue(relation[0].foreign.value);
+ }
+ });
+ });
+ },
+
+ _hoverOut: function (target) {
+ var self = this, c = this._const;
+ BI.each(this.relations, function (start, rs) {
+ BI.each(rs, function (end, relation) {
+ if (relation[0].primary.value === target || relation[0].foreign.value === target) {
+ self.lines[start][end].attr("stroke", c.lineColor);
+ self.storeViews[start].setValue([]);
+ self.storeViews[end].setValue([]);
+ }
+ });
+ });
+ },
+
+ previewRelationTables: function(relationTables, show) {
+ if (!show) {
+ BI.each(this.storeViews, function (i, view) {
+ view.toggleRegion(true);
+ view.setPreviewSelected(false);
+ });
+ BI.each(this.lines, function (i, lines) {
+ BI.each(lines, function (j, line) {
+ line.show();
+ });
+ });
+ return;
+ }
+ BI.each(this.storeViews, function (id, view) {
+ if (!relationTables.contains(id)) {
+ view.toggleRegion(false);
+ } else {
+ view.setPreviewSelected(true);
+ }
+ });
+ BI.each(this.lines, function (id, lines) {
+ BI.each(lines, function (cId, line) {
+ if (!relationTables.contains(id) || !relationTables.contains(cId)) {
+ line.hide();
+ }
+ });
+ });
+ },
+
+ populate: function (items) {
+ var self = this, o = this.options, c = this._const;
+ o.items = items || [];
+ this.empty();
+ this.svg = BI.createWidget({
+ type: "bi.svg"
+ });
+
+ //算出所有的区域和关联
+ var regions = this.regions = {}, relations = this.relations = {};
+ BI.each(items, function (i, item) {
+ var pr = item.primary.region, fr = item.foreign && item.foreign.region;
+ if (pr && !relations[pr]) {
+ relations[pr] = {};
+ }
+ if (pr && fr && !relations[pr][fr]) {
+ relations[pr][fr] = [];
+ }
+ if (pr && !regions[pr]) {
+ regions[pr] = [];
+ }
+ if (fr && !regions[fr]) {
+ regions[fr] = [];
+ }
+ if (pr && !BI.deepContains(regions[pr], item.primary)) {
+ regions[pr].push(item.primary);
+ }
+ if (fr && !BI.deepContains(regions[fr], item.foreign)) {
+ regions[fr].push(item.foreign);
+ }
+ pr && fr && relations[pr][fr].push(item);
+ });
+ //求拓扑
+ var topology = [];
+ var rs = BI.clone(regions), store = {};
+ while (!BI.isEmpty(rs)) {
+ var clone = BI.clone(rs);
+ BI.each(o.items, function (i, item) {
+ if (!store[item.primary.region]) {
+ delete clone[item.foreign && item.foreign.region];
+ }
+ });
+ topology.push(BI.keys(clone));
+ BI.extend(store, clone);
+ BI.each(clone, function (k, v) {
+ delete rs[k];
+ });
+ }
+ //构建视图
+ var views = this.views = {}, storeViews = this.storeViews = {}, indexes = this.indexes = {};
+ var verticals = [];
+ BI.each(topology, function (i, items) {
+ if (!views[i]) {
+ views[i] = {};
+ }
+ var horizontal = [];
+ BI.each(items, function (j, region) {
+ var items = regions[region];
+ views[i][j] = storeViews[region] = BI.createWidget({
+ type: "bi.relation_view_region_container",
+ value: region,
+ header: items[0].regionTitle,
+ text: items.length > 0 ? items[0].regionText : "",
+ handler: items.length > 0 ? items[0].regionHandler : BI.emptyFn,
+ items: items,
+ belongPackage: items.length > 0 ? items[0].belongPackage : true
+ });
+ if (BI.isNotNull(items[0]) && BI.isNotNull(items[0].keyword)) {
+ views[i][j].doRedMark(items[0].keyword);
+ }
+ views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN, function (v) {
+ self._hoverIn(v);
+ });
+ views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, function (v) {
+ self._hoverOut(v);
+ });
+ views[i][j].on(BI.RelationViewRegionContainer.EVENT_PREVIEW, function (v) {
+ self.fireEvent(BI.RelationView.EVENT_PREVIEW, region, v);
+ });
+ indexes[region] = {i: i, j: j};
+ horizontal.push(views[i][j]);
+ });
+ verticals.push({
+ type: "bi.horizontal",
+ items: horizontal
+ })
+ });
+
+ //求每一行的高度
+ var heights = this._calculateHeights();
+
+ //求每一列的宽度
+ var widths = this._calculateWidths();
+
+ //求相对宽度和高度
+ var offsetWidths = [0], offsetHeights = [0];
+ BI.each(heights, function (i, h) {
+ if (i === 0) {
+ return;
+ }
+ offsetHeights[i] = offsetHeights[i - 1] + heights[i - 1];
+ });
+ BI.each(widths, function (i, w) {
+ if (i === 0) {
+ return;
+ }
+ offsetWidths[i] = offsetWidths[i - 1] + widths[i - 1];
+ });
+
+ //画线
+ var lines = this.lines = {};//缓存所有的线
+ BI.each(relations, function (start, rs) {
+ BI.each(rs, function (end, relation) {
+ var startIndex = indexes[start], endIndex = indexes[end];
+ var top = 0, right = 1, bottom = 2, left = 3;
+ var startDirection = bottom, endDirection = top;
+ // if (startIndex.j > endIndex.j) {
+ // startDirection = left;
+ // endDirection = right;
+ // } else if (startIndex.j < endIndex.j) {
+ // startDirection = right;
+ // endDirection = left;
+ // } else if (startIndex.i < endIndex.i) {
+ // startDirection = bottom;
+ // endDirection = top;
+ // } else if (startIndex.i > endIndex.i) {
+ // startDirection = top;
+ // endDirection = bottom;
+ // }
+ var draw = function (i, j, direction, isForeign) {
+ var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2;
+ var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2;
+ var path = "", position;
+ switch (direction) {
+ case top:
+ position = isForeign ? views[i][j].getTopRightPosition() : views[i][j].getTopLeftPosition();
+ x += position.x;
+ y += position.y;
+ path = "M" + x + "," + y + "L" + x + "," + (y - 10);
+ y -= 10;
+ break;
+ case right:
+ position = views[i][j].getRightPosition();
+ x += position.x;
+ y += position.y;
+ path = "M" + x + "," + y + "L" + (x + 10) + "," + y;
+ x += 10;
+ break;
+ case bottom:
+ position = views[i][j].getBottomPosition();
+ x += position.x;
+ y += position.y;
+ path = "M" + x + "," + y + "L" + x + "," + (y + 10);
+ y += 10;
+ break;
+ case left:
+ position = views[i][j].getLeftPosition();
+ x += position.x;
+ y += position.y;
+ path = "M" + x + "," + y + "L" + (x - 10) + "," + y;
+ x -= 10;
+ break;
+ }
+ return {x: x, y: y, path: path};
+ };
+ var path = "";
+ var si = draw(startIndex.i, startIndex.j, startDirection);
+ var ei = draw(endIndex.i, endIndex.j, endDirection, true);
+ path += si.path + ei.path;
+ if (!lines[start]) {
+ lines[start] = {};
+ }
+ path += "M" + si.x + "," + si.y + "L" + ei.x + "," + ei.y;
+ var line = lines[start][end] = self.svg.path(path)
+ .attr({"stroke": c.lineColor, "stroke-width": "2"})
+ .hover(function () {
+ line.attr("stroke", c.selectLineColor).toFront();
+ storeViews[start].setValue(relation[0].primary.value);
+ storeViews[end].setValue(relation[0].foreign.value);
+ }, function () {
+ line.attr("stroke", c.lineColor);
+ storeViews[start].setValue([]);
+ storeViews[end].setValue([]);
+ });
+ });
+ });
+ var container = BI.createWidget();
+ BI.createWidget({
+ type: "bi.vertical",
+ element: container,
+ items: verticals
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: container,
+ items: [{
+ el: this.svg,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: true,
+ element: this,
+ items: [container]
+ });
+ }
+});
+BI.RelationView.EVENT_CHANGE = "RelationView.EVENT_CHANGE";
+BI.RelationView.EVENT_PREVIEW = "EVENT_PREVIEW";
+BI.shortcut('bi.relation_view', BI.RelationView);/**
+ * Created by Young's on 2017/3/10.
+ */
+BI.RelationViewRegionContainer = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-relation-view-region-container",
+ width: 150
+ });
+ },
+
+ _init: function () {
+ BI.RelationViewRegionContainer.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.region = BI.createWidget({
+ type: "bi.relation_view_region",
+ value: o.value,
+ header: o.header,
+ text: o.text,
+ handler: o.handler,
+ items: o.items,
+ belongPackage: o.belongPackage
+ });
+ this.region.on(BI.RelationViewRegion.EVENT_PREVIEW, function (v) {
+ self.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW, v);
+ });
+ this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN, function (v) {
+ self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN, v);
+ });
+ this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT, function (v) {
+ self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, v);
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.region],
+ width: this.region.getWidth(),
+ height: this.region.getHeight()
+ });
+ },
+
+ doRedMark: function () {
+ this.region.doRedMark.apply(this.region, arguments);
+ },
+
+ unRedMark: function () {
+ this.region.unRedMark.apply(this.region, arguments);
+ },
+
+ getWidth: function () {
+ return this.region.getWidth();
+ },
+
+ getHeight: function () {
+ return this.region.getHeight();
+ },
+
+ //获取上方开始划线的位置
+ getTopLeftPosition: function () {
+ return this.region.getTopLeftPosition();
+ },
+
+ getTopRightPosition: function () {
+ return this.region.getTopRightPosition();
+ },
+
+ getBottomPosition: function () {
+ return this.region.getBottomPosition();
+ },
+
+ getLeftPosition: function () {
+ return this.region.getLeftPosition();
+ },
+
+ getRightPosition: function () {
+ return this.region.getRightPosition();
+ },
+
+ setValue: function (v) {
+ this.region.setValue(v);
+ },
+
+ toggleRegion: function (v) {
+ v === true ? this.region.element.fadeIn() : this.region.element.fadeOut();
+ },
+
+ setPreviewSelected: function(v) {
+ this.region.setPreviewSelected(v);
+ }
+});
+BI.RelationViewRegionContainer.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN";
+BI.RelationViewRegionContainer.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT";
+BI.RelationViewRegionContainer.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW";
+BI.shortcut("bi.relation_view_region_container", BI.RelationViewRegionContainer);/**
+ * 关联视图
+ *
+ * Created by GUY on 2015/12/23.
+ * @class BI.RelationViewRegion
+ * @extends BI.BasicButton
+ */
+BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-relation-view-region cursor-pointer",
+ width: 150,
+ text: "",
+ value: "",
+ header: "",
+ items: [],
+ belongPackage: true
+ });
+ },
+
+ _init: function () {
+ BI.RelationViewRegion.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.preview = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "relation-table-preview-font",
+ width: 25,
+ height: 25,
+ stopPropagation: true
+ });
+ this.preview.on(BI.IconButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW, this.isSelected());
+ });
+
+ this.title = BI.createWidget({
+ type: "bi.label",
+ height: 25,
+ width: 70,
+ text: o.text,
+ value: o.value,
+ textAlign: "left"
+ });
+ //title放body上
+ if (BI.isKey(o.header)) {
+ this.title.setTitle(o.header, {
+ container: "body"
+ })
+ }
+
+ this.button_group = BI.createWidget({
+ type: "bi.button_group",
+ items: this._createItems(o.items),
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [{
+ type: "bi.vertical",
+ cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"),
+ items: [{
+ type: "bi.vertical_adapt",
+ cls: "relation-view-region-title bi-border-bottom",
+ items: [this.preview, this.title]
+ }, this.button_group]
+ }],
+ hgap: 25,
+ vgap: 20
+ })
+ },
+
+ _createItems: function (items) {
+ var self = this;
+ return BI.map(items, function (i, item) {
+ return BI.extend(item, {
+ type: "bi.relation_view_item",
+ hoverIn: function () {
+ self.setValue(item.value);
+ self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value);
+ },
+ hoverOut: function () {
+ self.setValue([]);
+ self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT, item.value);
+ }
+ })
+ });
+ },
+
+ doRedMark: function () {
+ this.title.doRedMark.apply(this.title, arguments);
+ },
+
+ unRedMark: function () {
+ this.title.unRedMark.apply(this.title, arguments);
+ },
+
+ getWidth: function () {
+ return this.options.width;
+ },
+
+ getHeight: function () {
+ return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3;
+ },
+
+ //获取上方开始划线的位置
+ getTopLeftPosition: function () {
+ return {
+ x: 25 + 10,
+ y: 20
+ }
+ },
+
+ getTopRightPosition: function () {
+ return {
+ x: this.getWidth() - 25 - 10,
+ y: 20
+ }
+ },
+
+ getBottomPosition: function () {
+ return {
+ x: 25 + 10,
+ y: this.getHeight() - 20
+ }
+ },
+
+ getLeftPosition: function () {
+ return {
+ x: 25,
+ y: 20 + 10
+ }
+ },
+
+ getRightPosition: function () {
+ return {
+ x: this.getWidth() - 25,
+ y: 20 + 10
+ }
+ },
+
+ setValue: function (v) {
+ this.button_group.setValue(v);
+ },
+
+ setPreviewSelected: function(v) {
+ this.preview.setSelected(v);
+ }
+});
+BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN";
+BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT";
+BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW";
+BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/**
+ * 自适应宽度的表格
+ *
+ * Created by GUY on 2016/2/3.
+ * @class BI.ResponisveTable
+ * @extends BI.Widget
+ */
+BI.ResponisveTable = BI.inherit(BI.Widget, {
+
+ _const: {
+ perColumnSize: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-responsive-table",
+ isNeedFreeze: false,//是否需要冻结单元格
+ freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
+
+ isNeedMerge: false,//是否需要合并单元格
+ mergeCols: [], //合并的单元格列号
+ mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
+ return BI.isEqual(row1, row2);
+ },
+
+ columnSize: [],
+ headerRowSize: 25,
+ footerRowSize: 25,
+ rowSize: 25,
+
+ regionColumnSize: false,
+
+ header: [],
+ footer: false,
+ items: [], //二维数组
+
+ //交叉表头
+ crossHeader: [],
+ crossItems: []
+ });
+ },
+
+ _init: function () {
+ BI.ResponisveTable.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.table = BI.createWidget({
+ type: "bi.table_view",
+ element: this,
+
+ isNeedFreeze: o.isNeedFreeze,
+ freezeCols: o.freezeCols,
+
+ isNeedMerge: o.isNeedMerge,
+ mergeCols: o.mergeCols,
+ mergeRule: o.mergeRule,
+
+ columnSize: o.columnSize,
+ headerRowSize: o.headerRowSize,
+ footerRowSize: o.footerRowSize,
+ rowSize: o.rowSize,
+
+ regionColumnSize: o.regionColumnSize,
+
+ header: o.header,
+ footer: o.footer,
+ items: o.items,
+ //交叉表头
+ crossHeader: o.crossHeader,
+ crossItems: o.crossItems
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
+ self._initRegionSize();
+ self.table.resize();
+ self._resizeHeader();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
+ self._resizeRegion();
+ self._resizeHeader();
+ self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
+ self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () {
+ self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () {
+ //important:在冻结并自适应列宽的情况下要随时变更表头宽度
+ if (o.isNeedResize === true && self._isAdaptiveColumn()) {
+ self._resizeHeader();
+ }
+ self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
+ self._resizeHeader();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
+ });
+
+ this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () {
+ self._resizeBody();
+ self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () {
+ self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
+ self._resizeRegion();
+ self._resizeHeader();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
+ });
+ },
+
+ _initRegionSize: function () {
+ var o = this.options;
+ if (o.isNeedFreeze === true) {
+ var regionColumnSize = this.table.getRegionColumnSize();
+ var maxWidth = this.table.element.width();
+ if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) {
+ var freezeCols = o.freezeCols;
+ if (freezeCols.length === 0) {
+ this.table.setRegionColumnSize([0, "fill"]);
+ } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) {
+ var size = maxWidth / 3;
+ if (freezeCols.length > o.columnSize.length / 2) {
+ size = maxWidth * 2 / 3;
+ }
+ this.table.setRegionColumnSize([size, "fill"]);
+ } else {
+ this.table.setRegionColumnSize(["fill", 0]);
+ }
+ }
+ }
+ },
+
+ _getBlockSize: function () {
+ var o = this.options;
+ var columnSize = this.table.getCalculateColumnSize();
+ if (o.isNeedFreeze === true) {
+ var columnSizeLeft = [], columnSizeRight = [];
+ BI.each(columnSize, function (i, size) {
+ if (o.freezeCols.contains(i)) {
+ columnSizeLeft.push(size);
+ } else {
+ columnSizeRight.push(size);
+ }
+ });
+ //因为有边框,所以加上数组长度的参数调整
+ var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length,
+ sumRight = BI.sum(columnSizeRight) + columnSizeRight.length;
+ return {
+ sumLeft: sumLeft,
+ sumRight: sumRight,
+ left: columnSizeLeft,
+ right: columnSizeRight
+ }
+ }
+ return {
+ size: columnSize,
+ sum: BI.sum(columnSize) + columnSize.length
+ };
+ },
+
+ _isAdaptiveColumn: function (columnSize) {
+ return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05);
+ },
+
+ _resizeHeader: function () {
+ var self = this, o = this.options;
+ if (o.isNeedFreeze === true) {
+ //若是当前处于自适应调节阶段
+ if (this._isAdaptiveColumn()) {
+ var columnSize = this.table.getCalculateColumnSize();
+ this.table.setHeaderColumnSize(columnSize);
+ } else {
+ var regionColumnSize = this.table.getClientRegionColumnSize();
+ var block = this._getBlockSize();
+ var sumLeft = block.sumLeft, sumRight = block.sumRight;
+ var columnSizeLeft = block.left, columnSizeRight = block.right;
+ columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft;
+ columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight;
+
+ var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight);
+ newLeft[newLeft.length - 1] = "";
+ newRight[newRight.length - 1] = "";
+ this.table.setColumnSize(newLeft.concat(newRight));
+
+ block = self._getBlockSize();
+ if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) {
+ columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1]
+ }
+ if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) {
+ columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1]
+ }
+
+ self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight));
+ }
+ } else {
+ if (!this._isAdaptiveColumn()) {
+ var regionColumnSize = this.table.getClientRegionColumnSize();
+ var block = this._getBlockSize();
+ var sum = block.sum;
+ var size = block.size;
+
+ size[size.length - 1] += regionColumnSize[0] - sum;
+
+ var newSize = BI.clone(size);
+ newSize[newSize.length - 1] = "";
+ this.table.setColumnSize(newSize);
+ block = this._getBlockSize();
+
+ if (size[size.length - 1] < block.size[block.size.length - 1]) {
+ size[size.length - 1] = block.size[block.size.length - 1]
+ }
+ this.table.setColumnSize(size);
+ }
+ }
+ },
+
+ _resizeBody: function () {
+ if (this._isAdaptiveColumn()) {
+ var columnSize = this.table.getCalculateColumnSize();
+ this.setColumnSize(columnSize);
+ }
+ },
+
+ _adjustRegion: function () {
+ var o = this.options;
+ var regionColumnSize = this.table.getCalculateRegionColumnSize();
+ if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
+ var block = this._getBlockSize();
+ var sumLeft = block.sumLeft, sumRight = block.sumRight;
+ if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) {
+ this.table.setRegionColumnSize([sumLeft, "fill"]);
+ }
+ this._resizeRegion();
+ }
+ },
+
+ _resizeRegion: function () {
+ var o = this.options;
+ var regionColumnSize = this.table.getCalculateRegionColumnSize();
+ if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
+ var maxWidth = this.table.element.width();
+ if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) {
+ var freezeCols = o.freezeCols;
+ var size = maxWidth / 3;
+ if (freezeCols.length > o.columnSize.length / 2) {
+ size = maxWidth * 2 / 3;
+ }
+ this.table.setRegionColumnSize([size, "fill"]);
+ }
+ }
+ },
+
+
+ resize: function () {
+ this.table.resize();
+ this._resizeRegion();
+ this._resizeHeader();
+ },
+
+ setColumnSize: function (columnSize) {
+ this.table.setColumnSize(columnSize);
+ this._adjustRegion();
+ this._resizeHeader();
+ },
+
+ getColumnSize: function () {
+ return this.table.getColumnSize();
+ },
+
+ getCalculateColumnSize: function () {
+ return this.table.getCalculateColumnSize();
+ },
+
+ setHeaderColumnSize: function (columnSize) {
+ this.table.setHeaderColumnSize(columnSize);
+ this._adjustRegion();
+ this._resizeHeader();
+ },
+
+ setRegionColumnSize: function (columnSize) {
+ this.table.setRegionColumnSize(columnSize);
+ this._resizeHeader();
+ },
+
+ getRegionColumnSize: function () {
+ return this.table.getRegionColumnSize();
+ },
+
+ getCalculateRegionColumnSize: function () {
+ return this.table.getCalculateRegionColumnSize();
+ },
+
+ getCalculateRegionRowSize: function () {
+ return this.table.getCalculateRegionRowSize();
+ },
+
+ getClientRegionColumnSize: function () {
+ return this.table.getClientRegionColumnSize();
+ },
+
+ getScrollRegionColumnSize: function () {
+ return this.table.getScrollRegionColumnSize();
+ },
+
+ getScrollRegionRowSize: function () {
+ return this.table.getScrollRegionRowSize();
+ },
+
+ hasVerticalScroll: function () {
+ return this.table.hasVerticalScroll();
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ this.table.setVerticalScroll(scrollTop);
+ },
+
+ setLeftHorizontalScroll: function (scrollLeft) {
+ this.table.setLeftHorizontalScroll(scrollLeft);
+ },
+
+ setRightHorizontalScroll: function (scrollLeft) {
+ this.table.setRightHorizontalScroll(scrollLeft);
+ },
+
+ getVerticalScroll: function () {
+ return this.table.getVerticalScroll();
+ },
+
+ getLeftHorizontalScroll: function () {
+ return this.table.getLeftHorizontalScroll();
+ },
+
+ getRightHorizontalScroll: function () {
+ return this.table.getRightHorizontalScroll();
+ },
+
+ getColumns: function () {
+ return this.table.getColumns();
+ },
+
+ attr: function () {
+ BI.ResponisveTable.superclass.attr.apply(this, arguments);
+ this.table.attr.apply(this.table, arguments);
+ },
+
+ populate: function (items) {
+ var self = this, o = this.options;
+ this.table.populate.apply(this.table, arguments);
+ if (o.isNeedFreeze === true) {
+ BI.nextTick(function () {
+ self._initRegionSize();
+ self.table.resize();
+ self._resizeHeader();
+ });
+ }
+ }
+});
+BI.shortcut('bi.responsive_table', BI.ResponisveTable);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.SelectTreeFirstPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-select-tree-first-plus-group-node bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.first_tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 25,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ },
+
+ setOpened: function (v) {
+ BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.select_tree_first_plus_group_node", BI.SelectTreeFirstPlusGroupNode);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.SelectTreeLastPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-select-tree-last-plus-group-node bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.last_tree_node_checkbox",
+ stopPropagation: true
+ })
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 25,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ },
+
+ setOpened: function (v) {
+ BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.select_tree_last_plus_group_node", BI.SelectTreeLastPlusGroupNode);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.SelectTreeMidPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-select-tree-mid-plus-group-node bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.mid_tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 25,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ },
+
+ setOpened: function (v) {
+ BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.select_tree_mid_plus_group_node", BI.SelectTreeMidPlusGroupNode);/**
+ * @class BI.SelectTreeCombo
+ * @extends BI.Widget
+ */
+BI.SelectTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-tree-combo",
+ height: 30,
+ text: "",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SelectTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.select_tree_popup",
+ items: o.items
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ }
+});
+
+
+BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo);/**
+ * @class BI.SelectTreeExpander
+ * @extends BI.Widget
+ */
+BI.SelectTreeExpander = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-tree-expander",
+ trigger: "click",
+ toggle: true,
+ direction: "bottom",
+ isDefaultInit: true,
+ el: {},
+ popup: {}
+ });
+ },
+
+ _init: function () {
+ BI.SelectTreeExpander.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget(BI.extend({stopPropagation: true}, o.el));
+ this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.expander.setValue([]);
+ }
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.expander = BI.createWidget({
+ type: "bi.expander",
+ element: this,
+ trigger: o.trigger,
+ toggle: o.toggle,
+ direction: o.direction,
+ isDefaultInit: o.isDefaultInit,
+ el: this.trigger,
+ popup: o.popup
+ });
+ this.expander.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self.trigger.setSelected(false);
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ },
+
+ setValue: function (v) {
+ if (BI.contains(v, this.trigger.getValue())) {
+ this.trigger.setSelected(true);
+ this.expander.setValue([]);
+ } else {
+ this.trigger.setSelected(false);
+ this.expander.setValue(v);
+ }
+ },
+
+ getValue: function () {
+ if (this.trigger.isSelected()) {
+ return [this.trigger.getValue()];
+ }
+ return this.expander.getValue();
+ },
+
+ populate: function (items) {
+ this.expander.populate(items);
+ }
+});
+
+BI.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);/**
+ * @class BI.SelectTreePopup
+ * @extends BI.Pane
+ */
+
+BI.SelectTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-tree-popup",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ items: []
+ });
+ },
+
+ _formatItems: function (nodes, layer) {
+ var self = this;
+ BI.each(nodes, function (i, node) {
+ var extend = {layer: layer};
+ node.id = node.id || BI.UUID();
+ if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
+ switch (i) {
+ case 0 :
+ extend.type = "bi.select_tree_first_plus_group_node";
+ break;
+ case nodes.length - 1 :
+ extend.type = "bi.select_tree_last_plus_group_node";
+ break;
+ default :
+ extend.type = "bi.select_tree_mid_plus_group_node";
+ break;
+ }
+ BI.defaults(node, extend);
+ self._formatItems(node.children);
+ } else {
+ switch (i) {
+ case nodes.length - 1:
+ extend.type = "bi.last_tree_leaf_item";
+ break;
+ default :
+ extend.type = "bi.mid_tree_leaf_item";
+ }
+ BI.defaults(node, extend);
+ }
+ });
+ return nodes;
+ },
+
+ _init: function () {
+ BI.SelectTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: 'bi.level_tree',
+ expander: {
+ type: "bi.select_tree_expander",
+ isDefaultInit: true
+ },
+ items: this._formatItems(BI.Tree.transformToTreeFormat(o.items)),
+ chooseType: BI.Selection.Single
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.LevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SelectTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.SelectTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.select_tree_popup", BI.SelectTreePopup);/**
+ *
+ * Created by GUY on 2016/8/10.
+ * @class BI.SequenceTableDynamicNumber
+ * @extends BI.SequenceTableTreeNumber
+ */
+BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-sequence-table-dynamic-number"
+ });
+ },
+
+ _init: function () {
+ BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments);
+ },
+
+ _formatNumber: function (nodes) {
+ var self = this, o = this.options;
+ var result = [];
+ var count = this._getStart(nodes);
+
+ function getLeafCount(node) {
+ var cnt = 0;
+ if (BI.isNotEmptyArray(node.children)) {
+ BI.each(node.children, function (index, child) {
+ cnt += getLeafCount(child);
+ });
+ if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) {
+ cnt++;
+ }
+ } else {
+ cnt++;
+ }
+ return cnt;
+ }
+
+ var start = 0, top = 0;
+ BI.each(nodes, function (i, node) {
+ if (BI.isArray(node.children)) {
+ BI.each(node.children, function (index, child) {
+ var cnt = getLeafCount(child);
+ result.push({
+ text: count++,
+ start: start,
+ top: top,
+ cnt: cnt,
+ index: index,
+ height: cnt * o.rowSize
+ });
+ start += cnt;
+ top += cnt * o.rowSize;
+ });
+ if (BI.isNotEmptyArray(node.values)) {
+ result.push({
+ text: BI.i18nText("BI-Summary_Values"),
+ start: start++,
+ top: top,
+ cnt: 1,
+ isSummary: true,
+ height: o.rowSize
+ });
+ top += o.rowSize;
+ }
+ }
+ });
+ return result;
+ }
+});
+BI.shortcut('bi.sequence_table_dynamic_number', BI.SequenceTableDynamicNumber);/**
+ *
+ * Created by GUY on 2016/5/26.
+ * @class BI.SequenceTableListNumber
+ * @extends BI.Widget
+ */
+BI.SequenceTableListNumber = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-sequence-table-list-number",
+ isNeedFreeze: false,
+ scrollTop: 0,
+ startSequence: 1,//开始的序号
+ headerRowSize: 25,
+ rowSize: 25,
+
+ sequenceHeaderCreator: null,
+
+ header: [],
+ items: [], //二维数组
+
+ //交叉表头
+ crossHeader: [],
+ crossItems: [],
+
+ pageSize: 20
+ });
+ },
+
+ _init: function () {
+ BI.SequenceTableListNumber.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.start = o.startSequence;
+ this.renderedCells = [];
+ this.renderedKeys = [];
+
+ this.container = BI.createWidget({
+ type: "bi.absolute",
+ width: 60,
+ scrollable: false
+ });
+
+ this.scrollContainer = BI.createWidget({
+ type: "bi.vertical",
+ scrollable: false,
+ scrolly: false,
+ items: [this.container]
+ });
+
+ this.headerContainer = BI.createWidget({
+ type: "bi.absolute",
+ cls: "bi-border",
+ width: 58,
+ scrollable: false
+ });
+
+ this.layout = BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.headerContainer,
+ height: o.headerRowSize * o.header.length - 2
+ }, {
+ el: {type: "bi.layout"},
+ height: 2
+ }, {
+ el: this.scrollContainer
+ }]
+ });
+ this._populate();
+ },
+
+ _layout: function () {
+ var self = this, o = this.options;
+ var headerHeight = o.headerRowSize * o.header.length - 2;
+ var items = this.layout.attr("items");
+ if (o.isNeedFreeze === false) {
+ items[0].height = 0;
+ items[1].height = 0;
+ } else if (o.isNeedFreeze === true) {
+ items[0].height = headerHeight;
+ items[1].height = 2;
+ }
+ this.layout.attr("items", items);
+ this.layout.resize();
+ this.container.setHeight(o.items.length * o.rowSize);
+ try {
+ this.scrollContainer.element.scrollTop(o.scrollTop);
+ } catch (e) {
+
+ }
+ },
+
+ _createHeader: function () {
+ var o = this.options;
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.headerContainer,
+ items: [{
+ el: o.sequenceHeaderCreator || {
+ type: "bi.table_style_cell",
+ cls: "sequence-table-title-cell",
+ styleGetter: o.headerCellStyleGetter,
+ text: BI.i18nText("BI-Number_Index")
+ },
+ left: 0,
+ top: 0,
+ right: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _calculateChildrenToRender: function () {
+ var self = this, o = this.options;
+ var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth());
+ var start = Math.floor(scrollTop / o.rowSize);
+ var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize);
+ var renderedCells = [], renderedKeys = [];
+ for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) {
+ var index = BI.deepIndexOf(this.renderedKeys, this.start + i);
+ var top = i * o.rowSize;
+ if (index > -1) {
+ if (o.rowSize !== this.renderedCells[index]._height) {
+ this.renderedCells[index]._height = o.rowSize;
+ this.renderedCells[index].el.setHeight(o.rowSize);
+ }
+ if (this.renderedCells[index].top !== top) {
+ this.renderedCells[index].top = top;
+ this.renderedCells[index].el.element.css("top", top + "px");
+ }
+ renderedCells.push(this.renderedCells[index]);
+ } else {
+ var child = BI.createWidget(BI.extend({
+ type: "bi.table_style_cell",
+ cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",
+ width: 60,
+ height: o.rowSize,
+ text: this.start + i,
+ styleGetter: function (index) {
+ return function () {
+ return o.sequenceCellStyleGetter(self.start + i - 1);
+ }
+ }(cnt)
+ }));
+ renderedCells.push({
+ el: child,
+ left: 0,
+ top: top,
+ _height: o.rowSize
+ });
+ }
+ renderedKeys.push(this.start + i);
+ }
+
+ //已存在的, 需要添加的和需要删除的
+ var existSet = {}, addSet = {}, deleteArray = [];
+ BI.each(renderedKeys, function (i, key) {
+ if (BI.deepContains(self.renderedKeys, key)) {
+ existSet[i] = key;
+ } else {
+ addSet[i] = key;
+ }
+ });
+ BI.each(this.renderedKeys, function (i, key) {
+ if (BI.deepContains(existSet, key)) {
+ return;
+ }
+ if (BI.deepContains(addSet, key)) {
+ return;
+ }
+ deleteArray.push(i);
+ });
+ BI.each(deleteArray, function (i, index) {
+ self.renderedCells[index].el.destroy();
+ });
+ var addedItems = [];
+ BI.each(addSet, function (index) {
+ addedItems.push(renderedCells[index])
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: addedItems
+ });
+ this.renderedCells = renderedCells;
+ this.renderedKeys = renderedKeys;
+ },
+
+ _populate: function () {
+ this.headerContainer.empty();
+ this._createHeader();
+ this._layout();
+ this._calculateChildrenToRender();
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ if (this.options.scrollTop !== scrollTop) {
+ this.options.scrollTop = scrollTop;
+ try {
+ this.scrollContainer.element.scrollTop(scrollTop);
+ } catch (e) {
+
+ }
+ }
+ },
+
+ getVerticalScroll: function () {
+ return this.options.scrollTop;
+ },
+
+ setVPage: function (v) {
+ v = v < 1 ? 1 : v;
+ var o = this.options;
+ this.start = (v - 1) * o.pageSize + 1;
+ },
+
+ _restore: function () {
+ var o = this.options;
+ BI.each(this.renderedCells, function (i, cell) {
+ cell.el.destroy();
+ });
+ this.renderedCells = [];
+ this.renderedKeys = [];
+ },
+
+ restore: function () {
+ this._restore();
+ },
+
+ populate: function (items, header) {
+ var o = this.options;
+ if (items && items !== this.options.items) {
+ o.items = items;
+ this._restore();
+ }
+ if (header && header !== this.options.header) {
+ o.header = header;
+ }
+ this._populate();
+ }
+});
+BI.shortcut('bi.sequence_table_list_number', BI.SequenceTableListNumber);/**
+ * 带有序号的表格
+ *
+ * Created by GUY on 2016/5/26.
+ * @class BI.SequenceTable
+ * @extends BI.Widget
+ */
+BI.SequenceTable = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-sequence-table",
+ el: {
+ type: "bi.adaptive_table"
+ },
+
+ sequence: {},
+
+ isNeedResize: true,
+ isResizeAdapt: false,
+
+ isNeedFreeze: false,//是否需要冻结单元格
+ freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
+
+ isNeedMerge: false,//是否需要合并单元格
+ mergeCols: [], //合并的单元格列号
+ mergeRule: BI.emptyFn,
+
+ columnSize: [],
+ minColumnSize: [],
+ maxColumnSize: [],
+ headerRowSize: 25,
+ rowSize: 25,
+
+ regionColumnSize: [],
+
+ headerCellStyleGetter: BI.emptyFn,
+ summaryCellStyleGetter: BI.emptyFn,
+ sequenceCellStyleGetter: BI.emptyFn,
+
+ header: [],
+ items: [], //二维数组
+
+ //交叉表头
+ crossHeader: [],
+ crossItems: [],
+
+ showSequence: false,
+ startSequence: 1//开始的序号
+ });
+ },
+
+ _init: function () {
+ BI.SequenceTable.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.sequence = BI.createWidget(o.sequence, {
+ type: "bi.sequence_table_list_number",
+ invisible: o.showSequence === false,
+ startSequence: o.startSequence,
+ isNeedFreeze: o.isNeedFreeze,
+ header: o.header,
+ items: o.items,
+ crossHeader: o.crossHeader,
+ crossItems: o.crossItems,
+ headerRowSize: o.headerRowSize,
+ rowSize: o.rowSize,
+ width: 60,
+ height: o.height && o.height - BI.GridTableScrollbar.SIZE,
+
+ headerCellStyleGetter: o.headerCellStyleGetter,
+ summaryCellStyleGetter: o.summaryCellStyleGetter,
+ sequenceCellStyleGetter: o.sequenceCellStyleGetter
+ });
+ this.table = BI.createWidget(o.el, {
+ type: "bi.adaptive_table",
+ width: o.showSequence === true ? o.width - 60 : o.width,
+ height: o.height,
+ isNeedResize: o.isNeedResize,
+ isResizeAdapt: o.isResizeAdapt,
+
+ isNeedFreeze: o.isNeedFreeze,
+ freezeCols: o.freezeCols,
+
+ isNeedMerge: o.isNeedMerge,
+ mergeCols: o.mergeCols,
+ mergeRule: o.mergeRule,
+
+ columnSize: o.columnSize,
+ minColumnSize: o.minColumnSize,
+ maxColumnSize: o.maxColumnSize,
+ headerRowSize: o.headerRowSize,
+ rowSize: o.rowSize,
+
+ regionColumnSize: o.regionColumnSize,
+
+ headerCellStyleGetter: o.headerCellStyleGetter,
+ summaryCellStyleGetter: o.summaryCellStyleGetter,
+ sequenceCellStyleGetter: o.sequenceCellStyleGetter,
+
+ header: o.header,
+ items: o.items,
+ //交叉表头
+ crossHeader: o.crossHeader,
+ crossItems: o.crossItems
+ });
+
+ this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) {
+ if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) {
+ self.sequence.setVerticalScroll(this.getVerticalScroll());
+ self.sequence.populate();
+ }
+ self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
+ o.regionColumnSize = this.getRegionColumnSize();
+ o.columnSize = this.getColumnSize();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
+ o.regionColumnSize = this.getRegionColumnSize();
+ o.columnSize = this.getColumnSize();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
+ });
+
+ this.htape = BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.sequence,
+ left: 0,
+ top: 0
+ }, {
+ el: this.table,
+ top: 0,
+ left: o.showSequence === true ? 60 : 0
+ }]
+ });
+ this._populate();
+ },
+
+ _populate: function () {
+ var o = this.options;
+ this.sequence.attr({
+ items: o.items,
+ header: o.header,
+ crossItems: o.crossItems,
+ crossHeader: o.crossHeader
+ });
+ if (o.showSequence === true) {
+ this.sequence.setVisible(true);
+ this.table.element.css("left", "60px");
+ this.table.setWidth(o.width - 60);
+ } else {
+ this.sequence.setVisible(false);
+ this.table.element.css("left", "0px");
+ this.table.setWidth(o.width);
+ }
+ },
+
+ setWidth: function (width) {
+ BI.PageTable.superclass.setWidth.apply(this, arguments);
+ this.table.setWidth(this.options.showSequence ? width - 60 : width);
+ },
+
+ setHeight: function (height) {
+ BI.PageTable.superclass.setHeight.apply(this, arguments);
+ this.table.setHeight(height);
+ this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE);
+ },
+
+ setColumnSize: function (columnSize) {
+ this.options.columnSize = columnSize;
+ this.table.setColumnSize(columnSize);
+ },
+
+ getColumnSize: function () {
+ return this.table.getColumnSize();
+ },
+
+ setRegionColumnSize: function (columnSize) {
+ this.options.columnSize = columnSize;
+ this.table.setRegionColumnSize(columnSize);
+ },
+
+ getRegionColumnSize: function () {
+ return this.table.getRegionColumnSize();
+ },
+
+ hasLeftHorizontalScroll: function () {
+ return this.table.hasLeftHorizontalScroll();
+ },
+
+ hasRightHorizontalScroll: function () {
+ return this.table.hasRightHorizontalScroll();
+ },
+
+ setLeftHorizontalScroll: function (scrollLeft) {
+ this.table.setLeftHorizontalScroll(scrollLeft);
+ },
+
+ setRightHorizontalScroll: function (scrollLeft) {
+ this.table.setRightHorizontalScroll(scrollLeft);
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ this.table.setVerticalScroll(scrollTop);
+ this.sequence.setVerticalScroll(scrollTop);
+ },
+
+ getVerticalScroll: function () {
+ return this.table.getVerticalScroll();
+ },
+
+ setVPage: function (page) {
+ this.sequence.setVPage && this.sequence.setVPage(page);
+ },
+
+ setHPage: function (page) {
+ this.sequence.setHPage && this.sequence.setHPage(page);
+ },
+
+ attr: function () {
+ BI.SequenceTable.superclass.attr.apply(this, arguments);
+ this.table.attr.apply(this.table, arguments);
+ this.sequence.attr.apply(this.sequence, arguments);
+ },
+
+ restore: function () {
+ this.table.restore();
+ this.sequence.restore();
+ },
+
+ populate: function (items, header, crossItems, crossHeader) {
+ var o = this.options;
+ if (items) {
+ o.items = items;
+ }
+ if (header) {
+ o.header = header;
+ }
+ if (crossItems) {
+ o.crossItems = crossItems;
+ }
+ if (crossHeader) {
+ o.crossHeader = crossHeader;
+ }
+ this._populate();
+ this.table.populate.apply(this.table, arguments);
+ this.sequence.populate.apply(this.sequence, arguments);
+ this.sequence.setVerticalScroll(this.table.getVerticalScroll());
+ },
+
+ destroy: function () {
+ this.table.destroy();
+ BI.SequenceTable.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.shortcut('bi.sequence_table', BI.SequenceTable);/*! jQuery UI - v1.12.1 - 2017-07-14
+* http://jqueryui.com
+* Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/draggable.js, widgets/droppable.js, widgets/resizable.js, widgets/selectable.js, widgets/sortable.js, widgets/mouse.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js
+* Copyright jQuery Foundation and other contributors; Licensed MIT */
+
+(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)})(function(t){function e(t){for(var e=t.css("visibility");"inherit"===e;)t=t.parent(),e=t.css("visibility");return"hidden"!==e}t.ui=t.ui||{},t.ui.version="1.12.1";var i=0,s=Array.prototype.slice;t.cleanData=function(e){return function(i){var s,n,o;for(o=0;null!=(n=i[o]);o++)try{s=t._data(n,"events"),s&&s.remove&&t(n).triggerHandler("remove")}catch(a){}e(i)}}(t.cleanData),t.widget=function(e,i,s){var n,o,a,r={},l=e.split(".")[0];e=e.split(".")[1];var h=l+"-"+e;return s||(s=i,i=t.Widget),t.isArray(s)&&(s=t.extend.apply(null,[{}].concat(s))),t.expr[":"][h.toLowerCase()]=function(e){return!!t.data(e,h)},t[l]=t[l]||{},n=t[l][e],o=t[l][e]=function(t,e){return this._createWidget?(arguments.length&&this._createWidget(t,e),void 0):new o(t,e)},t.extend(o,n,{version:s.version,_proto:t.extend({},s),_childConstructors:[]}),a=new i,a.options=t.widget.extend({},a.options),t.each(s,function(e,s){return t.isFunction(s)?(r[e]=function(){function t(){return i.prototype[e].apply(this,arguments)}function n(t){return i.prototype[e].apply(this,t)}return function(){var e,i=this._super,o=this._superApply;return this._super=t,this._superApply=n,e=s.apply(this,arguments),this._super=i,this._superApply=o,e}}(),void 0):(r[e]=s,void 0)}),o.prototype=t.widget.extend(a,{widgetEventPrefix:n?a.widgetEventPrefix||e:e},r,{constructor:o,namespace:l,widgetName:e,widgetFullName:h}),n?(t.each(n._childConstructors,function(e,i){var s=i.prototype;t.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete n._childConstructors):i._childConstructors.push(o),t.widget.bridge(e,o),o},t.widget.extend=function(e){for(var i,n,o=s.call(arguments,1),a=0,r=o.length;r>a;a++)for(i in o[a])n=o[a][i],o[a].hasOwnProperty(i)&&void 0!==n&&(e[i]=t.isPlainObject(n)?t.isPlainObject(e[i])?t.widget.extend({},e[i],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,i){var n=i.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=s.call(arguments,1),l=this;return a?this.length||"instance"!==o?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(l=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(l=i&&i.jquery?l.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):l=void 0:(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new i(o,this))})),l}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{classes:{},disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),this._on(e.element,{remove:"_untrackClassesElement"}),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(e){var i=this;t.each(i.classesElementLookup,function(s,n){-1!==t.inArray(e.target,n)&&(i.classesElementLookup[s]=t(n.not(e.target).get()))})},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var l=s.match(/^([\w:-]*)\s*(.*)$/),h=l[1]+o.eventNamespace,c=l[2];c?n.on(h,c,r):i.on(h,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,function(){function e(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function i(e,i){return parseInt(t.css(e,i),10)||0}function s(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}var n,o=Math.max,a=Math.abs,r=/left|center|right/,l=/top|center|bottom/,h=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,d=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==n)return n;var e,i,s=t("
"),o=s.children()[0];return t("body").append(s),e=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),n=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.width
i?"left":e>0?"right":"center",vertical:0>r?"top":s>0?"bottom":"middle"};h>p&&p>a(e+i)&&(u.horizontal="center"),c>f&&f>a(s+r)&&(u.vertical="middle"),u.important=o(a(e),a(i))>o(a(s),a(r))?"horizontal":"vertical",n.using.call(this,t,u)}),l.offset(t.extend(D,{using:r}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,l=n-r,h=r+e.collisionWidth-a-n;e.collisionWidth>a?l>0&&0>=h?(i=t.left+l+e.collisionWidth-a-n,t.left+=l-i):t.left=h>0&&0>=l?n:l>h?n+a-e.collisionWidth:n:l>0?t.left+=l:h>0?t.left-=h:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,l=n-r,h=r+e.collisionHeight-a-n;e.collisionHeight>a?l>0&&0>=h?(i=t.top+l+e.collisionHeight-a-n,t.top+=l-i):t.top=h>0&&0>=l?n:l>h?n+a-e.collisionHeight:n:l>0?t.top+=l:h>0?t.top-=h:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,l=n.isWindow?n.scrollLeft:n.offset.left,h=t.left-e.collisionPosition.marginLeft,c=h-l,u=h+e.collisionWidth-r-l,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-r-o,(0>i||a(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-l,(s>0||u>a(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,o=n.offset.top+n.scrollTop,r=n.height,l=n.isWindow?n.scrollTop:n.offset.top,h=t.top-e.collisionPosition.marginTop,c=h-l,u=h+e.collisionHeight-r-l,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,g=-2*e.offset[1];0>c?(s=t.top+p+f+g+e.collisionHeight-r-o,(0>s||a(c)>s)&&(t.top+=p+f+g)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+g-l,(i>0||u>a(i))&&(t.top+=p+f+g))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}}}(),t.ui.position,t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])}}),t.fn.extend({disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.off(".ui-disableSelection")}}),t.ui.focusable=function(i,s){var n,o,a,r,l,h=i.nodeName.toLowerCase();return"area"===h?(n=i.parentNode,o=n.name,i.href&&o&&"map"===n.nodeName.toLowerCase()?(a=t("img[usemap='#"+o+"']"),a.length>0&&a.is(":visible")):!1):(/^(input|select|textarea|button|object)$/.test(h)?(r=!i.disabled,r&&(l=t(i).closest("fieldset")[0],l&&(r=!l.disabled))):r="a"===h?i.href||s:s,r&&t(i).is(":visible")&&e(t(i)))},t.extend(t.expr[":"],{focusable:function(e){return t.ui.focusable(e,null!=t.attr(e,"tabindex"))}}),t.ui.focusable,t.fn.form=function(){return"string"==typeof this[0].form?this.closest("form"):t(this[0].form)},t.ui.formResetMixin={_formResetHandler:function(){var e=t(this);setTimeout(function(){var i=e.data("ui-form-reset-instances");t.each(i,function(){this.refresh()})})},_bindFormResetHandler:function(){if(this.form=this.element.form(),this.form.length){var t=this.form.data("ui-form-reset-instances")||[];t.length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t)}},_unbindFormResetHandler:function(){if(this.form.length){var e=this.form.data("ui-form-reset-instances");e.splice(t.inArray(this,e),1),e.length?this.form.data("ui-form-reset-instances",e):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset")}}},"1.7"===t.fn.jquery.substring(0,3)&&(t.each(["Width","Height"],function(e,i){function s(e,i,s,o){return t.each(n,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(e){return void 0===e?a["inner"+i].call(this):this.each(function(){t(this).css(o,s(this,e)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?a["outer"+i].call(this,e):this.each(function(){t(this).css(o,s(this,e,!0,n)+"px")})}}),t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},t.ui.escapeSelector=function(){var t=/([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;return function(e){return e.replace(t,"\\$1")}}(),t.fn.labels=function(){var e,i,s,n,o;return this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(n=this.eq(0).parents("label"),s=this.attr("id"),s&&(e=this.eq(0).parents().last(),o=e.add(e.length?e.siblings():this.siblings()),i="label[for='"+t.ui.escapeSelector(s)+"']",n=n.add(o.find(i).addBack(i))),this.pushStack(n))},t.fn.scrollParent=function(e){var i=this.css("position"),s="absolute"===i,n=e?/(auto|scroll|hidden)/:/(auto|scroll)/,o=this.parents().filter(function(){var e=t(this);return s&&"static"===e.css("position")?!1:n.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==i&&o.length?o:t(this[0].ownerDocument||document)},t.extend(t.expr[":"],{tabbable:function(e){var i=t.attr(e,"tabindex"),s=null!=i;return(!s||i>=0)&&t.ui.focusable(e,s)}}),t.fn.extend({uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var n=!1;t(document).on("mouseup",function(){n=!1}),t.widget("ui.mouse",{version:"1.12.1",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!n){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,s=1===e.which,o="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return s&&!o&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),n=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,n=!1,e.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.ui.plugin={add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;o.length>n;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},t.ui.safeActiveElement=function(t){var e;try{e=t.activeElement}catch(i){e=t.body}return e||(e=t.body),e.nodeName||(e=t.body),e},t.ui.safeBlur=function(e){e&&"body"!==e.nodeName.toLowerCase()&&t(e).trigger("blur")},t.widget("ui.draggable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"===this.options.helper&&this._setPositionRelative(),this.options.addClasses&&this._addClass("ui-draggable"),this._setHandleClassName(),this._mouseInit()},_setOption:function(t,e){this._super(t,e),"handle"===t&&(this._removeHandleClassName(),this._setHandleClassName())},_destroy:function(){return(this.helper||this.element).is(".ui-draggable-dragging")?(this.destroyOnClear=!0,void 0):(this._removeHandleClassName(),this._mouseDestroy(),void 0)},_mouseCapture:function(e){var i=this.options;return this.helper||i.disabled||t(e.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(e),this.handle?(this._blurActiveElement(e),this._blockFrames(i.iframeFix===!0?"iframe":i.iframeFix),!0):!1)},_blockFrames:function(e){this.iframeBlocks=this.document.find(e).map(function(){var e=t(this);return t("").css("position","absolute").appendTo(e.parent()).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()).offset(e.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_blurActiveElement:function(e){var i=t.ui.safeActiveElement(this.document[0]),s=t(e.target);s.closest(i).length||t.ui.safeBlur(i)},_mouseStart:function(e){var i=this.options;return this.helper=this._createHelper(e),this._addClass(this.helper,"ui-draggable-dragging"),this._cacheHelperProportions(),t.ui.ddmanager&&(t.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.hasFixedAncestor=this.helper.parents().filter(function(){return"fixed"===t(this).css("position")}).length>0,this.positionAbs=this.element.offset(),this._refreshOffsets(e),this.originalPosition=this.position=this._generatePosition(e,!1),this.originalPageX=e.pageX,this.originalPageY=e.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",e)===!1?(this._clear(),!1):(this._cacheHelperProportions(),t.ui.ddmanager&&!i.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this._mouseDrag(e,!0),t.ui.ddmanager&&t.ui.ddmanager.dragStart(this,e),!0)},_refreshOffsets:function(t){this.offset={top:this.positionAbs.top-this.margins.top,left:this.positionAbs.left-this.margins.left,scroll:!1,parent:this._getParentOffset(),relative:this._getRelativeOffset()},this.offset.click={left:t.pageX-this.offset.left,top:t.pageY-this.offset.top}},_mouseDrag:function(e,i){if(this.hasFixedAncestor&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(e,!0),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",e,s)===!1)return this._mouseUp(new t.Event("mouseup",e)),!1;this.position=s.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),!1},_mouseStop:function(e){var i=this,s=!1;return t.ui.ddmanager&&!this.options.dropBehaviour&&(s=t.ui.ddmanager.drop(this,e)),this.dropped&&(s=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||t.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?t(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",e)!==!1&&i._clear()}):this._trigger("stop",e)!==!1&&this._clear(),!1},_mouseUp:function(e){return this._unblockFrames(),t.ui.ddmanager&&t.ui.ddmanager.dragStop(this,e),this.handleElement.is(e.target)&&this.element.trigger("focus"),t.ui.mouse.prototype._mouseUp.call(this,e)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp(new t.Event("mouseup",{target:this.element[0]})):this._clear(),this},_getHandle:function(e){return this.options.handle?!!t(e.target).closest(this.element.find(this.options.handle)).length:!0},_setHandleClassName:function(){this.handleElement=this.options.handle?this.element.find(this.options.handle):this.element,this._addClass(this.handleElement,"ui-draggable-handle")},_removeHandleClassName:function(){this._removeClass(this.handleElement,"ui-draggable-handle")},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper),n=s?t(i.helper.apply(this.element[0],[e])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return n.parents("body").length||n.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s&&n[0]===this.element[0]&&this._setPositionRelative(),n[0]===this.element[0]||/(fixed|absolute)/.test(n.css("position"))||n.css("position","absolute"),n},_setPositionRelative:function(){/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative")},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_isRootNode:function(t){return/(html|body)/i.test(t.tagName)||t===this.document[0]},_getParentOffset:function(){var e=this.offsetParent.offset(),i=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==i&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),this._isRootNode(this.offsetParent[0])&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var t=this.element.position(),e=this._isRootNode(this.scrollParent[0]);return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+(e?0:this.scrollParent.scrollTop()),left:t.left-(parseInt(this.helper.css("left"),10)||0)+(e?0:this.scrollParent.scrollLeft())}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options,o=this.document[0];return this.relativeContainer=null,n.containment?"window"===n.containment?(this.containment=[t(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,t(window).scrollLeft()+t(window).width()-this.helperProportions.width-this.margins.left,t(window).scrollTop()+(t(window).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):"document"===n.containment?(this.containment=[0,0,t(o).width()-this.helperProportions.width-this.margins.left,(t(o).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):n.containment.constructor===Array?(this.containment=n.containment,void 0):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=t(n.containment),s=i[0],s&&(e=/(scroll|auto)/.test(i.css("overflow")),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(e?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(e?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relativeContainer=i),void 0):(this.containment=null,void 0)},_convertPositionTo:function(t,e){e||(e=this.position);var i="absolute"===t?1:-1,s=this._isRootNode(this.scrollParent[0]);return{top:e.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:s?0:this.offset.scroll.top)*i,left:e.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:s?0:this.offset.scroll.left)*i}},_generatePosition:function(t,e){var i,s,n,o,a=this.options,r=this._isRootNode(this.scrollParent[0]),l=t.pageX,h=t.pageY;return r&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),e&&(this.containment&&(this.relativeContainer?(s=this.relativeContainer.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,t.pageX-this.offset.click.left
i[2]&&(l=i[2]+this.offset.click.left),t.pageY-this.offset.click.top>i[3]&&(h=i[3]+this.offset.click.top)),a.grid&&(n=a.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/a.grid[1])*a.grid[1]:this.originalPageY,h=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-a.grid[1]:n+a.grid[1]:n,o=a.grid[0]?this.originalPageX+Math.round((l-this.originalPageX)/a.grid[0])*a.grid[0]:this.originalPageX,l=i?o-this.offset.click.left>=i[0]||o-this.offset.click.left>i[2]?o:o-this.offset.click.left>=i[0]?o-a.grid[0]:o+a.grid[0]:o),"y"===a.axis&&(l=this.originalPageX),"x"===a.axis&&(h=this.originalPageY)),{top:h-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:r?0:this.offset.scroll.top),left:l-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:r?0:this.offset.scroll.left)}
+},_clear:function(){this._removeClass(this.helper,"ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_trigger:function(e,i,s){return s=s||this._uiHash(),t.ui.plugin.call(this,e,[i,s,this],!0),/^(drag|start|stop)/.test(e)&&(this.positionAbs=this._convertPositionTo("absolute"),s.offset=this.positionAbs),t.Widget.prototype._trigger.call(this,e,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),t.ui.plugin.add("draggable","connectToSortable",{start:function(e,i,s){var n=t.extend({},i,{item:s.element});s.sortables=[],t(s.options.connectToSortable).each(function(){var i=t(this).sortable("instance");i&&!i.options.disabled&&(s.sortables.push(i),i.refreshPositions(),i._trigger("activate",e,n))})},stop:function(e,i,s){var n=t.extend({},i,{item:s.element});s.cancelHelperRemoval=!1,t.each(s.sortables,function(){var t=this;t.isOver?(t.isOver=0,s.cancelHelperRemoval=!0,t.cancelHelperRemoval=!1,t._storedCSS={position:t.placeholder.css("position"),top:t.placeholder.css("top"),left:t.placeholder.css("left")},t._mouseStop(e),t.options.helper=t.options._helper):(t.cancelHelperRemoval=!0,t._trigger("deactivate",e,n))})},drag:function(e,i,s){t.each(s.sortables,function(){var n=!1,o=this;o.positionAbs=s.positionAbs,o.helperProportions=s.helperProportions,o.offset.click=s.offset.click,o._intersectsWith(o.containerCache)&&(n=!0,t.each(s.sortables,function(){return this.positionAbs=s.positionAbs,this.helperProportions=s.helperProportions,this.offset.click=s.offset.click,this!==o&&this._intersectsWith(this.containerCache)&&t.contains(o.element[0],this.element[0])&&(n=!1),n})),n?(o.isOver||(o.isOver=1,s._parent=i.helper.parent(),o.currentItem=i.helper.appendTo(o.element).data("ui-sortable-item",!0),o.options._helper=o.options.helper,o.options.helper=function(){return i.helper[0]},e.target=o.currentItem[0],o._mouseCapture(e,!0),o._mouseStart(e,!0,!0),o.offset.click.top=s.offset.click.top,o.offset.click.left=s.offset.click.left,o.offset.parent.left-=s.offset.parent.left-o.offset.parent.left,o.offset.parent.top-=s.offset.parent.top-o.offset.parent.top,s._trigger("toSortable",e),s.dropped=o.element,t.each(s.sortables,function(){this.refreshPositions()}),s.currentItem=s.element,o.fromOutside=s),o.currentItem&&(o._mouseDrag(e),i.position=o.position)):o.isOver&&(o.isOver=0,o.cancelHelperRemoval=!0,o.options._revert=o.options.revert,o.options.revert=!1,o._trigger("out",e,o._uiHash(o)),o._mouseStop(e,!0),o.options.revert=o.options._revert,o.options.helper=o.options._helper,o.placeholder&&o.placeholder.remove(),i.helper.appendTo(s._parent),s._refreshOffsets(e),i.position=s._generatePosition(e,!0),s._trigger("fromSortable",e),s.dropped=!1,t.each(s.sortables,function(){this.refreshPositions()}))})}}),t.ui.plugin.add("draggable","cursor",{start:function(e,i,s){var n=t("body"),o=s.options;n.css("cursor")&&(o._cursor=n.css("cursor")),n.css("cursor",o.cursor)},stop:function(e,i,s){var n=s.options;n._cursor&&t("body").css("cursor",n._cursor)}}),t.ui.plugin.add("draggable","opacity",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("opacity")&&(o._opacity=n.css("opacity")),n.css("opacity",o.opacity)},stop:function(e,i,s){var n=s.options;n._opacity&&t(i.helper).css("opacity",n._opacity)}}),t.ui.plugin.add("draggable","scroll",{start:function(t,e,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(e,i,s){var n=s.options,o=!1,a=s.scrollParentNotHidden[0],r=s.document[0];a!==r&&"HTML"!==a.tagName?(n.axis&&"x"===n.axis||(s.overflowOffset.top+a.offsetHeight-e.pageY=0;d--)l=s.snapElements[d].left-s.margins.left,h=l+s.snapElements[d].width,c=s.snapElements[d].top-s.margins.top,u=c+s.snapElements[d].height,l-g>_||m>h+g||c-g>b||v>u+g||!t.contains(s.snapElements[d].item.ownerDocument,s.snapElements[d].item)?(s.snapElements[d].snapping&&s.options.snap.release&&s.options.snap.release.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=!1):("inner"!==f.snapMode&&(n=g>=Math.abs(c-b),o=g>=Math.abs(u-v),a=g>=Math.abs(l-_),r=g>=Math.abs(h-m),n&&(i.position.top=s._convertPositionTo("relative",{top:c-s.helperProportions.height,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l-s.helperProportions.width}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h}).left)),p=n||o||a||r,"outer"!==f.snapMode&&(n=g>=Math.abs(c-v),o=g>=Math.abs(u-b),a=g>=Math.abs(l-m),r=g>=Math.abs(h-_),n&&(i.position.top=s._convertPositionTo("relative",{top:c,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u-s.helperProportions.height,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h-s.helperProportions.width}).left)),!s.snapElements[d].snapping&&(n||o||a||r||p)&&s.options.snap.snap&&s.options.snap.snap.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=n||o||a||r||p)}}),t.ui.plugin.add("draggable","stack",{start:function(e,i,s){var n,o=s.options,a=t.makeArray(t(o.stack)).sort(function(e,i){return(parseInt(t(e).css("zIndex"),10)||0)-(parseInt(t(i).css("zIndex"),10)||0)});a.length&&(n=parseInt(t(a[0]).css("zIndex"),10)||0,t(a).each(function(e){t(this).css("zIndex",n+e)}),this.css("zIndex",n+a.length))}}),t.ui.plugin.add("draggable","zIndex",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("zIndex")&&(o._zIndex=n.css("zIndex")),n.css("zIndex",o.zIndex)},stop:function(e,i,s){var n=s.options;n._zIndex&&t(i.helper).css("zIndex",n._zIndex)}}),t.ui.draggable,t.widget("ui.droppable",{version:"1.12.1",widgetEventPrefix:"drop",options:{accept:"*",addClasses:!0,greedy:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var e,i=this.options,s=i.accept;this.isover=!1,this.isout=!0,this.accept=t.isFunction(s)?s:function(t){return t.is(s)},this.proportions=function(){return arguments.length?(e=arguments[0],void 0):e?e:e={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}},this._addToManager(i.scope),i.addClasses&&this._addClass("ui-droppable")},_addToManager:function(e){t.ui.ddmanager.droppables[e]=t.ui.ddmanager.droppables[e]||[],t.ui.ddmanager.droppables[e].push(this)},_splice:function(t){for(var e=0;t.length>e;e++)t[e]===this&&t.splice(e,1)},_destroy:function(){var e=t.ui.ddmanager.droppables[this.options.scope];this._splice(e)},_setOption:function(e,i){if("accept"===e)this.accept=t.isFunction(i)?i:function(t){return t.is(i)};else if("scope"===e){var s=t.ui.ddmanager.droppables[this.options.scope];this._splice(s),this._addToManager(i)}this._super(e,i)},_activate:function(e){var i=t.ui.ddmanager.current;this._addActiveClass(),i&&this._trigger("activate",e,this.ui(i))},_deactivate:function(e){var i=t.ui.ddmanager.current;this._removeActiveClass(),i&&this._trigger("deactivate",e,this.ui(i))},_over:function(e){var i=t.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this._addHoverClass(),this._trigger("over",e,this.ui(i)))},_out:function(e){var i=t.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this._removeHoverClass(),this._trigger("out",e,this.ui(i)))},_drop:function(e,i){var s=i||t.ui.ddmanager.current,n=!1;return s&&(s.currentItem||s.element)[0]!==this.element[0]?(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var i=t(this).droppable("instance");return i.options.greedy&&!i.options.disabled&&i.options.scope===s.options.scope&&i.accept.call(i.element[0],s.currentItem||s.element)&&o(s,t.extend(i,{offset:i.element.offset()}),i.options.tolerance,e)?(n=!0,!1):void 0}),n?!1:this.accept.call(this.element[0],s.currentItem||s.element)?(this._removeActiveClass(),this._removeHoverClass(),this._trigger("drop",e,this.ui(s)),this.element):!1):!1},ui:function(t){return{draggable:t.currentItem||t.element,helper:t.helper,position:t.position,offset:t.positionAbs}},_addHoverClass:function(){this._addClass("ui-droppable-hover")},_removeHoverClass:function(){this._removeClass("ui-droppable-hover")},_addActiveClass:function(){this._addClass("ui-droppable-active")},_removeActiveClass:function(){this._removeClass("ui-droppable-active")}});var o=t.ui.intersect=function(){function t(t,e,i){return t>=e&&e+i>t}return function(e,i,s,n){if(!i.offset)return!1;var o=(e.positionAbs||e.position.absolute).left+e.margins.left,a=(e.positionAbs||e.position.absolute).top+e.margins.top,r=o+e.helperProportions.width,l=a+e.helperProportions.height,h=i.offset.left,c=i.offset.top,u=h+i.proportions().width,d=c+i.proportions().height;switch(s){case"fit":return o>=h&&u>=r&&a>=c&&d>=l;case"intersect":return o+e.helperProportions.width/2>h&&u>r-e.helperProportions.width/2&&a+e.helperProportions.height/2>c&&d>l-e.helperProportions.height/2;case"pointer":return t(n.pageY,c,i.proportions().height)&&t(n.pageX,h,i.proportions().width);case"touch":return(a>=c&&d>=a||l>=c&&d>=l||c>a&&l>d)&&(o>=h&&u>=o||r>=h&&u>=r||h>o&&r>u);default:return!1}}}();t.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(e,i){var s,n,o=t.ui.ddmanager.droppables[e.options.scope]||[],a=i?i.type:null,r=(e.currentItem||e.element).find(":data(ui-droppable)").addBack();t:for(s=0;o.length>s;s++)if(!(o[s].options.disabled||e&&!o[s].accept.call(o[s].element[0],e.currentItem||e.element))){for(n=0;r.length>n;n++)if(r[n]===o[s].element[0]){o[s].proportions().height=0;continue t}o[s].visible="none"!==o[s].element.css("display"),o[s].visible&&("mousedown"===a&&o[s]._activate.call(o[s],i),o[s].offset=o[s].element.offset(),o[s].proportions({width:o[s].element[0].offsetWidth,height:o[s].element[0].offsetHeight}))}},drop:function(e,i){var s=!1;return t.each((t.ui.ddmanager.droppables[e.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&o(e,this,this.options.tolerance,i)&&(s=this._drop.call(this,i)||s),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],e.currentItem||e.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,i)))}),s},dragStart:function(e,i){e.element.parentsUntil("body").on("scroll.droppable",function(){e.options.refreshPositions||t.ui.ddmanager.prepareOffsets(e,i)})},drag:function(e,i){e.options.refreshPositions&&t.ui.ddmanager.prepareOffsets(e,i),t.each(t.ui.ddmanager.droppables[e.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var s,n,a,r=o(e,this,this.options.tolerance,i),l=!r&&this.isover?"isout":r&&!this.isover?"isover":null;l&&(this.options.greedy&&(n=this.options.scope,a=this.element.parents(":data(ui-droppable)").filter(function(){return t(this).droppable("instance").options.scope===n}),a.length&&(s=t(a[0]).droppable("instance"),s.greedyChild="isover"===l)),s&&"isover"===l&&(s.isover=!1,s.isout=!0,s._out.call(s,i)),this[l]=!0,this["isout"===l?"isover":"isout"]=!1,this["isover"===l?"_over":"_out"].call(this,i),s&&"isout"===l&&(s.isout=!1,s.isover=!0,s._over.call(s,i)))}})},dragStop:function(e,i){e.element.parentsUntil("body").off("scroll.droppable"),e.options.refreshPositions||t.ui.ddmanager.prepareOffsets(e,i)}},t.uiBackCompat!==!1&&t.widget("ui.droppable",t.ui.droppable,{options:{hoverClass:!1,activeClass:!1},_addActiveClass:function(){this._super(),this.options.activeClass&&this.element.addClass(this.options.activeClass)},_removeActiveClass:function(){this._super(),this.options.activeClass&&this.element.removeClass(this.options.activeClass)},_addHoverClass:function(){this._super(),this.options.hoverClass&&this.element.addClass(this.options.hoverClass)},_removeHoverClass:function(){this._super(),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass)}}),t.ui.droppable,t.widget("ui.resizable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,classes:{"ui-resizable-se":"ui-icon ui-icon-gripsmall-diagonal-se"},containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseFloat(t)||0},_isNumber:function(t){return!isNaN(parseFloat(t))},_hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)},_create:function(){var e,i=this.options,s=this;this._addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(t("
").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,e={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(e),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(e),this._proportionallyResize()),this._setupHandles(),i.autoHide&&t(this.element).on("mouseenter",function(){i.disabled||(s._removeClass("ui-resizable-autohide"),s._handles.show())}).on("mouseleave",function(){i.disabled||s.resizing||(s._addClass("ui-resizable-autohide"),s._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeData("resizable").removeData("ui-resizable").off(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;default:}},_setupHandles:function(){var e,i,s,n,o,a=this.options,r=this;if(this.handles=a.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=t(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),s=this.handles.split(","),this.handles={},i=0;s.length>i;i++)e=t.trim(s[i]),n="ui-resizable-"+e,o=t(""),this._addClass(o,"ui-resizable-handle "+n),o.css({zIndex:a.zIndex}),this.handles[e]=".ui-resizable-"+e,this.element.append(o);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=t(this.handles[i]),this._on(this.handles[i],{mousedown:r._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){r.resizing||(this.className&&(o=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),r.axis=o&&o[1]?o[1]:"se")}),a.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._handles.remove()},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(e){var i,s,n,o=this.options,a=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),o.containment&&(i+=t(o.containment).scrollLeft()||0,s+=t(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:e.pageX,top:e.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===n?this.axis+"-resize":n),this._addClass("ui-resizable-resizing"),this._propagate("start",e),!0},_mouseDrag:function(e){var i,s,n=this.originalMousePosition,o=this.axis,a=e.pageX-n.left||0,r=e.pageY-n.top||0,l=this._change[o];return this._updatePrevProperties(),l?(i=l.apply(this,[e,a,r]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",e,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,l,h=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseFloat(c.element.css("left"))+(c.position.left-c.originalPosition.left)||null,l=parseFloat(c.element.css("top"))+(c.position.top-c.originalPosition.top)||null,h.animate||this.element.css(t.extend(a,{top:l,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!h.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s,n,o,a=this.options;o={minWidth:this._isNumber(a.minWidth)?a.minWidth:0,maxWidth:this._isNumber(a.maxWidth)?a.maxWidth:1/0,minHeight:this._isNumber(a.minHeight)?a.minHeight:0,maxHeight:this._isNumber(a.maxHeight)?a.maxHeight:1/0},(this._aspectRatio||t)&&(e=o.minHeight*this.aspectRatio,s=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,n=o.maxWidth/this.aspectRatio,e>o.minWidth&&(o.minWidth=e),s>o.minHeight&&(o.minHeight=s),o.maxWidth>i&&(o.maxWidth=i),o.maxHeight>n&&(o.maxHeight=n)),this._vBoundaries=o},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidth
t.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,l=this.originalPosition.top+this.originalSize.height,h=/sw|nw|w/.test(i),c=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&h&&(t.left=r-e.minWidth),s&&h&&(t.left=r-e.maxWidth),a&&c&&(t.top=l-e.minHeight),n&&c&&(t.top=l-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];4>e;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;this._proportionallyResizeElements.length>e;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
"),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,l={width:i.size.width-r,height:i.size.height-a},h=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,c=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(l,c&&h?{top:c,left:h}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var e,i,s,n,o,a,r,l=t(this).resizable("instance"),h=l.options,c=l.element,u=h.containment,d=u instanceof t?u.get(0):/parent/.test(u)?c.parent().get(0):u;d&&(l.containerElement=t(d),/document/.test(u)||u===document?(l.containerOffset={left:0,top:0},l.containerPosition={left:0,top:0},l.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(e=t(d),i=[],t(["Top","Right","Left","Bottom"]).each(function(t,s){i[t]=l._num(e.css("padding"+s))}),l.containerOffset=e.offset(),l.containerPosition=e.position(),l.containerSize={height:e.innerHeight()-i[3],width:e.innerWidth()-i[1]},s=l.containerOffset,n=l.containerSize.height,o=l.containerSize.width,a=l._hasScroll(d,"left")?d.scrollWidth:o,r=l._hasScroll(d)?d.scrollHeight:n,l.parentData={element:d,left:s.left,top:s.top,width:a,height:r}))},resize:function(e){var i,s,n,o,a=t(this).resizable("instance"),r=a.options,l=a.containerOffset,h=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(u=l),h.left<(a._helper?l.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-l.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio,p=!1),a.position.left=r.helper?l.left:0),h.top<(a._helper?l.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-l.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio,p=!1),a.position.top=a._helper?l.top:0),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o?(a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top):(a.offset.left=a.element.offset().left,a.offset.top=a.element.offset().top),i=Math.abs(a.sizeDiff.width+(a._helper?a.offset.left-u.left:a.offset.left-l.left)),s=Math.abs(a.sizeDiff.height+(a._helper?a.offset.top-u.top:a.offset.top-l.top)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio,p=!1)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio,p=!1)),p||(a.position.left=a.prevPosition.left,a.position.top=a.prevPosition.top,a.size.width=a.prevSize.width,a.size.height=a.prevSize.height)},stop:function(){var e=t(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),l=a.outerWidth()-e.sizeDiff.width,h=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:l,height:h}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:l,height:h})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).resizable("instance"),i=e.options;t(i.alsoResize).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseFloat(e.width()),height:parseFloat(e.height()),left:parseFloat(e.css("left")),top:parseFloat(e.css("top"))})})},resize:function(e,i){var s=t(this).resizable("instance"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0};t(n.alsoResize).each(function(){var e=t(this),s=t(this).data("ui-resizable-alsoresize"),n={},o=e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(o,function(t,e){var i=(s[e]||0)+(r[e]||0);i&&i>=0&&(n[e]=i||null)}),e.css(n)})},stop:function(){t(this).removeData("ui-resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).resizable("instance"),i=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:i.height,width:i.width,margin:0,left:0,top:0}),e._addClass(e.ghost,"ui-resizable-ghost"),t.uiBackCompat!==!1&&"string"==typeof e.options.ghost&&e.ghost.addClass(this.options.ghost),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).resizable("instance");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).resizable("instance");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e,i=t(this).resizable("instance"),s=i.options,n=i.size,o=i.originalSize,a=i.originalPosition,r=i.axis,l="number"==typeof s.grid?[s.grid,s.grid]:s.grid,h=l[0]||1,c=l[1]||1,u=Math.round((n.width-o.width)/h)*h,d=Math.round((n.height-o.height)/c)*c,p=o.width+u,f=o.height+d,g=s.maxWidth&&p>s.maxWidth,m=s.maxHeight&&f>s.maxHeight,_=s.minWidth&&s.minWidth>p,v=s.minHeight&&s.minHeight>f;s.grid=l,_&&(p+=h),v&&(f+=c),g&&(p-=h),m&&(f-=c),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=a.top-d):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=a.left-u):((0>=f-c||0>=p-h)&&(e=i._getPaddingPlusBorderDimensions(this)),f-c>0?(i.size.height=f,i.position.top=a.top-d):(f=c-e.height,i.size.height=f,i.position.top=a.top+o.height-f),p-h>0?(i.size.width=p,i.position.left=a.left-u):(p=h-e.width,i.size.width=p,i.position.left=a.left+o.width-p))
+}}),t.ui.resizable,t.widget("ui.selectable",t.ui.mouse,{version:"1.12.1",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var e=this;this._addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){e.elementPos=t(e.element[0]).offset(),e.selectees=t(e.options.filter,e.element[0]),e._addClass(e.selectees,"ui-selectee"),e.selectees.each(function(){var i=t(this),s=i.offset(),n={left:s.left-e.elementPos.left,top:s.top-e.elementPos.top};t.data(this,"selectable-item",{element:this,$element:i,left:n.left,top:n.top,right:n.left+i.outerWidth(),bottom:n.top+i.outerHeight(),startselected:!1,selected:i.hasClass("ui-selected"),selecting:i.hasClass("ui-selecting"),unselecting:i.hasClass("ui-unselecting")})})},this.refresh(),this._mouseInit(),this.helper=t(""),this._addClass(this.helper,"ui-selectable-helper")},_destroy:function(){this.selectees.removeData("selectable-item"),this._mouseDestroy()},_mouseStart:function(e){var i=this,s=this.options;this.opos=[e.pageX,e.pageY],this.elementPos=t(this.element[0]).offset(),this.options.disabled||(this.selectees=t(s.filter,this.element[0]),this._trigger("start",e),t(s.appendTo).append(this.helper),this.helper.css({left:e.pageX,top:e.pageY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=t.data(this,"selectable-item");s.startselected=!0,e.metaKey||e.ctrlKey||(i._removeClass(s.$element,"ui-selected"),s.selected=!1,i._addClass(s.$element,"ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",e,{unselecting:s.element}))}),t(e.target).parents().addBack().each(function(){var s,n=t.data(this,"selectable-item");return n?(s=!e.metaKey&&!e.ctrlKey||!n.$element.hasClass("ui-selected"),i._removeClass(n.$element,s?"ui-unselecting":"ui-selected")._addClass(n.$element,s?"ui-selecting":"ui-unselecting"),n.unselecting=!s,n.selecting=s,n.selected=s,s?i._trigger("selecting",e,{selecting:n.element}):i._trigger("unselecting",e,{unselecting:n.element}),!1):void 0}))},_mouseDrag:function(e){if(this.dragged=!0,!this.options.disabled){var i,s=this,n=this.options,o=this.opos[0],a=this.opos[1],r=e.pageX,l=e.pageY;return o>r&&(i=r,r=o,o=i),a>l&&(i=l,l=a,a=i),this.helper.css({left:o,top:a,width:r-o,height:l-a}),this.selectees.each(function(){var i=t.data(this,"selectable-item"),h=!1,c={};i&&i.element!==s.element[0]&&(c.left=i.left+s.elementPos.left,c.right=i.right+s.elementPos.left,c.top=i.top+s.elementPos.top,c.bottom=i.bottom+s.elementPos.top,"touch"===n.tolerance?h=!(c.left>r||o>c.right||c.top>l||a>c.bottom):"fit"===n.tolerance&&(h=c.left>o&&r>c.right&&c.top>a&&l>c.bottom),h?(i.selected&&(s._removeClass(i.$element,"ui-selected"),i.selected=!1),i.unselecting&&(s._removeClass(i.$element,"ui-unselecting"),i.unselecting=!1),i.selecting||(s._addClass(i.$element,"ui-selecting"),i.selecting=!0,s._trigger("selecting",e,{selecting:i.element}))):(i.selecting&&((e.metaKey||e.ctrlKey)&&i.startselected?(s._removeClass(i.$element,"ui-selecting"),i.selecting=!1,s._addClass(i.$element,"ui-selected"),i.selected=!0):(s._removeClass(i.$element,"ui-selecting"),i.selecting=!1,i.startselected&&(s._addClass(i.$element,"ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",e,{unselecting:i.element}))),i.selected&&(e.metaKey||e.ctrlKey||i.startselected||(s._removeClass(i.$element,"ui-selected"),i.selected=!1,s._addClass(i.$element,"ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",e,{unselecting:i.element})))))}),!1}},_mouseStop:function(e){var i=this;return this.dragged=!1,t(".ui-unselecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");i._removeClass(s.$element,"ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",e,{unselected:s.element})}),t(".ui-selecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");i._removeClass(s.$element,"ui-selecting")._addClass(s.$element,"ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",e,{selected:s.element})}),this._trigger("stop",e),this.helper.remove(),!1}}),t.widget("ui.sortable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(t,e,i){return t>=e&&e+i>t},_isFloating:function(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))},_create:function(){this.containerCache={},this._addClass("ui-sortable"),this.refresh(),this.offset=this.element.offset(),this._mouseInit(),this._setHandleClassName(),this.ready=!0},_setOption:function(t,e){this._super(t,e),"handle"===t&&this._setHandleClassName()},_setHandleClassName:function(){var e=this;this._removeClass(this.element.find(".ui-sortable-handle"),"ui-sortable-handle"),t.each(this.items,function(){e._addClass(this.instance.options.handle?this.item.find(this.instance.options.handle):this.item,"ui-sortable-handle")})},_destroy:function(){this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_mouseCapture:function(e,i){var s=null,n=!1,o=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(e),t(e.target).parents().each(function(){return t.data(this,o.widgetName+"-item")===o?(s=t(this),!1):void 0}),t.data(e.target,o.widgetName+"-item")===o&&(s=t(e.target)),s?!this.options.handle||i||(t(this.options.handle,s).find("*").addBack().each(function(){this===e.target&&(n=!0)}),n)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(e,i,s){var n,o,a=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,a.cursorAt&&this._adjustOffsetFromHelper(a.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),a.containment&&this._setContainment(),a.cursor&&"auto"!==a.cursor&&(o=this.document.find("body"),this.storedCursor=o.css("cursor"),o.css("cursor",a.cursor),this.storedStylesheet=t("").appendTo(o)),a.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",a.opacity)),a.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",a.zIndex)),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!a.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this._addClass(this.helper,"ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,s,n,o,a=this.options,r=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY
=0;i--)if(s=this.items[i],n=s.item[0],o=this._intersectsWithPointer(s),o&&s.instance===this.currentContainer&&n!==this.currentItem[0]&&this.placeholder[1===o?"next":"prev"]()[0]!==n&&!t.contains(this.placeholder[0],n)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],n):!0)){if(this.direction=1===o?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break;this._rearrange(e,s),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var s=this,n=this.placeholder.offset(),o=this.options.axis,a={};o&&"x"!==o||(a.left=n.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollLeft)),o&&"y"!==o||(a.top=n.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(a,parseInt(this.options.revert,10)||500,function(){s._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp(new t.Event("mouseup",{target:null})),"original"===this.options.helper?(this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&s.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!s.length&&e.key&&s.push(e.key+"="),s.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},i.each(function(){s.push(t(e.item||this).attr(e.attribute||"id")||"")}),s},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,o=t.left,a=o+t.width,r=t.top,l=r+t.height,h=this.offset.click.top,c=this.offset.click.left,u="x"===this.options.axis||s+h>r&&l>s+h,d="y"===this.options.axis||e+c>o&&a>e+c,p=u&&d;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?p:e+this.helperProportions.width/2>o&&a>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>r&&l>n-this.helperProportions.height/2},_intersectsWithPointer:function(t){var e,i,s="x"===this.options.axis||this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),n="y"===this.options.axis||this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width),o=s&&n;return o?(e=this._getDragVerticalDirection(),i=this._getDragHorizontalDirection(),this.floating?"right"===i||"down"===e?2:1:e&&("down"===e?2:1)):!1},_intersectsWithSides:function(t){var e=this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),i=this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),s=this._getDragVerticalDirection(),n=this._getDragHorizontalDirection();return this.floating&&n?"right"===n&&i||"left"===n&&!i:s&&("down"===s&&e||"up"===s&&!e)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!==t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this._setHandleClassName(),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){function i(){r.push(this)}var s,n,o,a,r=[],l=[],h=this._connectWith();if(h&&e)for(s=h.length-1;s>=0;s--)for(o=t(h[s],this.document[0]),n=o.length-1;n>=0;n--)a=t.data(o[n],this.widgetFullName),a&&a!==this&&!a.options.disabled&&l.push([t.isFunction(a.options.items)?a.options.items.call(a.element):t(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a]);for(l.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),s=l.length-1;s>=0;s--)l[s][0].each(i);return t(r)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;e.length>i;i++)if(e[i]===t.item[0])return!1;return!0})},_refreshItems:function(e){this.items=[],this.containers=[this];var i,s,n,o,a,r,l,h,c=this.items,u=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],d=this._connectWith();if(d&&this.ready)for(i=d.length-1;i>=0;i--)for(n=t(d[i],this.document[0]),s=n.length-1;s>=0;s--)o=t.data(n[s],this.widgetFullName),o&&o!==this&&!o.options.disabled&&(u.push([t.isFunction(o.options.items)?o.options.items.call(o.element[0],e,{item:this.currentItem}):t(o.options.items,o.element),o]),this.containers.push(o));for(i=u.length-1;i>=0;i--)for(a=u[i][1],r=u[i][0],s=0,h=r.length;h>s;s++)l=t(r[s]),l.data(this.widgetName+"-item",a),c.push({item:l,instance:a,width:0,height:0,left:0,top:0})},refreshPositions:function(e){this.floating=this.items.length?"x"===this.options.axis||this._isFloating(this.items[0].item):!1,this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,s,n,o;for(i=this.items.length-1;i>=0;i--)s=this.items[i],s.instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(n=this.options.toleranceElement?t(this.options.toleranceElement,s.item):s.item,e||(s.width=n.outerWidth(),s.height=n.outerHeight()),o=n.offset(),s.left=o.left,s.top=o.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)o=this.containers[i].element.offset(),this.containers[i].containerCache.left=o.left,this.containers[i].containerCache.top=o.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){e=e||this;var i,s=e.options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=e.currentItem[0].nodeName.toLowerCase(),n=t("<"+s+">",e.document[0]);return e._addClass(n,"ui-sortable-placeholder",i||e.currentItem[0].className)._removeClass(n,"ui-sortable-helper"),"tbody"===s?e._createTrPlaceholder(e.currentItem.find("tr").eq(0),t("",e.document[0]).appendTo(n)):"tr"===s?e._createTrPlaceholder(e.currentItem,n):"img"===s&&n.attr("src",e.currentItem.attr("src")),i||n.css("visibility","hidden"),n},update:function(t,n){(!i||s.forcePlaceholderSize)&&(n.height()||n.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),n.width()||n.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(s.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),s.placeholder.update(e,e.placeholder)},_createTrPlaceholder:function(e,i){var s=this;e.children().each(function(){t(" ",s.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(i)})},_contactContainers:function(e){var i,s,n,o,a,r,l,h,c,u,d=null,p=null;for(i=this.containers.length-1;i>=0;i--)if(!t.contains(this.currentItem[0],this.containers[i].element[0]))if(this._intersectsWith(this.containers[i].containerCache)){if(d&&t.contains(this.containers[i].element[0],d.element[0]))continue;d=this.containers[i],p=i}else this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",e,this._uiHash(this)),this.containers[i].containerCache.over=0);if(d)if(1===this.containers.length)this.containers[p].containerCache.over||(this.containers[p]._trigger("over",e,this._uiHash(this)),this.containers[p].containerCache.over=1);else{for(n=1e4,o=null,c=d.floating||this._isFloating(this.currentItem),a=c?"left":"top",r=c?"width":"height",u=c?"pageX":"pageY",s=this.items.length-1;s>=0;s--)t.contains(this.containers[p].element[0],this.items[s].item[0])&&this.items[s].item[0]!==this.currentItem[0]&&(l=this.items[s].item.offset()[a],h=!1,e[u]-l>this.items[s][r]/2&&(h=!0),n>Math.abs(e[u]-l)&&(n=Math.abs(e[u]-l),o=this.items[s],this.direction=h?"up":"down"));if(!o&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[p])return this.currentContainer.containerCache.over||(this.containers[p]._trigger("over",e,this._uiHash()),this.currentContainer.containerCache.over=1),void 0;o?this._rearrange(e,o,null,!0):this._rearrange(e,null,this.containers[p].element,!0),this._trigger("change",e,this._uiHash()),this.containers[p]._trigger("change",e,this._uiHash(this)),this.currentContainer=this.containers[p],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[p]._trigger("over",e,this._uiHash(this)),this.containers[p].containerCache.over=1}},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||t("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(!s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===this.document[0].body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options;"parent"===n.containment&&(n.containment=this.helper[0].parentNode),("document"===n.containment||"window"===n.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,"document"===n.containment?this.document.width():this.window.width()-this.helperProportions.width-this.margins.left,("document"===n.containment?this.document.height()||document.body.parentNode.scrollHeight:this.window.height()||this.document[0].body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(n.containment)||(e=t(n.containment)[0],i=t(n.containment).offset(),s="hidden"!==t(e).css("overflow"),this.containment=[i.left+(parseInt(t(e).css("borderLeftWidth"),10)||0)+(parseInt(t(e).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(t(e).css("borderTopWidth"),10)||0)+(parseInt(t(e).css("paddingTop"),10)||0)-this.margins.top,i.left+(s?Math.max(e.scrollWidth,e.offsetWidth):e.offsetWidth)-(parseInt(t(e).css("borderLeftWidth"),10)||0)-(parseInt(t(e).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(s?Math.max(e.scrollHeight,e.offsetHeight):e.offsetHeight)-(parseInt(t(e).css("borderTopWidth"),10)||0)-(parseInt(t(e).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(e,i){i||(i=this.position);var s="absolute"===e?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(n[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():o?0:n.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():o?0:n.scrollLeft())*s}},_generatePosition:function(e){var i,s,n=this.options,o=e.pageX,a=e.pageY,r="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,l=/(html|body)/i.test(r[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.leftthis.containment[2]&&(o=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(a=this.containment[3]+this.offset.click.top)),n.grid&&(i=this.originalPageY+Math.round((a-this.originalPageY)/n.grid[1])*n.grid[1],a=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-n.grid[1]:i+n.grid[1]:i,s=this.originalPageX+Math.round((o-this.originalPageX)/n.grid[0])*n.grid[0],o=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-n.grid[0]:s+n.grid[0]:s)),{top:a-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():l?0:r.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():l?0:r.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){function i(t,e,i){return function(s){i._trigger(t,s,e._uiHash(e))}}this.reverting=!1;var s,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(s in this._storedCSS)("auto"===this._storedCSS[s]||"static"===this._storedCSS[s])&&(this._storedCSS[s]="");this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&n.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||n.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(n.push(function(t){this._trigger("remove",t,this._uiHash())}),n.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),s=this.containers.length-1;s>=0;s--)e||n.push(i("deactivate",this,this.containers[s])),this.containers[s].containerCache.over&&(n.push(i("out",this,this.containers[s])),this.containers[s].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.cancelHelperRemoval||(this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null),!e){for(s=0;n.length>s;s++)n[s].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!this.cancelHelperRemoval},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}});var a="ui-effects-",r="ui-effects-style",l="ui-effects-animated",h=t;t.effects={effect:{}},function(t,e){function i(t,e,i){var s=u[e.type]||{};return null==t?i||!e.def?null:e.def:(t=s.floor?~~t:parseFloat(t),isNaN(t)?e.def:s.mod?(t+s.mod)%s.mod:0>t?0:t>s.max?s.max:t)}function s(i){var s=h(),n=s._rgba=[];return i=i.toLowerCase(),f(l,function(t,o){var a,r=o.re.exec(i),l=r&&o.parse(r),h=o.space||"rgba";return l?(a=s[h](l),s[c[h].cache]=a[c[h].cache],n=s._rgba=a._rgba,!1):e}),n.length?("0,0,0,0"===n.join()&&t.extend(n,o.transparent),s):o[i]}function n(t,e,i){return i=(i+1)%1,1>6*i?t+6*(e-t)*i:1>2*i?e:2>3*i?t+6*(e-t)*(2/3-i):t}var o,a="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",r=/^([\-+])=\s*(\d+\.?\d*)/,l=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[t[1],t[2],t[3],t[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[2.55*t[1],2.55*t[2],2.55*t[3],t[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(t){return[t[1],t[2]/100,t[3]/100,t[4]]}}],h=t.Color=function(e,i,s,n){return new t.Color.fn.parse(e,i,s,n)},c={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},u={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},d=h.support={},p=t("")[0],f=t.each;p.style.cssText="background-color:rgba(1,1,1,.5)",d.rgba=p.style.backgroundColor.indexOf("rgba")>-1,f(c,function(t,e){e.cache="_"+t,e.props.alpha={idx:3,type:"percent",def:1}}),h.fn=t.extend(h.prototype,{parse:function(n,a,r,l){if(n===e)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=t(n).css(a),a=e);var u=this,d=t.type(n),p=this._rgba=[];return a!==e&&(n=[n,a,r,l],d="array"),"string"===d?this.parse(s(n)||o._default):"array"===d?(f(c.rgba.props,function(t,e){p[e.idx]=i(n[e.idx],e)}),this):"object"===d?(n instanceof h?f(c,function(t,e){n[e.cache]&&(u[e.cache]=n[e.cache].slice())}):f(c,function(e,s){var o=s.cache;f(s.props,function(t,e){if(!u[o]&&s.to){if("alpha"===t||null==n[t])return;u[o]=s.to(u._rgba)}u[o][e.idx]=i(n[t],e,!0)}),u[o]&&0>t.inArray(null,u[o].slice(0,3))&&(u[o][3]=1,s.from&&(u._rgba=s.from(u[o])))}),this):e},is:function(t){var i=h(t),s=!0,n=this;return f(c,function(t,o){var a,r=i[o.cache];return r&&(a=n[o.cache]||o.to&&o.to(n._rgba)||[],f(o.props,function(t,i){return null!=r[i.idx]?s=r[i.idx]===a[i.idx]:e})),s}),s},_space:function(){var t=[],e=this;return f(c,function(i,s){e[s.cache]&&t.push(i)}),t.pop()},transition:function(t,e){var s=h(t),n=s._space(),o=c[n],a=0===this.alpha()?h("transparent"):this,r=a[o.cache]||o.to(a._rgba),l=r.slice();
+return s=s[o.cache],f(o.props,function(t,n){var o=n.idx,a=r[o],h=s[o],c=u[n.type]||{};null!==h&&(null===a?l[o]=h:(c.mod&&(h-a>c.mod/2?a+=c.mod:a-h>c.mod/2&&(a-=c.mod)),l[o]=i((h-a)*e+a,n)))}),this[n](l)},blend:function(e){if(1===this._rgba[3])return this;var i=this._rgba.slice(),s=i.pop(),n=h(e)._rgba;return h(t.map(i,function(t,e){return(1-s)*n[e]+s*t}))},toRgbaString:function(){var e="rgba(",i=t.map(this._rgba,function(t,e){return null==t?e>2?1:0:t});return 1===i[3]&&(i.pop(),e="rgb("),e+i.join()+")"},toHslaString:function(){var e="hsla(",i=t.map(this.hsla(),function(t,e){return null==t&&(t=e>2?1:0),e&&3>e&&(t=Math.round(100*t)+"%"),t});return 1===i[3]&&(i.pop(),e="hsl("),e+i.join()+")"},toHexString:function(e){var i=this._rgba.slice(),s=i.pop();return e&&i.push(~~(255*s)),"#"+t.map(i,function(t){return t=(t||0).toString(16),1===t.length?"0"+t:t}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),h.fn.parse.prototype=h.fn,c.hsla.to=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e,i,s=t[0]/255,n=t[1]/255,o=t[2]/255,a=t[3],r=Math.max(s,n,o),l=Math.min(s,n,o),h=r-l,c=r+l,u=.5*c;return e=l===r?0:s===r?60*(n-o)/h+360:n===r?60*(o-s)/h+120:60*(s-n)/h+240,i=0===h?0:.5>=u?h/c:h/(2-c),[Math.round(e)%360,i,u,null==a?1:a]},c.hsla.from=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/360,i=t[1],s=t[2],o=t[3],a=.5>=s?s*(1+i):s+i-s*i,r=2*s-a;return[Math.round(255*n(r,a,e+1/3)),Math.round(255*n(r,a,e)),Math.round(255*n(r,a,e-1/3)),o]},f(c,function(s,n){var o=n.props,a=n.cache,l=n.to,c=n.from;h.fn[s]=function(s){if(l&&!this[a]&&(this[a]=l(this._rgba)),s===e)return this[a].slice();var n,r=t.type(s),u="array"===r||"object"===r?s:arguments,d=this[a].slice();return f(o,function(t,e){var s=u["object"===r?t:e.idx];null==s&&(s=d[e.idx]),d[e.idx]=i(s,e)}),c?(n=h(c(d)),n[a]=d,n):h(d)},f(o,function(e,i){h.fn[e]||(h.fn[e]=function(n){var o,a=t.type(n),l="alpha"===e?this._hsla?"hsla":"rgba":s,h=this[l](),c=h[i.idx];return"undefined"===a?c:("function"===a&&(n=n.call(this,c),a=t.type(n)),null==n&&i.empty?this:("string"===a&&(o=r.exec(n),o&&(n=c+parseFloat(o[2])*("+"===o[1]?1:-1))),h[i.idx]=n,this[l](h)))})})}),h.hook=function(e){var i=e.split(" ");f(i,function(e,i){t.cssHooks[i]={set:function(e,n){var o,a,r="";if("transparent"!==n&&("string"!==t.type(n)||(o=s(n)))){if(n=h(o||n),!d.rgba&&1!==n._rgba[3]){for(a="backgroundColor"===i?e.parentNode:e;(""===r||"transparent"===r)&&a&&a.style;)try{r=t.css(a,"backgroundColor"),a=a.parentNode}catch(l){}n=n.blend(r&&"transparent"!==r?r:"_default")}n=n.toRgbaString()}try{e.style[i]=n}catch(l){}}},t.fx.step[i]=function(e){e.colorInit||(e.start=h(e.elem,i),e.end=h(e.end),e.colorInit=!0),t.cssHooks[i].set(e.elem,e.start.transition(e.end,e.pos))}})},h.hook(a),t.cssHooks.borderColor={expand:function(t){var e={};return f(["Top","Right","Bottom","Left"],function(i,s){e["border"+s+"Color"]=t}),e}},o=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(h),function(){function e(e){var i,s,n=e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,null):e.currentStyle,o={};if(n&&n.length&&n[0]&&n[n[0]])for(s=n.length;s--;)i=n[s],"string"==typeof n[i]&&(o[t.camelCase(i)]=n[i]);else for(i in n)"string"==typeof n[i]&&(o[i]=n[i]);return o}function i(e,i){var s,o,a={};for(s in i)o=i[s],e[s]!==o&&(n[s]||(t.fx.step[s]||!isNaN(parseFloat(o)))&&(a[s]=o));return a}var s=["add","remove","toggle"],n={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};t.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(e,i){t.fx.step[i]=function(t){("none"!==t.end&&!t.setAttr||1===t.pos&&!t.setAttr)&&(h.style(t.elem,i,t.end),t.setAttr=!0)}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.effects.animateClass=function(n,o,a,r){var l=t.speed(o,a,r);return this.queue(function(){var o,a=t(this),r=a.attr("class")||"",h=l.children?a.find("*").addBack():a;h=h.map(function(){var i=t(this);return{el:i,start:e(this)}}),o=function(){t.each(s,function(t,e){n[e]&&a[e+"Class"](n[e])})},o(),h=h.map(function(){return this.end=e(this.el[0]),this.diff=i(this.start,this.end),this}),a.attr("class",r),h=h.map(function(){var e=this,i=t.Deferred(),s=t.extend({},l,{queue:!1,complete:function(){i.resolve(e)}});return this.el.animate(this.diff,s),i.promise()}),t.when.apply(t,h.get()).done(function(){o(),t.each(arguments,function(){var e=this.el;t.each(this.diff,function(t){e.css(t,"")})}),l.complete.call(a[0])})})},t.fn.extend({addClass:function(e){return function(i,s,n,o){return s?t.effects.animateClass.call(this,{add:i},s,n,o):e.apply(this,arguments)}}(t.fn.addClass),removeClass:function(e){return function(i,s,n,o){return arguments.length>1?t.effects.animateClass.call(this,{remove:i},s,n,o):e.apply(this,arguments)}}(t.fn.removeClass),toggleClass:function(e){return function(i,s,n,o,a){return"boolean"==typeof s||void 0===s?n?t.effects.animateClass.call(this,s?{add:i}:{remove:i},n,o,a):e.apply(this,arguments):t.effects.animateClass.call(this,{toggle:i},s,n,o)}}(t.fn.toggleClass),switchClass:function(e,i,s,n,o){return t.effects.animateClass.call(this,{add:i,remove:e},s,n,o)}})}(),function(){function e(e,i,s,n){return t.isPlainObject(e)&&(i=e,e=e.effect),e={effect:e},null==i&&(i={}),t.isFunction(i)&&(n=i,s=null,i={}),("number"==typeof i||t.fx.speeds[i])&&(n=s,s=i,i={}),t.isFunction(s)&&(n=s,s=null),i&&t.extend(e,i),s=s||i.duration,e.duration=t.fx.off?0:"number"==typeof s?s:s in t.fx.speeds?t.fx.speeds[s]:t.fx.speeds._default,e.complete=n||i.complete,e}function i(e){return!e||"number"==typeof e||t.fx.speeds[e]?!0:"string"!=typeof e||t.effects.effect[e]?t.isFunction(e)?!0:"object"!=typeof e||e.effect?!1:!0:!0}function s(t,e){var i=e.outerWidth(),s=e.outerHeight(),n=/^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/,o=n.exec(t)||["",0,i,s,0];return{top:parseFloat(o[1])||0,right:"auto"===o[2]?i:parseFloat(o[2]),bottom:"auto"===o[3]?s:parseFloat(o[3]),left:parseFloat(o[4])||0}}t.expr&&t.expr.filters&&t.expr.filters.animated&&(t.expr.filters.animated=function(e){return function(i){return!!t(i).data(l)||e(i)}}(t.expr.filters.animated)),t.uiBackCompat!==!1&&t.extend(t.effects,{save:function(t,e){for(var i=0,s=e.length;s>i;i++)null!==e[i]&&t.data(a+e[i],t[0].style[e[i]])},restore:function(t,e){for(var i,s=0,n=e.length;n>s;s++)null!==e[s]&&(i=t.data(a+e[s]),t.css(e[s],i))},setMode:function(t,e){return"toggle"===e&&(e=t.is(":hidden")?"show":"hide"),e},createWrapper:function(e){if(e.parent().is(".ui-effects-wrapper"))return e.parent();var i={width:e.outerWidth(!0),height:e.outerHeight(!0),"float":e.css("float")},s=t("
").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),n={width:e.width(),height:e.height()},o=document.activeElement;try{o.id}catch(a){o=document.body}return e.wrap(s),(e[0]===o||t.contains(e[0],o))&&t(o).trigger("focus"),s=e.parent(),"static"===e.css("position")?(s.css({position:"relative"}),e.css({position:"relative"})):(t.extend(i,{position:e.css("position"),zIndex:e.css("z-index")}),t.each(["top","left","bottom","right"],function(t,s){i[s]=e.css(s),isNaN(parseInt(i[s],10))&&(i[s]="auto")}),e.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),e.css(n),s.css(i).show()},removeWrapper:function(e){var i=document.activeElement;return e.parent().is(".ui-effects-wrapper")&&(e.parent().replaceWith(e),(e[0]===i||t.contains(e[0],i))&&t(i).trigger("focus")),e}}),t.extend(t.effects,{version:"1.12.1",define:function(e,i,s){return s||(s=i,i="effect"),t.effects.effect[e]=s,t.effects.effect[e].mode=i,s},scaledDimensions:function(t,e,i){if(0===e)return{height:0,width:0,outerHeight:0,outerWidth:0};var s="horizontal"!==i?(e||100)/100:1,n="vertical"!==i?(e||100)/100:1;return{height:t.height()*n,width:t.width()*s,outerHeight:t.outerHeight()*n,outerWidth:t.outerWidth()*s}},clipToBox:function(t){return{width:t.clip.right-t.clip.left,height:t.clip.bottom-t.clip.top,left:t.clip.left,top:t.clip.top}},unshift:function(t,e,i){var s=t.queue();e>1&&s.splice.apply(s,[1,0].concat(s.splice(e,i))),t.dequeue()},saveStyle:function(t){t.data(r,t[0].style.cssText)},restoreStyle:function(t){t[0].style.cssText=t.data(r)||"",t.removeData(r)},mode:function(t,e){var i=t.is(":hidden");return"toggle"===e&&(e=i?"show":"hide"),(i?"hide"===e:"show"===e)&&(e="none"),e},getBaseline:function(t,e){var i,s;switch(t[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=t[0]/e.height}switch(t[1]){case"left":s=0;break;case"center":s=.5;break;case"right":s=1;break;default:s=t[1]/e.width}return{x:s,y:i}},createPlaceholder:function(e){var i,s=e.css("position"),n=e.position();return e.css({marginTop:e.css("marginTop"),marginBottom:e.css("marginBottom"),marginLeft:e.css("marginLeft"),marginRight:e.css("marginRight")}).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()),/^(static|relative)/.test(s)&&(s="absolute",i=t("<"+e[0].nodeName+">").insertAfter(e).css({display:/^(inline|ruby)/.test(e.css("display"))?"inline-block":"block",visibility:"hidden",marginTop:e.css("marginTop"),marginBottom:e.css("marginBottom"),marginLeft:e.css("marginLeft"),marginRight:e.css("marginRight"),"float":e.css("float")}).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()).addClass("ui-effects-placeholder"),e.data(a+"placeholder",i)),e.css({position:s,left:n.left,top:n.top}),i},removePlaceholder:function(t){var e=a+"placeholder",i=t.data(e);i&&(i.remove(),t.removeData(e))},cleanUp:function(e){t.effects.restoreStyle(e),t.effects.removePlaceholder(e)},setTransition:function(e,i,s,n){return n=n||{},t.each(i,function(t,i){var o=e.cssUnit(i);o[0]>0&&(n[i]=o[0]*s+o[1])}),n}}),t.fn.extend({effect:function(){function i(e){function i(){r.removeData(l),t.effects.cleanUp(r),"hide"===s.mode&&r.hide(),a()}function a(){t.isFunction(h)&&h.call(r[0]),t.isFunction(e)&&e()}var r=t(this);s.mode=u.shift(),t.uiBackCompat===!1||o?"none"===s.mode?(r[c](),a()):n.call(r[0],s,i):(r.is(":hidden")?"hide"===c:"show"===c)?(r[c](),a()):n.call(r[0],s,a)}var s=e.apply(this,arguments),n=t.effects.effect[s.effect],o=n.mode,a=s.queue,r=a||"fx",h=s.complete,c=s.mode,u=[],d=function(e){var i=t(this),s=t.effects.mode(i,c)||o;i.data(l,!0),u.push(s),o&&("show"===s||s===o&&"hide"===s)&&i.show(),o&&"none"===s||t.effects.saveStyle(i),t.isFunction(e)&&e()};return t.fx.off||!n?c?this[c](s.duration,h):this.each(function(){h&&h.call(this)}):a===!1?this.each(d).each(i):this.queue(r,d).queue(r,i)},show:function(t){return function(s){if(i(s))return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="show",this.effect.call(this,n)}}(t.fn.show),hide:function(t){return function(s){if(i(s))return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="hide",this.effect.call(this,n)}}(t.fn.hide),toggle:function(t){return function(s){if(i(s)||"boolean"==typeof s)return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="toggle",this.effect.call(this,n)}}(t.fn.toggle),cssUnit:function(e){var i=this.css(e),s=[];return t.each(["em","px","%","pt"],function(t,e){i.indexOf(e)>0&&(s=[parseFloat(i),e])}),s},cssClip:function(t){return t?this.css("clip","rect("+t.top+"px "+t.right+"px "+t.bottom+"px "+t.left+"px)"):s(this.css("clip"),this)},transfer:function(e,i){var s=t(this),n=t(e.to),o="fixed"===n.css("position"),a=t("body"),r=o?a.scrollTop():0,l=o?a.scrollLeft():0,h=n.offset(),c={top:h.top-r,left:h.left-l,height:n.innerHeight(),width:n.innerWidth()},u=s.offset(),d=t("
").appendTo("body").addClass(e.className).css({top:u.top-r,left:u.left-l,height:s.innerHeight(),width:s.innerWidth(),position:o?"fixed":"absolute"}).animate(c,e.duration,e.easing,function(){d.remove(),t.isFunction(i)&&i()})}}),t.fx.step.clip=function(e){e.clipInit||(e.start=t(e.elem).cssClip(),"string"==typeof e.end&&(e.end=s(e.end,e.elem)),e.clipInit=!0),t(e.elem).cssClip({top:e.pos*(e.end.top-e.start.top)+e.start.top,right:e.pos*(e.end.right-e.start.right)+e.start.right,bottom:e.pos*(e.end.bottom-e.start.bottom)+e.start.bottom,left:e.pos*(e.end.left-e.start.left)+e.start.left})}}(),function(){var e={};t.each(["Quad","Cubic","Quart","Quint","Expo"],function(t,i){e[i]=function(e){return Math.pow(e,t+2)}}),t.extend(e,{Sine:function(t){return 1-Math.cos(t*Math.PI/2)},Circ:function(t){return 1-Math.sqrt(1-t*t)},Elastic:function(t){return 0===t||1===t?t:-Math.pow(2,8*(t-1))*Math.sin((80*(t-1)-7.5)*Math.PI/15)},Back:function(t){return t*t*(3*t-2)},Bounce:function(t){for(var e,i=4;((e=Math.pow(2,--i))-1)/11>t;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*e-2)/22-t,2)}}),t.each(e,function(e,i){t.easing["easeIn"+e]=i,t.easing["easeOut"+e]=function(t){return 1-i(1-t)},t.easing["easeInOut"+e]=function(t){return.5>t?i(2*t)/2:1-i(-2*t+2)/2}})}();var c=t.effects;t.effects.define("blind","hide",function(e,i){var s={up:["bottom","top"],vertical:["bottom","top"],down:["top","bottom"],left:["right","left"],horizontal:["right","left"],right:["left","right"]},n=t(this),o=e.direction||"up",a=n.cssClip(),r={clip:t.extend({},a)},l=t.effects.createPlaceholder(n);r.clip[s[o][0]]=r.clip[s[o][1]],"show"===e.mode&&(n.cssClip(r.clip),l&&l.css(t.effects.clipToBox(r)),r.clip=a),l&&l.animate(t.effects.clipToBox(r),e.duration,e.easing),n.animate(r,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("bounce",function(e,i){var s,n,o,a=t(this),r=e.mode,l="hide"===r,h="show"===r,c=e.direction||"up",u=e.distance,d=e.times||5,p=2*d+(h||l?1:0),f=e.duration/p,g=e.easing,m="up"===c||"down"===c?"top":"left",_="up"===c||"left"===c,v=0,b=a.queue().length;for(t.effects.createPlaceholder(a),o=a.css(m),u||(u=a["top"===m?"outerHeight":"outerWidth"]()/3),h&&(n={opacity:1},n[m]=o,a.css("opacity",0).css(m,_?2*-u:2*u).animate(n,f,g)),l&&(u/=Math.pow(2,d-1)),n={},n[m]=o;d>v;v++)s={},s[m]=(_?"-=":"+=")+u,a.animate(s,f,g).animate(n,f,g),u=l?2*u:u/2;l&&(s={opacity:0},s[m]=(_?"-=":"+=")+u,a.animate(s,f,g)),a.queue(i),t.effects.unshift(a,b,p+1)}),t.effects.define("clip","hide",function(e,i){var s,n={},o=t(this),a=e.direction||"vertical",r="both"===a,l=r||"horizontal"===a,h=r||"vertical"===a;s=o.cssClip(),n.clip={top:h?(s.bottom-s.top)/2:s.top,right:l?(s.right-s.left)/2:s.right,bottom:h?(s.bottom-s.top)/2:s.bottom,left:l?(s.right-s.left)/2:s.left},t.effects.createPlaceholder(o),"show"===e.mode&&(o.cssClip(n.clip),n.clip=s),o.animate(n,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("drop","hide",function(e,i){var s,n=t(this),o=e.mode,a="show"===o,r=e.direction||"left",l="up"===r||"down"===r?"top":"left",h="up"===r||"left"===r?"-=":"+=",c="+="===h?"-=":"+=",u={opacity:0};t.effects.createPlaceholder(n),s=e.distance||n["top"===l?"outerHeight":"outerWidth"](!0)/2,u[l]=h+s,a&&(n.css(u),u[l]=c+s,u.opacity=1),n.animate(u,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("explode","hide",function(e,i){function s(){b.push(this),b.length===u*d&&n()}function n(){p.css({visibility:"visible"}),t(b).remove(),i()}var o,a,r,l,h,c,u=e.pieces?Math.round(Math.sqrt(e.pieces)):3,d=u,p=t(this),f=e.mode,g="show"===f,m=p.show().css("visibility","hidden").offset(),_=Math.ceil(p.outerWidth()/d),v=Math.ceil(p.outerHeight()/u),b=[];for(o=0;u>o;o++)for(l=m.top+o*v,c=o-(u-1)/2,a=0;d>a;a++)r=m.left+a*_,h=a-(d-1)/2,p.clone().appendTo("body").wrap("
").css({position:"absolute",visibility:"visible",left:-a*_,top:-o*v}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:_,height:v,left:r+(g?h*_:0),top:l+(g?c*v:0),opacity:g?0:1}).animate({left:r+(g?0:h*_),top:l+(g?0:c*v),opacity:g?1:0},e.duration||500,e.easing,s)}),t.effects.define("fade","toggle",function(e,i){var s="show"===e.mode;t(this).css("opacity",s?0:1).animate({opacity:s?1:0},{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("fold","hide",function(e,i){var s=t(this),n=e.mode,o="show"===n,a="hide"===n,r=e.size||15,l=/([0-9]+)%/.exec(r),h=!!e.horizFirst,c=h?["right","bottom"]:["bottom","right"],u=e.duration/2,d=t.effects.createPlaceholder(s),p=s.cssClip(),f={clip:t.extend({},p)},g={clip:t.extend({},p)},m=[p[c[0]],p[c[1]]],_=s.queue().length;l&&(r=parseInt(l[1],10)/100*m[a?0:1]),f.clip[c[0]]=r,g.clip[c[0]]=r,g.clip[c[1]]=0,o&&(s.cssClip(g.clip),d&&d.css(t.effects.clipToBox(g)),g.clip=p),s.queue(function(i){d&&d.animate(t.effects.clipToBox(f),u,e.easing).animate(t.effects.clipToBox(g),u,e.easing),i()}).animate(f,u,e.easing).animate(g,u,e.easing).queue(i),t.effects.unshift(s,_,4)}),t.effects.define("highlight","show",function(e,i){var s=t(this),n={backgroundColor:s.css("backgroundColor")};"hide"===e.mode&&(n.opacity=0),t.effects.saveStyle(s),s.css({backgroundImage:"none",backgroundColor:e.color||"#ffff99"}).animate(n,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("size",function(e,i){var s,n,o,a=t(this),r=["fontSize"],l=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],h=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],c=e.mode,u="effect"!==c,d=e.scale||"both",p=e.origin||["middle","center"],f=a.css("position"),g=a.position(),m=t.effects.scaledDimensions(a),_=e.from||m,v=e.to||t.effects.scaledDimensions(a,0);t.effects.createPlaceholder(a),"show"===c&&(o=_,_=v,v=o),n={from:{y:_.height/m.height,x:_.width/m.width},to:{y:v.height/m.height,x:v.width/m.width}},("box"===d||"both"===d)&&(n.from.y!==n.to.y&&(_=t.effects.setTransition(a,l,n.from.y,_),v=t.effects.setTransition(a,l,n.to.y,v)),n.from.x!==n.to.x&&(_=t.effects.setTransition(a,h,n.from.x,_),v=t.effects.setTransition(a,h,n.to.x,v))),("content"===d||"both"===d)&&n.from.y!==n.to.y&&(_=t.effects.setTransition(a,r,n.from.y,_),v=t.effects.setTransition(a,r,n.to.y,v)),p&&(s=t.effects.getBaseline(p,m),_.top=(m.outerHeight-_.outerHeight)*s.y+g.top,_.left=(m.outerWidth-_.outerWidth)*s.x+g.left,v.top=(m.outerHeight-v.outerHeight)*s.y+g.top,v.left=(m.outerWidth-v.outerWidth)*s.x+g.left),a.css(_),("content"===d||"both"===d)&&(l=l.concat(["marginTop","marginBottom"]).concat(r),h=h.concat(["marginLeft","marginRight"]),a.find("*[width]").each(function(){var i=t(this),s=t.effects.scaledDimensions(i),o={height:s.height*n.from.y,width:s.width*n.from.x,outerHeight:s.outerHeight*n.from.y,outerWidth:s.outerWidth*n.from.x},a={height:s.height*n.to.y,width:s.width*n.to.x,outerHeight:s.height*n.to.y,outerWidth:s.width*n.to.x};n.from.y!==n.to.y&&(o=t.effects.setTransition(i,l,n.from.y,o),a=t.effects.setTransition(i,l,n.to.y,a)),n.from.x!==n.to.x&&(o=t.effects.setTransition(i,h,n.from.x,o),a=t.effects.setTransition(i,h,n.to.x,a)),u&&t.effects.saveStyle(i),i.css(o),i.animate(a,e.duration,e.easing,function(){u&&t.effects.restoreStyle(i)})})),a.animate(v,{queue:!1,duration:e.duration,easing:e.easing,complete:function(){var e=a.offset();0===v.opacity&&a.css("opacity",_.opacity),u||(a.css("position","static"===f?"relative":f).offset(e),t.effects.saveStyle(a)),i()}})}),t.effects.define("scale",function(e,i){var s=t(this),n=e.mode,o=parseInt(e.percent,10)||(0===parseInt(e.percent,10)?0:"effect"!==n?0:100),a=t.extend(!0,{from:t.effects.scaledDimensions(s),to:t.effects.scaledDimensions(s,o,e.direction||"both"),origin:e.origin||["middle","center"]},e);e.fade&&(a.from.opacity=1,a.to.opacity=0),t.effects.effect.size.call(this,a,i)}),t.effects.define("puff","hide",function(e,i){var s=t.extend(!0,{},e,{fade:!0,percent:parseInt(e.percent,10)||150});t.effects.effect.scale.call(this,s,i)}),t.effects.define("pulsate","show",function(e,i){var s=t(this),n=e.mode,o="show"===n,a="hide"===n,r=o||a,l=2*(e.times||5)+(r?1:0),h=e.duration/l,c=0,u=1,d=s.queue().length;for((o||!s.is(":visible"))&&(s.css("opacity",0).show(),c=1);l>u;u++)s.animate({opacity:c},h,e.easing),c=1-c;s.animate({opacity:c},h,e.easing),s.queue(i),t.effects.unshift(s,d,l+1)}),t.effects.define("shake",function(e,i){var s=1,n=t(this),o=e.direction||"left",a=e.distance||20,r=e.times||3,l=2*r+1,h=Math.round(e.duration/l),c="up"===o||"down"===o?"top":"left",u="up"===o||"left"===o,d={},p={},f={},g=n.queue().length;for(t.effects.createPlaceholder(n),d[c]=(u?"-=":"+=")+a,p[c]=(u?"+=":"-=")+2*a,f[c]=(u?"-=":"+=")+2*a,n.animate(d,h,e.easing);r>s;s++)n.animate(p,h,e.easing).animate(f,h,e.easing);n.animate(p,h,e.easing).animate(d,h/2,e.easing).queue(i),t.effects.unshift(n,g,l+1)}),t.effects.define("slide","show",function(e,i){var s,n,o=t(this),a={up:["bottom","top"],down:["top","bottom"],left:["right","left"],right:["left","right"]},r=e.mode,l=e.direction||"left",h="up"===l||"down"===l?"top":"left",c="up"===l||"left"===l,u=e.distance||o["top"===h?"outerHeight":"outerWidth"](!0),d={};t.effects.createPlaceholder(o),s=o.cssClip(),n=o.position()[h],d[h]=(c?-1:1)*u+n,d.clip=o.cssClip(),d.clip[a[l][1]]=d.clip[a[l][0]],"show"===r&&(o.cssClip(d.clip),o.css(h,d[h]),d.clip=s,d[h]=n),o.animate(d,{queue:!1,duration:e.duration,easing:e.easing,complete:i})});var c;t.uiBackCompat!==!1&&(c=t.effects.define("transfer",function(e,i){t(this).transfer(e,i)}))});/**
+ * Created by zcf on 2016/9/22.
+ */
+BI.SingleSlider = BI.inherit(BI.Widget, {
+ _constant: {
+ EDITOR_WIDTH: 60,
+ EDITOR_HEIGHT: 30,
+ HEIGHT: 28,
+ SLIDER_WIDTH_HALF: 15,
+ SLIDER_WIDTH: 30,
+ SLIDER_HEIGHT: 30,
+ TRACK_HEIGHT: 24
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-slider bi-slider-track"
+ });
+ },
+ _init: function () {
+ BI.SingleSlider.superclass._init.apply(this, arguments);
+
+ var self = this;
+ var c = this._constant;
+ this.enable = false;
+ this.value = "";
+
+ this.backgroundTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "background-track bi-background",
+ height: c.TRACK_HEIGHT
+ });
+ this.grayTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "gray-track",
+ height: 8
+ });
+ this.blueTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "blue-track bi-high-light-background",
+ height: 8
+ });
+ this.track = this._createTrackWrapper();
+
+ this.slider = BI.createWidget({
+ type: "bi.single_slider_slider"
+ });
+ this.slider.element.draggable({
+ axis: "x",
+ containment: this.grayTrack.element,
+ scroll: false,
+ drag: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1)); //直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
+ self._setBlueTrack(significantPercent);
+ self._setLabelPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.label.setValue(v);
+ self.value = v;
+ },
+ stop: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderPosition(significantPercent);
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }
+ });
+ var sliderVertical = BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [this.slider]
+ }],
+ hgap: c.SLIDER_WIDTH_HALF,
+ height: c.SLIDER_HEIGHT
+ });
+ sliderVertical.element.click(function (e) {
+ if (self.enable) {
+ var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF;
+ var trackLength = self.track.element[0].scrollWidth;
+ var percent = 0;
+ if (offset < 0) {
+ percent = 0
+ }
+ if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) {
+ percent = offset * 100 / self._getGrayTrackLength();
+ }
+ if (offset > (trackLength - c.SLIDER_WIDTH)) {
+ percent = 100
+ }
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setAllPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.label.setValue(v);
+ self.value = v;
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }
+ });
+ this.label = BI.createWidget({
+ type: "bi.sign_editor",
+ cls: "slider-editor-button",
+ errorText: "",
+ height: c.HEIGHT,
+ width: c.EDITOR_WIDTH,
+ allowBlank: false,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ },
+ quitChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var percent = self._getPercentByValue(this.getValue());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setAllPosition(significantPercent);
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ });
+ this.label.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.label.element.addClass("bi-border");
+ });
+ this.label.on(BI.SignEditor.EVENT_BLUR, function () {
+ self.label.element.removeClass("bi-border");
+ });
+ this._setVisible(false);
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.track,
+ width: "100%",
+ height: c.TRACK_HEIGHT
+ }]
+ }],
+ hgap: 7,
+ height: c.TRACK_HEIGHT
+ },
+ top: 33,
+ left: 0,
+ width: "100%"
+ }, {
+ el: sliderVertical,
+ top: 30,
+ left: 0,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [this.label]
+ }],
+ rgap: c.EDITOR_WIDTH / 2,
+ height: c.EDITOR_HEIGHT
+ },
+ top: 0,
+ left: 0,
+ width: "100%"
+ }]
+ })
+ },
+
+ _createTrackWrapper: function () {
+ return BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: this.backgroundTrack,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.grayTrack,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }, {
+ el: this.blueTrack,
+ top: 0,
+ left: 0,
+ width: "0%"
+ }]
+ }],
+ hgap: 8,
+ height: 8
+ },
+ top: 8,
+ left: 0,
+ width: "100%"
+ }]
+ })
+ },
+
+ _checkValidation: function (v) {
+ return !(BI.isNull(v) || v < this.min || v > this.max)
+ },
+
+ _setBlueTrack: function (percent) {
+ this.blueTrack.element.css({
+ "width": percent + "%"
+ });
+ },
+
+ _setLabelPosition: function (percent) {
+ this.label.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setSliderPosition: function (percent) {
+ this.slider.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setAllPosition: function (percent) {
+ this._setSliderPosition(percent);
+ this._setLabelPosition(percent);
+ this._setBlueTrack(percent);
+ },
+
+ _setVisible: function (visible) {
+ this.slider.setVisible(visible);
+ this.label.setVisible(visible);
+ },
+
+ _getGrayTrackLength: function () {
+ return this.grayTrack.element[0].scrollWidth
+ },
+
+ _getValueByPercent: function (percent) {
+ var thousandth = BI.parseInt(percent * 10);
+ return (((this.max - this.min) * thousandth) / 1000 + this.min);
+ },
+
+ _getPercentByValue: function (v) {
+ return (v - this.min) * 100 / (this.max - this.min);
+ },
+
+ getValue: function () {
+ return this.value;
+ },
+
+ setValue: function (v) {
+ var value = BI.parseFloat(v);
+ if ((!isNaN(value))) {
+ if (this._checkValidation(value)) {
+ this.value = value;
+ }
+ if (value > this.max) {
+ this.value = this.max;
+ }
+ if (value < this.min) {
+ this.value = this.min;
+ }
+ }
+ },
+
+ setMinAndMax: function (v) {
+ var minNumber = BI.parseFloat(v.min);
+ var maxNumber = BI.parseFloat(v.max);
+ if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber)) {
+ this.min = minNumber;
+ this.max = maxNumber;
+ }
+ },
+
+ reset: function () {
+ this._setVisible(false);
+ this.enable = false;
+ this.value = "";
+ this.min = 0;
+ this.max = 0;
+ this._setBlueTrack(0);
+ },
+
+ populate: function () {
+ if (!isNaN(this.min) && !isNaN(this.max)) {
+ this._setVisible(true);
+ this.enable = true;
+ this.label.setErrorText(BI.i18nText("BI-Please_Enter") + this.min + "-" + this.max + BI.i18nText("BI-Basic_De") + BI.i18nText("BI-Basic_Number"));
+ if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
+ this.label.setValue(this.value);
+ this._setAllPosition(this._getPercentByValue(this.value));
+ } else {
+ this.label.setValue(this.max);
+ this._setAllPosition(100);
+ }
+ }
+ }
+});
+BI.SingleSlider.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_slider", BI.SingleSlider);/**
+ * Created by zcf on 2016/9/22.
+ */
+BI.Slider = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Slider.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-slider-slider"
+ });
+ },
+ _init: function () {
+ BI.extend(BI.Slider.superclass._init.apply(this, arguments));
+ this.slider = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "widget-slider-icon",
+ iconWidth: 30,
+ iconHeight: 30,
+ height: 30,
+ width: 30
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.slider,
+ top: 0,
+ left: -15
+ }],
+ width: 0,
+ height: 30
+ });
+ }
+});
+BI.shortcut("bi.single_slider_slider", BI.Slider);/**
+ * @class BI.SingleTreeCombo
+ * @extends BI.Widget
+ */
+BI.SingleTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-tree-combo",
+ trigger: {},
+ height: 30,
+ text: "",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SingleTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget(BI.extend({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items
+ }, o.trigger));
+
+ this.popup = BI.createWidget({
+ type: "bi.single_tree_popup",
+ items: o.items
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments);
+ });
+
+ this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE);
+ });
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+
+BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE";
+BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/**
+ * @class BI.SingleTreePopup
+ * @extends BI.Pane
+ */
+
+BI.SingleTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-tree-popup",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SingleTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: 'bi.level_tree',
+ expander: {
+ isDefaultInit: true
+ },
+ items: o.items,
+ chooseType: BI.Selection.Single
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.LevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SingleTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.SingleTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_tree_popup", BI.SingleTreePopup);/**
+ * @class BI.SingleTreeTrigger
+ * @extends BI.Trigger
+ */
+
+BI.SingleTreeTrigger = BI.inherit(BI.Trigger, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-tree-trigger",
+ height: 30,
+ text: "",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SingleTreeTrigger.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.select_text_trigger",
+ element: this,
+ text: o.text,
+ items: o.items,
+ height: o.height
+ });
+ },
+
+ _checkTitle: function () {
+ var self = this, val = this.getValue();
+ BI.any(this.options.items, function (i, item) {
+ if (val.contains(item.value)) {
+ self.trigger.setTitle(item.text || item.value);
+ return true;
+ }
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.options.value = v;
+ this.trigger.setValue(v);
+ this._checkTitle();
+ },
+
+ getValue: function () {
+ return this.options.value || [];
+ },
+
+ populate: function (items) {
+ BI.SingleTreeTrigger.superclass.populate.apply(this, arguments);
+ this.trigger.populate(items);
+ }
+
+});
+
+BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);/**
+ * 可以单选多选切换的树
+ *
+ * Created by GUY on 2015/12/21.
+ * @class BI.SwitchTree
+ * @extends BI.Widget
+ */
+BI.SwitchTree = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-switch-tree",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SwitchTree.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.tab = BI.createWidget({
+ type: "bi.tab",
+ element: this,
+ tab: null,
+ defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect,
+ cardCreator: BI.bind(this._createTree, this)
+ });
+ },
+
+ _createTree: function (type) {
+ var self = this, o = this.options;
+ switch (type) {
+ case BI.SwitchTree.SelectType.SingleSelect:
+ this.levelTree = BI.createWidget({
+ type: "bi.multilayer_single_level_tree",
+ isDefaultInit: true,
+ items: BI.deepClone(o.items)
+ });
+ this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments);
+ });
+ return this.levelTree;
+ case BI.SwitchTree.SelectType.MultiSelect:
+ this.tree = BI.createWidget({
+ type: "bi.simple_tree",
+ items: this._removeIsParent(BI.deepClone(o.items))
+ });
+ this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments);
+ });
+ return this.tree;
+ }
+ },
+
+ _removeIsParent: function(items) {
+ BI.each(items, function(i, item) {
+ BI.isNotNull(item.isParent) && delete item.isParent;
+ });
+ return items;
+ },
+
+ switchSelect: function () {
+ switch (this.getSelect()) {
+ case BI.SwitchTree.SelectType.SingleSelect:
+ this.setSelect(BI.SwitchTree.SelectType.MultiSelect);
+ break;
+ case BI.SwitchTree.SelectType.MultiSelect:
+ this.setSelect(BI.SwitchTree.SelectType.SingleSelect);
+ break;
+ }
+ },
+
+ setSelect: function (v) {
+ this.tab.setSelect(v);
+ },
+
+ getSelect: function () {
+ return this.tab.getSelect();
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ switch (this.getSelect()) {
+ case BI.SwitchTree.SelectType.SingleSelect:
+ this.levelTree.setValue(v);
+ break;
+ case BI.SwitchTree.SelectType.MultiSelect:
+ this.tree.setValue(v);
+ break;
+ }
+ },
+
+ getValue: function () {
+ return this.tab.getValue();
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ if (BI.isNotNull(this.levelTree)) {
+ this.levelTree.populate(BI.deepClone(items));
+ }
+ if (BI.isNotNull(this.tree)) {
+ this.tree.populate(this._removeIsParent(BI.deepClone(items)));
+ }
+ }
+});
+BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE";
+BI.SwitchTree.SelectType = {
+ SingleSelect: BI.Selection.Single,
+ MultiSelect: BI.Selection.Multi
+};
+BI.shortcut('bi.switch_tree', BI.SwitchTree);
+/**
+ * 年份下拉框
+ *
+ * Created by GUY on 2015/8/28.
+ * @class BI.YearCombo
+ * @extends BI.Widget
+ */
+BI.YearCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-combo",
+ behaviors: {},
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.YearCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = "";
+ this.trigger = BI.createWidget({
+ type: "bi.year_trigger",
+ min: o.min,
+ max: o.max
+ });
+ this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () {
+ self.storeValue = this.getKey();
+ });
+ this.trigger.on(BI.YearTrigger.EVENT_START, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.YearTrigger.EVENT_STOP, function () {
+ self.combo.showView();
+ });
+ this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.YearTrigger.EVENT_CONFIRM, function () {
+ if (self.combo.isViewVisible()) {
+ return;
+ }
+ if (this.getKey() && this.getKey() !== self.storeValue) {
+ self.setValue(this.getKey());
+ } else if (!this.getKey()) {
+ self.setValue();
+ }
+ self.fireEvent(BI.YearCombo.EVENT_CONFIRM);
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ destroyWhenHide: true,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ stopPropagation: false,
+ el: {
+ type: "bi.year_popup",
+ ref: function () {
+ self.popup = this;
+ },
+ listeners: [{
+ eventName: BI.YearPopup.EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.YearCombo.EVENT_CONFIRM);
+ }
+ }],
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max
+ }
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ var value = self.trigger.getKey();
+ if (BI.isNotNull(value)) {
+ self.popup.setValue(value);
+ } else if (!value && value !== self.storeValue) {
+ self.popup.setValue(self.storeValue);
+ } else {
+ self.setValue();
+ }
+ self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.year_combo', BI.YearCombo);/**
+ * 年份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.YearPopup
+ * @extends BI.Trigger
+ */
+BI.YearPopup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-popup",
+ behaviors: {},
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31' //最大日期
+ });
+ },
+
+ _createYearCalendar: function (v) {
+ var o = this.options, y = this._year;
+
+ var calendar = BI.createWidget({
+ type: "bi.year_calendar",
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max,
+ logic: {
+ dynamic: true
+ },
+ year: y + v * 12
+ });
+ calendar.setValue(this._year);
+ return calendar;
+ },
+
+ _init: function () {
+ BI.YearPopup.superclass._init.apply(this, arguments);
+ var self = this;
+
+ this.selectedYear = this._year = new Date().getFullYear();
+
+ var backBtn = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "pre-page-h-font",
+ width: 25,
+ height: 25,
+ value: -1
+ });
+
+ var preBtn = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "next-page-h-font",
+ width: 25,
+ height: 25,
+ value: 1
+ });
+
+ this.navigation = BI.createWidget({
+ type: "bi.navigation",
+ element: this,
+ single: true,
+ logic: {
+ dynamic: true
+ },
+ tab: {
+ cls: "year-popup-navigation bi-high-light bi-border-top",
+ height: 25,
+ items: [backBtn, preBtn]
+ },
+ cardCreator: BI.bind(this._createYearCalendar, this),
+
+ afterCardShow: function () {
+ this.setValue(self.selectedYear);
+ var calendar = this.getSelectedCard();
+ backBtn.setEnable(!calendar.isFrontYear());
+ preBtn.setEnable(!calendar.isFinalYear());
+ }
+ });
+
+ this.navigation.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedYear = this.getValue();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear);
+ });
+ },
+
+ getValue: function () {
+ return this.selectedYear;
+ },
+
+ setValue: function (v) {
+ var o = this.options;
+ if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) {
+ v = new Date().getFullYear();
+ this.selectedYear = "";
+ this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
+ this.navigation.setValue("");
+ } else {
+ this.selectedYear = v;
+ this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
+ this.navigation.setValue(v);
+ }
+ }
+});
+BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.year_popup", BI.YearPopup);/**
+ * 年份trigger
+ *
+ * Created by GUY on 2015/8/21.
+ * @class BI.YearTrigger
+ * @extends BI.Trigger
+ */
+BI.YearTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ triggerWidth: 25,
+ errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
+ errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text")
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-year-trigger bi-border",
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.YearTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid);
+ return v === "" || (BI.isPositiveInteger(v) && !Date.checkVoid(v, 1, 1, o.min, o.max)[0]);
+ },
+ quitChecker: function (v) {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ errorText: c.errorText
+ })
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.YearTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.YearTrigger.EVENT_STOP);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setValue(value);
+ self.editor.setTitle(value);
+ }
+ self.fireEvent(BI.YearTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.YearTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
+ self.fireEvent(BI.YearTrigger.EVENT_ERROR);
+ });
+ BI.createWidget({
+ element: this,
+ type: 'bi.htape',
+ items: [
+ {
+ el: this.editor
+ }, {
+ el: {
+ type: "bi.text_button",
+ baseCls: "bi-trigger-year-text",
+ text: BI.i18nText("BI-Multi_Date_Year"),
+ width: c.triggerWidth
+ },
+ width: c.triggerWidth
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: c.triggerWidth
+ },
+ width: c.triggerWidth
+ }
+ ]
+ });
+ },
+ setValue: function (v) {
+ this.editor.setState(v);
+ this.editor.setValue(v);
+ this.editor.setTitle(v);
+ },
+ getKey: function () {
+ return this.editor.getValue() | 0;
+ }
+});
+BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR";
+BI.YearTrigger.EVENT_START = "EVENT_START";
+BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.YearTrigger.EVENT_STOP = "EVENT_STOP";
+BI.shortcut("bi.year_trigger", BI.YearTrigger);/**
+ * 年份 + 月份下拉框
+ *
+ * @class BI.YearMonthCombo
+ * @extends BI.Widget
+ */
+BI.YearMonthCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-month-combo",
+ yearBehaviors: {},
+ monthBehaviors: {},
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.YearMonthCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.year = BI.createWidget({
+ type: "bi.year_combo",
+ behaviors: o.yearBehaviors
+ });
+
+ this.month = BI.createWidget({
+ type: "bi.month_combo",
+ behaviors: o.monthBehaviors
+ });
+
+ this.year.on(BI.YearCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
+ });
+ this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
+ });
+ this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ BI.createWidget({
+ type: "bi.center",
+ element: this,
+ hgap: 5,
+ items: [this.year, this.month]
+ });
+
+ },
+
+ setValue: function (v) {
+ v = v || {};
+ this.month.setValue(v.month);
+ this.year.setValue(v.year);
+ },
+
+ getValue: function () {
+ return {
+ year: this.year.getValue(),
+ month: this.month.getValue()
+ };
+ }
+});
+BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/**
+ * 年份 + 月份下拉框
+ *
+ * @class BI.YearQuarterCombo
+ * @extends BI.Widget
+ */
+BI.YearQuarterCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-quarter-combo",
+ yearBehaviors: {},
+ quarterBehaviors: {},
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.YearQuarterCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.year = BI.createWidget({
+ type: "bi.year_combo",
+ behaviors: o.yearBehaviors
+ });
+
+ this.quarter = BI.createWidget({
+ type: "bi.quarter_combo",
+ behaviors: o.quarterBehaviors
+ });
+
+ this.year.on(BI.YearCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM);
+ });
+ this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM);
+ });
+ this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ BI.createWidget({
+ type: "bi.center",
+ element: this,
+ hgap: 5,
+ items: [this.year, this.quarter]
+ });
+
+ },
+
+ setValue: function (v) {
+ v = v || {};
+ this.quarter.setValue(v.quarter);
+ this.year.setValue(v.year);
+ },
+
+ getValue: function () {
+ return {
+ year: this.year.getValue(),
+ quarter: this.quarter.getValue()
+ };
+ }
+});
+BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AbstractAllValueChooser
+ * @extends BI.Widget
+ */
+BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ perPage: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _valueFormatter: function (v) {
+ var text = v;
+ if (BI.isNotNull(this.items)) {
+ BI.some(this.items, function (i, item) {
+ if (item.value === v) {
+ text = item.text;
+ return true;
+ }
+ });
+ }
+ return text;
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this, o = this.options;
+ if (!o.cache || !this.items) {
+ o.itemsCreator({}, function (items) {
+ self.items = items;
+ call(items);
+ });
+ } else {
+ call(this.items);
+ }
+ function call(items) {
+ var keywords = (options.keywords || []).slice();
+ if (options.keyword) {
+ keywords.push(options.keyword);
+ }
+ BI.each(keywords, function (i, kw) {
+ var search = BI.Func.getSearchResult(items, kw);
+ items = search.matched.concat(search.finded);
+ });
+ if (options.selectedValues) {//过滤
+ var filter = BI.makeObject(options.selectedValues, true);
+ items = BI.filter(items, function (i, ob) {
+ return !filter[ob.value];
+ });
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ callback({
+ items: items
+ });
+ return;
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ callback({count: items.length});
+ return;
+ }
+ callback({
+ items: items,
+ hasNext: false
+ });
+ }
+ }
+});/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AllValueChooserCombo
+ * @extends BI.AbstractAllValueChooser
+ */
+BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-all-value-chooser-combo",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ }
+ this.combo = BI.createWidget({
+ type: 'bi.multi_select_combo',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue({
+ type: BI.Selection.Multi,
+ value: v || []
+ });
+ },
+
+ getValue: function () {
+ var val = this.combo.getValue() || {};
+ if (val.type === BI.Selection.All) {
+ return val.assist;
+ }
+ return val.value || [];
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this, arguments);
+ }
+});
+BI.AllValueChooserCombo.EVENT_CONFIRM = "AllValueChooserCombo.EVENT_CONFIRM";
+BI.shortcut('bi.all_value_chooser_combo', BI.AllValueChooserCombo);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AllValueChooserPane
+ * @extends BI.AbstractAllValueChooser
+ */
+BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-all-value-chooser-pane",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.AllValueChooserPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ }
+ this.list = BI.createWidget({
+ type: 'bi.multi_select_list',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (v) {
+ this.list.setValue({
+ type: BI.Selection.Multi,
+ value: v || []
+ });
+ },
+
+ getValue: function () {
+ var val = this.list.getValue() || {};
+ if (val.type === BI.Selection.All) {
+ return val.assist;
+ }
+ return val.value || [];
+ },
+
+ populate: function () {
+ this.list.populate.apply(this.list, arguments);
+ }
+});
+BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE";
+BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ perPage: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ items: null,
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _initData: function (items) {
+ this.items = items;
+ var nodes = BI.Tree.treeFormat(items);
+ this.tree = new BI.Tree();
+ this.tree.initTree(nodes);
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this, o = this.options;
+ if (!this.items) {
+ o.itemsCreator({}, function (items) {
+ self._initData(items);
+ call();
+ });
+ } else {
+ call();
+ }
+ function call() {
+ switch (options.type) {
+ case BI.TreeView.REQ_TYPE_INIT_DATA:
+ self._reqInitTreeNode(options, callback);
+ break;
+ case BI.TreeView.REQ_TYPE_ADJUST_DATA:
+ self._reqAdjustTreeNode(options, callback);
+ break;
+ case BI.TreeView.REQ_TYPE_SELECT_DATA:
+ self._reqSelectedTreeNode(options, callback);
+ break;
+ case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA:
+ self._reqDisplayTreeNode(options, callback);
+ break;
+ default :
+ self._reqTreeNode(options, callback);
+ break;
+ }
+ }
+ },
+
+ _reqDisplayTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var selectedValues = op.selectedValues;
+
+ if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ callback({});
+ return;
+ }
+
+ doCheck([], this.tree.getRoot(), selectedValues);
+
+ callback({
+ items: result
+ });
+
+ function doCheck(parentValues, node, selected) {
+ if (selected == null || BI.isEmpty(selected)) {
+ BI.each(node.getChildren(), function (i, child) {
+ var newParents = BI.clone(parentValues);
+ newParents.push(child.value);
+ var llen = self._getChildCount(newParents);
+ createOneJson(child, node.id, llen);
+ doCheck(newParents, child, {});
+ });
+ return;
+ }
+ BI.each(selected, function (k) {
+ var node = self._getTreeNode(parentValues, k);
+ var newParents = BI.clone(parentValues);
+ newParents.push(node.value);
+ createOneJson(node, node.parent && node.parent.id, getCount(selected[k], newParents));
+ doCheck(newParents, node, selected[k]);
+ })
+ }
+
+ function getCount(jo, parentValues) {
+ if (jo == null) {
+ return 0;
+ }
+ if (BI.isEmpty(jo)) {
+ return self._getChildCount(parentValues);
+ }
+
+ return BI.size(jo);
+ }
+
+ function createOneJson(node, pId, llen) {
+ result.push({
+ id: node.id,
+ pId: pId,
+ text: node.text + (llen > 0 ? ("(" + BI.i18nText("BI-Basic_Altogether") + llen + BI.i18nText("BI-Basic_Count") + ")") : ""),
+ value: node.value,
+ open: true
+ });
+ }
+ },
+
+ _reqSelectedTreeNode: function (op, callback) {
+ var self = this;
+ var selectedValues = BI.deepClone(op.selectedValues);
+ var notSelectedValue = op.notSelectedValue || {};
+ var keyword = op.keyword || "";
+ var parentValues = op.parentValues || [];
+
+ if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ callback({});
+ return;
+ }
+
+ dealWithSelectedValues(selectedValues);
+ callback(selectedValues);
+
+
+ function dealWithSelectedValues(selectedValues) {
+ var p = parentValues.concat(notSelectedValue);
+ //存储的值中存在这个值就把它删掉
+ //例如选中了中国-江苏-南京, 取消中国或江苏或南京
+ if (canFindKey(selectedValues, p)) {
+ //如果搜索的值在父亲链中
+ if (isSearchValueInParent(p)) {
+ //例如选中了 中国-江苏, 搜索江苏, 取消江苏
+ //例如选中了 中国-江苏, 搜索江苏, 取消中国
+ self._deleteNode(selectedValues, p);
+ } else {
+ var searched = [];
+ var finded = search(parentValues, notSelectedValue, [], searched);
+ if (finded && BI.isNotEmptyArray(searched)) {
+ BI.each(searched, function (i, arr) {
+ var node = self._getNode(selectedValues, arr);
+ if (node) {
+ //例如选中了 中国-江苏-南京,搜索南京,取消中国
+ self._deleteNode(selectedValues, arr);
+ } else {
+ //例如选中了 中国-江苏,搜索南京,取消中国
+ expandSelectedValue(selectedValues, arr, BI.last(arr));
+ }
+ })
+ }
+ }
+ }
+
+ //存储的值中不存在这个值,但父亲节点是全选的情况
+ //例如选中了中国-江苏,取消南京
+ //important 选中了中国-江苏,取消了江苏,但是搜索的是南京
+ if (isChild(selectedValues, p)) {
+ var result = [], finded = false;
+ //如果parentValues中有匹配的值,说明搜索结果不在当前值下
+ if (isSearchValueInParent(p)) {
+ finded = true;
+ } else {
+ //从当前值开始搜
+ finded = search(parentValues, notSelectedValue, result);
+ p = parentValues;
+ }
+
+ if (finded === true) {
+ //去掉点击的节点之后的结果集
+ expandSelectedValue(selectedValues, p, notSelectedValue);
+ //添加去掉搜索的结果集
+ if (result.length > 0) {
+ BI.each(result, function (i, strs) {
+ self._buildTree(selectedValues, strs);
+ })
+ }
+ }
+ }
+
+ }
+
+ function expandSelectedValue(selectedValues, parents, notSelectedValue) {
+ var next = selectedValues;
+ var childrenCount = [];
+ var path = [];
+ //去掉点击的节点之后的结果集
+ BI.some(parents, function (i, v) {
+ var t = next[v];
+ if (t == null) {
+ if (i === 0) {
+ return true;
+ }
+ if (BI.isEmpty(next)) {
+ var split = parents.slice(0, i);
+ var expanded = self._getChildren(split);
+ path.push(split);
+ childrenCount.push(expanded.length);
+ //如果只有一个值且取消的就是这个值
+ if (i === parents.length - 1 && expanded.length === 1 && expanded[0] === notSelectedValue) {
+ for (var j = childrenCount.length - 1; j >= 0; j--) {
+ if (childrenCount[j] === 1) {
+ self._deleteNode(selectedValues, path[j]);
+ } else {
+ break;
+ }
+ }
+ } else {
+ BI.each(expanded, function (m, child) {
+ if (i === parents.length - 1 && child.value === notSelectedValue) {
+ return true;
+ }
+ next[child.value] = {};
+ });
+ }
+ next = next[v];
+ } else {
+ return true;
+ // next = {};
+ // next[v] = {};
+ }
+ } else {
+ next = t;
+ }
+ });
+ }
+
+ function search(parents, current, result, searched) {
+ var newParents = BI.clone(parents);
+ newParents.push(current);
+ if (self._isMatch(current, keyword)) {
+ searched && searched.push(newParents);
+ return true;
+ }
+
+ var children = self._getChildren(newParents);
+
+ var notSearch = [];
+ var can = false;
+
+ BI.each(children, function (i, child) {
+ if (search(newParents, child.value, result, searched)) {
+ can = true;
+ } else {
+ notSearch.push(child.value);
+ }
+ });
+ if (can === true) {
+ BI.each(notSearch, function (i, v) {
+ var next = BI.clone(newParents);
+ next.push(v);
+ result.push(next);
+ });
+ }
+ return can;
+ }
+
+ function isSearchValueInParent(parentValues) {
+ for (var i = 0, len = parentValues.length; i < len; i++) {
+ if (self._isMatch(parentValues[i], keyword)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function canFindKey(selectedValues, parents) {
+ var t = selectedValues;
+ for (var i = 0; i < parents.length; i++) {
+ var v = parents[i];
+ t = t[v];
+ if (t == null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ function isChild(selectedValues, parents) {
+ var t = selectedValues;
+ for (var i = 0; i < parents.length; i++) {
+ var v = parents[i];
+ if (!BI.has(t, v)) {
+ return false;
+ }
+ t = t[v];
+ if (BI.isEmpty(t)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ },
+
+ _reqAdjustTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var selectedValues = op.selectedValues;
+ if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ callback({});
+ return;
+ }
+ BI.each(selectedValues, function (k, v) {
+ result.push([k]);
+ });
+
+ dealWithSelectedValues(selectedValues, []);
+
+ var jo = {};
+ BI.each(result, function (i, strs) {
+ self._buildTree(jo, strs);
+ });
+ callback(jo);
+
+ function dealWithSelectedValues(selected, parents) {
+ if (selected == null || BI.isEmpty(selected)) {
+ return true;
+ }
+ var can = true;
+ BI.each(selected, function (k, v) {
+ var p = BI.clone(parents);
+ p.push(k);
+ if (!dealWithSelectedValues(selected[k], p)) {
+ BI.each(selected[k], function (nk, nv) {
+ var t = BI.clone(p);
+ t.push(nk);
+ result.push(t);
+ });
+ can = false;
+ }
+ });
+ return can && isAllSelected(selected, parents);
+ }
+
+ function isAllSelected(selected, parents) {
+ return BI.isEmpty(selected) || self._getChildCount(parents) === BI.size(selected);
+ }
+ },
+
+ _reqInitTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var keyword = op.keyword || "";
+ var selectedValues = op.selectedValues;
+ var lastSearchValue = op.lastSearchValue || "";
+ var output = search();
+ BI.nextTick(function () {
+ callback({
+ hasNext: output.length > self._const.perPage,
+ items: result,
+ lastSearchValue: BI.last(output)
+ })
+ });
+
+ function search() {
+ var children = self._getChildren([]);
+ var start = children.length;
+ if (lastSearchValue !== "") {
+ for (var j = 0, len = start; j < len; j++) {
+ if (children[j].value === lastSearchValue) {
+ start = j + 1;
+ break;
+ }
+ }
+ } else {
+ start = 0;
+ }
+ var output = [];
+ for (var i = start, len = children.length; i < len; i++) {
+ if (output.length < self._const.perPage) {
+ var find = nodeSearch(1, [], children[i].value, false, result);
+ } else if (output.length === self._const.perPage) {
+ var find = nodeSearch(1, [], children[i].value, false, []);
+ }
+ if (find[0] === true) {
+ output.push(children[i].value);
+ }
+ if (output.length > self._const.perPage) {
+ break;
+ }
+ }
+ return output;
+ }
+
+ function nodeSearch(deep, parentValues, current, isAllSelect, result) {
+ if (self._isMatch(current, keyword)) {
+ var checked = isAllSelect || isSelected(parentValues, current);
+ createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
+ return [true, checked];
+ }
+ var newParents = BI.clone(parentValues);
+ newParents.push(current);
+ var children = self._getChildren(newParents);
+
+ var can = false, checked = false;
+
+ var isCurAllSelected = isAllSelect || isAllSelected(parentValues, current);
+ BI.each(children, function (i, child) {
+ var state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result);
+ if (state[1] === true) {
+ checked = true;
+ }
+ if (state[0] === true) {
+ can = true;
+ }
+ });
+ if (can === true) {
+ checked = isCurAllSelected || (isSelected(parentValues, current) && checked);
+ createOneJson(parentValues, current, true, checked, false, false, result);
+ }
+ return [can, checked];
+ }
+
+ function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
+ var node = self._getTreeNode(parentValues, value)
+ result.push({
+ id: node.id,
+ pId: node.pId,
+ text: node.text,
+ value: node.value,
+ title: node.title,
+ isParent: node.getChildrenLength() > 0,
+ open: isOpen,
+ checked: checked,
+ halfCheck: half,
+ flag: flag
+ });
+ }
+
+ function isHalf(parentValues, value) {
+ var find = findSelectedObj(parentValues);
+ if (find == null) {
+ return null;
+ }
+ return BI.any(find, function (v, ob) {
+ if (v === value) {
+ if (ob != null && !BI.isEmpty(ob)) {
+ return true;
+ }
+ }
+ });
+ }
+
+ function isAllSelected(parentValues, value) {
+ var find = findSelectedObj(parentValues);
+ if (find == null) {
+ return null;
+ }
+ return BI.any(find, function (v, ob) {
+ if (v === value) {
+ if (ob != null && BI.isEmpty(ob)) {
+ return true;
+ }
+ }
+ });
+ }
+
+ function isSelected(parentValues, value) {
+ var find = findSelectedObj(parentValues);
+ if (find == null) {
+ return false;
+ }
+ return BI.any(find, function (v) {
+ if (v === value) {
+ return true;
+ }
+ });
+ }
+
+ function findSelectedObj(parentValues) {
+ var find = selectedValues;
+ if (find == null) {
+ return null;
+ }
+ BI.every(parentValues, function (i, v) {
+ find = find[v];
+ if (find == null) {
+ return false;
+ }
+ return true;
+ });
+ return find;
+ }
+ },
+
+ _reqTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var times = op.times;
+ var checkState = op.checkState || {};
+ var parentValues = op.parentValues || [];
+ var selectedValues = op.selectedValues || {};
+ var valueMap = {};
+ // if (judgeState(parentValues, selectedValues, checkState)) {
+ valueMap = dealWidthSelectedValue(parentValues, selectedValues);
+ // }
+ var nodes = this._getChildren(parentValues);
+ for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) {
+ var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState);
+ result.push({
+ id: nodes[i].id,
+ pId: nodes[i].pId,
+ value: nodes[i].value,
+ text: nodes[i].text,
+ times: 1,
+ isParent: nodes[i].getChildrenLength() > 0,
+ checked: state[0],
+ halfCheck: state[1]
+ })
+ }
+ BI.nextTick(function () {
+ callback({
+ items: result,
+ hasNext: nodes.length > times * self._const.perPage
+ });
+ });
+
+ function judgeState(parentValues, selected_value, checkState) {
+ var checked = checkState.checked, half = checkState.half;
+ if (parentValues.length > 0 && !checked) {
+ return false;
+ }
+ return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value));
+ }
+
+ function dealWidthSelectedValue(parentValues, selectedValues) {
+ var valueMap = {};
+ BI.each(parentValues, function (i, v) {
+ selectedValues = selectedValues[v] || {};
+ });
+ BI.each(selectedValues, function (value, obj) {
+ if (BI.isNull(obj)) {
+ valueMap[value] = [0, 0];
+ return;
+ }
+ if (BI.isEmpty(obj)) {
+ valueMap[value] = [2, 0];
+ return;
+ }
+ var nextNames = {};
+ BI.each(obj, function (t, o) {
+ if (BI.isNull(o) || BI.isEmpty(o)) {
+ nextNames[t] = true;
+ }
+ });
+ valueMap[value] = [1, BI.size(nextNames)];
+ });
+ return valueMap;
+ }
+
+ function getCheckState(current, parentValues, valueMap, checkState) {
+ var checked = checkState.checked, half = checkState.half;
+ var tempCheck = false, halfCheck = false;
+ if (BI.has(valueMap, current)) {
+ //可能是半选
+ if (valueMap[current][0] === 1) {
+ var values = BI.clone(parentValues);
+ values.push(current);
+ var childCount = self._getChildCount(values);
+ if (childCount > 0 && childCount !== valueMap[current][1]) {
+ halfCheck = true;
+ }
+ } else if (valueMap[current][0] === 2) {
+ tempCheck = true;
+ }
+ }
+ var check;
+ if (!checked && !halfCheck && !tempCheck) {
+ check = BI.has(valueMap, current);
+ } else {
+ check = ((tempCheck || checked) && !half) || BI.has(valueMap, current);
+ }
+ return [check, halfCheck];
+ }
+ },
+
+ _getNode: function (selectedValues, parentValues) {
+ var pNode = selectedValues;
+ for (var i = 0, len = parentValues.length; i < len; i++) {
+ if (pNode == null) {
+ return null;
+ }
+ pNode = pNode[parentValues[i]];
+ }
+ return pNode;
+ },
+
+ _deleteNode: function (selectedValues, values) {
+ var name = values[values.length - 1];
+ var p = values.slice(0, values.length - 1);
+ var pNode = this._getNode(selectedValues, p);
+ if (pNode != null && pNode[name]) {
+ delete pNode[name];
+ //递归删掉空父节点
+ while (p.length > 0 && BI.isEmpty(pNode)) {
+ name = p[p.length - 1];
+ p = p.slice(0, p.length - 1);
+ pNode = this._getNode(selectedValues, p);
+ if (pNode != null) {
+ delete pNode[name];
+ }
+ }
+ }
+ },
+
+ _buildTree: function (jo, values) {
+ var t = jo;
+ BI.each(values, function (i, v) {
+ if (!BI.has(t, v)) {
+ t[v] = {};
+ }
+ t = t[v];
+ });
+ },
+
+ _isMatch: function (value, keyword) {
+ var finded = BI.Func.getSearchResult([value], keyword);
+ return finded.finded.length > 0 || finded.matched.length > 0;
+ },
+
+ _getTreeNode: function (parentValues, v) {
+ var self = this;
+ var findedParentNode;
+ var index = 0;
+ this.tree.traverse(function (node) {
+ if (self.tree.isRoot(node)) {
+ return;
+ }
+ if (index > parentValues.length) {
+ return false;
+ }
+ if (index === parentValues.length && node.value === v) {
+ findedParentNode = node;
+ return false;
+ }
+ if (node.value === parentValues[index]) {
+ index++;
+ return;
+ }
+ return true;
+ });
+ return findedParentNode;
+ },
+
+ _getChildren: function (parentValues) {
+ if (parentValues.length > 0) {
+ var value = BI.last(parentValues);
+ var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value);
+ } else {
+ var parent = this.tree.getRoot();
+ }
+ return parent.getChildren();
+ },
+
+ _getChildCount: function (parentValues) {
+ return this._getChildren(parentValues).length;
+ }
+});/**
+ * 简单的复选下拉树控件, 适用于数据量少的情况
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.TreeValueChooserCombo
+ * @extends BI.Widget
+ */
+BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-tree-value-chooser-combo",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.TreeValueChooserCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this._initData(o.items);
+ }
+ this.combo = BI.createWidget({
+ type: 'bi.multi_tree_combo',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ },
+
+ getValue: function () {
+ return this.combo.getValue();
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+BI.TreeValueChooserCombo.EVENT_CONFIRM = "TreeValueChooserCombo.EVENT_CONFIRM";
+BI.shortcut('bi.tree_value_chooser_combo', BI.TreeValueChooserCombo);/**
+ * 简单的复选下拉树控件, 适用于数据量少的情况
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.TreeValueChooserPane
+ * @extends BI.AbstractTreeValueChooser
+ */
+BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-tree-value-chooser-pane",
+ items: null,
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.TreeValueChooserPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.pane = BI.createWidget({
+ type: 'bi.multi_select_tree',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this)
+ });
+
+ this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE);
+ });
+ if (BI.isNotNull(o.items)) {
+ this._initData(o.items);
+ this.populate();
+ }
+ },
+
+ setSelectedValue: function (v) {
+ this.pane.setSelectedValue(v);
+ },
+
+ setValue: function (v) {
+ this.pane.setValue(v);
+ },
+
+ getValue: function () {
+ return this.pane.getValue();
+ },
+
+ populate: function () {
+ this.pane.populate.apply(this.pane, arguments);
+ }
+});
+BI.TreeValueChooserPane.EVENT_CHANGE = "TreeValueChooserPane.EVENT_CHANGE";
+BI.shortcut('bi.tree_value_chooser_pane', BI.TreeValueChooserPane);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AbstractValueChooser
+ * @extends BI.Widget
+ */
+BI.AbstractValueChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ perPage: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _valueFormatter: function (v) {
+ var text = v;
+ if (BI.isNotNull(this.items)) {
+ BI.some(this.items, function (i, item) {
+ if (item.value === v) {
+ text = item.text;
+ return true;
+ }
+ });
+ }
+ return text;
+ },
+
+ _getItemsByTimes: function (items, times) {
+ var res = [];
+ for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
+ res.push(items[i]);
+ }
+ return res;
+ },
+
+ _hasNextByTimes: function (items, times) {
+ return times * this._const.perPage < items.length;
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this, o = this.options;
+ if (!o.cache || !this.items) {
+ o.itemsCreator({}, function (items) {
+ self.items = items;
+ call(items);
+ });
+ } else {
+ call(this.items);
+ }
+ function call(items) {
+ var keywords = (options.keywords || []).slice();
+ if (options.keyword) {
+ keywords.push(options.keyword);
+ }
+ BI.each(keywords, function (i, kw) {
+ var search = BI.Func.getSearchResult(items, kw);
+ items = search.matched.concat(search.finded);
+ });
+ if (options.selectedValues) {//过滤
+ var filter = BI.makeObject(options.selectedValues, true);
+ items = BI.filter(items, function (i, ob) {
+ return !filter[ob.value];
+ });
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ callback({
+ items: items
+ });
+ return;
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ callback({count: items.length});
+ return;
+ }
+ callback({
+ items: self._getItemsByTimes(items, options.times),
+ hasNext: self._hasNextByTimes(items, options.times)
+ });
+ }
+ }
+});/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.ValueChooserCombo
+ * @extends BI.Widget
+ */
+BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-value-chooser-combo",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.ValueChooserCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ }
+ this.combo = BI.createWidget({
+ type: 'bi.multi_select_combo',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ },
+
+ getValue: function () {
+ var val = this.combo.getValue() || {};
+ return {
+ type: val.type,
+ value: val.value
+ }
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this, arguments);
+ }
+});
+BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM";
+BI.shortcut('bi.value_chooser_combo', BI.ValueChooserCombo);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.ValueChooserPane
+ * @extends BI.Widget
+ */
+BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-value-chooser-pane",
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.ValueChooserPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.list = BI.createWidget({
+ type: 'bi.multi_select_list',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this)
+ });
+
+ this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE);
+ });
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ this.populate();
+ }
+ },
+
+ setValue: function (v) {
+ this.list.setValue(v);
+ },
+
+ getValue: function () {
+ var val = this.list.getValue() || {};
+ return {
+ type: val.type,
+ value: val.value
+ }
+ },
+
+ populate: function () {
+ this.list.populate.apply(this.list, arguments);
+ }
+});
+BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.value_chooser_pane', BI.ValueChooserPane);
\ No newline at end of file
diff --git a/demo/config.js b/demo/config.js
index e1c8645ca..daa3bf380 100644
--- a/demo/config.js
+++ b/demo/config.js
@@ -8,6 +8,21 @@ Demo.CONSTANTS = {
title: v
}
}),
- TREEITEMS: [{"pId":"0","id":"0_0","text":"( 共25个 )","value":"","open":true},{"pId":"0_0","id":"0_0_0","text":"安徽省( 共1个 )","value":"安徽省","open":true},{"pId":"0_0_0","id":"0_0_0_0","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_0","id":"0_0_1","text":"北京市( 共6个 )","value":"北京市","open":true},{"pId":"0_0_1","id":"0_0_1_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_0_1","id":"0_0_1_1","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_0_1","id":"0_0_1_2","text":"东城区","value":"东城区","open":true},{"pId":"0_0_1","id":"0_0_1_3","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_0_1","id":"0_0_1_4","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_0_1","id":"0_0_1_5","text":"石景山区","value":"石景山区","open":true},{"pId":"0_0","id":"0_0_2","text":"福建省( 共2个 )","value":"福建省","open":true},{"pId":"0_0_2","id":"0_0_2_0","text":"莆田市","value":"莆田市","open":true},{"pId":"0_0_2","id":"0_0_2_1","text":"泉州市","value":"泉州市","open":true},{"pId":"0_0","id":"0_0_3","text":"甘肃省( 共1个 )","value":"甘肃省","open":true},{"pId":"0_0_3","id":"0_0_3_0","text":"兰州市","value":"兰州市","open":true},{"pId":"0_0","id":"0_0_4","text":"广东省( 共5个 )","value":"广东省","open":true},{"pId":"0_0_4","id":"0_0_4_0","text":"东莞市","value":"东莞市","open":true},{"pId":"0_0_4","id":"0_0_4_1","text":"广州市","value":"广州市","open":true},{"pId":"0_0_4","id":"0_0_4_2","text":"惠州市","value":"惠州市","open":true},{"pId":"0_0_4","id":"0_0_4_3","text":"深圳市","value":"深圳市","open":true},{"pId":"0_0_4","id":"0_0_4_4","text":"珠海市","value":"珠海市","open":true},{"pId":"0_0","id":"0_0_5","text":"广西壮族自治区( 共1个 )","value":"广西壮族自治区","open":true},{"pId":"0_0_5","id":"0_0_5_0","text":"南宁市","value":"南宁市","open":true},{"pId":"0_0","id":"0_0_6","text":"河北省( 共2个 )","value":"河北省","open":true},{"pId":"0_0_6","id":"0_0_6_0","text":"保定市","value":"保定市","open":true},{"pId":"0_0_6","id":"0_0_6_1","text":"邢台市","value":"邢台市","open":true},{"pId":"0_0","id":"0_0_7","text":"河南省( 共1个 )","value":"河南省","open":true},{"pId":"0_0_7","id":"0_0_7_0","text":"郑州市","value":"郑州市","open":true},{"pId":"0_0","id":"0_0_8","text":"黑龙江省( 共7个 )","value":"黑龙江省","open":true},{"pId":"0_0_8","id":"0_0_8_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_0_8","id":"0_0_8_1","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_0_8","id":"0_0_8_2","text":"鸡西市","value":"鸡西市","open":true},{"pId":"0_0_8","id":"0_0_8_3","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_0_8","id":"0_0_8_4","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_0_8","id":"0_0_8_5","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_0_8","id":"0_0_8_6","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_0","id":"0_0_9","text":"湖北省( 共1个 )","value":"湖北省","open":true},{"pId":"0_0_9","id":"0_0_9_0","text":"武汉市","value":"武汉市","open":true},{"pId":"0_0","id":"0_0_10","text":"湖南省( 共3个 )","value":"湖南省","open":true},{"pId":"0_0_10","id":"0_0_10_0","text":"常德市","value":"常德市","open":true},{"pId":"0_0_10","id":"0_0_10_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_0_10","id":"0_0_10_2","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_0","id":"0_0_11","text":"吉林省( 共4个 )","value":"吉林省","open":true},{"pId":"0_0_11","id":"0_0_11_0","text":"白山市","value":"白山市","open":true},{"pId":"0_0_11","id":"0_0_11_1","text":"长春市","value":"长春市","open":true},{"pId":"0_0_11","id":"0_0_11_2","text":"松原市","value":"松原市","open":true},{"pId":"0_0_11","id":"0_0_11_3","text":"通化市","value":"通化市","open":true},{"pId":"0_0","id":"0_0_12","text":"江苏省( 共8个 )","value":"江苏省","open":true},{"pId":"0_0_12","id":"0_0_12_0","text":"常州市","value":"常州市","open":true},{"pId":"0_0_12","id":"0_0_12_1","text":"南京市","value":"南京市","open":true},{"pId":"0_0_12","id":"0_0_12_2","text":"南通市","value":"南通市","open":true},{"pId":"0_0_12","id":"0_0_12_3","text":"苏州市","value":"苏州市","open":true},{"pId":"0_0_12","id":"0_0_12_4","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_0_12","id":"0_0_12_5","text":"泰州市","value":"泰州市","open":true},{"pId":"0_0_12","id":"0_0_12_6","text":"无锡市","value":"无锡市","open":true},{"pId":"0_0_12","id":"0_0_12_7","text":"盐城市","value":"盐城市","open":true},{"pId":"0_0","id":"0_0_13","text":"辽宁省( 共11个 )","value":"辽宁省","open":true},{"pId":"0_0_13","id":"0_0_13_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_0_13","id":"0_0_13_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_0_13","id":"0_0_13_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_0_13","id":"0_0_13_3","text":"大连市","value":"大连市","open":true},{"pId":"0_0_13","id":"0_0_13_4","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_0_13","id":"0_0_13_5","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_0_13","id":"0_0_13_6","text":"锦州市","value":"锦州市","open":true},{"pId":"0_0_13","id":"0_0_13_7","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_0_13","id":"0_0_13_8","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_0_13","id":"0_0_13_9","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_0_13","id":"0_0_13_10","text":"营口市","value":"营口市","open":true},{"pId":"0_0","id":"0_0_14","text":"内蒙古( 共1个 )","value":"内蒙古","open":true},{"pId":"0_0_14","id":"0_0_14_0","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_0","id":"0_0_15","text":"宁夏回族自治区( 共1个 )","value":"宁夏回族自治区","open":true},{"pId":"0_0_15","id":"0_0_15_0","text":"银川市","value":"银川市","open":true},{"pId":"0_0","id":"0_0_16","text":"山东省( 共7个 )","value":"山东省","open":true},{"pId":"0_0_16","id":"0_0_16_0","text":"济南市","value":"济南市","open":true},{"pId":"0_0_16","id":"0_0_16_1","text":"济宁市","value":"济宁市","open":true},{"pId":"0_0_16","id":"0_0_16_2","text":"聊城市","value":"聊城市","open":true},{"pId":"0_0_16","id":"0_0_16_3","text":"临沂市","value":"临沂市","open":true},{"pId":"0_0_16","id":"0_0_16_4","text":"青岛市","value":"青岛市","open":true},{"pId":"0_0_16","id":"0_0_16_5","text":"烟台市","value":"烟台市","open":true},{"pId":"0_0_16","id":"0_0_16_6","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_0","id":"0_0_17","text":"山西省( 共1个 )","value":"山西省","open":true},{"pId":"0_0_17","id":"0_0_17_0","text":"太原市","value":"太原市","open":true},{"pId":"0_0","id":"0_0_18","text":"陕西省( 共1个 )","value":"陕西省","open":true},{"pId":"0_0_18","id":"0_0_18_0","text":"西安市","value":"西安市","open":true},{"pId":"0_0","id":"0_0_19","text":"上海市( 共1个 )","value":"上海市","open":true},{"pId":"0_0_19","id":"0_0_19_0","text":"上海市区","value":"上海市区","open":true},{"pId":"0_0","id":"0_0_20","text":"四川省( 共1个 )","value":"四川省","open":true},{"pId":"0_0_20","id":"0_0_20_0","text":"成都市","value":"成都市","open":true},{"pId":"0_0","id":"0_0_21","text":"新疆维吾尔族自治区( 共2个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_0_21","id":"0_0_21_0","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_0_21","id":"0_0_21_1","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_0","id":"0_0_22","text":"云南省( 共1个 )","value":"云南省","open":true},{"pId":"0_0_22","id":"0_0_22_0","text":"昆明市","value":"昆明市","open":true},{"pId":"0_0","id":"0_0_23","text":"浙江省( 共5个 )","value":"浙江省","open":true},{"pId":"0_0_23","id":"0_0_23_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_0_23","id":"0_0_23_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_0_23","id":"0_0_23_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_0_23","id":"0_0_23_3","text":"宁波市","value":"宁波市","open":true},{"pId":"0_0_23","id":"0_0_23_4","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_0","id":"0_0_24","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_0_24","id":"0_0_24_0","text":"重庆市区","value":"重庆市区","open":true},{"pId":"0","id":"0_1","text":"中国( 共34个 )","value":"中国","open":true},{"pId":"0_1","id":"0_1_0","text":"安徽省( 共19个 )","value":"安徽省","open":true},{"pId":"0_1_0","id":"0_1_0_0","text":"安庆市","value":"安庆市","open":true},{"pId":"0_1_0","id":"0_1_0_1","text":"蚌埠市","value":"蚌埠市","open":true},{"pId":"0_1_0","id":"0_1_0_2","text":"亳州市","value":"亳州市","open":true},{"pId":"0_1_0","id":"0_1_0_3","text":"巢湖市","value":"巢湖市","open":true},{"pId":"0_1_0","id":"0_1_0_4","text":"池州市","value":"池州市","open":true},{"pId":"0_1_0","id":"0_1_0_5","text":"滁州市","value":"滁州市","open":true},{"pId":"0_1_0","id":"0_1_0_6","text":"阜阳市","value":"阜阳市","open":true},{"pId":"0_1_0","id":"0_1_0_7","text":"毫州市","value":"毫州市","open":true},{"pId":"0_1_0","id":"0_1_0_8","text":"合肥市","value":"合肥市","open":true},{"pId":"0_1_0","id":"0_1_0_9","text":"淮北市","value":"淮北市","open":true},{"pId":"0_1_0","id":"0_1_0_10","text":"淮南市","value":"淮南市","open":true},{"pId":"0_1_0","id":"0_1_0_11","text":"黄山市","value":"黄山市","open":true},{"pId":"0_1_0","id":"0_1_0_12","text":"六安市","value":"六安市","open":true},{"pId":"0_1_0","id":"0_1_0_13","text":"马鞍山市","value":"马鞍山市","open":true},{"pId":"0_1_0","id":"0_1_0_14","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_0","id":"0_1_0_15","text":"宿州市","value":"宿州市","open":true},{"pId":"0_1_0","id":"0_1_0_16","text":"铜陵市","value":"铜陵市","open":true},{"pId":"0_1_0","id":"0_1_0_17","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_1_0","id":"0_1_0_18","text":"宣城市","value":"宣城市","open":true},{"pId":"0_1","id":"0_1_1","text":"澳门特别行政区( 共1个 )","value":"澳门特别行政区","open":true},{"pId":"0_1_1","id":"0_1_1_0","text":"澳门","value":"澳门","open":true},{"pId":"0_1","id":"0_1_2","text":"北京市( 共17个 )","value":"北京市","open":true},{"pId":"0_1_2","id":"0_1_2_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_1_2","id":"0_1_2_1","text":"昌平区","value":"昌平区","open":true},{"pId":"0_1_2","id":"0_1_2_2","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_1_2","id":"0_1_2_3","text":"大兴区","value":"大兴区","open":true},{"pId":"0_1_2","id":"0_1_2_4","text":"东城区","value":"东城区","open":true},{"pId":"0_1_2","id":"0_1_2_5","text":"房山区","value":"房山区","open":true},{"pId":"0_1_2","id":"0_1_2_6","text":"丰台区","value":"丰台区","open":true},{"pId":"0_1_2","id":"0_1_2_7","text":"海淀区","value":"海淀区","open":true},{"pId":"0_1_2","id":"0_1_2_8","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_1_2","id":"0_1_2_9","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_1_2","id":"0_1_2_10","text":"门头沟区","value":"门头沟区","open":true},{"pId":"0_1_2","id":"0_1_2_11","text":"平谷区","value":"平谷区","open":true},{"pId":"0_1_2","id":"0_1_2_12","text":"石景山区","value":"石景山区","open":true},{"pId":"0_1_2","id":"0_1_2_13","text":"顺义区","value":"顺义区","open":true},{"pId":"0_1_2","id":"0_1_2_14","text":"通州区","value":"通州区","open":true},{"pId":"0_1_2","id":"0_1_2_15","text":"西城区","value":"西城区","open":true},{"pId":"0_1_2","id":"0_1_2_16","text":"西城区 ","value":"西城区 ","open":true},{"pId":"0_1","id":"0_1_3","text":"福建省( 共9个 )","value":"福建省","open":true},{"pId":"0_1_3","id":"0_1_3_0","text":"福州市","value":"福州市","open":true},{"pId":"0_1_3","id":"0_1_3_1","text":"龙岩市","value":"龙岩市","open":true},{"pId":"0_1_3","id":"0_1_3_2","text":"南平市","value":"南平市","open":true},{"pId":"0_1_3","id":"0_1_3_3","text":"宁德市","value":"宁德市","open":true},{"pId":"0_1_3","id":"0_1_3_4","text":"莆田市","value":"莆田市","open":true},{"pId":"0_1_3","id":"0_1_3_5","text":"泉州市","value":"泉州市","open":true},{"pId":"0_1_3","id":"0_1_3_6","text":"三明市","value":"三明市","open":true},{"pId":"0_1_3","id":"0_1_3_7","text":"厦门市","value":"厦门市","open":true},{"pId":"0_1_3","id":"0_1_3_8","text":"漳州市","value":"漳州市","open":true},{"pId":"0_1","id":"0_1_4","text":"甘肃省( 共12个 )","value":"甘肃省","open":true},{"pId":"0_1_4","id":"0_1_4_0","text":"白银市","value":"白银市","open":true},{"pId":"0_1_4","id":"0_1_4_1","text":"嘉峪关市","value":"嘉峪关市","open":true},{"pId":"0_1_4","id":"0_1_4_2","text":"金昌市","value":"金昌市","open":true},{"pId":"0_1_4","id":"0_1_4_3","text":"酒泉市","value":"酒泉市","open":true},{"pId":"0_1_4","id":"0_1_4_4","text":"兰州市","value":"兰州市","open":true},{"pId":"0_1_4","id":"0_1_4_5","text":"陇南市","value":"陇南市","open":true},{"pId":"0_1_4","id":"0_1_4_6","text":"平凉市","value":"平凉市","open":true},{"pId":"0_1_4","id":"0_1_4_7","text":"庆阳市","value":"庆阳市","open":true},{"pId":"0_1_4","id":"0_1_4_8","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_4","id":"0_1_4_9","text":"天水市","value":"天水市","open":true},{"pId":"0_1_4","id":"0_1_4_10","text":"武威市","value":"武威市","open":true},{"pId":"0_1_4","id":"0_1_4_11","text":"张掖市","value":"张掖市","open":true},{"pId":"0_1","id":"0_1_5","text":"广东省( 共21个 )","value":"广东省","open":true},{"pId":"0_1_5","id":"0_1_5_0","text":"潮州市","value":"潮州市","open":true},{"pId":"0_1_5","id":"0_1_5_1","text":"东莞市","value":"东莞市","open":true},{"pId":"0_1_5","id":"0_1_5_2","text":"佛山市","value":"佛山市","open":true},{"pId":"0_1_5","id":"0_1_5_3","text":"广州市","value":"广州市","open":true},{"pId":"0_1_5","id":"0_1_5_4","text":"河源市","value":"河源市","open":true},{"pId":"0_1_5","id":"0_1_5_5","text":"惠州市","value":"惠州市","open":true},{"pId":"0_1_5","id":"0_1_5_6","text":"江门市","value":"江门市","open":true},{"pId":"0_1_5","id":"0_1_5_7","text":"揭阳市","value":"揭阳市","open":true},{"pId":"0_1_5","id":"0_1_5_8","text":"茂名市","value":"茂名市","open":true},{"pId":"0_1_5","id":"0_1_5_9","text":"梅州市","value":"梅州市","open":true},{"pId":"0_1_5","id":"0_1_5_10","text":"清远市","value":"清远市","open":true},{"pId":"0_1_5","id":"0_1_5_11","text":"汕头市","value":"汕头市","open":true},{"pId":"0_1_5","id":"0_1_5_12","text":"汕尾市","value":"汕尾市","open":true},{"pId":"0_1_5","id":"0_1_5_13","text":"韶关市","value":"韶关市","open":true},{"pId":"0_1_5","id":"0_1_5_14","text":"深圳市","value":"深圳市","open":true},{"pId":"0_1_5","id":"0_1_5_15","text":"阳江市","value":"阳江市","open":true},{"pId":"0_1_5","id":"0_1_5_16","text":"云浮市","value":"云浮市","open":true},{"pId":"0_1_5","id":"0_1_5_17","text":"湛江市","value":"湛江市","open":true},{"pId":"0_1_5","id":"0_1_5_18","text":"肇庆市","value":"肇庆市","open":true},{"pId":"0_1_5","id":"0_1_5_19","text":"中山市","value":"中山市","open":true},{"pId":"0_1_5","id":"0_1_5_20","text":"珠海市","value":"珠海市","open":true},{"pId":"0_1","id":"0_1_6","text":"广西壮族自治区( 共14个 )","value":"广西壮族自治区","open":true},{"pId":"0_1_6","id":"0_1_6_0","text":"百色市","value":"百色市","open":true},{"pId":"0_1_6","id":"0_1_6_1","text":"北海市","value":"北海市","open":true},{"pId":"0_1_6","id":"0_1_6_2","text":"崇左市","value":"崇左市","open":true},{"pId":"0_1_6","id":"0_1_6_3","text":"防城港市","value":"防城港市","open":true},{"pId":"0_1_6","id":"0_1_6_4","text":"桂林市","value":"桂林市","open":true},{"pId":"0_1_6","id":"0_1_6_5","text":"贵港市","value":"贵港市","open":true},{"pId":"0_1_6","id":"0_1_6_6","text":"河池市","value":"河池市","open":true},{"pId":"0_1_6","id":"0_1_6_7","text":"贺州市","value":"贺州市","open":true},{"pId":"0_1_6","id":"0_1_6_8","text":"来宾市","value":"来宾市","open":true},{"pId":"0_1_6","id":"0_1_6_9","text":"柳州市","value":"柳州市","open":true},{"pId":"0_1_6","id":"0_1_6_10","text":"南宁市","value":"南宁市","open":true},{"pId":"0_1_6","id":"0_1_6_11","text":"钦州市","value":"钦州市","open":true},{"pId":"0_1_6","id":"0_1_6_12","text":"梧州市","value":"梧州市","open":true},{"pId":"0_1_6","id":"0_1_6_13","text":"玉林市","value":"玉林市","open":true},{"pId":"0_1","id":"0_1_7","text":"贵州省( 共9个 )","value":"贵州省","open":true},{"pId":"0_1_7","id":"0_1_7_0","text":"安顺市","value":"安顺市","open":true},{"pId":"0_1_7","id":"0_1_7_1","text":"毕节地区","value":"毕节地区","open":true},{"pId":"0_1_7","id":"0_1_7_2","text":"贵阳市","value":"贵阳市","open":true},{"pId":"0_1_7","id":"0_1_7_3","text":"六盘水市","value":"六盘水市","open":true},{"pId":"0_1_7","id":"0_1_7_4","text":"黔东南州","value":"黔东南州","open":true},{"pId":"0_1_7","id":"0_1_7_5","text":"黔南州","value":"黔南州","open":true},{"pId":"0_1_7","id":"0_1_7_6","text":"黔西南市","value":"黔西南市","open":true},{"pId":"0_1_7","id":"0_1_7_7","text":"铜仁地区","value":"铜仁地区","open":true},{"pId":"0_1_7","id":"0_1_7_8","text":"遵义市","value":"遵义市","open":true},{"pId":"0_1","id":"0_1_8","text":"海南省( 共2个 )","value":"海南省","open":true},{"pId":"0_1_8","id":"0_1_8_0","text":"海口市","value":"海口市","open":true},{"pId":"0_1_8","id":"0_1_8_1","text":"三亚市","value":"三亚市","open":true},{"pId":"0_1","id":"0_1_9","text":"河北省( 共12个 )","value":"河北省","open":true},{"pId":"0_1_9","id":"0_1_9_0","text":"保定市","value":"保定市","open":true},{"pId":"0_1_9","id":"0_1_9_1","text":"沧州市","value":"沧州市","open":true},{"pId":"0_1_9","id":"0_1_9_2","text":"承德市","value":"承德市","open":true},{"pId":"0_1_9","id":"0_1_9_3","text":"邯郸市","value":"邯郸市","open":true},{"pId":"0_1_9","id":"0_1_9_4","text":"衡水市","value":"衡水市","open":true},{"pId":"0_1_9","id":"0_1_9_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_9","id":"0_1_9_6","text":"秦皇岛市","value":"秦皇岛市","open":true},{"pId":"0_1_9","id":"0_1_9_7","text":"石家庄市","value":"石家庄市","open":true},{"pId":"0_1_9","id":"0_1_9_8","text":"唐山市","value":"唐山市","open":true},{"pId":"0_1_9","id":"0_1_9_9","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_9","id":"0_1_9_10","text":"邢台市","value":"邢台市","open":true},{"pId":"0_1_9","id":"0_1_9_11","text":"张家口市","value":"张家口市","open":true},{"pId":"0_1","id":"0_1_10","text":"河南省( 共19个 )","value":"河南省","open":true},{"pId":"0_1_10","id":"0_1_10_0","text":"安阳市","value":"安阳市","open":true},{"pId":"0_1_10","id":"0_1_10_1","text":"鹤壁市","value":"鹤壁市","open":true},{"pId":"0_1_10","id":"0_1_10_2","text":"济源市","value":"济源市","open":true},{"pId":"0_1_10","id":"0_1_10_3","text":"焦作市","value":"焦作市","open":true},{"pId":"0_1_10","id":"0_1_10_4","text":"开封市","value":"开封市","open":true},{"pId":"0_1_10","id":"0_1_10_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_10","id":"0_1_10_6","text":"洛阳市","value":"洛阳市","open":true},{"pId":"0_1_10","id":"0_1_10_7","text":"漯河市","value":"漯河市","open":true},{"pId":"0_1_10","id":"0_1_10_8","text":"南阳市","value":"南阳市","open":true},{"pId":"0_1_10","id":"0_1_10_9","text":"平顶山市","value":"平顶山市","open":true},{"pId":"0_1_10","id":"0_1_10_10","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_10","id":"0_1_10_11","text":"三门峡市","value":"三门峡市","open":true},{"pId":"0_1_10","id":"0_1_10_12","text":"商丘市","value":"商丘市","open":true},{"pId":"0_1_10","id":"0_1_10_13","text":"新乡市","value":"新乡市","open":true},{"pId":"0_1_10","id":"0_1_10_14","text":"信阳市","value":"信阳市","open":true},{"pId":"0_1_10","id":"0_1_10_15","text":"许昌市","value":"许昌市","open":true},{"pId":"0_1_10","id":"0_1_10_16","text":"郑州市","value":"郑州市","open":true},{"pId":"0_1_10","id":"0_1_10_17","text":"周口市","value":"周口市","open":true},{"pId":"0_1_10","id":"0_1_10_18","text":"驻马店市","value":"驻马店市","open":true},{"pId":"0_1","id":"0_1_11","text":"黑龙江省( 共13个 )","value":"黑龙江省","open":true},{"pId":"0_1_11","id":"0_1_11_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_11","id":"0_1_11_1","text":"大兴安岭地区","value":"大兴安岭地区","open":true},{"pId":"0_1_11","id":"0_1_11_2","text":"大兴安岭市","value":"大兴安岭市","open":true},{"pId":"0_1_11","id":"0_1_11_3","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_1_11","id":"0_1_11_4","text":"鹤港市","value":"鹤港市","open":true},{"pId":"0_1_11","id":"0_1_11_5","text":"黑河市","value":"黑河市","open":true},{"pId":"0_1_11","id":"0_1_11_6","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_1_11","id":"0_1_11_7","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_1_11","id":"0_1_11_8","text":"七台河市","value":"七台河市","open":true},{"pId":"0_1_11","id":"0_1_11_9","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_1_11","id":"0_1_11_10","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_1_11","id":"0_1_11_11","text":"绥化市","value":"绥化市","open":true},{"pId":"0_1_11","id":"0_1_11_12","text":"伊春市","value":"伊春市","open":true},{"pId":"0_1","id":"0_1_12","text":"湖北省( 共16个 )","value":"湖北省","open":true},{"pId":"0_1_12","id":"0_1_12_0","text":"鄂州市","value":"鄂州市","open":true},{"pId":"0_1_12","id":"0_1_12_1","text":"恩施土家族苗族自治州","value":"恩施土家族苗族自治州","open":true},{"pId":"0_1_12","id":"0_1_12_2","text":"黄冈市","value":"黄冈市","open":true},{"pId":"0_1_12","id":"0_1_12_3","text":"黄石市","value":"黄石市","open":true},{"pId":"0_1_12","id":"0_1_12_4","text":"荆门市","value":"荆门市","open":true},{"pId":"0_1_12","id":"0_1_12_5","text":"荆州市","value":"荆州市","open":true},{"pId":"0_1_12","id":"0_1_12_6","text":"神农架市","value":"神农架市","open":true},{"pId":"0_1_12","id":"0_1_12_7","text":"十堰市","value":"十堰市","open":true},{"pId":"0_1_12","id":"0_1_12_8","text":"随州市","value":"随州市","open":true},{"pId":"0_1_12","id":"0_1_12_9","text":"天门市","value":"天门市","open":true},{"pId":"0_1_12","id":"0_1_12_10","text":"武汉市","value":"武汉市","open":true},{"pId":"0_1_12","id":"0_1_12_11","text":"咸宁市","value":"咸宁市","open":true},{"pId":"0_1_12","id":"0_1_12_12","text":"襄樊市","value":"襄樊市","open":true},{"pId":"0_1_12","id":"0_1_12_13","text":"襄阳市","value":"襄阳市","open":true},{"pId":"0_1_12","id":"0_1_12_14","text":"孝感市","value":"孝感市","open":true},{"pId":"0_1_12","id":"0_1_12_15","text":"宜昌市","value":"宜昌市","open":true},{"pId":"0_1","id":"0_1_13","text":"湖南省( 共15个 )","value":"湖南省","open":true},{"pId":"0_1_13","id":"0_1_13_0","text":"常德市","value":"常德市","open":true},{"pId":"0_1_13","id":"0_1_13_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_1_13","id":"0_1_13_2","text":"郴州市","value":"郴州市","open":true},{"pId":"0_1_13","id":"0_1_13_3","text":"衡阳市","value":"衡阳市","open":true},{"pId":"0_1_13","id":"0_1_13_4","text":"怀化市","value":"怀化市","open":true},{"pId":"0_1_13","id":"0_1_13_5","text":"娄底市","value":"娄底市","open":true},{"pId":"0_1_13","id":"0_1_13_6","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_1_13","id":"0_1_13_7","text":"湘潭市","value":"湘潭市","open":true},{"pId":"0_1_13","id":"0_1_13_8","text":"湘西市","value":"湘西市","open":true},{"pId":"0_1_13","id":"0_1_13_9","text":"湘西土家族苗族自治州","value":"湘西土家族苗族自治州","open":true},{"pId":"0_1_13","id":"0_1_13_10","text":"益阳市","value":"益阳市","open":true},{"pId":"0_1_13","id":"0_1_13_11","text":"永州市","value":"永州市","open":true},{"pId":"0_1_13","id":"0_1_13_12","text":"岳阳市","value":"岳阳市","open":true},{"pId":"0_1_13","id":"0_1_13_13","text":"张家界市","value":"张家界市","open":true},{"pId":"0_1_13","id":"0_1_13_14","text":"株洲市","value":"株洲市","open":true},{"pId":"0_1","id":"0_1_14","text":"吉林省( 共10个 )","value":"吉林省","open":true},{"pId":"0_1_14","id":"0_1_14_0","text":"白城市","value":"白城市","open":true},{"pId":"0_1_14","id":"0_1_14_1","text":"白山市","value":"白山市","open":true},{"pId":"0_1_14","id":"0_1_14_2","text":"长春市","value":"长春市","open":true},{"pId":"0_1_14","id":"0_1_14_3","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_14","id":"0_1_14_4","text":"吉林市","value":"吉林市","open":true},{"pId":"0_1_14","id":"0_1_14_5","text":"辽源市","value":"辽源市","open":true},{"pId":"0_1_14","id":"0_1_14_6","text":"四平市","value":"四平市","open":true},{"pId":"0_1_14","id":"0_1_14_7","text":"松原市","value":"松原市","open":true},{"pId":"0_1_14","id":"0_1_14_8","text":"通化市","value":"通化市","open":true},{"pId":"0_1_14","id":"0_1_14_9","text":"延边朝鲜族自治州","value":"延边朝鲜族自治州","open":true},{"pId":"0_1","id":"0_1_15","text":"江苏省( 共13个 )","value":"江苏省","open":true},{"pId":"0_1_15","id":"0_1_15_0","text":"常州市","value":"常州市","open":true},{"pId":"0_1_15","id":"0_1_15_1","text":"淮安市","value":"淮安市","open":true},{"pId":"0_1_15","id":"0_1_15_2","text":"连云港市","value":"连云港市","open":true},{"pId":"0_1_15","id":"0_1_15_3","text":"南京市","value":"南京市","open":true},{"pId":"0_1_15","id":"0_1_15_4","text":"南通市","value":"南通市","open":true},{"pId":"0_1_15","id":"0_1_15_5","text":"苏州市","value":"苏州市","open":true},{"pId":"0_1_15","id":"0_1_15_6","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_1_15","id":"0_1_15_7","text":"泰州市","value":"泰州市","open":true},{"pId":"0_1_15","id":"0_1_15_8","text":"无锡市","value":"无锡市","open":true},{"pId":"0_1_15","id":"0_1_15_9","text":"徐州市","value":"徐州市","open":true},{"pId":"0_1_15","id":"0_1_15_10","text":"盐城市","value":"盐城市","open":true},{"pId":"0_1_15","id":"0_1_15_11","text":"扬州市","value":"扬州市","open":true},{"pId":"0_1_15","id":"0_1_15_12","text":"镇江市","value":"镇江市","open":true},{"pId":"0_1","id":"0_1_16","text":"江西省( 共10个 )","value":"江西省","open":true},{"pId":"0_1_16","id":"0_1_16_0","text":"抚州市","value":"抚州市","open":true},{"pId":"0_1_16","id":"0_1_16_1","text":"赣州市","value":"赣州市","open":true},{"pId":"0_1_16","id":"0_1_16_2","text":"景德镇市","value":"景德镇市","open":true},{"pId":"0_1_16","id":"0_1_16_3","text":"九江市","value":"九江市","open":true},{"pId":"0_1_16","id":"0_1_16_4","text":"南昌市","value":"南昌市","open":true},{"pId":"0_1_16","id":"0_1_16_5","text":"萍乡市","value":"萍乡市","open":true},{"pId":"0_1_16","id":"0_1_16_6","text":"上饶市","value":"上饶市","open":true},{"pId":"0_1_16","id":"0_1_16_7","text":"新余市","value":"新余市","open":true},{"pId":"0_1_16","id":"0_1_16_8","text":"宜春市","value":"宜春市","open":true},{"pId":"0_1_16","id":"0_1_16_9","text":"鹰潭市","value":"鹰潭市","open":true},{"pId":"0_1","id":"0_1_17","text":"辽宁省( 共14个 )","value":"辽宁省","open":true},{"pId":"0_1_17","id":"0_1_17_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_1_17","id":"0_1_17_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_1_17","id":"0_1_17_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_1_17","id":"0_1_17_3","text":"大连市","value":"大连市","open":true},{"pId":"0_1_17","id":"0_1_17_4","text":"丹东市","value":"丹东市","open":true},{"pId":"0_1_17","id":"0_1_17_5","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_1_17","id":"0_1_17_6","text":"阜新市","value":"阜新市","open":true},{"pId":"0_1_17","id":"0_1_17_7","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_1_17","id":"0_1_17_8","text":"锦州市","value":"锦州市","open":true},{"pId":"0_1_17","id":"0_1_17_9","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_1_17","id":"0_1_17_10","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_1_17","id":"0_1_17_11","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_1_17","id":"0_1_17_12","text":"铁岭市","value":"铁岭市","open":true},{"pId":"0_1_17","id":"0_1_17_13","text":"营口市","value":"营口市","open":true},{"pId":"0_1","id":"0_1_18","text":"内蒙古( 共10个 )","value":"内蒙古","open":true},{"pId":"0_1_18","id":"0_1_18_0","text":"包头市","value":"包头市","open":true},{"pId":"0_1_18","id":"0_1_18_1","text":"赤峰市","value":"赤峰市","open":true},{"pId":"0_1_18","id":"0_1_18_2","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_1_18","id":"0_1_18_3","text":"呼和浩特市","value":"呼和浩特市","open":true},{"pId":"0_1_18","id":"0_1_18_4","text":"呼伦贝尔市","value":"呼伦贝尔市","open":true},{"pId":"0_1_18","id":"0_1_18_5","text":"通辽市","value":"通辽市","open":true},{"pId":"0_1_18","id":"0_1_18_6","text":"乌海市","value":"乌海市","open":true},{"pId":"0_1_18","id":"0_1_18_7","text":"锡林郭勒市","value":"锡林郭勒市","open":true},{"pId":"0_1_18","id":"0_1_18_8","text":"兴安市","value":"兴安市","open":true},{"pId":"0_1_18","id":"0_1_18_9","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_19","text":"宁夏回族自治区( 共5个 )","value":"宁夏回族自治区","open":true},{"pId":"0_1_19","id":"0_1_19_0","text":"固原市","value":"固原市","open":true},{"pId":"0_1_19","id":"0_1_19_1","text":"石嘴山市","value":"石嘴山市","open":true},{"pId":"0_1_19","id":"0_1_19_2","text":"吴忠市","value":"吴忠市","open":true},{"pId":"0_1_19","id":"0_1_19_3","text":"银川市","value":"银川市","open":true},{"pId":"0_1_19","id":"0_1_19_4","text":"中卫市","value":"中卫市","open":true},{"pId":"0_1","id":"0_1_20","text":"青海省( 共4个 )","value":"青海省","open":true},{"pId":"0_1_20","id":"0_1_20_0","text":"海东地区","value":"海东地区","open":true},{"pId":"0_1_20","id":"0_1_20_1","text":"海南藏族自治州","value":"海南藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_2","text":"海西蒙古族藏族自治州","value":"海西蒙古族藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_3","text":"西宁市","value":"西宁市","open":true},{"pId":"0_1","id":"0_1_21","text":"山东省( 共17个 )","value":"山东省","open":true},{"pId":"0_1_21","id":"0_1_21_0","text":"滨州市","value":"滨州市","open":true},{"pId":"0_1_21","id":"0_1_21_1","text":"德州市","value":"德州市","open":true},{"pId":"0_1_21","id":"0_1_21_2","text":"东营市","value":"东营市","open":true},{"pId":"0_1_21","id":"0_1_21_3","text":"菏泽市","value":"菏泽市","open":true},{"pId":"0_1_21","id":"0_1_21_4","text":"济南市","value":"济南市","open":true},{"pId":"0_1_21","id":"0_1_21_5","text":"济宁市","value":"济宁市","open":true},{"pId":"0_1_21","id":"0_1_21_6","text":"莱芜市","value":"莱芜市","open":true},{"pId":"0_1_21","id":"0_1_21_7","text":"聊城市","value":"聊城市","open":true},{"pId":"0_1_21","id":"0_1_21_8","text":"临沂市","value":"临沂市","open":true},{"pId":"0_1_21","id":"0_1_21_9","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_21","id":"0_1_21_10","text":"日照市","value":"日照市","open":true},{"pId":"0_1_21","id":"0_1_21_11","text":"泰安市","value":"泰安市","open":true},{"pId":"0_1_21","id":"0_1_21_12","text":"威海市","value":"威海市","open":true},{"pId":"0_1_21","id":"0_1_21_13","text":"潍坊市","value":"潍坊市","open":true},{"pId":"0_1_21","id":"0_1_21_14","text":"烟台市","value":"烟台市","open":true},{"pId":"0_1_21","id":"0_1_21_15","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_1_21","id":"0_1_21_16","text":"淄博市","value":"淄博市","open":true},{"pId":"0_1","id":"0_1_22","text":"山西省( 共12个 )","value":"山西省","open":true},{"pId":"0_1_22","id":"0_1_22_0","text":"长治市","value":"长治市","open":true},{"pId":"0_1_22","id":"0_1_22_1","text":"大同市","value":"大同市","open":true},{"pId":"0_1_22","id":"0_1_22_2","text":"晋城市","value":"晋城市","open":true},{"pId":"0_1_22","id":"0_1_22_3","text":"晋中市","value":"晋中市","open":true},{"pId":"0_1_22","id":"0_1_22_4","text":"临汾市","value":"临汾市","open":true},{"pId":"0_1_22","id":"0_1_22_5","text":"吕梁市","value":"吕梁市","open":true},{"pId":"0_1_22","id":"0_1_22_6","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_22","id":"0_1_22_7","text":"朔州市","value":"朔州市","open":true},{"pId":"0_1_22","id":"0_1_22_8","text":"太原市","value":"太原市","open":true},{"pId":"0_1_22","id":"0_1_22_9","text":"忻州市","value":"忻州市","open":true},{"pId":"0_1_22","id":"0_1_22_10","text":"阳泉市","value":"阳泉市","open":true},{"pId":"0_1_22","id":"0_1_22_11","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_23","text":"陕西省( 共9个 )","value":"陕西省","open":true},{"pId":"0_1_23","id":"0_1_23_0","text":"安康市","value":"安康市","open":true},{"pId":"0_1_23","id":"0_1_23_1","text":"宝鸡市","value":"宝鸡市","open":true},{"pId":"0_1_23","id":"0_1_23_2","text":"汉中市","value":"汉中市","open":true},{"pId":"0_1_23","id":"0_1_23_3","text":"商洛市","value":"商洛市","open":true},{"pId":"0_1_23","id":"0_1_23_4","text":"渭南市","value":"渭南市","open":true},{"pId":"0_1_23","id":"0_1_23_5","text":"西安市","value":"西安市","open":true},{"pId":"0_1_23","id":"0_1_23_6","text":"咸阳市","value":"咸阳市","open":true},{"pId":"0_1_23","id":"0_1_23_7","text":"延安市","value":"延安市","open":true},{"pId":"0_1_23","id":"0_1_23_8","text":"榆林市","value":"榆林市","open":true},{"pId":"0_1","id":"0_1_24","text":"上海市( 共19个 )","value":"上海市","open":true},{"pId":"0_1_24","id":"0_1_24_0","text":"宝山区","value":"宝山区","open":true},{"pId":"0_1_24","id":"0_1_24_1","text":"长宁区","value":"长宁区","open":true},{"pId":"0_1_24","id":"0_1_24_2","text":"崇明县","value":"崇明县","open":true},{"pId":"0_1_24","id":"0_1_24_3","text":"奉贤区","value":"奉贤区","open":true},{"pId":"0_1_24","id":"0_1_24_4","text":"虹口区","value":"虹口区","open":true},{"pId":"0_1_24","id":"0_1_24_5","text":"黄浦区","value":"黄浦区","open":true},{"pId":"0_1_24","id":"0_1_24_6","text":"嘉定区","value":"嘉定区","open":true},{"pId":"0_1_24","id":"0_1_24_7","text":"金山区","value":"金山区","open":true},{"pId":"0_1_24","id":"0_1_24_8","text":"静安区","value":"静安区","open":true},{"pId":"0_1_24","id":"0_1_24_9","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_24","id":"0_1_24_10","text":"闵行区","value":"闵行区","open":true},{"pId":"0_1_24","id":"0_1_24_11","text":"普陀区","value":"普陀区","open":true},{"pId":"0_1_24","id":"0_1_24_12","text":"浦东新区","value":"浦东新区","open":true},{"pId":"0_1_24","id":"0_1_24_13","text":"青浦区","value":"青浦区","open":true},{"pId":"0_1_24","id":"0_1_24_14","text":"上海市区","value":"上海市区","open":true},{"pId":"0_1_24","id":"0_1_24_15","text":"松江区","value":"松江区","open":true},{"pId":"0_1_24","id":"0_1_24_16","text":"徐汇区","value":"徐汇区","open":true},{"pId":"0_1_24","id":"0_1_24_17","text":"杨浦区","value":"杨浦区","open":true},{"pId":"0_1_24","id":"0_1_24_18","text":"闸北区","value":"闸北区","open":true},{"pId":"0_1","id":"0_1_25","text":"四川省( 共21个 )","value":"四川省","open":true},{"pId":"0_1_25","id":"0_1_25_0","text":"阿坝藏族羌族自治州","value":"阿坝藏族羌族自治州","open":true},{"pId":"0_1_25","id":"0_1_25_1","text":"巴中市","value":"巴中市","open":true},{"pId":"0_1_25","id":"0_1_25_2","text":"成都市","value":"成都市","open":true},{"pId":"0_1_25","id":"0_1_25_3","text":"达州市","value":"达州市","open":true},{"pId":"0_1_25","id":"0_1_25_4","text":"德阳市","value":"德阳市","open":true},{"pId":"0_1_25","id":"0_1_25_5","text":"甘孜市","value":"甘孜市","open":true},{"pId":"0_1_25","id":"0_1_25_6","text":"广安市","value":"广安市","open":true},{"pId":"0_1_25","id":"0_1_25_7","text":"广元市","value":"广元市","open":true},{"pId":"0_1_25","id":"0_1_25_8","text":"乐山市","value":"乐山市","open":true},{"pId":"0_1_25","id":"0_1_25_9","text":"凉山市","value":"凉山市","open":true},{"pId":"0_1_25","id":"0_1_25_10","text":"泸州市","value":"泸州市","open":true},{"pId":"0_1_25","id":"0_1_25_11","text":"眉山市","value":"眉山市","open":true},{"pId":"0_1_25","id":"0_1_25_12","text":"绵阳市","value":"绵阳市","open":true},{"pId":"0_1_25","id":"0_1_25_13","text":"南充市","value":"南充市","open":true},{"pId":"0_1_25","id":"0_1_25_14","text":"内江市","value":"内江市","open":true},{"pId":"0_1_25","id":"0_1_25_15","text":"攀枝花市","value":"攀枝花市","open":true},{"pId":"0_1_25","id":"0_1_25_16","text":"遂宁市","value":"遂宁市","open":true},{"pId":"0_1_25","id":"0_1_25_17","text":"雅安市","value":"雅安市","open":true},{"pId":"0_1_25","id":"0_1_25_18","text":"宜宾市","value":"宜宾市","open":true},{"pId":"0_1_25","id":"0_1_25_19","text":"资阳市","value":"资阳市","open":true},{"pId":"0_1_25","id":"0_1_25_20","text":"自贡市","value":"自贡市","open":true},{"pId":"0_1","id":"0_1_26","text":"台湾( 共1个 )","value":"台湾","open":true},{"pId":"0_1_26","id":"0_1_26_0","text":"台北市","value":"台北市","open":true},{"pId":"0_1","id":"0_1_27","text":"天津市( 共1个 )","value":"天津市","open":true},{"pId":"0_1_27","id":"0_1_27_0","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1","id":"0_1_28","text":"西藏自治区( 共2个 )","value":"西藏自治区","open":true},{"pId":"0_1_28","id":"0_1_28_0","text":"阿里市","value":"阿里市","open":true},{"pId":"0_1_28","id":"0_1_28_1","text":"日喀则市","value":"日喀则市","open":true},{"pId":"0_1","id":"0_1_29","text":"香港特别行政区( 共1个 )","value":"香港特别行政区","open":true},{"pId":"0_1_29","id":"0_1_29_0","text":"香港","value":"香港","open":true},{"pId":"0_1","id":"0_1_30","text":"新疆维吾尔族自治区( 共11个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_1_30","id":"0_1_30_0","text":"巴音郭楞市","value":"巴音郭楞市","open":true},{"pId":"0_1_30","id":"0_1_30_1","text":"哈密市","value":"哈密市","open":true},{"pId":"0_1_30","id":"0_1_30_2","text":"和田市","value":"和田市","open":true},{"pId":"0_1_30","id":"0_1_30_3","text":"喀什地区","value":"喀什地区","open":true},{"pId":"0_1_30","id":"0_1_30_4","text":"克拉玛依市","value":"克拉玛依市","open":true},{"pId":"0_1_30","id":"0_1_30_5","text":"克孜勒苏柯州","value":"克孜勒苏柯州","open":true},{"pId":"0_1_30","id":"0_1_30_6","text":"石河子市","value":"石河子市","open":true},{"pId":"0_1_30","id":"0_1_30_7","text":"塔城市","value":"塔城市","open":true},{"pId":"0_1_30","id":"0_1_30_8","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_1_30","id":"0_1_30_9","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_1_30","id":"0_1_30_10","text":"伊犁市","value":"伊犁市","open":true},{"pId":"0_1","id":"0_1_31","text":"云南省( 共12个 )","value":"云南省","open":true},{"pId":"0_1_31","id":"0_1_31_0","text":"保山市","value":"保山市","open":true},{"pId":"0_1_31","id":"0_1_31_1","text":"楚雄彝族自治州","value":"楚雄彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_2","text":"大理白族自治州","value":"大理白族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_3","text":"红河哈尼族彝族自治州","value":"红河哈尼族彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_4","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_31","id":"0_1_31_5","text":"丽江市","value":"丽江市","open":true},{"pId":"0_1_31","id":"0_1_31_6","text":"临沧市","value":"临沧市","open":true},{"pId":"0_1_31","id":"0_1_31_7","text":"曲靖市","value":"曲靖市","open":true},{"pId":"0_1_31","id":"0_1_31_8","text":"思茅市","value":"思茅市","open":true},{"pId":"0_1_31","id":"0_1_31_9","text":"文山市","value":"文山市","open":true},{"pId":"0_1_31","id":"0_1_31_10","text":"玉溪市","value":"玉溪市","open":true},{"pId":"0_1_31","id":"0_1_31_11","text":"昭通市","value":"昭通市","open":true},{"pId":"0_1","id":"0_1_32","text":"浙江省( 共12个 )","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_1_32","id":"0_1_32_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_1_32","id":"0_1_32_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_1_32","id":"0_1_32_3","text":"金华市","value":"金华市","open":true},{"pId":"0_1_32","id":"0_1_32_4","text":"丽水市","value":"丽水市","open":true},{"pId":"0_1_32","id":"0_1_32_5","text":"宁波市","value":"宁波市","open":true},{"pId":"0_1_32","id":"0_1_32_6","text":"衢州市","value":"衢州市","open":true},{"pId":"0_1_32","id":"0_1_32_7","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_1_32","id":"0_1_32_8","text":"台州市","value":"台州市","open":true},{"pId":"0_1_32","id":"0_1_32_9","text":"温州市","value":"温州市","open":true},{"pId":"0_1_32","id":"0_1_32_10","text":"浙江省","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_11","text":"舟山市","value":"舟山市","open":true},{"pId":"0_1","id":"0_1_33","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_1_33","id":"0_1_33_0","text":"重庆市区","value":"重庆市区","open":true}]
+ TREEITEMS: [{"pId":"0","id":"0_0","text":"( 共25个 )","value":"","open":true},{"pId":"0_0","id":"0_0_0","text":"安徽省( 共1个 )","value":"安徽省","open":true},{"pId":"0_0_0","id":"0_0_0_0","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_0","id":"0_0_1","text":"北京市( 共6个 )","value":"北京市","open":true},{"pId":"0_0_1","id":"0_0_1_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_0_1","id":"0_0_1_1","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_0_1","id":"0_0_1_2","text":"东城区","value":"东城区","open":true},{"pId":"0_0_1","id":"0_0_1_3","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_0_1","id":"0_0_1_4","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_0_1","id":"0_0_1_5","text":"石景山区","value":"石景山区","open":true},{"pId":"0_0","id":"0_0_2","text":"福建省( 共2个 )","value":"福建省","open":true},{"pId":"0_0_2","id":"0_0_2_0","text":"莆田市","value":"莆田市","open":true},{"pId":"0_0_2","id":"0_0_2_1","text":"泉州市","value":"泉州市","open":true},{"pId":"0_0","id":"0_0_3","text":"甘肃省( 共1个 )","value":"甘肃省","open":true},{"pId":"0_0_3","id":"0_0_3_0","text":"兰州市","value":"兰州市","open":true},{"pId":"0_0","id":"0_0_4","text":"广东省( 共5个 )","value":"广东省","open":true},{"pId":"0_0_4","id":"0_0_4_0","text":"东莞市","value":"东莞市","open":true},{"pId":"0_0_4","id":"0_0_4_1","text":"广州市","value":"广州市","open":true},{"pId":"0_0_4","id":"0_0_4_2","text":"惠州市","value":"惠州市","open":true},{"pId":"0_0_4","id":"0_0_4_3","text":"深圳市","value":"深圳市","open":true},{"pId":"0_0_4","id":"0_0_4_4","text":"珠海市","value":"珠海市","open":true},{"pId":"0_0","id":"0_0_5","text":"广西壮族自治区( 共1个 )","value":"广西壮族自治区","open":true},{"pId":"0_0_5","id":"0_0_5_0","text":"南宁市","value":"南宁市","open":true},{"pId":"0_0","id":"0_0_6","text":"河北省( 共2个 )","value":"河北省","open":true},{"pId":"0_0_6","id":"0_0_6_0","text":"保定市","value":"保定市","open":true},{"pId":"0_0_6","id":"0_0_6_1","text":"邢台市","value":"邢台市","open":true},{"pId":"0_0","id":"0_0_7","text":"河南省( 共1个 )","value":"河南省","open":true},{"pId":"0_0_7","id":"0_0_7_0","text":"郑州市","value":"郑州市","open":true},{"pId":"0_0","id":"0_0_8","text":"黑龙江省( 共7个 )","value":"黑龙江省","open":true},{"pId":"0_0_8","id":"0_0_8_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_0_8","id":"0_0_8_1","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_0_8","id":"0_0_8_2","text":"鸡西市","value":"鸡西市","open":true},{"pId":"0_0_8","id":"0_0_8_3","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_0_8","id":"0_0_8_4","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_0_8","id":"0_0_8_5","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_0_8","id":"0_0_8_6","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_0","id":"0_0_9","text":"湖北省( 共1个 )","value":"湖北省","open":true},{"pId":"0_0_9","id":"0_0_9_0","text":"武汉市","value":"武汉市","open":true},{"pId":"0_0","id":"0_0_10","text":"湖南省( 共3个 )","value":"湖南省","open":true},{"pId":"0_0_10","id":"0_0_10_0","text":"常德市","value":"常德市","open":true},{"pId":"0_0_10","id":"0_0_10_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_0_10","id":"0_0_10_2","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_0","id":"0_0_11","text":"吉林省( 共4个 )","value":"吉林省","open":true},{"pId":"0_0_11","id":"0_0_11_0","text":"白山市","value":"白山市","open":true},{"pId":"0_0_11","id":"0_0_11_1","text":"长春市","value":"长春市","open":true},{"pId":"0_0_11","id":"0_0_11_2","text":"松原市","value":"松原市","open":true},{"pId":"0_0_11","id":"0_0_11_3","text":"通化市","value":"通化市","open":true},{"pId":"0_0","id":"0_0_12","text":"江苏省( 共8个 )","value":"江苏省","open":true},{"pId":"0_0_12","id":"0_0_12_0","text":"常州市","value":"常州市","open":true},{"pId":"0_0_12","id":"0_0_12_1","text":"南京市","value":"南京市","open":true},{"pId":"0_0_12","id":"0_0_12_2","text":"南通市","value":"南通市","open":true},{"pId":"0_0_12","id":"0_0_12_3","text":"苏州市","value":"苏州市","open":true},{"pId":"0_0_12","id":"0_0_12_4","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_0_12","id":"0_0_12_5","text":"泰州市","value":"泰州市","open":true},{"pId":"0_0_12","id":"0_0_12_6","text":"无锡市","value":"无锡市","open":true},{"pId":"0_0_12","id":"0_0_12_7","text":"盐城市","value":"盐城市","open":true},{"pId":"0_0","id":"0_0_13","text":"辽宁省( 共11个 )","value":"辽宁省","open":true},{"pId":"0_0_13","id":"0_0_13_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_0_13","id":"0_0_13_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_0_13","id":"0_0_13_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_0_13","id":"0_0_13_3","text":"大连市","value":"大连市","open":true},{"pId":"0_0_13","id":"0_0_13_4","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_0_13","id":"0_0_13_5","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_0_13","id":"0_0_13_6","text":"锦州市","value":"锦州市","open":true},{"pId":"0_0_13","id":"0_0_13_7","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_0_13","id":"0_0_13_8","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_0_13","id":"0_0_13_9","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_0_13","id":"0_0_13_10","text":"营口市","value":"营口市","open":true},{"pId":"0_0","id":"0_0_14","text":"内蒙古( 共1个 )","value":"内蒙古","open":true},{"pId":"0_0_14","id":"0_0_14_0","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_0","id":"0_0_15","text":"宁夏回族自治区( 共1个 )","value":"宁夏回族自治区","open":true},{"pId":"0_0_15","id":"0_0_15_0","text":"银川市","value":"银川市","open":true},{"pId":"0_0","id":"0_0_16","text":"山东省( 共7个 )","value":"山东省","open":true},{"pId":"0_0_16","id":"0_0_16_0","text":"济南市","value":"济南市","open":true},{"pId":"0_0_16","id":"0_0_16_1","text":"济宁市","value":"济宁市","open":true},{"pId":"0_0_16","id":"0_0_16_2","text":"聊城市","value":"聊城市","open":true},{"pId":"0_0_16","id":"0_0_16_3","text":"临沂市","value":"临沂市","open":true},{"pId":"0_0_16","id":"0_0_16_4","text":"青岛市","value":"青岛市","open":true},{"pId":"0_0_16","id":"0_0_16_5","text":"烟台市","value":"烟台市","open":true},{"pId":"0_0_16","id":"0_0_16_6","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_0","id":"0_0_17","text":"山西省( 共1个 )","value":"山西省","open":true},{"pId":"0_0_17","id":"0_0_17_0","text":"太原市","value":"太原市","open":true},{"pId":"0_0","id":"0_0_18","text":"陕西省( 共1个 )","value":"陕西省","open":true},{"pId":"0_0_18","id":"0_0_18_0","text":"西安市","value":"西安市","open":true},{"pId":"0_0","id":"0_0_19","text":"上海市( 共1个 )","value":"上海市","open":true},{"pId":"0_0_19","id":"0_0_19_0","text":"上海市区","value":"上海市区","open":true},{"pId":"0_0","id":"0_0_20","text":"四川省( 共1个 )","value":"四川省","open":true},{"pId":"0_0_20","id":"0_0_20_0","text":"成都市","value":"成都市","open":true},{"pId":"0_0","id":"0_0_21","text":"新疆维吾尔族自治区( 共2个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_0_21","id":"0_0_21_0","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_0_21","id":"0_0_21_1","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_0","id":"0_0_22","text":"云南省( 共1个 )","value":"云南省","open":true},{"pId":"0_0_22","id":"0_0_22_0","text":"昆明市","value":"昆明市","open":true},{"pId":"0_0","id":"0_0_23","text":"浙江省( 共5个 )","value":"浙江省","open":true},{"pId":"0_0_23","id":"0_0_23_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_0_23","id":"0_0_23_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_0_23","id":"0_0_23_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_0_23","id":"0_0_23_3","text":"宁波市","value":"宁波市","open":true},{"pId":"0_0_23","id":"0_0_23_4","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_0","id":"0_0_24","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_0_24","id":"0_0_24_0","text":"重庆市区","value":"重庆市区","open":true},{"pId":"0","id":"0_1","text":"中国( 共34个 )","value":"中国","open":true},{"pId":"0_1","id":"0_1_0","text":"安徽省( 共19个 )","value":"安徽省","open":true},{"pId":"0_1_0","id":"0_1_0_0","text":"安庆市","value":"安庆市","open":true},{"pId":"0_1_0","id":"0_1_0_1","text":"蚌埠市","value":"蚌埠市","open":true},{"pId":"0_1_0","id":"0_1_0_2","text":"亳州市","value":"亳州市","open":true},{"pId":"0_1_0","id":"0_1_0_3","text":"巢湖市","value":"巢湖市","open":true},{"pId":"0_1_0","id":"0_1_0_4","text":"池州市","value":"池州市","open":true},{"pId":"0_1_0","id":"0_1_0_5","text":"滁州市","value":"滁州市","open":true},{"pId":"0_1_0","id":"0_1_0_6","text":"阜阳市","value":"阜阳市","open":true},{"pId":"0_1_0","id":"0_1_0_7","text":"毫州市","value":"毫州市","open":true},{"pId":"0_1_0","id":"0_1_0_8","text":"合肥市","value":"合肥市","open":true},{"pId":"0_1_0","id":"0_1_0_9","text":"淮北市","value":"淮北市","open":true},{"pId":"0_1_0","id":"0_1_0_10","text":"淮南市","value":"淮南市","open":true},{"pId":"0_1_0","id":"0_1_0_11","text":"黄山市","value":"黄山市","open":true},{"pId":"0_1_0","id":"0_1_0_12","text":"六安市","value":"六安市","open":true},{"pId":"0_1_0","id":"0_1_0_13","text":"马鞍山市","value":"马鞍山市","open":true},{"pId":"0_1_0","id":"0_1_0_14","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_0","id":"0_1_0_15","text":"宿州市","value":"宿州市","open":true},{"pId":"0_1_0","id":"0_1_0_16","text":"铜陵市","value":"铜陵市","open":true},{"pId":"0_1_0","id":"0_1_0_17","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_1_0","id":"0_1_0_18","text":"宣城市","value":"宣城市","open":true},{"pId":"0_1","id":"0_1_1","text":"澳门特别行政区( 共1个 )","value":"澳门特别行政区","open":true},{"pId":"0_1_1","id":"0_1_1_0","text":"澳门","value":"澳门","open":true},{"pId":"0_1","id":"0_1_2","text":"北京市( 共17个 )","value":"北京市","open":true},{"pId":"0_1_2","id":"0_1_2_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_1_2","id":"0_1_2_1","text":"昌平区","value":"昌平区","open":true},{"pId":"0_1_2","id":"0_1_2_2","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_1_2","id":"0_1_2_3","text":"大兴区","value":"大兴区","open":true},{"pId":"0_1_2","id":"0_1_2_4","text":"东城区","value":"东城区","open":true},{"pId":"0_1_2","id":"0_1_2_5","text":"房山区","value":"房山区","open":true},{"pId":"0_1_2","id":"0_1_2_6","text":"丰台区","value":"丰台区","open":true},{"pId":"0_1_2","id":"0_1_2_7","text":"海淀区","value":"海淀区","open":true},{"pId":"0_1_2","id":"0_1_2_8","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_1_2","id":"0_1_2_9","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_1_2","id":"0_1_2_10","text":"门头沟区","value":"门头沟区","open":true},{"pId":"0_1_2","id":"0_1_2_11","text":"平谷区","value":"平谷区","open":true},{"pId":"0_1_2","id":"0_1_2_12","text":"石景山区","value":"石景山区","open":true},{"pId":"0_1_2","id":"0_1_2_13","text":"顺义区","value":"顺义区","open":true},{"pId":"0_1_2","id":"0_1_2_14","text":"通州区","value":"通州区","open":true},{"pId":"0_1_2","id":"0_1_2_15","text":"西城区","value":"西城区","open":true},{"pId":"0_1_2","id":"0_1_2_16","text":"西城区 ","value":"西城区 ","open":true},{"pId":"0_1","id":"0_1_3","text":"福建省( 共9个 )","value":"福建省","open":true},{"pId":"0_1_3","id":"0_1_3_0","text":"福州市","value":"福州市","open":true},{"pId":"0_1_3","id":"0_1_3_1","text":"龙岩市","value":"龙岩市","open":true},{"pId":"0_1_3","id":"0_1_3_2","text":"南平市","value":"南平市","open":true},{"pId":"0_1_3","id":"0_1_3_3","text":"宁德市","value":"宁德市","open":true},{"pId":"0_1_3","id":"0_1_3_4","text":"莆田市","value":"莆田市","open":true},{"pId":"0_1_3","id":"0_1_3_5","text":"泉州市","value":"泉州市","open":true},{"pId":"0_1_3","id":"0_1_3_6","text":"三明市","value":"三明市","open":true},{"pId":"0_1_3","id":"0_1_3_7","text":"厦门市","value":"厦门市","open":true},{"pId":"0_1_3","id":"0_1_3_8","text":"漳州市","value":"漳州市","open":true},{"pId":"0_1","id":"0_1_4","text":"甘肃省( 共12个 )","value":"甘肃省","open":true},{"pId":"0_1_4","id":"0_1_4_0","text":"白银市","value":"白银市","open":true},{"pId":"0_1_4","id":"0_1_4_1","text":"嘉峪关市","value":"嘉峪关市","open":true},{"pId":"0_1_4","id":"0_1_4_2","text":"金昌市","value":"金昌市","open":true},{"pId":"0_1_4","id":"0_1_4_3","text":"酒泉市","value":"酒泉市","open":true},{"pId":"0_1_4","id":"0_1_4_4","text":"兰州市","value":"兰州市","open":true},{"pId":"0_1_4","id":"0_1_4_5","text":"陇南市","value":"陇南市","open":true},{"pId":"0_1_4","id":"0_1_4_6","text":"平凉市","value":"平凉市","open":true},{"pId":"0_1_4","id":"0_1_4_7","text":"庆阳市","value":"庆阳市","open":true},{"pId":"0_1_4","id":"0_1_4_8","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_4","id":"0_1_4_9","text":"天水市","value":"天水市","open":true},{"pId":"0_1_4","id":"0_1_4_10","text":"武威市","value":"武威市","open":true},{"pId":"0_1_4","id":"0_1_4_11","text":"张掖市","value":"张掖市","open":true},{"pId":"0_1","id":"0_1_5","text":"广东省( 共21个 )","value":"广东省","open":true},{"pId":"0_1_5","id":"0_1_5_0","text":"潮州市","value":"潮州市","open":true},{"pId":"0_1_5","id":"0_1_5_1","text":"东莞市","value":"东莞市","open":true},{"pId":"0_1_5","id":"0_1_5_2","text":"佛山市","value":"佛山市","open":true},{"pId":"0_1_5","id":"0_1_5_3","text":"广州市","value":"广州市","open":true},{"pId":"0_1_5","id":"0_1_5_4","text":"河源市","value":"河源市","open":true},{"pId":"0_1_5","id":"0_1_5_5","text":"惠州市","value":"惠州市","open":true},{"pId":"0_1_5","id":"0_1_5_6","text":"江门市","value":"江门市","open":true},{"pId":"0_1_5","id":"0_1_5_7","text":"揭阳市","value":"揭阳市","open":true},{"pId":"0_1_5","id":"0_1_5_8","text":"茂名市","value":"茂名市","open":true},{"pId":"0_1_5","id":"0_1_5_9","text":"梅州市","value":"梅州市","open":true},{"pId":"0_1_5","id":"0_1_5_10","text":"清远市","value":"清远市","open":true},{"pId":"0_1_5","id":"0_1_5_11","text":"汕头市","value":"汕头市","open":true},{"pId":"0_1_5","id":"0_1_5_12","text":"汕尾市","value":"汕尾市","open":true},{"pId":"0_1_5","id":"0_1_5_13","text":"韶关市","value":"韶关市","open":true},{"pId":"0_1_5","id":"0_1_5_14","text":"深圳市","value":"深圳市","open":true},{"pId":"0_1_5","id":"0_1_5_15","text":"阳江市","value":"阳江市","open":true},{"pId":"0_1_5","id":"0_1_5_16","text":"云浮市","value":"云浮市","open":true},{"pId":"0_1_5","id":"0_1_5_17","text":"湛江市","value":"湛江市","open":true},{"pId":"0_1_5","id":"0_1_5_18","text":"肇庆市","value":"肇庆市","open":true},{"pId":"0_1_5","id":"0_1_5_19","text":"中山市","value":"中山市","open":true},{"pId":"0_1_5","id":"0_1_5_20","text":"珠海市","value":"珠海市","open":true},{"pId":"0_1","id":"0_1_6","text":"广西壮族自治区( 共14个 )","value":"广西壮族自治区","open":true},{"pId":"0_1_6","id":"0_1_6_0","text":"百色市","value":"百色市","open":true},{"pId":"0_1_6","id":"0_1_6_1","text":"北海市","value":"北海市","open":true},{"pId":"0_1_6","id":"0_1_6_2","text":"崇左市","value":"崇左市","open":true},{"pId":"0_1_6","id":"0_1_6_3","text":"防城港市","value":"防城港市","open":true},{"pId":"0_1_6","id":"0_1_6_4","text":"桂林市","value":"桂林市","open":true},{"pId":"0_1_6","id":"0_1_6_5","text":"贵港市","value":"贵港市","open":true},{"pId":"0_1_6","id":"0_1_6_6","text":"河池市","value":"河池市","open":true},{"pId":"0_1_6","id":"0_1_6_7","text":"贺州市","value":"贺州市","open":true},{"pId":"0_1_6","id":"0_1_6_8","text":"来宾市","value":"来宾市","open":true},{"pId":"0_1_6","id":"0_1_6_9","text":"柳州市","value":"柳州市","open":true},{"pId":"0_1_6","id":"0_1_6_10","text":"南宁市","value":"南宁市","open":true},{"pId":"0_1_6","id":"0_1_6_11","text":"钦州市","value":"钦州市","open":true},{"pId":"0_1_6","id":"0_1_6_12","text":"梧州市","value":"梧州市","open":true},{"pId":"0_1_6","id":"0_1_6_13","text":"玉林市","value":"玉林市","open":true},{"pId":"0_1","id":"0_1_7","text":"贵州省( 共9个 )","value":"贵州省","open":true},{"pId":"0_1_7","id":"0_1_7_0","text":"安顺市","value":"安顺市","open":true},{"pId":"0_1_7","id":"0_1_7_1","text":"毕节地区","value":"毕节地区","open":true},{"pId":"0_1_7","id":"0_1_7_2","text":"贵阳市","value":"贵阳市","open":true},{"pId":"0_1_7","id":"0_1_7_3","text":"六盘水市","value":"六盘水市","open":true},{"pId":"0_1_7","id":"0_1_7_4","text":"黔东南州","value":"黔东南州","open":true},{"pId":"0_1_7","id":"0_1_7_5","text":"黔南州","value":"黔南州","open":true},{"pId":"0_1_7","id":"0_1_7_6","text":"黔西南市","value":"黔西南市","open":true},{"pId":"0_1_7","id":"0_1_7_7","text":"铜仁地区","value":"铜仁地区","open":true},{"pId":"0_1_7","id":"0_1_7_8","text":"遵义市","value":"遵义市","open":true},{"pId":"0_1","id":"0_1_8","text":"海南省( 共2个 )","value":"海南省","open":true},{"pId":"0_1_8","id":"0_1_8_0","text":"海口市","value":"海口市","open":true},{"pId":"0_1_8","id":"0_1_8_1","text":"三亚市","value":"三亚市","open":true},{"pId":"0_1","id":"0_1_9","text":"河北省( 共12个 )","value":"河北省","open":true},{"pId":"0_1_9","id":"0_1_9_0","text":"保定市","value":"保定市","open":true},{"pId":"0_1_9","id":"0_1_9_1","text":"沧州市","value":"沧州市","open":true},{"pId":"0_1_9","id":"0_1_9_2","text":"承德市","value":"承德市","open":true},{"pId":"0_1_9","id":"0_1_9_3","text":"邯郸市","value":"邯郸市","open":true},{"pId":"0_1_9","id":"0_1_9_4","text":"衡水市","value":"衡水市","open":true},{"pId":"0_1_9","id":"0_1_9_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_9","id":"0_1_9_6","text":"秦皇岛市","value":"秦皇岛市","open":true},{"pId":"0_1_9","id":"0_1_9_7","text":"石家庄市","value":"石家庄市","open":true},{"pId":"0_1_9","id":"0_1_9_8","text":"唐山市","value":"唐山市","open":true},{"pId":"0_1_9","id":"0_1_9_9","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_9","id":"0_1_9_10","text":"邢台市","value":"邢台市","open":true},{"pId":"0_1_9","id":"0_1_9_11","text":"张家口市","value":"张家口市","open":true},{"pId":"0_1","id":"0_1_10","text":"河南省( 共19个 )","value":"河南省","open":true},{"pId":"0_1_10","id":"0_1_10_0","text":"安阳市","value":"安阳市","open":true},{"pId":"0_1_10","id":"0_1_10_1","text":"鹤壁市","value":"鹤壁市","open":true},{"pId":"0_1_10","id":"0_1_10_2","text":"济源市","value":"济源市","open":true},{"pId":"0_1_10","id":"0_1_10_3","text":"焦作市","value":"焦作市","open":true},{"pId":"0_1_10","id":"0_1_10_4","text":"开封市","value":"开封市","open":true},{"pId":"0_1_10","id":"0_1_10_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_10","id":"0_1_10_6","text":"洛阳市","value":"洛阳市","open":true},{"pId":"0_1_10","id":"0_1_10_7","text":"漯河市","value":"漯河市","open":true},{"pId":"0_1_10","id":"0_1_10_8","text":"南阳市","value":"南阳市","open":true},{"pId":"0_1_10","id":"0_1_10_9","text":"平顶山市","value":"平顶山市","open":true},{"pId":"0_1_10","id":"0_1_10_10","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_10","id":"0_1_10_11","text":"三门峡市","value":"三门峡市","open":true},{"pId":"0_1_10","id":"0_1_10_12","text":"商丘市","value":"商丘市","open":true},{"pId":"0_1_10","id":"0_1_10_13","text":"新乡市","value":"新乡市","open":true},{"pId":"0_1_10","id":"0_1_10_14","text":"信阳市","value":"信阳市","open":true},{"pId":"0_1_10","id":"0_1_10_15","text":"许昌市","value":"许昌市","open":true},{"pId":"0_1_10","id":"0_1_10_16","text":"郑州市","value":"郑州市","open":true},{"pId":"0_1_10","id":"0_1_10_17","text":"周口市","value":"周口市","open":true},{"pId":"0_1_10","id":"0_1_10_18","text":"驻马店市","value":"驻马店市","open":true},{"pId":"0_1","id":"0_1_11","text":"黑龙江省( 共13个 )","value":"黑龙江省","open":true},{"pId":"0_1_11","id":"0_1_11_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_11","id":"0_1_11_1","text":"大兴安岭地区","value":"大兴安岭地区","open":true},{"pId":"0_1_11","id":"0_1_11_2","text":"大兴安岭市","value":"大兴安岭市","open":true},{"pId":"0_1_11","id":"0_1_11_3","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_1_11","id":"0_1_11_4","text":"鹤港市","value":"鹤港市","open":true},{"pId":"0_1_11","id":"0_1_11_5","text":"黑河市","value":"黑河市","open":true},{"pId":"0_1_11","id":"0_1_11_6","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_1_11","id":"0_1_11_7","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_1_11","id":"0_1_11_8","text":"七台河市","value":"七台河市","open":true},{"pId":"0_1_11","id":"0_1_11_9","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_1_11","id":"0_1_11_10","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_1_11","id":"0_1_11_11","text":"绥化市","value":"绥化市","open":true},{"pId":"0_1_11","id":"0_1_11_12","text":"伊春市","value":"伊春市","open":true},{"pId":"0_1","id":"0_1_12","text":"湖北省( 共16个 )","value":"湖北省","open":true},{"pId":"0_1_12","id":"0_1_12_0","text":"鄂州市","value":"鄂州市","open":true},{"pId":"0_1_12","id":"0_1_12_1","text":"恩施土家族苗族自治州","value":"恩施土家族苗族自治州","open":true},{"pId":"0_1_12","id":"0_1_12_2","text":"黄冈市","value":"黄冈市","open":true},{"pId":"0_1_12","id":"0_1_12_3","text":"黄石市","value":"黄石市","open":true},{"pId":"0_1_12","id":"0_1_12_4","text":"荆门市","value":"荆门市","open":true},{"pId":"0_1_12","id":"0_1_12_5","text":"荆州市","value":"荆州市","open":true},{"pId":"0_1_12","id":"0_1_12_6","text":"神农架市","value":"神农架市","open":true},{"pId":"0_1_12","id":"0_1_12_7","text":"十堰市","value":"十堰市","open":true},{"pId":"0_1_12","id":"0_1_12_8","text":"随州市","value":"随州市","open":true},{"pId":"0_1_12","id":"0_1_12_9","text":"天门市","value":"天门市","open":true},{"pId":"0_1_12","id":"0_1_12_10","text":"武汉市","value":"武汉市","open":true},{"pId":"0_1_12","id":"0_1_12_11","text":"咸宁市","value":"咸宁市","open":true},{"pId":"0_1_12","id":"0_1_12_12","text":"襄樊市","value":"襄樊市","open":true},{"pId":"0_1_12","id":"0_1_12_13","text":"襄阳市","value":"襄阳市","open":true},{"pId":"0_1_12","id":"0_1_12_14","text":"孝感市","value":"孝感市","open":true},{"pId":"0_1_12","id":"0_1_12_15","text":"宜昌市","value":"宜昌市","open":true},{"pId":"0_1","id":"0_1_13","text":"湖南省( 共15个 )","value":"湖南省","open":true},{"pId":"0_1_13","id":"0_1_13_0","text":"常德市","value":"常德市","open":true},{"pId":"0_1_13","id":"0_1_13_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_1_13","id":"0_1_13_2","text":"郴州市","value":"郴州市","open":true},{"pId":"0_1_13","id":"0_1_13_3","text":"衡阳市","value":"衡阳市","open":true},{"pId":"0_1_13","id":"0_1_13_4","text":"怀化市","value":"怀化市","open":true},{"pId":"0_1_13","id":"0_1_13_5","text":"娄底市","value":"娄底市","open":true},{"pId":"0_1_13","id":"0_1_13_6","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_1_13","id":"0_1_13_7","text":"湘潭市","value":"湘潭市","open":true},{"pId":"0_1_13","id":"0_1_13_8","text":"湘西市","value":"湘西市","open":true},{"pId":"0_1_13","id":"0_1_13_9","text":"湘西土家族苗族自治州","value":"湘西土家族苗族自治州","open":true},{"pId":"0_1_13","id":"0_1_13_10","text":"益阳市","value":"益阳市","open":true},{"pId":"0_1_13","id":"0_1_13_11","text":"永州市","value":"永州市","open":true},{"pId":"0_1_13","id":"0_1_13_12","text":"岳阳市","value":"岳阳市","open":true},{"pId":"0_1_13","id":"0_1_13_13","text":"张家界市","value":"张家界市","open":true},{"pId":"0_1_13","id":"0_1_13_14","text":"株洲市","value":"株洲市","open":true},{"pId":"0_1","id":"0_1_14","text":"吉林省( 共10个 )","value":"吉林省","open":true},{"pId":"0_1_14","id":"0_1_14_0","text":"白城市","value":"白城市","open":true},{"pId":"0_1_14","id":"0_1_14_1","text":"白山市","value":"白山市","open":true},{"pId":"0_1_14","id":"0_1_14_2","text":"长春市","value":"长春市","open":true},{"pId":"0_1_14","id":"0_1_14_3","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_14","id":"0_1_14_4","text":"吉林市","value":"吉林市","open":true},{"pId":"0_1_14","id":"0_1_14_5","text":"辽源市","value":"辽源市","open":true},{"pId":"0_1_14","id":"0_1_14_6","text":"四平市","value":"四平市","open":true},{"pId":"0_1_14","id":"0_1_14_7","text":"松原市","value":"松原市","open":true},{"pId":"0_1_14","id":"0_1_14_8","text":"通化市","value":"通化市","open":true},{"pId":"0_1_14","id":"0_1_14_9","text":"延边朝鲜族自治州","value":"延边朝鲜族自治州","open":true},{"pId":"0_1","id":"0_1_15","text":"江苏省( 共13个 )","value":"江苏省","open":true},{"pId":"0_1_15","id":"0_1_15_0","text":"常州市","value":"常州市","open":true},{"pId":"0_1_15","id":"0_1_15_1","text":"淮安市","value":"淮安市","open":true},{"pId":"0_1_15","id":"0_1_15_2","text":"连云港市","value":"连云港市","open":true},{"pId":"0_1_15","id":"0_1_15_3","text":"南京市","value":"南京市","open":true},{"pId":"0_1_15","id":"0_1_15_4","text":"南通市","value":"南通市","open":true},{"pId":"0_1_15","id":"0_1_15_5","text":"苏州市","value":"苏州市","open":true},{"pId":"0_1_15","id":"0_1_15_6","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_1_15","id":"0_1_15_7","text":"泰州市","value":"泰州市","open":true},{"pId":"0_1_15","id":"0_1_15_8","text":"无锡市","value":"无锡市","open":true},{"pId":"0_1_15","id":"0_1_15_9","text":"徐州市","value":"徐州市","open":true},{"pId":"0_1_15","id":"0_1_15_10","text":"盐城市","value":"盐城市","open":true},{"pId":"0_1_15","id":"0_1_15_11","text":"扬州市","value":"扬州市","open":true},{"pId":"0_1_15","id":"0_1_15_12","text":"镇江市","value":"镇江市","open":true},{"pId":"0_1","id":"0_1_16","text":"江西省( 共10个 )","value":"江西省","open":true},{"pId":"0_1_16","id":"0_1_16_0","text":"抚州市","value":"抚州市","open":true},{"pId":"0_1_16","id":"0_1_16_1","text":"赣州市","value":"赣州市","open":true},{"pId":"0_1_16","id":"0_1_16_2","text":"景德镇市","value":"景德镇市","open":true},{"pId":"0_1_16","id":"0_1_16_3","text":"九江市","value":"九江市","open":true},{"pId":"0_1_16","id":"0_1_16_4","text":"南昌市","value":"南昌市","open":true},{"pId":"0_1_16","id":"0_1_16_5","text":"萍乡市","value":"萍乡市","open":true},{"pId":"0_1_16","id":"0_1_16_6","text":"上饶市","value":"上饶市","open":true},{"pId":"0_1_16","id":"0_1_16_7","text":"新余市","value":"新余市","open":true},{"pId":"0_1_16","id":"0_1_16_8","text":"宜春市","value":"宜春市","open":true},{"pId":"0_1_16","id":"0_1_16_9","text":"鹰潭市","value":"鹰潭市","open":true},{"pId":"0_1","id":"0_1_17","text":"辽宁省( 共14个 )","value":"辽宁省","open":true},{"pId":"0_1_17","id":"0_1_17_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_1_17","id":"0_1_17_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_1_17","id":"0_1_17_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_1_17","id":"0_1_17_3","text":"大连市","value":"大连市","open":true},{"pId":"0_1_17","id":"0_1_17_4","text":"丹东市","value":"丹东市","open":true},{"pId":"0_1_17","id":"0_1_17_5","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_1_17","id":"0_1_17_6","text":"阜新市","value":"阜新市","open":true},{"pId":"0_1_17","id":"0_1_17_7","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_1_17","id":"0_1_17_8","text":"锦州市","value":"锦州市","open":true},{"pId":"0_1_17","id":"0_1_17_9","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_1_17","id":"0_1_17_10","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_1_17","id":"0_1_17_11","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_1_17","id":"0_1_17_12","text":"铁岭市","value":"铁岭市","open":true},{"pId":"0_1_17","id":"0_1_17_13","text":"营口市","value":"营口市","open":true},{"pId":"0_1","id":"0_1_18","text":"内蒙古( 共10个 )","value":"内蒙古","open":true},{"pId":"0_1_18","id":"0_1_18_0","text":"包头市","value":"包头市","open":true},{"pId":"0_1_18","id":"0_1_18_1","text":"赤峰市","value":"赤峰市","open":true},{"pId":"0_1_18","id":"0_1_18_2","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_1_18","id":"0_1_18_3","text":"呼和浩特市","value":"呼和浩特市","open":true},{"pId":"0_1_18","id":"0_1_18_4","text":"呼伦贝尔市","value":"呼伦贝尔市","open":true},{"pId":"0_1_18","id":"0_1_18_5","text":"通辽市","value":"通辽市","open":true},{"pId":"0_1_18","id":"0_1_18_6","text":"乌海市","value":"乌海市","open":true},{"pId":"0_1_18","id":"0_1_18_7","text":"锡林郭勒市","value":"锡林郭勒市","open":true},{"pId":"0_1_18","id":"0_1_18_8","text":"兴安市","value":"兴安市","open":true},{"pId":"0_1_18","id":"0_1_18_9","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_19","text":"宁夏回族自治区( 共5个 )","value":"宁夏回族自治区","open":true},{"pId":"0_1_19","id":"0_1_19_0","text":"固原市","value":"固原市","open":true},{"pId":"0_1_19","id":"0_1_19_1","text":"石嘴山市","value":"石嘴山市","open":true},{"pId":"0_1_19","id":"0_1_19_2","text":"吴忠市","value":"吴忠市","open":true},{"pId":"0_1_19","id":"0_1_19_3","text":"银川市","value":"银川市","open":true},{"pId":"0_1_19","id":"0_1_19_4","text":"中卫市","value":"中卫市","open":true},{"pId":"0_1","id":"0_1_20","text":"青海省( 共4个 )","value":"青海省","open":true},{"pId":"0_1_20","id":"0_1_20_0","text":"海东地区","value":"海东地区","open":true},{"pId":"0_1_20","id":"0_1_20_1","text":"海南藏族自治州","value":"海南藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_2","text":"海西蒙古族藏族自治州","value":"海西蒙古族藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_3","text":"西宁市","value":"西宁市","open":true},{"pId":"0_1","id":"0_1_21","text":"山东省( 共17个 )","value":"山东省","open":true},{"pId":"0_1_21","id":"0_1_21_0","text":"滨州市","value":"滨州市","open":true},{"pId":"0_1_21","id":"0_1_21_1","text":"德州市","value":"德州市","open":true},{"pId":"0_1_21","id":"0_1_21_2","text":"东营市","value":"东营市","open":true},{"pId":"0_1_21","id":"0_1_21_3","text":"菏泽市","value":"菏泽市","open":true},{"pId":"0_1_21","id":"0_1_21_4","text":"济南市","value":"济南市","open":true},{"pId":"0_1_21","id":"0_1_21_5","text":"济宁市","value":"济宁市","open":true},{"pId":"0_1_21","id":"0_1_21_6","text":"莱芜市","value":"莱芜市","open":true},{"pId":"0_1_21","id":"0_1_21_7","text":"聊城市","value":"聊城市","open":true},{"pId":"0_1_21","id":"0_1_21_8","text":"临沂市","value":"临沂市","open":true},{"pId":"0_1_21","id":"0_1_21_9","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_21","id":"0_1_21_10","text":"日照市","value":"日照市","open":true},{"pId":"0_1_21","id":"0_1_21_11","text":"泰安市","value":"泰安市","open":true},{"pId":"0_1_21","id":"0_1_21_12","text":"威海市","value":"威海市","open":true},{"pId":"0_1_21","id":"0_1_21_13","text":"潍坊市","value":"潍坊市","open":true},{"pId":"0_1_21","id":"0_1_21_14","text":"烟台市","value":"烟台市","open":true},{"pId":"0_1_21","id":"0_1_21_15","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_1_21","id":"0_1_21_16","text":"淄博市","value":"淄博市","open":true},{"pId":"0_1","id":"0_1_22","text":"山西省( 共12个 )","value":"山西省","open":true},{"pId":"0_1_22","id":"0_1_22_0","text":"长治市","value":"长治市","open":true},{"pId":"0_1_22","id":"0_1_22_1","text":"大同市","value":"大同市","open":true},{"pId":"0_1_22","id":"0_1_22_2","text":"晋城市","value":"晋城市","open":true},{"pId":"0_1_22","id":"0_1_22_3","text":"晋中市","value":"晋中市","open":true},{"pId":"0_1_22","id":"0_1_22_4","text":"临汾市","value":"临汾市","open":true},{"pId":"0_1_22","id":"0_1_22_5","text":"吕梁市","value":"吕梁市","open":true},{"pId":"0_1_22","id":"0_1_22_6","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_22","id":"0_1_22_7","text":"朔州市","value":"朔州市","open":true},{"pId":"0_1_22","id":"0_1_22_8","text":"太原市","value":"太原市","open":true},{"pId":"0_1_22","id":"0_1_22_9","text":"忻州市","value":"忻州市","open":true},{"pId":"0_1_22","id":"0_1_22_10","text":"阳泉市","value":"阳泉市","open":true},{"pId":"0_1_22","id":"0_1_22_11","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_23","text":"陕西省( 共9个 )","value":"陕西省","open":true},{"pId":"0_1_23","id":"0_1_23_0","text":"安康市","value":"安康市","open":true},{"pId":"0_1_23","id":"0_1_23_1","text":"宝鸡市","value":"宝鸡市","open":true},{"pId":"0_1_23","id":"0_1_23_2","text":"汉中市","value":"汉中市","open":true},{"pId":"0_1_23","id":"0_1_23_3","text":"商洛市","value":"商洛市","open":true},{"pId":"0_1_23","id":"0_1_23_4","text":"渭南市","value":"渭南市","open":true},{"pId":"0_1_23","id":"0_1_23_5","text":"西安市","value":"西安市","open":true},{"pId":"0_1_23","id":"0_1_23_6","text":"咸阳市","value":"咸阳市","open":true},{"pId":"0_1_23","id":"0_1_23_7","text":"延安市","value":"延安市","open":true},{"pId":"0_1_23","id":"0_1_23_8","text":"榆林市","value":"榆林市","open":true},{"pId":"0_1","id":"0_1_24","text":"上海市( 共19个 )","value":"上海市","open":true},{"pId":"0_1_24","id":"0_1_24_0","text":"宝山区","value":"宝山区","open":true},{"pId":"0_1_24","id":"0_1_24_1","text":"长宁区","value":"长宁区","open":true},{"pId":"0_1_24","id":"0_1_24_2","text":"崇明县","value":"崇明县","open":true},{"pId":"0_1_24","id":"0_1_24_3","text":"奉贤区","value":"奉贤区","open":true},{"pId":"0_1_24","id":"0_1_24_4","text":"虹口区","value":"虹口区","open":true},{"pId":"0_1_24","id":"0_1_24_5","text":"黄浦区","value":"黄浦区","open":true},{"pId":"0_1_24","id":"0_1_24_6","text":"嘉定区","value":"嘉定区","open":true},{"pId":"0_1_24","id":"0_1_24_7","text":"金山区","value":"金山区","open":true},{"pId":"0_1_24","id":"0_1_24_8","text":"静安区","value":"静安区","open":true},{"pId":"0_1_24","id":"0_1_24_9","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_24","id":"0_1_24_10","text":"闵行区","value":"闵行区","open":true},{"pId":"0_1_24","id":"0_1_24_11","text":"普陀区","value":"普陀区","open":true},{"pId":"0_1_24","id":"0_1_24_12","text":"浦东新区","value":"浦东新区","open":true},{"pId":"0_1_24","id":"0_1_24_13","text":"青浦区","value":"青浦区","open":true},{"pId":"0_1_24","id":"0_1_24_14","text":"上海市区","value":"上海市区","open":true},{"pId":"0_1_24","id":"0_1_24_15","text":"松江区","value":"松江区","open":true},{"pId":"0_1_24","id":"0_1_24_16","text":"徐汇区","value":"徐汇区","open":true},{"pId":"0_1_24","id":"0_1_24_17","text":"杨浦区","value":"杨浦区","open":true},{"pId":"0_1_24","id":"0_1_24_18","text":"闸北区","value":"闸北区","open":true},{"pId":"0_1","id":"0_1_25","text":"四川省( 共21个 )","value":"四川省","open":true},{"pId":"0_1_25","id":"0_1_25_0","text":"阿坝藏族羌族自治州","value":"阿坝藏族羌族自治州","open":true},{"pId":"0_1_25","id":"0_1_25_1","text":"巴中市","value":"巴中市","open":true},{"pId":"0_1_25","id":"0_1_25_2","text":"成都市","value":"成都市","open":true},{"pId":"0_1_25","id":"0_1_25_3","text":"达州市","value":"达州市","open":true},{"pId":"0_1_25","id":"0_1_25_4","text":"德阳市","value":"德阳市","open":true},{"pId":"0_1_25","id":"0_1_25_5","text":"甘孜市","value":"甘孜市","open":true},{"pId":"0_1_25","id":"0_1_25_6","text":"广安市","value":"广安市","open":true},{"pId":"0_1_25","id":"0_1_25_7","text":"广元市","value":"广元市","open":true},{"pId":"0_1_25","id":"0_1_25_8","text":"乐山市","value":"乐山市","open":true},{"pId":"0_1_25","id":"0_1_25_9","text":"凉山市","value":"凉山市","open":true},{"pId":"0_1_25","id":"0_1_25_10","text":"泸州市","value":"泸州市","open":true},{"pId":"0_1_25","id":"0_1_25_11","text":"眉山市","value":"眉山市","open":true},{"pId":"0_1_25","id":"0_1_25_12","text":"绵阳市","value":"绵阳市","open":true},{"pId":"0_1_25","id":"0_1_25_13","text":"南充市","value":"南充市","open":true},{"pId":"0_1_25","id":"0_1_25_14","text":"内江市","value":"内江市","open":true},{"pId":"0_1_25","id":"0_1_25_15","text":"攀枝花市","value":"攀枝花市","open":true},{"pId":"0_1_25","id":"0_1_25_16","text":"遂宁市","value":"遂宁市","open":true},{"pId":"0_1_25","id":"0_1_25_17","text":"雅安市","value":"雅安市","open":true},{"pId":"0_1_25","id":"0_1_25_18","text":"宜宾市","value":"宜宾市","open":true},{"pId":"0_1_25","id":"0_1_25_19","text":"资阳市","value":"资阳市","open":true},{"pId":"0_1_25","id":"0_1_25_20","text":"自贡市","value":"自贡市","open":true},{"pId":"0_1","id":"0_1_26","text":"台湾( 共1个 )","value":"台湾","open":true},{"pId":"0_1_26","id":"0_1_26_0","text":"台北市","value":"台北市","open":true},{"pId":"0_1","id":"0_1_27","text":"天津市( 共1个 )","value":"天津市","open":true},{"pId":"0_1_27","id":"0_1_27_0","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1","id":"0_1_28","text":"西藏自治区( 共2个 )","value":"西藏自治区","open":true},{"pId":"0_1_28","id":"0_1_28_0","text":"阿里市","value":"阿里市","open":true},{"pId":"0_1_28","id":"0_1_28_1","text":"日喀则市","value":"日喀则市","open":true},{"pId":"0_1","id":"0_1_29","text":"香港特别行政区( 共1个 )","value":"香港特别行政区","open":true},{"pId":"0_1_29","id":"0_1_29_0","text":"香港","value":"香港","open":true},{"pId":"0_1","id":"0_1_30","text":"新疆维吾尔族自治区( 共11个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_1_30","id":"0_1_30_0","text":"巴音郭楞市","value":"巴音郭楞市","open":true},{"pId":"0_1_30","id":"0_1_30_1","text":"哈密市","value":"哈密市","open":true},{"pId":"0_1_30","id":"0_1_30_2","text":"和田市","value":"和田市","open":true},{"pId":"0_1_30","id":"0_1_30_3","text":"喀什地区","value":"喀什地区","open":true},{"pId":"0_1_30","id":"0_1_30_4","text":"克拉玛依市","value":"克拉玛依市","open":true},{"pId":"0_1_30","id":"0_1_30_5","text":"克孜勒苏柯州","value":"克孜勒苏柯州","open":true},{"pId":"0_1_30","id":"0_1_30_6","text":"石河子市","value":"石河子市","open":true},{"pId":"0_1_30","id":"0_1_30_7","text":"塔城市","value":"塔城市","open":true},{"pId":"0_1_30","id":"0_1_30_8","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_1_30","id":"0_1_30_9","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_1_30","id":"0_1_30_10","text":"伊犁市","value":"伊犁市","open":true},{"pId":"0_1","id":"0_1_31","text":"云南省( 共12个 )","value":"云南省","open":true},{"pId":"0_1_31","id":"0_1_31_0","text":"保山市","value":"保山市","open":true},{"pId":"0_1_31","id":"0_1_31_1","text":"楚雄彝族自治州","value":"楚雄彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_2","text":"大理白族自治州","value":"大理白族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_3","text":"红河哈尼族彝族自治州","value":"红河哈尼族彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_4","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_31","id":"0_1_31_5","text":"丽江市","value":"丽江市","open":true},{"pId":"0_1_31","id":"0_1_31_6","text":"临沧市","value":"临沧市","open":true},{"pId":"0_1_31","id":"0_1_31_7","text":"曲靖市","value":"曲靖市","open":true},{"pId":"0_1_31","id":"0_1_31_8","text":"思茅市","value":"思茅市","open":true},{"pId":"0_1_31","id":"0_1_31_9","text":"文山市","value":"文山市","open":true},{"pId":"0_1_31","id":"0_1_31_10","text":"玉溪市","value":"玉溪市","open":true},{"pId":"0_1_31","id":"0_1_31_11","text":"昭通市","value":"昭通市","open":true},{"pId":"0_1","id":"0_1_32","text":"浙江省( 共12个 )","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_1_32","id":"0_1_32_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_1_32","id":"0_1_32_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_1_32","id":"0_1_32_3","text":"金华市","value":"金华市","open":true},{"pId":"0_1_32","id":"0_1_32_4","text":"丽水市","value":"丽水市","open":true},{"pId":"0_1_32","id":"0_1_32_5","text":"宁波市","value":"宁波市","open":true},{"pId":"0_1_32","id":"0_1_32_6","text":"衢州市","value":"衢州市","open":true},{"pId":"0_1_32","id":"0_1_32_7","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_1_32","id":"0_1_32_8","text":"台州市","value":"台州市","open":true},{"pId":"0_1_32","id":"0_1_32_9","text":"温州市","value":"温州市","open":true},{"pId":"0_1_32","id":"0_1_32_10","text":"浙江省","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_11","text":"舟山市","value":"舟山市","open":true},{"pId":"0_1","id":"0_1_33","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_1_33","id":"0_1_33_0","text":"重庆市区","value":"重庆市区","open":true}],
+
+ TREE:[{id: -1, pId: -2, value: "根目录", text: "根目录"},
+ {id: 1, pId: -1, value: "第一级目录1", text: "第一级目录1"},
+ {id: 11, pId: 1, value: "第二级文件1", text: "第二级文件1"},
+ {id: 12, pId: 1, value: "第二级目录2", text: "第二级目录2"},
+ {id: 121, pId: 12, value: "第三级目录1", text: "第三级目录1"},
+ {id: 122, pId: 12, value: "第三级文件1", text: "第三级文件1"},
+ {id: 1211, pId: 121, value: "第四级目录1", text: "第四级目录1"},
+ {id: 12111, pId: 1211, value: "第五级文件1", text: "第五级文件1"},
+ {id: 2, pId: -1, value: "第一级目录2", text: "第一级目录2"},
+ {id: 21, pId: 2, value: "第二级目录3", text: "第二级目录3"},
+ {id: 22, pId: 2, value: "第二级文件2", text: "第二级文件2"},
+ {id: 211, pId: 21, value: "第三级目录2", text: "第三级目录2"},
+ {id: 212, pId: 21, value: "第三级文件2", text: "第三级文件2"},
+ {id: 2111, pId: 211, value: "第四级文件1", text: "第四级文件1"}]
};
diff --git a/demo/css/main.css b/demo/css/main.css
index ab550ecc8..5cf3fdb8a 100644
--- a/demo/css/main.css
+++ b/demo/css/main.css
@@ -45,3 +45,49 @@ body {
.bi-theme-dark body {
background-color: #191B2B;
}
+.demo-editor {
+ border: 1px solid #cccccc;
+}
+.bi-slider-track .background-track {
+ background-color: rgba(153, 153, 153, 0);
+ _filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#33999999, 99, endColorstr=#33999999, 99);
+ -webkit-border-radius: 12px;
+ -moz-border-radius: 12px;
+ border-radius: 12px;
+}
+.bi-slider-track .gray-track {
+ background: #cccccc;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+.bi-slider-track .blue-track {
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+.widget-slider-icon .x-icon {
+ display: block;
+ background: url('icon/slider.png') no-repeat;
+ _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-normal.png');
+ _background: none;
+ background-size: 100% 100%;
+}
+.widget-slider-icon:hover .x-icon {
+ display: block;
+ background: url('icon/双向箭头.png') no-repeat;
+ _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
+ _background: none;
+ background-size: 100% 100%;
+}
+.widget-slider-icon::focus .x-icon {
+ display: block;
+ background: url('icon/双向箭头.png') no-repeat;
+ _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
+ _background: none;
+ background-size: 100% 100%;
+}
+.widget-slider-icon.native .x-icon,
+.widget-slider-icon.disabled .x-icon {
+ display: block;
+}
diff --git a/demo/js/config/base.js b/demo/js/config/base.js
index f3c020ded..f983e4a55 100644
--- a/demo/js/config/base.js
+++ b/demo/js/config/base.js
@@ -1,7 +1,7 @@
Demo.BASE_CONFIG = [{
id: 2,
text: "基础控件",
- open: true
+ open: false
}, {
pId: 2,
text: "bi.label",
diff --git a/demo/js/config/case.js b/demo/js/config/case.js
index 959d69ff1..3b477402b 100644
--- a/demo/js/config/case.js
+++ b/demo/js/config/case.js
@@ -1,7 +1,7 @@
Demo.CASE_CONFIG = [{
id: 3,
text: "实例控件",
- open: true,
+ open: false
}, {
pId: 3,
id: 301,
diff --git a/demo/js/config/widget.js b/demo/js/config/widget.js
index 49aaec038..80351ea3d 100644
--- a/demo/js/config/widget.js
+++ b/demo/js/config/widget.js
@@ -1,48 +1,269 @@
Demo.WIDGET_CONFIG = [{
- id: 4,
- text: "详细控件"
-}, {
- id: 401,
- pId: 4,
- text: "table"
-}, {
- pId: 401,
- text: "bi.preview_table",
- value: "demo.preview_table"
-}, {
- pId: 401,
- text: "bi.responsive_table",
- value: "demo.responsive_table"
-}, {
- pId: 401,
- text: "bi.sequence_table",
- value: "demo.sequence_table"
-}, {
- pId: 401,
- text: "bi.page_table",
- value: "demo.page_table"
-}, {
- id: 402,
- pId: 4,
- text: "tree"
-}, {
- pId: 402,
- text: "bi.multilayer_select_tree_combo",
- value: "demo.multilayer_select_tree_combo"
-}, {
- pId: 4,
- text: "bi.multi_select_combo",
- value: "demo.multi_select_combo"
-}, {
- pId: 4,
- text: "bi.path_chooser",
- value: "demo.path_chooser"
-}, {
- pId: 4,
- text: "bi.relation_view",
- value: "demo.relation_view"
-}, {
- pId: 4,
- text: "bi.interactive_arrangement",
- value: "demo.interactive_arrangement"
-}];
\ No newline at end of file
+ id: 4,
+ text: "详细控件",
+ open: true
+ }, {
+ id: 400,
+ pId: 4,
+ text: "tree"
+ }, {
+ pId: 400,
+ text: "bi.multi_tree_combo",
+ value: "demo.multi_tree_combo"
+ }, {
+ id: 401,
+ pId: 4,
+ text: "table"
+ }, {
+ pId: 401,
+ text: "bi.preview_table",
+ value: "demo.preview_table"
+ }, {
+ pId: 401,
+ text: "bi.responsive_table",
+ value: "demo.responsive_table"
+ }, {
+ pId: 401,
+ text: "bi.excel_table",
+ value: "demo.excel_table"
+ }, {
+ pId: 4,
+ id: 402,
+ text: "年份控件",
+ open: false
+ }, {
+ pId: 402,
+ text: "bi.year_combo",
+ value: "demo.year"
+ }, {
+ pId: 4,
+ id: 403,
+ text: "月份控件",
+ open: false
+ }, {
+ pId: 403,
+ text: "bi.month_combo",
+ value: "demo.month"
+ }, {
+ pId: 4,
+ id: 404,
+ text: "季度控件",
+ open: false
+ }, {
+ pId: 404,
+ text: "bi.quarter_combo",
+ value: "demo.quarter"
+ }, {
+ pId: 4,
+ id: 405,
+ text: "下拉列表",
+ open: false
+ }, {
+ pId: 405,
+ text: "bi.down_list_combo",
+ value: "demo.down_list"
+ }, {
+ pId: 4,
+ id: 406,
+ text: "文本框控件",
+ open: false
+ }, {
+ pId: 406,
+ text: "bi.text_editor",
+ value: "demo.text_editor"
+ }, {
+ pId: 406,
+ text: "bi.search_editor",
+ value: "demo.search_editor"
+ }, {
+ pId: 406,
+ text: "bi.sign_editor",
+ value: "demo.sign_editor"
+ }, {
+ pId: 406,
+ text: "bi.sign_initial_editor",
+ value: "demo.sign_initial_editor"
+ }, {
+ pId: 406,
+ text: "bi.sign_style_editor",
+ value: "demo.sign_style_editor"
+ }, {
+ pId: 406,
+ text: "bi.state_editor",
+ value: "demo.state_editor"
+ }, {
+ pId: 406,
+ text: "bi.clear_editor",
+ value: "demo.clear_editor"
+ }, {
+ pId: 406,
+ text: "bi.record_editor",
+ value: "demo.record_editor"
+ }, {
+ pId: 406,
+ text: "bi.shelter_editor",
+ value: "demo.shelter_editor"
+ },
+ {
+ pId: 4,
+ id: 407,
+ text: "下拉框控件",
+ open: false
+ }, {
+ pId: 407,
+ text: "bi.text_value_combo",
+ value: "demo.text_value_combo"
+ }, {
+ pId: 407,
+ text: "bi.text_value_check_combo",
+ value: "demo.text_value_check_combo"
+ }, {
+ pId: 407,
+ text: "bi.text_value_down_list_combo",
+ value: "demo.text_value_down_list_combo"
+ }, {
+ pId: 407,
+ text: "bi.static_combo",
+ value: "demo.static_combo"
+ }, {
+ pId: 407,
+ text: "bi.icon_combo",
+ value: "demo.icon_combo"
+ }, {
+ pId: 407,
+ text: "bi.formula_combo",
+ value: "demo.formula_combo"
+ }, {
+ pId: 4,
+ id: 408,
+ text: "选择字段列表",
+ open: false
+ }, {
+ pId: 408,
+ text: "bi.placeholder"
+ }, {
+ pId: 4,
+ id: 409,
+ text: "公式编辑器",
+ open: false
+ }, {
+ pId: 409,
+ text: "bi.placeholder"
+ }, {
+ pId: 4,
+ id: 410,
+ text: "数值区间控件"
+ }, {
+ pId: 410,
+ text: "bi.numerical_interval",
+ value: "demo.numberical_interval"
+ }, {
+ pId: 4,
+ id: 411,
+ text: "下拉复选框有确定按钮"
+ }, {
+ pId: 411,
+ text: "bi.multi_select_combo",
+ value: "demo.multi_select_combo"
+ }, {
+ pId: 4,
+ id: 412,
+ text: "简单日期控件"
+ }, {
+ pId: 412,
+ text: "bi.date_combo",
+ value: "demo.date"
+ }, {
+ pId: 412,
+ text: "bi.date_pane_widget",
+ value: "demo.date_pane_widget"
+ }, {
+ pId: 412,
+ text: "bi.year_month_combo",
+ value: "demo.year_month_combo"
+ },{
+ pId: 412,
+ text: "bi.year_quarter_combo",
+ value: "demo.year_quarter_combo"
+ },{
+ pId: 4,
+ id: 413,
+ text: "简单下拉树"
+ }, {
+ pId: 413,
+ text: "bi.single_tree_combo",
+ value: "demo.single_tree_combo"
+ }, {
+ pId: 413,
+ text: "bi.multilayer_single_tree_combo",
+ value: "demo.multilayer_single_tree_combo"
+ }, {
+ pId: 4,
+ id: 414,
+ text: "可选下拉树"
+ }, {
+ pId: 414,
+ text: "bi.select_tree_combo",
+ value: "demo.select_tree_combo"
+ }, {
+ pId: 414,
+ text: "bi.multilayer_select_tree_combo",
+ value: "demo.multilayer_select_tree_combo"
+ }, {
+ pId: 4,
+ id: 415,
+ text: "路径选择"
+ }, {
+ pId: 415,
+ text: "bi.path_chooser",
+ value: "demo.path_chooser"
+ }, {
+ pId: 415,
+ text: "bi.direction_path_chooser",
+ value: "demo.direction_path_chooser"
+ }, {
+ pId: 4,
+ id: 416,
+ text: "关联视图"
+ }, {
+ pId: 416,
+ text: "bi.relation_view",
+ value: "demo.relation_view"
+ }, {
+ pId: 4,
+ id: 417,
+ text: "布局"
+ }, {
+ pId: 417,
+ text: "bi.adaptive_arrangement",
+ value: "demo.adaptive_arrangement"
+ }, {
+ pId: 417,
+ text: "bi.interactive_arrangement",
+ value: "demo.interactive_arrangement"
+ }, {
+ pId: 4,
+ id: 418,
+ text: "提示对话框"
+ }, {
+ pId: 418,
+ text: "bi.dialog",
+ value: "demo.dialog"
+ }, {
+ pId: 4,
+ id: 419,
+ text: "单值滑块"
+ }, {
+ pId: 419,
+ text: "bi.single_slider",
+ value: "demo.single_slider"
+ },{
+ pId: 4,
+ id: 420,
+ text: "区间滑块"
+ }, {
+ pId: 420,
+ text: "bi.interval_slider",
+ value: "demo.interval_slider"
+ },
+];
\ No newline at end of file
diff --git a/demo/js/widget/arrangment/demo.adaptive_arrangement.js b/demo/js/widget/arrangment/demo.adaptive_arrangement.js
new file mode 100644
index 000000000..f6bb68f97
--- /dev/null
+++ b/demo/js/widget/arrangment/demo.adaptive_arrangement.js
@@ -0,0 +1,121 @@
+Demo.AdaptiveArrangement = BI.inherit(BI.Widget, {
+
+ _createItem: function () {
+ var self = this;
+ var id = BI.UUID();
+ var item = BI.createWidget({
+ type: "bi.text_button",
+ id: id,
+ cls: "layout-bg" + BI.random(1, 8),
+ handler: function () {
+ self.arrangement.deleteRegion(id);
+ }
+ });
+ item.setValue(item.attr("id"));
+ return item;
+ },
+
+ render: function () {
+ var self = this;
+ this.arrangement = BI.createWidget({
+ type: "bi.adaptive_arrangement",
+ layoutType: BI.Arrangement.LAYOUT_TYPE.ADAPTIVE,
+ cls: "mvc-border",
+ width: 800,
+ height: 400,
+ items: []
+ });
+ var drag = BI.createWidget({
+ type: "bi.label",
+ cls: "mvc-border",
+ width: 100,
+ height: 25,
+ text: "drag me"
+ });
+
+ // drag.element.draggable &&
+ drag.element.draggable({
+ revert: true,
+ cursorAt: {
+ left: 0,
+ top: 0
+ },
+ drag: function (e, ui) {
+ self.arrangement.setPosition({
+ left: ui.position.left,
+ top: ui.position.top
+ }, {
+ width: 300,
+ height: 200
+ })
+ },
+ stop: function (e, ui) {
+ self.arrangement.addRegion({
+ el: self._createItem()
+ });
+ },
+ helper: function (e) {
+ var helper = self.arrangement.getHelper();
+ return helper.element;
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: drag,
+ left: 30,
+ top: 450
+ }, {
+ el: this.arrangement,
+ left: 30,
+ top: 30
+ }, {
+ el: {
+ type: "bi.button",
+ text: "回撤",
+ height: 25,
+ handler: function () {
+ //self.arrangement.revoke();
+ }
+ },
+ left: 130,
+ top: 450
+ }, {
+ el: {
+ type: "bi.button",
+ text: "getAllRegions",
+ height: 25,
+ handler: function () {
+ var items = [];
+ BI.each(self.arrangement.getAllRegions(), function (i, region) {
+ items.push({
+ id: region.id,
+ left: region.left,
+ top: region.top,
+ width: region.width,
+ height: region.height
+ });
+ });
+ BI.Msg.toast(JSON.stringify(items));
+ }
+ },
+ left: 230,
+ top: 450
+ }, {
+ el: {
+ type: "bi.button",
+ text: "relayout",
+ height: 25,
+ handler: function () {
+ self.arrangement.relayout();
+ }
+ },
+ left: 330,
+ top: 450
+ }]
+ });
+ }
+});
+
+BI.shortcut("demo.adaptive_arrangement", Demo.AdaptiveArrangement);
\ No newline at end of file
diff --git a/demo/js/widget/demo.interactivearrangement.js b/demo/js/widget/arrangment/demo.interactive_arrangement.js
similarity index 100%
rename from demo/js/widget/demo.interactivearrangement.js
rename to demo/js/widget/arrangment/demo.interactive_arrangement.js
diff --git a/demo/js/widget/combo/demo.formula_combo.js b/demo/js/widget/combo/demo.formula_combo.js
new file mode 100644
index 000000000..71a42f8e2
--- /dev/null
+++ b/demo/js/widget/combo/demo.formula_combo.js
@@ -0,0 +1,31 @@
+/**
+ * Created by Dailer on 2017/7/12.
+ */
+Demo.FormulaCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+
+ var self = this;
+
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.formula_combo",
+ fieldItems: [{
+ text: "A",
+ value: "A",
+ fieldType: 16
+ }],
+ width: 200,
+ height: 30
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.formula_combo", Demo.FormulaCombo);
\ No newline at end of file
diff --git a/demo/js/widget/combo/demo.icon_combo.js b/demo/js/widget/combo/demo.icon_combo.js
new file mode 100644
index 000000000..90a4344c8
--- /dev/null
+++ b/demo/js/widget/combo/demo.icon_combo.js
@@ -0,0 +1,38 @@
+/**
+ * Created by Dailer on 2017/7/12.
+ */
+Demo.IconCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+
+ var self = this;
+
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.icon_combo",
+ ref:function(_ref){
+ self.refs=_ref;
+ },
+ // iconClass: "pull-down-ha-font",
+ items: [{
+ value: "第一项",
+ iconClass: "delete-font"
+ }, {
+ value: "第二项",
+ iconClass: "rename-font"
+ }, {
+ value: "第三项",
+ iconClass: "move-font"
+ }]
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.icon_combo", Demo.IconCombo);
\ No newline at end of file
diff --git a/demo/js/widget/combo/demo.static_combo.js b/demo/js/widget/combo/demo.static_combo.js
new file mode 100644
index 000000000..a62c03d03
--- /dev/null
+++ b/demo/js/widget/combo/demo.static_combo.js
@@ -0,0 +1,45 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.StaticCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+
+ beforeMounted: function () {
+ this.refs.setValue(2);
+ },
+
+ render: function () {
+
+ var self = this;
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.static_combo",
+ text: "Value 不变",
+ width: 300,
+ ref: function (_ref) {
+ self.refs = _ref;
+ },
+ items: [
+ {
+ text: "MVC-1",
+ value: 1
+ }, {
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }
+ ]
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.static_combo", Demo.StaticCombo);
\ No newline at end of file
diff --git a/demo/js/widget/combo/demo.text_value_combo.js b/demo/js/widget/combo/demo.text_value_combo.js
new file mode 100644
index 000000000..4966600df
--- /dev/null
+++ b/demo/js/widget/combo/demo.text_value_combo.js
@@ -0,0 +1,60 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.TextValueCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.text_value_combo",
+ text: "天气热死了",
+ width: 300,
+ items: [{
+ text: "MVC-1",
+ value: 1
+ }, {
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }]
+ },{
+ type: "bi.text_value_check_combo",
+ text: "天气热死了",
+ width: 300,
+ items: [{
+ text: "MVC-1",
+ value: 1
+ }, {
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }]
+ },{
+ type: "bi.text_value_combo",
+ text: "天气热死了",
+ width: 300,
+ items: [{
+ text: "MVC-1",
+ value: 1
+ }, {
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }]
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.text_value_combo", Demo.TextValueCombo);
\ No newline at end of file
diff --git a/demo/js/widget/combo/demo.text_value_down_list_combo.js b/demo/js/widget/combo/demo.text_value_down_list_combo.js
new file mode 100644
index 000000000..3be823d0b
--- /dev/null
+++ b/demo/js/widget/combo/demo.text_value_down_list_combo.js
@@ -0,0 +1,57 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.TextValueDownListCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+
+ beforeMounted:function(){
+ this.refs.setValue(2);
+ },
+
+ render: function () {
+
+ var self = this;
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.label",
+ cls: "layout-bg2",
+ text: "分组+二级",
+ width: 300
+ }, {
+ type: "bi.text_value_down_list_combo",
+ text: "天气热死了",
+ width: 300,
+ ref: function (_ref) {
+ self.refs = _ref;
+ },
+ items: [
+ [{
+ el: {
+ text: "MVC-1",
+ value: 1
+ },
+ children: [{
+ text: "MVC-1-1",
+ value: 11
+ }]
+ }],
+ [{
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }]
+ ]
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.text_value_down_list_combo", Demo.TextValueDownListCombo);
\ No newline at end of file
diff --git a/demo/js/widget/combo/demo.text_vlaue_check_combo.js b/demo/js/widget/combo/demo.text_vlaue_check_combo.js
new file mode 100644
index 000000000..bb0638da7
--- /dev/null
+++ b/demo/js/widget/combo/demo.text_vlaue_check_combo.js
@@ -0,0 +1,32 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.TextValueCheckCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.text_value_check_combo",
+ text: "天气热死了",
+ width: 300,
+ items: [{
+ text: "MVC-1",
+ value: 1
+ }, {
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }]
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.text_value_check_combo", Demo.TextValueCheckCombo);
\ No newline at end of file
diff --git a/demo/js/widget/date/demo.date.js b/demo/js/widget/date/demo.date.js
new file mode 100644
index 000000000..8b5665ce6
--- /dev/null
+++ b/demo/js/widget/date/demo.date.js
@@ -0,0 +1,31 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.Date = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-date"
+ },
+
+ _init: function () {
+ Demo.Date.superclass._init.apply(this, arguments);
+ },
+
+ render: function () {
+
+ return {
+ type: "bi.horizontal_auto",
+ vgap: 10,
+ items: [{
+ type: "bi.date_combo",
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ height: 50,
+ width: 300
+ }]
+ }
+ }
+})
+
+BI.shortcut("demo.date", Demo.Date);
\ No newline at end of file
diff --git a/demo/js/widget/date/demo.datepane.js b/demo/js/widget/date/demo.datepane.js
new file mode 100644
index 000000000..c3ba442fd
--- /dev/null
+++ b/demo/js/widget/date/demo.datepane.js
@@ -0,0 +1,39 @@
+Demo.DatePane = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-datepane"
+ },
+ render: function () {
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.vertical",
+ vgap: 10,
+ items: [{
+ type: "bi.label",
+ cls: "layout-bg2",
+ text: "bi.date_pane_widget"
+ }, {
+ type: "bi.date_pane_widget",
+ selectedTime: {
+ year: 2017,
+ month: 12,
+ day: 11
+ },
+ height:300
+ },
+ {
+ type: "bi.button",
+ text: "getValue",
+ handler: function () {
+ BI.Msg.toast("date" + JSON.stringify(datepane.getValue()));
+ }
+ }
+ ],
+ width: "50%"
+ }]
+ }
+ }
+})
+
+BI.shortcut("demo.date_pane_widget", Demo.DatePane);
\ No newline at end of file
diff --git a/demo/js/widget/dialog/demo.dialog.js b/demo/js/widget/dialog/demo.dialog.js
new file mode 100644
index 000000000..2e0ec34b0
--- /dev/null
+++ b/demo/js/widget/dialog/demo.dialog.js
@@ -0,0 +1,27 @@
+Demo.DialogView = BI.inherit(BI.Widget, {
+
+ render: function () {
+ var items = [{
+ el: {
+ type: 'bi.button',
+ text: '弹出对话框',
+ level: 'common',
+ height: 30
+ }
+ }];
+ BI.each(items, function (i, item) {
+ item.el.handler = function () {
+ BI.Msg.alert('提示', "这是一段可以换行的文字,为了使它换行我要多写几个字,但是我又凑不够这么多的字,万般焦急下,只能随便写写");
+ }
+ });
+
+ return {
+ type: "bi.left",
+ vgap: 200,
+ hgap: 20,
+ items: items
+ }
+ }
+});
+
+BI.shortcut("demo.dialog", Demo.DialogView);
\ No newline at end of file
diff --git a/demo/js/widget/downlist/demo.downlist.js b/demo/js/widget/downlist/demo.downlist.js
new file mode 100644
index 000000000..41d22d3df
--- /dev/null
+++ b/demo/js/widget/downlist/demo.downlist.js
@@ -0,0 +1,136 @@
+Demo.Downlist = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-downlist"
+ },
+
+ mounted: function () {
+ var downlist = this.downlist;
+ var label = this.label;
+ downlist.on(BI.DownListCombo.EVENT_CHANGE, function (value, fatherValue) {
+ label.setValue(JSON.stringify(downlist.getValue()));
+ });
+
+ this.downlist.on(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
+ label.setValue(JSON.stringify(downlist.getValue()));
+ });
+ },
+
+
+ render: function () {
+ self = this;
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.down_list_combo",
+ ref: function (_ref) {
+ self.downlist = _ref;
+ },
+ cls:"layout-bg3",
+ height: 30,
+ width: 100,
+ items: [
+ [{
+ el: {
+ text: "column 1111",
+ iconCls1: "check-mark-e-font",
+ value: 11
+ },
+ children: [{
+ text: "column 1.1",
+ value: 21,
+ cls: "dot-e-font",
+ selected: true
+ }, {
+ text: "column 1.222222222222222222222222222222222222",
+ cls: "dot-e-font",
+ value: 22,
+ }]
+ }],
+ [{
+ el: {
+ type: "bi.icon_text_icon_item",
+ text: "column 2",
+ iconCls1: "chart-type-e-font",
+ cls: "dot-e-font",
+ value: 12
+ },
+ disabled: true,
+ children: [{
+ type: "bi.icon_text_item",
+ cls: "dot-e-font",
+ height: 25,
+ text: "column 2.1",
+ value: 11
+ }, {
+ text: "column 2.2",
+ value: 12,
+ cls: "dot-e-font"
+ }]
+ }],
+ [{
+ text: "column 8",
+ value: 18,
+ cls: "dot-e-font",
+ selected: true
+ },
+ {
+
+ text: "column 9",
+ cls: "dot-e-font",
+ value: 19
+ }
+ ],
+ [{
+ text: "column 10",
+ value: 20,
+ cls: "dot-e-font",
+ selected: true
+ },
+ {
+
+ text: "column 11",
+ cls: "dot-e-font",
+ value: 21
+ },
+ {
+
+ text: "column 12",
+ cls: "dot-e-font",
+ value: 22
+ },
+ {
+
+ text: "column 13",
+ cls: "dot-e-font",
+ value: 23
+ },
+ {
+
+ text: "column 14",
+ cls: "dot-e-font",
+ value: 24
+ },
+ {
+
+ text: "column 15",
+ cls: "dot-e-font",
+ value: 23
+ }
+ ]
+
+ ]
+ }, {
+ type: "bi.label",
+ text: "显示选择值",
+ width:500,
+ cls:"layout-bg4",
+ ref: function (_ref) {
+ self.label = _ref;
+ }
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.down_list", Demo.Downlist);
\ No newline at end of file
diff --git a/demo/js/widget/editor/demo.adapt_editor.js b/demo/js/widget/editor/demo.adapt_editor.js
new file mode 100644
index 000000000..e32b1801c
--- /dev/null
+++ b/demo/js/widget/editor/demo.adapt_editor.js
@@ -0,0 +1,46 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.AdaptEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+
+
+ //这东西好奇怪,不支持设置宽度,那么渲染出来宽度几乎没有,无奈之下只能假装给他个默认值了
+ beforeMounted: function () {
+ this.refs.setValue("Winter is coming !")
+ },
+
+ render: function () {
+ var self = this;
+ var editor = BI.createWidget({
+ type: "bi.adapt_editor",
+ cls: "layout-bg5",
+ ref: function (_ref) {
+ self.refs = _ref;
+ }
+ })
+
+ var text=["You know nothing! Jon Snow","A Lannister always pays his debts.","Power is a curious thing."]
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ el: editor
+ }, {
+ type: "bi.button",
+ text: "为了展示长度真的是可变的,每点一下就换一行字",
+ handler: function () {
+ var temp=text.shift();
+ editor.setValue(temp);
+ text.push(temp);
+ }
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.adapt_editor", Demo.AdaptEditor);
\ No newline at end of file
diff --git a/demo/js/widget/editor/demo.clear_editor.js b/demo/js/widget/editor/demo.clear_editor.js
new file mode 100644
index 000000000..7e683b62b
--- /dev/null
+++ b/demo/js/widget/editor/demo.clear_editor.js
@@ -0,0 +1,22 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.ClearEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.clear_editor",
+ cls: "bi-border",
+ width: 300,
+ watermark: "这个是带清除按钮的"
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.clear_editor", Demo.ClearEditor);
\ No newline at end of file
diff --git a/demo/js/widget/editor/demo.record_editor.js b/demo/js/widget/editor/demo.record_editor.js
new file mode 100644
index 000000000..bb7de6923
--- /dev/null
+++ b/demo/js/widget/editor/demo.record_editor.js
@@ -0,0 +1,22 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.RecordEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.record_editor",
+ cls: "bi-border",
+ width: 300,
+ watermark: "这个是可以记录输入的"
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.record_editor", Demo.RecordEditor);
\ No newline at end of file
diff --git a/demo/js/widget/editor/demo.search_editor.js b/demo/js/widget/editor/demo.search_editor.js
new file mode 100644
index 000000000..020bf0d25
--- /dev/null
+++ b/demo/js/widget/editor/demo.search_editor.js
@@ -0,0 +1,29 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.SearchEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.search_editor",
+ width: 300,
+ watermark:"添加合法性判断",
+ errorText: "长度必须大于4",
+ validationChecker:function(){
+ return this.getValue().length > 4 ? true : false
+ }
+ },{
+ type: "bi.small_search_editor",
+ width: 300,
+ watermark:"这个是 small,小一号"
+ }],
+ vgap:20
+ }
+ }
+})
+
+BI.shortcut("demo.search_editor", Demo.SearchEditor);
\ No newline at end of file
diff --git a/demo/js/widget/editor/demo.shelter_editor.js b/demo/js/widget/editor/demo.shelter_editor.js
new file mode 100644
index 000000000..74914201b
--- /dev/null
+++ b/demo/js/widget/editor/demo.shelter_editor.js
@@ -0,0 +1,41 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.ClearEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ var editor;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.shelter_editor",
+ cls: "bi-border",
+ ref:function(_ref){
+ editor=_ref;
+ },
+ width: 300,
+ watermark: "这个是带标记的"
+ },{
+ type:"bi.button",
+ text:"setValue",
+ width:300,
+ handler:function(){
+ editor.setValue("凛冬将至");
+ }
+ },{
+ type:"bi.button",
+ text:"doHighLight",
+ width:300,
+ handler:function(){
+ editor.doHighLight();
+ console.log(editor.getState());
+ }
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.shelter_editor", Demo.ClearEditor);
\ No newline at end of file
diff --git a/demo/js/widget/editor/demo.sign_editor.js b/demo/js/widget/editor/demo.sign_editor.js
new file mode 100644
index 000000000..90f4f8448
--- /dev/null
+++ b/demo/js/widget/editor/demo.sign_editor.js
@@ -0,0 +1,24 @@
+/**
+ * Created by Dailer on 2017/7/14.
+ */
+Demo.SignEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.sign_editor",
+ // cls:"layout-bg5",
+ value: "123",
+ text: "456",
+ width: 300
+ }],
+ vgap: 20
+
+ }
+ }
+})
+
+BI.shortcut("demo.sign_editor", Demo.SignEditor);
\ No newline at end of file
diff --git a/demo/js/widget/editor/demo.sign_initial_editor.js b/demo/js/widget/editor/demo.sign_initial_editor.js
new file mode 100644
index 000000000..480d4d498
--- /dev/null
+++ b/demo/js/widget/editor/demo.sign_initial_editor.js
@@ -0,0 +1,24 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.SignInitialEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.sign_initial_editor",
+ cls:"layout-bg5",
+ value:"123",
+ text:"456",
+ width: 300
+ }],
+ vgap:20
+
+ }
+ }
+})
+
+BI.shortcut("demo.sign_initial_editor", Demo.SignInitialEditor);
\ No newline at end of file
diff --git a/demo/js/widget/editor/demo.sign_style_editor.js b/demo/js/widget/editor/demo.sign_style_editor.js
new file mode 100644
index 000000000..81f66c0e2
--- /dev/null
+++ b/demo/js/widget/editor/demo.sign_style_editor.js
@@ -0,0 +1,22 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.SignStyleEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.sign_style_editor",
+ cls:"layout-bg5",
+ value:"12313",
+ width: 300
+ }],
+ vgap:20
+ }
+ }
+})
+
+BI.shortcut("demo.sign_style_editor", Demo.SignStyleEditor);
\ No newline at end of file
diff --git a/demo/js/widget/editor/demo.state_editor.js b/demo/js/widget/editor/demo.state_editor.js
new file mode 100644
index 000000000..dedc7d024
--- /dev/null
+++ b/demo/js/widget/editor/demo.state_editor.js
@@ -0,0 +1,24 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.StateEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.state_editor",
+ cls:"bi-border",
+ value:"123",
+ text:"456",
+ width: 300
+ }],
+ vgap:20
+
+ }
+ }
+})
+
+BI.shortcut("demo.state_editor", Demo.StateEditor);
\ No newline at end of file
diff --git a/demo/js/widget/editor/demo.text_editor.js b/demo/js/widget/editor/demo.text_editor.js
new file mode 100644
index 000000000..db748cfbe
--- /dev/null
+++ b/demo/js/widget/editor/demo.text_editor.js
@@ -0,0 +1,28 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.TextEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.text_editor",
+ watermark:"这是水印,watermark",
+ width: 300
+ },{
+ type: "bi.text_editor",
+ watermark:"这个不予许空",
+ allowBlank: false,
+ errorText: "非空!",
+ width: 300
+ }],
+ vgap:20
+
+ }
+ }
+})
+
+BI.shortcut("demo.text_editor", Demo.TextEditor);
\ No newline at end of file
diff --git a/demo/js/widget/intervalslider/demo.interval_slider.js b/demo/js/widget/intervalslider/demo.interval_slider.js
new file mode 100644
index 000000000..aaa878496
--- /dev/null
+++ b/demo/js/widget/intervalslider/demo.interval_slider.js
@@ -0,0 +1,70 @@
+/**
+ * Created by Dailer on 2017/7/14.
+ */
+Demo.IntervalSlider = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+ var min = BI.createWidget({
+ type: "bi.text_editor",
+ watermark: "min",
+ width: 100
+ });
+ var max = BI.createWidget({
+ type: "bi.text_editor",
+ watermark: "max",
+ width: 100
+ })
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.interval_slider",
+ ref: function (_ref) {
+ self.slider = _ref;
+ },
+ width: 300,
+ height: 90
+ }, {
+ type: "bi.center_adapt",
+ width: 300,
+ items: [{
+ type: "bi.text",
+ text: "min"
+ }, min, {
+ type: "bi.text",
+ text: "max"
+ }, max]
+ }, {
+ type: "bi.button",
+ text: "populate",
+ handler: function () {
+ self.slider.setMinAndMax({
+ min: min.getValue() || 0,
+ max: max.getValue() || 100
+ });
+ self.slider.populate();
+ },
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "setValue",
+ handler: function () {
+
+ //既然 setVlaue后要重新 populate 才能生效,为何不直接在 setValue方法的结尾调用 populate 方法呢?
+ self.slider.setValue({
+ min: 20,
+ max: 80
+ });
+ self.slider.populate();
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.interval_slider", Demo.IntervalSlider);
\ No newline at end of file
diff --git a/demo/js/widget/month/demo.month.js b/demo/js/widget/month/demo.month.js
new file mode 100644
index 000000000..c40ccdad9
--- /dev/null
+++ b/demo/js/widget/month/demo.month.js
@@ -0,0 +1,20 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.Month = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.month_combo",
+ width: 300
+ }]
+
+ }
+ }
+})
+
+BI.shortcut("demo.month", Demo.Month);
\ No newline at end of file
diff --git a/demo/js/widget/demo.multiselectcombo.js b/demo/js/widget/multiselect/demo.multi_select_combo.js
similarity index 91%
rename from demo/js/widget/demo.multiselectcombo.js
rename to demo/js/widget/multiselect/demo.multi_select_combo.js
index 431982b93..57b3df91f 100644
--- a/demo/js/widget/demo.multiselectcombo.js
+++ b/demo/js/widget/multiselect/demo.multi_select_combo.js
@@ -44,8 +44,8 @@ Demo.MultiSelectCombo = BI.inherit(BI.Widget, {
var search = BI.Func.getSearchResult(items, kw);
items = search.matched.concat(search.finded);
});
- if (options.selectedValues) {//过滤
- var filter = BI.makeObject(options.selectedValues, true);
+ if (options.selected_values) {//过滤
+ var filter = BI.makeObject(options.selected_values, true);
items = BI.filter(items, function (i, ob) {
return !filter[ob.value];
});
@@ -74,7 +74,7 @@ Demo.MultiSelectCombo = BI.inherit(BI.Widget, {
scrolly: false,
items: [{
el: this._createMultiSelectCombo(),
- right: 10,
+ right: "50%",
top: 10
}]
}
diff --git a/demo/js/widget/multitree/demo.multi_tree_combo.js b/demo/js/widget/multitree/demo.multi_tree_combo.js
new file mode 100644
index 000000000..f1716f8ef
--- /dev/null
+++ b/demo/js/widget/multitree/demo.multi_tree_combo.js
@@ -0,0 +1,41 @@
+/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.MultiTreeCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+ var items = BI.deepClone(Demo.CONSTANTS.TREE);
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.multi_tree_combo",
+ ref: function (_ref) {
+ self.tree = _ref;
+ },
+ itemsCreator: function (options, callback) {
+ console.log(options);
+
+
+ callback({
+ items: items
+ });
+ },
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(JSON.stringify(self.tree.getValue()));
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.multi_tree_combo", Demo.MultiTreeCombo);
\ No newline at end of file
diff --git a/demo/js/widget/numericalinterval/demo.numerical_interval.js b/demo/js/widget/numericalinterval/demo.numerical_interval.js
new file mode 100644
index 000000000..b11680a1d
--- /dev/null
+++ b/demo/js/widget/numericalinterval/demo.numerical_interval.js
@@ -0,0 +1,44 @@
+/**
+ * Created by Dailer on 2017/7/12.
+ */
+Demo.NumericalInterval = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+
+ mounted: function () {
+ var numerical = this.numerical;
+ var label = this.label;
+ numerical.on(BI.NumericalInterval.EVENT_CHANGE, function () {
+ var temp = numerical.getValue();
+ var res = "大于" + (temp.closemin ? "等于 " : " ") + temp.min + " 小于" + (temp.closemax ? "等于 " : " ") + temp.max;
+ label.setValue(res);
+ })
+ },
+
+
+
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.numerical_interval",
+ ref: function (_ref) {
+ self.numerical = _ref;
+ },
+ width: 500
+ }, {
+ type: "bi.label",
+ ref: function (_ref) {
+ self.label = _ref;
+ },
+ text: "显示结果"
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.numberical_interval", Demo.NumericalInterval);
\ No newline at end of file
diff --git a/demo/js/widget/pathchooser/demo.directionpathchooser.js b/demo/js/widget/pathchooser/demo.directionpathchooser.js
new file mode 100644
index 000000000..647521fe9
--- /dev/null
+++ b/demo/js/widget/pathchooser/demo.directionpathchooser.js
@@ -0,0 +1,77 @@
+
+
+
+Demo.DirectionPathChooser = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-direction-path-chooser"
+ },
+
+ render: function () {
+ return {
+ type: "bi.center_adapt",
+ items: [
+ {
+ type: "bi.direction_path_chooser",
+ items: [[{
+ "region": "8c4460bc3605685e",
+ "regionText": "采购订单XXX",
+ "text": "ID",
+ "value": "1"
+ }, {
+ "region": "0fbd0dc648f41e97",
+ "regionText": "采购订单",
+ "text": "学号",
+ "value": "3"
+ }, {
+ "region": "c6d72d6c7e19a667",
+ "regionText": "供应商基本信息",
+ "text": "ID",
+ "value": "5"
+ }], [{
+ "region": "ed013e18cc7c8637",
+ "regionText": "采购订单XXX",
+ "text": "ID",
+ "value": "1"
+ }, {
+ "region": "153d75878431f8ee",
+ "regionText": "A3",
+ "text": "学号",
+ "value": "2"
+ }, {
+ "region": "3861fb024c7d7825",
+ "regionText": "采购订单",
+ "text": "学号",
+ "value": "3"
+ }, {
+ "region": "88e3e5071bd10bc5",
+ "regionText": "供应商",
+ "text": "ID",
+ "value": "4"
+ }, {
+ "region": "8476c77ab5c147e0",
+ "regionText": "供应商基本信息",
+ "text": "ID",
+ "value": "5"
+ }], [{
+ "region": "f00f67fbb9fba6fe",
+ "regionText": "采购订单XXX",
+ "text": "ID",
+ "value": "1"
+ }, {
+ "region": "1e8badf5d5793408",
+ "regionText": "A3",
+ "text": "学号",
+ "value": "2"
+ }, {
+ "region": "de1ebd3d0986a294",
+ "regionText": "供应商基本信息",
+ "text": "ID",
+ "value": "5"
+ }]]
+ }
+ ]
+ }
+ }
+})
+
+BI.shortcut("demo.direction_path_chooser",Demo.DirectionPathChooser);
\ No newline at end of file
diff --git a/demo/js/widget/demo.pathchooser.js b/demo/js/widget/pathchooser/demo.pathchooser.js
similarity index 100%
rename from demo/js/widget/demo.pathchooser.js
rename to demo/js/widget/pathchooser/demo.pathchooser.js
diff --git a/demo/js/widget/quarter/demo.quarter.js b/demo/js/widget/quarter/demo.quarter.js
new file mode 100644
index 000000000..bad058e63
--- /dev/null
+++ b/demo/js/widget/quarter/demo.quarter.js
@@ -0,0 +1,20 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.Quarter = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.quarter_combo",
+ width: 300
+ }]
+
+ }
+ }
+})
+
+BI.shortcut("demo.quarter", Demo.Quarter);
\ No newline at end of file
diff --git a/demo/js/widget/demo.relationview.js b/demo/js/widget/relationview/demo.relationview.js
similarity index 100%
rename from demo/js/widget/demo.relationview.js
rename to demo/js/widget/relationview/demo.relationview.js
diff --git a/demo/js/widget/selecttree/demo.multilayer_select_tree_combo.js b/demo/js/widget/selecttree/demo.multilayer_select_tree_combo.js
new file mode 100644
index 000000000..a50862225
--- /dev/null
+++ b/demo/js/widget/selecttree/demo.multilayer_select_tree_combo.js
@@ -0,0 +1,35 @@
+/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+ var items = BI.deepClone(Demo.CONSTANTS.TREE);
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.multilayer_select_tree_combo",
+ ref: function (_ref) {
+ self.tree = _ref;
+ },
+ text: "默认值",
+ items: items,
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(self.tree.getValue()[0]);
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiLayerSelectTreeCombo);
\ No newline at end of file
diff --git a/demo/js/widget/selecttree/demo.select_tree_combo.js b/demo/js/widget/selecttree/demo.select_tree_combo.js
new file mode 100644
index 000000000..5eeac55a3
--- /dev/null
+++ b/demo/js/widget/selecttree/demo.select_tree_combo.js
@@ -0,0 +1,182 @@
+/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.SelectTreeCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+
+ render: function () {
+ var self = this;
+ var items = [{
+ id: 1,
+ text: "第一项",
+ value: 1,
+ isParent: true,
+ title: "第一项"
+ }, {
+ id: 2,
+ text: "第二项",
+ value: 2,
+ isParent: true,
+ title: "第二项"
+ }, {
+ id: 3,
+ text: "第三项",
+ value: 3,
+ isParent: true,
+ open: true,
+ title: "第三项"
+ }, {
+ id: 4,
+ text: "第四项",
+ value: 4,
+ isParent: true,
+ title: "第四项"
+ }, {
+ id: 5,
+ text: "第五项",
+ value: 5,
+ isParent: true,
+ title: "第五项"
+ }, {
+ id: 6,
+ text: "第六项",
+ value: 6,
+ isParent: true,
+ open: true,
+ title: "第六项"
+ }, {
+ id: 7,
+ text: "第七项",
+ value: 7,
+ isParent: true,
+ open: true,
+ title: "第七项"
+ }, {
+ id: 11,
+ pId: 1,
+ text: "子项1",
+ value: 11,
+ title: "子项1"
+ }, {
+ id: 12,
+ pId: 1,
+ text: "子项2",
+ value: 12,
+ title: "子项2"
+ }, {
+ id: 13,
+ pId: 1,
+ text: "子项3",
+ value: 13,
+ title: "子项3"
+ }, {
+ id: 21,
+ pId: 2,
+ text: "子项1",
+ value: 21,
+ title: "子项1"
+ }, {
+ id: 22,
+ pId: 2,
+ text: "子项2",
+ value: 22,
+ title: "子项2"
+ }, {
+ id: 31,
+ pId: 3,
+ text: "子项1",
+ value: 31,
+ title: "子项1"
+ }, {
+ id: 32,
+ pId: 3,
+ text: "子项2",
+ value: 32,
+ title: "子项2"
+ }, {
+ id: 33,
+ pId: 3,
+ text: "子项3",
+ value: 33,
+ title: "子项3"
+ }, {
+ id: 41,
+ pId: 4,
+ text: "子项1",
+ value: 41,
+ title: "子项1"
+ }, {
+ id: 42,
+ pId: 4,
+ text: "子项2",
+ value: 42,
+ title: "子项2"
+ }, {
+ id: 43,
+ pId: 4,
+ text: "子项3",
+ value: 43,
+ title: "子项3"
+ }, {
+ id: 51,
+ pId: 5,
+ text: "子项1",
+ value: 51,
+ title: "子项1"
+ }, {
+ id: 52,
+ pId: 5,
+ text: "子项2",
+ value: 52,
+ title: "子项2"
+ }, {
+ id: 61,
+ pId: 6,
+ text: "子项1",
+ value: 61,
+ title: "子项1"
+ }, {
+ id: 62,
+ pId: 6,
+ text: "子项2",
+ value: 62,
+ title: "子项2"
+ }, {
+ id: 71,
+ pId: 7,
+ text: "子项1",
+ value: 71,
+ title: "子项1"
+ }, {
+ id: 72,
+ pId: 7,
+ text: "子项2",
+ value: 72,
+ title: "子项2"
+ }];
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.select_tree_combo",
+ ref: function (_ref) {
+ self.tree = _ref;
+ },
+ text: "默认值",
+ items: items,
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(self.tree.getValue()[0]);
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.select_tree_combo", Demo.SelectTreeCombo);
\ No newline at end of file
diff --git a/demo/js/widget/singleslider/demo.single_slider.js b/demo/js/widget/singleslider/demo.single_slider.js
new file mode 100644
index 000000000..c40467874
--- /dev/null
+++ b/demo/js/widget/singleslider/demo.single_slider.js
@@ -0,0 +1,48 @@
+/**
+ * Created by Dailer on 2017/7/14.
+ */
+Demo.SingleSlider = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.single_slider",
+ ref: function (_ref) {
+ self.slider = _ref;
+ },
+ width: 300,
+ height: 50
+ }, {
+ type: "bi.button",
+ text: "populate",
+ handler: function () {
+ self.slider.setMinAndMax({
+ min: 1,
+ max: 100
+ });
+ self.slider.populate();
+ },
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "setValue",
+ handler: function () {
+
+ //既然 setVlaue后要重新 populate 才能生效,为何不直接在 setValue方法的结尾调用 populate 方法呢?
+ self.slider.setValue(50);
+ self.slider.populate();
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.single_slider", Demo.SingleSlider);
\ No newline at end of file
diff --git a/demo/js/widget/singletree/demo.multilayer_single_tree_combo.js b/demo/js/widget/singletree/demo.multilayer_single_tree_combo.js
new file mode 100644
index 000000000..42f06052b
--- /dev/null
+++ b/demo/js/widget/singletree/demo.multilayer_single_tree_combo.js
@@ -0,0 +1,35 @@
+/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+ var items = BI.deepClone(Demo.CONSTANTS.TREE);
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.multilayer_single_tree_combo",
+ ref: function (_ref) {
+ self.tree = _ref;
+ },
+ text: "默认值",
+ items: items,
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(self.tree.getValue()[0]);
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.multilayer_single_tree_combo", Demo.MultiLayerSingleTreeCombo);
\ No newline at end of file
diff --git a/demo/js/widget/singletree/demo.single_tree_combo.js b/demo/js/widget/singletree/demo.single_tree_combo.js
new file mode 100644
index 000000000..208dec66d
--- /dev/null
+++ b/demo/js/widget/singletree/demo.single_tree_combo.js
@@ -0,0 +1,181 @@
+/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.SingleTreeCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.single_tree_combo",
+ ref: function (_ref) {
+ self.tree = _ref;
+ },
+ text: "默认值",
+ items: [{
+ id: 1,
+ text: "第一项",
+ value: 1,
+ isParent: true,
+ title: "第一项"
+ }, {
+ id: 2,
+ text: "第二项",
+ value: 1,
+ isParent: true,
+ title: "第二项"
+ }, {
+ id: 3,
+ text: "第三项",
+ value: 1,
+ isParent: true,
+ open: true,
+ title: "第三项"
+ }, {
+ id: 4,
+ text: "第四项",
+ value: 1,
+ isParent: true,
+ title: "第四项"
+ }, {
+ id: 5,
+ text: "第五项",
+ value: 1,
+ isParent: true,
+ title: "第五项"
+ }, {
+ id: 6,
+ text: "第六项",
+ value: 1,
+ isParent: true,
+ open: true,
+ title: "第六项"
+ }, {
+ id: 7,
+ text: "第七项",
+ value: 1,
+ isParent: true,
+ open: true,
+ title: "第七项"
+ }, {
+ id: 11,
+ pId: 1,
+ text: "子项1",
+ value: 11,
+ title: "子项1"
+ }, {
+ id: 12,
+ pId: 1,
+ text: "子项2",
+ value: 12,
+ title: "子项2"
+ }, {
+ id: 13,
+ pId: 1,
+ text: "子项3",
+ value: 13,
+ title: "子项3"
+ }, {
+ id: 21,
+ pId: 2,
+ text: "子项1",
+ value: 21,
+ title: "子项1"
+ }, {
+ id: 22,
+ pId: 2,
+ text: "子项2",
+ value: 22,
+ title: "子项2"
+ }, {
+ id: 31,
+ pId: 3,
+ text: "子项1",
+ value: 31,
+ title: "子项1"
+ }, {
+ id: 32,
+ pId: 3,
+ text: "子项2",
+ value: 32,
+ title: "子项2"
+ }, {
+ id: 33,
+ pId: 3,
+ text: "子项3",
+ value: 33,
+ title: "子项3"
+ }, {
+ id: 41,
+ pId: 4,
+ text: "子项1",
+ value: 41,
+ title: "子项1"
+ }, {
+ id: 42,
+ pId: 4,
+ text: "子项2",
+ value: 42,
+ title: "子项2"
+ }, {
+ id: 43,
+ pId: 4,
+ text: "子项3",
+ value: 43,
+ title: "子项3"
+ }, {
+ id: 51,
+ pId: 5,
+ text: "子项1",
+ value: 51,
+ title: "子项1"
+ }, {
+ id: 52,
+ pId: 5,
+ text: "子项2",
+ value: 52,
+ title: "子项2"
+ }, {
+ id: 61,
+ pId: 6,
+ text: "子项1",
+ value: 61,
+ title: "子项1"
+ }, {
+ id: 62,
+ pId: 6,
+ text: "子项2",
+ value: 62,
+ title: "子项2"
+ }, {
+ id: 71,
+ pId: 7,
+ text: "子项1",
+ value: 71,
+ title: "子项1"
+ }, {
+ id: 72,
+ pId: 7,
+ text: "子项2",
+ value: 72,
+ title: "子项2"
+ }],
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(self.tree.getValue()[0]);
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.single_tree_combo", Demo.SingleTreeCombo);
\ No newline at end of file
diff --git a/demo/js/widget/table/demo.excel_table.js b/demo/js/widget/table/demo.excel_table.js
new file mode 100644
index 000000000..5e518d165
--- /dev/null
+++ b/demo/js/widget/table/demo.excel_table.js
@@ -0,0 +1,40 @@
+/**
+ * Created by Dailer on 2017/7/12.
+ */
+Demo.ExcelTable = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.excel_table",
+ columnSize: [200,200,200,200,200],
+ items: [
+ [{
+ type: "bi.label",
+ cls: "layout-bg1",
+ text: "第一行第一列"
+ }, {
+ type: "bi.label",
+ cls: "layout-bg2",
+ text: "第一行第二列"
+ }],
+ [{
+ type: "bi.label",
+ cls: "layout-bg3",
+ text: "第二行第一列"
+ }, {
+ type: "bi.label",
+ cls: "layout-bg4",
+ text: "第二行第二列"
+ }]
+ ]
+ }],
+ width:500
+ }
+ }
+})
+
+BI.shortcut("demo.excel_table", Demo.ExcelTable);
\ No newline at end of file
diff --git a/demo/js/widget/timeinterval/demo.time_interval.js b/demo/js/widget/timeinterval/demo.time_interval.js
new file mode 100644
index 000000000..d473da5dd
--- /dev/null
+++ b/demo/js/widget/timeinterval/demo.time_interval.js
@@ -0,0 +1,33 @@
+/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.TimeInterval = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+ var items = BI.deepClone(Demo.CONSTANTS.TREE);
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.time_interval",
+ ref: function (_ref) {
+ self.interval = _ref;
+ },
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(JSON.stringify(self.interval.getValue()));
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.time_interval", Demo.TimeInterval);
\ No newline at end of file
diff --git a/demo/js/widget/tree/demo.multilayer_select_tree_combo.js b/demo/js/widget/tree/demo.multilayer_select_tree_combo.js
deleted file mode 100644
index 4968bb7b1..000000000
--- a/demo/js/widget/tree/demo.multilayer_select_tree_combo.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Created by User on 2017/3/22.
- */
-Demo.MultiSelectCombo = BI.inherit(BI.Widget, {
- props: {},
-
- render: function (vessel) {
- var TREEWITHCHILDREN = [{
- id: -1, value: "根目录", text: "根目录", children: [
- {
- id: 1, value: "第一级目录1", text: "第一级目录1", children: [
- {id: 11, value: "第二级文件1", text: "第二级文件1"},
- {
- id: 12, value: "第二级目录2", text: "第二级目录2", children: [
- {
- id: 121, value: "第三级目录1", text: "第三级目录1", children: [
- {
- id: 1211, value: "第四级目录1", text: "第四级目录1", children: [
- {id: 12111, value: "第五级文件1", text: "第五级文件1"}
- ]
- }
- ]
- },
- {id: 122, value: "第三级文件1", text: "第三级文件1"}
- ]
- }
- ]
- },
- {
- id: 2, value: "第一级目录2", text: "第一级目录2", children: [
- {
- id: 21, value: "第二级目录3", text: "第二级目录3", children: [
- {
- id: 211, value: "第三级目录2", text: "第三级目录2", children: [
- {id: 2111, value: "第四级文件1", text: "第四级文件1"}
- ]
- },
- {id: 212, value: "第三级文件2", text: "第三级文件2"}
- ]
- },
- {id: 22, value: "第二级文件2", text: "第二级文件2"}
- ]
- }
- ]
- }];
- var items = BI.deepClone(TREEWITHCHILDREN);
- var combo = BI.createWidget({
- type: "bi.multilayer_select_tree_combo",
- });
-
- combo.populate(items);
- return {
- type: "bi.vertical",
- items: [combo, {
- type: "bi.button",
- width: 100,
- text: "getValue",
- handler: function () {
- BI.Msg.alert("", JSON.stringify(combo.getValue()));
- }
- }],
- vgap: 100
- }
- }
-});
-BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiSelectCombo);
\ No newline at end of file
diff --git a/demo/js/widget/tree/demo.switch_tree.js b/demo/js/widget/tree/demo.switch_tree.js
new file mode 100644
index 000000000..0e7a1788d
--- /dev/null
+++ b/demo/js/widget/tree/demo.switch_tree.js
@@ -0,0 +1,24 @@
+/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.SwitchTree = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+
+ var items = BI.deepClone(Demo.CONSTANTS.TREE);
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.switch_tree",
+ items: items
+ },{
+ type:"bi.button",
+ text:"getValue"
+ }]
+ }
+ }
+})
+
+BI.shortcut("demo.switch_tree", Demo.SwitchTree);
\ No newline at end of file
diff --git a/demo/js/widget/year/demo.year.js b/demo/js/widget/year/demo.year.js
new file mode 100644
index 000000000..810b224b9
--- /dev/null
+++ b/demo/js/widget/year/demo.year.js
@@ -0,0 +1,19 @@
+/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.Year = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.year_combo",
+ width: 300
+ }]
+ }
+ }
+})
+
+BI.shortcut("demo.year", Demo.Year);
\ No newline at end of file
diff --git a/demo/js/widget/yearmonth/demo.year_month_combo.js b/demo/js/widget/yearmonth/demo.year_month_combo.js
new file mode 100644
index 000000000..02ab8af65
--- /dev/null
+++ b/demo/js/widget/yearmonth/demo.year_month_combo.js
@@ -0,0 +1,32 @@
+/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.YearMonthCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+
+ var self = this;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.year_month_combo",
+ ref: function (_ref) {
+ self.widget = _ref;
+ },
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getValue",
+ handler: function () {
+ BI.Msg.toast(JSON.stringify(self.widget.getValue()))
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.year_month_combo", Demo.YearMonthCombo);
\ No newline at end of file
diff --git a/demo/js/widget/yearquarter/demo.year_quarter_combo.js b/demo/js/widget/yearquarter/demo.year_quarter_combo.js
new file mode 100644
index 000000000..ddd9cccf2
--- /dev/null
+++ b/demo/js/widget/yearquarter/demo.year_quarter_combo.js
@@ -0,0 +1,33 @@
+/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.YearQuarterCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ var self=this;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.year_quarter_combo",
+ width: 300,
+ ref:function(_ref){
+ self.widget=_ref;
+ },
+ yearBehaviors: {},
+ quarterBehaviors: {},
+ }, {
+ type: "bi.button",
+ text: "getValue",
+ handler:function(){
+ BI.Msg.toast(JSON.stringify(self.widget.getValue()))
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.year_quarter_combo", Demo.YearQuarterCombo);
\ No newline at end of file
diff --git a/demo/less/main.less b/demo/less/main.less
index 662c65ed7..a722d266f 100644
--- a/demo/less/main.less
+++ b/demo/less/main.less
@@ -1,5 +1,4 @@
@import "index";
-
.layout-bg-white {
background-color: #ffffff;
}
@@ -60,4 +59,64 @@ body {
.bi-theme-dark body {
background-color: @color-bi-background-normal-theme-dark;
+}
+
+.demo-editor {
+ border: 1px solid rgb(204, 204, 204);
+}
+
+.bi-slider-track {
+ .background-track {
+ background-color: rgba(153, 153, 153, 0);
+ _filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#33999999, endColorstr=#33999999);
+ -webkit-border-radius: 12px;
+ -moz-border-radius: 12px;
+ border-radius: 12px;
+ }
+ .gray-track {
+ background: #cccccc;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ }
+ .blue-track {
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ }
+}
+
+.widget-slider-icon {
+ .x-icon {
+ display: block;
+ background: url('./icon/slider.png') no-repeat;
+ _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-normal.png');
+ _background: none;
+ background-size: 100% 100%;
+ }
+ &:hover {
+ .x-icon {
+ display: block;
+ background: url('./icon/双向箭头.png') no-repeat;
+ _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
+ _background: none;
+ background-size: 100% 100%;
+ }
+ }
+ &::focus {
+ .x-icon {
+ display: block;
+ background: url('./icon/双向箭头.png') no-repeat;
+ _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
+ _background: none;
+ background-size: 100% 100%;
+ }
+ }
+}
+
+.widget-slider-icon.native,
+.widget-slider-icon.disabled {
+ .x-icon {
+ display: block;
+ }
}
\ No newline at end of file
diff --git a/docs/core.js b/docs/core.js
index 398c89578..1658c3c94 100644
--- a/docs/core.js
+++ b/docs/core.js
@@ -1,3 +1,28683 @@
+<<<<<<< HEAD
+/*!
+ * jQuery JavaScript Library v1.9.1
+ * http://jquery.com/
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ *
+ * Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: 2013-2-4
+ */
+(function( window, undefined ) {
+
+// Can't do this because several apps including ASP.NET trace
+// the stack via arguments.caller.callee and Firefox dies if
+// you try to trace through "use strict" call chains. (#13335)
+// Support: Firefox 18+
+//"use strict";
+var
+ // The deferred used on DOM ready
+ readyList,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // Support: IE<9
+ // For `typeof node.method` instead of `node.method !== undefined`
+ core_strundefined = typeof undefined,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+ location = window.location,
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // [[Class]] -> type pairs
+ class2type = {},
+
+ // List of deleted data cache ids, so we can reuse them
+ core_deletedIds = [],
+
+ core_version = "1.9.1",
+
+ // Save a reference to some core methods
+ core_concat = core_deletedIds.concat,
+ core_push = core_deletedIds.push,
+ core_slice = core_deletedIds.slice,
+ core_indexOf = core_deletedIds.indexOf,
+ core_toString = class2type.toString,
+ core_hasOwn = class2type.hasOwnProperty,
+ core_trim = core_version.trim,
+
+ // Define a local copy of jQuery
+ jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context, rootjQuery );
+ },
+
+ // Used for matching numbers
+ core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,
+
+ // Used for splitting on whitespace
+ core_rnotwhite = /\S+/g,
+
+ // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
+ rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
+
+ // A simple way to check for HTML strings
+ // Prioritize #id over to avoid XSS via location.hash (#9521)
+ // Strict HTML recognition (#11290: must start with <)
+ rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
+
+ // JSON RegExp
+ rvalidchars = /^[\],:{}\s]*$/,
+ rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
+ rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
+ rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,
+
+ // Matches dashed string for camelizing
+ rmsPrefix = /^-ms-/,
+ rdashAlpha = /-([\da-z])/gi,
+
+ // Used by jQuery.camelCase as callback to replace()
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ },
+
+ // The ready event handler
+ completed = function( event ) {
+
+ // readyState === "complete" is good enough for us to call the dom ready in oldIE
+ if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
+ detach();
+ jQuery.ready();
+ }
+ },
+ // Clean-up method for dom ready events
+ detach = function() {
+ if ( document.addEventListener ) {
+ document.removeEventListener( "DOMContentLoaded", completed, false );
+ window.removeEventListener( "load", completed, false );
+
+ } else {
+ document.detachEvent( "onreadystatechange", completed );
+ window.detachEvent( "onload", completed );
+ }
+ };
+
+jQuery.fn = jQuery.prototype = {
+ // The current version of jQuery being used
+ jquery: core_version,
+
+ constructor: jQuery,
+ init: function( selector, context, rootjQuery ) {
+ var match, elem;
+
+ // HANDLE: $(""), $(null), $(undefined), $(false)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
+ // Assume that strings that start and end with <> are HTML and skip the regex check
+ match = [ null, selector, null ];
+
+ } else {
+ match = rquickExpr.exec( selector );
+ }
+
+ // Match html or make sure no context is specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ context = context instanceof jQuery ? context[0] : context;
+
+ // scripts is true for back-compat
+ jQuery.merge( this, jQuery.parseHTML(
+ match[1],
+ context && context.nodeType ? context.ownerDocument || context : document,
+ true
+ ) );
+
+ // HANDLE: $(html, props)
+ if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
+ for ( match in context ) {
+ // Properties of context are called as methods if possible
+ if ( jQuery.isFunction( this[ match ] ) ) {
+ this[ match ]( context[ match ] );
+
+ // ...and otherwise set as attributes
+ } else {
+ this.attr( match, context[ match ] );
+ }
+ }
+ }
+
+ return this;
+
+ // HANDLE: $(#id)
+ } else {
+ elem = document.getElementById( match[2] );
+
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return ( context || rootjQuery ).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return this.constructor( context ).find( selector );
+ }
+
+ // HANDLE: $(DOMElement)
+ } else if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if ( selector.selector !== undefined ) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return core_slice.call( this );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this[ this.length + num ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems ) {
+
+ // Build a new jQuery matched element set
+ var ret = jQuery.merge( this.constructor(), elems );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+ ret.context = this.context;
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Add the callback
+ jQuery.ready.promise().done( fn );
+
+ return this;
+ },
+
+ slice: function() {
+ return this.pushStack( core_slice.apply( this, arguments ) );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ eq: function( i ) {
+ var len = this.length,
+ j = +i + ( i < 0 ? len : 0 );
+ return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || this.constructor(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: core_push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ var src, copyIsArray, copy, name, options, clone,
+ target = arguments[0] || {},
+ i = 1,
+ length = arguments.length,
+ deep = false;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging plain objects or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
+ if ( copyIsArray ) {
+ copyIsArray = false;
+ clone = src && jQuery.isArray(src) ? src : [];
+
+ } else {
+ clone = src && jQuery.isPlainObject(src) ? src : {};
+ }
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ if ( window.$ === jQuery ) {
+ window.$ = _$;
+ }
+
+ if ( deep && window.jQuery === jQuery ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // A counter to track how many items to wait for before
+ // the ready event fires. See #6781
+ readyWait: 1,
+
+ // Hold (or release) the ready event
+ holdReady: function( hold ) {
+ if ( hold ) {
+ jQuery.readyWait++;
+ } else {
+ jQuery.ready( true );
+ }
+ },
+
+ // Handle when the DOM is ready
+ ready: function( wait ) {
+
+ // Abort if there are pending holds or we're already ready
+ if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
+ return;
+ }
+
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If a normal DOM Ready event fired, decrement, and wait if need be
+ if ( wait !== true && --jQuery.readyWait > 0 ) {
+ return;
+ }
+
+ // If there are functions bound, to execute
+ readyList.resolveWith( document, [ jQuery ] );
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.trigger ) {
+ jQuery( document ).trigger("ready").off("ready");
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return jQuery.type(obj) === "function";
+ },
+
+ isArray: Array.isArray || function( obj ) {
+ return jQuery.type(obj) === "array";
+ },
+
+ isWindow: function( obj ) {
+ return obj != null && obj == obj.window;
+ },
+
+ isNumeric: function( obj ) {
+ return !isNaN( parseFloat(obj) ) && isFinite( obj );
+ },
+
+ type: function( obj ) {
+ if ( obj == null ) {
+ return String( obj );
+ }
+ return typeof obj === "object" || typeof obj === "function" ?
+ class2type[ core_toString.call(obj) ] || "object" :
+ typeof obj;
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
+ return false;
+ }
+
+ try {
+ // Not own constructor property must be Object
+ if ( obj.constructor &&
+ !core_hasOwn.call(obj, "constructor") &&
+ !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+ } catch ( e ) {
+ // IE8,9 Will throw exceptions on certain host objects #9897
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || core_hasOwn.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ var name;
+ for ( name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ error: function( msg ) {
+ throw new Error( msg );
+ },
+
+ // data: string of html
+ // context (optional): If specified, the fragment will be created in this context, defaults to document
+ // keepScripts (optional): If true, will include scripts passed in the html string
+ parseHTML: function( data, context, keepScripts ) {
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+ if ( typeof context === "boolean" ) {
+ keepScripts = context;
+ context = false;
+ }
+ context = context || document;
+
+ var parsed = rsingleTag.exec( data ),
+ scripts = !keepScripts && [];
+
+ // Single tag
+ if ( parsed ) {
+ return [ context.createElement( parsed[1] ) ];
+ }
+
+ parsed = jQuery.buildFragment( [ data ], context, scripts );
+ if ( scripts ) {
+ jQuery( scripts ).remove();
+ }
+ return jQuery.merge( [], parsed.childNodes );
+ },
+
+ parseJSON: function( data ) {
+ // Attempt to parse using the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ return window.JSON.parse( data );
+ }
+
+ if ( data === null ) {
+ return data;
+ }
+
+ if ( typeof data === "string" ) {
+
+ // Make sure leading/trailing whitespace is removed (IE can't handle it)
+ data = jQuery.trim( data );
+
+ if ( data ) {
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if ( rvalidchars.test( data.replace( rvalidescape, "@" )
+ .replace( rvalidtokens, "]" )
+ .replace( rvalidbraces, "")) ) {
+
+ return ( new Function( "return " + data ) )();
+ }
+ }
+ }
+
+ jQuery.error( "Invalid JSON: " + data );
+ },
+
+ // Cross-browser xml parsing
+ parseXML: function( data ) {
+ var xml, tmp;
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+ try {
+ if ( window.DOMParser ) { // Standard
+ tmp = new DOMParser();
+ xml = tmp.parseFromString( data , "text/xml" );
+ } else { // IE
+ xml = new ActiveXObject( "Microsoft.XMLDOM" );
+ xml.async = "false";
+ xml.loadXML( data );
+ }
+ } catch( e ) {
+ xml = undefined;
+ }
+ if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
+ jQuery.error( "Invalid XML: " + data );
+ }
+ return xml;
+ },
+
+ noop: function() {},
+
+ // Evaluates a script in a global context
+ // Workarounds based on findings by Jim Driscoll
+ // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
+ globalEval: function( data ) {
+ if ( data && jQuery.trim( data ) ) {
+ // We use execScript on Internet Explorer
+ // We use an anonymous function so that context is window
+ // rather than jQuery in Firefox
+ ( window.execScript || function( data ) {
+ window[ "eval" ].call( window, data );
+ } )( data );
+ }
+ },
+
+ // Convert dashed to camelCase; used by the css and data modules
+ // Microsoft forgot to hump their vendor prefix (#9572)
+ camelCase: function( string ) {
+ return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+ },
+
+ // args is for internal usage only
+ each: function( obj, callback, args ) {
+ var value,
+ i = 0,
+ length = obj.length,
+ isArray = isArraylike( obj );
+
+ if ( args ) {
+ if ( isArray ) {
+ for ( ; i < length; i++ ) {
+ value = callback.apply( obj[ i ], args );
+
+ if ( value === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( i in obj ) {
+ value = callback.apply( obj[ i ], args );
+
+ if ( value === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isArray ) {
+ for ( ; i < length; i++ ) {
+ value = callback.call( obj[ i ], i, obj[ i ] );
+
+ if ( value === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( i in obj ) {
+ value = callback.call( obj[ i ], i, obj[ i ] );
+
+ if ( value === false ) {
+ break;
+ }
+ }
+ }
+ }
+
+ return obj;
+ },
+
+ // Use native String.trim function wherever possible
+ trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
+ function( text ) {
+ return text == null ?
+ "" :
+ core_trim.call( text );
+ } :
+
+ // Otherwise use our own trimming functionality
+ function( text ) {
+ return text == null ?
+ "" :
+ ( text + "" ).replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( arr, results ) {
+ var ret = results || [];
+
+ if ( arr != null ) {
+ if ( isArraylike( Object(arr) ) ) {
+ jQuery.merge( ret,
+ typeof arr === "string" ?
+ [ arr ] : arr
+ );
+ } else {
+ core_push.call( ret, arr );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, arr, i ) {
+ var len;
+
+ if ( arr ) {
+ if ( core_indexOf ) {
+ return core_indexOf.call( arr, elem, i );
+ }
+
+ len = arr.length;
+ i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
+
+ for ( ; i < len; i++ ) {
+ // Skip accessing in sparse arrays
+ if ( i in arr && arr[ i ] === elem ) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var l = second.length,
+ i = first.length,
+ j = 0;
+
+ if ( typeof l === "number" ) {
+ for ( ; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var retVal,
+ ret = [],
+ i = 0,
+ length = elems.length;
+ inv = !!inv;
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( ; i < length; i++ ) {
+ retVal = !!callback( elems[ i ], i );
+ if ( inv !== retVal ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var value,
+ i = 0,
+ length = elems.length,
+ isArray = isArraylike( elems ),
+ ret = [];
+
+ // Go through the array, translating each of the items to their
+ if ( isArray ) {
+ for ( ; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ // Go through every key on the object,
+ } else {
+ for ( i in elems ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+ }
+
+ // Flatten any nested arrays
+ return core_concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ // Bind a function to a context, optionally partially applying any
+ // arguments.
+ proxy: function( fn, context ) {
+ var args, proxy, tmp;
+
+ if ( typeof context === "string" ) {
+ tmp = fn[ context ];
+ context = fn;
+ fn = tmp;
+ }
+
+ // Quick check to determine if target is callable, in the spec
+ // this throws a TypeError, but we will just return undefined.
+ if ( !jQuery.isFunction( fn ) ) {
+ return undefined;
+ }
+
+ // Simulated bind
+ args = core_slice.call( arguments, 2 );
+ proxy = function() {
+ return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) );
+ };
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
+
+ return proxy;
+ },
+
+ // Multifunctional method to get and set values of a collection
+ // The value/s can optionally be executed if it's a function
+ access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
+ var i = 0,
+ length = elems.length,
+ bulk = key == null;
+
+ // Sets many values
+ if ( jQuery.type( key ) === "object" ) {
+ chainable = true;
+ for ( i in key ) {
+ jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
+ }
+
+ // Sets one value
+ } else if ( value !== undefined ) {
+ chainable = true;
+
+ if ( !jQuery.isFunction( value ) ) {
+ raw = true;
+ }
+
+ if ( bulk ) {
+ // Bulk operations run against the entire set
+ if ( raw ) {
+ fn.call( elems, value );
+ fn = null;
+
+ // ...except when executing function values
+ } else {
+ bulk = fn;
+ fn = function( elem, key, value ) {
+ return bulk.call( jQuery( elem ), value );
+ };
+ }
+ }
+
+ if ( fn ) {
+ for ( ; i < length; i++ ) {
+ fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
+ }
+ }
+ }
+
+ return chainable ?
+ elems :
+
+ // Gets
+ bulk ?
+ fn.call( elems ) :
+ length ? fn( elems[0], key ) : emptyGet;
+ },
+
+ now: function() {
+ return ( new Date() ).getTime();
+ }
+});
+
+jQuery.ready.promise = function( obj ) {
+ if ( !readyList ) {
+
+ readyList = jQuery.Deferred();
+
+ // Catch cases where $(document).ready() is called after the browser event has already occurred.
+ // we once tried to use readyState "interactive" here, but it caused issues like the one
+ // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
+ if ( document.readyState === "complete" ) {
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ setTimeout( jQuery.ready );
+
+ // Standards-based browsers support DOMContentLoaded
+ } else if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", completed, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", completed, false );
+
+ // If IE event model is used
+ } else {
+ // Ensure firing before onload, maybe late but safe also for iframes
+ document.attachEvent( "onreadystatechange", completed );
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", completed );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var top = false;
+
+ try {
+ top = window.frameElement == null && document.documentElement;
+ } catch(e) {}
+
+ if ( top && top.doScroll ) {
+ (function doScrollCheck() {
+ if ( !jQuery.isReady ) {
+
+ try {
+ // Use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ top.doScroll("left");
+ } catch(e) {
+ return setTimeout( doScrollCheck, 50 );
+ }
+
+ // detach all dom ready events
+ detach();
+
+ // and execute any waiting functions
+ jQuery.ready();
+ }
+ })();
+ }
+ }
+ }
+ return readyList.promise( obj );
+};
+
+// Populate the class2type map
+jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
+});
+
+function isArraylike( obj ) {
+ var length = obj.length,
+ type = jQuery.type( obj );
+
+ if ( jQuery.isWindow( obj ) ) {
+ return false;
+ }
+
+ if ( obj.nodeType === 1 && length ) {
+ return true;
+ }
+
+ return type === "array" || type !== "function" &&
+ ( length === 0 ||
+ typeof length === "number" && length > 0 && ( length - 1 ) in obj );
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+// String to Object options format cache
+var optionsCache = {};
+
+// Convert String-formatted options into Object-formatted ones and store in cache
+function createOptions( options ) {
+ var object = optionsCache[ options ] = {};
+ jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) {
+ object[ flag ] = true;
+ });
+ return object;
+}
+
+/*
+ * Create a callback list using the following parameters:
+ *
+ * options: an optional list of space-separated options that will change how
+ * the callback list behaves or a more traditional option object
+ *
+ * By default a callback list will act like an event callback list and can be
+ * "fired" multiple times.
+ *
+ * Possible options:
+ *
+ * once: will ensure the callback list can only be fired once (like a Deferred)
+ *
+ * memory: will keep track of previous values and will call any callback added
+ * after the list has been fired right away with the latest "memorized"
+ * values (like a Deferred)
+ *
+ * unique: will ensure a callback can only be added once (no duplicate in the list)
+ *
+ * stopOnFalse: interrupt callings when a callback returns false
+ *
+ */
+jQuery.Callbacks = function( options ) {
+
+ // Convert options from String-formatted to Object-formatted if needed
+ // (we check in cache first)
+ options = typeof options === "string" ?
+ ( optionsCache[ options ] || createOptions( options ) ) :
+ jQuery.extend( {}, options );
+
+ var // Flag to know if list is currently firing
+ firing,
+ // Last fire value (for non-forgettable lists)
+ memory,
+ // Flag to know if list was already fired
+ fired,
+ // End of the loop when firing
+ firingLength,
+ // Index of currently firing callback (modified by remove if needed)
+ firingIndex,
+ // First callback to fire (used internally by add and fireWith)
+ firingStart,
+ // Actual callback list
+ list = [],
+ // Stack of fire calls for repeatable lists
+ stack = !options.once && [],
+ // Fire callbacks
+ fire = function( data ) {
+ memory = options.memory && data;
+ fired = true;
+ firingIndex = firingStart || 0;
+ firingStart = 0;
+ firingLength = list.length;
+ firing = true;
+ for ( ; list && firingIndex < firingLength; firingIndex++ ) {
+ if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
+ memory = false; // To prevent further calls using add
+ break;
+ }
+ }
+ firing = false;
+ if ( list ) {
+ if ( stack ) {
+ if ( stack.length ) {
+ fire( stack.shift() );
+ }
+ } else if ( memory ) {
+ list = [];
+ } else {
+ self.disable();
+ }
+ }
+ },
+ // Actual Callbacks object
+ self = {
+ // Add a callback or a collection of callbacks to the list
+ add: function() {
+ if ( list ) {
+ // First, we save the current length
+ var start = list.length;
+ (function add( args ) {
+ jQuery.each( args, function( _, arg ) {
+ var type = jQuery.type( arg );
+ if ( type === "function" ) {
+ if ( !options.unique || !self.has( arg ) ) {
+ list.push( arg );
+ }
+ } else if ( arg && arg.length && type !== "string" ) {
+ // Inspect recursively
+ add( arg );
+ }
+ });
+ })( arguments );
+ // Do we need to add the callbacks to the
+ // current firing batch?
+ if ( firing ) {
+ firingLength = list.length;
+ // With memory, if we're not firing then
+ // we should call right away
+ } else if ( memory ) {
+ firingStart = start;
+ fire( memory );
+ }
+ }
+ return this;
+ },
+ // Remove a callback from the list
+ remove: function() {
+ if ( list ) {
+ jQuery.each( arguments, function( _, arg ) {
+ var index;
+ while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
+ list.splice( index, 1 );
+ // Handle firing indexes
+ if ( firing ) {
+ if ( index <= firingLength ) {
+ firingLength--;
+ }
+ if ( index <= firingIndex ) {
+ firingIndex--;
+ }
+ }
+ }
+ });
+ }
+ return this;
+ },
+ // Check if a given callback is in the list.
+ // If no argument is given, return whether or not list has callbacks attached.
+ has: function( fn ) {
+ return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
+ },
+ // Remove all callbacks from the list
+ empty: function() {
+ list = [];
+ return this;
+ },
+ // Have the list do nothing anymore
+ disable: function() {
+ list = stack = memory = undefined;
+ return this;
+ },
+ // Is it disabled?
+ disabled: function() {
+ return !list;
+ },
+ // Lock the list in its current state
+ lock: function() {
+ stack = undefined;
+ if ( !memory ) {
+ self.disable();
+ }
+ return this;
+ },
+ // Is it locked?
+ locked: function() {
+ return !stack;
+ },
+ // Call all callbacks with the given context and arguments
+ fireWith: function( context, args ) {
+ args = args || [];
+ args = [ context, args.slice ? args.slice() : args ];
+ if ( list && ( !fired || stack ) ) {
+ if ( firing ) {
+ stack.push( args );
+ } else {
+ fire( args );
+ }
+ }
+ return this;
+ },
+ // Call all the callbacks with the given arguments
+ fire: function() {
+ self.fireWith( this, arguments );
+ return this;
+ },
+ // To know if the callbacks have already been called at least once
+ fired: function() {
+ return !!fired;
+ }
+ };
+
+ return self;
+};
+jQuery.extend({
+
+ Deferred: function( func ) {
+ var tuples = [
+ // action, add listener, listener list, final state
+ [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
+ [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
+ [ "notify", "progress", jQuery.Callbacks("memory") ]
+ ],
+ state = "pending",
+ promise = {
+ state: function() {
+ return state;
+ },
+ always: function() {
+ deferred.done( arguments ).fail( arguments );
+ return this;
+ },
+ then: function( /* fnDone, fnFail, fnProgress */ ) {
+ var fns = arguments;
+ return jQuery.Deferred(function( newDefer ) {
+ jQuery.each( tuples, function( i, tuple ) {
+ var action = tuple[ 0 ],
+ fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
+ // deferred[ done | fail | progress ] for forwarding actions to newDefer
+ deferred[ tuple[1] ](function() {
+ var returned = fn && fn.apply( this, arguments );
+ if ( returned && jQuery.isFunction( returned.promise ) ) {
+ returned.promise()
+ .done( newDefer.resolve )
+ .fail( newDefer.reject )
+ .progress( newDefer.notify );
+ } else {
+ newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
+ }
+ });
+ });
+ fns = null;
+ }).promise();
+ },
+ // Get a promise for this deferred
+ // If obj is provided, the promise aspect is added to the object
+ promise: function( obj ) {
+ return obj != null ? jQuery.extend( obj, promise ) : promise;
+ }
+ },
+ deferred = {};
+
+ // Keep pipe for back-compat
+ promise.pipe = promise.then;
+
+ // Add list-specific methods
+ jQuery.each( tuples, function( i, tuple ) {
+ var list = tuple[ 2 ],
+ stateString = tuple[ 3 ];
+
+ // promise[ done | fail | progress ] = list.add
+ promise[ tuple[1] ] = list.add;
+
+ // Handle state
+ if ( stateString ) {
+ list.add(function() {
+ // state = [ resolved | rejected ]
+ state = stateString;
+
+ // [ reject_list | resolve_list ].disable; progress_list.lock
+ }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
+ }
+
+ // deferred[ resolve | reject | notify ]
+ deferred[ tuple[0] ] = function() {
+ deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
+ return this;
+ };
+ deferred[ tuple[0] + "With" ] = list.fireWith;
+ });
+
+ // Make the deferred a promise
+ promise.promise( deferred );
+
+ // Call given func if any
+ if ( func ) {
+ func.call( deferred, deferred );
+ }
+
+ // All done!
+ return deferred;
+ },
+
+ // Deferred helper
+ when: function( subordinate /* , ..., subordinateN */ ) {
+ var i = 0,
+ resolveValues = core_slice.call( arguments ),
+ length = resolveValues.length,
+
+ // the count of uncompleted subordinates
+ remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
+
+ // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
+ deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
+
+ // Update function for both resolve and progress values
+ updateFunc = function( i, contexts, values ) {
+ return function( value ) {
+ contexts[ i ] = this;
+ values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
+ if( values === progressValues ) {
+ deferred.notifyWith( contexts, values );
+ } else if ( !( --remaining ) ) {
+ deferred.resolveWith( contexts, values );
+ }
+ };
+ },
+
+ progressValues, progressContexts, resolveContexts;
+
+ // add listeners to Deferred subordinates; treat others as resolved
+ if ( length > 1 ) {
+ progressValues = new Array( length );
+ progressContexts = new Array( length );
+ resolveContexts = new Array( length );
+ for ( ; i < length; i++ ) {
+ if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
+ resolveValues[ i ].promise()
+ .done( updateFunc( i, resolveContexts, resolveValues ) )
+ .fail( deferred.reject )
+ .progress( updateFunc( i, progressContexts, progressValues ) );
+ } else {
+ --remaining;
+ }
+ }
+ }
+
+ // if we're not waiting on anything, resolve the master
+ if ( !remaining ) {
+ deferred.resolveWith( resolveContexts, resolveValues );
+ }
+
+ return deferred.promise();
+ }
+});
+jQuery.support = (function() {
+
+ var support, all, a,
+ input, select, fragment,
+ opt, eventName, isSupported, i,
+ div = document.createElement("div");
+
+ // Setup
+ div.setAttribute( "className", "t" );
+ div.innerHTML = " a ";
+
+ // Support tests won't run in some limited or non-browser environments
+ all = div.getElementsByTagName("*");
+ a = div.getElementsByTagName("a")[ 0 ];
+ if ( !all || !a || !all.length ) {
+ return {};
+ }
+
+ // First batch of tests
+ select = document.createElement("select");
+ opt = select.appendChild( document.createElement("option") );
+ input = div.getElementsByTagName("input")[ 0 ];
+
+ a.style.cssText = "top:1px;float:left;opacity:.5";
+ support = {
+ // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
+ getSetAttribute: div.className !== "t",
+
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText instead)
+ style: /top/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.5/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
+ checkOn: !!input.value,
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: opt.selected,
+
+ // Tests for enctype support on a form (#6743)
+ enctype: !!document.createElement("form").enctype,
+
+ // Makes sure cloning an html5 element does not cause problems
+ // Where outerHTML is undefined, this still works
+ html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>",
+
+ // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
+ boxModel: document.compatMode === "CSS1Compat",
+
+ // Will be defined later
+ deleteExpando: true,
+ noCloneEvent: true,
+ inlineBlockNeedsLayout: false,
+ shrinkWrapBlocks: false,
+ reliableMarginRight: true,
+ boxSizingReliable: true,
+ pixelPosition: false
+ };
+
+ // Make sure checked status is properly cloned
+ input.checked = true;
+ support.noCloneChecked = input.cloneNode( true ).checked;
+
+ // Make sure that the options inside disabled selects aren't marked as disabled
+ // (WebKit marks them as disabled)
+ select.disabled = true;
+ support.optDisabled = !opt.disabled;
+
+ // Support: IE<9
+ try {
+ delete div.test;
+ } catch( e ) {
+ support.deleteExpando = false;
+ }
+
+ // Check if we can trust getAttribute("value")
+ input = document.createElement("input");
+ input.setAttribute( "value", "" );
+ support.input = input.getAttribute( "value" ) === "";
+
+ // Check if an input maintains its value after becoming a radio
+ input.value = "t";
+ input.setAttribute( "type", "radio" );
+ support.radioValue = input.value === "t";
+
+ // #11217 - WebKit loses check when the name is after the checked attribute
+ input.setAttribute( "checked", "t" );
+ input.setAttribute( "name", "t" );
+
+ fragment = document.createDocumentFragment();
+ fragment.appendChild( input );
+
+ // Check if a disconnected checkbox will retain its checked
+ // value of true after appended to the DOM (IE6/7)
+ support.appendChecked = input.checked;
+
+ // WebKit doesn't clone checked state correctly in fragments
+ support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
+
+ // Support: IE<9
+ // Opera does not clone events (and typeof div.attachEvent === undefined).
+ // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
+ if ( div.attachEvent ) {
+ div.attachEvent( "onclick", function() {
+ support.noCloneEvent = false;
+ });
+
+ div.cloneNode( true ).click();
+ }
+
+ // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
+ // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP), test/csp.php
+ for ( i in { submit: true, change: true, focusin: true }) {
+ div.setAttribute( eventName = "on" + i, "t" );
+
+ support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
+ }
+
+ div.style.backgroundClip = "content-box";
+ div.cloneNode( true ).style.backgroundClip = "";
+ support.clearCloneStyle = div.style.backgroundClip === "content-box";
+
+ // Run tests that need a body at doc ready
+ jQuery(function() {
+ var container, marginDiv, tds,
+ divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
+ body = document.getElementsByTagName("body")[0];
+
+ if ( !body ) {
+ // Return for frameset docs that don't have a body
+ return;
+ }
+
+ container = document.createElement("div");
+ container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
+
+ body.appendChild( container ).appendChild( div );
+
+ // Support: IE8
+ // Check if table cells still have offsetWidth/Height when they are set
+ // to display:none and there are still other visible table cells in a
+ // table row; if so, offsetWidth/Height are not reliable for use when
+ // determining if an element has been hidden directly using
+ // display:none (it is still safe to use offsets if a parent element is
+ // hidden; don safety goggles and see bug #4512 for more information).
+ div.innerHTML = "";
+ tds = div.getElementsByTagName("td");
+ tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
+ isSupported = ( tds[ 0 ].offsetHeight === 0 );
+
+ tds[ 0 ].style.display = "";
+ tds[ 1 ].style.display = "none";
+
+ // Support: IE8
+ // Check if empty table cells still have offsetWidth/Height
+ support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
+
+ // Check box-sizing and margin behavior
+ div.innerHTML = "";
+ div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
+ support.boxSizing = ( div.offsetWidth === 4 );
+ support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
+
+ // Use window.getComputedStyle because jsdom on node.js will break without it.
+ if ( window.getComputedStyle ) {
+ support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
+ support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
+
+ // Check if div with explicit width and no margin-right incorrectly
+ // gets computed margin-right based on width of container. (#3333)
+ // Fails in WebKit before Feb 2011 nightlies
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ marginDiv = div.appendChild( document.createElement("div") );
+ marginDiv.style.cssText = div.style.cssText = divReset;
+ marginDiv.style.marginRight = marginDiv.style.width = "0";
+ div.style.width = "1px";
+
+ support.reliableMarginRight =
+ !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
+ }
+
+ if ( typeof div.style.zoom !== core_strundefined ) {
+ // Support: IE<8
+ // Check if natively block-level elements act like inline-block
+ // elements when setting their display to 'inline' and giving
+ // them layout
+ div.innerHTML = "";
+ div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
+ support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
+
+ // Support: IE6
+ // Check if elements with layout shrink-wrap their children
+ div.style.display = "block";
+ div.innerHTML = "
";
+ div.firstChild.style.width = "5px";
+ support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
+
+ if ( support.inlineBlockNeedsLayout ) {
+ // Prevent IE 6 from affecting layout for positioned elements #11048
+ // Prevent IE from shrinking the body in IE 7 mode #12869
+ // Support: IE<8
+ body.style.zoom = 1;
+ }
+ }
+
+ body.removeChild( container );
+
+ // Null elements to avoid leaks in IE
+ container = div = tds = marginDiv = null;
+ });
+
+ // Null elements to avoid leaks in IE
+ all = select = fragment = opt = a = input = null;
+
+ return support;
+})();
+
+var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
+ rmultiDash = /([A-Z])/g;
+
+function internalData( elem, name, data, pvt /* Internal Use Only */ ){
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ var thisCache, ret,
+ internalKey = jQuery.expando,
+ getByName = typeof name === "string",
+
+ // We have to handle DOM nodes and JS objects differently because IE6-7
+ // can't GC object references properly across the DOM-JS boundary
+ isNode = elem.nodeType,
+
+ // Only DOM nodes need the global jQuery cache; JS object data is
+ // attached directly to the object so GC can occur automatically
+ cache = isNode ? jQuery.cache : elem,
+
+ // Only defining an ID for JS objects if its cache already exists allows
+ // the code to shortcut on the same path as a DOM node with no cache
+ id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
+
+ // Avoid doing any more work than we need to when trying to get data on an
+ // object that has no data at all
+ if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
+ return;
+ }
+
+ if ( !id ) {
+ // Only DOM nodes need a new unique ID for each element since their data
+ // ends up in the global cache
+ if ( isNode ) {
+ elem[ internalKey ] = id = core_deletedIds.pop() || jQuery.guid++;
+ } else {
+ id = internalKey;
+ }
+ }
+
+ if ( !cache[ id ] ) {
+ cache[ id ] = {};
+
+ // Avoids exposing jQuery metadata on plain JS objects when the object
+ // is serialized using JSON.stringify
+ if ( !isNode ) {
+ cache[ id ].toJSON = jQuery.noop;
+ }
+ }
+
+ // An object can be passed to jQuery.data instead of a key/value pair; this gets
+ // shallow copied over onto the existing cache
+ if ( typeof name === "object" || typeof name === "function" ) {
+ if ( pvt ) {
+ cache[ id ] = jQuery.extend( cache[ id ], name );
+ } else {
+ cache[ id ].data = jQuery.extend( cache[ id ].data, name );
+ }
+ }
+
+ thisCache = cache[ id ];
+
+ // jQuery data() is stored in a separate object inside the object's internal data
+ // cache in order to avoid key collisions between internal data and user-defined
+ // data.
+ if ( !pvt ) {
+ if ( !thisCache.data ) {
+ thisCache.data = {};
+ }
+
+ thisCache = thisCache.data;
+ }
+
+ if ( data !== undefined ) {
+ thisCache[ jQuery.camelCase( name ) ] = data;
+ }
+
+ // Check for both converted-to-camel and non-converted data property names
+ // If a data property was specified
+ if ( getByName ) {
+
+ // First Try to find as-is property data
+ ret = thisCache[ name ];
+
+ // Test for null|undefined property data
+ if ( ret == null ) {
+
+ // Try to find the camelCased property
+ ret = thisCache[ jQuery.camelCase( name ) ];
+ }
+ } else {
+ ret = thisCache;
+ }
+
+ return ret;
+}
+
+function internalRemoveData( elem, name, pvt ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ var i, l, thisCache,
+ isNode = elem.nodeType,
+
+ // See jQuery.data for more information
+ cache = isNode ? jQuery.cache : elem,
+ id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
+
+ // If there is already no cache entry for this object, there is no
+ // purpose in continuing
+ if ( !cache[ id ] ) {
+ return;
+ }
+
+ if ( name ) {
+
+ thisCache = pvt ? cache[ id ] : cache[ id ].data;
+
+ if ( thisCache ) {
+
+ // Support array or space separated string names for data keys
+ if ( !jQuery.isArray( name ) ) {
+
+ // try the string as a key before any manipulation
+ if ( name in thisCache ) {
+ name = [ name ];
+ } else {
+
+ // split the camel cased version by spaces unless a key with the spaces exists
+ name = jQuery.camelCase( name );
+ if ( name in thisCache ) {
+ name = [ name ];
+ } else {
+ name = name.split(" ");
+ }
+ }
+ } else {
+ // If "name" is an array of keys...
+ // When data is initially created, via ("key", "val") signature,
+ // keys will be converted to camelCase.
+ // Since there is no way to tell _how_ a key was added, remove
+ // both plain key and camelCase key. #12786
+ // This will only penalize the array argument path.
+ name = name.concat( jQuery.map( name, jQuery.camelCase ) );
+ }
+
+ for ( i = 0, l = name.length; i < l; i++ ) {
+ delete thisCache[ name[i] ];
+ }
+
+ // If there is no data left in the cache, we want to continue
+ // and let the cache object itself get destroyed
+ if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
+ return;
+ }
+ }
+ }
+
+ // See jQuery.data for more information
+ if ( !pvt ) {
+ delete cache[ id ].data;
+
+ // Don't destroy the parent cache unless the internal data object
+ // had been the only thing left in it
+ if ( !isEmptyDataObject( cache[ id ] ) ) {
+ return;
+ }
+ }
+
+ // Destroy the cache
+ if ( isNode ) {
+ jQuery.cleanData( [ elem ], true );
+
+ // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
+ } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
+ delete cache[ id ];
+
+ // When all else fails, null
+ } else {
+ cache[ id ] = null;
+ }
+}
+
+jQuery.extend({
+ cache: {},
+
+ // Unique for each copy of jQuery on the page
+ // Non-digits removed to match rinlinejQuery
+ expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ // Ban all objects except for Flash (which handle expandos)
+ "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
+ "applet": true
+ },
+
+ hasData: function( elem ) {
+ elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
+ return !!elem && !isEmptyDataObject( elem );
+ },
+
+ data: function( elem, name, data ) {
+ return internalData( elem, name, data );
+ },
+
+ removeData: function( elem, name ) {
+ return internalRemoveData( elem, name );
+ },
+
+ // For internal use only.
+ _data: function( elem, name, data ) {
+ return internalData( elem, name, data, true );
+ },
+
+ _removeData: function( elem, name ) {
+ return internalRemoveData( elem, name, true );
+ },
+
+ // A method for determining if a DOM node can handle the data expando
+ acceptData: function( elem ) {
+ // Do not set data on non-element because it will not be cleared (#8335).
+ if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) {
+ return false;
+ }
+
+ var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
+
+ // nodes accept data unless otherwise specified; rejection can be conditional
+ return !noData || noData !== true && elem.getAttribute("classid") === noData;
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ var attrs, name,
+ elem = this[0],
+ i = 0,
+ data = null;
+
+ // Gets all values
+ if ( key === undefined ) {
+ if ( this.length ) {
+ data = jQuery.data( elem );
+
+ if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
+ attrs = elem.attributes;
+ for ( ; i < attrs.length; i++ ) {
+ name = attrs[i].name;
+
+ if ( !name.indexOf( "data-" ) ) {
+ name = jQuery.camelCase( name.slice(5) );
+
+ dataAttr( elem, name, data[ name ] );
+ }
+ }
+ jQuery._data( elem, "parsedAttrs", true );
+ }
+ }
+
+ return data;
+ }
+
+ // Sets multiple values
+ if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ return jQuery.access( this, function( value ) {
+
+ if ( value === undefined ) {
+ // Try to fetch any internally stored data first
+ return elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null;
+ }
+
+ this.each(function() {
+ jQuery.data( this, key, value );
+ });
+ }, null, value, arguments.length > 1, null, true );
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+
+function dataAttr( elem, key, data ) {
+ // If nothing was found internally, try to fetch any
+ // data from the HTML5 data-* attribute
+ if ( data === undefined && elem.nodeType === 1 ) {
+
+ var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
+
+ data = elem.getAttribute( name );
+
+ if ( typeof data === "string" ) {
+ try {
+ data = data === "true" ? true :
+ data === "false" ? false :
+ data === "null" ? null :
+ // Only convert to a number if it doesn't change the string
+ +data + "" === data ? +data :
+ rbrace.test( data ) ? jQuery.parseJSON( data ) :
+ data;
+ } catch( e ) {}
+
+ // Make sure we set the data so it isn't changed later
+ jQuery.data( elem, key, data );
+
+ } else {
+ data = undefined;
+ }
+ }
+
+ return data;
+}
+
+// checks a cache object for emptiness
+function isEmptyDataObject( obj ) {
+ var name;
+ for ( name in obj ) {
+
+ // if the public data object is empty, the private is still empty
+ if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
+ continue;
+ }
+ if ( name !== "toJSON" ) {
+ return false;
+ }
+ }
+
+ return true;
+}
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ var queue;
+
+ if ( elem ) {
+ type = ( type || "fx" ) + "queue";
+ queue = jQuery._data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( data ) {
+ if ( !queue || jQuery.isArray(data) ) {
+ queue = jQuery._data( elem, type, jQuery.makeArray(data) );
+ } else {
+ queue.push( data );
+ }
+ }
+ return queue || [];
+ }
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ),
+ startLength = queue.length,
+ fn = queue.shift(),
+ hooks = jQuery._queueHooks( elem, type ),
+ next = function() {
+ jQuery.dequeue( elem, type );
+ };
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ startLength--;
+ }
+
+ hooks.cur = fn;
+ if ( fn ) {
+
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift( "inprogress" );
+ }
+
+ // clear up the last queue stop function
+ delete hooks.stop;
+ fn.call( elem, next, hooks );
+ }
+
+ if ( !startLength && hooks ) {
+ hooks.empty.fire();
+ }
+ },
+
+ // not intended for public consumption - generates a queueHooks object, or returns the current one
+ _queueHooks: function( elem, type ) {
+ var key = type + "queueHooks";
+ return jQuery._data( elem, key ) || jQuery._data( elem, key, {
+ empty: jQuery.Callbacks("once memory").add(function() {
+ jQuery._removeData( elem, type + "queue" );
+ jQuery._removeData( elem, key );
+ })
+ });
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ var setter = 2;
+
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ setter--;
+ }
+
+ if ( arguments.length < setter ) {
+ return jQuery.queue( this[0], type );
+ }
+
+ return data === undefined ?
+ this :
+ this.each(function() {
+ var queue = jQuery.queue( this, type, data );
+
+ // ensure a hooks for this queue
+ jQuery._queueHooks( this, type );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function( next, hooks ) {
+ var timeout = setTimeout( next, time );
+ hooks.stop = function() {
+ clearTimeout( timeout );
+ };
+ });
+ },
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ },
+ // Get a promise resolved when queues of a certain type
+ // are emptied (fx is the type by default)
+ promise: function( type, obj ) {
+ var tmp,
+ count = 1,
+ defer = jQuery.Deferred(),
+ elements = this,
+ i = this.length,
+ resolve = function() {
+ if ( !( --count ) ) {
+ defer.resolveWith( elements, [ elements ] );
+ }
+ };
+
+ if ( typeof type !== "string" ) {
+ obj = type;
+ type = undefined;
+ }
+ type = type || "fx";
+
+ while( i-- ) {
+ tmp = jQuery._data( elements[ i ], type + "queueHooks" );
+ if ( tmp && tmp.empty ) {
+ count++;
+ tmp.empty.add( resolve );
+ }
+ }
+ resolve();
+ return defer.promise( obj );
+ }
+});
+var nodeHook, boolHook,
+ rclass = /[\t\r\n]/g,
+ rreturn = /\r/g,
+ rfocusable = /^(?:input|select|textarea|button|object)$/i,
+ rclickable = /^(?:a|area)$/i,
+ rboolean = /^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,
+ ruseDefault = /^(?:checked|selected)$/i,
+ getSetAttribute = jQuery.support.getSetAttribute,
+ getSetInput = jQuery.support.input;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
+ },
+
+ removeAttr: function( name ) {
+ return this.each(function() {
+ jQuery.removeAttr( this, name );
+ });
+ },
+
+ prop: function( name, value ) {
+ return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
+ },
+
+ removeProp: function( name ) {
+ name = jQuery.propFix[ name ] || name;
+ return this.each(function() {
+ // try/catch handles cases where IE balks (such as removing a property on window)
+ try {
+ this[ name ] = undefined;
+ delete this[ name ];
+ } catch( e ) {}
+ });
+ },
+
+ addClass: function( value ) {
+ var classes, elem, cur, clazz, j,
+ i = 0,
+ len = this.length,
+ proceed = typeof value === "string" && value;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( j ) {
+ jQuery( this ).addClass( value.call( this, j, this.className ) );
+ });
+ }
+
+ if ( proceed ) {
+ // The disjunction here is for better compressibility (see removeClass)
+ classes = ( value || "" ).match( core_rnotwhite ) || [];
+
+ for ( ; i < len; i++ ) {
+ elem = this[ i ];
+ cur = elem.nodeType === 1 && ( elem.className ?
+ ( " " + elem.className + " " ).replace( rclass, " " ) :
+ " "
+ );
+
+ if ( cur ) {
+ j = 0;
+ while ( (clazz = classes[j++]) ) {
+ if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
+ cur += clazz + " ";
+ }
+ }
+ elem.className = jQuery.trim( cur );
+
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ var classes, elem, cur, clazz, j,
+ i = 0,
+ len = this.length,
+ proceed = arguments.length === 0 || typeof value === "string" && value;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( j ) {
+ jQuery( this ).removeClass( value.call( this, j, this.className ) );
+ });
+ }
+ if ( proceed ) {
+ classes = ( value || "" ).match( core_rnotwhite ) || [];
+
+ for ( ; i < len; i++ ) {
+ elem = this[ i ];
+ // This expression is here for better compressibility (see addClass)
+ cur = elem.nodeType === 1 && ( elem.className ?
+ ( " " + elem.className + " " ).replace( rclass, " " ) :
+ ""
+ );
+
+ if ( cur ) {
+ j = 0;
+ while ( (clazz = classes[j++]) ) {
+ // Remove *all* instances
+ while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
+ cur = cur.replace( " " + clazz + " ", " " );
+ }
+ }
+ elem.className = value ? jQuery.trim( cur ) : "";
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value,
+ isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( i ) {
+ jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className,
+ i = 0,
+ self = jQuery( this ),
+ state = stateVal,
+ classNames = value.match( core_rnotwhite ) || [];
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space separated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ // Toggle whole class name
+ } else if ( type === core_strundefined || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery._data( this, "__className__", this.className );
+ }
+
+ // If the element has a class name or if we're passed "false",
+ // then remove the whole classname (if there was one, the above saved it).
+ // Otherwise bring back whatever was previously saved (if anything),
+ // falling back to the empty string if nothing was stored.
+ this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ",
+ i = 0,
+ l = this.length;
+ for ( ; i < l; i++ ) {
+ if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ var ret, hooks, isFunction,
+ elem = this[0];
+
+ if ( !arguments.length ) {
+ if ( elem ) {
+ hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
+
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
+ return ret;
+ }
+
+ ret = elem.value;
+
+ return typeof ret === "string" ?
+ // handle most common string cases
+ ret.replace(rreturn, "") :
+ // handle cases where value is null/undef or number
+ ret == null ? "" : ret;
+ }
+
+ return;
+ }
+
+ isFunction = jQuery.isFunction( value );
+
+ return this.each(function( i ) {
+ var val,
+ self = jQuery(this);
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call( this, i, self.val() );
+ } else {
+ val = value;
+ }
+
+ // Treat null/undefined as ""; convert numbers to string
+ if ( val == null ) {
+ val = "";
+ } else if ( typeof val === "number" ) {
+ val += "";
+ } else if ( jQuery.isArray( val ) ) {
+ val = jQuery.map(val, function ( value ) {
+ return value == null ? "" : value + "";
+ });
+ }
+
+ hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
+
+ // If set returns undefined, fall back to normal setting
+ if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ valHooks: {
+ option: {
+ get: function( elem ) {
+ // attributes.value is undefined in Blackberry 4.7 but
+ // uses .value. See #6932
+ var val = elem.attributes.value;
+ return !val || val.specified ? elem.value : elem.text;
+ }
+ },
+ select: {
+ get: function( elem ) {
+ var value, option,
+ options = elem.options,
+ index = elem.selectedIndex,
+ one = elem.type === "select-one" || index < 0,
+ values = one ? null : [],
+ max = one ? index + 1 : options.length,
+ i = index < 0 ?
+ max :
+ one ? index : 0;
+
+ // Loop through all the selected options
+ for ( ; i < max; i++ ) {
+ option = options[ i ];
+
+ // oldIE doesn't update selected after form reset (#2551)
+ if ( ( option.selected || i === index ) &&
+ // Don't return options that are disabled or in a disabled optgroup
+ ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
+ ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
+
+ // Get the specific value for the option
+ value = jQuery( option ).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ },
+
+ set: function( elem, value ) {
+ var values = jQuery.makeArray( value );
+
+ jQuery(elem).find("option").each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ elem.selectedIndex = -1;
+ }
+ return values;
+ }
+ }
+ },
+
+ attr: function( elem, name, value ) {
+ var hooks, notxml, ret,
+ nType = elem.nodeType;
+
+ // don't get/set attributes on text, comment and attribute nodes
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ // Fallback to prop when attributes are not supported
+ if ( typeof elem.getAttribute === core_strundefined ) {
+ return jQuery.prop( elem, name, value );
+ }
+
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+ // All attributes are lowercase
+ // Grab necessary hook if one is defined
+ if ( notxml ) {
+ name = name.toLowerCase();
+ hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
+ }
+
+ if ( value !== undefined ) {
+
+ if ( value === null ) {
+ jQuery.removeAttr( elem, name );
+
+ } else if ( hooks && notxml && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
+ return ret;
+
+ } else {
+ elem.setAttribute( name, value + "" );
+ return value;
+ }
+
+ } else if ( hooks && notxml && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
+ return ret;
+
+ } else {
+
+ // In IE9+, Flash objects don't have .getAttribute (#12945)
+ // Support: IE9+
+ if ( typeof elem.getAttribute !== core_strundefined ) {
+ ret = elem.getAttribute( name );
+ }
+
+ // Non-existent attributes return null, we normalize to undefined
+ return ret == null ?
+ undefined :
+ ret;
+ }
+ },
+
+ removeAttr: function( elem, value ) {
+ var name, propName,
+ i = 0,
+ attrNames = value && value.match( core_rnotwhite );
+
+ if ( attrNames && elem.nodeType === 1 ) {
+ while ( (name = attrNames[i++]) ) {
+ propName = jQuery.propFix[ name ] || name;
+
+ // Boolean attributes get special treatment (#10870)
+ if ( rboolean.test( name ) ) {
+ // Set corresponding property to false for boolean attributes
+ // Also clear defaultChecked/defaultSelected (if appropriate) for IE<8
+ if ( !getSetAttribute && ruseDefault.test( name ) ) {
+ elem[ jQuery.camelCase( "default-" + name ) ] =
+ elem[ propName ] = false;
+ } else {
+ elem[ propName ] = false;
+ }
+
+ // See #9699 for explanation of this approach (setting first, then removal)
+ } else {
+ jQuery.attr( elem, name, "" );
+ }
+
+ elem.removeAttribute( getSetAttribute ? name : propName );
+ }
+ }
+ },
+
+ attrHooks: {
+ type: {
+ set: function( elem, value ) {
+ if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
+ // Setting the type on a radio button after the value resets the value in IE6-9
+ // Reset value to default in case type is set after value during creation
+ var val = elem.value;
+ elem.setAttribute( "type", value );
+ if ( val ) {
+ elem.value = val;
+ }
+ return value;
+ }
+ }
+ }
+ },
+
+ propFix: {
+ tabindex: "tabIndex",
+ readonly: "readOnly",
+ "for": "htmlFor",
+ "class": "className",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ cellpadding: "cellPadding",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ usemap: "useMap",
+ frameborder: "frameBorder",
+ contenteditable: "contentEditable"
+ },
+
+ prop: function( elem, name, value ) {
+ var ret, hooks, notxml,
+ nType = elem.nodeType;
+
+ // don't get/set properties on text, comment and attribute nodes
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+ if ( notxml ) {
+ // Fix name and attach hooks
+ name = jQuery.propFix[ name ] || name;
+ hooks = jQuery.propHooks[ name ];
+ }
+
+ if ( value !== undefined ) {
+ if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
+ return ret;
+
+ } else {
+ return ( elem[ name ] = value );
+ }
+
+ } else {
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
+ return ret;
+
+ } else {
+ return elem[ name ];
+ }
+ }
+ },
+
+ propHooks: {
+ tabIndex: {
+ get: function( elem ) {
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ var attributeNode = elem.getAttributeNode("tabindex");
+
+ return attributeNode && attributeNode.specified ?
+ parseInt( attributeNode.value, 10 ) :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+ }
+ }
+});
+
+// Hook for boolean attributes
+boolHook = {
+ get: function( elem, name ) {
+ var
+ // Use .prop to determine if this attribute is understood as boolean
+ prop = jQuery.prop( elem, name ),
+
+ // Fetch it accordingly
+ attr = typeof prop === "boolean" && elem.getAttribute( name ),
+ detail = typeof prop === "boolean" ?
+
+ getSetInput && getSetAttribute ?
+ attr != null :
+ // oldIE fabricates an empty string for missing boolean attributes
+ // and conflates checked/selected into attroperties
+ ruseDefault.test( name ) ?
+ elem[ jQuery.camelCase( "default-" + name ) ] :
+ !!attr :
+
+ // fetch an attribute node for properties not recognized as boolean
+ elem.getAttributeNode( name );
+
+ return detail && detail.value !== false ?
+ name.toLowerCase() :
+ undefined;
+ },
+ set: function( elem, value, name ) {
+ if ( value === false ) {
+ // Remove boolean attributes when set to false
+ jQuery.removeAttr( elem, name );
+ } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
+ // IE<8 needs the *property* name
+ elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
+
+ // Use defaultChecked and defaultSelected for oldIE
+ } else {
+ elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
+ }
+
+ return name;
+ }
+};
+
+// fix oldIE value attroperty
+if ( !getSetInput || !getSetAttribute ) {
+ jQuery.attrHooks.value = {
+ get: function( elem, name ) {
+ var ret = elem.getAttributeNode( name );
+ return jQuery.nodeName( elem, "input" ) ?
+
+ // Ignore the value *property* by using defaultValue
+ elem.defaultValue :
+
+ ret && ret.specified ? ret.value : undefined;
+ },
+ set: function( elem, value, name ) {
+ if ( jQuery.nodeName( elem, "input" ) ) {
+ // Does not return so that setAttribute is also used
+ elem.defaultValue = value;
+ } else {
+ // Use nodeHook if defined (#1954); otherwise setAttribute is fine
+ return nodeHook && nodeHook.set( elem, value, name );
+ }
+ }
+ };
+}
+
+// IE6/7 do not support getting/setting some attributes with get/setAttribute
+if ( !getSetAttribute ) {
+
+ // Use this for any attribute in IE6/7
+ // This fixes almost every IE6/7 issue
+ nodeHook = jQuery.valHooks.button = {
+ get: function( elem, name ) {
+ var ret = elem.getAttributeNode( name );
+ return ret && ( name === "id" || name === "name" || name === "coords" ? ret.value !== "" : ret.specified ) ?
+ ret.value :
+ undefined;
+ },
+ set: function( elem, value, name ) {
+ // Set the existing or create a new attribute node
+ var ret = elem.getAttributeNode( name );
+ if ( !ret ) {
+ elem.setAttributeNode(
+ (ret = elem.ownerDocument.createAttribute( name ))
+ );
+ }
+
+ ret.value = value += "";
+
+ // Break association with cloned elements by also using setAttribute (#9646)
+ return name === "value" || value === elem.getAttribute( name ) ?
+ value :
+ undefined;
+ }
+ };
+
+ // Set contenteditable to false on removals(#10429)
+ // Setting to empty string throws an error as an invalid value
+ jQuery.attrHooks.contenteditable = {
+ get: nodeHook.get,
+ set: function( elem, value, name ) {
+ nodeHook.set( elem, value === "" ? false : value, name );
+ }
+ };
+
+ // Set width and height to auto instead of 0 on empty string( Bug #8150 )
+ // This is for removals
+ jQuery.each([ "width", "height" ], function( i, name ) {
+ jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
+ set: function( elem, value ) {
+ if ( value === "" ) {
+ elem.setAttribute( name, "auto" );
+ return value;
+ }
+ }
+ });
+ });
+}
+
+
+// Some attributes require a special call on IE
+// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
+if ( !jQuery.support.hrefNormalized ) {
+ jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
+ jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
+ get: function( elem ) {
+ var ret = elem.getAttribute( name, 2 );
+ return ret == null ? undefined : ret;
+ }
+ });
+ });
+
+ // href/src property should get the full normalized URL (#10299/#12915)
+ jQuery.each([ "href", "src" ], function( i, name ) {
+ jQuery.propHooks[ name ] = {
+ get: function( elem ) {
+ return elem.getAttribute( name, 4 );
+ }
+ };
+ });
+}
+
+if ( !jQuery.support.style ) {
+ jQuery.attrHooks.style = {
+ get: function( elem ) {
+ // Return undefined in the case of empty string
+ // Note: IE uppercases css property names, but if we were to .toLowerCase()
+ // .cssText, that would destroy case senstitivity in URL's, like in "background"
+ return elem.style.cssText || undefined;
+ },
+ set: function( elem, value ) {
+ return ( elem.style.cssText = value + "" );
+ }
+ };
+}
+
+// Safari mis-reports the default selected property of an option
+// Accessing the parent's selectedIndex property fixes it
+if ( !jQuery.support.optSelected ) {
+ jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
+ get: function( elem ) {
+ var parent = elem.parentNode;
+
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ return null;
+ }
+ });
+}
+
+// IE6/7 call enctype encoding
+if ( !jQuery.support.enctype ) {
+ jQuery.propFix.enctype = "encoding";
+}
+
+// Radios and checkboxes getter/setter
+if ( !jQuery.support.checkOn ) {
+ jQuery.each([ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = {
+ get: function( elem ) {
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+ };
+ });
+}
+jQuery.each([ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
+ set: function( elem, value ) {
+ if ( jQuery.isArray( value ) ) {
+ return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
+ }
+ }
+ });
+});
+var rformElems = /^(?:input|select|textarea)$/i,
+ rkeyEvent = /^key/,
+ rmouseEvent = /^(?:mouse|contextmenu)|click/,
+ rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
+ rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
+
+function returnTrue() {
+ return true;
+}
+
+function returnFalse() {
+ return false;
+}
+
+/*
+ * Helper functions for managing events -- not part of the public interface.
+ * Props to Dean Edwards' addEvent library for many of the ideas.
+ */
+jQuery.event = {
+
+ global: {},
+
+ add: function( elem, types, handler, data, selector ) {
+ var tmp, events, t, handleObjIn,
+ special, eventHandle, handleObj,
+ handlers, type, namespaces, origType,
+ elemData = jQuery._data( elem );
+
+ // Don't attach events to noData or text/comment nodes (but allow plain objects)
+ if ( !elemData ) {
+ return;
+ }
+
+ // Caller can pass in an object of custom data in lieu of the handler
+ if ( handler.handler ) {
+ handleObjIn = handler;
+ handler = handleObjIn.handler;
+ selector = handleObjIn.selector;
+ }
+
+ // Make sure that the handler has a unique ID, used to find/remove it later
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // Init the element's event structure and main handler, if this is the first
+ if ( !(events = elemData.events) ) {
+ events = elemData.events = {};
+ }
+ if ( !(eventHandle = elemData.handle) ) {
+ eventHandle = elemData.handle = function( e ) {
+ // Discard the second event of a jQuery.event.trigger() and
+ // when an event is called after a page has unloaded
+ return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
+ jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+ // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
+ eventHandle.elem = elem;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = ( types || "" ).match( core_rnotwhite ) || [""];
+ t = types.length;
+ while ( t-- ) {
+ tmp = rtypenamespace.exec( types[t] ) || [];
+ type = origType = tmp[1];
+ namespaces = ( tmp[2] || "" ).split( "." ).sort();
+
+ // If event changes its type, use the special event handlers for the changed type
+ special = jQuery.event.special[ type ] || {};
+
+ // If selector defined, determine special event api type, otherwise given type
+ type = ( selector ? special.delegateType : special.bindType ) || type;
+
+ // Update special based on newly reset type
+ special = jQuery.event.special[ type ] || {};
+
+ // handleObj is passed to all event handlers
+ handleObj = jQuery.extend({
+ type: type,
+ origType: origType,
+ data: data,
+ handler: handler,
+ guid: handler.guid,
+ selector: selector,
+ needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
+ namespace: namespaces.join(".")
+ }, handleObjIn );
+
+ // Init the event handler queue if we're the first
+ if ( !(handlers = events[ type ]) ) {
+ handlers = events[ type ] = [];
+ handlers.delegateCount = 0;
+
+ // Only use addEventListener/attachEvent if the special events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, eventHandle, false );
+
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, eventHandle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ special.add.call( elem, handleObj );
+
+ if ( !handleObj.handler.guid ) {
+ handleObj.handler.guid = handler.guid;
+ }
+ }
+
+ // Add to the element's handler list, delegates in front
+ if ( selector ) {
+ handlers.splice( handlers.delegateCount++, 0, handleObj );
+ } else {
+ handlers.push( handleObj );
+ }
+
+ // Keep track of which events have ever been used, for event optimization
+ jQuery.event.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler, selector, mappedTypes ) {
+ var j, handleObj, tmp,
+ origCount, t, events,
+ special, handlers, type,
+ namespaces, origType,
+ elemData = jQuery.hasData( elem ) && jQuery._data( elem );
+
+ if ( !elemData || !(events = elemData.events) ) {
+ return;
+ }
+
+ // Once for each type.namespace in types; type may be omitted
+ types = ( types || "" ).match( core_rnotwhite ) || [""];
+ t = types.length;
+ while ( t-- ) {
+ tmp = rtypenamespace.exec( types[t] ) || [];
+ type = origType = tmp[1];
+ namespaces = ( tmp[2] || "" ).split( "." ).sort();
+
+ // Unbind all events (on this namespace, if provided) for the element
+ if ( !type ) {
+ for ( type in events ) {
+ jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
+ }
+ continue;
+ }
+
+ special = jQuery.event.special[ type ] || {};
+ type = ( selector ? special.delegateType : special.bindType ) || type;
+ handlers = events[ type ] || [];
+ tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
+
+ // Remove matching events
+ origCount = j = handlers.length;
+ while ( j-- ) {
+ handleObj = handlers[ j ];
+
+ if ( ( mappedTypes || origType === handleObj.origType ) &&
+ ( !handler || handler.guid === handleObj.guid ) &&
+ ( !tmp || tmp.test( handleObj.namespace ) ) &&
+ ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
+ handlers.splice( j, 1 );
+
+ if ( handleObj.selector ) {
+ handlers.delegateCount--;
+ }
+ if ( special.remove ) {
+ special.remove.call( elem, handleObj );
+ }
+ }
+ }
+
+ // Remove generic event handler if we removed something and no more handlers exist
+ // (avoids potential for endless recursion during removal of special event handlers)
+ if ( origCount && !handlers.length ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
+ jQuery.removeEvent( elem, type, elemData.handle );
+ }
+
+ delete events[ type ];
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ if ( jQuery.isEmptyObject( events ) ) {
+ delete elemData.handle;
+
+ // removeData also checks for emptiness and clears the expando if empty
+ // so use it instead of delete
+ jQuery._removeData( elem, "events" );
+ }
+ },
+
+ trigger: function( event, data, elem, onlyHandlers ) {
+ var handle, ontype, cur,
+ bubbleType, special, tmp, i,
+ eventPath = [ elem || document ],
+ type = core_hasOwn.call( event, "type" ) ? event.type : event,
+ namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
+
+ cur = tmp = elem = elem || document;
+
+ // Don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // focus/blur morphs to focusin/out; ensure we're not firing them right now
+ if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
+ return;
+ }
+
+ if ( type.indexOf(".") >= 0 ) {
+ // Namespaced trigger; create a regexp to match event type in handle()
+ namespaces = type.split(".");
+ type = namespaces.shift();
+ namespaces.sort();
+ }
+ ontype = type.indexOf(":") < 0 && "on" + type;
+
+ // Caller can pass in a jQuery.Event object, Object, or just an event type string
+ event = event[ jQuery.expando ] ?
+ event :
+ new jQuery.Event( type, typeof event === "object" && event );
+
+ event.isTrigger = true;
+ event.namespace = namespaces.join(".");
+ event.namespace_re = event.namespace ?
+ new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
+ null;
+
+ // Clean up the event in case it is being reused
+ event.result = undefined;
+ if ( !event.target ) {
+ event.target = elem;
+ }
+
+ // Clone any incoming data and prepend the event, creating the handler arg list
+ data = data == null ?
+ [ event ] :
+ jQuery.makeArray( data, [ event ] );
+
+ // Allow special events to draw outside the lines
+ special = jQuery.event.special[ type ] || {};
+ if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
+ return;
+ }
+
+ // Determine event propagation path in advance, per W3C events spec (#9951)
+ // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
+ if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
+
+ bubbleType = special.delegateType || type;
+ if ( !rfocusMorph.test( bubbleType + type ) ) {
+ cur = cur.parentNode;
+ }
+ for ( ; cur; cur = cur.parentNode ) {
+ eventPath.push( cur );
+ tmp = cur;
+ }
+
+ // Only add window if we got to document (e.g., not plain obj or detached DOM)
+ if ( tmp === (elem.ownerDocument || document) ) {
+ eventPath.push( tmp.defaultView || tmp.parentWindow || window );
+ }
+ }
+
+ // Fire handlers on the event path
+ i = 0;
+ while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
+
+ event.type = i > 1 ?
+ bubbleType :
+ special.bindType || type;
+
+ // jQuery handler
+ handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
+ if ( handle ) {
+ handle.apply( cur, data );
+ }
+
+ // Native handler
+ handle = ontype && cur[ ontype ];
+ if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
+ event.preventDefault();
+ }
+ }
+ event.type = type;
+
+ // If nobody prevented the default action, do it now
+ if ( !onlyHandlers && !event.isDefaultPrevented() ) {
+
+ if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
+ !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
+
+ // Call a native DOM method on the target with the same name name as the event.
+ // Can't use an .isFunction() check here because IE6/7 fails that test.
+ // Don't do default actions on window, that's where global variables be (#6170)
+ if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
+
+ // Don't re-trigger an onFOO event when we call its FOO() method
+ tmp = elem[ ontype ];
+
+ if ( tmp ) {
+ elem[ ontype ] = null;
+ }
+
+ // Prevent re-triggering of the same event, since we already bubbled it above
+ jQuery.event.triggered = type;
+ try {
+ elem[ type ]();
+ } catch ( e ) {
+ // IE<9 dies on focus/blur to hidden element (#1486,#12518)
+ // only reproducible on winXP IE8 native, not IE9 in IE8 mode
+ }
+ jQuery.event.triggered = undefined;
+
+ if ( tmp ) {
+ elem[ ontype ] = tmp;
+ }
+ }
+ }
+ }
+
+ return event.result;
+ },
+
+ dispatch: function( event ) {
+
+ // Make a writable jQuery.Event from the native event object
+ event = jQuery.event.fix( event );
+
+ var i, ret, handleObj, matched, j,
+ handlerQueue = [],
+ args = core_slice.call( arguments ),
+ handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
+ special = jQuery.event.special[ event.type ] || {};
+
+ // Use the fix-ed jQuery.Event rather than the (read-only) native event
+ args[0] = event;
+ event.delegateTarget = this;
+
+ // Call the preDispatch hook for the mapped type, and let it bail if desired
+ if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
+ return;
+ }
+
+ // Determine handlers
+ handlerQueue = jQuery.event.handlers.call( this, event, handlers );
+
+ // Run delegates first; they may want to stop propagation beneath us
+ i = 0;
+ while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
+ event.currentTarget = matched.elem;
+
+ j = 0;
+ while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
+
+ // Triggered event must either 1) have no namespace, or
+ // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
+ if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
+
+ event.handleObj = handleObj;
+ event.data = handleObj.data;
+
+ var obj = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler );
+ if(obj.apply){
+ ret = obj.apply( matched.elem, args );
+ }
+
+ if ( ret !== undefined ) {
+ if ( (event.result = ret) === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+ }
+ }
+ }
+
+ // Call the postDispatch hook for the mapped type
+ if ( special.postDispatch ) {
+ special.postDispatch.call( this, event );
+ }
+
+ return event.result;
+ },
+
+ handlers: function( event, handlers ) {
+ var sel, handleObj, matches, i,
+ handlerQueue = [],
+ delegateCount = handlers.delegateCount,
+ cur = event.target;
+
+ // Find delegate handlers
+ // Black-hole SVG instance trees (#13180)
+ // Avoid non-left-click bubbling in Firefox (#3861)
+ if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
+
+ for ( ; cur != this; cur = cur.parentNode || this ) {
+
+ // Don't check non-elements (#13208)
+ // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
+ if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
+ matches = [];
+ for ( i = 0; i < delegateCount; i++ ) {
+ handleObj = handlers[ i ];
+
+ // Don't conflict with Object.prototype properties (#13203)
+ sel = handleObj.selector + " ";
+
+ if ( matches[ sel ] === undefined ) {
+ matches[ sel ] = handleObj.needsContext ?
+ jQuery( sel, this ).index( cur ) >= 0 :
+ jQuery.find( sel, this, null, [ cur ] ).length;
+ }
+ if ( matches[ sel ] ) {
+ matches.push( handleObj );
+ }
+ }
+ if ( matches.length ) {
+ handlerQueue.push({ elem: cur, handlers: matches });
+ }
+ }
+ }
+ }
+
+ // Add the remaining (directly-bound) handlers
+ if ( delegateCount < handlers.length ) {
+ handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
+ }
+
+ return handlerQueue;
+ },
+
+ fix: function( event ) {
+ if ( event[ jQuery.expando ] ) {
+ return event;
+ }
+
+ // Create a writable copy of the event object and normalize some properties
+ var i, prop, copy,
+ type = event.type,
+ originalEvent = event,
+ fixHook = this.fixHooks[ type ];
+
+ if ( !fixHook ) {
+ this.fixHooks[ type ] = fixHook =
+ rmouseEvent.test( type ) ? this.mouseHooks :
+ rkeyEvent.test( type ) ? this.keyHooks :
+ {};
+ }
+ copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
+
+ event = new jQuery.Event( originalEvent );
+
+ i = copy.length;
+ while ( i-- ) {
+ prop = copy[ i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Support: IE<9
+ // Fix target property (#1925)
+ if ( !event.target ) {
+ event.target = originalEvent.srcElement || document;
+ }
+
+ // Support: Chrome 23+, Safari?
+ // Target should not be a text node (#504, #13143)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Support: IE<9
+ // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
+ event.metaKey = !!event.metaKey;
+
+ return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
+ },
+
+ // Includes some event props shared by KeyEvent and MouseEvent
+ props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
+
+ fixHooks: {},
+
+ keyHooks: {
+ props: "char charCode key keyCode".split(" "),
+ filter: function( event, original ) {
+
+ // Add which for key events
+ if ( event.which == null ) {
+ event.which = original.charCode != null ? original.charCode : original.keyCode;
+ }
+
+ return event;
+ }
+ },
+
+ mouseHooks: {
+ props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
+ filter: function( event, original ) {
+ var body, eventDoc, doc,
+ button = original.button,
+ fromElement = original.fromElement;
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && original.clientX != null ) {
+ eventDoc = event.target.ownerDocument || document;
+ doc = eventDoc.documentElement;
+ body = eventDoc.body;
+
+ event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
+ event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && fromElement ) {
+ event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && button !== undefined ) {
+ event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
+ }
+
+ return event;
+ }
+ },
+
+ special: {
+ load: {
+ // Prevent triggered image.load events from bubbling to window.load
+ noBubble: true
+ },
+ click: {
+ // For checkbox, fire native event so checked state will be right
+ trigger: function() {
+ if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
+ this.click();
+ return false;
+ }
+ }
+ },
+ focus: {
+ // Fire native event if possible so blur/focus sequence is correct
+ trigger: function() {
+ if ( this !== document.activeElement && this.focus ) {
+ try {
+ this.focus();
+ return false;
+ } catch ( e ) {
+ // Support: IE<9
+ // If we error on focus to hidden element (#1486, #12518),
+ // let .trigger() run the handlers
+ }
+ }
+ },
+ delegateType: "focusin"
+ },
+ blur: {
+ trigger: function() {
+ if ( this === document.activeElement && this.blur ) {
+ this.blur();
+ return false;
+ }
+ },
+ delegateType: "focusout"
+ },
+
+ beforeunload: {
+ postDispatch: function( event ) {
+
+ // Even when returnValue equals to undefined Firefox will still show alert
+ if ( event.result !== undefined ) {
+ event.originalEvent.returnValue = event.result;
+ }
+ }
+ }
+ },
+
+ simulate: function( type, elem, event, bubble ) {
+ // Piggyback on a donor event to simulate a different one.
+ // Fake originalEvent to avoid donor's stopPropagation, but if the
+ // simulated event prevents default then we do the same on the donor.
+ var e = jQuery.extend(
+ new jQuery.Event(),
+ event,
+ { type: type,
+ isSimulated: true,
+ originalEvent: {}
+ }
+ );
+ if ( bubble ) {
+ jQuery.event.trigger( e, null, elem );
+ } else {
+ jQuery.event.dispatch.call( elem, e );
+ }
+ if ( e.isDefaultPrevented() ) {
+ event.preventDefault();
+ }
+ }
+};
+
+jQuery.removeEvent = document.removeEventListener ?
+ function( elem, type, handle ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, handle, false );
+ }
+ } :
+ function( elem, type, handle ) {
+ var name = "on" + type;
+
+ if ( elem.detachEvent ) {
+
+ // #8545, #7054, preventing memory leaks for custom events in IE6-8
+ // detachEvent needed property on element, by name of that event, to properly expose it to GC
+ if ( typeof elem[ name ] === core_strundefined ) {
+ elem[ name ] = null;
+ }
+
+ elem.detachEvent( name, handle );
+ }
+ };
+
+jQuery.Event = function( src, props ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !(this instanceof jQuery.Event) ) {
+ return new jQuery.Event( src, props );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+
+ // Events bubbling up the document may have been marked as prevented
+ // by a handler lower down the tree; reflect the correct value.
+ this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
+ src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
+
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // Put explicitly provided properties onto the event object
+ if ( props ) {
+ jQuery.extend( this, props );
+ }
+
+ // Create a timestamp if incoming event doesn't have one
+ this.timeStamp = src && src.timeStamp || jQuery.now();
+
+ // Mark it as fixed
+ this[ jQuery.expando ] = true;
+};
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse,
+
+ preventDefault: function() {
+ var e = this.originalEvent;
+
+ this.isDefaultPrevented = returnTrue;
+ if ( !e ) {
+ return;
+ }
+
+ // If preventDefault exists, run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+
+ // Support: IE
+ // Otherwise set the returnValue property of the original event to false
+ } else {
+ e.returnValue = false;
+ }
+ },
+ stopPropagation: function() {
+ var e = this.originalEvent;
+
+ this.isPropagationStopped = returnTrue;
+ if ( !e ) {
+ return;
+ }
+ // If stopPropagation exists, run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+
+ // Support: IE
+ // Set the cancelBubble property of the original event to true
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ }
+};
+
+// Create mouseenter/leave events using mouseover/out and event-time checks
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ delegateType: fix,
+ bindType: fix,
+
+ handle: function( event ) {
+ var ret,
+ target = this,
+ related = event.relatedTarget,
+ handleObj = event.handleObj;
+
+ // For mousenter/leave call the handler if related is outside the target.
+ // NB: No relatedTarget if the mouse left/entered the browser window
+ if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
+ event.type = handleObj.origType;
+ ret = handleObj.handler.apply( this, arguments );
+ event.type = fix;
+ }
+ return ret;
+ }
+ };
+});
+
+// IE submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+ jQuery.event.special.submit = {
+ setup: function() {
+ // Only need this for delegated form submit events
+ if ( jQuery.nodeName( this, "form" ) ) {
+ return false;
+ }
+
+ // Lazy-add a submit handler when a descendant form may potentially be submitted
+ jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
+ // Node name check avoids a VML-related crash in IE (#9807)
+ var elem = e.target,
+ form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
+ if ( form && !jQuery._data( form, "submitBubbles" ) ) {
+ jQuery.event.add( form, "submit._submit", function( event ) {
+ event._submit_bubble = true;
+ });
+ jQuery._data( form, "submitBubbles", true );
+ }
+ });
+ // return undefined since we don't need an event listener
+ },
+
+ postDispatch: function( event ) {
+ // If form was submitted by the user, bubble the event up the tree
+ if ( event._submit_bubble ) {
+ delete event._submit_bubble;
+ if ( this.parentNode && !event.isTrigger ) {
+ jQuery.event.simulate( "submit", this.parentNode, event, true );
+ }
+ }
+ },
+
+ teardown: function() {
+ // Only need this for delegated form submit events
+ if ( jQuery.nodeName( this, "form" ) ) {
+ return false;
+ }
+
+ // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
+ jQuery.event.remove( this, "._submit" );
+ }
+ };
+}
+
+// IE change delegation and checkbox/radio fix
+if ( !jQuery.support.changeBubbles ) {
+
+ jQuery.event.special.change = {
+
+ setup: function() {
+
+ if ( rformElems.test( this.nodeName ) ) {
+ // IE doesn't fire change on a check/radio until blur; trigger it on click
+ // after a propertychange. Eat the blur-change in special.change.handle.
+ // This still fires onchange a second time for check/radio after blur.
+ if ( this.type === "checkbox" || this.type === "radio" ) {
+ jQuery.event.add( this, "propertychange._change", function( event ) {
+ if ( event.originalEvent.propertyName === "checked" ) {
+ this._just_changed = true;
+ }
+ });
+ jQuery.event.add( this, "click._change", function( event ) {
+ if ( this._just_changed && !event.isTrigger ) {
+ this._just_changed = false;
+ }
+ // Allow triggered, simulated change events (#11500)
+ jQuery.event.simulate( "change", this, event, true );
+ });
+ }
+ return false;
+ }
+ // Delegated event; lazy-add a change handler on descendant inputs
+ jQuery.event.add( this, "beforeactivate._change", function( e ) {
+ var elem = e.target;
+
+ if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
+ jQuery.event.add( elem, "change._change", function( event ) {
+ if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
+ jQuery.event.simulate( "change", this.parentNode, event, true );
+ }
+ });
+ jQuery._data( elem, "changeBubbles", true );
+ }
+ });
+ },
+
+ handle: function( event ) {
+ var elem = event.target;
+
+ // Swallow native change events from checkbox/radio, we already triggered them above
+ if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
+ return event.handleObj.handler.apply( this, arguments );
+ }
+ },
+
+ teardown: function() {
+ jQuery.event.remove( this, "._change" );
+
+ return !rformElems.test( this.nodeName );
+ }
+ };
+}
+
+// Create "bubbling" focus and blur events
+if ( !jQuery.support.focusinBubbles ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+
+ // Attach a single capturing handler while someone wants focusin/focusout
+ var attaches = 0,
+ handler = function( event ) {
+ jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
+ };
+
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ if ( attaches++ === 0 ) {
+ document.addEventListener( orig, handler, true );
+ }
+ },
+ teardown: function() {
+ if ( --attaches === 0 ) {
+ document.removeEventListener( orig, handler, true );
+ }
+ }
+ };
+ });
+}
+
+jQuery.fn.extend({
+
+ on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
+ var type, origFn;
+
+ // Types can be a map of types/handlers
+ if ( typeof types === "object" ) {
+ // ( types-Object, selector, data )
+ if ( typeof selector !== "string" ) {
+ // ( types-Object, data )
+ data = data || selector;
+ selector = undefined;
+ }
+ for ( type in types ) {
+ this.on( type, selector, data, types[ type ], one );
+ }
+ return this;
+ }
+
+ if ( data == null && fn == null ) {
+ // ( types, fn )
+ fn = selector;
+ data = selector = undefined;
+ } else if ( fn == null ) {
+ if ( typeof selector === "string" ) {
+ // ( types, selector, fn )
+ fn = data;
+ data = undefined;
+ } else {
+ // ( types, data, fn )
+ fn = data;
+ data = selector;
+ selector = undefined;
+ }
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ } else if ( !fn ) {
+ return this;
+ }
+
+ if ( one === 1 ) {
+ origFn = fn;
+ fn = function( event ) {
+ // Can use an empty set, since event contains the info
+ jQuery().off( event );
+ return origFn.apply( this, arguments );
+ };
+ // Use same guid so caller can remove using origFn
+ fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
+ }
+ return this.each( function() {
+ jQuery.event.add( this, types, fn, data, selector );
+ });
+ },
+ one: function( types, selector, data, fn ) {
+ return this.on( types, selector, data, fn, 1 );
+ },
+ off: function( types, selector, fn ) {
+ var handleObj, type;
+ if ( types && types.preventDefault && types.handleObj ) {
+ // ( event ) dispatched jQuery.Event
+ handleObj = types.handleObj;
+ jQuery( types.delegateTarget ).off(
+ handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
+ handleObj.selector,
+ handleObj.handler
+ );
+ return this;
+ }
+ if ( typeof types === "object" ) {
+ // ( types-object [, selector] )
+ for ( type in types ) {
+ this.off( type, selector, types[ type ] );
+ }
+ return this;
+ }
+ if ( selector === false || typeof selector === "function" ) {
+ // ( types [, fn] )
+ fn = selector;
+ selector = undefined;
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ }
+ return this.each(function() {
+ jQuery.event.remove( this, types, fn, selector );
+ });
+ },
+
+ bind: function( types, data, fn ) {
+ return this.on( types, null, data, fn );
+ },
+ unbind: function( types, fn ) {
+ return this.off( types, null, fn );
+ },
+
+ delegate: function( selector, types, data, fn ) {
+ return this.on( types, selector, data, fn );
+ },
+ undelegate: function( selector, types, fn ) {
+ // ( namespace ) or ( selector, types [, fn] )
+ return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
+ },
+
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+ triggerHandler: function( type, data ) {
+ var elem = this[0];
+ if ( elem ) {
+ return jQuery.event.trigger( type, data, elem, true );
+ }
+ }
+});
+/*!
+ * Sizzle CSS Selector Engine
+ * Copyright 2012 jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://sizzlejs.com/
+ */
+(function( window, undefined ) {
+
+var i,
+ cachedruns,
+ Expr,
+ getText,
+ isXML,
+ compile,
+ hasDuplicate,
+ outermostContext,
+
+ // Local document vars
+ setDocument,
+ document,
+ docElem,
+ documentIsXML,
+ rbuggyQSA,
+ rbuggyMatches,
+ matches,
+ contains,
+ sortOrder,
+
+ // Instance-specific data
+ expando = "sizzle" + -(new Date()),
+ preferredDoc = window.document,
+ support = {},
+ dirruns = 0,
+ done = 0,
+ classCache = createCache(),
+ tokenCache = createCache(),
+ compilerCache = createCache(),
+
+ // General-purpose constants
+ strundefined = typeof undefined,
+ MAX_NEGATIVE = 1 << 31,
+
+ // Array methods
+ arr = [],
+ pop = arr.pop,
+ push = arr.push,
+ slice = arr.slice,
+ // Use a stripped-down indexOf if we can't use a native one
+ indexOf = arr.indexOf || function( elem ) {
+ var i = 0,
+ len = this.length;
+ for ( ; i < len; i++ ) {
+ if ( this[i] === elem ) {
+ return i;
+ }
+ }
+ return -1;
+ },
+
+
+ // Regular expressions
+
+ // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
+ whitespace = "[\\x20\\t\\r\\n\\f]",
+ // http://www.w3.org/TR/css3-syntax/#characters
+ characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
+
+ // Loosely modeled on CSS identifier characters
+ // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
+ // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
+ identifier = characterEncoding.replace( "w", "w#" ),
+
+ // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
+ operators = "([*^$|!~]?=)",
+ attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
+ "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
+
+ // Prefer arguments quoted,
+ // then not containing pseudos/brackets,
+ // then attribute selectors/non-parenthetical expressions,
+ // then anything else
+ // These preferences are here to reduce the number of selectors
+ // needing tokenize in the PSEUDO preFilter
+ pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
+
+ // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
+ rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
+
+ rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
+ rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
+ rpseudo = new RegExp( pseudos ),
+ ridentifier = new RegExp( "^" + identifier + "$" ),
+
+ matchExpr = {
+ "ID": new RegExp( "^#(" + characterEncoding + ")" ),
+ "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
+ "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
+ "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
+ "ATTR": new RegExp( "^" + attributes ),
+ "PSEUDO": new RegExp( "^" + pseudos ),
+ "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
+ "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
+ "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
+ // For use in libraries implementing .is()
+ // We use this for POS matching in `select`
+ "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
+ whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
+ },
+
+ rsibling = /[\x20\t\r\n\f]*[+~]/,
+
+ rnative = /^[^{]+\{\s*\[native code/,
+
+ // Easily-parseable/retrievable ID or TAG or CLASS selectors
+ rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
+
+ rinputs = /^(?:input|select|textarea|button)$/i,
+ rheader = /^h\d$/i,
+
+ rescape = /'|\\/g,
+ rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
+
+ // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
+ runescape = /\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,
+ funescape = function( _, escaped ) {
+ var high = "0x" + escaped - 0x10000;
+ // NaN means non-codepoint
+ return high !== high ?
+ escaped :
+ // BMP codepoint
+ high < 0 ?
+ String.fromCharCode( high + 0x10000 ) :
+ // Supplemental Plane codepoint (surrogate pair)
+ String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
+ };
+
+// Use a stripped-down slice if we can't use a native one
+try {
+ slice.call( preferredDoc.documentElement.childNodes, 0 )[0].nodeType;
+} catch ( e ) {
+ slice = function( i ) {
+ var elem,
+ results = [];
+ while ( (elem = this[i++]) ) {
+ results.push( elem );
+ }
+ return results;
+ };
+}
+
+/**
+ * For feature detection
+ * @param {Function} fn The function to test for native support
+ */
+function isNative( fn ) {
+ return rnative.test( fn + "" );
+}
+
+/**
+ * Create key-value caches of limited size
+ * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
+ * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
+ * deleting the oldest entry
+ */
+function createCache() {
+ var cache,
+ keys = [];
+
+ return (cache = function( key, value ) {
+ // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
+ if ( keys.push( key += " " ) > Expr.cacheLength ) {
+ // Only keep the most recent entries
+ delete cache[ keys.shift() ];
+ }
+ return (cache[ key ] = value);
+ });
+}
+
+/**
+ * Mark a function for special use by Sizzle
+ * @param {Function} fn The function to mark
+ */
+function markFunction( fn ) {
+ fn[ expando ] = true;
+ return fn;
+}
+
+/**
+ * Support testing using an element
+ * @param {Function} fn Passed the created div and expects a boolean result
+ */
+function assert( fn ) {
+ var div = document.createElement("div");
+
+ try {
+ return fn( div );
+ } catch (e) {
+ return false;
+ } finally {
+ // release memory in IE
+ div = null;
+ }
+}
+
+function Sizzle( selector, context, results, seed ) {
+ var match, elem, m, nodeType,
+ // QSA vars
+ i, groups, old, nid, newContext, newSelector;
+
+ if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
+ setDocument( context );
+ }
+
+ context = context || document;
+ results = results || [];
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !documentIsXML && !seed ) {
+
+ // Shortcuts
+ if ( (match = rquickExpr.exec( selector )) ) {
+ // Speed-up: Sizzle("#ID")
+ if ( (m = match[1]) ) {
+ if ( nodeType === 9 ) {
+ elem = context.getElementById( m );
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+ // Handle the case where IE, Opera, and Webkit return items
+ // by name instead of ID
+ if ( elem.id === m ) {
+ results.push( elem );
+ return results;
+ }
+ } else {
+ return results;
+ }
+ } else {
+ // Context is not a document
+ if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
+ contains( context, elem ) && elem.id === m ) {
+ results.push( elem );
+ return results;
+ }
+ }
+
+ // Speed-up: Sizzle("TAG")
+ } else if ( match[2] ) {
+ push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
+ return results;
+
+ // Speed-up: Sizzle(".CLASS")
+ } else if ( (m = match[3]) && support.getByClassName && context.getElementsByClassName ) {
+ push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
+ return results;
+ }
+ }
+
+ // QSA path
+ if ( support.qsa && !rbuggyQSA.test(selector) ) {
+ old = true;
+ nid = expando;
+ newContext = context;
+ newSelector = nodeType === 9 && selector;
+
+ // qSA works strangely on Element-rooted queries
+ // We can work around this by specifying an extra ID on the root
+ // and working up from there (Thanks to Andrew Dupont for the technique)
+ // IE 8 doesn't work on object elements
+ if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
+ groups = tokenize( selector );
+
+ if ( (old = context.getAttribute("id")) ) {
+ nid = old.replace( rescape, "\\$&" );
+ } else {
+ context.setAttribute( "id", nid );
+ }
+ nid = "[id='" + nid + "'] ";
+
+ i = groups.length;
+ while ( i-- ) {
+ groups[i] = nid + toSelector( groups[i] );
+ }
+ newContext = rsibling.test( selector ) && context.parentNode || context;
+ newSelector = groups.join(",");
+ }
+
+ if ( newSelector ) {
+ try {
+ push.apply( results, slice.call( newContext.querySelectorAll(
+ newSelector
+ ), 0 ) );
+ return results;
+ } catch(qsaError) {
+ } finally {
+ if ( !old ) {
+ context.removeAttribute("id");
+ }
+ }
+ }
+ }
+ }
+
+ // All others
+ return select( selector.replace( rtrim, "$1" ), context, results, seed );
+}
+
+/**
+ * Detect xml
+ * @param {Element|Object} elem An element or a document
+ */
+isXML = Sizzle.isXML = function( elem ) {
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = elem && (elem.ownerDocument || elem).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+/**
+ * Sets document-related variables once based on the current document
+ * @param {Element|Object} [doc] An element or document object to use to set the document
+ * @returns {Object} Returns the current document
+ */
+setDocument = Sizzle.setDocument = function( node ) {
+ var doc = node ? node.ownerDocument || node : preferredDoc;
+
+ // If no document and documentElement is available, return
+ if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
+ return document;
+ }
+
+ // Set our document
+ document = doc;
+ docElem = doc.documentElement;
+
+ // Support tests
+ documentIsXML = isXML( doc );
+
+ // Check if getElementsByTagName("*") returns only elements
+ support.tagNameNoComments = assert(function( div ) {
+ div.appendChild( doc.createComment("") );
+ return !div.getElementsByTagName("*").length;
+ });
+
+ // Check if attributes should be retrieved by attribute nodes
+ support.attributes = assert(function( div ) {
+ div.innerHTML = " ";
+ var type = typeof div.lastChild.getAttribute("multiple");
+ // IE8 returns a string for some attributes even when not present
+ return type !== "boolean" && type !== "string";
+ });
+
+ // Check if getElementsByClassName can be trusted
+ support.getByClassName = assert(function( div ) {
+ // Opera can't find a second classname (in 9.6)
+ div.innerHTML = "
";
+ if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
+ return false;
+ }
+
+ // Safari 3.2 caches class attributes and doesn't catch changes
+ div.lastChild.className = "e";
+ return div.getElementsByClassName("e").length === 2;
+ });
+
+ // Check if getElementById returns elements by name
+ // Check if getElementsByName privileges form controls or returns elements by ID
+ support.getByName = assert(function( div ) {
+ // Inject content
+ div.id = expando + 0;
+ div.innerHTML = "
";
+ docElem.insertBefore( div, docElem.firstChild );
+
+ // Test
+ var pass = doc.getElementsByName &&
+ // buggy browsers will return fewer than the correct 2
+ doc.getElementsByName( expando ).length === 2 +
+ // buggy browsers will return more than the correct 0
+ doc.getElementsByName( expando + 0 ).length;
+ support.getIdNotName = !doc.getElementById( expando );
+
+ // Cleanup
+ docElem.removeChild( div );
+
+ return pass;
+ });
+
+ // IE6/7 return modified attributes
+ Expr.attrHandle = assert(function( div ) {
+ div.innerHTML = " ";
+ return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
+ div.firstChild.getAttribute("href") === "#";
+ }) ?
+ {} :
+ {
+ "href": function( elem ) {
+ return elem.getAttribute( "href", 2 );
+ },
+ "type": function( elem ) {
+ return elem.getAttribute("type");
+ }
+ };
+
+ // ID find and filter
+ if ( support.getIdNotName ) {
+ Expr.find["ID"] = function( id, context ) {
+ if ( typeof context.getElementById !== strundefined && !documentIsXML ) {
+ var m = context.getElementById( id );
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ return m && m.parentNode ? [m] : [];
+ }
+ };
+ Expr.filter["ID"] = function( id ) {
+ var attrId = id.replace( runescape, funescape );
+ return function( elem ) {
+ return elem.getAttribute("id") === attrId;
+ };
+ };
+ } else {
+ Expr.find["ID"] = function( id, context ) {
+ if ( typeof context.getElementById !== strundefined && !documentIsXML ) {
+ var m = context.getElementById( id );
+
+ return m ?
+ m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
+ [m] :
+ undefined :
+ [];
+ }
+ };
+ Expr.filter["ID"] = function( id ) {
+ var attrId = id.replace( runescape, funescape );
+ return function( elem ) {
+ var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
+ return node && node.value === attrId;
+ };
+ };
+ }
+
+ // Tag
+ Expr.find["TAG"] = support.tagNameNoComments ?
+ function( tag, context ) {
+ if ( typeof context.getElementsByTagName !== strundefined ) {
+ return context.getElementsByTagName( tag );
+ }
+ } :
+ function( tag, context ) {
+ var elem,
+ tmp = [],
+ i = 0,
+ results = context.getElementsByTagName( tag );
+
+ // Filter out possible comments
+ if ( tag === "*" ) {
+ while ( (elem = results[i++]) ) {
+ if ( elem.nodeType === 1 ) {
+ tmp.push( elem );
+ }
+ }
+
+ return tmp;
+ }
+ return results;
+ };
+
+ // Name
+ Expr.find["NAME"] = support.getByName && function( tag, context ) {
+ if ( typeof context.getElementsByName !== strundefined ) {
+ return context.getElementsByName( name );
+ }
+ };
+
+ // Class
+ Expr.find["CLASS"] = support.getByClassName && function( className, context ) {
+ if ( typeof context.getElementsByClassName !== strundefined && !documentIsXML ) {
+ return context.getElementsByClassName( className );
+ }
+ };
+
+ // QSA and matchesSelector support
+
+ // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
+ rbuggyMatches = [];
+
+ // qSa(:focus) reports false when true (Chrome 21),
+ // no need to also add to buggyMatches since matches checks buggyQSA
+ // A support test would require too much code (would include document ready)
+ rbuggyQSA = [ ":focus" ];
+
+ if ( (support.qsa = isNative(doc.querySelectorAll)) ) {
+ // Build QSA regex
+ // Regex strategy adopted from Diego Perini
+ assert(function( div ) {
+ // Select is set to empty string on purpose
+ // This is to test IE's treatment of not explictly
+ // setting a boolean content attribute,
+ // since its presence should be enough
+ // http://bugs.jquery.com/ticket/12359
+ div.innerHTML = " ";
+
+ // IE8 - Some boolean attributes are not treated correctly
+ if ( !div.querySelectorAll("[selected]").length ) {
+ rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
+ }
+
+ // Webkit/Opera - :checked should return selected option elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ // IE8 throws error here and will not see later tests
+ if ( !div.querySelectorAll(":checked").length ) {
+ rbuggyQSA.push(":checked");
+ }
+ });
+
+ assert(function( div ) {
+
+ // Opera 10-12/IE8 - ^= $= *= and empty values
+ // Should not select anything
+ div.innerHTML = " ";
+ if ( div.querySelectorAll("[i^='']").length ) {
+ rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
+ }
+
+ // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
+ // IE8 throws error here and will not see later tests
+ if ( !div.querySelectorAll(":enabled").length ) {
+ rbuggyQSA.push( ":enabled", ":disabled" );
+ }
+
+ // Opera 10-11 does not throw on post-comma invalid pseudos
+ div.querySelectorAll("*,:x");
+ rbuggyQSA.push(",.*:");
+ });
+ }
+
+ if ( (support.matchesSelector = isNative( (matches = docElem.matchesSelector ||
+ docElem.mozMatchesSelector ||
+ docElem.webkitMatchesSelector ||
+ docElem.oMatchesSelector ||
+ docElem.msMatchesSelector) )) ) {
+
+ assert(function( div ) {
+ // Check to see if it's possible to do matchesSelector
+ // on a disconnected node (IE 9)
+ support.disconnectedMatch = matches.call( div, "div" );
+
+ // This should fail with an exception
+ // Gecko does not error, returns false instead
+ matches.call( div, "[s!='']:x" );
+ rbuggyMatches.push( "!=", pseudos );
+ });
+ }
+
+ rbuggyQSA = new RegExp( rbuggyQSA.join("|") );
+ rbuggyMatches = new RegExp( rbuggyMatches.join("|") );
+
+ // Element contains another
+ // Purposefully does not implement inclusive descendent
+ // As in, an element does not contain itself
+ contains = isNative(docElem.contains) || docElem.compareDocumentPosition ?
+ function( a, b ) {
+ var adown = a.nodeType === 9 ? a.documentElement : a,
+ bup = b && b.parentNode;
+ return a === bup || !!( bup && bup.nodeType === 1 && (
+ adown.contains ?
+ adown.contains( bup ) :
+ a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
+ ));
+ } :
+ function( a, b ) {
+ if ( b ) {
+ while ( (b = b.parentNode) ) {
+ if ( b === a ) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+
+ // Document order sorting
+ sortOrder = docElem.compareDocumentPosition ?
+ function( a, b ) {
+ var compare;
+
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ if ( (compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b )) ) {
+ if ( compare & 1 || a.parentNode && a.parentNode.nodeType === 11 ) {
+ if ( a === doc || contains( preferredDoc, a ) ) {
+ return -1;
+ }
+ if ( b === doc || contains( preferredDoc, b ) ) {
+ return 1;
+ }
+ return 0;
+ }
+ return compare & 4 ? -1 : 1;
+ }
+
+ return a.compareDocumentPosition ? -1 : 1;
+ } :
+ function( a, b ) {
+ var cur,
+ i = 0,
+ aup = a.parentNode,
+ bup = b.parentNode,
+ ap = [ a ],
+ bp = [ b ];
+
+ // Exit early if the nodes are identical
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+
+ // Parentless nodes are either documents or disconnected
+ } else if ( !aup || !bup ) {
+ return a === doc ? -1 :
+ b === doc ? 1 :
+ aup ? -1 :
+ bup ? 1 :
+ 0;
+
+ // If the nodes are siblings, we can do a quick check
+ } else if ( aup === bup ) {
+ return siblingCheck( a, b );
+ }
+
+ // Otherwise we need full lists of their ancestors for comparison
+ cur = a;
+ while ( (cur = cur.parentNode) ) {
+ ap.unshift( cur );
+ }
+ cur = b;
+ while ( (cur = cur.parentNode) ) {
+ bp.unshift( cur );
+ }
+
+ // Walk down the tree looking for a discrepancy
+ while ( ap[i] === bp[i] ) {
+ i++;
+ }
+
+ return i ?
+ // Do a sibling check if the nodes have a common ancestor
+ siblingCheck( ap[i], bp[i] ) :
+
+ // Otherwise nodes in our document sort first
+ ap[i] === preferredDoc ? -1 :
+ bp[i] === preferredDoc ? 1 :
+ 0;
+ };
+
+ // Always assume the presence of duplicates if sort doesn't
+ // pass them to our comparison function (as in Google Chrome).
+ hasDuplicate = false;
+ [0, 0].sort( sortOrder );
+ support.detectDuplicates = hasDuplicate;
+
+ return document;
+};
+
+Sizzle.matches = function( expr, elements ) {
+ return Sizzle( expr, null, null, elements );
+};
+
+Sizzle.matchesSelector = function( elem, expr ) {
+ // Set document vars if needed
+ if ( ( elem.ownerDocument || elem ) !== document ) {
+ setDocument( elem );
+ }
+
+ // Make sure that attribute selectors are quoted
+ expr = expr.replace( rattributeQuotes, "='$1']" );
+
+ // rbuggyQSA always contains :focus, so no need for an existence check
+ if ( support.matchesSelector && !documentIsXML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && !rbuggyQSA.test(expr) ) {
+ try {
+ var ret = matches.call( elem, expr );
+
+ // IE 9's matchesSelector returns false on disconnected nodes
+ if ( ret || support.disconnectedMatch ||
+ // As well, disconnected nodes are said to be in a document
+ // fragment in IE 9
+ elem.document && elem.document.nodeType !== 11 ) {
+ return ret;
+ }
+ } catch(e) {}
+ }
+
+ return Sizzle( expr, document, null, [elem] ).length > 0;
+};
+
+Sizzle.contains = function( context, elem ) {
+ // Set document vars if needed
+ if ( ( context.ownerDocument || context ) !== document ) {
+ setDocument( context );
+ }
+ return contains( context, elem );
+};
+
+Sizzle.attr = function( elem, name ) {
+ var val;
+
+ // Set document vars if needed
+ if ( ( elem.ownerDocument || elem ) !== document ) {
+ setDocument( elem );
+ }
+
+ if ( !documentIsXML ) {
+ name = name.toLowerCase();
+ }
+ if ( (val = Expr.attrHandle[ name ]) ) {
+ return val( elem );
+ }
+ if ( documentIsXML || support.attributes ) {
+ return elem.getAttribute( name );
+ }
+ return ( (val = elem.getAttributeNode( name )) || elem.getAttribute( name ) ) && elem[ name ] === true ?
+ name :
+ val && val.specified ? val.value : null;
+};
+
+Sizzle.error = function( msg ) {
+ throw new Error( "Syntax error, unrecognized expression: " + msg );
+};
+
+// Document sorting and removing duplicates
+Sizzle.uniqueSort = function( results ) {
+ var elem,
+ duplicates = [],
+ i = 1,
+ j = 0;
+
+ // Unless we *know* we can detect duplicates, assume their presence
+ hasDuplicate = !support.detectDuplicates;
+ results.sort( sortOrder );
+
+ if ( hasDuplicate ) {
+ for ( ; (elem = results[i]); i++ ) {
+ if ( elem === results[ i - 1 ] ) {
+ j = duplicates.push( i );
+ }
+ }
+ while ( j-- ) {
+ results.splice( duplicates[ j ], 1 );
+ }
+ }
+
+ return results;
+};
+
+function siblingCheck( a, b ) {
+ var cur = b && a,
+ diff = cur && ( ~b.sourceIndex || MAX_NEGATIVE ) - ( ~a.sourceIndex || MAX_NEGATIVE );
+
+ // Use IE sourceIndex if available on both nodes
+ if ( diff ) {
+ return diff;
+ }
+
+ // Check if b follows a
+ if ( cur ) {
+ while ( (cur = cur.nextSibling) ) {
+ if ( cur === b ) {
+ return -1;
+ }
+ }
+ }
+
+ return a ? 1 : -1;
+}
+
+// Returns a function to use in pseudos for input types
+function createInputPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === type;
+ };
+}
+
+// Returns a function to use in pseudos for buttons
+function createButtonPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && elem.type === type;
+ };
+}
+
+// Returns a function to use in pseudos for positionals
+function createPositionalPseudo( fn ) {
+ return markFunction(function( argument ) {
+ argument = +argument;
+ return markFunction(function( seed, matches ) {
+ var j,
+ matchIndexes = fn( [], seed.length, argument ),
+ i = matchIndexes.length;
+
+ // Match elements found at the specified indexes
+ while ( i-- ) {
+ if ( seed[ (j = matchIndexes[i]) ] ) {
+ seed[j] = !(matches[j] = seed[j]);
+ }
+ }
+ });
+ });
+}
+
+/**
+ * Utility function for retrieving the text value of an array of DOM nodes
+ * @param {Array|Element} elem
+ */
+getText = Sizzle.getText = function( elem ) {
+ var node,
+ ret = "",
+ i = 0,
+ nodeType = elem.nodeType;
+
+ if ( !nodeType ) {
+ // If no nodeType, this is expected to be an array
+ for ( ; (node = elem[i]); i++ ) {
+ // Do not traverse comment nodes
+ ret += getText( node );
+ }
+ } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
+ // Use textContent for elements
+ // innerText usage removed for consistency of new lines (see #11153)
+ if ( typeof elem.textContent === "string" ) {
+ return elem.textContent;
+ } else {
+ // Traverse its children
+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+ ret += getText( elem );
+ }
+ }
+ } else if ( nodeType === 3 || nodeType === 4 ) {
+ return elem.nodeValue;
+ }
+ // Do not include comment or processing instruction nodes
+
+ return ret;
+};
+
+Expr = Sizzle.selectors = {
+
+ // Can be adjusted by the user
+ cacheLength: 50,
+
+ createPseudo: markFunction,
+
+ match: matchExpr,
+
+ find: {},
+
+ relative: {
+ ">": { dir: "parentNode", first: true },
+ " ": { dir: "parentNode" },
+ "+": { dir: "previousSibling", first: true },
+ "~": { dir: "previousSibling" }
+ },
+
+ preFilter: {
+ "ATTR": function( match ) {
+ match[1] = match[1].replace( runescape, funescape );
+
+ // Move the given value to match[3] whether quoted or unquoted
+ match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
+
+ if ( match[2] === "~=" ) {
+ match[3] = " " + match[3] + " ";
+ }
+
+ return match.slice( 0, 4 );
+ },
+
+ "CHILD": function( match ) {
+ /* matches from matchExpr["CHILD"]
+ 1 type (only|nth|...)
+ 2 what (child|of-type)
+ 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
+ 4 xn-component of xn+y argument ([+-]?\d*n|)
+ 5 sign of xn-component
+ 6 x of xn-component
+ 7 sign of y-component
+ 8 y of y-component
+ */
+ match[1] = match[1].toLowerCase();
+
+ if ( match[1].slice( 0, 3 ) === "nth" ) {
+ // nth-* requires argument
+ if ( !match[3] ) {
+ Sizzle.error( match[0] );
+ }
+
+ // numeric x and y parameters for Expr.filter.CHILD
+ // remember that false/true cast respectively to 0/1
+ match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
+ match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
+
+ // other types prohibit arguments
+ } else if ( match[3] ) {
+ Sizzle.error( match[0] );
+ }
+
+ return match;
+ },
+
+ "PSEUDO": function( match ) {
+ var excess,
+ unquoted = !match[5] && match[2];
+
+ if ( matchExpr["CHILD"].test( match[0] ) ) {
+ return null;
+ }
+
+ // Accept quoted arguments as-is
+ if ( match[4] ) {
+ match[2] = match[4];
+
+ // Strip excess characters from unquoted arguments
+ } else if ( unquoted && rpseudo.test( unquoted ) &&
+ // Get excess from tokenize (recursively)
+ (excess = tokenize( unquoted, true )) &&
+ // advance to the next closing parenthesis
+ (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
+
+ // excess is a negative index
+ match[0] = match[0].slice( 0, excess );
+ match[2] = unquoted.slice( 0, excess );
+ }
+
+ // Return only captures needed by the pseudo filter method (type and argument)
+ return match.slice( 0, 3 );
+ }
+ },
+
+ filter: {
+
+ "TAG": function( nodeName ) {
+ if ( nodeName === "*" ) {
+ return function() { return true; };
+ }
+
+ nodeName = nodeName.replace( runescape, funescape ).toLowerCase();
+ return function( elem ) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
+ };
+ },
+
+ "CLASS": function( className ) {
+ var pattern = classCache[ className + " " ];
+
+ return pattern ||
+ (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
+ classCache( className, function( elem ) {
+ return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
+ });
+ },
+
+ "ATTR": function( name, operator, check ) {
+ return function( elem ) {
+ var result = Sizzle.attr( elem, name );
+
+ if ( result == null ) {
+ return operator === "!=";
+ }
+ if ( !operator ) {
+ return true;
+ }
+
+ result += "";
+
+ return operator === "=" ? result === check :
+ operator === "!=" ? result !== check :
+ operator === "^=" ? check && result.indexOf( check ) === 0 :
+ operator === "*=" ? check && result.indexOf( check ) > -1 :
+ operator === "$=" ? check && result.slice( -check.length ) === check :
+ operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
+ operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
+ false;
+ };
+ },
+
+ "CHILD": function( type, what, argument, first, last ) {
+ var simple = type.slice( 0, 3 ) !== "nth",
+ forward = type.slice( -4 ) !== "last",
+ ofType = what === "of-type";
+
+ return first === 1 && last === 0 ?
+
+ // Shortcut for :nth-*(n)
+ function( elem ) {
+ return !!elem.parentNode;
+ } :
+
+ function( elem, context, xml ) {
+ var cache, outerCache, node, diff, nodeIndex, start,
+ dir = simple !== forward ? "nextSibling" : "previousSibling",
+ parent = elem.parentNode,
+ name = ofType && elem.nodeName.toLowerCase(),
+ useCache = !xml && !ofType;
+
+ if ( parent ) {
+
+ // :(first|last|only)-(child|of-type)
+ if ( simple ) {
+ while ( dir ) {
+ node = elem;
+ while ( (node = node[ dir ]) ) {
+ if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ // Reverse direction for :only-* (if we haven't yet done so)
+ start = dir = type === "only" && !start && "nextSibling";
+ }
+ return true;
+ }
+
+ start = [ forward ? parent.firstChild : parent.lastChild ];
+
+ // non-xml :nth-child(...) stores cache data on `parent`
+ if ( forward && useCache ) {
+ // Seek `elem` from a previously-cached index
+ outerCache = parent[ expando ] || (parent[ expando ] = {});
+ cache = outerCache[ type ] || [];
+ nodeIndex = cache[0] === dirruns && cache[1];
+ diff = cache[0] === dirruns && cache[2];
+ node = nodeIndex && parent.childNodes[ nodeIndex ];
+
+ while ( (node = ++nodeIndex && node && node[ dir ] ||
+
+ // Fallback to seeking `elem` from the start
+ (diff = nodeIndex = 0) || start.pop()) ) {
+
+ // When found, cache indexes on `parent` and break
+ if ( node.nodeType === 1 && ++diff && node === elem ) {
+ outerCache[ type ] = [ dirruns, nodeIndex, diff ];
+ break;
+ }
+ }
+
+ // Use previously-cached element index if available
+ } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
+ diff = cache[1];
+
+ // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
+ } else {
+ // Use the same loop as above to seek `elem` from the start
+ while ( (node = ++nodeIndex && node && node[ dir ] ||
+ (diff = nodeIndex = 0) || start.pop()) ) {
+
+ if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
+ // Cache the index of each encountered element
+ if ( useCache ) {
+ (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
+ }
+
+ if ( node === elem ) {
+ break;
+ }
+ }
+ }
+ }
+
+ // Incorporate the offset, then check against cycle size
+ diff -= last;
+ return diff === first || ( diff % first === 0 && diff / first >= 0 );
+ }
+ };
+ },
+
+ "PSEUDO": function( pseudo, argument ) {
+ // pseudo-class names are case-insensitive
+ // http://www.w3.org/TR/selectors/#pseudo-classes
+ // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
+ // Remember that setFilters inherits from pseudos
+ var args,
+ fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
+ Sizzle.error( "unsupported pseudo: " + pseudo );
+
+ // The user may use createPseudo to indicate that
+ // arguments are needed to create the filter function
+ // just as Sizzle does
+ if ( fn[ expando ] ) {
+ return fn( argument );
+ }
+
+ // But maintain support for old signatures
+ if ( fn.length > 1 ) {
+ args = [ pseudo, pseudo, "", argument ];
+ return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
+ markFunction(function( seed, matches ) {
+ var idx,
+ matched = fn( seed, argument ),
+ i = matched.length;
+ while ( i-- ) {
+ idx = indexOf.call( seed, matched[i] );
+ seed[ idx ] = !( matches[ idx ] = matched[i] );
+ }
+ }) :
+ function( elem ) {
+ return fn( elem, 0, args );
+ };
+ }
+
+ return fn;
+ }
+ },
+
+ pseudos: {
+ // Potentially complex pseudos
+ "not": markFunction(function( selector ) {
+ // Trim the selector passed to compile
+ // to avoid treating leading and trailing
+ // spaces as combinators
+ var input = [],
+ results = [],
+ matcher = compile( selector.replace( rtrim, "$1" ) );
+
+ return matcher[ expando ] ?
+ markFunction(function( seed, matches, context, xml ) {
+ var elem,
+ unmatched = matcher( seed, null, xml, [] ),
+ i = seed.length;
+
+ // Match elements unmatched by `matcher`
+ while ( i-- ) {
+ if ( (elem = unmatched[i]) ) {
+ seed[i] = !(matches[i] = elem);
+ }
+ }
+ }) :
+ function( elem, context, xml ) {
+ input[0] = elem;
+ matcher( input, null, xml, results );
+ return !results.pop();
+ };
+ }),
+
+ "has": markFunction(function( selector ) {
+ return function( elem ) {
+ return Sizzle( selector, elem ).length > 0;
+ };
+ }),
+
+ "contains": markFunction(function( text ) {
+ return function( elem ) {
+ return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
+ };
+ }),
+
+ // "Whether an element is represented by a :lang() selector
+ // is based solely on the element's language value
+ // being equal to the identifier C,
+ // or beginning with the identifier C immediately followed by "-".
+ // The matching of C against the element's language value is performed case-insensitively.
+ // The identifier C does not have to be a valid language name."
+ // http://www.w3.org/TR/selectors/#lang-pseudo
+ "lang": markFunction( function( lang ) {
+ // lang value must be a valid identifider
+ if ( !ridentifier.test(lang || "") ) {
+ Sizzle.error( "unsupported lang: " + lang );
+ }
+ lang = lang.replace( runescape, funescape ).toLowerCase();
+ return function( elem ) {
+ var elemLang;
+ do {
+ if ( (elemLang = documentIsXML ?
+ elem.getAttribute("xml:lang") || elem.getAttribute("lang") :
+ elem.lang) ) {
+
+ elemLang = elemLang.toLowerCase();
+ return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
+ }
+ } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
+ return false;
+ };
+ }),
+
+ // Miscellaneous
+ "target": function( elem ) {
+ var hash = window.location && window.location.hash;
+ return hash && hash.slice( 1 ) === elem.id;
+ },
+
+ "root": function( elem ) {
+ return elem === docElem;
+ },
+
+ "focus": function( elem ) {
+ return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
+ },
+
+ // Boolean properties
+ "enabled": function( elem ) {
+ return elem.disabled === false;
+ },
+
+ "disabled": function( elem ) {
+ return elem.disabled === true;
+ },
+
+ "checked": function( elem ) {
+ // In CSS3, :checked should return both checked and selected elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ var nodeName = elem.nodeName.toLowerCase();
+ return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
+ },
+
+ "selected": function( elem ) {
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ if ( elem.parentNode ) {
+ elem.parentNode.selectedIndex;
+ }
+
+ return elem.selected === true;
+ },
+
+ // Contents
+ "empty": function( elem ) {
+ // http://www.w3.org/TR/selectors/#empty-pseudo
+ // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
+ // not comment, processing instructions, or others
+ // Thanks to Diego Perini for the nodeName shortcut
+ // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+ if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) {
+ return false;
+ }
+ }
+ return true;
+ },
+
+ "parent": function( elem ) {
+ return !Expr.pseudos["empty"]( elem );
+ },
+
+ // Element/input types
+ "header": function( elem ) {
+ return rheader.test( elem.nodeName );
+ },
+
+ "input": function( elem ) {
+ return rinputs.test( elem.nodeName );
+ },
+
+ "button": function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === "button" || name === "button";
+ },
+
+ "text": function( elem ) {
+ var attr;
+ // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
+ // use getAttribute instead to test this case
+ return elem.nodeName.toLowerCase() === "input" &&
+ elem.type === "text" &&
+ ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type );
+ },
+
+ // Position-in-collection
+ "first": createPositionalPseudo(function() {
+ return [ 0 ];
+ }),
+
+ "last": createPositionalPseudo(function( matchIndexes, length ) {
+ return [ length - 1 ];
+ }),
+
+ "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ return [ argument < 0 ? argument + length : argument ];
+ }),
+
+ "even": createPositionalPseudo(function( matchIndexes, length ) {
+ var i = 0;
+ for ( ; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "odd": createPositionalPseudo(function( matchIndexes, length ) {
+ var i = 1;
+ for ( ; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ var i = argument < 0 ? argument + length : argument;
+ for ( ; --i >= 0; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ var i = argument < 0 ? argument + length : argument;
+ for ( ; ++i < length; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ })
+ }
+};
+
+// Add button/input type pseudos
+for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
+ Expr.pseudos[ i ] = createInputPseudo( i );
+}
+for ( i in { submit: true, reset: true } ) {
+ Expr.pseudos[ i ] = createButtonPseudo( i );
+}
+
+function tokenize( selector, parseOnly ) {
+ var matched, match, tokens, type,
+ soFar, groups, preFilters,
+ cached = tokenCache[ selector + " " ];
+
+ if ( cached ) {
+ return parseOnly ? 0 : cached.slice( 0 );
+ }
+
+ soFar = selector;
+ groups = [];
+ preFilters = Expr.preFilter;
+
+ while ( soFar ) {
+
+ // Comma and first run
+ if ( !matched || (match = rcomma.exec( soFar )) ) {
+ if ( match ) {
+ // Don't consume trailing commas as valid
+ soFar = soFar.slice( match[0].length ) || soFar;
+ }
+ groups.push( tokens = [] );
+ }
+
+ matched = false;
+
+ // Combinators
+ if ( (match = rcombinators.exec( soFar )) ) {
+ matched = match.shift();
+ tokens.push( {
+ value: matched,
+ // Cast descendant combinators to space
+ type: match[0].replace( rtrim, " " )
+ } );
+ soFar = soFar.slice( matched.length );
+ }
+
+ // Filters
+ for ( type in Expr.filter ) {
+ if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
+ (match = preFilters[ type ]( match ))) ) {
+ matched = match.shift();
+ tokens.push( {
+ value: matched,
+ type: type,
+ matches: match
+ } );
+ soFar = soFar.slice( matched.length );
+ }
+ }
+
+ if ( !matched ) {
+ break;
+ }
+ }
+
+ // Return the length of the invalid excess
+ // if we're just parsing
+ // Otherwise, throw an error or return tokens
+ return parseOnly ?
+ soFar.length :
+ soFar ?
+ Sizzle.error( selector ) :
+ // Cache the tokens
+ tokenCache( selector, groups ).slice( 0 );
+}
+
+function toSelector( tokens ) {
+ var i = 0,
+ len = tokens.length,
+ selector = "";
+ for ( ; i < len; i++ ) {
+ selector += tokens[i].value;
+ }
+ return selector;
+}
+
+function addCombinator( matcher, combinator, base ) {
+ var dir = combinator.dir,
+ checkNonElements = base && dir === "parentNode",
+ doneName = done++;
+
+ return combinator.first ?
+ // Check against closest ancestor/preceding element
+ function( elem, context, xml ) {
+ while ( (elem = elem[ dir ]) ) {
+ if ( elem.nodeType === 1 || checkNonElements ) {
+ return matcher( elem, context, xml );
+ }
+ }
+ } :
+
+ // Check against all ancestor/preceding elements
+ function( elem, context, xml ) {
+ var data, cache, outerCache,
+ dirkey = dirruns + " " + doneName;
+
+ // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
+ if ( xml ) {
+ while ( (elem = elem[ dir ]) ) {
+ if ( elem.nodeType === 1 || checkNonElements ) {
+ if ( matcher( elem, context, xml ) ) {
+ return true;
+ }
+ }
+ }
+ } else {
+ while ( (elem = elem[ dir ]) ) {
+ if ( elem.nodeType === 1 || checkNonElements ) {
+ outerCache = elem[ expando ] || (elem[ expando ] = {});
+ if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) {
+ if ( (data = cache[1]) === true || data === cachedruns ) {
+ return data === true;
+ }
+ } else {
+ cache = outerCache[ dir ] = [ dirkey ];
+ cache[1] = matcher( elem, context, xml ) || cachedruns;
+ if ( cache[1] === true ) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ };
+}
+
+function elementMatcher( matchers ) {
+ return matchers.length > 1 ?
+ function( elem, context, xml ) {
+ var i = matchers.length;
+ while ( i-- ) {
+ if ( !matchers[i]( elem, context, xml ) ) {
+ return false;
+ }
+ }
+ return true;
+ } :
+ matchers[0];
+}
+
+function condense( unmatched, map, filter, context, xml ) {
+ var elem,
+ newUnmatched = [],
+ i = 0,
+ len = unmatched.length,
+ mapped = map != null;
+
+ for ( ; i < len; i++ ) {
+ if ( (elem = unmatched[i]) ) {
+ if ( !filter || filter( elem, context, xml ) ) {
+ newUnmatched.push( elem );
+ if ( mapped ) {
+ map.push( i );
+ }
+ }
+ }
+ }
+
+ return newUnmatched;
+}
+
+function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
+ if ( postFilter && !postFilter[ expando ] ) {
+ postFilter = setMatcher( postFilter );
+ }
+ if ( postFinder && !postFinder[ expando ] ) {
+ postFinder = setMatcher( postFinder, postSelector );
+ }
+ return markFunction(function( seed, results, context, xml ) {
+ var temp, i, elem,
+ preMap = [],
+ postMap = [],
+ preexisting = results.length,
+
+ // Get initial elements from seed or context
+ elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
+
+ // Prefilter to get matcher input, preserving a map for seed-results synchronization
+ matcherIn = preFilter && ( seed || !selector ) ?
+ condense( elems, preMap, preFilter, context, xml ) :
+ elems,
+
+ matcherOut = matcher ?
+ // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
+ postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
+
+ // ...intermediate processing is necessary
+ [] :
+
+ // ...otherwise use results directly
+ results :
+ matcherIn;
+
+ // Find primary matches
+ if ( matcher ) {
+ matcher( matcherIn, matcherOut, context, xml );
+ }
+
+ // Apply postFilter
+ if ( postFilter ) {
+ temp = condense( matcherOut, postMap );
+ postFilter( temp, [], context, xml );
+
+ // Un-match failing elements by moving them back to matcherIn
+ i = temp.length;
+ while ( i-- ) {
+ if ( (elem = temp[i]) ) {
+ matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
+ }
+ }
+ }
+
+ if ( seed ) {
+ if ( postFinder || preFilter ) {
+ if ( postFinder ) {
+ // Get the final matcherOut by condensing this intermediate into postFinder contexts
+ temp = [];
+ i = matcherOut.length;
+ while ( i-- ) {
+ if ( (elem = matcherOut[i]) ) {
+ // Restore matcherIn since elem is not yet a final match
+ temp.push( (matcherIn[i] = elem) );
+ }
+ }
+ postFinder( null, (matcherOut = []), temp, xml );
+ }
+
+ // Move matched elements from seed to results to keep them synchronized
+ i = matcherOut.length;
+ while ( i-- ) {
+ if ( (elem = matcherOut[i]) &&
+ (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
+
+ seed[temp] = !(results[temp] = elem);
+ }
+ }
+ }
+
+ // Add elements to results, through postFinder if defined
+ } else {
+ matcherOut = condense(
+ matcherOut === results ?
+ matcherOut.splice( preexisting, matcherOut.length ) :
+ matcherOut
+ );
+ if ( postFinder ) {
+ postFinder( null, results, matcherOut, xml );
+ } else {
+ push.apply( results, matcherOut );
+ }
+ }
+ });
+}
+
+function matcherFromTokens( tokens ) {
+ var checkContext, matcher, j,
+ len = tokens.length,
+ leadingRelative = Expr.relative[ tokens[0].type ],
+ implicitRelative = leadingRelative || Expr.relative[" "],
+ i = leadingRelative ? 1 : 0,
+
+ // The foundational matcher ensures that elements are reachable from top-level context(s)
+ matchContext = addCombinator( function( elem ) {
+ return elem === checkContext;
+ }, implicitRelative, true ),
+ matchAnyContext = addCombinator( function( elem ) {
+ return indexOf.call( checkContext, elem ) > -1;
+ }, implicitRelative, true ),
+ matchers = [ function( elem, context, xml ) {
+ return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
+ (checkContext = context).nodeType ?
+ matchContext( elem, context, xml ) :
+ matchAnyContext( elem, context, xml ) );
+ } ];
+
+ for ( ; i < len; i++ ) {
+ if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
+ matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
+ } else {
+ matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
+
+ // Return special upon seeing a positional matcher
+ if ( matcher[ expando ] ) {
+ // Find the next relative operator (if any) for proper handling
+ j = ++i;
+ for ( ; j < len; j++ ) {
+ if ( Expr.relative[ tokens[j].type ] ) {
+ break;
+ }
+ }
+ return setMatcher(
+ i > 1 && elementMatcher( matchers ),
+ i > 1 && toSelector( tokens.slice( 0, i - 1 ) ).replace( rtrim, "$1" ),
+ matcher,
+ i < j && matcherFromTokens( tokens.slice( i, j ) ),
+ j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
+ j < len && toSelector( tokens )
+ );
+ }
+ matchers.push( matcher );
+ }
+ }
+
+ return elementMatcher( matchers );
+}
+
+function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
+ // A counter to specify which element is currently being matched
+ var matcherCachedRuns = 0,
+ bySet = setMatchers.length > 0,
+ byElement = elementMatchers.length > 0,
+ superMatcher = function( seed, context, xml, results, expandContext ) {
+ var elem, j, matcher,
+ setMatched = [],
+ matchedCount = 0,
+ i = "0",
+ unmatched = seed && [],
+ outermost = expandContext != null,
+ contextBackup = outermostContext,
+ // We must always have either seed elements or context
+ elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
+ // Use integer dirruns iff this is the outermost matcher
+ dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1);
+
+ if ( outermost ) {
+ outermostContext = context !== document && context;
+ cachedruns = matcherCachedRuns;
+ }
+
+ // Add elements passing elementMatchers directly to results
+ // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
+ for ( ; (elem = elems[i]) != null; i++ ) {
+ if ( byElement && elem ) {
+ j = 0;
+ while ( (matcher = elementMatchers[j++]) ) {
+ if ( matcher( elem, context, xml ) ) {
+ results.push( elem );
+ break;
+ }
+ }
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ cachedruns = ++matcherCachedRuns;
+ }
+ }
+
+ // Track unmatched elements for set filters
+ if ( bySet ) {
+ // They will have gone through all possible matchers
+ if ( (elem = !matcher && elem) ) {
+ matchedCount--;
+ }
+
+ // Lengthen the array for every element, matched or not
+ if ( seed ) {
+ unmatched.push( elem );
+ }
+ }
+ }
+
+ // Apply set filters to unmatched elements
+ matchedCount += i;
+ if ( bySet && i !== matchedCount ) {
+ j = 0;
+ while ( (matcher = setMatchers[j++]) ) {
+ matcher( unmatched, setMatched, context, xml );
+ }
+
+ if ( seed ) {
+ // Reintegrate element matches to eliminate the need for sorting
+ if ( matchedCount > 0 ) {
+ while ( i-- ) {
+ if ( !(unmatched[i] || setMatched[i]) ) {
+ setMatched[i] = pop.call( results );
+ }
+ }
+ }
+
+ // Discard index placeholder values to get only actual matches
+ setMatched = condense( setMatched );
+ }
+
+ // Add matches to results
+ push.apply( results, setMatched );
+
+ // Seedless set matches succeeding multiple successful matchers stipulate sorting
+ if ( outermost && !seed && setMatched.length > 0 &&
+ ( matchedCount + setMatchers.length ) > 1 ) {
+
+ Sizzle.uniqueSort( results );
+ }
+ }
+
+ // Override manipulation of globals by nested matchers
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ outermostContext = contextBackup;
+ }
+
+ return unmatched;
+ };
+
+ return bySet ?
+ markFunction( superMatcher ) :
+ superMatcher;
+}
+
+compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
+ var i,
+ setMatchers = [],
+ elementMatchers = [],
+ cached = compilerCache[ selector + " " ];
+
+ if ( !cached ) {
+ // Generate a function of recursive functions that can be used to check each element
+ if ( !group ) {
+ group = tokenize( selector );
+ }
+ i = group.length;
+ while ( i-- ) {
+ cached = matcherFromTokens( group[i] );
+ if ( cached[ expando ] ) {
+ setMatchers.push( cached );
+ } else {
+ elementMatchers.push( cached );
+ }
+ }
+
+ // Cache the compiled function
+ cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
+ }
+ return cached;
+};
+
+function multipleContexts( selector, contexts, results ) {
+ var i = 0,
+ len = contexts.length;
+ for ( ; i < len; i++ ) {
+ Sizzle( selector, contexts[i], results );
+ }
+ return results;
+}
+
+function select( selector, context, results, seed ) {
+ var i, tokens, token, type, find,
+ match = tokenize( selector );
+
+ if ( !seed ) {
+ // Try to minimize operations if there is only one group
+ if ( match.length === 1 ) {
+
+ // Take a shortcut and set the context if the root selector is an ID
+ tokens = match[0] = match[0].slice( 0 );
+ if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
+ context.nodeType === 9 && !documentIsXML &&
+ Expr.relative[ tokens[1].type ] ) {
+
+ context = Expr.find["ID"]( token.matches[0].replace( runescape, funescape ), context )[0];
+ if ( !context ) {
+ return results;
+ }
+
+ selector = selector.slice( tokens.shift().value.length );
+ }
+
+ // Fetch a seed set for right-to-left matching
+ i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
+ while ( i-- ) {
+ token = tokens[i];
+
+ // Abort if we hit a combinator
+ if ( Expr.relative[ (type = token.type) ] ) {
+ break;
+ }
+ if ( (find = Expr.find[ type ]) ) {
+ // Search, expanding context for leading sibling combinators
+ if ( (seed = find(
+ token.matches[0].replace( runescape, funescape ),
+ rsibling.test( tokens[0].type ) && context.parentNode || context
+ )) ) {
+
+ // If seed is empty or no tokens remain, we can return early
+ tokens.splice( i, 1 );
+ selector = seed.length && toSelector( tokens );
+ if ( !selector ) {
+ push.apply( results, slice.call( seed, 0 ) );
+ return results;
+ }
+
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // Compile and execute a filtering function
+ // Provide `match` to avoid retokenization if we modified the selector above
+ compile( selector, match )(
+ seed,
+ context,
+ documentIsXML,
+ results,
+ rsibling.test( selector )
+ );
+ return results;
+}
+
+// Deprecated
+Expr.pseudos["nth"] = Expr.pseudos["eq"];
+
+// Easy API for creating new setFilters
+function setFilters() {}
+Expr.filters = setFilters.prototype = Expr.pseudos;
+Expr.setFilters = new setFilters();
+
+// Initialize with the default document
+setDocument();
+
+// Override sizzle attribute retrieval
+Sizzle.attr = jQuery.attr;
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.pseudos;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.text = Sizzle.getText;
+jQuery.isXMLDoc = Sizzle.isXML;
+jQuery.contains = Sizzle.contains;
+
+
+})( window );
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prev(?:Until|All))/,
+ isSimple = /^.[^:#\[\.,]*$/,
+ rneedsContext = jQuery.expr.match.needsContext,
+ // methods guaranteed to produce a unique set when starting from a unique set
+ guaranteedUnique = {
+ children: true,
+ contents: true,
+ next: true,
+ prev: true
+ };
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var i, ret, self,
+ len = this.length;
+
+ if ( typeof selector !== "string" ) {
+ self = this;
+ return this.pushStack( jQuery( selector ).filter(function() {
+ for ( i = 0; i < len; i++ ) {
+ if ( jQuery.contains( self[ i ], this ) ) {
+ return true;
+ }
+ }
+ }) );
+ }
+
+ ret = [];
+ for ( i = 0; i < len; i++ ) {
+ jQuery.find( selector, this[ i ], ret );
+ }
+
+ // Needed because $( selector, context ) becomes $( context ).find( selector )
+ ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
+ ret.selector = ( this.selector ? this.selector + " " : "" ) + selector;
+ return ret;
+ },
+
+ has: function( target ) {
+ var i,
+ targets = jQuery( target, this ),
+ len = targets.length;
+
+ return this.filter(function() {
+ for ( i = 0; i < len; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false) );
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true) );
+ },
+
+ is: function( selector ) {
+ return !!selector && (
+ typeof selector === "string" ?
+ // If this is a positional/relative selector, check membership in the returned set
+ // so $("p:first").is("p:last") won't return true for a doc with two "p".
+ rneedsContext.test( selector ) ?
+ jQuery( selector, this.context ).index( this[0] ) >= 0 :
+ jQuery.filter( selector, this ).length > 0 :
+ this.filter( selector ).length > 0 );
+ },
+
+ closest: function( selectors, context ) {
+ var cur,
+ i = 0,
+ l = this.length,
+ ret = [],
+ pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
+ jQuery( selectors, context || this.context ) :
+ 0;
+
+ for ( ; i < l; i++ ) {
+ cur = this[i];
+
+ while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
+ ret.push( cur );
+ break;
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret );
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+
+ // No argument, return index in parent
+ if ( !elem ) {
+ return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
+ }
+
+ // index in selector
+ if ( typeof elem === "string" ) {
+ return jQuery.inArray( this[0], jQuery( elem ) );
+ }
+
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context ) :
+ jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( jQuery.unique(all) );
+ },
+
+ addBack: function( selector ) {
+ return this.add( selector == null ?
+ this.prevObject : this.prevObject.filter(selector)
+ );
+ }
+});
+
+jQuery.fn.andSelf = jQuery.fn.addBack;
+
+function sibling( cur, dir ) {
+ do {
+ cur = cur[ dir ];
+ } while ( cur && cur.nodeType !== 1 );
+
+ return cur;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return sibling( elem, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return sibling( elem, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.merge( [], elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
+
+ if ( this.length > 1 && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return elems.length === 1 ?
+ jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
+ jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [],
+ cur = elem[ dir ];
+
+ while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+
+// Implement the identical functionality for filter and not
+function winnow( elements, qualifier, keep ) {
+
+ // Can't pass null or undefined to indexOf in Firefox 4
+ // Set to 0 to skip string check
+ qualifier = qualifier || 0;
+
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ var retVal = !!qualifier.call( elem, i, elem );
+ return retVal === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem ) {
+ return ( elem === qualifier ) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, filtered );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem ) {
+ return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
+ });
+}
+function createSafeFragment( document ) {
+ var list = nodeNames.split( "|" ),
+ safeFrag = document.createDocumentFragment();
+
+ if ( safeFrag.createElement ) {
+ while ( list.length ) {
+ safeFrag.createElement(
+ list.pop()
+ );
+ }
+ }
+ return safeFrag;
+}
+
+var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
+ "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
+ rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
+ rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
+ rtagName = /<([\w:]+)/,
+ rtbody = /\s*$/g,
+
+ // We have to close these tags to support XHTML (#13200)
+ wrapMap = {
+ option: [ 1, "", " " ],
+ legend: [ 1, "", " " ],
+ area: [ 1, "", " " ],
+ param: [ 1, "", " " ],
+ thead: [ 1, "" ],
+ tr: [ 2, "" ],
+ col: [ 2, "" ],
+ td: [ 3, "" ],
+
+ // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
+ // unless wrapped in a div with non-breaking characters in front of it.
+ _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X", "
" ]
+ },
+ safeFragment = createSafeFragment( document ),
+ fragmentDiv = safeFragment.appendChild( document.createElement("div") );
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+jQuery.fn.extend({
+ text: function( value ) {
+ return jQuery.access( this, function( value ) {
+ return value === undefined ?
+ jQuery.text( this ) :
+ this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
+ }, null, value, arguments.length );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append( this );
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapInner( html.call(this, i) );
+ });
+ }
+
+ return this.each(function() {
+ var self = jQuery( this ),
+ contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ var isFunction = jQuery.isFunction( html );
+
+ return this.each(function(i) {
+ jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ return this.domManip( arguments, false, function( elem ) {
+ if ( this.parentNode ) {
+ this.parentNode.insertBefore( elem, this );
+ }
+ });
+ },
+
+ after: function() {
+ return this.domManip( arguments, false, function( elem ) {
+ if ( this.parentNode ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ }
+ });
+ },
+
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ var elem,
+ i = 0;
+
+ for ( ; (elem = this[i]) != null; i++ ) {
+ if ( !selector || jQuery.filter( selector, [ elem ] ).length > 0 ) {
+ if ( !keepData && elem.nodeType === 1 ) {
+ jQuery.cleanData( getAll( elem ) );
+ }
+
+ if ( elem.parentNode ) {
+ if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
+ setGlobalEval( getAll( elem, "script" ) );
+ }
+ elem.parentNode.removeChild( elem );
+ }
+ }
+ }
+
+ return this;
+ },
+
+ empty: function() {
+ var elem,
+ i = 0;
+
+ for ( ; (elem = this[i]) != null; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( getAll( elem, false ) );
+ }
+
+ // Remove any remaining nodes
+ while ( elem.firstChild ) {
+ elem.removeChild( elem.firstChild );
+ }
+
+ // If this is a select, ensure that it displays empty (#12336)
+ // Support: IE<9
+ if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
+ elem.options.length = 0;
+ }
+ }
+
+ return this;
+ },
+
+ clone: function( dataAndEvents, deepDataAndEvents ) {
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
+ deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
+
+ return this.map( function () {
+ return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
+ });
+ },
+
+ html: function( value ) {
+ return jQuery.access( this, function( value ) {
+ var elem = this[0] || {},
+ i = 0,
+ l = this.length;
+
+ if ( value === undefined ) {
+ return elem.nodeType === 1 ?
+ elem.innerHTML.replace( rinlinejQuery, "" ) :
+ undefined;
+ }
+
+ // See if we can take a shortcut and just use innerHTML
+ if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
+ ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
+ ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
+ !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
+
+ value = value.replace( rxhtmlTag, "<$1>$2>" );
+
+ try {
+ for (; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ elem = this[i] || {};
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( getAll( elem, false ) );
+ elem.innerHTML = value;
+ }
+ }
+
+ elem = 0;
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {}
+ }
+
+ if ( elem ) {
+ this.empty().append( value );
+ }
+ }, null, value, arguments.length );
+ },
+
+ replaceWith: function( value ) {
+ var isFunc = jQuery.isFunction( value );
+
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( !isFunc && typeof value !== "string" ) {
+ value = jQuery( value ).not( this ).detach();
+ }
+
+ return this.domManip( [ value ], true, function( elem ) {
+ var next = this.nextSibling,
+ parent = this.parentNode;
+
+ if ( parent ) {
+ jQuery( this ).remove();
+ parent.insertBefore( elem, next );
+ }
+ });
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+
+ // Flatten any nested arrays
+ args = core_concat.apply( [], args );
+
+ var first, node, hasScripts,
+ scripts, doc, fragment,
+ i = 0,
+ l = this.length,
+ set = this,
+ iNoClone = l - 1,
+ value = args[0],
+ isFunction = jQuery.isFunction( value );
+
+ // We can't cloneNode fragments that contain checked, in WebKit
+ if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) {
+ return this.each(function( index ) {
+ var self = set.eq( index );
+ if ( isFunction ) {
+ args[0] = value.call( this, index, table ? self.html() : undefined );
+ }
+ self.domManip( args, table, callback );
+ });
+ }
+
+ if ( l ) {
+ fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
+ first = fragment.firstChild;
+
+ if ( fragment.childNodes.length === 1 ) {
+ fragment = first;
+ }
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+ scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
+ hasScripts = scripts.length;
+
+ // Use the original fragment for the last item instead of the first because it can end up
+ // being emptied incorrectly in certain situations (#8070).
+ for ( ; i < l; i++ ) {
+ node = fragment;
+
+ if ( i !== iNoClone ) {
+ node = jQuery.clone( node, true, true );
+
+ // Keep references to cloned scripts for later restoration
+ if ( hasScripts ) {
+ jQuery.merge( scripts, getAll( node, "script" ) );
+ }
+ }
+
+ callback.call(
+ table && jQuery.nodeName( this[i], "table" ) ?
+ findOrAppend( this[i], "tbody" ) :
+ this[i],
+ node,
+ i
+ );
+ }
+
+ if ( hasScripts ) {
+ doc = scripts[ scripts.length - 1 ].ownerDocument;
+
+ // Reenable scripts
+ jQuery.map( scripts, restoreScript );
+
+ // Evaluate executable scripts on first document insertion
+ for ( i = 0; i < hasScripts; i++ ) {
+ node = scripts[ i ];
+ if ( rscriptType.test( node.type || "" ) &&
+ !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
+
+ if ( node.src ) {
+ // Hope ajax is available...
+ jQuery.ajax({
+ url: node.src,
+ type: "GET",
+ dataType: "script",
+ async: false,
+ global: false,
+ "throws": true
+ });
+ } else {
+ jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
+ }
+ }
+ }
+ }
+
+ // Fix #11809: Avoid leaking memory
+ fragment = first = null;
+ }
+ }
+
+ return this;
+ }
+});
+
+function findOrAppend( elem, tag ) {
+ return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
+}
+
+// Replace/restore the type attribute of script elements for safe DOM manipulation
+function disableScript( elem ) {
+ var attr = elem.getAttributeNode("type");
+ elem.type = ( attr && attr.specified ) + "/" + elem.type;
+ return elem;
+}
+function restoreScript( elem ) {
+ var match = rscriptTypeMasked.exec( elem.type );
+ if ( match ) {
+ elem.type = match[1];
+ } else {
+ elem.removeAttribute("type");
+ }
+ return elem;
+}
+
+// Mark scripts as having already been evaluated
+function setGlobalEval( elems, refElements ) {
+ var elem,
+ i = 0;
+ for ( ; (elem = elems[i]) != null; i++ ) {
+ jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
+ }
+}
+
+function cloneCopyEvent( src, dest ) {
+
+ if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
+ return;
+ }
+
+ var type, i, l,
+ oldData = jQuery._data( src ),
+ curData = jQuery._data( dest, oldData ),
+ events = oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( type in events ) {
+ for ( i = 0, l = events[ type ].length; i < l; i++ ) {
+ jQuery.event.add( dest, type, events[ type ][ i ] );
+ }
+ }
+ }
+
+ // make the cloned public data object a copy from the original
+ if ( curData.data ) {
+ curData.data = jQuery.extend( {}, curData.data );
+ }
+}
+
+function fixCloneNodeIssues( src, dest ) {
+ var nodeName, e, data;
+
+ // We do not need to do anything for non-Elements
+ if ( dest.nodeType !== 1 ) {
+ return;
+ }
+
+ nodeName = dest.nodeName.toLowerCase();
+
+ // IE6-8 copies events bound via attachEvent when using cloneNode.
+ if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) {
+ data = jQuery._data( dest );
+
+ for ( e in data.events ) {
+ jQuery.removeEvent( dest, e, data.handle );
+ }
+
+ // Event data gets referenced instead of copied if the expando gets copied too
+ dest.removeAttribute( jQuery.expando );
+ }
+
+ // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
+ if ( nodeName === "script" && dest.text !== src.text ) {
+ disableScript( dest ).text = src.text;
+ restoreScript( dest );
+
+ // IE6-10 improperly clones children of object elements using classid.
+ // IE10 throws NoModificationAllowedError if parent is null, #12132.
+ } else if ( nodeName === "object" ) {
+ if ( dest.parentNode ) {
+ dest.outerHTML = src.outerHTML;
+ }
+
+ // This path appears unavoidable for IE9. When cloning an object
+ // element in IE9, the outerHTML strategy above is not sufficient.
+ // If the src has innerHTML and the destination does not,
+ // copy the src.innerHTML into the dest.innerHTML. #10324
+ if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
+ dest.innerHTML = src.innerHTML;
+ }
+
+ } else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
+ // IE6-8 fails to persist the checked state of a cloned checkbox
+ // or radio button. Worse, IE6-7 fail to give the cloned element
+ // a checked appearance if the defaultChecked value isn't also set
+
+ dest.defaultChecked = dest.checked = src.checked;
+
+ // IE6-7 get confused and end up setting the value of a cloned
+ // checkbox/radio button to an empty string instead of "on"
+ if ( dest.value !== src.value ) {
+ dest.value = src.value;
+ }
+
+ // IE6-8 fails to return the selected option to the default selected
+ // state when cloning options
+ } else if ( nodeName === "option" ) {
+ dest.defaultSelected = dest.selected = src.defaultSelected;
+
+ // IE6-8 fails to set the defaultValue to the correct value when
+ // cloning other types of input fields
+ } else if ( nodeName === "input" || nodeName === "textarea" ) {
+ dest.defaultValue = src.defaultValue;
+ }
+}
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var elems,
+ i = 0,
+ ret = [],
+ insert = jQuery( selector ),
+ last = insert.length - 1;
+
+ for ( ; i <= last; i++ ) {
+ elems = i === last ? this : this.clone(true);
+ jQuery( insert[i] )[ original ]( elems );
+
+ // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
+ core_push.apply( ret, elems.get() );
+ }
+
+ return this.pushStack( ret );
+ };
+});
+
+function getAll( context, tag ) {
+ var elems, elem,
+ i = 0,
+ found = typeof context.getElementsByTagName !== core_strundefined ? context.getElementsByTagName( tag || "*" ) :
+ typeof context.querySelectorAll !== core_strundefined ? context.querySelectorAll( tag || "*" ) :
+ undefined;
+
+ if ( !found ) {
+ for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
+ if ( !tag || jQuery.nodeName( elem, tag ) ) {
+ found.push( elem );
+ } else {
+ jQuery.merge( found, getAll( elem, tag ) );
+ }
+ }
+ }
+
+ return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
+ jQuery.merge( [ context ], found ) :
+ found;
+}
+
+// Used in buildFragment, fixes the defaultChecked property
+function fixDefaultChecked( elem ) {
+ if ( manipulation_rcheckableType.test( elem.type ) ) {
+ elem.defaultChecked = elem.checked;
+ }
+}
+
+jQuery.extend({
+ clone: function( elem, dataAndEvents, deepDataAndEvents ) {
+ var destElements, node, clone, i, srcElements,
+ inPage = jQuery.contains( elem.ownerDocument, elem );
+
+ if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
+ clone = elem.cloneNode( true );
+
+ // IE<=8 does not properly clone detached, unknown element nodes
+ } else {
+ fragmentDiv.innerHTML = elem.outerHTML;
+ fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
+ }
+
+ if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
+ (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
+
+ // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
+ destElements = getAll( clone );
+ srcElements = getAll( elem );
+
+ // Fix all IE cloning issues
+ for ( i = 0; (node = srcElements[i]) != null; ++i ) {
+ // Ensure that the destination node is not null; Fixes #9587
+ if ( destElements[i] ) {
+ fixCloneNodeIssues( node, destElements[i] );
+ }
+ }
+ }
+
+ // Copy the events from the original to the clone
+ if ( dataAndEvents ) {
+ if ( deepDataAndEvents ) {
+ srcElements = srcElements || getAll( elem );
+ destElements = destElements || getAll( clone );
+
+ for ( i = 0; (node = srcElements[i]) != null; i++ ) {
+ cloneCopyEvent( node, destElements[i] );
+ }
+ } else {
+ cloneCopyEvent( elem, clone );
+ }
+ }
+
+ // Preserve script evaluation history
+ destElements = getAll( clone, "script" );
+ if ( destElements.length > 0 ) {
+ setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
+ }
+
+ destElements = srcElements = node = null;
+
+ // Return the cloned set
+ return clone;
+ },
+
+ buildFragment: function( elems, context, scripts, selection ) {
+ var j, elem, contains,
+ tmp, tag, tbody, wrap,
+ l = elems.length,
+
+ // Ensure a safe fragment
+ safe = createSafeFragment( context ),
+
+ nodes = [],
+ i = 0;
+
+ for ( ; i < l; i++ ) {
+ elem = elems[ i ];
+
+ if ( elem || elem === 0 ) {
+
+ // Add nodes directly
+ if ( jQuery.type( elem ) === "object" ) {
+ jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
+
+ // Convert non-html into a text node
+ } else if ( !rhtml.test( elem ) ) {
+ nodes.push( context.createTextNode( elem ) );
+
+ // Convert html into DOM nodes
+ } else {
+ tmp = tmp || safe.appendChild( context.createElement("div") );
+
+ // Deserialize a standard representation
+ tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
+ wrap = wrapMap[ tag ] || wrapMap._default;
+
+ tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1>$2>" ) + wrap[2];
+
+ // Descend through wrappers to the right content
+ j = wrap[0];
+ while ( j-- ) {
+ tmp = tmp.lastChild;
+ }
+
+ // Manually add leading whitespace removed by IE
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
+ }
+
+ // Remove IE's autoinserted from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a , *may* have spurious
+ elem = tag === "table" && !rtbody.test( elem ) ?
+ tmp.firstChild :
+
+ // String was a bare or
+ wrap[1] === "" && !rtbody.test( elem ) ?
+ tmp :
+ 0;
+
+ j = elem && elem.childNodes.length;
+ while ( j-- ) {
+ if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
+ elem.removeChild( tbody );
+ }
+ }
+ }
+
+ jQuery.merge( nodes, tmp.childNodes );
+
+ // Fix #12392 for WebKit and IE > 9
+ tmp.textContent = "";
+
+ // Fix #12392 for oldIE
+ while ( tmp.firstChild ) {
+ tmp.removeChild( tmp.firstChild );
+ }
+
+ // Remember the top-level container for proper cleanup
+ tmp = safe.lastChild;
+ }
+ }
+ }
+
+ // Fix #11356: Clear elements from fragment
+ if ( tmp ) {
+ safe.removeChild( tmp );
+ }
+
+ // Reset defaultChecked for any radios and checkboxes
+ // about to be appended to the DOM in IE 6/7 (#8060)
+ if ( !jQuery.support.appendChecked ) {
+ jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
+ }
+
+ i = 0;
+ while ( (elem = nodes[ i++ ]) ) {
+
+ // #4087 - If origin and destination elements are the same, and this is
+ // that element, do not do anything
+ if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
+ continue;
+ }
+
+ contains = jQuery.contains( elem.ownerDocument, elem );
+
+ // Append to fragment
+ tmp = getAll( safe.appendChild( elem ), "script" );
+
+ // Preserve script evaluation history
+ if ( contains ) {
+ setGlobalEval( tmp );
+ }
+
+ // Capture executables
+ if ( scripts ) {
+ j = 0;
+ while ( (elem = tmp[ j++ ]) ) {
+ if ( rscriptType.test( elem.type || "" ) ) {
+ scripts.push( elem );
+ }
+ }
+ }
+ }
+
+ tmp = null;
+
+ return safe;
+ },
+
+ cleanData: function( elems, /* internal */ acceptData ) {
+ var elem, type, id, data,
+ i = 0,
+ internalKey = jQuery.expando,
+ cache = jQuery.cache,
+ deleteExpando = jQuery.support.deleteExpando,
+ special = jQuery.event.special;
+
+ for ( ; (elem = elems[i]) != null; i++ ) {
+
+ if ( acceptData || jQuery.acceptData( elem ) ) {
+
+ id = elem[ internalKey ];
+ data = id && cache[ id ];
+
+ if ( data ) {
+ if ( data.events ) {
+ for ( type in data.events ) {
+ if ( special[ type ] ) {
+ jQuery.event.remove( elem, type );
+
+ // This is a shortcut to avoid jQuery.event.remove's overhead
+ } else {
+ jQuery.removeEvent( elem, type, data.handle );
+ }
+ }
+ }
+
+ // Remove cache only if it was not already removed by jQuery.event.remove
+ if ( cache[ id ] ) {
+
+ delete cache[ id ];
+
+ // IE does not allow us to delete expando properties from nodes,
+ // nor does it have a removeAttribute function on Document nodes;
+ // we must handle all of these cases
+ if ( deleteExpando ) {
+ delete elem[ internalKey ];
+
+ } else if ( typeof elem.removeAttribute !== core_strundefined ) {
+ elem.removeAttribute( internalKey );
+
+ } else {
+ elem[ internalKey ] = null;
+ }
+
+ core_deletedIds.push( id );
+ }
+ }
+ }
+ }
+ }
+});
+var iframe, getStyles, curCSS,
+ ralpha = /alpha\([^)]*\)/i,
+ ropacity = /opacity\s*=\s*([^)]*)/,
+ rposition = /^(top|right|bottom|left)$/,
+ // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
+ // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
+ rdisplayswap = /^(none|table(?!-c[ea]).+)/,
+ rmargin = /^margin/,
+ rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
+ rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
+ rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ),
+ elemdisplay = { BODY: "block" },
+
+ cssShow = { position: "absolute", visibility: "hidden", display: "block" },
+ cssNormalTransform = {
+ letterSpacing: 0,
+ fontWeight: 400
+ },
+
+ cssExpand = [ "Top", "Right", "Bottom", "Left" ],
+ cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
+
+// return a css property mapped to a potentially vendor prefixed property
+function vendorPropName( style, name ) {
+
+ // shortcut for names that are not vendor prefixed
+ if ( name in style ) {
+ return name;
+ }
+
+ // check for vendor prefixed names
+ var capName = name.charAt(0).toUpperCase() + name.slice(1),
+ origName = name,
+ i = cssPrefixes.length;
+
+ while ( i-- ) {
+ name = cssPrefixes[ i ] + capName;
+ if ( name in style ) {
+ return name;
+ }
+ }
+
+ return origName;
+}
+
+function isHidden( elem, el ) {
+ // isHidden might be called from jQuery#filter function;
+ // in that case, element will be second argument
+ elem = el || elem;
+ return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
+}
+
+function showHide( elements, show ) {
+ var display, elem, hidden,
+ values = [],
+ index = 0,
+ length = elements.length;
+
+ for ( ; index < length; index++ ) {
+ elem = elements[ index ];
+ if ( !elem.style ) {
+ continue;
+ }
+
+ values[ index ] = jQuery._data( elem, "olddisplay" );
+ display = elem.style.display;
+ if ( show ) {
+ // Reset the inline display of this element to learn if it is
+ // being hidden by cascaded rules or not
+ if ( !values[ index ] && display === "none" ) {
+ elem.style.display = "";
+ }
+
+ // Set elements which have been overridden with display: none
+ // in a stylesheet to whatever the default browser style is
+ // for such an element
+ if ( elem.style.display === "" && isHidden( elem ) ) {
+ values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
+ }
+ } else {
+
+ if ( !values[ index ] ) {
+ hidden = isHidden( elem );
+
+ if ( display && display !== "none" || !hidden ) {
+ jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
+ }
+ }
+ }
+ }
+
+ // Set the display of most of the elements in a second loop
+ // to avoid the constant reflow
+ for ( index = 0; index < length; index++ ) {
+ elem = elements[ index ];
+ if ( !elem.style ) {
+ continue;
+ }
+ if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
+ elem.style.display = show ? values[ index ] || "" : "none";
+ }
+ }
+
+ return elements;
+}
+
+jQuery.fn.extend({
+ css: function( name, value ) {
+ return jQuery.access( this, function( elem, name, value ) {
+ var len, styles,
+ map = {},
+ i = 0;
+
+ if ( jQuery.isArray( name ) ) {
+ styles = getStyles( elem );
+ len = name.length;
+
+ for ( ; i < len; i++ ) {
+ map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
+ }
+
+ return map;
+ }
+
+ return value !== undefined ?
+ jQuery.style( elem, name, value ) :
+ jQuery.css( elem, name );
+ }, name, value, arguments.length > 1 );
+ },
+ show: function() {
+ return showHide( this, true );
+ },
+ hide: function() {
+ return showHide( this );
+ },
+ toggle: function( state ) {
+ var bool = typeof state === "boolean";
+
+ return this.each(function() {
+ if ( bool ? state : isHidden( this ) ) {
+ jQuery( this ).show();
+ } else {
+ jQuery( this ).hide();
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ // Add in style property hooks for overriding the default
+ // behavior of getting and setting a style property
+ cssHooks: {
+ opacity: {
+ get: function( elem, computed ) {
+ if ( computed ) {
+ // We should always get a number back from opacity
+ var ret = curCSS( elem, "opacity" );
+ return ret === "" ? "1" : ret;
+ }
+ }
+ }
+ },
+
+ // Exclude the following css properties to add px
+ cssNumber: {
+ "columnCount": true,
+ "fillOpacity": true,
+ "fontWeight": true,
+ "lineHeight": true,
+ "opacity": true,
+ "orphans": true,
+ "widows": true,
+ "zIndex": true,
+ "zoom": true
+ },
+
+ // Add in properties whose names you wish to fix before
+ // setting or getting the value
+ cssProps: {
+ // normalize float css property
+ "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
+ },
+
+ // Get and set the style property on a DOM Node
+ style: function( elem, name, value, extra ) {
+ // Don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
+ return;
+ }
+
+ // Make sure that we're working with the right name
+ var ret, type, hooks,
+ origName = jQuery.camelCase( name ),
+ style = elem.style;
+
+ name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
+
+ // gets hook for the prefixed version
+ // followed by the unprefixed version
+ hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+ // Check if we're setting a value
+ if ( value !== undefined ) {
+ type = typeof value;
+
+ // convert relative number strings (+= or -=) to relative numbers. #7345
+ if ( type === "string" && (ret = rrelNum.exec( value )) ) {
+ value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
+ // Fixes bug #9237
+ type = "number";
+ }
+
+ // Make sure that NaN and null values aren't set. See: #7116
+ if ( value == null || type === "number" && isNaN( value ) ) {
+ return;
+ }
+
+ // If a number was passed in, add 'px' to the (except for certain CSS properties)
+ if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
+ value += "px";
+ }
+
+ // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
+ // but it would mean to define eight (for every problematic property) identical functions
+ if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
+ style[ name ] = "inherit";
+ }
+
+ // If a hook was provided, use that value, otherwise just set the specified value
+ if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
+
+ // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
+ // Fixes bug #5509
+ try {
+ style[ name ] = value;
+ } catch(e) {}
+ }
+
+ } else {
+ // If a hook was provided get the non-computed value from there
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
+ return ret;
+ }
+
+ // Otherwise just get the value from the style object
+ return style[ name ];
+ }
+ },
+
+ css: function( elem, name, extra, styles ) {
+ var num, val, hooks,
+ origName = jQuery.camelCase( name );
+
+ // Make sure that we're working with the right name
+ name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
+
+ // gets hook for the prefixed version
+ // followed by the unprefixed version
+ hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+ // If a hook was provided get the computed value from there
+ if ( hooks && "get" in hooks ) {
+ val = hooks.get( elem, true, extra );
+ }
+
+ // Otherwise, if a way to get the computed value exists, use that
+ if ( val === undefined ) {
+ val = curCSS( elem, name, styles );
+ }
+
+ //convert "normal" to computed value
+ if ( val === "normal" && name in cssNormalTransform ) {
+ val = cssNormalTransform[ name ];
+ }
+
+ // Return, converting to number if forced or a qualifier was provided and val looks numeric
+ if ( extra === "" || extra ) {
+ num = parseFloat( val );
+ return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
+ }
+ return val;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback, args ) {
+ var ret, name,
+ old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ ret = callback.apply( elem, args || [] );
+
+ // Revert the old values
+ for ( name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+
+ return ret;
+ }
+});
+
+// NOTE: we've included the "window" in window.getComputedStyle
+// because jsdom on node.js will break without it.
+if ( window.getComputedStyle ) {
+ getStyles = function( elem ) {
+ return window.getComputedStyle( elem, null );
+ };
+
+ curCSS = function( elem, name, _computed ) {
+ var width, minWidth, maxWidth,
+ computed = _computed || getStyles( elem ),
+
+ // getPropertyValue is only needed for .css('filter') in IE9, see #12537
+ ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined,
+ style = elem.style;
+
+ if ( computed ) {
+
+ if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
+ ret = jQuery.style( elem, name );
+ }
+
+ // A tribute to the "awesome hack by Dean Edwards"
+ // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
+ // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
+ // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
+ if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
+
+ // Remember the original values
+ width = style.width;
+ minWidth = style.minWidth;
+ maxWidth = style.maxWidth;
+
+ // Put in the new values to get a computed value out
+ style.minWidth = style.maxWidth = style.width = ret;
+ ret = computed.width;
+
+ // Revert the changed values
+ style.width = width;
+ style.minWidth = minWidth;
+ style.maxWidth = maxWidth;
+ }
+ }
+
+ return ret;
+ };
+} else if ( document.documentElement.currentStyle ) {
+ getStyles = function( elem ) {
+ return elem.currentStyle;
+ };
+
+ curCSS = function( elem, name, _computed ) {
+ var left, rs, rsLeft,
+ computed = _computed || getStyles( elem ),
+ ret = computed ? computed[ name ] : undefined,
+ style = elem.style;
+
+ // Avoid setting ret to empty string here
+ // so we don't default to auto
+ if ( ret == null && style && style[ name ] ) {
+ ret = style[ name ];
+ }
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ // but not position css attributes, as those are proportional to the parent element instead
+ // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
+ if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
+
+ // Remember the original values
+ left = style.left;
+ rs = elem.runtimeStyle;
+ rsLeft = rs && rs.left;
+
+ // Put in the new values to get a computed value out
+ if ( rsLeft ) {
+ rs.left = elem.currentStyle.left;
+ }
+ style.left = name === "fontSize" ? "1em" : ret;
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ if ( rsLeft ) {
+ rs.left = rsLeft;
+ }
+ }
+
+ return ret === "" ? "auto" : ret;
+ };
+}
+
+function setPositiveNumber( elem, value, subtract ) {
+ var matches = rnumsplit.exec( value );
+ return matches ?
+ // Guard against undefined "subtract", e.g., when used as in cssHooks
+ Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
+ value;
+}
+
+function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
+ var i = extra === ( isBorderBox ? "border" : "content" ) ?
+ // If we already have the right measurement, avoid augmentation
+ 4 :
+ // Otherwise initialize for horizontal or vertical properties
+ name === "width" ? 1 : 0,
+
+ val = 0;
+
+ for ( ; i < 4; i += 2 ) {
+ // both box models exclude margin, so add it if we want it
+ if ( extra === "margin" ) {
+ val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
+ }
+
+ if ( isBorderBox ) {
+ // border-box includes padding, so remove it if we want content
+ if ( extra === "content" ) {
+ val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+ }
+
+ // at this point, extra isn't border nor margin, so remove border
+ if ( extra !== "margin" ) {
+ val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+ }
+ } else {
+ // at this point, extra isn't content, so add padding
+ val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+
+ // at this point, extra isn't content nor padding, so add border
+ if ( extra !== "padding" ) {
+ val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+ }
+ }
+ }
+
+ return val;
+}
+
+function getWidthOrHeight( elem, name, extra ) {
+
+ // Start with offset property, which is equivalent to the border-box value
+ var valueIsBorderBox = true,
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
+ styles = getStyles( elem ),
+ isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
+
+ // some non-html elements return undefined for offsetWidth, so check for null/undefined
+ // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
+ // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
+ if ( val <= 0 || val == null ) {
+ // Fall back to computed then uncomputed css if necessary
+ val = curCSS( elem, name, styles );
+ if ( val < 0 || val == null ) {
+ val = elem.style[ name ];
+ }
+
+ // Computed unit is not pixels. Stop here and return.
+ if ( rnumnonpx.test(val) ) {
+ return val;
+ }
+
+ // we need the check for style in case a browser which returns unreliable values
+ // for getComputedStyle silently falls back to the reliable elem.style
+ valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
+
+ // Normalize "", auto, and prepare for extra
+ val = parseFloat( val ) || 0;
+ }
+
+ // use the active box-sizing model to add/subtract irrelevant styles
+ return ( val +
+ augmentWidthOrHeight(
+ elem,
+ name,
+ extra || ( isBorderBox ? "border" : "content" ),
+ valueIsBorderBox,
+ styles
+ )
+ ) + "px";
+}
+
+// Try to determine the default display value of an element
+function css_defaultDisplay( nodeName ) {
+ var doc = document,
+ display = elemdisplay[ nodeName ];
+
+ if ( !display ) {
+ display = actualDisplay( nodeName, doc );
+
+ // If the simple way fails, read from inside an iframe
+ if ( display === "none" || !display ) {
+ // Use the already-created iframe if possible
+ iframe = ( iframe ||
+ jQuery("")
+ .css( "cssText", "display:block !important" )
+ ).appendTo( doc.documentElement );
+
+ // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
+ doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
+ doc.write("");
+ doc.close();
+
+ display = actualDisplay( nodeName, doc );
+ iframe.detach();
+ }
+
+ // Store the correct default display
+ elemdisplay[ nodeName ] = display;
+ }
+
+ return display;
+}
+
+// Called ONLY from within css_defaultDisplay
+function actualDisplay( name, doc ) {
+ var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
+ display = jQuery.css( elem[0], "display" );
+ elem.remove();
+ return display;
+}
+
+jQuery.each([ "height", "width" ], function( i, name ) {
+ jQuery.cssHooks[ name ] = {
+ get: function( elem, computed, extra ) {
+ if ( computed ) {
+ // certain elements can have dimension info if we invisibly show them
+ // however, it must have a current display style that would benefit from this
+ return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
+ jQuery.swap( elem, cssShow, function() {
+ return getWidthOrHeight( elem, name, extra );
+ }) :
+ getWidthOrHeight( elem, name, extra );
+ }
+ },
+
+ set: function( elem, value, extra ) {
+ var styles = extra && getStyles( elem );
+ return setPositiveNumber( elem, value, extra ?
+ augmentWidthOrHeight(
+ elem,
+ name,
+ extra,
+ jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
+ styles
+ ) : 0
+ );
+ }
+ };
+});
+
+if ( !jQuery.support.opacity ) {
+ jQuery.cssHooks.opacity = {
+ get: function( elem, computed ) {
+ // IE uses filters for opacity
+ return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
+ ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
+ computed ? "1" : "";
+ },
+
+ set: function( elem, value ) {
+ var style = elem.style,
+ currentStyle = elem.currentStyle,
+ opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
+ filter = currentStyle && currentStyle.filter || style.filter || "";
+
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
+ // if value === "", then remove inline opacity #12685
+ if ( ( value >= 1 || value === "" ) &&
+ jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
+ style.removeAttribute ) {
+
+ // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
+ // if "filter:" is present at all, clearType is disabled, we want to avoid this
+ // style.removeAttribute is IE Only, but so apparently is this code path...
+ style.removeAttribute( "filter" );
+
+ // if there is no filter style applied in a css rule or unset inline opacity, we are done
+ if ( value === "" || currentStyle && !currentStyle.filter ) {
+ return;
+ }
+ }
+
+ // otherwise, set new filter values
+ style.filter = ralpha.test( filter ) ?
+ filter.replace( ralpha, opacity ) :
+ filter + " " + opacity;
+ }
+ };
+}
+
+// These hooks cannot be added until DOM ready because the support test
+// for it is not run until after DOM ready
+jQuery(function() {
+ if ( !jQuery.support.reliableMarginRight ) {
+ jQuery.cssHooks.marginRight = {
+ get: function( elem, computed ) {
+ if ( computed ) {
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ // Work around by temporarily setting element display to inline-block
+ return jQuery.swap( elem, { "display": "inline-block" },
+ curCSS, [ elem, "marginRight" ] );
+ }
+ }
+ };
+ }
+
+ // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
+ // getComputedStyle returns percent when specified for top/left/bottom/right
+ // rather than make the css module depend on the offset module, we just check for it here
+ if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
+ jQuery.each( [ "top", "left" ], function( i, prop ) {
+ jQuery.cssHooks[ prop ] = {
+ get: function( elem, computed ) {
+ if ( computed ) {
+ computed = curCSS( elem, prop );
+ // if curCSS returns percentage, fallback to offset
+ return rnumnonpx.test( computed ) ?
+ jQuery( elem ).position()[ prop ] + "px" :
+ computed;
+ }
+ }
+ };
+ });
+ }
+
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ // Support: Opera <= 12.12
+ // Opera reports offsetWidths and offsetHeights less than zero on some elements
+ return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
+ (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+
+// These hooks are used by animate to expand properties
+jQuery.each({
+ margin: "",
+ padding: "",
+ border: "Width"
+}, function( prefix, suffix ) {
+ jQuery.cssHooks[ prefix + suffix ] = {
+ expand: function( value ) {
+ var i = 0,
+ expanded = {},
+
+ // assumes a single number if not a string
+ parts = typeof value === "string" ? value.split(" ") : [ value ];
+
+ for ( ; i < 4; i++ ) {
+ expanded[ prefix + cssExpand[ i ] + suffix ] =
+ parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
+ }
+
+ return expanded;
+ }
+ };
+
+ if ( !rmargin.test( prefix ) ) {
+ jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
+ }
+});
+var r20 = /%20/g,
+ rbracket = /\[\]$/,
+ rCRLF = /\r?\n/g,
+ rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
+ rsubmittable = /^(?:input|select|textarea|keygen)/i;
+
+jQuery.fn.extend({
+ serialize: function() {
+ return jQuery.param( this.serializeArray() );
+ },
+ serializeArray: function() {
+ return this.map(function(){
+ // Can add propHook for "elements" to filter or add form elements
+ var elements = jQuery.prop( this, "elements" );
+ return elements ? jQuery.makeArray( elements ) : this;
+ })
+ .filter(function(){
+ var type = this.type;
+ // Use .is(":disabled") so that fieldset[disabled] works
+ return this.name && !jQuery( this ).is( ":disabled" ) &&
+ rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
+ ( this.checked || !manipulation_rcheckableType.test( type ) );
+ })
+ .map(function( i, elem ){
+ var val = jQuery( this ).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray( val ) ?
+ jQuery.map( val, function( val ){
+ return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+ }) :
+ { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+ }).get();
+ }
+});
+
+//Serialize an array of form elements or a set of
+//key/values into a query string
+jQuery.param = function( a, traditional ) {
+ var prefix,
+ s = [],
+ add = function( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
+ s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
+ };
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ for ( prefix in a ) {
+ buildParams( prefix, a[ prefix ], traditional, add );
+ }
+ }
+
+ // Return the resulting serialization
+ return s.join( "&" ).replace( r20, "+" );
+};
+
+function buildParams( prefix, obj, traditional, add ) {
+ var name;
+
+ if ( jQuery.isArray( obj ) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional || rbracket.test( prefix ) ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+
+ } else {
+ // Item is non-scalar (array or object), encode its numeric index.
+ buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
+ }
+ });
+
+ } else if ( !traditional && jQuery.type( obj ) === "object" ) {
+ // Serialize object item.
+ for ( name in obj ) {
+ buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
+ }
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+}
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( data, fn ) {
+ return arguments.length > 0 ?
+ this.on( name, null, data, fn ) :
+ this.trigger( name );
+ };
+});
+
+jQuery.fn.hover = function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+};
+var
+ // Document location
+ ajaxLocParts,
+ ajaxLocation,
+ ajax_nonce = jQuery.now(),
+
+ ajax_rquery = /\?/,
+ rhash = /#.*$/,
+ rts = /([?&])_=[^&]*/,
+ rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
+ // #7653, #8125, #8152: local protocol detection
+ rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
+ rnoContent = /^(?:GET|HEAD)$/,
+ rprotocol = /^\/\//,
+ rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
+
+ // Keep a copy of the old load method
+ _load = jQuery.fn.load,
+
+ /* Prefilters
+ * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
+ * 2) These are called:
+ * - BEFORE asking for a transport
+ * - AFTER param serialization (s.data is a string if s.processData is true)
+ * 3) key is the dataType
+ * 4) the catchall symbol "*" can be used
+ * 5) execution will start with transport dataType and THEN continue down to "*" if needed
+ */
+ prefilters = {},
+
+ /* Transports bindings
+ * 1) key is the dataType
+ * 2) the catchall symbol "*" can be used
+ * 3) selection will start with transport dataType and THEN go to "*" if needed
+ */
+ transports = {},
+
+ // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
+ allTypes = "*/".concat("*");
+
+// #8138, IE may throw an exception when accessing
+// a field from window.location if document.domain has been set
+try {
+ ajaxLocation = location.href;
+} catch( e ) {
+ // Use the href attribute of an A element
+ // since IE will modify it given document.location
+ ajaxLocation = document.createElement( "a" );
+ ajaxLocation.href = "";
+ ajaxLocation = ajaxLocation.href;
+}
+
+// Segment location into parts
+ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
+
+// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
+function addToPrefiltersOrTransports( structure ) {
+
+ // dataTypeExpression is optional and defaults to "*"
+ return function( dataTypeExpression, func ) {
+
+ if ( typeof dataTypeExpression !== "string" ) {
+ func = dataTypeExpression;
+ dataTypeExpression = "*";
+ }
+
+ var dataType,
+ i = 0,
+ dataTypes = dataTypeExpression.toLowerCase().match( core_rnotwhite ) || [];
+
+ if ( jQuery.isFunction( func ) ) {
+ // For each dataType in the dataTypeExpression
+ while ( (dataType = dataTypes[i++]) ) {
+ // Prepend if requested
+ if ( dataType[0] === "+" ) {
+ dataType = dataType.slice( 1 ) || "*";
+ (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
+
+ // Otherwise append
+ } else {
+ (structure[ dataType ] = structure[ dataType ] || []).push( func );
+ }
+ }
+ }
+ };
+}
+
+// Base inspection function for prefilters and transports
+function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
+
+ var inspected = {},
+ seekingTransport = ( structure === transports );
+
+ function inspect( dataType ) {
+ var selected;
+ inspected[ dataType ] = true;
+ jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
+ var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
+ if( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
+ options.dataTypes.unshift( dataTypeOrTransport );
+ inspect( dataTypeOrTransport );
+ return false;
+ } else if ( seekingTransport ) {
+ return !( selected = dataTypeOrTransport );
+ }
+ });
+ return selected;
+ }
+
+ return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
+}
+
+// A special extend for ajax options
+// that takes "flat" options (not to be deep extended)
+// Fixes #9887
+function ajaxExtend( target, src ) {
+ var deep, key,
+ flatOptions = jQuery.ajaxSettings.flatOptions || {};
+
+ for ( key in src ) {
+ if ( src[ key ] !== undefined ) {
+ ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
+ }
+ }
+ if ( deep ) {
+ jQuery.extend( true, target, deep );
+ }
+
+ return target;
+}
+
+jQuery.fn.load = function( url, params, callback ) {
+ if ( typeof url !== "string" && _load ) {
+ return _load.apply( this, arguments );
+ }
+
+ var selector, response, type,
+ self = this,
+ off = url.indexOf(" ");
+
+ if ( off >= 0 ) {
+ selector = url.slice( off, url.length );
+ url = url.slice( 0, off );
+ }
+
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+
+ // We assume that it's the callback
+ callback = params;
+ params = undefined;
+
+ // Otherwise, build a param string
+ } else if ( params && typeof params === "object" ) {
+ type = "POST";
+ }
+
+ // If we have elements to modify, make the request
+ if ( self.length > 0 ) {
+ jQuery.ajax({
+ url: url,
+
+ // if "type" variable is undefined, then "GET" method will be used
+ type: type,
+ dataType: "html",
+ data: params
+ }).done(function( responseText ) {
+
+ // Save response for use in complete callback
+ response = arguments;
+
+ self.html( selector ?
+
+ // If a selector was specified, locate the right elements in a dummy div
+ // Exclude scripts to avoid IE 'Permission Denied' errors
+ jQuery("").append( jQuery.parseHTML( responseText ) ).find( selector ) :
+
+ // Otherwise use the full result
+ responseText );
+
+ }).complete( callback && function( jqXHR, status ) {
+ self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
+ });
+ }
+
+ return this;
+};
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){
+ jQuery.fn[ type ] = function( fn ){
+ return this.on( type, fn );
+ };
+});
+
+jQuery.each( [ "get", "post" ], function( i, method ) {
+ jQuery[ method ] = function( url, data, callback, type ) {
+ // shift arguments if data argument was omitted
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = undefined;
+ }
+
+ return jQuery.ajax({
+ url: url,
+ type: method,
+ dataType: type,
+ data: data,
+ success: callback
+ });
+ };
+});
+
+jQuery.extend({
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajaxSettings: {
+ url: ajaxLocation,
+ type: "GET",
+ isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
+ global: true,
+ processData: true,
+ async: true,
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+ /*
+ timeout: 0,
+ data: null,
+ dataType: null,
+ username: null,
+ password: null,
+ cache: null,
+ throws: false,
+ traditional: false,
+ headers: {},
+ */
+
+ accepts: {
+ "*": allTypes,
+ text: "text/plain",
+ html: "text/html",
+ xml: "application/xml, text/xml",
+ json: "application/json, text/javascript"
+ },
+
+ contents: {
+ xml: /xml/,
+ html: /html/,
+ json: /json/
+ },
+
+ responseFields: {
+ xml: "responseXML",
+ text: "responseText"
+ },
+
+ // Data converters
+ // Keys separate source (or catchall "*") and destination types with a single space
+ converters: {
+
+ // Convert anything to text
+ "* text": window.String,
+
+ // Text to html (true = no transformation)
+ "text html": true,
+
+ // Evaluate text as a json expression
+ "text json": jQuery.parseJSON,
+
+ // Parse text as xml
+ "text xml": jQuery.parseXML
+ },
+
+ // For options that shouldn't be deep extended:
+ // you can add your own custom options here if
+ // and when you create one that shouldn't be
+ // deep extended (see ajaxExtend)
+ flatOptions: {
+ url: true,
+ context: true
+ }
+ },
+
+ // Creates a full fledged settings object into target
+ // with both ajaxSettings and settings fields.
+ // If target is omitted, writes into ajaxSettings.
+ ajaxSetup: function( target, settings ) {
+ return settings ?
+
+ // Building a settings object
+ ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
+
+ // Extending ajaxSettings
+ ajaxExtend( jQuery.ajaxSettings, target );
+ },
+
+ ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
+ ajaxTransport: addToPrefiltersOrTransports( transports ),
+
+ // Main method
+ ajax: function( url, options ) {
+
+ // If url is an object, simulate pre-1.5 signature
+ if ( typeof url === "object" ) {
+ options = url;
+ url = undefined;
+ }
+
+ // Force options to be an object
+ options = options || {};
+
+ var // Cross-domain detection vars
+ parts,
+ // Loop variable
+ i,
+ // URL without anti-cache param
+ cacheURL,
+ // Response headers as string
+ responseHeadersString,
+ // timeout handle
+ timeoutTimer,
+
+ // To know if global events are to be dispatched
+ fireGlobals,
+
+ transport,
+ // Response headers
+ responseHeaders,
+ // Create the final options object
+ s = jQuery.ajaxSetup( {}, options ),
+ // Callbacks context
+ callbackContext = s.context || s,
+ // Context for global events is callbackContext if it is a DOM node or jQuery collection
+ globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
+ jQuery( callbackContext ) :
+ jQuery.event,
+ // Deferreds
+ deferred = jQuery.Deferred(),
+ completeDeferred = jQuery.Callbacks("once memory"),
+ // Status-dependent callbacks
+ statusCode = s.statusCode || {},
+ // Headers (they are sent all at once)
+ requestHeaders = {},
+ requestHeadersNames = {},
+ // The jqXHR state
+ state = 0,
+ // Default abort message
+ strAbort = "canceled",
+ // Fake xhr
+ jqXHR = {
+ readyState: 0,
+
+ // Builds headers hashtable if needed
+ getResponseHeader: function( key ) {
+ var match;
+ if ( state === 2 ) {
+ if ( !responseHeaders ) {
+ responseHeaders = {};
+ while ( (match = rheaders.exec( responseHeadersString )) ) {
+ responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
+ }
+ }
+ match = responseHeaders[ key.toLowerCase() ];
+ }
+ return match == null ? null : match;
+ },
+
+ // Raw string
+ getAllResponseHeaders: function() {
+ return state === 2 ? responseHeadersString : null;
+ },
+
+ // Caches the header
+ setRequestHeader: function( name, value ) {
+ var lname = name.toLowerCase();
+ if ( !state ) {
+ name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
+ requestHeaders[ name ] = value;
+ }
+ return this;
+ },
+
+ // Overrides response content-type header
+ overrideMimeType: function( type ) {
+ if ( !state ) {
+ s.mimeType = type;
+ }
+ return this;
+ },
+
+ // Status-dependent callbacks
+ statusCode: function( map ) {
+ var code;
+ if ( map ) {
+ if ( state < 2 ) {
+ for ( code in map ) {
+ // Lazy-add the new callback in a way that preserves old ones
+ statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
+ }
+ } else {
+ // Execute the appropriate callbacks
+ jqXHR.always( map[ jqXHR.status ] );
+ }
+ }
+ return this;
+ },
+
+ // Cancel the request
+ abort: function( statusText ) {
+ var finalText = statusText || strAbort;
+ if ( transport ) {
+ transport.abort( finalText );
+ }
+ done( 0, finalText );
+ return this;
+ }
+ };
+
+ // Attach deferreds
+ deferred.promise( jqXHR ).complete = completeDeferred.add;
+ jqXHR.success = jqXHR.done;
+ jqXHR.error = jqXHR.fail;
+
+ // Remove hash character (#7531: and string promotion)
+ // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
+ // Handle falsy url in the settings object (#10093: consistency with old signature)
+ // We also use the url parameter if available
+ s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
+
+ // Alias method option to type as per ticket #12004
+ s.type = options.method || options.type || s.method || s.type;
+
+ // Extract dataTypes list
+ s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
+
+ // A cross-domain request is in order when we have a protocol:host:port mismatch
+ if ( s.crossDomain == null ) {
+ parts = rurl.exec( s.url.toLowerCase() );
+ s.crossDomain = !!( parts &&
+ ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
+ ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
+ ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
+ );
+ }
+
+ // Convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Apply prefilters
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
+
+ // If request was aborted inside a prefilter, stop there
+ if ( state === 2 ) {
+ return jqXHR;
+ }
+
+ // We can fire global events as of now if asked to
+ fireGlobals = s.global;
+
+ // Watch for a new set of requests
+ if ( fireGlobals && jQuery.active++ === 0 ) {
+ jQuery.event.trigger("ajaxStart");
+ }
+
+ // Uppercase the type
+ s.type = s.type.toUpperCase();
+
+ // Determine if request has content
+ s.hasContent = !rnoContent.test( s.type );
+
+ // Save the URL in case we're toying with the If-Modified-Since
+ // and/or If-None-Match header later on
+ cacheURL = s.url;
+
+ // More options handling for requests with no content
+ if ( !s.hasContent ) {
+
+ // If data is available, append data to url
+ if ( s.data ) {
+ cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
+ // #9682: remove data so that it's not used in an eventual retry
+ delete s.data;
+ }
+
+ // Add anti-cache in url if needed
+ if ( s.cache === false ) {
+ s.url = rts.test( cacheURL ) ?
+
+ // If there is already a '_' parameter, set its value
+ cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) :
+
+ // Otherwise add one to the end
+ cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++;
+ }
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[ cacheURL ] ) {
+ jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
+ }
+ if ( jQuery.etag[ cacheURL ] ) {
+ jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
+ }
+ }
+
+ // Set the correct header, if data is being sent
+ if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
+ jqXHR.setRequestHeader( "Content-Type", s.contentType );
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ jqXHR.setRequestHeader(
+ "Accept",
+ s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
+ s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
+ s.accepts[ "*" ]
+ );
+
+ // Check for headers option
+ for ( i in s.headers ) {
+ jqXHR.setRequestHeader( i, s.headers[ i ] );
+ }
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
+ // Abort if not done already and return
+ return jqXHR.abort();
+ }
+
+ // aborting is no longer a cancellation
+ strAbort = "abort";
+
+ // Install callbacks on deferreds
+ for ( i in { success: 1, error: 1, complete: 1 } ) {
+ jqXHR[ i ]( s[ i ] );
+ }
+
+ // Get transport
+ transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
+
+ // If no transport, we auto-abort
+ if ( !transport ) {
+ done( -1, "No Transport" );
+ } else {
+ jqXHR.readyState = 1;
+
+ // Send global event
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
+ }
+ // Timeout
+ if ( s.async && s.timeout > 0 ) {
+ timeoutTimer = setTimeout(function() {
+ jqXHR.abort("timeout");
+ }, s.timeout );
+ }
+
+ try {
+ state = 1;
+ transport.send( requestHeaders, done );
+ } catch ( e ) {
+ // Propagate exception as error if not done
+ if ( state < 2 ) {
+ done( -1, e );
+ // Simply rethrow otherwise
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ // Callback for when everything is done
+ function done( status, nativeStatusText, responses, headers ) {
+ var isSuccess, success, error, response, modified,
+ statusText = nativeStatusText;
+
+ // Called once
+ if ( state === 2 ) {
+ return;
+ }
+
+ // State is "done" now
+ state = 2;
+
+ // Clear timeout if it exists
+ if ( timeoutTimer ) {
+ clearTimeout( timeoutTimer );
+ }
+
+ // Dereference transport for early garbage collection
+ // (no matter how long the jqXHR object will be used)
+ transport = undefined;
+
+ // Cache response headers
+ responseHeadersString = headers || "";
+
+ // Set readyState
+ jqXHR.readyState = status > 0 ? 4 : 0;
+
+ // Get response data
+ if ( responses ) {
+ response = ajaxHandleResponses( s, jqXHR, responses );
+ }
+
+ // If successful, handle type chaining
+ if ( status >= 200 && status < 300 || status === 304 ) {
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ modified = jqXHR.getResponseHeader("Last-Modified");
+ if ( modified ) {
+ jQuery.lastModified[ cacheURL ] = modified;
+ }
+ modified = jqXHR.getResponseHeader("etag");
+ if ( modified ) {
+ jQuery.etag[ cacheURL ] = modified;
+ }
+ }
+
+ // if no content
+ if ( status === 204 ) {
+ isSuccess = true;
+ statusText = "nocontent";
+
+ // if not modified
+ } else if ( status === 304 ) {
+ isSuccess = true;
+ statusText = "notmodified";
+
+ // If we have data, let's convert it
+ } else {
+ isSuccess = ajaxConvert( s, response );
+ statusText = isSuccess.state;
+ success = isSuccess.data;
+ error = isSuccess.error;
+ isSuccess = !error;
+ }
+ } else {
+ // We extract error from statusText
+ // then normalize statusText and status for non-aborts
+ error = statusText;
+ if ( status || !statusText ) {
+ statusText = "error";
+ if ( status < 0 ) {
+ status = 0;
+ }
+ }
+ }
+
+ // Set data for the fake xhr object
+ jqXHR.status = status;
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
+
+ // Success/Error
+ if ( isSuccess ) {
+ deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
+ } else {
+ deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
+ }
+
+ // Status-dependent callbacks
+ jqXHR.statusCode( statusCode );
+ statusCode = undefined;
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
+ [ jqXHR, s, isSuccess ? success : error ] );
+ }
+
+ // Complete
+ completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
+ // Handle the global AJAX counter
+ if ( !( --jQuery.active ) ) {
+ jQuery.event.trigger("ajaxStop");
+ }
+ }
+ }
+
+ return jqXHR;
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get( url, undefined, callback, "script" );
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get( url, data, callback, "json" );
+ }
+});
+
+/* Handles responses to an ajax request:
+ * - sets all responseXXX fields accordingly
+ * - finds the right dataType (mediates between content-type and expected dataType)
+ * - returns the corresponding response
+ */
+function ajaxHandleResponses( s, jqXHR, responses ) {
+ var firstDataType, ct, finalDataType, type,
+ contents = s.contents,
+ dataTypes = s.dataTypes,
+ responseFields = s.responseFields;
+
+ // Fill responseXXX fields
+ for ( type in responseFields ) {
+ if ( type in responses ) {
+ jqXHR[ responseFields[type] ] = responses[ type ];
+ }
+ }
+
+ // Remove auto dataType and get content-type in the process
+ while( dataTypes[ 0 ] === "*" ) {
+ dataTypes.shift();
+ if ( ct === undefined ) {
+ ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
+ }
+ }
+
+ // Check if we're dealing with a known content-type
+ if ( ct ) {
+ for ( type in contents ) {
+ if ( contents[ type ] && contents[ type ].test( ct ) ) {
+ dataTypes.unshift( type );
+ break;
+ }
+ }
+ }
+
+ // Check to see if we have a response for the expected dataType
+ if ( dataTypes[ 0 ] in responses ) {
+ finalDataType = dataTypes[ 0 ];
+ } else {
+ // Try convertible dataTypes
+ for ( type in responses ) {
+ if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
+ finalDataType = type;
+ break;
+ }
+ if ( !firstDataType ) {
+ firstDataType = type;
+ }
+ }
+ // Or just use first one
+ finalDataType = finalDataType || firstDataType;
+ }
+
+ // If we found a dataType
+ // We add the dataType to the list if needed
+ // and return the corresponding response
+ if ( finalDataType ) {
+ if ( finalDataType !== dataTypes[ 0 ] ) {
+ dataTypes.unshift( finalDataType );
+ }
+ return responses[ finalDataType ];
+ }
+}
+
+// Chain conversions given the request and the original response
+function ajaxConvert( s, response ) {
+ var conv2, current, conv, tmp,
+ converters = {},
+ i = 0,
+ // Work with a copy of dataTypes in case we need to modify it for conversion
+ dataTypes = s.dataTypes.slice(),
+ prev = dataTypes[ 0 ];
+
+ // Apply the dataFilter if provided
+ if ( s.dataFilter ) {
+ response = s.dataFilter( response, s.dataType );
+ }
+
+ // Create converters map with lowercased keys
+ if ( dataTypes[ 1 ] ) {
+ for ( conv in s.converters ) {
+ converters[ conv.toLowerCase() ] = s.converters[ conv ];
+ }
+ }
+
+ // Convert to each sequential dataType, tolerating list modification
+ for ( ; (current = dataTypes[++i]); ) {
+
+ // There's only work to do if current dataType is non-auto
+ if ( current !== "*" ) {
+
+ // Convert response if prev dataType is non-auto and differs from current
+ if ( prev !== "*" && prev !== current ) {
+
+ // Seek a direct converter
+ conv = converters[ prev + " " + current ] || converters[ "* " + current ];
+
+ // If none found, seek a pair
+ if ( !conv ) {
+ for ( conv2 in converters ) {
+
+ // If conv2 outputs current
+ tmp = conv2.split(" ");
+ if ( tmp[ 1 ] === current ) {
+
+ // If prev can be converted to accepted input
+ conv = converters[ prev + " " + tmp[ 0 ] ] ||
+ converters[ "* " + tmp[ 0 ] ];
+ if ( conv ) {
+ // Condense equivalence converters
+ if ( conv === true ) {
+ conv = converters[ conv2 ];
+
+ // Otherwise, insert the intermediate dataType
+ } else if ( converters[ conv2 ] !== true ) {
+ current = tmp[ 0 ];
+ dataTypes.splice( i--, 0, current );
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ // Apply converter (if not an equivalence)
+ if ( conv !== true ) {
+
+ // Unless errors are allowed to bubble, catch and return them
+ if ( conv && s["throws"] ) {
+ response = conv( response );
+ } else {
+ try {
+ response = conv( response );
+ } catch ( e ) {
+ return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
+ }
+ }
+ }
+ }
+
+ // Update prev for next iteration
+ prev = current;
+ }
+ }
+
+ return { state: "success", data: response };
+}
+// Install script dataType
+jQuery.ajaxSetup({
+ accepts: {
+ script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
+ },
+ contents: {
+ script: /(?:java|ecma)script/
+ },
+ converters: {
+ "text script": function( text ) {
+ jQuery.globalEval( text );
+ return text;
+ }
+ }
+});
+
+// Handle cache's special case and global
+jQuery.ajaxPrefilter( "script", function( s ) {
+ if ( s.cache === undefined ) {
+ s.cache = false;
+ }
+ if ( s.crossDomain ) {
+ s.type = "GET";
+ s.global = false;
+ }
+});
+
+// Bind script tag hack transport
+jQuery.ajaxTransport( "script", function(s) {
+
+ // This transport only deals with cross domain requests
+ if ( s.crossDomain ) {
+
+ var script,
+ head = document.head || jQuery("head")[0] || document.documentElement;
+
+ return {
+
+ send: function( _, callback ) {
+
+ script = document.createElement("script");
+
+ script.async = true;
+
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ script.src = s.url;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function( _, isAbort ) {
+
+ if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+
+ // Remove the script
+ if ( script.parentNode ) {
+ script.parentNode.removeChild( script );
+ }
+
+ // Dereference the script
+ script = null;
+
+ // Callback if not abort
+ if ( !isAbort ) {
+ callback( 200, "success" );
+ }
+ }
+ };
+
+ // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
+ // Use native DOM manipulation to avoid our domManip AJAX trickery
+ head.insertBefore( script, head.firstChild );
+ },
+
+ abort: function() {
+ if ( script ) {
+ script.onload( undefined, true );
+ }
+ }
+ };
+ }
+});
+var oldCallbacks = [],
+ rjsonp = /(=)\?(?=&|$)|\?\?/;
+
+// Default jsonp settings
+jQuery.ajaxSetup({
+ jsonp: "callback",
+ jsonpCallback: function() {
+ var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
+ this[ callback ] = true;
+ return callback;
+ }
+});
+
+// Detect, normalize options and install callbacks for jsonp requests
+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
+
+ var callbackName, overwritten, responseContainer,
+ jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
+ "url" :
+ typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
+ );
+
+ // Handle iff the expected data type is "jsonp" or we have a parameter to set
+ if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
+
+ // Get callback name, remembering preexisting value associated with it
+ callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
+ s.jsonpCallback() :
+ s.jsonpCallback;
+
+ // Insert callback into url or form data
+ if ( jsonProp ) {
+ s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
+ } else if ( s.jsonp !== false ) {
+ s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+ }
+
+ // Use data converter to retrieve json after script execution
+ s.converters["script json"] = function() {
+ if ( !responseContainer ) {
+ jQuery.error( callbackName + " was not called" );
+ }
+ return responseContainer[ 0 ];
+ };
+
+ // force json dataType
+ s.dataTypes[ 0 ] = "json";
+
+ // Install callback
+ overwritten = window[ callbackName ];
+ window[ callbackName ] = function() {
+ responseContainer = arguments;
+ };
+
+ // Clean-up function (fires after converters)
+ jqXHR.always(function() {
+ // Restore preexisting value
+ window[ callbackName ] = overwritten;
+
+ // Save back as free
+ if ( s[ callbackName ] ) {
+ // make sure that re-using the options doesn't screw things around
+ s.jsonpCallback = originalSettings.jsonpCallback;
+
+ // save the callback name for future use
+ oldCallbacks.push( callbackName );
+ }
+
+ // Call if it was a function and we have a response
+ if ( responseContainer && jQuery.isFunction( overwritten ) ) {
+ overwritten( responseContainer[ 0 ] );
+ }
+
+ responseContainer = overwritten = undefined;
+ });
+
+ // Delegate to script
+ return "script";
+ }
+});
+var xhrCallbacks, xhrSupported,
+ xhrId = 0,
+ // #5280: Internet Explorer will keep connections alive if we don't abort on unload
+ xhrOnUnloadAbort = window.ActiveXObject && function() {
+ // Abort all pending requests
+ var key;
+ for ( key in xhrCallbacks ) {
+ xhrCallbacks[ key ]( undefined, true );
+ }
+ };
+
+// Functions to create xhrs
+function createStandardXHR() {
+ try {
+ return new window.XMLHttpRequest();
+ } catch( e ) {}
+}
+
+function createActiveXHR() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch( e ) {}
+}
+
+// Create the request object
+// (This is still attached to ajaxSettings for backward compatibility)
+jQuery.ajaxSettings.xhr = window.ActiveXObject ?
+ /* Microsoft failed to properly
+ * implement the XMLHttpRequest in IE7 (can't request local files),
+ * so we use the ActiveXObject when it is available
+ * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
+ * we need a fallback.
+ */
+ function() {
+ return !this.isLocal && createStandardXHR() || createActiveXHR();
+ } :
+ // For all other browsers, use the standard XMLHttpRequest object
+ createStandardXHR;
+
+// Determine support properties
+xhrSupported = jQuery.ajaxSettings.xhr();
+jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
+xhrSupported = jQuery.support.ajax = !!xhrSupported;
+
+// Create transport if the browser can provide an xhr
+if ( xhrSupported ) {
+
+ jQuery.ajaxTransport(function( s ) {
+ // Cross domain only allowed if supported through XMLHttpRequest
+ if ( !s.crossDomain || jQuery.support.cors ) {
+
+ var callback;
+
+ return {
+ send: function( headers, complete ) {
+
+ // Get a new xhr
+ var handle, i,
+ xhr = s.xhr();
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open( s.type, s.url, s.async, s.username, s.password );
+ } else {
+ xhr.open( s.type, s.url, s.async );
+ }
+
+ // Apply custom fields if provided
+ if ( s.xhrFields ) {
+ for ( i in s.xhrFields ) {
+ xhr[ i ] = s.xhrFields[ i ];
+ }
+ }
+
+ // Override mime type if needed
+ if ( s.mimeType && xhr.overrideMimeType ) {
+ xhr.overrideMimeType( s.mimeType );
+ }
+
+ // X-Requested-With header
+ // For cross-domain requests, seeing as conditions for a preflight are
+ // akin to a jigsaw puzzle, we simply never set it to be sure.
+ // (it can always be set on a per-request basis or even using ajaxSetup)
+ // For same-domain requests, won't change header if already provided.
+ if ( !s.crossDomain && !headers["X-Requested-With"] ) {
+ headers["X-Requested-With"] = "XMLHttpRequest";
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ for ( i in headers ) {
+ xhr.setRequestHeader( i, headers[ i ] );
+ }
+ } catch( err ) {}
+
+ // Do send the request
+ // This may raise an exception which is actually
+ // handled in jQuery.ajax (so no try/catch here)
+ xhr.send( ( s.hasContent && s.data ) || null );
+
+ // Listener
+ callback = function( _, isAbort ) {
+ var status, responseHeaders, statusText, responses;
+
+ // Firefox throws exceptions when accessing properties
+ // of an xhr when a network error occurred
+ // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
+ try {
+
+ // Was never called and is aborted or complete
+ if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
+
+ // Only called once
+ callback = undefined;
+
+ // Do not keep as active anymore
+ if ( handle ) {
+ xhr.onreadystatechange = jQuery.noop;
+ if ( xhrOnUnloadAbort ) {
+ delete xhrCallbacks[ handle ];
+ }
+ }
+
+ // If it's an abort
+ if ( isAbort ) {
+ // Abort it manually if needed
+ if ( xhr.readyState !== 4 ) {
+ xhr.abort();
+ }
+ } else {
+ responses = {};
+ status = xhr.status;
+ responseHeaders = xhr.getAllResponseHeaders();
+
+ // When requesting binary data, IE6-9 will throw an exception
+ // on any attempt to access responseText (#11426)
+ if ( typeof xhr.responseText === "string" ) {
+ responses.text = xhr.responseText;
+ }
+
+ // Firefox throws an exception when accessing
+ // statusText for faulty cross-domain requests
+ try {
+ statusText = xhr.statusText;
+ } catch( e ) {
+ // We normalize with Webkit giving an empty statusText
+ statusText = "";
+ }
+
+ // Filter status for non standard behaviors
+
+ // If the request is local and we have data: assume a success
+ // (success with no data won't get notified, that's the best we
+ // can do given current implementations)
+ if ( !status && s.isLocal && !s.crossDomain ) {
+ status = responses.text ? 200 : 404;
+ // IE - #1450: sometimes returns 1223 when it should be 204
+ } else if ( status === 1223 ) {
+ status = 204;
+ }
+ }
+ }
+ } catch( firefoxAccessException ) {
+ if ( !isAbort ) {
+ complete( -1, firefoxAccessException );
+ }
+ }
+
+ // Call complete if needed
+ if ( responses ) {
+ complete( status, statusText, responses, responseHeaders );
+ }
+ };
+
+ if ( !s.async ) {
+ // if we're in sync mode we fire the callback
+ callback();
+ } else if ( xhr.readyState === 4 ) {
+ // (IE6 & IE7) if it's in cache and has been
+ // retrieved directly we need to fire the callback
+ setTimeout( callback );
+ } else {
+ handle = ++xhrId;
+ if ( xhrOnUnloadAbort ) {
+ // Create the active xhrs callbacks list if needed
+ // and attach the unload handler
+ if ( !xhrCallbacks ) {
+ xhrCallbacks = {};
+ jQuery( window ).unload( xhrOnUnloadAbort );
+ }
+ // Add to list of active xhrs callbacks
+ xhrCallbacks[ handle ] = callback;
+ }
+ xhr.onreadystatechange = callback;
+ }
+ },
+
+ abort: function() {
+ if ( callback ) {
+ callback( undefined, true );
+ }
+ }
+ };
+ }
+ });
+}
+var fxNow, timerId,
+ rfxtypes = /^(?:toggle|show|hide)$/,
+ rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
+ rrun = /queueHooks$/,
+ animationPrefilters = [ defaultPrefilter ],
+ tweeners = {
+ "*": [function( prop, value ) {
+ var end, unit,
+ tween = this.createTween( prop, value ),
+ parts = rfxnum.exec( value ),
+ target = tween.cur(),
+ start = +target || 0,
+ scale = 1,
+ maxIterations = 20;
+
+ if ( parts ) {
+ end = +parts[2];
+ unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+
+ // We need to compute starting value
+ if ( unit !== "px" && start ) {
+ // Iteratively approximate from a nonzero starting point
+ // Prefer the current property, because this process will be trivial if it uses the same units
+ // Fallback to end or a simple constant
+ start = jQuery.css( tween.elem, prop, true ) || end || 1;
+
+ do {
+ // If previous iteration zeroed out, double until we get *something*
+ // Use a string for doubling factor so we don't accidentally see scale as unchanged below
+ scale = scale || ".5";
+
+ // Adjust and apply
+ start = start / scale;
+ jQuery.style( tween.elem, prop, start + unit );
+
+ // Update scale, tolerating zero or NaN from tween.cur()
+ // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
+ } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
+ }
+
+ tween.unit = unit;
+ tween.start = start;
+ // If a +=/-= token was provided, we're doing a relative animation
+ tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
+ }
+ return tween;
+ }]
+ };
+
+// Animations created synchronously will run synchronously
+function createFxNow() {
+ setTimeout(function() {
+ fxNow = undefined;
+ });
+ return ( fxNow = jQuery.now() );
+}
+
+function createTweens( animation, props ) {
+ jQuery.each( props, function( prop, value ) {
+ var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
+ index = 0,
+ length = collection.length;
+ for ( ; index < length; index++ ) {
+ if ( collection[ index ].call( animation, prop, value ) ) {
+
+ // we're done with this property
+ return;
+ }
+ }
+ });
+}
+
+function Animation( elem, properties, options ) {
+ var result,
+ stopped,
+ index = 0,
+ length = animationPrefilters.length,
+ deferred = jQuery.Deferred().always( function() {
+ // don't match elem in the :animated selector
+ delete tick.elem;
+ }),
+ tick = function() {
+ if ( stopped ) {
+ return false;
+ }
+ var currentTime = fxNow || createFxNow(),
+ remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
+ // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
+ temp = remaining / animation.duration || 0,
+ percent = 1 - temp,
+ index = 0,
+ length = animation.tweens.length;
+
+ for ( ; index < length ; index++ ) {
+ animation.tweens[ index ].run( percent );
+ }
+
+ deferred.notifyWith( elem, [ animation, percent, remaining ]);
+
+ if ( percent < 1 && length ) {
+ return remaining;
+ } else {
+ deferred.resolveWith( elem, [ animation ] );
+ return false;
+ }
+ },
+ animation = deferred.promise({
+ elem: elem,
+ props: jQuery.extend( {}, properties ),
+ opts: jQuery.extend( true, { specialEasing: {} }, options ),
+ originalProperties: properties,
+ originalOptions: options,
+ startTime: fxNow || createFxNow(),
+ duration: options.duration,
+ tweens: [],
+ createTween: function( prop, end ) {
+ var tween = jQuery.Tween( elem, animation.opts, prop, end,
+ animation.opts.specialEasing[ prop ] || animation.opts.easing );
+ animation.tweens.push( tween );
+ return tween;
+ },
+ stop: function( gotoEnd ) {
+ var index = 0,
+ // if we are going to the end, we want to run all the tweens
+ // otherwise we skip this part
+ length = gotoEnd ? animation.tweens.length : 0;
+ if ( stopped ) {
+ return this;
+ }
+ stopped = true;
+ for ( ; index < length ; index++ ) {
+ animation.tweens[ index ].run( 1 );
+ }
+
+ // resolve when we played the last frame
+ // otherwise, reject
+ if ( gotoEnd ) {
+ deferred.resolveWith( elem, [ animation, gotoEnd ] );
+ } else {
+ deferred.rejectWith( elem, [ animation, gotoEnd ] );
+ }
+ return this;
+ }
+ }),
+ props = animation.props;
+
+ propFilter( props, animation.opts.specialEasing );
+
+ for ( ; index < length ; index++ ) {
+ result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
+ if ( result ) {
+ return result;
+ }
+ }
+
+ createTweens( animation, props );
+
+ if ( jQuery.isFunction( animation.opts.start ) ) {
+ animation.opts.start.call( elem, animation );
+ }
+
+ jQuery.fx.timer(
+ jQuery.extend( tick, {
+ elem: elem,
+ anim: animation,
+ queue: animation.opts.queue
+ })
+ );
+
+ // attach callbacks from options
+ return animation.progress( animation.opts.progress )
+ .done( animation.opts.done, animation.opts.complete )
+ .fail( animation.opts.fail )
+ .always( animation.opts.always );
+}
+
+function propFilter( props, specialEasing ) {
+ var value, name, index, easing, hooks;
+
+ // camelCase, specialEasing and expand cssHook pass
+ for ( index in props ) {
+ name = jQuery.camelCase( index );
+ easing = specialEasing[ name ];
+ value = props[ index ];
+ if ( jQuery.isArray( value ) ) {
+ easing = value[ 1 ];
+ value = props[ index ] = value[ 0 ];
+ }
+
+ if ( index !== name ) {
+ props[ name ] = value;
+ delete props[ index ];
+ }
+
+ hooks = jQuery.cssHooks[ name ];
+ if ( hooks && "expand" in hooks ) {
+ value = hooks.expand( value );
+ delete props[ name ];
+
+ // not quite $.extend, this wont overwrite keys already present.
+ // also - reusing 'index' from above because we have the correct "name"
+ for ( index in value ) {
+ if ( !( index in props ) ) {
+ props[ index ] = value[ index ];
+ specialEasing[ index ] = easing;
+ }
+ }
+ } else {
+ specialEasing[ name ] = easing;
+ }
+ }
+}
+
+jQuery.Animation = jQuery.extend( Animation, {
+
+ tweener: function( props, callback ) {
+ if ( jQuery.isFunction( props ) ) {
+ callback = props;
+ props = [ "*" ];
+ } else {
+ props = props.split(" ");
+ }
+
+ var prop,
+ index = 0,
+ length = props.length;
+
+ for ( ; index < length ; index++ ) {
+ prop = props[ index ];
+ tweeners[ prop ] = tweeners[ prop ] || [];
+ tweeners[ prop ].unshift( callback );
+ }
+ },
+
+ prefilter: function( callback, prepend ) {
+ if ( prepend ) {
+ animationPrefilters.unshift( callback );
+ } else {
+ animationPrefilters.push( callback );
+ }
+ }
+});
+
+function defaultPrefilter( elem, props, opts ) {
+ /*jshint validthis:true */
+ var prop, index, length,
+ value, dataShow, toggle,
+ tween, hooks, oldfire,
+ anim = this,
+ style = elem.style,
+ orig = {},
+ handled = [],
+ hidden = elem.nodeType && isHidden( elem );
+
+ // handle queue: false promises
+ if ( !opts.queue ) {
+ hooks = jQuery._queueHooks( elem, "fx" );
+ if ( hooks.unqueued == null ) {
+ hooks.unqueued = 0;
+ oldfire = hooks.empty.fire;
+ hooks.empty.fire = function() {
+ if ( !hooks.unqueued ) {
+ oldfire();
+ }
+ };
+ }
+ hooks.unqueued++;
+
+ anim.always(function() {
+ // doing this makes sure that the complete handler will be called
+ // before this completes
+ anim.always(function() {
+ hooks.unqueued--;
+ if ( !jQuery.queue( elem, "fx" ).length ) {
+ hooks.empty.fire();
+ }
+ });
+ });
+ }
+
+ // height/width overflow pass
+ if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
+ // Make sure that nothing sneaks out
+ // Record all 3 overflow attributes because IE does not
+ // change the overflow attribute when overflowX and
+ // overflowY are set to the same value
+ opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
+
+ // Set display property to inline-block for height/width
+ // animations on inline elements that are having width/height animated
+ if ( jQuery.css( elem, "display" ) === "inline" &&
+ jQuery.css( elem, "float" ) === "none" ) {
+
+ // inline-level elements accept inline-block;
+ // block-level elements need to be inline with layout
+ if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
+ style.display = "inline-block";
+
+ } else {
+ style.zoom = 1;
+ }
+ }
+ }
+
+ if ( opts.overflow ) {
+ style.overflow = "hidden";
+ if ( !jQuery.support.shrinkWrapBlocks ) {
+ anim.always(function() {
+ style.overflow = opts.overflow[ 0 ];
+ style.overflowX = opts.overflow[ 1 ];
+ style.overflowY = opts.overflow[ 2 ];
+ });
+ }
+ }
+
+
+ // show/hide pass
+ for ( index in props ) {
+ value = props[ index ];
+ if ( rfxtypes.exec( value ) ) {
+ delete props[ index ];
+ toggle = toggle || value === "toggle";
+ if ( value === ( hidden ? "hide" : "show" ) ) {
+ continue;
+ }
+ handled.push( index );
+ }
+ }
+
+ length = handled.length;
+ if ( length ) {
+ dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
+ if ( "hidden" in dataShow ) {
+ hidden = dataShow.hidden;
+ }
+
+ // store state if its toggle - enables .stop().toggle() to "reverse"
+ if ( toggle ) {
+ dataShow.hidden = !hidden;
+ }
+ if ( hidden ) {
+ jQuery( elem ).show();
+ } else {
+ anim.done(function() {
+ jQuery( elem ).hide();
+ });
+ }
+ anim.done(function() {
+ var prop;
+ jQuery._removeData( elem, "fxshow" );
+ for ( prop in orig ) {
+ jQuery.style( elem, prop, orig[ prop ] );
+ }
+ });
+ for ( index = 0 ; index < length ; index++ ) {
+ prop = handled[ index ];
+ tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
+ orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
+
+ if ( !( prop in dataShow ) ) {
+ dataShow[ prop ] = tween.start;
+ if ( hidden ) {
+ tween.end = tween.start;
+ tween.start = prop === "width" || prop === "height" ? 1 : 0;
+ }
+ }
+ }
+ }
+}
+
+function Tween( elem, options, prop, end, easing ) {
+ return new Tween.prototype.init( elem, options, prop, end, easing );
+}
+jQuery.Tween = Tween;
+
+Tween.prototype = {
+ constructor: Tween,
+ init: function( elem, options, prop, end, easing, unit ) {
+ this.elem = elem;
+ this.prop = prop;
+ this.easing = easing || "swing";
+ this.options = options;
+ this.start = this.now = this.cur();
+ this.end = end;
+ this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+ },
+ cur: function() {
+ var hooks = Tween.propHooks[ this.prop ];
+
+ return hooks && hooks.get ?
+ hooks.get( this ) :
+ Tween.propHooks._default.get( this );
+ },
+ run: function( percent ) {
+ var eased,
+ hooks = Tween.propHooks[ this.prop ];
+
+ if ( this.options.duration ) {
+ this.pos = eased = jQuery.easing[ this.easing ](
+ percent, this.options.duration * percent, 0, 1, this.options.duration
+ );
+ } else {
+ this.pos = eased = percent;
+ }
+ this.now = ( this.end - this.start ) * eased + this.start;
+
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ if ( hooks && hooks.set ) {
+ hooks.set( this );
+ } else {
+ Tween.propHooks._default.set( this );
+ }
+ return this;
+ }
+};
+
+Tween.prototype.init.prototype = Tween.prototype;
+
+Tween.propHooks = {
+ _default: {
+ get: function( tween ) {
+ var result;
+
+ if ( tween.elem[ tween.prop ] != null &&
+ (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
+ return tween.elem[ tween.prop ];
+ }
+
+ // passing an empty string as a 3rd parameter to .css will automatically
+ // attempt a parseFloat and fallback to a string if the parse fails
+ // so, simple values such as "10px" are parsed to Float.
+ // complex values such as "rotate(1rad)" are returned as is.
+ result = jQuery.css( tween.elem, tween.prop, "" );
+ // Empty strings, null, undefined and "auto" are converted to 0.
+ return !result || result === "auto" ? 0 : result;
+ },
+ set: function( tween ) {
+ // use step hook for back compat - use cssHook if its there - use .style if its
+ // available and use plain properties where available
+ if ( jQuery.fx.step[ tween.prop ] ) {
+ jQuery.fx.step[ tween.prop ]( tween );
+ } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
+ jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
+ } else {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+ }
+};
+
+// Remove in 2.0 - this supports IE8's panic based approach
+// to setting things on disconnected nodes
+
+Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
+ set: function( tween ) {
+ if ( tween.elem.nodeType && tween.elem.parentNode ) {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+};
+
+jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
+ var cssFn = jQuery.fn[ name ];
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return speed == null || typeof speed === "boolean" ?
+ cssFn.apply( this, arguments ) :
+ this.animate( genFx( name, true ), speed, easing, callback );
+ };
+});
+
+jQuery.fn.extend({
+ fadeTo: function( speed, to, easing, callback ) {
+
+ // show any hidden elements after setting opacity to 0
+ return this.filter( isHidden ).css( "opacity", 0 ).show()
+
+ // animate to the value specified
+ .end().animate({ opacity: to }, speed, easing, callback );
+ },
+ animate: function( prop, speed, easing, callback ) {
+ var empty = jQuery.isEmptyObject( prop ),
+ optall = jQuery.speed( speed, easing, callback ),
+ doAnimation = function() {
+ // Operate on a copy of prop so per-property easing won't be lost
+ var anim = Animation( this, jQuery.extend( {}, prop ), optall );
+ doAnimation.finish = function() {
+ anim.stop( true );
+ };
+ // Empty animations, or finishing resolves immediately
+ if ( empty || jQuery._data( this, "finish" ) ) {
+ anim.stop( true );
+ }
+ };
+ doAnimation.finish = doAnimation;
+
+ return empty || optall.queue === false ?
+ this.each( doAnimation ) :
+ this.queue( optall.queue, doAnimation );
+ },
+ stop: function( type, clearQueue, gotoEnd ) {
+ var stopQueue = function( hooks ) {
+ var stop = hooks.stop;
+ delete hooks.stop;
+ stop( gotoEnd );
+ };
+
+ if ( typeof type !== "string" ) {
+ gotoEnd = clearQueue;
+ clearQueue = type;
+ type = undefined;
+ }
+ if ( clearQueue && type !== false ) {
+ this.queue( type || "fx", [] );
+ }
+
+ return this.each(function() {
+ var dequeue = true,
+ index = type != null && type + "queueHooks",
+ timers = jQuery.timers,
+ data = jQuery._data( this );
+
+ if ( index ) {
+ if ( data[ index ] && data[ index ].stop ) {
+ stopQueue( data[ index ] );
+ }
+ } else {
+ for ( index in data ) {
+ if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
+ stopQueue( data[ index ] );
+ }
+ }
+ }
+
+ for ( index = timers.length; index--; ) {
+ if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
+ timers[ index ].anim.stop( gotoEnd );
+ dequeue = false;
+ timers.splice( index, 1 );
+ }
+ }
+
+ // start the next in the queue if the last step wasn't forced
+ // timers currently will call their complete callbacks, which will dequeue
+ // but only if they were gotoEnd
+ if ( dequeue || !gotoEnd ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ finish: function( type ) {
+ if ( type !== false ) {
+ type = type || "fx";
+ }
+ return this.each(function() {
+ var index,
+ data = jQuery._data( this ),
+ queue = data[ type + "queue" ],
+ hooks = data[ type + "queueHooks" ],
+ timers = jQuery.timers,
+ length = queue ? queue.length : 0;
+
+ // enable finishing flag on private data
+ data.finish = true;
+
+ // empty the queue first
+ jQuery.queue( this, type, [] );
+
+ if ( hooks && hooks.cur && hooks.cur.finish ) {
+ hooks.cur.finish.call( this );
+ }
+
+ // look for any active animations, and finish them
+ for ( index = timers.length; index--; ) {
+ if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
+ timers[ index ].anim.stop( true );
+ timers.splice( index, 1 );
+ }
+ }
+
+ // look for any animations in the old queue and finish them
+ for ( index = 0; index < length; index++ ) {
+ if ( queue[ index ] && queue[ index ].finish ) {
+ queue[ index ].finish.call( this );
+ }
+ }
+
+ // turn off finishing flag
+ delete data.finish;
+ });
+ }
+});
+
+// Generate parameters to create a standard animation
+function genFx( type, includeWidth ) {
+ var which,
+ attrs = { height: type },
+ i = 0;
+
+ // if we include width, step value is 1 to do all cssExpand values,
+ // if we don't include width, step value is 2 to skip over Left and Right
+ includeWidth = includeWidth? 1 : 0;
+ for( ; i < 4 ; i += 2 - includeWidth ) {
+ which = cssExpand[ i ];
+ attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
+ }
+
+ if ( includeWidth ) {
+ attrs.opacity = attrs.width = type;
+ }
+
+ return attrs;
+}
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show"),
+ slideUp: genFx("hide"),
+ slideToggle: genFx("toggle"),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" },
+ fadeToggle: { opacity: "toggle" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return this.animate( props, speed, easing, callback );
+ };
+});
+
+jQuery.speed = function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
+
+ // normalize opt.queue - true/undefined/null -> "fx"
+ if ( opt.queue == null || opt.queue === true ) {
+ opt.queue = "fx";
+ }
+
+ // Queueing
+ opt.old = opt.complete;
+
+ opt.complete = function() {
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+
+ if ( opt.queue ) {
+ jQuery.dequeue( this, opt.queue );
+ }
+ };
+
+ return opt;
+};
+
+jQuery.easing = {
+ linear: function( p ) {
+ return p;
+ },
+ swing: function( p ) {
+ return 0.5 - Math.cos( p*Math.PI ) / 2;
+ }
+};
+
+jQuery.timers = [];
+jQuery.fx = Tween.prototype.init;
+jQuery.fx.tick = function() {
+ var timer,
+ timers = jQuery.timers,
+ i = 0;
+
+ fxNow = jQuery.now();
+
+ for ( ; i < timers.length; i++ ) {
+ timer = timers[ i ];
+ // Checks the timer has not already been removed
+ if ( !timer() && timers[ i ] === timer ) {
+ timers.splice( i--, 1 );
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ fxNow = undefined;
+};
+
+jQuery.fx.timer = function( timer ) {
+ if ( timer() && jQuery.timers.push( timer ) ) {
+ jQuery.fx.start();
+ }
+};
+
+jQuery.fx.interval = 13;
+
+jQuery.fx.start = function() {
+ if ( !timerId ) {
+ timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
+ }
+};
+
+jQuery.fx.stop = function() {
+ clearInterval( timerId );
+ timerId = null;
+};
+
+jQuery.fx.speeds = {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+};
+
+// Back Compat <1.8 extension point
+jQuery.fx.step = {};
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+jQuery.fn.offset = function( options ) {
+ if ( arguments.length ) {
+ return options === undefined ?
+ this :
+ this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ var docElem, win,
+ box = { top: 0, left: 0 },
+ elem = this[ 0 ],
+ doc = elem && elem.ownerDocument;
+
+ if ( !doc ) {
+ return;
+ }
+
+ docElem = doc.documentElement;
+
+ // Make sure it's not a disconnected DOM node
+ if ( !jQuery.contains( docElem, elem ) ) {
+ return box;
+ }
+
+ // If we don't have gBCR, just use 0,0 rather than error
+ // BlackBerry 5, iOS 3 (original iPhone)
+ if ( typeof elem.getBoundingClientRect !== core_strundefined ) {
+ box = elem.getBoundingClientRect();
+ }
+ win = getWindow( doc );
+ return {
+ top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
+ left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
+ };
+};
+
+jQuery.offset = {
+
+ setOffset: function( elem, options, i ) {
+ var position = jQuery.css( elem, "position" );
+
+ // set position first, in-case top/left are set even on static elem
+ if ( position === "static" ) {
+ elem.style.position = "relative";
+ }
+
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curCSSTop = jQuery.css( elem, "top" ),
+ curCSSLeft = jQuery.css( elem, "left" ),
+ calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
+ props = {}, curPosition = {}, curTop, curLeft;
+
+ // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
+ if ( calculatePosition ) {
+ curPosition = curElem.position();
+ curTop = curPosition.top;
+ curLeft = curPosition.left;
+ } else {
+ curTop = parseFloat( curCSSTop ) || 0;
+ curLeft = parseFloat( curCSSLeft ) || 0;
+ }
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ if ( options.top != null ) {
+ props.top = ( options.top - curOffset.top ) + curTop;
+ }
+ if ( options.left != null ) {
+ props.left = ( options.left - curOffset.left ) + curLeft;
+ }
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+
+ position: function() {
+ if ( !this[ 0 ] ) {
+ return;
+ }
+
+ var offsetParent, offset,
+ parentOffset = { top: 0, left: 0 },
+ elem = this[ 0 ];
+
+ // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is it's only offset parent
+ if ( jQuery.css( elem, "position" ) === "fixed" ) {
+ // we assume that getBoundingClientRect is available when computed position is fixed
+ offset = elem.getBoundingClientRect();
+ } else {
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent();
+
+ // Get correct offsets
+ offset = this.offset();
+ if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
+ parentOffset = offsetParent.offset();
+ }
+
+ // Add offsetParent borders
+ parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
+ parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
+ }
+
+ // Subtract parent offsets and element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ return {
+ top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
+ left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.documentElement;
+ while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position") === "static" ) ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent || document.documentElement;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
+ var top = /Y/.test( prop );
+
+ jQuery.fn[ method ] = function( val ) {
+ return jQuery.access( this, function( elem, method, val ) {
+ var win = getWindow( elem );
+
+ if ( val === undefined ) {
+ return win ? (prop in win) ? win[ prop ] :
+ win.document.documentElement[ method ] :
+ elem[ method ];
+ }
+
+ if ( win ) {
+ win.scrollTo(
+ !top ? val : jQuery( win ).scrollLeft(),
+ top ? val : jQuery( win ).scrollTop()
+ );
+
+ } else {
+ elem[ method ] = val;
+ }
+ }, method, val, arguments.length, null );
+ };
+});
+
+function getWindow( elem ) {
+ return jQuery.isWindow( elem ) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
+jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
+ jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
+ // margin is only for outerHeight, outerWidth
+ jQuery.fn[ funcName ] = function( margin, value ) {
+ var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
+ extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
+
+ return jQuery.access( this, function( elem, type, value ) {
+ var doc;
+
+ if ( jQuery.isWindow( elem ) ) {
+ // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
+ // isn't a whole lot we can do. See pull request at this URL for discussion:
+ // https://github.com/jquery/jquery/pull/764
+ return elem.document.documentElement[ "client" + name ];
+ }
+
+ // Get document width or height
+ if ( elem.nodeType === 9 ) {
+ doc = elem.documentElement;
+
+ // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
+ // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
+ return Math.max(
+ elem.body[ "scroll" + name ], doc[ "scroll" + name ],
+ elem.body[ "offset" + name ], doc[ "offset" + name ],
+ doc[ "client" + name ]
+ );
+ }
+
+ return value === undefined ?
+ // Get width or height on the element, requesting but not forcing parseFloat
+ jQuery.css( elem, type, extra ) :
+
+ // Set width or height on the element
+ jQuery.style( elem, type, value, extra );
+ }, type, chainable ? margin : undefined, chainable, null );
+ };
+ });
+});
+// Limit scope pollution from any deprecated API
+// (function() {
+
+// })();
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+// Expose jQuery as an AMD module, but only for AMD loaders that
+// understand the issues with loading multiple versions of jQuery
+// in a page that all might call define(). The loader will indicate
+// they have special allowances for multiple jQuery versions by
+// specifying define.amd.jQuery = true. Register as a named module,
+// since jQuery can be concatenated with other files that may use define,
+// but not use a proper concatenation script that understands anonymous
+// AMD modules. A named AMD is safest and most robust way to register.
+// Lowercase jquery is used because AMD module names are derived from
+// file names, and jQuery is normally delivered in a lowercase file name.
+// Do this after creating the global so that if an AMD module wants to call
+// noConflict to hide this version of jQuery, it will work.
+if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
+ define( "jquery", [], function () { return jQuery; } );
+}
+
+})( window );// Underscore.js 1.8.2
+// http://underscorejs.org
+// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+// Underscore may be freely distributed under the MIT license.
+
+(function() {
+
+ // Baseline setup
+ // --------------
+
+ // Establish the root object, `window` in the browser, or `exports` on the server.
+ var root = this;
+
+ // Save the previous value of the `_` variable.
+ var previousUnderscore = root._;
+
+ // Save bytes in the minified (but not gzipped) version:
+ var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
+
+ // Create quick reference variables for speed access to core prototypes.
+ var
+ push = ArrayProto.push,
+ slice = ArrayProto.slice,
+ toString = ObjProto.toString,
+ hasOwnProperty = ObjProto.hasOwnProperty;
+
+ // All **ECMAScript 5** native function implementations that we hope to use
+ // are declared here.
+ var
+ nativeIsArray = Array.isArray,
+ nativeKeys = Object.keys,
+ nativeBind = FuncProto.bind,
+ nativeCreate = Object.create;
+
+ // Naked function reference for surrogate-prototype-swapping.
+ var Ctor = function(){};
+
+ // Create a safe reference to the Underscore object for use below.
+ var _ = function(obj) {
+ if (obj instanceof _) return obj;
+ if (!(this instanceof _)) return new _(obj);
+ this._wrapped = obj;
+ };
+
+ // Export the Underscore object for **Node.js**, with
+ // backwards-compatibility for the old `require()` API. If we're in
+ // the browser, add `_` as a global object.
+ if (typeof exports !== 'undefined') {
+ if (typeof module !== 'undefined' && module.exports) {
+ exports = module.exports = _;
+ }
+ exports._ = _;
+ } else {
+ root._ = _;
+ }
+
+ // Current version.
+ _.VERSION = '1.8.2';
+
+ // Internal function that returns an efficient (for current engines) version
+ // of the passed-in callback, to be repeatedly applied in other Underscore
+ // functions.
+ var optimizeCb = function(func, context, argCount) {
+ if (context === void 0) return func;
+ switch (argCount == null ? 3 : argCount) {
+ case 1: return function(value) {
+ return func.call(context, value);
+ };
+ case 2: return function(value, other) {
+ return func.call(context, value, other);
+ };
+ case 3: return function(value, index, collection) {
+ return func.call(context, value, index, collection);
+ };
+ case 4: return function(accumulator, value, index, collection) {
+ return func.call(context, accumulator, value, index, collection);
+ };
+ }
+ return function() {
+ return func.apply(context, arguments);
+ };
+ };
+
+ // A mostly-internal function to generate callbacks that can be applied
+ // to each element in a collection, returning the desired result 鈥? either
+ // identity, an arbitrary callback, a property matcher, or a property accessor.
+ var cb = function(value, context, argCount) {
+ if (value == null) return _.identity;
+ if (_.isFunction(value)) return optimizeCb(value, context, argCount);
+ if (_.isObject(value)) return _.matcher(value);
+ return _.property(value);
+ };
+ _.iteratee = function(value, context) {
+ return cb(value, context, Infinity);
+ };
+
+ // An internal function for creating assigner functions.
+ var createAssigner = function(keysFunc, undefinedOnly) {
+ return function(obj) {
+ var length = arguments.length;
+ if (length < 2 || obj == null) return obj;
+ for (var index = 1; index < length; index++) {
+ var source = arguments[index],
+ keys = keysFunc(source),
+ l = keys.length;
+ for (var i = 0; i < l; i++) {
+ var key = keys[i];
+ if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key];
+ }
+ }
+ return obj;
+ };
+ };
+
+ // An internal function for creating a new object that inherits from another.
+ var baseCreate = function(prototype) {
+ if (!_.isObject(prototype)) return {};
+ if (nativeCreate) return nativeCreate(prototype);
+ Ctor.prototype = prototype;
+ var result = new Ctor;
+ Ctor.prototype = null;
+ return result;
+ };
+
+ // Helper for collection methods to determine whether a collection
+ // should be iterated as an array or as an object
+ // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
+ var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
+ var isArrayLike = function(collection) {
+ var length = collection != null && collection.length;
+ return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
+ };
+
+ // Collection Functions
+ // --------------------
+
+ // The cornerstone, an `each` implementation, aka `forEach`.
+ // Handles raw objects in addition to array-likes. Treats all
+ // sparse array-likes as if they were dense.
+ _.each = _.forEach = function(obj, iteratee, context) {
+ iteratee = optimizeCb(iteratee, context);
+ var i, length;
+ if (isArrayLike(obj)) {
+ for (i = 0, length = obj.length; i < length; i++) {
+ iteratee(obj[i], i, obj);
+ }
+ } else {
+ var keys = _.keys(obj);
+ for (i = 0, length = keys.length; i < length; i++) {
+ iteratee(obj[keys[i]], keys[i], obj);
+ }
+ }
+ return obj;
+ };
+
+ // Return the results of applying the iteratee to each element.
+ _.map = _.collect = function(obj, iteratee, context) {
+ iteratee = cb(iteratee, context);
+ var keys = !isArrayLike(obj) && _.keys(obj),
+ length = (keys || obj).length,
+ results = Array(length);
+ for (var index = 0; index < length; index++) {
+ var currentKey = keys ? keys[index] : index;
+ results[index] = iteratee(obj[currentKey], currentKey, obj);
+ }
+ return results;
+ };
+
+ // Create a reducing function iterating left or right.
+ function createReduce(dir) {
+ // Optimized iterator function as using arguments.length
+ // in the main function will deoptimize the, see #1991.
+ function iterator(obj, iteratee, memo, keys, index, length) {
+ for (; index >= 0 && index < length; index += dir) {
+ var currentKey = keys ? keys[index] : index;
+ memo = iteratee(memo, obj[currentKey], currentKey, obj);
+ }
+ return memo;
+ }
+
+ return function(obj, iteratee, memo, context) {
+ iteratee = optimizeCb(iteratee, context, 4);
+ var keys = !isArrayLike(obj) && _.keys(obj),
+ length = (keys || obj).length,
+ index = dir > 0 ? 0 : length - 1;
+ // Determine the initial value if none is provided.
+ if (arguments.length < 3) {
+ memo = obj[keys ? keys[index] : index];
+ index += dir;
+ }
+ return iterator(obj, iteratee, memo, keys, index, length);
+ };
+ }
+
+ // **Reduce** builds up a single result from a list of values, aka `inject`,
+ // or `foldl`.
+ _.reduce = _.foldl = _.inject = createReduce(1);
+
+ // The right-associative version of reduce, also known as `foldr`.
+ _.reduceRight = _.foldr = createReduce(-1);
+
+ // Return the first value which passes a truth test. Aliased as `detect`.
+ _.find = _.detect = function(obj, predicate, context) {
+ var key;
+ if (isArrayLike(obj)) {
+ key = _.findIndex(obj, predicate, context);
+ } else {
+ key = _.findKey(obj, predicate, context);
+ }
+ if (key !== void 0 && key !== -1) return obj[key];
+ };
+
+ // Return all the elements that pass a truth test.
+ // Aliased as `select`.
+ _.filter = _.select = function(obj, predicate, context) {
+ var results = [];
+ predicate = cb(predicate, context);
+ _.each(obj, function(value, index, list) {
+ if (predicate(value, index, list)) results.push(value);
+ });
+ return results;
+ };
+
+ // Return all the elements for which a truth test fails.
+ _.reject = function(obj, predicate, context) {
+ return _.filter(obj, _.negate(cb(predicate)), context);
+ };
+
+ // Determine whether all of the elements match a truth test.
+ // Aliased as `all`.
+ _.every = _.all = function(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var keys = !isArrayLike(obj) && _.keys(obj),
+ length = (keys || obj).length;
+ for (var index = 0; index < length; index++) {
+ var currentKey = keys ? keys[index] : index;
+ if (!predicate(obj[currentKey], currentKey, obj)) return false;
+ }
+ return true;
+ };
+
+ // Determine if at least one element in the object matches a truth test.
+ // Aliased as `any`.
+ _.some = _.any = function(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var keys = !isArrayLike(obj) && _.keys(obj),
+ length = (keys || obj).length;
+ for (var index = 0; index < length; index++) {
+ var currentKey = keys ? keys[index] : index;
+ if (predicate(obj[currentKey], currentKey, obj)) return true;
+ }
+ return false;
+ };
+
+ // Determine if the array or object contains a given value (using `===`).
+ // Aliased as `includes` and `include`.
+ _.contains = _.includes = _.include = function(obj, target, fromIndex) {
+ if (!isArrayLike(obj)) obj = _.values(obj);
+ return _.indexOf(obj, target, typeof fromIndex == 'number' && fromIndex) >= 0;
+ };
+
+ // Invoke a method (with arguments) on every item in a collection.
+ _.invoke = function(obj, method) {
+ var args = slice.call(arguments, 2);
+ var isFunc = _.isFunction(method);
+ return _.map(obj, function(value) {
+ var func = isFunc ? method : value[method];
+ return func == null ? func : func.apply(value, args);
+ });
+ };
+
+ // Convenience version of a common use case of `map`: fetching a property.
+ _.pluck = function(obj, key) {
+ return _.map(obj, _.property(key));
+ };
+
+ // Convenience version of a common use case of `filter`: selecting only objects
+ // containing specific `key:value` pairs.
+ _.where = function(obj, attrs) {
+ return _.filter(obj, _.matcher(attrs));
+ };
+
+ // Convenience version of a common use case of `find`: getting the first object
+ // containing specific `key:value` pairs.
+ _.findWhere = function(obj, attrs) {
+ return _.find(obj, _.matcher(attrs));
+ };
+
+ // Return the maximum element (or element-based computation).
+ _.max = function(obj, iteratee, context) {
+ var result = -Infinity, lastComputed = -Infinity,
+ value, computed;
+ if (iteratee == null && obj != null) {
+ obj = isArrayLike(obj) ? obj : _.values(obj);
+ for (var i = 0, length = obj.length; i < length; i++) {
+ value = obj[i];
+ if (value > result) {
+ result = value;
+ }
+ }
+ } else {
+ iteratee = cb(iteratee, context);
+ _.each(obj, function(value, index, list) {
+ computed = iteratee(value, index, list);
+ if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
+ result = value;
+ lastComputed = computed;
+ }
+ });
+ }
+ return result;
+ };
+
+ // Return the minimum element (or element-based computation).
+ _.min = function(obj, iteratee, context) {
+ var result = Infinity, lastComputed = Infinity,
+ value, computed;
+ if (iteratee == null && obj != null) {
+ obj = isArrayLike(obj) ? obj : _.values(obj);
+ for (var i = 0, length = obj.length; i < length; i++) {
+ value = obj[i];
+ if (value < result) {
+ result = value;
+ }
+ }
+ } else {
+ iteratee = cb(iteratee, context);
+ _.each(obj, function(value, index, list) {
+ computed = iteratee(value, index, list);
+ if (computed < lastComputed || computed === Infinity && result === Infinity) {
+ result = value;
+ lastComputed = computed;
+ }
+ });
+ }
+ return result;
+ };
+
+ // Shuffle a collection, using the modern version of the
+ // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher鈥揧ates_shuffle).
+ _.shuffle = function(obj) {
+ var set = isArrayLike(obj) ? obj : _.values(obj);
+ var length = set.length;
+ var shuffled = Array(length);
+ for (var index = 0, rand; index < length; index++) {
+ rand = _.random(0, index);
+ if (rand !== index) shuffled[index] = shuffled[rand];
+ shuffled[rand] = set[index];
+ }
+ return shuffled;
+ };
+
+ // Sample **n** random values from a collection.
+ // If **n** is not specified, returns a single random element.
+ // The internal `guard` argument allows it to work with `map`.
+ _.sample = function(obj, n, guard) {
+ if (n == null || guard) {
+ if (!isArrayLike(obj)) obj = _.values(obj);
+ return obj[_.random(obj.length - 1)];
+ }
+ return _.shuffle(obj).slice(0, Math.max(0, n));
+ };
+
+ // Sort the object's values by a criterion produced by an iteratee.
+ _.sortBy = function(obj, iteratee, context) {
+ iteratee = cb(iteratee, context);
+ return _.pluck(_.map(obj, function(value, index, list) {
+ return {
+ value: value,
+ index: index,
+ criteria: iteratee(value, index, list)
+ };
+ }).sort(function(left, right) {
+ var a = left.criteria;
+ var b = right.criteria;
+ if (a !== b) {
+ if (a > b || a === void 0) return 1;
+ if (a < b || b === void 0) return -1;
+ }
+ return left.index - right.index;
+ }), 'value');
+ };
+
+ // An internal function used for aggregate "group by" operations.
+ var group = function(behavior) {
+ return function(obj, iteratee, context) {
+ var result = {};
+ iteratee = cb(iteratee, context);
+ _.each(obj, function(value, index) {
+ var key = iteratee(value, index, obj);
+ behavior(result, value, key);
+ });
+ return result;
+ };
+ };
+
+ // Groups the object's values by a criterion. Pass either a string attribute
+ // to group by, or a function that returns the criterion.
+ _.groupBy = group(function(result, value, key) {
+ if (_.has(result, key)) result[key].push(value); else result[key] = [value];
+ });
+
+ // Indexes the object's values by a criterion, similar to `groupBy`, but for
+ // when you know that your index values will be unique.
+ _.indexBy = group(function(result, value, key) {
+ result[key] = value;
+ });
+
+ // Counts instances of an object that group by a certain criterion. Pass
+ // either a string attribute to count by, or a function that returns the
+ // criterion.
+ _.countBy = group(function(result, value, key) {
+ if (_.has(result, key)) result[key]++; else result[key] = 1;
+ });
+
+ // Safely create a real, live array from anything iterable.
+ _.toArray = function(obj) {
+ if (!obj) return [];
+ if (_.isArray(obj)) return slice.call(obj);
+ if (isArrayLike(obj)) return _.map(obj, _.identity);
+ return _.values(obj);
+ };
+
+ // Return the number of elements in an object.
+ _.size = function(obj) {
+ if (obj == null) return 0;
+ return isArrayLike(obj) ? obj.length : _.keys(obj).length;
+ };
+
+ // Split a collection into two arrays: one whose elements all satisfy the given
+ // predicate, and one whose elements all do not satisfy the predicate.
+ _.partition = function(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var pass = [], fail = [];
+ _.each(obj, function(value, key, obj) {
+ (predicate(value, key, obj) ? pass : fail).push(value);
+ });
+ return [pass, fail];
+ };
+
+ // Array Functions
+ // ---------------
+
+ // Get the first element of an array. Passing **n** will return the first N
+ // values in the array. Aliased as `head` and `take`. The **guard** check
+ // allows it to work with `_.map`.
+ _.first = _.head = _.take = function(array, n, guard) {
+ if (array == null) return void 0;
+ if (n == null || guard) return array[0];
+ return _.initial(array, array.length - n);
+ };
+
+ // Returns everything but the last entry of the array. Especially useful on
+ // the arguments object. Passing **n** will return all the values in
+ // the array, excluding the last N.
+ _.initial = function(array, n, guard) {
+ return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
+ };
+
+ // Get the last element of an array. Passing **n** will return the last N
+ // values in the array.
+ _.last = function(array, n, guard) {
+ if (array == null) return void 0;
+ if (n == null || guard) return array[array.length - 1];
+ return _.rest(array, Math.max(0, array.length - n));
+ };
+
+ // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
+ // Especially useful on the arguments object. Passing an **n** will return
+ // the rest N values in the array.
+ _.rest = _.tail = _.drop = function(array, n, guard) {
+ return slice.call(array, n == null || guard ? 1 : n);
+ };
+
+ // Trim out all falsy values from an array.
+ _.compact = function(array) {
+ return _.filter(array, _.identity);
+ };
+
+ // Internal implementation of a recursive `flatten` function.
+ var flatten = function(input, shallow, strict, startIndex) {
+ var output = [], idx = 0;
+ for (var i = startIndex || 0, length = input && input.length; i < length; i++) {
+ var value = input[i];
+ if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
+ //flatten current level of array or arguments object
+ if (!shallow) value = flatten(value, shallow, strict);
+ var j = 0, len = value.length;
+ output.length += len;
+ while (j < len) {
+ output[idx++] = value[j++];
+ }
+ } else if (!strict) {
+ output[idx++] = value;
+ }
+ }
+ return output;
+ };
+
+ // Flatten out an array, either recursively (by default), or just one level.
+ _.flatten = function(array, shallow) {
+ return flatten(array, shallow, false);
+ };
+
+ // Return a version of the array that does not contain the specified value(s).
+ _.without = function(array) {
+ return _.difference(array, slice.call(arguments, 1));
+ };
+
+ // Produce a duplicate-free version of the array. If the array has already
+ // been sorted, you have the option of using a faster algorithm.
+ // Aliased as `unique`.
+ _.uniq = _.unique = function(array, isSorted, iteratee, context) {
+ if (array == null) return [];
+ if (!_.isBoolean(isSorted)) {
+ context = iteratee;
+ iteratee = isSorted;
+ isSorted = false;
+ }
+ if (iteratee != null) iteratee = cb(iteratee, context);
+ var result = [];
+ var seen = [];
+ for (var i = 0, length = array.length; i < length; i++) {
+ var value = array[i],
+ computed = iteratee ? iteratee(value, i, array) : value;
+ if (isSorted) {
+ if (!i || seen !== computed) result.push(value);
+ seen = computed;
+ } else if (iteratee) {
+ if (!_.contains(seen, computed)) {
+ seen.push(computed);
+ result.push(value);
+ }
+ } else if (!_.contains(result, value)) {
+ result.push(value);
+ }
+ }
+ return result;
+ };
+
+ // Produce an array that contains the union: each distinct element from all of
+ // the passed-in arrays.
+ _.union = function() {
+ return _.uniq(flatten(arguments, true, true));
+ };
+
+ // Produce an array that contains every item shared between all the
+ // passed-in arrays.
+ _.intersection = function(array) {
+ if (array == null) return [];
+ var result = [];
+ var argsLength = arguments.length;
+ for (var i = 0, length = array.length; i < length; i++) {
+ var item = array[i];
+ if (_.contains(result, item)) continue;
+ for (var j = 1; j < argsLength; j++) {
+ if (!_.contains(arguments[j], item)) break;
+ }
+ if (j === argsLength) result.push(item);
+ }
+ return result;
+ };
+
+ // Take the difference between one array and a number of other arrays.
+ // Only the elements present in just the first array will remain.
+ _.difference = function(array) {
+ var rest = flatten(arguments, true, true, 1);
+ return _.filter(array, function(value){
+ return !_.contains(rest, value);
+ });
+ };
+
+ // Zip together multiple lists into a single array -- elements that share
+ // an index go together.
+ _.zip = function() {
+ return _.unzip(arguments);
+ };
+
+ // Complement of _.zip. Unzip accepts an array of arrays and groups
+ // each array's elements on shared indices
+ _.unzip = function(array) {
+ var length = array && _.max(array, 'length').length || 0;
+ var result = Array(length);
+
+ for (var index = 0; index < length; index++) {
+ result[index] = _.pluck(array, index);
+ }
+ return result;
+ };
+
+ // Converts lists into objects. Pass either a single array of `[key, value]`
+ // pairs, or two parallel arrays of the same length -- one of keys, and one of
+ // the corresponding values.
+ _.object = function(list, values) {
+ var result = {};
+ for (var i = 0, length = list && list.length; i < length; i++) {
+ if (values) {
+ result[list[i]] = values[i];
+ } else {
+ result[list[i][0]] = list[i][1];
+ }
+ }
+ return result;
+ };
+
+ // Return the position of the first occurrence of an item in an array,
+ // or -1 if the item is not included in the array.
+ // If the array is large and already in sort order, pass `true`
+ // for **isSorted** to use binary search.
+ _.indexOf = function(array, item, isSorted) {
+ var i = 0, length = array && array.length;
+ if (typeof isSorted == 'number') {
+ i = isSorted < 0 ? Math.max(0, length + isSorted) : isSorted;
+ } else if (isSorted && length) {
+ i = _.sortedIndex(array, item);
+ return array[i] === item ? i : -1;
+ }
+ if (item !== item) {
+ return _.findIndex(slice.call(array, i), _.isNaN);
+ }
+ for (; i < length; i++) if (array[i] === item) return i;
+ return -1;
+ };
+
+ _.lastIndexOf = function(array, item, from) {
+ var idx = array ? array.length : 0;
+ if (typeof from == 'number') {
+ idx = from < 0 ? idx + from + 1 : Math.min(idx, from + 1);
+ }
+ if (item !== item) {
+ return _.findLastIndex(slice.call(array, 0, idx), _.isNaN);
+ }
+ while (--idx >= 0) if (array[idx] === item) return idx;
+ return -1;
+ };
+
+ // Generator function to create the findIndex and findLastIndex functions
+ function createIndexFinder(dir) {
+ return function(array, predicate, context) {
+ predicate = cb(predicate, context);
+ var length = array != null && array.length;
+ var index = dir > 0 ? 0 : length - 1;
+ for (; index >= 0 && index < length; index += dir) {
+ if (predicate(array[index], index, array)) return index;
+ }
+ return -1;
+ };
+ }
+
+ // Returns the first index on an array-like that passes a predicate test
+ _.findIndex = createIndexFinder(1);
+
+ _.findLastIndex = createIndexFinder(-1);
+
+ // Use a comparator function to figure out the smallest index at which
+ // an object should be inserted so as to maintain order. Uses binary search.
+ _.sortedIndex = function(array, obj, iteratee, context) {
+ iteratee = cb(iteratee, context, 1);
+ var value = iteratee(obj);
+ var low = 0, high = array.length;
+ while (low < high) {
+ var mid = Math.floor((low + high) / 2);
+ if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
+ }
+ return low;
+ };
+
+ // Generate an integer Array containing an arithmetic progression. A port of
+ // the native Python `range()` function. See
+ // [the Python documentation](http://docs.python.org/library/functions.html#range).
+ _.range = function(start, stop, step) {
+ if (arguments.length <= 1) {
+ stop = start || 0;
+ start = 0;
+ }
+ step = step || 1;
+
+ var length = Math.max(Math.ceil((stop - start) / step), 0);
+ var range = Array(length);
+
+ for (var idx = 0; idx < length; idx++, start += step) {
+ range[idx] = start;
+ }
+
+ return range;
+ };
+
+ // Function (ahem) Functions
+ // ------------------
+
+ // Determines whether to execute a function as a constructor
+ // or a normal function with the provided arguments
+ var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
+ if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
+ var self = baseCreate(sourceFunc.prototype);
+ var result = sourceFunc.apply(self, args);
+ if (_.isObject(result)) return result;
+ return self;
+ };
+
+ // Create a function bound to a given object (assigning `this`, and arguments,
+ // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
+ // available.
+ _.bind = function(func, context) {
+ if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
+ if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
+ var args = slice.call(arguments, 2);
+ var bound = function() {
+ return executeBound(func, bound, context, this, args.concat(slice.call(arguments)));
+ };
+ return bound;
+ };
+
+ // Partially apply a function by creating a version that has had some of its
+ // arguments pre-filled, without changing its dynamic `this` context. _ acts
+ // as a placeholder, allowing any combination of arguments to be pre-filled.
+ _.partial = function(func) {
+ var boundArgs = slice.call(arguments, 1);
+ var bound = function() {
+ var position = 0, length = boundArgs.length;
+ var args = Array(length);
+ for (var i = 0; i < length; i++) {
+ args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i];
+ }
+ while (position < arguments.length) args.push(arguments[position++]);
+ return executeBound(func, bound, this, this, args);
+ };
+ return bound;
+ };
+
+ // Bind a number of an object's methods to that object. Remaining arguments
+ // are the method names to be bound. Useful for ensuring that all callbacks
+ // defined on an object belong to it.
+ _.bindAll = function(obj) {
+ var i, length = arguments.length, key;
+ if (length <= 1) throw new Error('bindAll must be passed function names');
+ for (i = 1; i < length; i++) {
+ key = arguments[i];
+ obj[key] = _.bind(obj[key], obj);
+ }
+ return obj;
+ };
+
+ // Memoize an expensive function by storing its results.
+ _.memoize = function(func, hasher) {
+ var memoize = function(key) {
+ var cache = memoize.cache;
+ var address = '' + (hasher ? hasher.apply(this, arguments) : key);
+ if (!_.has(cache, address)) cache[address] = func.apply(this, arguments);
+ return cache[address];
+ };
+ memoize.cache = {};
+ return memoize;
+ };
+
+ // Delays a function for the given number of milliseconds, and then calls
+ // it with the arguments supplied.
+ _.delay = function(func, wait) {
+ var args = slice.call(arguments, 2);
+ return setTimeout(function(){
+ return func.apply(null, args);
+ }, wait);
+ };
+
+ // Defers a function, scheduling it to run after the current call stack has
+ // cleared.
+ _.defer = _.partial(_.delay, _, 1);
+
+ // Returns a function, that, when invoked, will only be triggered at most once
+ // during a given window of time. Normally, the throttled function will run
+ // as much as it can, without ever going more than once per `wait` duration;
+ // but if you'd like to disable the execution on the leading edge, pass
+ // `{leading: false}`. To disable execution on the trailing edge, ditto.
+ _.throttle = function(func, wait, options) {
+ var context, args, result;
+ var timeout = null;
+ var previous = 0;
+ if (!options) options = {};
+ var later = function() {
+ previous = options.leading === false ? 0 : _.now();
+ timeout = null;
+ result = func.apply(context, args);
+ if (!timeout) context = args = null;
+ };
+ return function() {
+ var now = _.now();
+ if (!previous && options.leading === false) previous = now;
+ var remaining = wait - (now - previous);
+ context = this;
+ args = arguments;
+ if (remaining <= 0 || remaining > wait) {
+ if (timeout) {
+ clearTimeout(timeout);
+ timeout = null;
+ }
+ previous = now;
+ result = func.apply(context, args);
+ if (!timeout) context = args = null;
+ } else if (!timeout && options.trailing !== false) {
+ timeout = setTimeout(later, remaining);
+ }
+ return result;
+ };
+ };
+
+ // Returns a function, that, as long as it continues to be invoked, will not
+ // be triggered. The function will be called after it stops being called for
+ // N milliseconds. If `immediate` is passed, trigger the function on the
+ // leading edge, instead of the trailing.
+ _.debounce = function(func, wait, immediate) {
+ var timeout, args, context, timestamp, result;
+
+ var later = function() {
+ var last = _.now() - timestamp;
+
+ if (last < wait && last >= 0) {
+ timeout = setTimeout(later, wait - last);
+ } else {
+ timeout = null;
+ if (!immediate) {
+ result = func.apply(context, args);
+ if (!timeout) context = args = null;
+ }
+ }
+ };
+
+ return function() {
+ context = this;
+ args = arguments;
+ timestamp = _.now();
+ var callNow = immediate && !timeout;
+ if (!timeout) timeout = setTimeout(later, wait);
+ if (callNow) {
+ result = func.apply(context, args);
+ context = args = null;
+ }
+
+ return result;
+ };
+ };
+
+ // Returns the first function passed as an argument to the second,
+ // allowing you to adjust arguments, run code before and after, and
+ // conditionally execute the original function.
+ _.wrap = function(func, wrapper) {
+ return _.partial(wrapper, func);
+ };
+
+ // Returns a negated version of the passed-in predicate.
+ _.negate = function(predicate) {
+ return function() {
+ return !predicate.apply(this, arguments);
+ };
+ };
+
+ // Returns a function that is the composition of a list of functions, each
+ // consuming the return value of the function that follows.
+ _.compose = function() {
+ var args = arguments;
+ var start = args.length - 1;
+ return function() {
+ var i = start;
+ var result = args[start].apply(this, arguments);
+ while (i--) result = args[i].call(this, result);
+ return result;
+ };
+ };
+
+ // Returns a function that will only be executed on and after the Nth call.
+ _.after = function(times, func) {
+ return function() {
+ if (--times < 1) {
+ return func.apply(this, arguments);
+ }
+ };
+ };
+
+ // Returns a function that will only be executed up to (but not including) the Nth call.
+ _.before = function(times, func) {
+ var memo;
+ return function() {
+ if (--times > 0) {
+ memo = func.apply(this, arguments);
+ }
+ if (times <= 1) func = null;
+ return memo;
+ };
+ };
+
+ // Returns a function that will be executed at most one time, no matter how
+ // often you call it. Useful for lazy initialization.
+ _.once = _.partial(_.before, 2);
+
+ // Object Functions
+ // ----------------
+
+ // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
+ var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
+ var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
+ 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
+
+ function collectNonEnumProps(obj, keys) {
+ var nonEnumIdx = nonEnumerableProps.length;
+ var constructor = obj.constructor;
+ var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto;
+
+ // Constructor is a special case.
+ var prop = 'constructor';
+ if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);
+
+ while (nonEnumIdx--) {
+ prop = nonEnumerableProps[nonEnumIdx];
+ if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
+ keys.push(prop);
+ }
+ }
+ }
+
+ // Retrieve the names of an object's own properties.
+ // Delegates to **ECMAScript 5**'s native `Object.keys`
+ _.keys = function(obj) {
+ if (!_.isObject(obj)) return [];
+ if (nativeKeys) return nativeKeys(obj);
+ var keys = [];
+ for (var key in obj) if (_.has(obj, key)) keys.push(key);
+ // Ahem, IE < 9.
+ if (hasEnumBug) collectNonEnumProps(obj, keys);
+ return keys;
+ };
+
+ // Retrieve all the property names of an object.
+ _.allKeys = function(obj) {
+ if (!_.isObject(obj)) return [];
+ var keys = [];
+ for (var key in obj) keys.push(key);
+ // Ahem, IE < 9.
+ if (hasEnumBug) collectNonEnumProps(obj, keys);
+ return keys;
+ };
+
+ // Retrieve the values of an object's properties.
+ _.values = function(obj) {
+ var keys = _.keys(obj);
+ var length = keys.length;
+ var values = Array(length);
+ for (var i = 0; i < length; i++) {
+ values[i] = obj[keys[i]];
+ }
+ return values;
+ };
+
+ // Returns the results of applying the iteratee to each element of the object
+ // In contrast to _.map it returns an object
+ _.mapObject = function(obj, iteratee, context) {
+ iteratee = cb(iteratee, context);
+ var keys = _.keys(obj),
+ length = keys.length,
+ results = {},
+ currentKey;
+ for (var index = 0; index < length; index++) {
+ currentKey = keys[index];
+ results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
+ }
+ return results;
+ };
+
+ // Convert an object into a list of `[key, value]` pairs.
+ _.pairs = function(obj) {
+ var keys = _.keys(obj);
+ var length = keys.length;
+ var pairs = Array(length);
+ for (var i = 0; i < length; i++) {
+ pairs[i] = [keys[i], obj[keys[i]]];
+ }
+ return pairs;
+ };
+
+ // Invert the keys and values of an object. The values must be serializable.
+ _.invert = function(obj) {
+ var result = {};
+ var keys = _.keys(obj);
+ for (var i = 0, length = keys.length; i < length; i++) {
+ result[obj[keys[i]]] = keys[i];
+ }
+ return result;
+ };
+
+ // Return a sorted list of the function names available on the object.
+ // Aliased as `methods`
+ _.functions = _.methods = function(obj) {
+ var names = [];
+ for (var key in obj) {
+ if (_.isFunction(obj[key])) names.push(key);
+ }
+ return names.sort();
+ };
+
+ // Extend a given object with all the properties in passed-in object(s).
+ _.extend = createAssigner(_.allKeys);
+
+ // Assigns a given object with all the own properties in the passed-in object(s)
+ // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
+ _.extendOwn = _.assign = createAssigner(_.keys);
+
+ // Returns the first key on an object that passes a predicate test
+ _.findKey = function(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var keys = _.keys(obj), key;
+ for (var i = 0, length = keys.length; i < length; i++) {
+ key = keys[i];
+ if (predicate(obj[key], key, obj)) return key;
+ }
+ };
+
+ // Return a copy of the object only containing the whitelisted properties.
+ _.pick = function(object, oiteratee, context) {
+ var result = {}, obj = object, iteratee, keys;
+ if (obj == null) return result;
+ if (_.isFunction(oiteratee)) {
+ keys = _.allKeys(obj);
+ iteratee = optimizeCb(oiteratee, context);
+ } else {
+ keys = flatten(arguments, false, false, 1);
+ iteratee = function(value, key, obj) { return key in obj; };
+ obj = Object(obj);
+ }
+ for (var i = 0, length = keys.length; i < length; i++) {
+ var key = keys[i];
+ var value = obj[key];
+ if (iteratee(value, key, obj)) result[key] = value;
+ }
+ return result;
+ };
+
+ // Return a copy of the object without the blacklisted properties.
+ _.omit = function(obj, iteratee, context) {
+ if (_.isFunction(iteratee)) {
+ iteratee = _.negate(iteratee);
+ } else {
+ var keys = _.map(flatten(arguments, false, false, 1), String);
+ iteratee = function(value, key) {
+ return !_.contains(keys, key);
+ };
+ }
+ return _.pick(obj, iteratee, context);
+ };
+
+ // Fill in a given object with default properties.
+ _.defaults = createAssigner(_.allKeys, true);
+
+ // Creates an object that inherits from the given prototype object.
+ // If additional properties are provided then they will be added to the
+ // created object.
+ _.create = function(prototype, props) {
+ var result = baseCreate(prototype);
+ if (props) _.extendOwn(result, props);
+ return result;
+ };
+
+ // Create a (shallow-cloned) duplicate of an object.
+ _.clone = function(obj) {
+ if (!_.isObject(obj)) return obj;
+ return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
+ };
+
+ // Invokes interceptor with the obj, and then returns obj.
+ // The primary purpose of this method is to "tap into" a method chain, in
+ // order to perform operations on intermediate results within the chain.
+ _.tap = function(obj, interceptor) {
+ interceptor(obj);
+ return obj;
+ };
+
+ // Returns whether an object has a given set of `key:value` pairs.
+ _.isMatch = function(object, attrs) {
+ var keys = _.keys(attrs), length = keys.length;
+ if (object == null) return !length;
+ var obj = Object(object);
+ for (var i = 0; i < length; i++) {
+ var key = keys[i];
+ if (attrs[key] !== obj[key] || !(key in obj)) return false;
+ }
+ return true;
+ };
+
+
+ // Internal recursive comparison function for `isEqual`.
+ var eq = function(a, b, aStack, bStack) {
+ // Identical objects are equal. `0 === -0`, but they aren't identical.
+ // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
+ if (a === b) return a !== 0 || 1 / a === 1 / b;
+ // A strict comparison is necessary because `null == undefined`.
+ if (a == null || b == null) return a === b;
+ // Unwrap any wrapped objects.
+ if (a instanceof _) a = a._wrapped;
+ if (b instanceof _) b = b._wrapped;
+ // Compare `[[Class]]` names.
+ var className = toString.call(a);
+ if (className !== toString.call(b)) return false;
+ switch (className) {
+ // Strings, numbers, regular expressions, dates, and booleans are compared by value.
+ case '[object RegExp]':
+ // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
+ case '[object String]':
+ // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
+ // equivalent to `new String("5")`.
+ return '' + a === '' + b;
+ case '[object Number]':
+ // `NaN`s are equivalent, but non-reflexive.
+ // Object(NaN) is equivalent to NaN
+ if (+a !== +a) return +b !== +b;
+ // An `egal` comparison is performed for other numeric values.
+ return +a === 0 ? 1 / +a === 1 / b : +a === +b;
+ case '[object Date]':
+ case '[object Boolean]':
+ // Coerce dates and booleans to numeric primitive values. Dates are compared by their
+ // millisecond representations. Note that invalid dates with millisecond representations
+ // of `NaN` are not equivalent.
+ return +a === +b;
+ }
+
+ var areArrays = className === '[object Array]';
+ if (!areArrays) {
+ if (typeof a != 'object' || typeof b != 'object') return false;
+
+ // Objects with different constructors are not equivalent, but `Object`s or `Array`s
+ // from different frames are.
+ var aCtor = a.constructor, bCtor = b.constructor;
+ if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor &&
+ _.isFunction(bCtor) && bCtor instanceof bCtor)
+ && ('constructor' in a && 'constructor' in b)) {
+ return false;
+ }
+ }
+ // Assume equality for cyclic structures. The algorithm for detecting cyclic
+ // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
+
+ // Initializing stack of traversed objects.
+ // It's done here since we only need them for objects and arrays comparison.
+ aStack = aStack || [];
+ bStack = bStack || [];
+ var length = aStack.length;
+ while (length--) {
+ // Linear search. Performance is inversely proportional to the number of
+ // unique nested structures.
+ if (aStack[length] === a) return bStack[length] === b;
+ }
+
+ // Add the first object to the stack of traversed objects.
+ aStack.push(a);
+ bStack.push(b);
+
+ // Recursively compare objects and arrays.
+ if (areArrays) {
+ // Compare array lengths to determine if a deep comparison is necessary.
+ length = a.length;
+ if (length !== b.length) return false;
+ // Deep compare the contents, ignoring non-numeric properties.
+ while (length--) {
+ if (!eq(a[length], b[length], aStack, bStack)) return false;
+ }
+ } else {
+ // Deep compare objects.
+ var keys = _.keys(a), key;
+ length = keys.length;
+ // Ensure that both objects contain the same number of properties before comparing deep equality.
+ if (_.keys(b).length !== length) return false;
+ while (length--) {
+ // Deep compare each member
+ key = keys[length];
+ if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
+ }
+ }
+ // Remove the first object from the stack of traversed objects.
+ aStack.pop();
+ bStack.pop();
+ return true;
+ };
+
+ // Perform a deep comparison to check if two objects are equal.
+ _.isEqual = function(a, b) {
+ return eq(a, b);
+ };
+
+ // Is a given array, string, or object empty?
+ // An "empty" object has no enumerable own-properties.
+ _.isEmpty = function(obj) {
+ if (obj == null) return true;
+ if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0;
+ return _.keys(obj).length === 0;
+ };
+
+ // Is a given value a DOM element?
+ _.isElement = function(obj) {
+ return !!(obj && obj.nodeType === 1);
+ };
+
+ // Is a given value an array?
+ // Delegates to ECMA5's native Array.isArray
+ _.isArray = nativeIsArray || function(obj) {
+ return toString.call(obj) === '[object Array]';
+ };
+
+ // Is a given variable an object?
+ _.isObject = function(obj) {
+ var type = typeof obj;
+ return type === 'function' || type === 'object' && !!obj;
+ };
+
+ // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.
+ _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) {
+ _['is' + name] = function(obj) {
+ return toString.call(obj) === '[object ' + name + ']';
+ };
+ });
+
+ // Define a fallback version of the method in browsers (ahem, IE < 9), where
+ // there isn't any inspectable "Arguments" type.
+ if (!_.isArguments(arguments)) {
+ _.isArguments = function(obj) {
+ return _.has(obj, 'callee');
+ };
+ }
+
+ // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8,
+ // IE 11 (#1621), and in Safari 8 (#1929).
+ if (typeof /./ != 'function' && typeof Int8Array != 'object') {
+ _.isFunction = function(obj) {
+ return typeof obj == 'function' || false;
+ };
+ }
+
+ // Is a given object a finite number?
+ _.isFinite = function(obj) {
+ return isFinite(obj) && !isNaN(parseFloat(obj));
+ };
+
+ // Is the given value `NaN`? (NaN is the only number which does not equal itself).
+ _.isNaN = function(obj) {
+ return _.isNumber(obj) && obj !== +obj;
+ };
+
+ // Is a given value a boolean?
+ _.isBoolean = function(obj) {
+ return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
+ };
+
+ // Is a given value equal to null?
+ _.isNull = function(obj) {
+ return obj === null;
+ };
+
+ // Is a given variable undefined?
+ _.isUndefined = function(obj) {
+ return obj === void 0;
+ };
+
+ // Shortcut function for checking if an object has a given property directly
+ // on itself (in other words, not on a prototype).
+ _.has = function(obj, key) {
+ return obj != null && hasOwnProperty.call(obj, key);
+ };
+
+ // Utility Functions
+ // -----------------
+
+ // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
+ // previous owner. Returns a reference to the Underscore object.
+ _.noConflict = function() {
+ root._ = previousUnderscore;
+ return this;
+ };
+
+ // Keep the identity function around for default iteratees.
+ _.identity = function(value) {
+ return value;
+ };
+
+ // Predicate-generating functions. Often useful outside of Underscore.
+ _.constant = function(value) {
+ return function() {
+ return value;
+ };
+ };
+
+ _.noop = function(){};
+
+ _.property = function(key) {
+ return function(obj) {
+ return obj == null ? void 0 : obj[key];
+ };
+ };
+
+ // Generates a function for a given object that returns a given property.
+ _.propertyOf = function(obj) {
+ return obj == null ? function(){} : function(key) {
+ return obj[key];
+ };
+ };
+
+ // Returns a predicate for checking whether an object has a given set of
+ // `key:value` pairs.
+ _.matcher = _.matches = function(attrs) {
+ attrs = _.extendOwn({}, attrs);
+ return function(obj) {
+ return _.isMatch(obj, attrs);
+ };
+ };
+
+ // Run a function **n** times.
+ _.times = function(n, iteratee, context) {
+ var accum = Array(Math.max(0, n));
+ iteratee = optimizeCb(iteratee, context, 1);
+ for (var i = 0; i < n; i++) accum[i] = iteratee(i);
+ return accum;
+ };
+
+ // Return a random integer between min and max (inclusive).
+ _.random = function(min, max) {
+ if (max == null) {
+ max = min;
+ min = 0;
+ }
+ return min + Math.floor(Math.random() * (max - min + 1));
+ };
+
+ // A (possibly faster) way to get the current timestamp as an integer.
+ _.now = Date.now || function() {
+ return new Date().getTime();
+ };
+
+ // List of HTML entities for escaping.
+ var escapeMap = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ "'": ''',
+ '`': '`'
+ };
+ var unescapeMap = _.invert(escapeMap);
+
+ // Functions for escaping and unescaping strings to/from HTML interpolation.
+ var createEscaper = function(map) {
+ var escaper = function(match) {
+ return map[match];
+ };
+ // Regexes for identifying a key that needs to be escaped
+ var source = '(?:' + _.keys(map).join('|') + ')';
+ var testRegexp = RegExp(source);
+ var replaceRegexp = RegExp(source, 'g');
+ return function(string) {
+ string = string == null ? '' : '' + string;
+ return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
+ };
+ };
+ _.escape = createEscaper(escapeMap);
+ _.unescape = createEscaper(unescapeMap);
+
+ // If the value of the named `property` is a function then invoke it with the
+ // `object` as context; otherwise, return it.
+ _.result = function(object, property, fallback) {
+ var value = object == null ? void 0 : object[property];
+ if (value === void 0) {
+ value = fallback;
+ }
+ return _.isFunction(value) ? value.call(object) : value;
+ };
+
+ // Generate a unique integer id (unique within the entire client session).
+ // Useful for temporary DOM ids.
+ var idCounter = 0;
+ _.uniqueId = function(prefix) {
+ var id = ++idCounter + '';
+ return prefix ? prefix + id : id;
+ };
+
+ // By default, Underscore uses ERB-style template delimiters, change the
+ // following template settings to use alternative delimiters.
+ _.templateSettings = {
+ evaluate : /<%([\s\S]+?)%>/g,
+ interpolate : /<%=([\s\S]+?)%>/g,
+ escape : /<%-([\s\S]+?)%>/g
+ };
+
+ // When customizing `templateSettings`, if you don't want to define an
+ // interpolation, evaluation or escaping regex, we need one that is
+ // guaranteed not to match.
+ var noMatch = /(.)^/;
+
+ // Certain characters need to be escaped so that they can be put into a
+ // string literal.
+ var escapes = {
+ "'": "'",
+ '\\': '\\',
+ '\r': 'r',
+ '\n': 'n',
+ '\u2028': 'u2028',
+ '\u2029': 'u2029'
+ };
+
+ var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
+
+ var escapeChar = function(match) {
+ return '\\' + escapes[match];
+ };
+
+ // JavaScript micro-templating, similar to John Resig's implementation.
+ // Underscore templating handles arbitrary delimiters, preserves whitespace,
+ // and correctly escapes quotes within interpolated code.
+ // NB: `oldSettings` only exists for backwards compatibility.
+ _.template = function(text, settings, oldSettings) {
+ if (!settings && oldSettings) settings = oldSettings;
+ settings = _.defaults({}, settings, _.templateSettings);
+
+ // Combine delimiters into one regular expression via alternation.
+ var matcher = RegExp([
+ (settings.escape || noMatch).source,
+ (settings.interpolate || noMatch).source,
+ (settings.evaluate || noMatch).source
+ ].join('|') + '|$', 'g');
+
+ // Compile the template source, escaping string literals appropriately.
+ var index = 0;
+ var source = "__p+='";
+ text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
+ source += text.slice(index, offset).replace(escaper, escapeChar);
+ index = offset + match.length;
+
+ if (escape) {
+ source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
+ } else if (interpolate) {
+ source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
+ } else if (evaluate) {
+ source += "';\n" + evaluate + "\n__p+='";
+ }
+
+ // Adobe VMs need the match returned to produce the correct offest.
+ return match;
+ });
+ source += "';\n";
+
+ // If a variable is not specified, place data values in local scope.
+ if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
+
+ source = "var __t,__p='',__j=Array.prototype.join," +
+ "print=function(){__p+=__j.call(arguments,'');};\n" +
+ source + 'return __p;\n';
+
+ try {
+ var render = new Function(settings.variable || 'obj', '_', source);
+ } catch (e) {
+ e.source = source;
+ throw e;
+ }
+
+ var template = function(data) {
+ return render.call(this, data, _);
+ };
+
+ // Provide the compiled source as a convenience for precompilation.
+ var argument = settings.variable || 'obj';
+ template.source = 'function(' + argument + '){\n' + source + '}';
+
+ return template;
+ };
+
+ // Add a "chain" function. Start chaining a wrapped Underscore object.
+ _.chain = function(obj) {
+ var instance = _(obj);
+ instance._chain = true;
+ return instance;
+ };
+
+ // OOP
+ // ---------------
+ // If Underscore is called as a function, it returns a wrapped object that
+ // can be used OO-style. This wrapper holds altered versions of all the
+ // underscore functions. Wrapped objects may be chained.
+
+ // Helper function to continue chaining intermediate results.
+ var result = function(instance, obj) {
+ return instance._chain ? _(obj).chain() : obj;
+ };
+
+ // Add your own custom functions to the Underscore object.
+ _.mixin = function(obj) {
+ _.each(_.functions(obj), function(name) {
+ var func = _[name] = obj[name];
+ _.prototype[name] = function() {
+ var args = [this._wrapped];
+ push.apply(args, arguments);
+ return result(this, func.apply(_, args));
+ };
+ });
+ };
+
+ // Add all of the Underscore functions to the wrapper object.
+ _.mixin(_);
+
+ // Add all mutator Array functions to the wrapper.
+ _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
+ var method = ArrayProto[name];
+ _.prototype[name] = function() {
+ var obj = this._wrapped;
+ method.apply(obj, arguments);
+ if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
+ return result(this, obj);
+ };
+ });
+
+ // Add all accessor Array functions to the wrapper.
+ _.each(['concat', 'join', 'slice'], function(name) {
+ var method = ArrayProto[name];
+ _.prototype[name] = function() {
+ return result(this, method.apply(this._wrapped, arguments));
+ };
+ });
+
+ // Extracts the result from a wrapped and chained object.
+ _.prototype.value = function() {
+ return this._wrapped;
+ };
+
+ // Provide unwrapping proxy for some methods used in engine operations
+ // such as arithmetic and JSON stringification.
+ _.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
+
+ _.prototype.toString = function() {
+ return '' + this._wrapped;
+ };
+
+ // AMD registration happens at the end for compatibility with AMD loaders
+ // that may not enforce next-turn semantics on modules. Even though general
+ // practice for AMD registration is to be anonymous, underscore registers
+ // as a named module because, like jQuery, it is a base library that is
+ // popular enough to be bundled in a third party lib, but not be part of
+ // an AMD load request. Those cases could generate an error when an
+ // anonymous define() is called outside of a loader request.
+ if (typeof define === 'function' && define.amd) {
+ define('underscore', [], function() {
+ return _;
+ });
+ }
+}.call(this));/**
+ * Created by richie on 15/7/8.
+ */
+/**
+ * 初始化BI对象
+ */
+if (window.BI == null) {
+ window.BI = {};
+}/**
+ * MVC工厂
+ * guy
+ * @class BI.Factory
+ */
+BI.Factory = {
+ parsePath: function parsePath (path) {
+ var segments = path.split('.');
+ return function (obj) {
+ for (var i = 0; i < segments.length; i++) {
+ if (!obj) {
+ return;
+ }
+ obj = obj[segments[i]];
+ }
+ return obj;
+ }
+ },
+ createView : function(url, viewFunc, mData, vData, context){
+ var modelFunc = viewFunc.replace(/View/, "Model");
+ modelFunc = this.parsePath(modelFunc)(window);
+ if(!_.isFunction(modelFunc)){
+ modelFunc = BI.Model;
+ }
+// try {
+ var model = new (modelFunc)(_.extend({}, mData, {
+ parent: context && context.model,
+ rootURL: url
+ }), {silent: true});
+// } catch (e) {
+//
+// }
+// try {
+ var view = new (eval(viewFunc))(_.extend({}, vData, {
+ model: model,
+ parent: context,
+ rootURL: url
+ }));
+// } catch (e) {
+//
+// }
+ return view;
+ }
+};(function (root, factory) {
+ root.BI = factory(root, root.BI || {}, root._, (root.jQuery || root.$));
+}(this, function (root, BI, _, $) {
+
+ var previousBI = root.BI;
+
+ // Create local references to array methods we'll want to use later.
+ var array = [];
+ var slice = array.slice;
+
+ // Current version of the library. Keep in sync with `package.json`.
+ BI.VERSION = '1.0.0';
+
+ // For BI's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
+ // the `$` variable.
+ BI.$ = $;
+
+ // Runs BI.js in *noConflict* mode, returning the `BI` variable
+ // to its previous owner. Returns a reference to this BI object.
+ BI.noConflict = function () {
+ root.BI = previousBI;
+ return this;
+ };
+
+ // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option
+ // will fake `"PATCH"`, `"PUT"` and `"DELETE"` requests via the `_method` parameter and
+ // set a `X-Http-Method-Override` header.
+ BI.emulateHTTP = true;
+
+ // Turn on `emulateJSON` to support legacy servers that can't deal with direct
+ // `application/json` requests ... this will encode the body as
+ // `application/x-www-form-urlencoded` instead and will send the model in a
+ // form param named `model`.
+ BI.emulateJSON = true;
+
+ // BI.Events
+ // ---------------
+
+ // A module that can be mixed in to *any object* in order to provide it with
+ // custom events. You may bind with `on` or remove with `off` callback
+ // functions to an event; `trigger`-ing an event fires all callbacks in
+ // succession.
+ //
+ // var object = {};
+ // _.extend(object, BI.Events);
+ // object.on('expand', function(){ alert('expanded'); });
+ // object.trigger('expand');
+ //
+ var Events = BI.Events = {
+
+ // Bind an event to a `callback` function. Passing `"all"` will bind
+ // the callback to all events fired.
+ on: function (name, callback, context) {
+ if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this;
+ this._events || (this._events = {});
+ var events = this._events[name] || (this._events[name] = []);
+ events.push({callback: callback, context: context, ctx: context || this});
+ return this;
+ },
+
+ // Bind an event to only be triggered a single time. After the first time
+ // the callback is invoked, it will be removed.
+ once: function (name, callback, context) {
+ if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this;
+ var self = this;
+ var once = _.once(function () {
+ self.off(name, once);
+ callback.apply(this, arguments);
+ });
+ once._callback = callback;
+ return this.on(name, once, context);
+ },
+
+ // Remove one or many callbacks. If `context` is null, removes all
+ // callbacks with that function. If `callback` is null, removes all
+ // callbacks for the event. If `name` is null, removes all bound
+ // callbacks for all events.
+ off: function (name, callback, context) {
+ if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this;
+
+ // Remove all callbacks for all events.
+ if (!name && !callback && !context) {
+ this._events = void 0;
+ return this;
+ }
+
+ var names = name ? [name] : _.keys(this._events);
+ for (var i = 0, length = names.length; i < length; i++) {
+ name = names[i];
+
+ // Bail out if there are no events stored.
+ var events = this._events[name];
+ if (!events) continue;
+
+ // Remove all callbacks for this event.
+ if (!callback && !context) {
+ delete this._events[name];
+ continue;
+ }
+
+ // Find any remaining events.
+ var remaining = [];
+ for (var j = 0, k = events.length; j < k; j++) {
+ var event = events[j];
+ if (
+ callback && callback !== event.callback &&
+ callback !== event.callback._callback ||
+ context && context !== event.context
+ ) {
+ remaining.push(event);
+ }
+ }
+
+ // Replace events if there are any remaining. Otherwise, clean up.
+ if (remaining.length) {
+ this._events[name] = remaining;
+ } else {
+ delete this._events[name];
+ }
+ }
+
+ return this;
+ },
+
+ un: function () {
+ this.off.apply(this, arguments);
+ },
+
+ // Trigger one or many events, firing all bound callbacks. Callbacks are
+ // passed the same arguments as `trigger` is, apart from the event name
+ // (unless you're listening on `"all"`, which will cause your callback to
+ // receive the true name of the event as the first argument).
+ trigger: function (name) {
+ if (!this._events) return this;
+ var args = slice.call(arguments, 1);
+ if (!eventsApi(this, 'trigger', name, args)) return this;
+ var events = this._events[name];
+ var allEvents = this._events.all;
+ if (events) triggerEvents(events, args);
+ if (allEvents) triggerEvents(allEvents, arguments);
+ return this;
+ },
+
+ fireEvent: function () {
+ this.trigger.apply(this, arguments);
+ },
+
+ // Inversion-of-control versions of `on` and `once`. Tell *this* object to
+ // listen to an event in another object ... keeping track of what it's
+ // listening to.
+ listenTo: function (obj, name, callback) {
+ var listeningTo = this._listeningTo || (this._listeningTo = {});
+ var id = obj._listenId || (obj._listenId = _.uniqueId('l'));
+ listeningTo[id] = obj;
+ if (!callback && typeof name === 'object') callback = this;
+ obj.on(name, callback, this);
+ return this;
+ },
+
+ listenToOnce: function (obj, name, callback) {
+ if (typeof name === 'object') {
+ for (var event in name) this.listenToOnce(obj, event, name[event]);
+ return this;
+ }
+ if (eventSplitter.test(name)) {
+ var names = name.split(eventSplitter);
+ for (var i = 0, length = names.length; i < length; i++) {
+ this.listenToOnce(obj, names[i], callback);
+ }
+ return this;
+ }
+ if (!callback) return this;
+ var once = _.once(function () {
+ this.stopListening(obj, name, once);
+ callback.apply(this, arguments);
+ });
+ once._callback = callback;
+ return this.listenTo(obj, name, once);
+ },
+
+ // Tell this object to stop listening to either specific events ... or
+ // to every object it's currently listening to.
+ stopListening: function (obj, name, callback) {
+ var listeningTo = this._listeningTo;
+ if (!listeningTo) return this;
+ var remove = !name && !callback;
+ if (!callback && typeof name === 'object') callback = this;
+ if (obj) (listeningTo = {})[obj._listenId] = obj;
+ for (var id in listeningTo) {
+ obj = listeningTo[id];
+ obj.off(name, callback, this);
+ if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id];
+ }
+ return this;
+ }
+
+ };
+
+ // Regular expression used to split event strings.
+ var eventSplitter = /\s+/;
+
+ // Implement fancy features of the Events API such as multiple event
+ // names `"change blur"` and jQuery-style event maps `{change: action}`
+ // in terms of the existing API.
+ var eventsApi = function (obj, action, name, rest) {
+ if (!name) return true;
+
+ // Handle event maps.
+ if (typeof name === 'object') {
+ for (var key in name) {
+ obj[action].apply(obj, [key, name[key]].concat(rest));
+ }
+ return false;
+ }
+
+ // Handle space separated event names.
+ if (eventSplitter.test(name)) {
+ var names = name.split(eventSplitter);
+ for (var i = 0, length = names.length; i < length; i++) {
+ obj[action].apply(obj, [names[i]].concat(rest));
+ }
+ return false;
+ }
+
+ return true;
+ };
+
+ // A difficult-to-believe, but optimized internal dispatch function for
+ // triggering events. Tries to keep the usual cases speedy (most internal
+ // BI events have 3 arguments).
+ var triggerEvents = function (events, args) {
+ var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
+ switch (args.length) {
+ case 0:
+ while (++i < l) (ev = events[i]).callback.call(ev.ctx);
+ return;
+ case 1:
+ while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1);
+ return;
+ case 2:
+ while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2);
+ return;
+ case 3:
+ while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3);
+ return;
+ default:
+ while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
+ return;
+ }
+ };
+
+ // Aliases for backwards compatibility.
+ Events.bind = Events.on;
+ Events.unbind = Events.off;
+
+ // Allow the `BI` object to serve as a global event bus, for folks who
+ // want global "pubsub" in a convenient place.
+ _.extend(BI, Events);
+
+ // BI.M
+ // --------------
+
+ // BI **Models** are the basic data object in the framework --
+ // frequently representing a row in a table in a database on your server.
+ // A discrete chunk of data and a bunch of useful, related methods for
+ // performing computations and transformations on that data.
+
+ // Create a new model with the specified attributes. A client id (`cid`)
+ // is automatically generated and assigned for you.
+ var M = BI.M = function (attributes, options) {
+ var attrs = attributes || {};
+ options = options || {};
+ this.cid = _.uniqueId('c');
+ this.attributes = {};
+ if (options.collection) this.collection = options.collection;
+ if (options.parse) attrs = this.parse(attrs, options) || {};
+ this.options = attrs = _.defaults({}, attrs, _.result(this, '_defaultConfig'));
+ _.extend(this, _.pick(this.options, modelOptions));
+ this.set(attrs, options);
+ this.changed = {};
+ this._init.apply(this, arguments);
+ };
+
+ var modelOptions = ['rootURL', 'parent', 'data', 'id'];
+
+ // Attach all inheritable methods to the M prototype.
+ _.extend(M.prototype, Events, {
+
+ // A hash of attributes whose current and previous value differ.
+ changed: null,
+
+ // The value returned during the last failed validation.
+ validationError: null,
+
+ // The default name for the JSON `id` attribute is `"id"`. MongoDB and
+ // CouchDB users may want to set this to `"_id"`.
+ idAttribute: 'ID',
+
+ _defaultConfig: function () {
+ return {}
+ },
+
+ // _init is an empty function by default. Override it with your own
+ // initialization logic.
+ _init: function () {
+ },
+
+ // Return a copy of the model's `attributes` object.
+ toJSON: function (options) {
+ return _.clone(this.attributes);
+ },
+
+ // Proxy `BI.sync` by default -- but override this if you need
+ // custom syncing semantics for *this* particular model.
+ sync: function () {
+ return BI.sync.apply(this, arguments);
+ },
+
+ // Get the value of an attribute.
+ get: function (attr) {
+ return this.attributes[attr];
+ },
+
+ // Get the HTML-escaped value of an attribute.
+ escape: function (attr) {
+ return _.escape(this.get(attr));
+ },
+
+ // Returns `true` if the attribute contains a value that is not null
+ // or undefined.
+ has: function (attr) {
+ return _.has(this.attributes, attr);
+ },
+
+ // Special-cased proxy to underscore's `_.matches` method.
+ matches: function (attrs) {
+ var keys = _.keys(attrs), length = keys.length;
+ var obj = Object(this.attributes);
+ for (var i = 0; i < length; i++) {
+ var key = keys[i];
+ if (!_.isEqual(attrs[key], obj[key]) || !(key in obj)) return false;
+ }
+ return true;
+ },
+
+ // Set a hash of model attributes on the object, firing `"change"`. This is
+ // the core primitive operation of a model, updating the data and notifying
+ // anyone who needs to know about the change in state. The heart of the beast.
+ set: function (key, val, options) {
+ var attr, attrs, unset, changes, silent, changing, changed, prev, current;
+ if (key == null) return this;
+
+ // Handle both `"key", value` and `{key: value}` -style arguments.
+ if (typeof key === 'object') {
+ attrs = key;
+ options = val;
+ } else {
+ (attrs = {})[key] = val;
+ }
+
+ options || (options = {});
+
+ // Run validation.
+ if (!this._validate(attrs, options)) return false;
+
+ // Extract attributes and options.
+ unset = options.unset;
+ silent = options.silent;
+ changes = [];
+ changing = this._changing;
+ this._changing = true;
+
+ if (!changing) {
+ this._previousAttributes = _.clone(this.attributes);
+ this.changed = {};
+ }
+ current = this.attributes, prev = this._previousAttributes;
+
+ // Check for changes of `id`.
+ if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
+
+ // For each `set` attribute, update or delete the current value.
+ for (attr in attrs) {
+ val = attrs[attr];
+ if (!_.isEqual(current[attr], val)) changes.push(attr);
+ if (!_.isEqual(prev[attr], val)) {
+ this.changed[attr] = val;
+ } else {
+ delete this.changed[attr];
+ }
+ unset ? delete current[attr] : current[attr] = val;
+ }
+
+ // Trigger all relevant attribute changes.
+ if (!silent) {
+ if (changes.length) this._pending = options;
+ for (var i = 0, length = changes.length; i < length; i++) {
+ this.trigger('change:' + changes[i], this, current[changes[i]], options);
+ }
+ }
+
+ // You might be wondering why there's a `while` loop here. Changes can
+ // be recursively nested within `"change"` events.
+ if (changing) return this;
+ changed = BI.clone(this.changed);
+ if (!silent) {
+ while (this._pending) {
+ options = this._pending;
+ this._pending = false;
+ this.trigger('change', changed, prev, this, options);
+ }
+ }
+ this._pending = false;
+ this._changing = false;
+ if (!silent && changes.length) this.trigger("changed", changed, prev, this, options);
+ return this;
+ },
+
+ // Remove an attribute from the model, firing `"change"`. `unset` is a noop
+ // if the attribute doesn't exist.
+ unset: function (attr, options) {
+ return this.set(attr, void 0, _.extend({}, options, {unset: true}));
+ },
+
+ // Clear all attributes on the model, firing `"change"`.
+ clear: function (options) {
+ var attrs = {};
+ for (var key in this.attributes) attrs[key] = void 0;
+ return this.set(attrs, _.extend({}, options, {unset: true}));
+ },
+
+ // Determine if the model has changed since the last `"change"` event.
+ // If you specify an attribute name, determine if that attribute has changed.
+ hasChanged: function (attr) {
+ if (attr == null) return !_.isEmpty(this.changed);
+ return _.has(this.changed, attr);
+ },
+
+ // Return an object containing all the attributes that have changed, or
+ // false if there are no changed attributes. Useful for determining what
+ // parts of a view need to be updated and/or what attributes need to be
+ // persisted to the server. Unset attributes will be set to undefined.
+ // You can also pass an attributes object to diff against the model,
+ // determining if there *would be* a change.
+ changedAttributes: function (diff) {
+ if (!diff) return this.hasChanged() ? _.clone(this.changed) : false;
+ var val, changed = false;
+ var old = this._changing ? this._previousAttributes : this.attributes;
+ for (var attr in diff) {
+ if (_.isEqual(old[attr], (val = diff[attr]))) continue;
+ (changed || (changed = {}))[attr] = val;
+ }
+ return changed;
+ },
+
+ // Get the previous value of an attribute, recorded at the time the last
+ // `"change"` event was fired.
+ previous: function (attr) {
+ if (attr == null || !this._previousAttributes) return null;
+ return this._previousAttributes[attr];
+ },
+
+ // Get all of the attributes of the model at the time of the previous
+ // `"change"` event.
+ previousAttributes: function () {
+ return _.clone(this._previousAttributes);
+ },
+
+ // Fetch the model from the server. If the server's representation of the
+ // model differs from its current attributes, they will be overridden,
+ // triggering a `"change"` event.
+ fetch: function (options) {
+ options = options ? _.clone(options) : {};
+ if (options.parse === void 0) options.parse = true;
+ var model = this;
+ var success = options.success;
+ options.success = function (resp) {
+ if (!options.noset) {
+ if (!model.set(model.parse(resp, options), options)) return false;
+ }
+ if (success) success(resp, model, options);
+ model.trigger('sync', resp, model, options).trigger('read', resp, model, options);
+ };
+ wrapError(this, options);
+ return this.sync('read', this, options);
+ },
+
+ // Set a hash of model attributes, and sync the model to the server.
+ // If the server returns an attributes hash that differs, the model's
+ // state will be `set` again.
+ save: function (key, val, options) {
+ var attrs, method, xhr, attributes = this.attributes;
+
+ // Handle both `"key", value` and `{key: value}` -style arguments.
+ if (key == null || typeof key === 'object') {
+ attrs = key;
+ options = val;
+ } else {
+ (attrs = {})[key] = val;
+ }
+
+ options = _.extend({validate: true}, options);
+
+ // If we're not waiting and attributes exist, save acts as
+ // `set(attr).save(null, opts)` with validation. Otherwise, check if
+ // the model will be valid when the attributes, if any, are set.
+ if (attrs && !options.wait) {
+ if (!this.set(attrs, options)) return false;
+ } else {
+ if (!this._validate(attrs, options)) return false;
+ }
+
+ // Set temporary attributes if `{wait: true}`.
+ if (attrs && options.wait) {
+ this.attributes = _.extend({}, attributes, attrs);
+ }
+
+ // After a successful server-side save, the client is (optionally)
+ // updated with the server-side state.
+ if (options.parse === void 0) options.parse = true;
+ var model = this;
+ var success = options.success;
+ options.success = function (resp) {
+ // Ensure attributes are restored during synchronous saves.
+ model.attributes = attributes;
+ var serverAttrs = model.parse(resp, options);
+ if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs);
+ if (_.isObject(serverAttrs) && !options.noset && !model.set(serverAttrs, options)) {
+ return false;
+ }
+ if (success) success(resp, model, options);
+ model.trigger('sync', resp, model, options)
+ .trigger((options.patch ? 'patch' : 'update'), resp, model, options);
+ };
+ wrapError(this, options);
+
+ method = /**this.isNew() ? 'create' :**/ (options.patch ? 'patch' : 'update');
+ if (method === 'patch' && !options.attrs) options.attrs = attrs;
+ xhr = this.sync(method, this, options);
+
+ // Restore attributes.
+ if (attrs && options.wait) this.attributes = attributes;
+
+ return xhr;
+ },
+
+ // Destroy this model on the server if it was already persisted.
+ // Optimistically removes the model from its collection, if it has one.
+ // If `wait: true` is passed, waits for the server to respond before removal.
+ destroy: function (options) {
+ options = options ? _.clone(options) : {};
+ var model = this;
+ var success = options.success;
+
+ var destroy = function () {
+ model.stopListening();
+ model.trigger('destroy', model.collection, model, options);
+ };
+
+ options.success = function (resp) {
+ if (options.wait || model.isNew()) destroy();
+ if (success) success(resp, model, options);
+ if (!model.isNew()) model.trigger('sync', resp, model, options).trigger('delete', resp, model, options);
+ };
+
+ if (this.isNew()) {
+ options.success();
+ return false;
+ }
+ wrapError(this, options);
+
+ var xhr = this.sync('delete', this, options);
+ if (!options.wait) destroy();
+ return xhr;
+ },
+
+ // Default URL for the model's representation on the server -- if you're
+ // using BI's restful methods, override this to change the endpoint
+ // that will be called.
+ url: function () {
+ var base =
+ _.result(this.collection, 'url');
+ if (this.isNew()) return base;
+ return base.replace(/([^\/])$/, '$1/') + encodeURIComponent(this.id);
+ },
+
+ // **parse** converts a response into the hash of attributes to be `set` on
+ // the model. The default implementation is just to pass the response along.
+ parse: function (resp, options) {
+ return resp;
+ },
+
+ // Create a new model with identical attributes to this one.
+ clone: function () {
+ return new this.constructor(this.attributes);
+ },
+
+ // A model is new if it has never been saved to the server, and lacks an id.
+ isNew: function () {
+ return !this.has(this.idAttribute);
+ },
+
+ // Check if the model is currently in a valid state.
+ isValid: function (options) {
+ return this._validate({}, _.extend(options || {}, {validate: true}));
+ },
+
+ // Run validation against the next complete set of model attributes,
+ // returning `true` if all is well. Otherwise, fire an `"invalid"` event.
+ _validate: function (attrs, options) {
+ if (!options.validate || !this.validate) return true;
+ attrs = _.extend({}, this.attributes, attrs);
+ var error = this.validationError = this.validate(attrs, options) || null;
+ if (!error) return true;
+ this.trigger('invalid', error, this, _.extend(options, {validationError: error}));
+ return false;
+ }
+
+ });
+
+ // Underscore methods that we want to implement on the M.
+ var modelMethods = ['keys', 'values', 'pairs', 'invert', 'pick', 'omit', 'chain', 'isEmpty'];
+
+ // Mix in each Underscore method as a proxy to `M#attributes`.
+ _.each(modelMethods, function (method) {
+ if (!_[method]) return;
+ M.prototype[method] = function () {
+ var args = slice.call(arguments);
+ args.unshift(this.attributes);
+ return _[method].apply(_, args);
+ };
+ });
+
+ // BI.Collection
+ // -------------------
+
+ // If models tend to represent a single row of data, a BI Collection is
+ // more analogous to a table full of data ... or a small slice or page of that
+ // table, or a collection of rows that belong together for a particular reason
+ // -- all of the messages in this particular folder, all of the documents
+ // belonging to this particular author, and so on. Collections maintain
+ // indexes of their models, both in order, and for lookup by `id`.
+
+ // Create a new **Collection**, perhaps to contain a specific type of `model`.
+ // If a `comparator` is specified, the Collection will maintain
+ // its models in sort order, as they're added and removed.
+ var Collection = BI.Collection = function (models, options) {
+ this.options = options = options || {};
+ if (options.model) this.model = options.model;
+ if (options.comparator !== void 0) this.comparator = options.comparator;
+ this._reset();
+ this._init.apply(this, arguments);
+ if (models) this.reset(models, _.extend({silent: true}, options));
+ };
+
+ // Default options for `Collection#set`.
+ var setOptions = {add: true, remove: true, merge: true};
+ var addOptions = {add: true, remove: false};
+
+ // Define the Collection's inheritable methods.
+ _.extend(Collection.prototype, Events, {
+
+ // The default model for a collection is just a **BI.M**.
+ // This should be overridden in most cases.
+ model: M,
+
+ // _init is an empty function by default. Override it with your own
+ // initialization logic.
+ _init: function () {
+ },
+
+ // The JSON representation of a Collection is an array of the
+ // models' attributes.
+ toJSON: function (options) {
+ return this.map(function (model) {
+ return model.toJSON(options);
+ });
+ },
+
+ // Proxy `BI.sync` by default.
+ sync: function () {
+ return BI.sync.apply(this, arguments);
+ },
+
+ // Add a model, or list of models to the set.
+ add: function (models, options) {
+ return this.set(models, _.extend({merge: false}, options, addOptions));
+ },
+
+ // Remove a model, or a list of models from the set.
+ remove: function (models, options) {
+ var singular = !_.isArray(models);
+ models = singular ? [models] : _.clone(models);
+ options || (options = {});
+ for (var i = 0, length = models.length; i < length; i++) {
+ var model = models[i] = this.get(models[i]);
+ if (!model) continue;
+ var id = this.modelId(model.attributes);
+ if (id != null) delete this._byId[id];
+ delete this._byId[model.cid];
+ var index = this.indexOf(model);
+ this.models.splice(index, 1);
+ this.length--;
+ if (!options.silent) {
+ options.index = index;
+ model.trigger('remove', model, this, options);
+ }
+ this._removeReference(model, options);
+ }
+ return singular ? models[0] : models;
+ },
+
+ // Update a collection by `set`-ing a new list of models, adding new ones,
+ // removing models that are no longer present, and merging models that
+ // already exist in the collection, as necessary. Similar to **M#set**,
+ // the core operation for updating the data contained by the collection.
+ set: function (models, options) {
+ options = _.defaults({}, options, setOptions);
+ if (options.parse) models = this.parse(models, options);
+ var singular = !_.isArray(models);
+ models = singular ? (models ? [models] : []) : models.slice();
+ var id, model, attrs, existing, sort;
+ var at = options.at;
+ if (at != null) at = +at;
+ if (at < 0) at += this.length + 1;
+ var sortable = this.comparator && (at == null) && options.sort !== false;
+ var sortAttr = _.isString(this.comparator) ? this.comparator : null;
+ var toAdd = [], toRemove = [], modelMap = {};
+ var add = options.add, merge = options.merge, remove = options.remove;
+ var order = !sortable && add && remove ? [] : false;
+ var orderChanged = false;
+
+ // Turn bare objects into model references, and prevent invalid models
+ // from being added.
+ for (var i = 0, length = models.length; i < length; i++) {
+ attrs = models[i];
+
+ // If a duplicate is found, prevent it from being added and
+ // optionally merge it into the existing model.
+ if (existing = this.get(attrs)) {
+ if (remove) modelMap[existing.cid] = true;
+ if (merge && attrs !== existing) {
+ attrs = this._isModel(attrs) ? attrs.attributes : attrs;
+ if (options.parse) attrs = existing.parse(attrs, options);
+ existing.set(attrs, options);
+ if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true;
+ }
+ models[i] = existing;
+
+ // If this is a new, valid model, push it to the `toAdd` list.
+ } else if (add) {
+ model = models[i] = this._prepareModel(attrs, options);
+ if (!model) continue;
+ toAdd.push(model);
+ this._addReference(model, options);
+ }
+
+ // Do not add multiple models with the same `id`.
+ model = existing || model;
+ if (!model) continue;
+ id = this.modelId(model.attributes);
+ if (order && (model.isNew() || !modelMap[id])) {
+ order.push(model);
+
+ // Check to see if this is actually a new model at this index.
+ orderChanged = orderChanged || !this.models[i] || model.cid !== this.models[i].cid;
+ }
+
+ modelMap[id] = true;
+ }
+
+ // Remove nonexistent models if appropriate.
+ if (remove) {
+ for (var i = 0, length = this.length; i < length; i++) {
+ if (!modelMap[(model = this.models[i]).cid]) toRemove.push(model);
+ }
+ if (toRemove.length) this.remove(toRemove, options);
+ }
+
+ // See if sorting is needed, update `length` and splice in new models.
+ if (toAdd.length || orderChanged) {
+ if (sortable) sort = true;
+ this.length += toAdd.length;
+ if (at != null) {
+ for (var i = 0, length = toAdd.length; i < length; i++) {
+ this.models.splice(at + i, 0, toAdd[i]);
+ }
+ } else {
+ if (order) this.models.length = 0;
+ var orderedModels = order || toAdd;
+ for (var i = 0, length = orderedModels.length; i < length; i++) {
+ this.models.push(orderedModels[i]);
+ }
+ }
+ }
+
+ // Silently sort the collection if appropriate.
+ if (sort) this.sort({silent: true});
+
+ // Unless silenced, it's time to fire all appropriate add/sort events.
+ if (!options.silent) {
+ var addOpts = at != null ? _.clone(options) : options;
+ for (var i = 0, length = toAdd.length; i < length; i++) {
+ if (at != null) addOpts.index = at + i;
+ (model = toAdd[i]).trigger('add', model, this, addOpts);
+ }
+ if (sort || orderChanged) this.trigger('sort', this, options);
+ }
+
+ // Return the added (or merged) model (or models).
+ return singular ? models[0] : models;
+ },
+
+ // When you have more items than you want to add or remove individually,
+ // you can reset the entire set with a new list of models, without firing
+ // any granular `add` or `remove` events. Fires `reset` when finished.
+ // Useful for bulk operations and optimizations.
+ reset: function (models, options) {
+ options = options ? _.clone(options) : {};
+ for (var i = 0, length = this.models.length; i < length; i++) {
+ this._removeReference(this.models[i], options);
+ }
+ options.previousModels = this.models;
+ this._reset();
+ models = this.add(models, _.extend({silent: true}, options));
+ if (!options.silent) this.trigger('reset', this, options);
+ return models;
+ },
+
+ // Add a model to the end of the collection.
+ push: function (model, options) {
+ return this.add(model, _.extend({at: this.length}, options));
+ },
+
+ // Remove a model from the end of the collection.
+ pop: function (options) {
+ var model = this.at(this.length - 1);
+ this.remove(model, options);
+ return model;
+ },
+
+ // Add a model to the beginning of the collection.
+ unshift: function (model, options) {
+ return this.add(model, _.extend({at: 0}, options));
+ },
+
+ // Remove a model from the beginning of the collection.
+ shift: function (options) {
+ var model = this.at(0);
+ this.remove(model, options);
+ return model;
+ },
+
+ // Slice out a sub-array of models from the collection.
+ slice: function () {
+ return slice.apply(this.models, arguments);
+ },
+
+ // Get a model from the set by id.
+ get: function (obj) {
+ if (obj == null) return void 0;
+ var id = this.modelId(this._isModel(obj) ? obj.attributes : obj);
+ return this._byId[obj] || this._byId[id] || this._byId[obj.cid];
+ },
+
+ // Get the model at the given index.
+ at: function (index) {
+ if (index < 0) index += this.length;
+ return this.models[index];
+ },
+
+ // Return models with matching attributes. Useful for simple cases of
+ // `filter`.
+ where: function (attrs, first) {
+ var matches = _.matches(attrs);
+ return this[first ? 'find' : 'filter'](function (model) {
+ return matches(model.attributes);
+ });
+ },
+
+ // Return the first model with matching attributes. Useful for simple cases
+ // of `find`.
+ findWhere: function (attrs) {
+ return this.where(attrs, true);
+ },
+
+ // Force the collection to re-sort itself. You don't need to call this under
+ // normal circumstances, as the set will maintain sort order as each item
+ // is added.
+ sort: function (options) {
+ if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
+ options || (options = {});
+
+ // Run sort based on type of `comparator`.
+ if (_.isString(this.comparator) || this.comparator.length === 1) {
+ this.models = this.sortBy(this.comparator, this);
+ } else {
+ this.models.sort(_.bind(this.comparator, this));
+ }
+
+ if (!options.silent) this.trigger('sort', this, options);
+ return this;
+ },
+
+ // Pluck an attribute from each model in the collection.
+ pluck: function (attr) {
+ return _.invoke(this.models, 'get', attr);
+ },
+
+ // Fetch the default set of models for this collection, resetting the
+ // collection when they arrive. If `reset: true` is passed, the response
+ // data will be passed through the `reset` method instead of `set`.
+ fetch: function (options) {
+ options = options ? _.clone(options) : {};
+ if (options.parse === void 0) options.parse = true;
+ var success = options.success;
+ var collection = this;
+ options.success = function (resp) {
+ var method = options.reset ? 'reset' : 'set';
+ collection[method](resp, options);
+ if (success) success(collection, resp, options);
+ collection.trigger('sync', collection, resp, options);
+ };
+ wrapError(this, options);
+ return this.sync('read', this, options);
+ },
+
+ // Create a new instance of a model in this collection. Add the model to the
+ // collection immediately, unless `wait: true` is passed, in which case we
+ // wait for the server to agree.
+ create: function (model, options) {
+ options = options ? _.clone(options) : {};
+ if (!(model = this._prepareModel(model, options))) return false;
+ if (!options.wait) this.add(model, options);
+ var collection = this;
+ var success = options.success;
+ options.success = function (model, resp) {
+ if (options.wait) collection.add(model, options);
+ if (success) success(model, resp, options);
+ };
+ model.save(null, options);
+ return model;
+ },
+
+ // **parse** converts a response into a list of models to be added to the
+ // collection. The default implementation is just to pass it through.
+ parse: function (resp, options) {
+ return resp;
+ },
+
+ // Create a new collection with an identical list of models as this one.
+ clone: function () {
+ return new this.constructor(this.models, {
+ model: this.model,
+ comparator: this.comparator
+ });
+ },
+
+ // Define how to uniquely identify models in the collection.
+ modelId: function (attrs) {
+ return attrs[this.model.prototype.idAttribute || 'id'];
+ },
+
+ // Private method to reset all internal state. Called when the collection
+ // is first _initd or reset.
+ _reset: function () {
+ this.length = 0;
+ this.models = [];
+ this._byId = {};
+ },
+
+ // Prepare a hash of attributes (or other model) to be added to this
+ // collection.
+ _prepareModel: function (attrs, options) {
+ if (this._isModel(attrs)) {
+ if (!attrs.collection) attrs.collection = this;
+ return attrs;
+ }
+ options = options ? _.clone(options) : {};
+ options.collection = this;
+ var model = new this.model(attrs, options);
+ if (!model.validationError) return model;
+ this.trigger('invalid', this, model.validationError, options);
+ return false;
+ },
+
+ // Method for checking whether an object should be considered a model for
+ // the purposes of adding to the collection.
+ _isModel: function (model) {
+ return model instanceof M;
+ },
+
+ // Internal method to create a model's ties to a collection.
+ _addReference: function (model, options) {
+ this._byId[model.cid] = model;
+ var id = this.modelId(model.attributes);
+ if (id != null) this._byId[id] = model;
+ model.on('all', this._onModelEvent, this);
+ },
+
+ // Internal method to sever a model's ties to a collection.
+ _removeReference: function (model, options) {
+ if (this === model.collection) delete model.collection;
+ model.off('all', this._onModelEvent, this);
+ },
+
+ // Internal method called every time a model in the set fires an event.
+ // Sets need to update their indexes when models change ids. All other
+ // events simply proxy through. "add" and "remove" events that originate
+ // in other collections are ignored.
+ _onModelEvent: function (event, model, collection, options) {
+ if ((event === 'add' || event === 'remove') && collection !== this) return;
+ if (event === 'destroy') this.remove(model, options);
+ if (event === 'change') {
+ var prevId = this.modelId(model.previousAttributes());
+ var id = this.modelId(model.attributes);
+ if (prevId !== id) {
+ if (prevId != null) delete this._byId[prevId];
+ if (id != null) this._byId[id] = model;
+ }
+ }
+ this.trigger.apply(this, arguments);
+ }
+
+ });
+
+ // Underscore methods that we want to implement on the Collection.
+ // 90% of the core usefulness of BI Collections is actually implemented
+ // right here:
+ var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl',
+ 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
+ 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
+ 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
+ 'tail', 'drop', 'last', 'without', 'difference', 'indexOf', 'shuffle',
+ 'lastIndexOf', 'isEmpty', 'chain', 'sample', 'partition'];
+
+ // Mix in each Underscore method as a proxy to `Collection#models`.
+ _.each(methods, function (method) {
+ if (!_[method]) return;
+ Collection.prototype[method] = function () {
+ var args = slice.call(arguments);
+ args.unshift(this.models);
+ return _[method].apply(_, args);
+ };
+ });
+
+ // Underscore methods that take a property name as an argument.
+ var attributeMethods = ['groupBy', 'countBy', 'sortBy', 'indexBy'];
+
+ // Use attributes instead of properties.
+ _.each(attributeMethods, function (method) {
+ if (!_[method]) return;
+ Collection.prototype[method] = function (value, context) {
+ var iterator = _.isFunction(value) ? value : function (model) {
+ return model.get(value);
+ };
+ return _[method](this.models, iterator, context);
+ };
+ });
+
+ // BI.V
+ // -------------
+
+ // BI Views are almost more convention than they are actual code. A V
+ // is simply a JavaScript object that represents a logical chunk of UI in the
+ // DOM. This might be a single item, an entire list, a sidebar or panel, or
+ // even the surrounding frame which wraps your whole app. Defining a chunk of
+ // UI as a **V** allows you to define your DOM events declaratively, without
+ // having to worry about render order ... and makes it easy for the view to
+ // react to specific changes in the state of your models.
+
+ // Creating a BI.V creates its initial element outside of the DOM,
+ // if an existing element is not provided...
+ var V = BI.V = function (options) {
+ this.cid = _.uniqueId('view');
+ options = options || {};
+ this.options = _.defaults(options, _.result(this, '_defaultConfig'));
+ _.extend(this, _.pick(this.options, viewOptions));
+ this._ensureElement();
+ this._init.apply(this, arguments);
+ };
+
+ // Cached regex to split keys for `delegate`.
+ var delegateEventSplitter = /^(\S+)\s*(.*)$/;
+
+ // List of view options to be merged as properties.
+ var viewOptions = ['rootURL', 'model', 'parent', 'collection', 'element', 'id', 'attributes', 'baseCls', 'tagName', 'events'];
+
+ // Set up all inheritable **BI.V** properties and methods.
+ _.extend(V.prototype, Events, {
+
+ // The default `tagName` of a V's element is `"div"`.
+ tagName: 'div',
+
+ // jQuery delegate for element lookup, scoped to DOM elements within the
+ // current view. This should be preferred to global lookups where possible.
+ $: function (selector) {
+ return this.$el.find(selector);
+ },
+
+ _defaultConfig: function () {
+ return {}
+ },
+
+ // _init is an empty function by default. Override it with your own
+ // initialization logic.
+ _init: function () {
+ },
+
+ //容器,默认放在this.element上
+ _vessel: function () {
+ return this
+ },
+ // **render** is the core function that your view should override, in order
+ // to populate its element (`this.el`), with the appropriate HTML. The
+ // convention is for **render** to always return `this`.
+ render: function (vessel) {
+ return this;
+ },
+
+ // Remove this view by taking the element out of the DOM, and removing any
+ // applicable BI.Events listeners.
+ remove: function () {
+ this._removeElement();
+ this.stopListening();
+ return this;
+ },
+
+ // Remove this view's element from the document and all event listeners
+ // attached to it. Exposed for subclasses using an alternative DOM
+ // manipulation API.
+ _removeElement: function () {
+ this.$el.remove();
+ if ($.browser.msie === true) {
+ this.el.outerHTML = '';
+ }
+ },
+
+ // Change the view's element (`this.el` property) and re-delegate the
+ // view's events on the new element.
+ setElement: function (element) {
+ this.undelegateEvents();
+ this._setElement(element);
+ this.vessel = this._vessel();
+ this.render(this.vessel);
+ this.delegateEvents();
+ return this;
+ },
+
+ setVisible: function (visible) {
+ this.options.invisible = !visible;
+ if (visible) {
+ this.element.css("display", "");
+ } else {
+ this.element.css("display", "none");
+ }
+ },
+
+ isVisible: function () {
+ return !this.options.invisible;
+ },
+
+ visible: function () {
+ this.setVisible(true);
+ },
+
+ invisible: function () {
+ this.setVisible(false);
+ },
+
+ // Creates the `this.el` and `this.$el` references for this view using the
+ // given `el`. `el` can be a CSS selector or an HTML string, a jQuery
+ // context or an element. Subclasses can override this to utilize an
+ // alternative DOM manipulation API and are only required to set the
+ // `this.el` property.
+ _setElement: function (el) {
+ this.$el = el instanceof BI.$ ? el : BI.$(el);
+ this.element = this.$el;
+ this.el = this.$el[0];
+ },
+
+ // Set callbacks, where `this.events` is a hash of
+ //
+ // *{"event selector": "callback"}*
+ //
+ // {
+ // 'mousedown .title': 'edit',
+ // 'click .button': 'save',
+ // 'click .open': function(e) { ... }
+ // }
+ //
+ // pairs. Callbacks will be bound to the view, with `this` set properly.
+ // Uses event delegation for efficiency.
+ // Omitting the selector binds the event to `this.el`.
+ delegateEvents: function (events) {
+ if (!(events || (events = _.result(this, 'events')))) return this;
+ this.undelegateEvents();
+ for (var key in events) {
+ var method = events[key];
+ if (!_.isFunction(method)) method = this[events[key]];
+ if (!method) continue;
+ var match = key.match(delegateEventSplitter);
+ this.delegate(match[1], match[2], _.bind(method, this));
+ }
+ return this;
+ },
+
+ // Add a single event listener to the view's element (or a child element
+ // using `selector`). This only works for delegate-able events: not `focus`,
+ // `blur`, and not `change`, `submit`, and `reset` in Internet Explorer.
+ delegate: function (eventName, selector, listener) {
+ this.vessel.element.on(eventName + '.delegateEvents' + this.cid, selector, listener);
+ },
+
+ // Clears all callbacks previously bound to the view by `delegateEvents`.
+ // You usually don't need to use this, but may wish to if you have multiple
+ // BI views attached to the same DOM element.
+ undelegateEvents: function () {
+ if (this.vessel) this.vessel.element.off('.delegateEvents' + this.cid);
+ return this;
+ },
+
+ // A finer-grained `undelegateEvents` for removing a single delegated event.
+ // `selector` and `listener` are both optional.
+ undelegate: function (eventName, selector, listener) {
+ this.vessel.element.off(eventName + '.delegateEvents' + this.cid, selector, listener);
+ },
+
+ // Produces a DOM element to be assigned to your view. Exposed for
+ // subclasses using an alternative DOM manipulation API.
+ _createElement: function (tagName) {
+ return document.createElement(tagName);
+ },
+
+ // Ensure that the V has a DOM element to render into.
+ // If `this.el` is a string, pass it through `$()`, take the first
+ // matching element, and re-assign it to `el`. Otherwise, create
+ // an element from the `id`, `className` and `tagName` properties.
+ _ensureElement: function () {
+ var attrs = _.extend({}, _.result(this, 'attributes'));
+ if (this.baseCls) attrs['class'] = _.result(this, 'baseCls');
+ if (!this.element) {
+ this.setElement(this._createElement(_.result(this, 'tagName')));
+ } else {
+ this.setElement(_.result(this, 'element'));
+ }
+ this._setAttributes(attrs);
+ },
+
+ // Set attributes from a hash on this view's element. Exposed for
+ // subclasses using an alternative DOM manipulation API.
+ _setAttributes: function (attributes) {
+ this.$el.attr(attributes);
+ }
+
+ });
+
+ // BI.sync
+ // -------------
+
+ // Override this function to change the manner in which BI persists
+ // models to the server. You will be passed the type of request, and the
+ // model in question. By default, makes a RESTful Ajax request
+ // to the model's `url()`. Some possible customizations could be:
+ //
+ // * Use `setTimeout` to batch rapid-fire updates into a single request.
+ // * Send up the models as XML instead of JSON.
+ // * Persist models via WebSockets instead of Ajax.
+ //
+ // Turn on `BI.emulateHTTP` in order to send `PUT` and `DELETE` requests
+ // as `POST`, with a `_method` parameter containing the true HTTP method,
+ // as well as all requests with the body as `application/x-www-form-urlencoded`
+ // instead of `application/json` with the model in a param named `model`.
+ // Useful when interfacing with server-side languages like **PHP** that make
+ // it difficult to read the body of `PUT` requests.
+ BI.sync = function (method, model, options) {
+ var type = methodMap[method];
+
+ // Default options, unless specified.
+ _.defaults(options || (options = {}), {
+ emulateHTTP: BI.emulateHTTP,
+ emulateJSON: BI.emulateJSON
+ });
+
+ // Default JSON-request options.
+ var params = {type: type, dataType: 'json'};
+
+ // Ensure that we have a URL.
+ if (!options.url) {
+ params.url = _.result(model, method + "URL") || _.result(model, 'url');
+ if (!params.url) {
+ return;
+ }
+ }
+
+ // Ensure that we have the appropriate request data.
+ if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) {
+ params.contentType = 'application/json';
+ params.data = _.extend({id: model.id}, model.toJSON(options), options.attrs);
+ }
+
+ // For older servers, emulate JSON by encoding the request into an HTML-form.
+ if (options.emulateJSON) {
+ params.contentType = 'application/x-www-form-urlencoded';
+ params.data = options.data ? options.data : params.data;
+ }
+
+ // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
+ // And an `X-HTTP-Method-Override` header.
+ if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) {
+ params.type = 'POST';
+ if (options.emulateJSON) params.data._method = type;
+ var beforeSend = options.beforeSend;
+ options.beforeSend = function (xhr) {
+ xhr.setRequestHeader('X-HTTP-Method-Override', type);
+ if (beforeSend) return beforeSend.apply(this, arguments);
+ };
+ }
+
+ // Don't process data on a non-GET request.
+ if (params.type !== 'GET' && !options.emulateJSON) {
+ params.processData = false;
+ }
+
+ // Pass along `textStatus` and `errorThrown` from jQuery.
+ var error = options.error;
+ options.error = function (xhr, textStatus, errorThrown) {
+ options.textStatus = textStatus;
+ options.errorThrown = errorThrown;
+ if (error) error.apply(this, arguments);
+ };
+
+ // Make the request, allowing the user to override any Ajax options.
+ var xhr = options.xhr = BI.ajax(_.extend(params, options));
+ model.trigger('request', xhr, model, options);
+ return xhr;
+ };
+
+ // Map from CRUD to HTTP for our default `BI.sync` implementation.
+ var methodMap = {
+ 'create': 'POST',
+ 'update': 'PUT',
+ 'patch': 'PATCH',
+ 'delete': 'DELETE',
+ 'read': 'GET'
+ };
+
+ // Set the default implementation of `BI.ajax` to proxy through to `$`.
+ // Override this if you'd like to use a different library.
+ BI.ajax = $.ajax;
+
+ // BI.Router
+ // ---------------
+
+ // Routers map faux-URLs to actions, and fire events when routes are
+ // matched. Creating a new one sets its `routes` hash, if not set statically.
+ var Router = BI.Router = function (options) {
+ options || (options = {});
+ if (options.routes) this.routes = options.routes;
+ this._bindRoutes();
+ this._init.apply(this, arguments);
+ };
+
+ // Cached regular expressions for matching named param parts and splatted
+ // parts of route strings.
+ var optionalParam = /\((.*?)\)/g;
+ var namedParam = /(\(\?)?:\w+/g;
+ var splatParam = /\*\w+/g;
+ var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;
+
+ // Set up all inheritable **BI.Router** properties and methods.
+ _.extend(Router.prototype, Events, {
+
+ // _init is an empty function by default. Override it with your own
+ // initialization logic.
+ _init: function () {
+ },
+
+ // Manually bind a single named route to a callback. For example:
+ //
+ // this.route('search/:query/p:num', 'search', function(query, num) {
+ // ...
+ // });
+ //
+ route: function (route, name, callback) {
+ if (!_.isRegExp(route)) route = this._routeToRegExp(route);
+ if (_.isFunction(name)) {
+ callback = name;
+ name = '';
+ }
+ if (!callback) callback = this[name];
+ var router = this;
+ BI.history.route(route, function (fragment) {
+ var args = router._extractParameters(route, fragment);
+ if (router.execute(callback, args, name) !== false) {
+ router.trigger.apply(router, ['route:' + name].concat(args));
+ router.trigger('route', name, args);
+ BI.history.trigger('route', router, name, args);
+ }
+ });
+ return this;
+ },
+
+ // Execute a route handler with the provided parameters. This is an
+ // excellent place to do pre-route setup or post-route cleanup.
+ execute: function (callback, args, name) {
+ if (callback) callback.apply(this, args);
+ },
+
+ // Simple proxy to `BI.history` to save a fragment into the history.
+ navigate: function (fragment, options) {
+ BI.history.navigate(fragment, options);
+ return this;
+ },
+
+ // Bind all defined routes to `BI.history`. We have to reverse the
+ // order of the routes here to support behavior where the most general
+ // routes can be defined at the bottom of the route map.
+ _bindRoutes: function () {
+ if (!this.routes) return;
+ this.routes = _.result(this, 'routes');
+ var route, routes = _.keys(this.routes);
+ while ((route = routes.pop()) != null) {
+ this.route(route, this.routes[route]);
+ }
+ },
+
+ // Convert a route string into a regular expression, suitable for matching
+ // against the current location hash.
+ _routeToRegExp: function (route) {
+ route = route.replace(escapeRegExp, '\\$&')
+ .replace(optionalParam, '(?:$1)?')
+ .replace(namedParam, function (match, optional) {
+ return optional ? match : '([^/?]+)';
+ })
+ .replace(splatParam, '([^?]*?)');
+ return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$');
+ },
+
+ // Given a route, and a URL fragment that it matches, return the array of
+ // extracted decoded parameters. Empty or unmatched parameters will be
+ // treated as `null` to normalize cross-browser behavior.
+ _extractParameters: function (route, fragment) {
+ var params = route.exec(fragment).slice(1);
+ return _.map(params, function (param, i) {
+ // Don't decode the search params.
+ if (i === params.length - 1) return param || null;
+ return param ? decodeURIComponent(param) : null;
+ });
+ }
+
+ });
+
+ // BI.History
+ // ----------------
+
+ // Handles cross-browser history management, based on either
+ // [pushState](http://diveintohtml5.info/history.html) and real URLs, or
+ // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange)
+ // and URL fragments. If the browser supports neither (old IE, natch),
+ // falls back to polling.
+ var History = BI.History = function () {
+ this.handlers = [];
+ _.bindAll(this, 'checkUrl');
+
+ // Ensure that `History` can be used outside of the browser.
+ if (typeof window !== 'undefined') {
+ this.location = window.location;
+ this.history = window.history;
+ }
+ };
+
+ // Cached regex for stripping a leading hash/slash and trailing space.
+ var routeStripper = /^[#\/]|\s+$/g;
+
+ // Cached regex for stripping leading and trailing slashes.
+ var rootStripper = /^\/+|\/+$/g;
+
+ // Cached regex for stripping urls of hash.
+ var pathStripper = /#.*$/;
+
+ // Has the history handling already been started?
+ History.started = false;
+
+ // Set up all inheritable **BI.History** properties and methods.
+ _.extend(History.prototype, Events, {
+
+ // The default interval to poll for hash changes, if necessary, is
+ // twenty times a second.
+ interval: 50,
+
+ // Are we at the app root?
+ atRoot: function () {
+ var path = this.location.pathname.replace(/[^\/]$/, '$&/');
+ return path === this.root && !this.getSearch();
+ },
+
+ // In IE6, the hash fragment and search params are incorrect if the
+ // fragment contains `?`.
+ getSearch: function () {
+ var match = this.location.href.replace(/#.*/, '').match(/\?.+/);
+ return match ? match[0] : '';
+ },
+
+ // Gets the true hash value. Cannot use location.hash directly due to bug
+ // in Firefox where location.hash will always be decoded.
+ getHash: function (window) {
+ var match = (window || this).location.href.match(/#(.*)$/);
+ return match ? match[1] : '';
+ },
+
+ // Get the pathname and search params, without the root.
+ getPath: function () {
+ var path = decodeURI(this.location.pathname + this.getSearch());
+ var root = this.root.slice(0, -1);
+ if (!path.indexOf(root)) path = path.slice(root.length);
+ return path.charAt(0) === '/' ? path.slice(1) : path;
+ },
+
+ // Get the cross-browser normalized URL fragment from the path or hash.
+ getFragment: function (fragment) {
+ if (fragment == null) {
+ if (this._hasPushState || !this._wantsHashChange) {
+ fragment = this.getPath();
+ } else {
+ fragment = this.getHash();
+ }
+ }
+ return fragment.replace(routeStripper, '');
+ },
+
+ // Start the hash change handling, returning `true` if the current URL matches
+ // an existing route, and `false` otherwise.
+ start: function (options) {
+ if (History.started) throw new Error('BI.history has already been started');
+ History.started = true;
+
+ // Figure out the initial configuration. Do we need an iframe?
+ // Is pushState desired ... is it available?
+ this.options = _.extend({root: '/'}, this.options, options);
+ this.root = this.options.root;
+ this._wantsHashChange = this.options.hashChange !== false;
+ this._hasHashChange = 'onhashchange' in window;
+ this._wantsPushState = !!this.options.pushState;
+ this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState);
+ this.fragment = this.getFragment();
+
+ // Normalize root to always include a leading and trailing slash.
+ this.root = ('/' + this.root + '/').replace(rootStripper, '/');
+
+ // Transition from hashChange to pushState or vice versa if both are
+ // requested.
+ if (this._wantsHashChange && this._wantsPushState) {
+
+ // If we've started off with a route from a `pushState`-enabled
+ // browser, but we're currently in a browser that doesn't support it...
+ if (!this._hasPushState && !this.atRoot()) {
+ var root = this.root.slice(0, -1) || '/';
+ this.location.replace(root + '#' + this.getPath());
+ // Return immediately as browser will do redirect to new url
+ return true;
+
+ // Or if we've started out with a hash-based route, but we're currently
+ // in a browser where it could be `pushState`-based instead...
+ } else if (this._hasPushState && this.atRoot()) {
+ this.navigate(this.getHash(), {replace: true});
+ }
+
+ }
+
+ // Proxy an iframe to handle location events if the browser doesn't
+ // support the `hashchange` event, HTML5 history, or the user wants
+ // `hashChange` but not `pushState`.
+ if (!this._hasHashChange && this._wantsHashChange && (!this._wantsPushState || !this._hasPushState)) {
+ var iframe = document.createElement('iframe');
+ iframe.src = 'javascript:0';
+ iframe.style.display = 'none';
+ iframe.tabIndex = -1;
+ var body = document.body;
+ // Using `appendChild` will throw on IE < 9 if the document is not ready.
+ this.iframe = body.insertBefore(iframe, body.firstChild).contentWindow;
+ this.iframe.document.open().close();
+ this.iframe.location.hash = '#' + this.fragment;
+ }
+
+ // Add a cross-platform `addEventListener` shim for older browsers.
+ var addEventListener = window.addEventListener || function (eventName, listener) {
+ return attachEvent('on' + eventName, listener);
+ };
+
+ // Depending on whether we're using pushState or hashes, and whether
+ // 'onhashchange' is supported, determine how we check the URL state.
+ if (this._hasPushState) {
+ addEventListener('popstate', this.checkUrl, false);
+ } else if (this._wantsHashChange && this._hasHashChange && !this.iframe) {
+ addEventListener('hashchange', this.checkUrl, false);
+ } else if (this._wantsHashChange) {
+ this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
+ }
+
+ if (!this.options.silent) return this.loadUrl();
+ },
+
+ // Disable BI.history, perhaps temporarily. Not useful in a real app,
+ // but possibly useful for unit testing Routers.
+ stop: function () {
+ // Add a cross-platform `removeEventListener` shim for older browsers.
+ var removeEventListener = window.removeEventListener || function (eventName, listener) {
+ return detachEvent('on' + eventName, listener);
+ };
+
+ // Remove window listeners.
+ if (this._hasPushState) {
+ removeEventListener('popstate', this.checkUrl, false);
+ } else if (this._wantsHashChange && this._hasHashChange && !this.iframe) {
+ removeEventListener('hashchange', this.checkUrl, false);
+ }
+
+ // Clean up the iframe if necessary.
+ if (this.iframe) {
+ document.body.removeChild(this.iframe.frameElement);
+ this.iframe = null;
+ }
+
+ // Some environments will throw when clearing an undefined interval.
+ if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
+ History.started = false;
+ },
+
+ // Add a route to be tested when the fragment changes. Routes added later
+ // may override previous routes.
+ route: function (route, callback) {
+ this.handlers.unshift({route: route, callback: callback});
+ },
+
+ // Checks the current URL to see if it has changed, and if it has,
+ // calls `loadUrl`, normalizing across the hidden iframe.
+ checkUrl: function (e) {
+ var current = this.getFragment();
+
+ // If the user pressed the back button, the iframe's hash will have
+ // changed and we should use that for comparison.
+ if (current === this.fragment && this.iframe) {
+ current = this.getHash(this.iframe);
+ }
+
+ if (current === this.fragment) return false;
+ if (this.iframe) this.navigate(current);
+ this.loadUrl();
+ },
+
+ // Attempt to load the current URL fragment. If a route succeeds with a
+ // match, returns `true`. If no defined routes matches the fragment,
+ // returns `false`.
+ loadUrl: function (fragment) {
+ fragment = this.fragment = this.getFragment(fragment);
+ return _.any(this.handlers, function (handler) {
+ if (handler.route.test(fragment)) {
+ handler.callback(fragment);
+ return true;
+ }
+ });
+ },
+
+ // Save a fragment into the hash history, or replace the URL state if the
+ // 'replace' option is passed. You are responsible for properly URL-encoding
+ // the fragment in advance.
+ //
+ // The options object can contain `trigger: true` if you wish to have the
+ // route callback be fired (not usually desirable), or `replace: true`, if
+ // you wish to modify the current URL without adding an entry to the history.
+ navigate: function (fragment, options) {
+ if (!History.started) return false;
+ if (!options || options === true) options = {trigger: !!options};
+
+ // Normalize the fragment.
+ fragment = this.getFragment(fragment || '');
+
+ // Don't include a trailing slash on the root.
+ var root = this.root;
+ if (fragment === '' || fragment.charAt(0) === '?') {
+ root = root.slice(0, -1) || '/';
+ }
+ var url = root + fragment;
+
+ // Strip the hash and decode for matching.
+ fragment = decodeURI(fragment.replace(pathStripper, ''));
+
+ if (this.fragment === fragment) return;
+ this.fragment = fragment;
+
+ // If pushState is available, we use it to set the fragment as a real URL.
+ if (this._hasPushState) {
+ this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url);
+
+ // If hash changes haven't been explicitly disabled, update the hash
+ // fragment to store history.
+ } else if (this._wantsHashChange) {
+ this._updateHash(this.location, fragment, options.replace);
+ if (this.iframe && (fragment !== this.getHash(this.iframe))) {
+ // Opening and closing the iframe tricks IE7 and earlier to push a
+ // history entry on hash-tag change. When replace is true, we don't
+ // want this.
+ if (!options.replace) this.iframe.document.open().close();
+ this._updateHash(this.iframe.location, fragment, options.replace);
+ }
+
+ // If you've told us that you explicitly don't want fallback hashchange-
+ // based history, then `navigate` becomes a page refresh.
+ } else {
+ return this.location.assign(url);
+ }
+ if (options.trigger) return this.loadUrl(fragment);
+ },
+
+ // Update the hash location, either replacing the current entry, or adding
+ // a new one to the browser history.
+ _updateHash: function (location, fragment, replace) {
+ if (replace) {
+ var href = location.href.replace(/(javascript:|#).*$/, '');
+ location.replace(href + '#' + fragment);
+ } else {
+ // Some browsers require that `hash` contains a leading #.
+ location.hash = '#' + fragment;
+ }
+ }
+
+ });
+
+ // Create the default BI.history.
+ BI.history = new History;
+
+ // Helpers
+ // -------
+
+ // Helper function to correctly set up the prototype chain, for subclasses.
+ // Similar to `goog.inherits`, but uses a hash of prototype properties and
+ // class properties to be extended.
+ var extend = function (protoProps, staticProps) {
+ var parent = this;
+ var child;
+
+ // The constructor function for the new subclass is either defined by you
+ // (the "constructor" property in your `extend` definition), or defaulted
+ // by us to simply call the parent's constructor.
+ if (protoProps && _.has(protoProps, 'constructor')) {
+ child = protoProps.constructor;
+ } else {
+ child = function () {
+ return parent.apply(this, arguments);
+ };
+ }
+
+ // Add static properties to the constructor function, if supplied.
+ _.extend(child, parent, staticProps);
+
+ // Set the prototype chain to inherit from `parent`, without calling
+ // `parent`'s constructor function.
+ var Surrogate = function () {
+ this.constructor = child;
+ };
+ Surrogate.prototype = parent.prototype;
+ child.prototype = new Surrogate;
+
+ // Add prototype properties (instance properties) to the subclass,
+ // if supplied.
+ if (protoProps) _.extend(child.prototype, protoProps);
+
+ // Set a convenience property in case the parent's prototype is needed
+ // later.
+ child.__super__ = parent.prototype;
+
+ return child;
+ };
+
+ // Set up inheritance for the model, collection, router, view and history.
+ M.extend = Collection.extend = Router.extend = V.extend = History.extend = extend;
+
+ // Throw an error when a URL is needed, and none is supplied.
+ var urlError = function () {
+ throw new Error('A "url" property or function must be specified');
+ };
+
+ // Wrap an optional error callback with a fallback error event.
+ var wrapError = function (model, options) {
+ var error = options.error;
+ options.error = function (resp) {
+ if (error) error(model, resp, options);
+ model.trigger('error', model, resp, options);
+ };
+ };
+
+ return BI;
+
+}));/**
+ * MVC路由
+ * @class BI.WRouter
+ * @extends BI.Router
+ * @type {*|void|Object}
+ */
+BI.WRouter = BI.Router.extend({
+ add: function(route, callback){
+ this.handlers || (this.handlers=[]);
+ this.handlers.unshift({route: route, callback: callback})
+ },
+
+ route: function(route, name, callback) {
+ if (!_.isRegExp(route)) route = this._routeToRegExp(route);
+ if (_.isFunction(name)) {
+ callback = name;
+ name = '';
+ }
+ if (!callback) callback = this[name];
+ var self = this;
+ this.add(route, function(fragment) {
+ var args = self._extractParameters(route, fragment);
+ var result = self.execute(callback, args, name)
+ if (result !== false) {
+ self.trigger.apply(self, ['route:' + name].concat(args));
+ self.trigger('route', name, args);
+ }
+ return result;
+ });
+ return this;
+ },
+
+ execute: function(callback, args, name) {
+ if (callback) return callback.apply(this, args);
+ return name;
+ },
+
+ get: function(fragment){
+ var result = null;
+ _.any(this.handlers, function(handler) {
+ if (handler.route.test(fragment)) {
+ result = handler.callback(fragment);
+ return true;
+ }
+ });
+ return result;
+ }
+});/**
+ * 基本函数
+ * Create By GUY 2014\11\17
+ *
+ */
+
+if (!window.BI) {
+ window.BI = {};
+}
+;
+!(function ($, undefined) {
+ var traverse = function (func, context) {
+ return function (value, key, obj) {
+ return func.call(context, key, value, obj);
+ }
+ };
+ var _apply = function (name) {
+ return function () {
+ return _[name].apply(_, arguments);
+ }
+ };
+ var _applyFunc = function (name) {
+ return function () {
+ var args = Array.prototype.slice.call(arguments, 0);
+ args[1] = _.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1];
+ return _[name].apply(_, args);
+ }
+ };
+
+ //Utility
+ _.extend(BI, {
+ i18nText: function (key) {
+ var localeText = (BI.i18n && BI.i18n[key]) || "";
+ if (!localeText) {
+ localeText = key;
+ }
+ var len = arguments.length;
+ if (len > 1) {
+ for (var i = 1; i < len; i++) {
+ var key = "{R" + i + "}";
+ localeText = localeText.replaceAll(key, arguments[i] + "");
+ }
+ }
+ return localeText;
+ },
+
+ assert: function (v, is) {
+ if (this.isFunction(is)) {
+ if (!is(v)) {
+ throw new Error(v + " error");
+ } else {
+ return true;
+ }
+ }
+ if (!this.isArray(is)) {
+ is = [is];
+ }
+ if (!this.deepContains(is, v)) {
+ throw new Error(v + " error");
+ }
+ },
+
+ warn: function (message) {
+ console.warn(message)
+ },
+
+ UUID: function () {
+ var f = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
+ var str = "";
+ for (var i = 0; i < 16; i++) {
+ var r = parseInt(f.length * Math.random(), 10);
+ str += f[r];
+ }
+ return str;
+ },
+
+ isWidget: function (widget) {
+ return widget instanceof BI.Widget || (BI.View && widget instanceof BI.View);
+ },
+
+ createWidgets: function (items, options) {
+ if (!BI.isArray(items)) {
+ throw new Error("cannot create Widgets")
+ }
+ return BI.map(BI.flatten(items), function (i, item) {
+ return BI.createWidget(item, BI.deepClone(options));
+ });
+ },
+
+ createItems: function (data, innerAttr, outerAttr) {
+ innerAttr = BI.isArray(innerAttr) ? innerAttr : BI.makeArray(BI.flatten(data).length, innerAttr);
+ outerAttr = BI.isArray(outerAttr) ? outerAttr : BI.makeArray(BI.flatten(data).length, outerAttr);
+ return BI.map(data, function (i, item) {
+ if (BI.isArray(item)) {
+ return BI.createItems(item, innerAttr, outerAttr);
+ }
+ if (item instanceof BI.Widget) {
+ return BI.extend({}, innerAttr.shift(), outerAttr.shift(), {
+ type: null,
+ el: item
+ });
+ }
+ if (innerAttr[0] instanceof BI.Widget) {
+ outerAttr.shift();
+ return BI.extend({}, item, {
+ el: innerAttr.shift()
+ })
+ }
+ if (item.el instanceof BI.Widget || (BI.View && item.el instanceof BI.View)) {
+ innerAttr.shift();
+ return BI.extend({}, outerAttr.shift(), {type: null}, item);
+ }
+ if (item.el) {
+ return BI.extend({}, outerAttr.shift(), item, {
+ el: BI.extend({}, innerAttr.shift(), item.el)
+ })
+ }
+ return BI.extend({}, outerAttr.shift(), {
+ el: BI.extend({}, innerAttr.shift(), item)
+ })
+ })
+ },
+
+ //用容器包装items
+ packageItems: function (items, layouts) {
+ for (var i = layouts.length - 1; i >= 0; i--) {
+ items = BI.map(items, function (k, it) {
+ return BI.extend({}, layouts[i], {
+ items: [
+ BI.extend({}, layouts[i].el, {
+ el: it
+ })
+ ]
+ })
+ })
+ }
+ return items;
+ },
+
+ formatEL: function (obj) {
+ if (obj && !obj.type && obj.el) {
+ return obj;
+ }
+ return {
+ el: obj
+ };
+ },
+
+ //剥开EL
+ stripEL: function (obj) {
+ return obj.type && obj || obj.el || obj;
+ },
+
+ trans2Element: function (widgets) {
+ return BI.map(widgets, function (i, wi) {
+ return wi.element;
+ });
+ }
+ });
+
+ //集合相关方法
+ _.each(["where", "findWhere", "contains", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) {
+ BI[name] = _apply(name)
+ });
+ _.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
+ "sortBy", "groupBy", "indexBy", "countBy", "partition"], function (name) {
+ BI[name] = _applyFunc(name)
+ });
+ _.extend(BI, {
+ clamp: function (value, minValue, maxValue) {
+ if (value < minValue) {
+ value = minValue;
+ }
+ if (value > maxValue) {
+ value = maxValue;
+ }
+ return value;
+ },
+ //数数
+ count: function (from, to, predicate) {
+ var t;
+ if (predicate) {
+ for (t = from; t < to; t++) {
+ predicate(t);
+ }
+ }
+ return to - from;
+ },
+
+ //倒数
+ inverse: function (from, to, predicate) {
+ return BI.count(to, from, predicate);
+ },
+
+ firstKey: function (obj) {
+ var res = undefined;
+ BI.any(obj, function (key, value) {
+ res = key;
+ return true;
+ });
+ return res;
+ },
+
+ lastKey: function (obj) {
+ var res = undefined;
+ BI.each(obj, function (key, value) {
+ res = key;
+ return true;
+ });
+ return res;
+ },
+
+ firstObject: function (obj) {
+ var res = undefined;
+ BI.any(obj, function (key, value) {
+ res = value;
+ return true;
+ });
+ return res;
+ },
+
+ lastObject: function (obj) {
+ var res = undefined;
+ BI.each(obj, function (key, value) {
+ res = value;
+ return true;
+ });
+ return res;
+ },
+
+ concat: function (obj1, obj2) {
+ if (BI.isKey(obj1)) {
+ return obj1 + "" + obj2;
+ }
+ if (BI.isArray(obj1)) {
+ return obj1.concat(obj2);
+ }
+ if (BI.isObject(obj1)) {
+ return _.extend({}, obj1, obj2);
+ }
+ },
+
+ backEach: function (obj, predicate, context) {
+ predicate = BI.iteratee(predicate, context);
+ for (var index = obj.length - 1; index >= 0; index--) {
+ predicate(index, obj[index], obj);
+ }
+ return false;
+ },
+
+ backAny: function (obj, predicate, context) {
+ predicate = BI.iteratee(predicate, context);
+ for (var index = obj.length - 1; index >= 0; index--) {
+ if (predicate(index, obj[index], obj)) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ backEvery: function (obj, predicate, context) {
+ predicate = BI.iteratee(predicate, context);
+ for (var index = obj.length - 1; index >= 0; index--) {
+ if (!predicate(index, obj[index], obj)) {
+ return false;
+ }
+ }
+ return true;
+ },
+
+ backFindKey: function (obj, predicate, context) {
+ predicate = BI.iteratee(predicate, context);
+ var keys = _.keys(obj), key;
+ for (var i = keys.length - 1; i >= 0; i--) {
+ key = keys[i];
+ if (predicate(obj[key], key, obj)) {
+ return key;
+ }
+ }
+ },
+
+ backFind: function (obj, predicate, context) {
+ var key;
+ if (BI.isArray(obj)) {
+ key = BI.findLastIndex(obj, predicate, context);
+ } else {
+ key = BI.backFindKey(obj, predicate, context);
+ }
+ if (key !== void 0 && key !== -1) {
+ return obj[key];
+ }
+ },
+
+ remove: function (obj, target, context) {
+ var isFunction = BI.isFunction(target);
+ target = isFunction || BI.isArray(target) ? target : [target];
+ var i;
+ if (BI.isArray(obj)) {
+ for (i = 0; i < obj.length; i++) {
+ if ((isFunction && target.apply(context, [i, obj[i]]) === true) || (!isFunction && target.contains(obj[i]))) {
+ obj.splice(i--, 1);
+ }
+ }
+ } else {
+ BI.each(obj, function (i, v) {
+ if ((isFunction && target.apply(context, [i, obj[i]]) === true) || (!isFunction && target.contains(obj[i]))) {
+ delete obj[i];
+ }
+ });
+ }
+ },
+
+ removeAt: function (obj, index) {
+ index = BI.isArray(index) ? index : [index];
+ var isArray = BI.isArray(obj), i;
+ for (i = 0; i < index.length; i++) {
+ if (isArray) {
+ obj[index[i]] = "$deleteIndex";
+ } else {
+ delete obj[index[i]];
+ }
+ }
+ if (isArray) {
+ BI.remove(obj, "$deleteIndex");
+ }
+ },
+
+ string2Array: function (str) {
+ return str.split('&-&');
+ },
+
+ array2String: function (array) {
+ return array.join("&-&");
+ },
+
+ abc2Int: function (str) {
+ var idx = 0, start = 'A', str = str.toUpperCase();
+ for (var i = 0, len = str.length; i < len; ++i) {
+ idx = str.charAt(i).charCodeAt(0) - start.charCodeAt(0) + 26 * idx + 1;
+ if (idx > (2147483646 - str.charAt(i).charCodeAt(0) + start.charCodeAt(0)) / 26) {
+ return 0;
+ }
+ }
+ return idx;
+ },
+
+ int2Abc: function (num) {
+ var DIGITS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
+ var idx = num, str = "";
+ if (num === 0) {
+ return "";
+ }
+ while (idx !== 0) {
+ var t = idx % 26;
+ if (t === 0) {
+ t = 26;
+ }
+ str = DIGITS[t - 1] + str;
+ idx = (idx - t) / 26;
+ }
+ return str;
+ }
+ });
+
+ //数组相关的方法
+ _.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
+ "difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range"], function (name) {
+ BI[name] = _apply(name)
+ });
+ _.each(["findIndex", "findLastIndex"], function (name) {
+ BI[name] = _applyFunc(name)
+ });
+ _.extend(BI, {
+ //构建一个长度为length的数组
+ makeArray: function (length, value) {
+ var res = [];
+ for (var i = 0; i < length; i++) {
+ if (BI.isNull(value)) {
+ res.push(i);
+ } else {
+ res.push(BI.deepClone(value));
+ }
+ }
+ return res;
+ },
+
+ makeObject: function (array, value) {
+ var map = {};
+ for (var i = 0; i < array.length; i++) {
+ if (BI.isNull(value)) {
+ map[array[i]] = array[i];
+ } else {
+ map[array[i]] = BI.deepClone(value);
+ }
+ }
+ return map;
+ },
+
+ makeArrayByArray: function (array, value) {
+ var res = [];
+ if (!array) {
+ return res;
+ }
+ for (var i = 0, len = array.length; i < len; i++) {
+ if (BI.isArray(array[i])) {
+ res.push(arguments.callee(array[i], value));
+ } else {
+ res.push(BI.deepClone(value));
+ }
+ }
+ return res;
+ },
+
+ uniq: function (array, isSorted, iteratee, context) {
+ if (array == null) {
+ return [];
+ }
+ if (!_.isBoolean(isSorted)) {
+ context = iteratee;
+ iteratee = isSorted;
+ isSorted = false;
+ }
+ iteratee && (iteratee = traverse(iteratee, context));
+ return _.uniq.call(_, array, isSorted, iteratee, context);
+ }
+ });
+
+ //对象相关方法
+ _.each(["keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn",
+ "defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty",
+ "isElement", "isNumber", "isString", "isArray", "isObject", "isArguments", "isFunction", "isFinite",
+ "isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined"], function (name) {
+ BI[name] = _apply(name)
+ });
+ _.each(["mapObject", "findKey", "pick", "omit", "tap"], function (name) {
+ BI[name] = _applyFunc(name)
+ });
+ _.extend(BI, {
+
+ inherit: function (sb, sp, overrides) {
+ if (typeof sp == 'object') {
+ overrides = sp;
+ sp = sb;
+ sb = function () {
+ sp.apply(this, arguments);
+ };
+ }
+ var F = function () {
+ }, spp = sp.prototype;
+ F.prototype = spp;
+ sb.prototype = new F();
+ sb.superclass = spp;
+ _.extend(sb.prototype, overrides, {
+ superclass: sp
+ });
+ return sb;
+ },
+
+ has: function (obj, keys) {
+ if (BI.isArray(keys)) {
+ if (keys.length === 0) {
+ return false;
+ }
+ return BI.every(keys, function (i, key) {
+ return _.has(obj, key);
+ });
+ }
+ return _.has.apply(_, arguments);
+ },
+
+ //数字和字符串可以作为key
+ isKey: function (key) {
+ return BI.isNumber(key) || (BI.isString(key) && key.length > 0);
+ },
+
+ //忽略大小写的等于
+ isCapitalEqual: function (a, b) {
+ a = BI.isNull(a) ? a : ("" + a).toLowerCase();
+ b = BI.isNull(b) ? b : ("" + b).toLowerCase();
+ return BI.isEqual(a, b);
+ },
+
+ isWidthOrHeight: function (w) {
+ if (typeof w == 'number') {
+ return w >= 0;
+ } else if (typeof w == 'string') {
+ return /^\d{1,3}%$/.exec(w) || w == 'auto' || /^\d+px$/.exec(w);
+ }
+ },
+
+ isNotNull: function (obj) {
+ return !BI.isNull(obj);
+ },
+
+ isNull: function (obj) {
+ return typeof obj === "undefined" || obj === null;
+ },
+
+ isPlainObject: function () {
+ return $.isPlainObject.apply($, arguments);
+ },
+
+ isEmptyArray: function (arr) {
+ return BI.isArray(arr) && BI.isEmpty(arr);
+ },
+
+ isNotEmptyArray: function (arr) {
+ return BI.isArray(arr) && !BI.isEmpty(arr);
+ },
+
+ isEmptyObject: function (obj) {
+ return BI.isEqual(obj, {});
+ },
+
+ isNotEmptyObject: function (obj) {
+ return BI.isPlainObject(obj) && !BI.isEmptyObject(obj);
+ },
+
+ isEmptyString: function (obj) {
+ return BI.isString(obj) && obj.length === 0;
+ },
+
+ isNotEmptyString: function (obj) {
+ return BI.isString(obj) && !BI.isEmptyString(obj);
+ },
+
+ isWindow: function () {
+ return $.isWindow.apply($, arguments);
+ }
+ });
+
+ //deep方法
+ _.extend(BI, {
+ /**
+ *完全克隆�?个js对象
+ * @param obj
+ * @returns {*}
+ */
+ deepClone: function (obj) {
+ if (obj === null || obj === undefined) {
+ return obj;
+ }
+
+ var type = Object.prototype.toString.call(obj);
+
+ // Date
+ if (type === '[object Date]') {
+ return new Date(obj.getTime());
+ }
+
+ var i, clone, key;
+
+ // Array
+ if (type === '[object Array]') {
+ i = obj.length;
+
+ clone = [];
+
+ while (i--) {
+ clone[i] = BI.deepClone(obj[i]);
+ }
+ }
+ // Object
+ else if (type === '[object Object]' && obj.constructor === Object) {
+ clone = {};
+
+ for (var i in obj) {
+ if (_.has(obj, i)) {
+ clone[i] = BI.deepClone(obj[i]);
+ }
+ }
+ }
+
+ return clone || obj;
+ },
+
+ isDeepMatch: function (object, attrs) {
+ var keys = BI.keys(attrs), length = keys.length;
+ if (object == null) {
+ return !length;
+ }
+ var obj = Object(object);
+ for (var i = 0; i < length; i++) {
+ var key = keys[i];
+ if (!BI.isEqual(attrs[key], obj[key]) || !(key in obj)) {
+ return false;
+ }
+ }
+ return true;
+ },
+
+ deepContains: function (obj, copy) {
+ if (BI.isObject(copy)) {
+ return BI.any(obj, function (i, v) {
+ if (BI.isEqual(v, copy)) {
+ return true;
+ }
+ })
+ }
+ return BI.contains(obj, copy);
+ },
+
+ deepIndexOf: function (obj, target) {
+ for (var i = 0; i < obj.length; i++) {
+ if (BI.isEqual(target, obj[i])) {
+ return i;
+ }
+ }
+ return -1;
+ },
+
+ deepRemove: function (obj, target) {
+ var done = false;
+ var i;
+ if (BI.isArray(obj)) {
+ for (i = 0; i < obj.length; i++) {
+ if (BI.isEqual(target, obj[i])) {
+ obj.splice(i--, 1);
+ done = true;
+ }
+ }
+ } else {
+ BI.each(obj, function (i, v) {
+ if (BI.isEqual(target, obj[i])) {
+ delete obj[i];
+ done = true;
+ }
+ });
+ }
+ return done;
+ },
+
+ deepWithout: function (obj, target) {
+ if (BI.isArray(obj)) {
+ var result = [];
+ for (var i = 0; i < obj.length; i++) {
+ if (!BI.isEqual(target, obj[i])) {
+ result.push(obj[i]);
+ }
+ }
+ return result;
+ } else {
+ var result = {};
+ BI.each(obj, function (i, v) {
+ if (!BI.isEqual(target, obj[i])) {
+ result[i] = v;
+ }
+ });
+ return result;
+ }
+ },
+
+ deepUnique: function (array) {
+ var result = [];
+ BI.each(array, function (i, item) {
+ if (!BI.deepContains(result, item)) {
+ result.push(item);
+ }
+ });
+ return result;
+ },
+
+ //比较两个对象得出不一样的key值
+ deepDiff: function (object, other) {
+ object || (object = {});
+ other || (other = {});
+ var result = [];
+ var used = [];
+ for (var b in object) {
+ if (this.has(object, b)) {
+ if (!this.isEqual(object[b], other[b])) {
+ result.push(b);
+ }
+ used.push(b);
+ }
+ }
+ for (var b in other) {
+ if (this.has(other, b) && !used.contains(b)) {
+ result.push(b);
+ }
+ }
+ return result;
+ }
+ });
+
+ //通用方法
+ _.each(["uniqueId", "result", "chain", "iteratee", "escape", "unescape"], function (name) {
+ BI[name] = function () {
+ return _[name].apply(_, arguments);
+ }
+ });
+
+ //事件相关方法
+ _.each(["bind", "once", "partial", "debounce", "throttle", "delay", "defer", "wrap"], function (name) {
+ BI[name] = function () {
+ return _[name].apply(_, arguments);
+ }
+ });
+
+ _.extend(BI, {
+ nextTick: (function () {
+ var callbacks = [];
+ var pending = false;
+ var timerFunc;
+
+ function nextTickHandler() {
+ pending = false;
+ var copies = callbacks.slice(0);
+ callbacks = [];
+ for (var i = 0; i < copies.length; i++) {
+ copies[i]();
+ }
+ }
+
+ if (typeof Promise !== 'undefined') {
+ var p = Promise.resolve();
+ timerFunc = function () {
+ p.then(nextTickHandler);
+ }
+ } else
+
+ /* istanbul ignore if */
+ if (typeof MutationObserver !== 'undefined') {
+ var counter = 1;
+ var observer = new MutationObserver(nextTickHandler);
+ var textNode = document.createTextNode(counter + "");
+ observer.observe(textNode, {
+ characterData: true
+ });
+ timerFunc = function () {
+ counter = (counter + 1) % 2;
+ textNode.data = counter + "";
+ }
+ } else {
+ timerFunc = function () {
+ setTimeout(nextTickHandler, 0)
+ }
+ }
+ return function queueNextTick(cb) {
+ var _resolve;
+ var args = [].slice.call(arguments, 1);
+ callbacks.push(function () {
+ if (cb) {
+ cb.apply(null, args);
+ }
+ if (_resolve) {
+ _resolve.apply(null, args);
+ }
+ });
+ if (!pending) {
+ pending = true;
+ timerFunc();
+ }
+ if (!cb && typeof Promise !== 'undefined') {
+ return new Promise(function (resolve) {
+ _resolve = resolve
+ })
+ }
+ }
+ })()
+ });
+
+ //数字相关方法
+ _.each(["random"], function (name) {
+ BI[name] = _apply(name)
+ });
+ _.extend(BI, {
+ getTime: function () {
+ if (window.performance && window.performance.now) {
+ return window.performance.now();
+ } else {
+ if (window.performance && window.performance.webkitNow) {
+ return window.performance.webkitNow();
+ } else {
+ if (Date.now) {
+ return Date.now();
+ } else {
+ return new Date().getTime();
+ }
+ }
+ }
+ },
+
+ parseInt: function (number) {
+ var radix = 10;
+ if (/^0x/g.test(number)) {
+ radix = 16;
+ }
+ try {
+ return parseInt(number, radix);
+ } catch (e) {
+ throw new Error(number + "parse int error");
+ return NaN;
+ }
+ },
+
+ parseSafeInt: function (value) {
+ var MAX_SAFE_INTEGER = 9007199254740991;
+ return value
+ ? this.clamp(this.parseInt(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
+ : (value === 0 ? value : 0);
+ },
+
+ parseFloat: function (number) {
+ try {
+ return parseFloat(number);
+ } catch (e) {
+ throw new Error(number + "parse float error");
+ return NaN;
+ }
+ },
+
+ isNaturalNumber: function (number) {
+ if (/^\d+$/.test(number)) {
+ return true;
+ }
+ return false;
+ },
+
+ isPositiveInteger: function (number) {
+ if (/^\+?[1-9][0-9]*$/.test(number)) {
+ return true;
+ }
+ return false;
+ },
+
+ isNegativeInteger: function (number) {
+ if (/^\-[1-9][0-9]*$/.test(number)) {
+ return true;
+ }
+ return false;
+ },
+
+ isInteger: function (number) {
+ if (/^\-?\d+$/.test(number)) {
+ return true;
+ }
+ return false;
+ },
+
+ isNumeric: function (number) {
+ return $.isNumeric(number);
+ },
+
+ isFloat: function (number) {
+ if (/^([+-]?)\\d*\\.\\d+$/.test(number)) {
+ return true;
+ }
+ return false;
+ },
+
+ isOdd: function (number) {
+ if (!BI.isInteger(number)) {
+ return false;
+ }
+ return number & 1 === 1;
+ },
+
+ isEven: function (number) {
+ if (!BI.isInteger(number)) {
+ return false;
+ }
+ return number & 1 === 0;
+ },
+
+ sum: function (array, iteratee, context) {
+ var sum = 0;
+ BI.each(array, function (i, item) {
+ if (iteratee) {
+ sum += Number(iteratee.apply(context, [i, item]));
+ } else {
+ sum += Number(item);
+ }
+ });
+ return sum;
+ },
+
+ average: function (array, iteratee, context) {
+ var sum = BI.sum(array, iteratee, context);
+ return sum / array.length;
+ }
+ });
+
+ //字符串相关方法
+ _.extend(BI, {
+ trim: function () {
+ return $.trim.apply($, arguments);
+ },
+
+ toUpperCase: function (string) {
+ return (string + "").toLocaleUpperCase();
+ },
+
+ toLowerCase: function (string) {
+ return (string + "").toLocaleLowerCase();
+ },
+
+ isEndWithBlank: function (string) {
+ return /(\s|\u00A0)$/.test(string);
+ },
+
+ isLiteral: function (exp) {
+ var literalValueRE = /^\s?(true|false|-?[\d\.]+|'[^']*'|"[^"]*")\s?$/
+ return literalValueRE.test(exp)
+ },
+
+ stripQuotes: function (str) {
+ var a = str.charCodeAt(0)
+ var b = str.charCodeAt(str.length - 1)
+ return a === b && (a === 0x22 || a === 0x27)
+ ? str.slice(1, -1)
+ : str
+ },
+
+ //background-color => backgroundColor
+ camelize: function (str) {
+ return str.replace(/-(.)/g, function (_, character) {
+ return character.toUpperCase();
+ });
+ },
+
+ //backgroundColor => background-color
+ hyphenate: function (str) {
+ return str.replace(/([A-Z])/g, '-$1').toLowerCase();
+ },
+
+ isNotEmptyString: function (str) {
+ return BI.isString(str) && !BI.isEmpty(str);
+ },
+
+ isEmptyString: function (str) {
+ return BI.isString(str) && BI.isEmpty(str);
+ },
+
+ /**
+ * 对字符串进行加密 {@link #decrypt}
+ * @static
+ * @param str 原始字符�?
+ * @param keyt 密钥
+ * @returns {String} 加密后的字符�?
+ */
+ encrypt: function (str, keyt) {
+ if (str == "") {
+ return "";
+ }
+ str = escape(str);
+ if (!keyt || keyt == "") {
+ keyt = "655";
+ }
+ keyt = escape(keyt);
+ if (keyt == null || keyt.length <= 0) {
+ alert("Please enter a password with which to encrypt the message.");
+ return null;
+ }
+ var prand = "";
+ for (var i = 0; i < keyt.length; i++) {
+ prand += keyt.charCodeAt(i).toString();
+ }
+ var sPos = Math.floor(prand.length / 5);
+ var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos * 2) + prand.charAt(sPos * 3) + prand.charAt(sPos * 4) + prand.charAt(sPos * 5));
+
+ var incr = Math.ceil(keyt.length / 2);
+ var modu = Math.pow(2, 31) - 1;
+ if (mult < 2) {
+ alert("Algorithm cannot find a suitable hash. Please choose a different password. \nPossible considerations are to choose a more complex or longer password.");
+ return null;
+ }
+// var salt = Math.round(Math.random() * 1000000000) % 100000000;
+ var salt = 101;
+ prand += salt;
+ while (prand.length > 10) {
+ prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length), 10)).toString();
+ }
+ prand = (mult * prand + incr) % modu;
+ var enc_chr = "";
+ var enc_str = "";
+ for (var i = 0; i < str.length; i++) {
+ enc_chr = parseInt(str.charCodeAt(i) ^ Math.floor((prand / modu) * 255));
+ if (enc_chr < 16) {
+ enc_str += "0" + enc_chr.toString(16);
+ } else {
+ enc_str += enc_chr.toString(16);
+ }
+ prand = (mult * prand + incr) % modu;
+ }
+ salt = salt.toString(16);
+ while (salt.length < 8) {
+ salt = "0" + salt;
+ }
+ enc_str += salt;
+ return enc_str;
+ },
+
+ /**
+ * 对加密后的字符串解密 {@link #encrypt}
+ * @static
+ * @param str 加密过的字符�?
+ * @param keyt 密钥
+ * @returns {String} 解密后的字符�?
+ */
+ decrypt: function (str, keyt) {
+ if (str == "") {
+ return "";
+ }
+ if (!keyt || keyt == "") {
+ keyt = "655";
+ }
+ keyt = escape(keyt);
+ if (str == null || str.length < 8) {
+ return;
+ }
+ if (keyt == null || keyt.length <= 0) {
+ return;
+ }
+ var prand = "";
+ for (var i = 0; i < keyt.length; i++) {
+ prand += keyt.charCodeAt(i).toString();
+ }
+ var sPos = Math.floor(prand.length / 5);
+ var tempmult = prand.charAt(sPos) + prand.charAt(sPos * 2) + prand.charAt(sPos * 3) + prand.charAt(sPos * 4);
+ if (sPos * 5 < prand.length) {
+ tempmult += prand.charAt(sPos * 5);
+ }
+ var mult = parseInt(tempmult);
+ var incr = Math.round(keyt.length / 2);
+ var modu = Math.pow(2, 31) - 1;
+ var salt = parseInt(str.substring(str.length - 8, str.length), 16);
+ str = str.substring(0, str.length - 8);
+ prand += salt;
+ while (prand.length > 10) {
+ prand = (parseInt(prand.substring(0, 10), 10) + parseInt(prand.substring(10, prand.length), 10)).toString();
+ }
+ prand = (mult * prand + incr) % modu;
+ var enc_chr = "";
+ var enc_str = "";
+ for (var i = 0; i < str.length; i += 2) {
+ enc_chr = parseInt(parseInt(str.substring(i, i + 2), 16) ^ Math.floor((prand / modu) * 255));
+ enc_str += String.fromCharCode(enc_chr);
+ prand = (mult * prand + incr) % modu;
+ }
+ return unescape(enc_str);
+ }
+ });
+
+ //浏览器相关方法
+ _.extend(BI, {
+ isIE: function () {
+ return /(msie|trident)/i.test(navigator.userAgent.toLowerCase());
+ },
+
+ isIE9Below: function () {
+ if (!BI.isIE()) {
+ return false;
+ }
+ var version = 0;
+ var agent = navigator.userAgent.toLowerCase();
+ var v1 = agent.match(/(?:msie\s([\w.]+))/);
+ var v2 = agent.match(/(?:trident.*rv:([\w.]+))/);
+ if (v1 && v2 && v1[1] && v2[1]) {
+ version = Math.max(v1[1] * 1, v2[1] * 1);
+ } else if (v1 && v1[1]) {
+ version = v1[1] * 1;
+ } else if (v2 && v2[1]) {
+ version = v2[1] * 1;
+ } else {
+ version = 0;
+ }
+ return version < 9;
+ },
+
+ isEdge: function () {
+ return /edge/i.test(navigator.userAgent.toLowerCase());
+ },
+
+ isChrome: function () {
+ return /chrome/i.test(navigator.userAgent.toLowerCase());
+ },
+
+ isFireFox: function () {
+ return /firefox/i.test(navigator.userAgent.toLowerCase());
+ },
+
+ isOpera: function () {
+ return /opera/i.test(navigator.userAgent.toLowerCase());
+ },
+
+ isSafari: function () {
+ return /safari/i.test(navigator.userAgent.toLowerCase());
+ },
+
+ isKhtml: function () {
+ return /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
+ },
+
+ isMac: function () {
+ return /macintosh|mac os x/i.test(navigator.userAgent);
+ },
+
+ isWindows: function () {
+ return /windows|win32/i.test(navigator.userAgent);
+ },
+
+ isSupportCss3: function (style) {
+ var prefix = ['webkit', 'Moz', 'ms', 'o'],
+ i, len,
+ humpString = [],
+ htmlStyle = document.documentElement.style,
+ _toHumb = function (string) {
+ return string.replace(/-(\w)/g, function ($0, $1) {
+ return $1.toUpperCase();
+ });
+ };
+
+ for (i in prefix) {
+ humpString.push(_toHumb(prefix[i] + '-' + style));
+ }
+ humpString.push(_toHumb(style));
+
+ for (i = 0, len = humpString.length; i < len; i++) {
+ if (humpString[i] in htmlStyle) {
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+ //BI请求
+ _.extend(BI, {
+
+ ajax: function (option) {
+ option || (option = {});
+ var async = option.async;
+ option.data = BI.cjkEncodeDO(option.data || {});
+
+ $.ajax({
+ url: option.url,
+ type: "POST",
+ data: option.data,
+ async: async,
+ error: option.error,
+ complete: function (res, status) {
+ if (BI.isFunction(option.complete)) {
+ option.complete(BI.jsonDecode(res.responseText), status);
+ }
+ }
+ });
+ }
+ });
+})(jQuery);/**
+ * 客户端观察者,主要处理事件的添加、删除、执行等
+ * @class BI.OB
+ * @abstract
+ */
+BI.OB = function (config) {
+ var props = this.props;
+ if (BI.isFunction(this.props)) {
+ props = this.props(config);
+ }
+ this.options = $.extend(this._defaultConfig(config), props, config);
+ this._init();
+ this._initRef();
+};
+$.extend(BI.OB.prototype, {
+ props: {},
+ init: null,
+ destroyed: null,
+
+ _defaultConfig: function (config) {
+ return {};
+ },
+
+ _init: function () {
+ this._initListeners();
+ this.init && this.init();
+ },
+
+ _initListeners: function () {
+ var self = this;
+ if (this.options.listeners != null) {
+ $.each(this.options.listeners, function (i, lis) {
+ (lis.target ? lis.target : self)[lis.once ? 'once' : 'on']
+ (lis.eventName, _.bind(lis.action, self))
+ });
+ delete this.options.listeners;
+ }
+ },
+
+ //获得一个当前对象的引用
+ _initRef: function () {
+ if (this.options.ref) {
+ this.options.ref.call(this, this);
+ }
+ },
+
+ _getEvents: function () {
+ if (!$.isArray(this.events)) {
+ this.events = []
+ }
+ return this.events;
+ },
+
+ /**
+ * 给观察者绑定一个事件
+ * @param {String} eventName 事件的名字
+ * @param {Function} fn 事件对应的执行函数
+ */
+ on: function (eventName, fn) {
+ eventName = eventName.toLowerCase();
+ var fns = this._getEvents()[eventName];
+ if (!$.isArray(fns)) {
+ fns = [];
+ this._getEvents()[eventName] = fns;
+ }
+ fns.push(fn);
+ },
+
+ /**
+ * 给观察者绑定一个只执行一次的事件
+ * @param {String} eventName 事件的名字
+ * @param {Function} fn 事件对应的执行函数
+ */
+ once: function (eventName, fn) {
+ var proxy = function () {
+ fn.apply(this, arguments);
+ this.un(eventName, proxy);
+ };
+ this.on(eventName, proxy);
+ },
+ /**
+ * 解除观察者绑定的指定事件
+ * @param {String} eventName 要解除绑定事件的名字
+ * @param {Function} fn 事件对应的执行函数,该参数是可选的,没有该参数时,将解除绑定所有同名字的事件
+ */
+ un: function (eventName, fn) {
+ eventName = eventName.toLowerCase();
+
+ /*alex:如果fn是null,就是把eventName上面所有方法都un掉*/
+ if (fn == null) {
+ delete this._getEvents()[eventName];
+ } else {
+ var fns = this._getEvents()[eventName];
+ if ($.isArray(fns)) {
+ var newFns = [];
+ $.each(fns, function (idx, ifn) {
+ if (ifn != fn) {
+ newFns.push(ifn);
+ }
+ })
+ this._getEvents()[eventName] = newFns;
+ }
+ }
+ },
+ /**
+ * 清除观察者的所有事件绑定
+ */
+ purgeListeners: function () {
+ /*alex:清空events*/
+ this.events = [];
+ },
+ /**
+ * 触发绑定过的事件
+ *
+ * @param {String} eventName 要触发的事件的名字
+ * @returns {Boolean} 如果事件函数返回false,则返回false并中断其他同名事件的执行,否则执行所有的同名事件并返回true
+ */
+ fireEvent: function () {
+ var eventName = arguments[0].toLowerCase();
+ var fns = this._getEvents()[eventName];
+ if (BI.isArray(fns)) {
+ if (BI.isArguments(arguments[1])) {
+ for (var i = 0; i < fns.length; i++) {
+ if (fns[i].apply(this, arguments[1]) === false) {
+ return false;
+ }
+ }
+ } else {
+ var args = Array.prototype.slice.call(arguments, 1);
+ for (var i = 0; i < fns.length; i++) {
+ if (fns[i].apply(this, args) === false) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ },
+
+ destroy: function () {
+ this.destroyed && this.destroyed();
+ this.purgeListeners();
+ }
+});/**
+ * Widget超类
+ * @class BI.Widget
+ * @extends BI.OB
+ *
+ * @cfg {JSON} options 配置属性
+ */
+BI.Widget = BI.inherit(BI.OB, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), {
+ root: false,
+ tagName: "div",
+ attributes: null,
+ data: null,
+
+ tag: null,
+ disabled: false,
+ invisible: false,
+ invalid: false,
+ baseCls: "",
+ extraCls: "",
+ cls: ""
+ })
+ },
+
+ //生命周期函数
+ beforeCreate: null,
+
+ created: null,
+
+ render: null,
+
+ beforeMounted: null,
+
+ mounted: null,
+
+ update: function () {
+ },
+
+ beforeDestroyed: null,
+
+ destroyed: null,
+
+ _init: function () {
+ BI.Widget.superclass._init.apply(this, arguments);
+ this.beforeCreate && this.beforeCreate();
+ this._initRoot();
+ this._initElementWidth();
+ this._initElementHeight();
+ this._initVisual();
+ this._initState();
+ this._initElement();
+ this._initEffects();
+ this.created && this.created();
+ },
+
+ /**
+ * 初始化根节点
+ * @private
+ */
+ _initRoot: function () {
+ var o = this.options;
+ this.widgetName = o.widgetName || BI.uniqueId("widget");
+ this._isRoot = o.root;
+ if (BI.isWidget(o.element)) {
+ if (o.element instanceof BI.Widget) {
+ this._parent = o.element;
+ this._parent.addWidget(this.widgetName, this);
+ } else {
+ this._isRoot = true;
+ }
+ this.element = this.options.element.element;
+ } else if (o.element) {
+ // if (o.root !== true) {
+ // throw new Error("root is a required property");
+ // }
+ this.element = $(o.element);
+ this._isRoot = true;
+ } else {
+ this.element = $(document.createElement(o.tagName));
+ }
+ if (o.baseCls || o.extraCls || o.cls) {
+ this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || ""));
+ }
+ if (o.attributes) {
+ this.element.attr(o.attributes);
+ }
+ if (o.data) {
+ this.element.data(o.data);
+ }
+ this._children = {};
+ },
+
+ _initElementWidth: function () {
+ var o = this.options;
+ if (BI.isWidthOrHeight(o.width)) {
+ this.element.css("width", o.width);
+ }
+ },
+
+ _initElementHeight: function () {
+ var o = this.options;
+ if (BI.isWidthOrHeight(o.height)) {
+ this.element.css("height", o.height);
+ }
+ },
+
+ _initVisual: function () {
+ var o = this.options;
+ if (o.invisible) {
+ //用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
+ this.element.css("display", "none");
+ }
+ },
+
+ _initEffects: function () {
+ var o = this.options;
+ if (o.disabled || o.invalid) {
+ if (this.options.disabled) {
+ this.setEnable(false);
+ }
+ if (this.options.invalid) {
+ this.setValid(false);
+ }
+ }
+ },
+
+ _initState: function () {
+ this._isMounted = false;
+ },
+
+ _initElement: function () {
+ var self = this;
+ var els = this.render && this.render();
+ if (BI.isPlainObject(els)) {
+ els = [els];
+ }
+ if (BI.isArray(els)) {
+ BI.each(els, function (i, el) {
+ BI.createWidget(el, {
+ element: self
+ })
+ })
+ }
+ // if (this._isRoot === true || !(this instanceof BI.Layout)) {
+ this._mount();
+ // }
+ },
+
+ _setParent: function (parent) {
+ this._parent = parent;
+ },
+
+ _mount: function () {
+ var self = this;
+ var isMounted = this._isMounted;
+ if (isMounted || !this.isVisible()) {
+ return;
+ }
+ if (this._isRoot === true) {
+ isMounted = true;
+ } else if (this._parent && this._parent._isMounted === true) {
+ isMounted = true;
+ }
+ if (!isMounted) {
+ return;
+ }
+ this.beforeMounted && this.beforeMounted();
+ this._isMounted = true;
+ this._mountChildren && this._mountChildren();
+ BI.each(this._children, function (i, widget) {
+ !self.isEnabled() && widget._setEnable(false);
+ !self.isValid() && widget._setValid(false);
+ widget._mount && widget._mount();
+ });
+ this.mounted && this.mounted();
+ },
+
+ _mountChildren: null,
+
+ isMounted: function () {
+ return this._isMounted;
+ },
+
+ setWidth: function (w) {
+ this.options.width = w;
+ this._initElementWidth();
+ },
+
+ setHeight: function (h) {
+ this.options.height = h;
+ this._initElementHeight();
+ },
+
+ _setEnable: function (enable) {
+ if (enable === true) {
+ this.options.disabled = false;
+ } else if (enable === false) {
+ this.options.disabled = true;
+ }
+ //递归将所有子组件使能
+ BI.each(this._children, function (i, child) {
+ !child._manualSetEnable && child._setEnable && child._setEnable(enable);
+ });
+ },
+
+ _setValid: function (valid) {
+ if (valid === true) {
+ this.options.invalid = false;
+ } else if (valid === false) {
+ this.options.invalid = true;
+ }
+ //递归将所有子组件使有效
+ BI.each(this._children, function (i, child) {
+ !child._manualSetValid && child._setValid && child._setValid(valid);
+ });
+ },
+
+ _setVisible: function (visible) {
+ if (visible === true) {
+ this.options.invisible = false;
+ } else if (visible === false) {
+ this.options.invisible = true;
+ }
+ },
+
+ setEnable: function (enable) {
+ this._manualSetEnable = true;
+ this._setEnable(enable);
+ if (enable === true) {
+ this.element.removeClass("base-disabled disabled");
+ } else if (enable === false) {
+ this.element.addClass("base-disabled disabled");
+ }
+ },
+
+ setVisible: function (visible) {
+ this._setVisible(visible);
+ if (visible === true) {
+ //用this.element.show()会把display属性改成block
+ this.element.css("display", "");
+ this._mount();
+ } else if (visible === false) {
+ this.element.css("display", "none");
+ }
+ this.fireEvent(BI.Events.VIEW, visible);
+ },
+
+ setValid: function (valid) {
+ this._manualSetValid = true;
+ this._setValid(valid);
+ if (valid === true) {
+ this.element.removeClass("base-invalid invalid");
+ } else if (valid === false) {
+ this.element.addClass("base-invalid invalid");
+ }
+ },
+
+ doBehavior: function () {
+ var args = arguments;
+ //递归将所有子组件使有效
+ BI.each(this._children, function (i, child) {
+ child.doBehavior && child.doBehavior.apply(child, args);
+ });
+ },
+
+ getWidth: function () {
+ return this.options.width;
+ },
+
+ getHeight: function () {
+ return this.options.height;
+ },
+
+ isValid: function () {
+ return !this.options.invalid;
+ },
+
+ addWidget: function (name, widget) {
+ var self = this;
+ if (name instanceof BI.Widget) {
+ widget = name;
+ name = widget.getName();
+ }
+ if (BI.isKey(name)) {
+ name = name + "";
+ }
+ name = name || widget.getName() || BI.uniqueId("widget");
+ if (this._children[name]) {
+ throw new Error("name has already been existed");
+ }
+ widget._setParent && widget._setParent(this);
+ widget.on(BI.Events.DESTROY, function () {
+ BI.remove(self._children, this);
+ });
+ return (this._children[name] = widget);
+ },
+
+ getWidgetByName: function (name) {
+ if (!BI.isKey(name) || name === this.getName()) {
+ return this;
+ }
+ name = name + "";
+ var widget = void 0, other = {};
+ BI.any(this._children, function (i, wi) {
+ if (i === name) {
+ widget = wi;
+ return true;
+ }
+ other[i] = wi;
+ });
+ if (!widget) {
+ BI.any(other, function (i, wi) {
+ return (widget = wi.getWidgetByName(i));
+ });
+ }
+ return widget;
+ },
+
+ removeWidget: function (nameOrWidget) {
+ var self = this;
+ if (BI.isWidget(nameOrWidget)) {
+ BI.remove(this._children, nameOrWidget);
+ } else {
+ delete this._children[nameOrWidget];
+ }
+ },
+
+ hasWidget: function (name) {
+ return this._children[name] != null;
+ },
+
+ getName: function () {
+ return this.widgetName;
+ },
+
+ setTag: function (tag) {
+ this.options.tag = tag;
+ },
+
+ getTag: function () {
+ return this.options.tag;
+ },
+
+ attr: function (key, value) {
+ if (BI.isNotNull(value)) {
+ return this.options[key] = value;
+ }
+ return this.options[key];
+ },
+
+ getText: function () {
+
+ },
+
+ setText: function (text) {
+
+ },
+
+ getValue: function () {
+
+ },
+
+ setValue: function (value) {
+
+ },
+
+ isEnabled: function () {
+ return !this.options.disabled;
+ },
+
+ isVisible: function () {
+ return !this.options.invisible;
+ },
+
+ disable: function () {
+ this.setEnable(false);
+ },
+
+ enable: function () {
+ this.setEnable(true);
+ },
+
+ valid: function () {
+ this.setValid(true);
+ },
+
+ invalid: function () {
+ this.setValid(false);
+ },
+
+ invisible: function () {
+ this.setVisible(false);
+ },
+
+ visible: function () {
+ this.setVisible(true);
+ },
+
+ __d: function () {
+ this.beforeDestroyed && this.beforeDestroyed();
+ BI.each(this._children, function (i, widget) {
+ widget._unMount && widget._unMount();
+ });
+ this._children = {};
+ this._parent = null;
+ this._isMounted = false;
+ this.destroyed && this.destroyed();
+ },
+
+ _unMount: function () {
+ this.__d();
+ this.fireEvent(BI.Events.UNMOUNT);
+ this.purgeListeners();
+ },
+
+ isolate: function () {
+ if (this._parent) {
+ this._parent.removeWidget(this);
+ }
+ BI.DOM.hang([this]);
+ },
+
+ empty: function () {
+ BI.each(this._children, function (i, widget) {
+ widget._unMount && widget._unMount();
+ });
+ this._children = {};
+ this.element.empty();
+ },
+
+ _destroy: function () {
+ this.__d();
+ this.element.destroy();
+ this.purgeListeners();
+ },
+
+ destroy: function () {
+ this.__d();
+ this.element.destroy();
+ this.fireEvent(BI.Events.DESTROY);
+ this.purgeListeners();
+ }
+});BI.Model = BI.inherit(BI.M, {
+ props: {},
+ init: null,
+ destroyed: null,
+
+ _defaultConfig: function () {
+ return BI.extend({
+ "default": "just a default",
+ "current": void 0
+ }, this.props)
+ },
+
+ _static: function () {
+ return {};
+ },
+
+ _init: function () {
+ BI.Model.superclass._init.apply(this, arguments);
+ this.on("change:current", function (obj, val) {
+ BI.isNotNull(val) && this.refresh(val);
+ }).on("change", function (changed, prev, context, options) {
+ if (this._start === true || BI.has(changed, "current")) {
+ return;
+ }
+ this.actionStart();
+ if (!this.local()) {
+ !BI.has(this._tmp, BI.keys(changed)) && this.parent && this.parent._change(this);
+ this._changing_ = true;
+ this.change(changed, prev, context, options);
+ this._changing_ = false;
+ }
+ });
+
+ this._tmp = {};//过渡属性
+
+ this._hass = {};
+ this._gets = [];//记录交互行为
+ this._start = false;
+ this._changing_ = false;
+
+ this._read = BI.debounce(BI.bind(this.fetch, this), 30);
+ this._save = BI.debounce(BI.bind(this.save, this), 30);
+ this._F = [];
+ this.init && this.init();
+ },
+
+ toJSON: function () {
+ var json = BI.Model.superclass.toJSON.apply(this, arguments);
+ delete json["baseCls"];
+ delete json["current"];
+ delete json["default"];
+ delete json["parent"];
+ delete json["rootURL"];
+ delete json["id"];
+ delete json["tag"];
+ BI.each(this._gets, function (i, action) {
+ delete json[action];
+ });
+ return json;
+ },
+
+ copy: function () {
+ if (this._start === true || this._changing_ === true) {
+ this._F.push({f: this.copy, arg: arguments});
+ return;
+ }
+ this.trigger("copy");
+ },
+ //子节点的一个类似副本
+ similar: function (value, key1, key2, key3) {
+ return value;
+ },
+
+ _map: function (child) {
+ var self = this;
+ var map = {}, current = {};
+ var mapping = function (key, ch) {
+ key = key + "";
+ if (key === "") {
+ return;
+ }
+ var keys = key.split('.');
+ if (!map[keys[0]]) {
+ map[keys[0]] = self.get(keys[0]);
+ }
+ var parent = map, last = void 0;
+ BI.each(keys, function (i, k) {
+ last && (parent = parent[last] || (parent[last] = {}));
+ last = k;
+ });
+ parent[last] = ch.toJSON();
+ };
+ BI.each(this._childs, function (key, chs) {
+ if (!BI.isArray(chs)) {
+ chs = [chs];
+ }
+ BI.each(chs, function (i, ch) {
+ if (ch === child) {
+ current[key] = child;
+ return;
+ }
+ //mapping(key, ch);
+ })
+ });
+ BI.each(current, function (key, ch) {
+ mapping(key, ch);
+ });
+ var tmp = {};
+ BI.each(this._tmp, function (k) {
+ if (map[k]) {
+ tmp[k] = map[k];
+ delete map[k];
+ }
+ });
+ this.tmp(tmp);
+ return map;
+ },
+
+ _change: function (child) {
+ this.set(this._map(child));
+ return this;
+ },
+
+ splice: function (old, key1, key2, key3) {
+
+ },
+
+ duplicate: function (copy, key1, key2, key3) {
+
+ },
+
+ change: function (changed, prev) {
+
+ },
+
+ actionStart: function () {
+ this._start = true;
+ return this;
+ },
+
+ actionEnd: function () {
+ var self = this;
+ this._start = false;
+ var _gets = this._gets.slice(0), _F = this._F.slice(0);
+ this._gets = [];
+ this._hass = {};
+ this._F = [];
+ BI.each(_gets, function (i, action) {
+ self.unset(action, {silent: true});
+ });
+ BI.each(_F, function (i, fn) {
+ fn.f.apply(self, fn.arg);
+ });
+ return this;
+ },
+
+ addChild: function (name, child) {
+ name = name + "";
+ var self = this;
+ this._childs || (this._childs = {});
+ if (this._childs[name]) {
+ if (BI.isArray(this._childs[name])) {
+ this._childs[name].push(child);
+ } else {
+ this._childs[name] = [this._childs[name]].concat(child)
+ }
+ } else {
+ this._childs[name] = child;
+ }
+ child && child.on("destroy", function () {
+ var keys = name.split('.');
+ var g = self.get(keys[0]), p, c;
+ var sset = !!self._tmp[keys[0]] ? "tmp" : "set", unset = "un" + sset;
+
+ BI.each(keys, function (i, k) {
+ if (i === 0) {
+ c = g;
+ return;
+ }
+ p = c;
+ c = c[k];
+ });
+ self.removeChild(name, child);
+ var newKeys = BI.clone(keys);
+ keys.length > 1 ? newKeys.unshift(BI.deepClone(p[keys[keys.length - 1]])) : newKeys.unshift(BI.deepClone(g));
+ keys.length > 1 ? (delete p[keys[keys.length - 1]], self[sset](keys[0], g, {silent: true})) : self[unset](name, {silent: true});
+ !BI.has(self._tmp, keys[0]) && self.parent && self.parent._change(self);
+ self.splice.apply(self, newKeys);
+ self.trigger("splice", newKeys);
+ BI.remove(self._childs, child);
+ }).on("copy", function () {
+ var keys = name.split('.');
+ var g = self.get(keys[0]), p, c;
+ var sset = !!self._tmp[keys[0]] ? "tmp" : "set";
+ BI.each(keys, function (i, k) {
+ if (i === 0) {
+ c = g;
+ return;
+ }
+ p = c;
+ c = c[k];
+ });
+ var copy = BI.UUID(), newKeys = BI.clone(keys);
+ keys.length > 1 ? newKeys.unshift(BI.deepClone(p[keys[keys.length - 1]])) : newKeys.unshift(BI.deepClone(g));
+ var backup = self.similar.apply(self, newKeys);
+ keys.length > 1 ? (p[copy] = backup, self[sset](keys[0], g, {silent: true})) : self[sset](copy, backup, {silent: true});
+ keys.unshift(copy);
+ !BI.has(self._tmp, keys[0]) && self.parent && self.parent._change(self);
+ self.duplicate.apply(self, keys);
+ self.trigger("duplicate", keys);
+ });
+ },
+
+ removeChild: function (name, child) {
+ if (BI.isArray(this._childs[name])) {
+ BI.remove(this._childs[name], child);
+ if (BI.isEmpty(this._childs[name])) {
+ delete this._childs[name];
+ }
+ return;
+ }
+ delete this._childs[name];
+ },
+
+ has: function (attr, istemp) {
+ if (istemp === true) {
+ return _.has(this.tmp, attr);
+ }
+ if (this._start === true && this._changing_ === false) {
+ this._hass[attr] = true;
+ }
+ return BI.Model.superclass.has.apply(this, arguments);
+ },
+
+ cat: function (attr) {
+ if (_.has(this._tmp, attr)) {
+ return this._tmp[attr];
+ }
+ if (this._start === true && this._hass[attr]) {
+ delete this._hass[attr];
+ switch (attr) {
+ case "default":
+ break;
+ case "current":
+ break;
+ default :
+ this._gets.push(attr);
+ break;
+ }
+ }
+ if (_.has(this.attributes, attr)) {
+ return this.attributes[attr];
+ }
+ var sta = _.result(this, "_static");
+ return BI.isFunction(sta[attr]) ? sta[attr].apply(this, BI.values(arguments).slice(1)) : sta[attr];
+ },
+
+ get: function () {
+ return BI.deepClone(this.cat.apply(this, arguments));
+ },
+
+ set: function (key, val, options) {
+ if (this._start === true || this._changing_ === true) {
+ this._F.push({f: this.set, arg: arguments});
+ return this;
+ }
+ return BI.Model.superclass.set.apply(this, arguments);
+ },
+
+ unset: function (attr, options) {
+ var self = this;
+ BI.each(this._childs, function (key, model) {
+ key = key + "";
+ var keys = key.split('.');
+ if (_.isEqual(attr, keys[0])) {
+ delete self._childs[attr];
+ if (!BI.isArray(model)) {
+ model = [model];
+ }
+ BI.each(model, function (i, m) {
+ m.trigger("unset");
+ });
+ }
+ });
+ return BI.Model.superclass.unset.apply(this, arguments);
+ },
+
+ tmp: function (key, val, options) {
+ if (this._start === true || this._changing_ === true) {
+ this._F.push({f: this.tmp, arg: arguments});
+ return this;
+ }
+ var attr, attrs, unset, changes, silent, changing, changed, prev, current;
+ if (key == null) return this;
+ if (typeof key === 'object') {
+ attrs = key;
+ options = val;
+ } else {
+ (attrs = {})[key] = val;
+ }
+ options || (options = {});
+
+ unset = options.unset;
+ silent = options.silent;
+ changes = [];
+ changing = this._changingTmp;
+ this._changingTmp = true;
+
+ if (!changing) {
+ this._previousTmp = _.clone(this._tmp);
+ this.changedTmp = {};
+ }
+ if (!this._previousTmp) {
+ this._previousTmp = _.clone(this._tmp);
+ }
+ current = this._tmp, prev = this._previousTmp;
+
+ for (attr in attrs) {
+ val = attrs[attr];
+ if (!_.isEqual(current[attr], val)) changes.push(attr);
+ if (!_.isEqual(prev[attr], val)) {
+ this.changedTmp[attr] = val;
+ } else {
+ delete this.changedTmp[attr];
+ }
+ unset ? delete current[attr] : current[attr] = val;
+ }
+
+ if (!silent) {
+ if (changes.length) this._pendingTmp = options;
+ for (var i = 0, length = changes.length; i < length; i++) {
+ this.trigger('change:' + changes[i], this, current[changes[i]], options);
+ }
+ }
+
+ if (changing) return this;
+ changed = BI.clone(this.changedTmp);
+ if (!silent) {
+ while (this._pendingTmp) {
+ options = this._pendingTmp;
+ this._pendingTmp = false;
+ this.trigger('change', changed, prev, this, options);
+ }
+ }
+ this._pendingTmp = false;
+ this._changingTmp = false;
+ if (!silent && changes.length) this.trigger("changed", changed, prev, this, options);
+ return this;
+ },
+
+ untmp: function (attr, options) {
+ var self = this;
+ BI.each(this._childs, function (key, model) {
+ key = key + "";
+ var keys = key.split('.');
+ if (_.isEqual(attr, keys[0])) {
+ delete self._childs[attr];
+ if (!BI.isArray(model)) {
+ model = [model];
+ }
+ BI.each(model, function (i, m) {
+ m.trigger("unset");
+ });
+ }
+ });
+ return this.tmp(attr, void 0, _.extend({}, options, {unset: true}));
+ },
+
+ cancel: function (options) {
+ var self = this;
+ var tmp = BI.clone(this._tmp);
+ this._tmp = {};
+ BI.each(tmp, function (k) {
+ self.untmp(k, options);
+ });
+ },
+
+ submit: function () {
+ var tmp = BI.clone(this._tmp);
+ this._tmp = {};
+ this.set(tmp);
+ return this;
+ },
+
+ urlRoot: function () {
+ return BI.servletURL;
+ },
+
+ parse: function (data) {
+ return data;
+ },
+
+ setEditing: function (edit) {
+ this._editing = edit;
+ },
+
+ getEditing: function () {
+ if (this._start !== true) {
+ throw new Error("getEditing函数只允许在local中调用");
+ }
+ return this._editing;
+ },
+
+ local: function () {
+
+ },
+
+ load: function (data) {
+
+ },
+
+ refresh: function () {
+
+ },
+
+ /**
+ * 更新整个model
+ */
+ updateURL: function () {
+
+ },
+ /**
+ * 添加一个元素或删除一个元素或修改一个元素
+ */
+ patchURL: function () {
+
+ },
+ /**
+ * 删除整个model, destroy方法调用
+ */
+ deleteURL: function () {
+
+ },
+ /**
+ * 读取model
+ */
+ readURL: function () {
+
+ },
+
+ read: function (options) {
+ if (this._start == true || this._changing_ === true) {
+ this._F.push({f: this.read, arg: arguments});
+ return;
+ }
+ this._read(options);
+ },
+
+ update: function (options) {
+ if (this._start == true || this._changing_ === true) {
+ this._F.push({f: this.update, arg: arguments});
+ return;
+ }
+ this._save(null, options);
+ },
+
+ patch: function (options) {
+ if (this._start == true || this._changing_ === true) {
+ this._F.push({f: this.patch, arg: arguments});
+ return;
+ }
+ this._save(null, BI.extend({}, options, {
+ patch: true
+ }));
+ },
+
+ _destroy: function () {
+ var children = BI.extend({}, this._childs);
+ this._childs = {};
+ BI.each(children, function (i, child) {
+ child._destroy();
+ });
+ this.destroyed && this.destroyed();
+ },
+
+ destroy: function () {
+ this._destroy();
+ BI.Model.superclass.destroy.apply(this, arguments);
+ }
+});/**
+ * @class BI.View
+ * @extends BI.V
+ * @type {*|void|Object}
+ */
+BI.View = BI.inherit(BI.V, {
+
+ //生命周期函数
+ beforeCreate: null,
+
+ created: null,
+
+ beforeDestroyed: null,
+
+ destroyed: null,
+
+ _init: function () {
+ BI.View.superclass._init.apply(this, arguments);
+ this.beforeCreate && this.beforeCreate();
+ var self = this;
+ this.listenTo(this.model, "change:current", function (obj, val) {
+ if (BI.isNotNull(val) && val.length > 0) {
+ this.refresh(val);
+ }
+ }).listenTo(this.model, "change", function (changed) {
+ this.delegateEvents();
+ }).listenTo(this.model, "changed", function (changed, prev, context, options) {
+ if (BI.has(changed, "current") && BI.size(changed) > 1) {
+ throw new Error("refresh操作不能调用set操作");
+ }
+ var notLocal = !BI.has(changed, "current") && !this.local() && this.notifyParent().notify();
+ this.model.actionEnd() && this.actionEnd();
+ this.model._changing_ = true;
+ notLocal && !BI.isEmpty(changed) && this.change(changed, prev, context, options);
+ this.model._changing_ = false;
+ this.model.actionEnd() && this.actionEnd();
+ }).listenTo(this.model, "destroy", function () {
+ this._destroy();
+ }).listenTo(this.model, "unset", function () {
+ this._destroy();
+ }).listenTo(this.model, "splice", function (arg) {
+ this.splice.apply(this, arg);
+ }).listenTo(this.model, "duplicate", function (arg) {
+ this.duplicate.apply(this, arg);
+ });
+ this._F = [];
+ var flatten = ["_init", "_defaultConfig", "_vessel", "_render", "getName", "listenEnd", "local", "refresh", "load", "change"];
+ flatten = BI.makeObject(flatten, true);
+ BI.each(this.constructor.caller.caller.prototype, function (key) {
+ if (flatten[key]) {
+ return;
+ }
+ var f = self[key];
+ if (BI.isFunction(f)) {
+ self[key] = BI.bind(function () {
+ if (this.model._start === true) {
+ this._F.push({f: f, arg: arguments});
+ return;
+ }
+ return f.apply(this, arguments);
+ }, self);
+ }
+ });
+ this.created && this.created();
+ },
+
+ change: function (changed, prev) {
+
+ },
+
+ actionEnd: function () {
+ var self = this;
+ var _F = this._F.slice(0);
+ this._F = [];
+ BI.each(_F, function (i, f) {
+ f.f.apply(self, f.arg);
+ });
+ return this;
+ },
+
+ delegateEvents: function (events) {
+ if (!(events || (events = BI.deepClone(_.result(this, 'events'))))) return this;
+ var delegateEventSplitter = /^(\S+)\s*(.*)$/;
+ for (var key in events) {
+ var method = events[key];
+ if (!_.isFunction(method)) method = this[events[key]];
+ if (!method) continue;
+ var match = key.match(delegateEventSplitter);
+ var ev = true;
+ switch (match[1]) {
+ case "draggable":
+ break;
+ case "droppable":
+ break;
+ case "sortable":
+ break;
+ case "resizable":
+ break;
+ case "hover":
+ break;
+ default :
+ ev = false;
+ break;
+ }
+
+ var off = new BI.OffList({
+ event: match[1] + '.delegateEvents' + this.cid
+ });
+
+ var keys = match[2].split('.');
+ var handle = keys[1];
+ var bind = ev ? new BI.EventList({
+ event: match[1],
+ handle: handle,
+ callback: BI.bind(method, this)
+ }) : new BI.ListenerList({
+ event: match[1] + '.delegateEvents' + this.cid,
+ handle: handle,
+ callback: BI.bind(method, this),
+ context: this
+ });
+
+ var list = [];
+ if (this[keys[0]] && (this[keys[0]] instanceof $ || this[keys[0]].element instanceof $)) {
+ list = [this[keys[0]]]
+ delete events[key];
+ } else if (BI.isArray(this[keys[0]]) || BI.isPlainObject(this[keys[0]])) {
+ list = this[keys[0]]
+ delete events[key];
+ }
+ off.populate(list);
+ bind.populate(list);
+ }
+ return BI.View.superclass.delegateEvents.apply(this, [events]);
+ },
+
+ _vessel: function () {
+ this._cardLayouts = {};
+ this._cardLayouts[this.getName()] = new BI.CardLayout({
+ element: this
+ });
+ var vessel = BI.createWidget();
+ this._cardLayouts[this.getName()].addCardByName(this.getName(), vessel);
+ return vessel;
+ },
+
+ render: function (vessel) {
+ return this;
+ },
+
+ /**
+ * 创建儿子所在容器
+ * @param key
+ * @param vessel
+ * @param options isLayer:是否是弹出层, defaultShowName:默认显示项
+ * @returns {BI.View}
+ */
+ addSubVessel: function (key, vessel, options) {
+ options || (options = {});
+ this._cardLayouts || (this._cardLayouts = {});
+ var id = key + this.cid;
+ options.isLayer && (vessel = BI.Layers.has(id) ? BI.Layers.get(id) : BI.Layers.create(id, vessel));
+ if (this._cardLayouts[key]) {
+ options.defaultShowName && this._cardLayouts[key].setDefaultShowName(options.defaultShowName);
+ return this;
+ }
+ this._cardLayouts[key] = BI.createWidget({
+ type: "bi.card",
+ element: vessel,
+ defaultShowName: options.defaultShowName
+ });
+ return this;
+ },
+
+ removeSubVessel: function (key) {
+ var self = this, id = key + this.cid;
+ BI.Layers.remove(id);
+ var cardNames = this._cardLayouts[key] && this._cardLayouts[key].getAllCardNames();
+ BI.each(cardNames, function (i, name) {
+ delete self._cards[name];
+ });
+ this._cardLayouts[key] && this._cardLayouts[key]._destroy();
+ return this;
+ },
+
+ createView: function (url, modelData, viewData) {
+ return BI.Factory.createView(url, this.get(url), modelData, viewData);
+ },
+
+ /**
+ * 跳转到指定的card
+ * @param cardName
+ */
+ skipTo: function (cardName, layout, modelData, viewData, options) {
+ if (this.model._start === true || this._changing_ === true) {
+ this._F.push({f: this.skipTo, arg: arguments});
+ return this;
+ }
+ var self = this, isValid = BI.isKey(modelData), data = void 0;
+ BI.isKey(layout) && (layout = layout + "");
+ layout = layout || this.getName();
+ options || (options = {});
+ if (isValid) {
+ modelData = modelData + "";//避免modelData是数字
+ var keys = modelData.split('.');
+ BI.each(keys, function (i, k) {
+ if (i === 0) {
+ data = self.model.get(k) || {};
+ } else {
+ data = data[k] || {};
+ }
+ });
+ data.id = options.id || keys[keys.length - 1];
+ } else {
+ data = modelData;
+ }
+ BI.extend(data, options.data);
+ var action = options.action || new BI.ShowAction();
+ var cardLayout = this._cardLayouts[layout];
+ if (!cardLayout) {
+ return this;
+ }
+ cardLayout.setVisible(true);
+ if (BI.isKey(cardName) && !cardLayout.isCardExisted(cardName)) {
+ var view = this.createView(this.rootURL + "/" + cardName, data, viewData);
+ isValid && this.model.addChild(modelData, view.model);
+ view.listenTo(view.model, "destroy", function () {
+ delete self._cards[cardName];
+ cardLayout.deleteCardByName(cardName);
+ if (cardLayout.isAllCardHide()) {
+ cardLayout.setVisible(false);
+ BI.Layers.hide(layout + self.cid);
+ }
+ }).listenTo(view.model, "unset", function () {
+ delete self._cards[cardName];
+ cardLayout.deleteCardByName(cardName);
+ });
+ cardLayout.addCardByName(cardName, view);
+ this._cards || (this._cards = {});
+ this._cards[cardName] = view;
+ data = {};
+ this.on("end:" + view.cid, function () {
+ var isNew = false, t, keys;
+ if (isValid) {
+ keys = modelData.split('.');
+ BI.each(keys, function (i, k) {
+ if (i === 0) {
+ t = self.model.get(k) || (isNew = true);
+ } else {
+ t = t[k] || (isNew = true);
+ }
+ });
+ }
+ if (isNew) {
+ delete self._cards[cardName];
+ self.model.removeChild(modelData, view.model);
+ cardLayout.deleteCardByName(cardName);
+ view._destroy();
+ cardLayout.setVisible(false);
+ }
+ action.actionBack(view, null, function () {
+ if (cardLayout.isAllCardHide()) {
+ cardLayout.setVisible(false);
+ BI.Layers.hide(layout + self.cid);
+ }
+ !isNew && (self.listenEnd.apply(self, isValid ? keys : [modelData]) !== false) && self.populate();
+ })
+ }).on("change:" + view.cid, _.bind(this.notifyParent, this));
+ }
+ BI.isKey(cardName) && BI.Layers.show(layout + this.cid);
+ cardLayout.showCardByName(cardName, action, function () {
+ BI.isKey(cardName) && self._cards[cardName].populate(data, options);
+ });
+ !BI.isKey(cardName) && BI.Layers.hide(layout + this.cid);
+ return this._cards[cardName];
+ },
+
+ listenEnd: function (key1, key2, key3) {
+ return this;
+ },
+
+ /**
+ * 告诉父亲我的操作结束了,后面的事情任由父亲处置
+ * @param force 强制下次再次进入该节点时不进行刷新操作, 默认执行刷新
+ * @returns {BI.View}
+ */
+ notifyParentEnd: function (force) {
+ this.parent && this.parent.trigger("end:" + this.cid);
+ this.trigger("end");
+ !force && this.notify();
+ return this;
+ },
+
+ /**
+ * 通知父亲我的数据发生了变化
+ */
+ notifyParent: function () {
+ this.parent && this.parent.notify().trigger("change:" + this.cid);
+ return this;
+ },
+
+ /**
+ * 告诉Model数据改变了
+ */
+ notify: function () {
+ this.model.unset("current", {silent: true});
+ return this;
+ },
+
+ getName: function () {
+ return "VIEW"
+ },
+
+ /**
+ * 全局刷新
+ * @param current
+ */
+ refresh: function (current) {
+ },
+ /**
+ * 局部刷新
+ */
+ local: function () {
+ return false;
+ },
+
+ load: function (data) {
+
+ },
+
+ readData: function (force, options) {
+ options || (options = {});
+ var self = this;
+ var args = [].slice.call(arguments, 2);
+ if (!force && this._readed === true) {//只从后台获取一次数据
+ callback(this.model.toJSON());
+ return;
+ }
+ //采用静默方式读数据,该数据变化不引起data的change事件触发
+ var success = options.success;
+ this.model.read(BI.extend({
+ silent: true
+ }, options, {
+ success: function (data, model) {
+ callback(data);
+ !force && (self._readed = true);
+ self.delegateEvents();
+ success && success(data, model);
+ }
+ }));
+ function callback(data) {
+ self.model.load(data);
+ self.load(data);
+ BI.each(args, function (i, arg) {
+ if (BI.isFunction(arg)) {
+ arg.apply(self, [data]);
+ }
+ })
+ }
+ },
+
+ //处理model的通用方法
+ cat: function () {
+ return this.model.cat.apply(this.model, arguments);
+ },
+
+ get: function () {
+ return this.model.get.apply(this.model, arguments);
+ },
+
+ set: function () {
+ return this.model.set.apply(this.model, arguments);
+ },
+
+ has: function () {
+ return this.model.has.apply(this.model, arguments);
+ },
+
+ getEditing: function () {
+ return this.model.getEditing();
+ },
+
+ reading: function (options) {
+ var self = this;
+ var name = BI.UUID();
+ this.model.read(BI.extend({}, options, {
+ beforeSend: function () {
+ var loading = BI.createWidget({
+ type: 'bi.vertical',
+ items: [{
+ type: "bi.layout",
+ height: 30,
+ cls: "loading-background"
+ }],
+ element: BI.Maskers.make(name, self)
+ });
+ loading.setVisible(true);
+ },
+ complete: function (data) {
+ options.complete && options.complete(data);
+ BI.Maskers.remove(name);
+ }
+ }));
+ },
+
+ updating: function (options) {
+ var self = this;
+ var name = BI.UUID();
+ this.model.update(BI.extend({}, options, {
+ noset: true,
+ beforeSend: function () {
+ var loading = BI.createWidget({
+ type: 'bi.vertical',
+ items: [{
+ type: "bi.layout",
+ height: 30,
+ cls: "loading-background"
+ }],
+ element: BI.Maskers.make(name, self)
+ });
+ loading.setVisible(true);
+ },
+ complete: function (data) {
+ options.complete && options.complete(data);
+ BI.Maskers.remove(name);
+ }
+ }));
+ },
+
+ patching: function (options) {
+ var self = this;
+ var name = BI.UUID();
+ this.model.patch(BI.extend({}, options, {
+ noset: true,
+ beforeSend: function () {
+ var loading = BI.createWidget({
+ type: 'bi.vertical',
+ items: [{
+ type: "bi.layout",
+ height: 30,
+ cls: "loading-background"
+ }],
+ element: BI.Maskers.make(name, self)
+ });
+ loading.setVisible(true);
+ },
+ complete: function (data) {
+ options.complete && options.complete(data);
+ BI.Maskers.remove(name);
+ }
+ }));
+ },
+
+ populate: function (modelData, options) {
+ var self = this;
+ options || (options = {});
+ if (options.force === true) {
+ this.notify();
+ }
+ if (this._cardLayouts && this._cardLayouts[this.getName()]) {
+ this._cardLayouts[this.getName()].showCardByName(this.getName());
+ }
+ //BI.each(this._cardLayouts, function (key, layout) {
+ // layout.showCardByName(layout.getDefaultShowName() || self.getName());
+ //});
+ //BI.each(this._cards, function (i, card) {
+ // card.notify && card.notify();
+ //});
+ if (this._F.length > 0) {
+ throw new Error("流程错误");
+ }
+ if (options.force === true) {
+ this.model.set(modelData, options).set({current: this.model.get("default")});
+ return;
+ }
+ if (options.force === false) {
+ this.model.set(modelData);
+ return;
+ }
+ var filter = BI.clone(modelData || {});
+ delete filter.id;
+ var contains = BI.has(this.model.toJSON(), _.keys(filter));
+ var match = BI.isEmpty(filter) || (contains && this.model.matches(modelData));
+ if (match === true) {
+ this.model.set({current: this.model.get("default")});
+ } else if (contains === false) {
+ this.model.set(modelData);
+ } else {
+ this.model.set(modelData, options).set({current: this.model.get("default")});
+ }
+ },
+
+ //删除子节点触发
+ splice: function (old, key1, key2, key3) {
+
+ },
+
+ //复制子节点触发
+ duplicate: function (copy, key1, key2, key3) {
+
+ },
+
+ _unMount: function () {
+ this.beforeDestroyed && this.beforeDestroyed();
+ BI.each(this._cardLayouts, function (name, card) {
+ card && card._unMount();
+ });
+ delete this._cardLayouts;
+ delete this._cards;
+ this.destroyed && this.destroyed();
+ this.trigger(BI.Events.UNMOUNT);
+ this.off();
+ },
+
+ _destroy: function () {
+ var self = this;
+ BI.each(this._cardLayouts, function (name, card) {
+ card && card._unMount();
+ BI.Layers.remove(name + self.cid);
+ });
+ delete this._cardLayouts;
+ delete this._cards;
+ this.destroyed && this.destroyed();
+ this.remove();
+ this.trigger(BI.Events.DESTROY);
+ this.off();
+ }
+});(function () {
+
+ var kv = {}; // alex:键(编辑器简称,如text)值(也是一个字符串,如FR.TextEditor)对
+ BI.shortcut = function (xtype, cls) {
+ if (kv[xtype] != null) {
+ throw ("shortcut:[" + xtype + "] has been registed");
+ }
+ kv[xtype] = cls;
+ _.extend(cls.prototype, {
+ xtype: xtype
+ })
+ };
+
+ // 根据配置属性生成widget
+ var createWidget = function (config) {
+ if (config['classType']) {
+ return new (new Function('return ' + config['classType'] + ';')())(config);
+ }
+
+ if (!config.type) {
+
+ }
+ var xtype = config.type.toLowerCase();
+ var cls = kv[xtype];
+ return new cls(config);
+ };
+
+ BI.createWidget = function (item, options) {
+ var el;
+ options || (options = {});
+ if (BI.isEmpty(item) && BI.isEmpty(options)) {
+ return BI.createWidget({
+ type: "bi.layout"
+ });
+ }
+ if (BI.isWidget(item)) {
+ return item;
+ }
+ if (item && (item.type || options.type)) {
+ el = BI.extend({}, options, item);
+ return BI.Plugin.getObject(el.type, createWidget(BI.Plugin.getWidget(el.type, el)));
+ }
+ if (item && item.el && (item.el.type || options.type)) {
+ el = BI.extend({}, options, item.el);
+ return BI.Plugin.getObject(el.type, createWidget(BI.Plugin.getWidget(el.type, el)));
+ }
+ if (item && BI.isWidget(item.el)) {
+ return item.el;
+ }
+ throw new Error('无法根据item创建组件');
+ }
+
+})();(function (window, undefined) {
+ function aspect(type) {
+ return function (target, methodName, advice) {
+ var exist = target[methodName],
+ dispatcher;
+
+ if (!exist || exist.target != target) {
+ dispatcher = target[methodName] = function () {
+ // before methods
+ var beforeArr = dispatcher.before;
+ var args = arguments, next;
+ for (var l = beforeArr.length; l--;) {
+ next = beforeArr[l].advice.apply(this, args);
+ if (next === false) {
+ return false;
+ }
+ args = next || args;
+ }
+ // target method
+ var rs = dispatcher.method.apply(this, args);
+ // after methods
+ var afterArr = dispatcher.after;
+ for (var i = 0, ii = afterArr.length; i < ii; i++) {
+ next = afterArr[i].advice.call(this, rs, args);
+ if (rs === false) {
+ return false;
+ }
+ args = next || args;
+ }
+ return rs;
+ };
+
+ dispatcher.before = [];
+ dispatcher.after = [];
+
+ if (exist) {
+ dispatcher.method = exist;
+ }
+ dispatcher.target = target;
+ }
+
+ var aspectArr = (dispatcher || exist)[type];
+ var obj = {
+ advice: advice,
+ _index: aspectArr.length,
+ remove: function () {
+ aspectArr.splice(this._index, 1);
+ }
+ };
+ aspectArr.push(obj);
+
+ return obj;
+ };
+ }
+
+ BI.aspect = {
+ before: aspect("before"),
+ after: aspect("after")
+ };
+
+ return BI.aspect;
+
+})(window);;
+!(function () {
+
+ var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+
+
+ // private method for UTF-8 encoding
+ var _utf8_encode = function (string) {
+ string = string.replace(/\r\n/g, "\n");
+ var utftext = "";
+
+ for (var n = 0; n < string.length; n++) {
+
+ var c = string.charCodeAt(n);
+
+ if (c < 128) {
+ utftext += String.fromCharCode(c);
+ } else if ((c > 127) && (c < 2048)) {
+ utftext += String.fromCharCode((c >> 6) | 192);
+ utftext += String.fromCharCode((c & 63) | 128);
+ } else {
+ utftext += String.fromCharCode((c >> 12) | 224);
+ utftext += String.fromCharCode(((c >> 6) & 63) | 128);
+ utftext += String.fromCharCode((c & 63) | 128);
+ }
+
+ }
+
+ return utftext;
+ };
+
+ // private method for UTF-8 decoding
+ var _utf8_decode = function (utftext) {
+ var string = "";
+ var i = 0;
+ var c = 0, c3 = 0, c2 = 0;
+
+ while (i < utftext.length) {
+
+ c = utftext.charCodeAt(i);
+
+ if (c < 128) {
+ string += String.fromCharCode(c);
+ i++;
+ } else if ((c > 191) && (c < 224)) {
+ c2 = utftext.charCodeAt(i + 1);
+ string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
+ i += 2;
+ } else {
+ c2 = utftext.charCodeAt(i + 1);
+ c3 = utftext.charCodeAt(i + 2);
+ string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
+ i += 3;
+ }
+
+ }
+ return string;
+ };
+
+ _.extend(BI, {
+
+ encode: function (input) {
+ var output = "";
+ var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
+ var i = 0;
+
+ input = _utf8_encode(input);
+
+ while (i < input.length) {
+
+ chr1 = input.charCodeAt(i++);
+ chr2 = input.charCodeAt(i++);
+ chr3 = input.charCodeAt(i++);
+
+ enc1 = chr1 >> 2;
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
+ enc4 = chr3 & 63;
+
+ if (isNaN(chr2)) {
+ enc3 = enc4 = 64;
+ } else if (isNaN(chr3)) {
+ enc4 = 64;
+ }
+
+ output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
+
+ }
+
+ return output;
+ },
+
+ // public method for decoding
+ decode: function (input) {
+ var output = "";
+ var chr1, chr2, chr3;
+ var enc1, enc2, enc3, enc4;
+ var i = 0;
+
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
+
+ while (i < input.length) {
+
+ enc1 = _keyStr.indexOf(input.charAt(i++));
+ enc2 = _keyStr.indexOf(input.charAt(i++));
+ enc3 = _keyStr.indexOf(input.charAt(i++));
+ enc4 = _keyStr.indexOf(input.charAt(i++));
+
+ chr1 = (enc1 << 2) | (enc2 >> 4);
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
+ chr3 = ((enc3 & 3) << 6) | enc4;
+
+ output = output + String.fromCharCode(chr1);
+
+ if (enc3 != 64) {
+ output = output + String.fromCharCode(chr2);
+ }
+ if (enc4 != 64) {
+ output = output + String.fromCharCode(chr3);
+ }
+
+ }
+
+ output = _utf8_decode(output);
+
+ return output;
+
+ }
+ })
+})();BI.CellSizeAndPositionManager = function (cellCount, cellSizeGetter, estimatedCellSize) {
+ this._cellSizeGetter = cellSizeGetter;
+ this._cellCount = cellCount;
+ this._estimatedCellSize = estimatedCellSize;
+ this._cellSizeAndPositionData = {};
+ this._lastMeasuredIndex = -1;
+};
+
+BI.CellSizeAndPositionManager.prototype = {
+ constructor: BI.CellSizeAndPositionManager,
+ configure: function (cellCount, estimatedCellSize) {
+ this._cellCount = cellCount;
+ this._estimatedCellSize = estimatedCellSize;
+ },
+
+ getCellCount: function () {
+ return this._cellCount;
+ },
+
+ getEstimatedCellSize: function () {
+ return this._estimatedCellSize;
+ },
+
+ getLastMeasuredIndex: function () {
+ return this._lastMeasuredIndex;
+ },
+
+ getSizeAndPositionOfCell: function (index) {
+ if (index < 0 || index >= this._cellCount) {
+ return;
+ }
+ if (index > this._lastMeasuredIndex) {
+ var lastMeasuredCellSizeAndPosition = this.getSizeAndPositionOfLastMeasuredCell();
+ var offset = lastMeasuredCellSizeAndPosition.offset + lastMeasuredCellSizeAndPosition.size;
+
+ for (var i = this._lastMeasuredIndex + 1; i <= index; i++) {
+ var size = this._cellSizeGetter(i);
+
+ if (size == null || isNaN(size)) {
+ continue;
+ }
+
+ this._cellSizeAndPositionData[i] = {
+ offset: offset,
+ size: size
+ };
+
+ offset += size;
+ }
+
+ this._lastMeasuredIndex = index;
+ }
+ return this._cellSizeAndPositionData[index];
+ },
+
+ getSizeAndPositionOfLastMeasuredCell: function () {
+ return this._lastMeasuredIndex >= 0
+ ? this._cellSizeAndPositionData[this._lastMeasuredIndex]
+ : {
+ offset: 0,
+ size: 0
+ }
+ },
+
+ getTotalSize: function () {
+ var lastMeasuredCellSizeAndPosition = this.getSizeAndPositionOfLastMeasuredCell();
+ return lastMeasuredCellSizeAndPosition.offset + lastMeasuredCellSizeAndPosition.size + (this._cellCount - this._lastMeasuredIndex - 1) * this._estimatedCellSize
+ },
+
+ getUpdatedOffsetForIndex: function (align, containerSize, currentOffset, targetIndex) {
+ var datum = this.getSizeAndPositionOfCell(targetIndex);
+ var maxOffset = datum.offset;
+ var minOffset = maxOffset - containerSize + datum.size;
+
+ var idealOffset;
+
+ switch (align) {
+ case 'start':
+ idealOffset = maxOffset;
+ break;
+ case 'end':
+ idealOffset = minOffset;
+ break;
+ case 'center':
+ idealOffset = maxOffset - ((containerSize - datum.size) / 2);
+ break;
+ default:
+ idealOffset = Math.max(minOffset, Math.min(maxOffset, currentOffset));
+ break;
+ }
+
+ var totalSize = this.getTotalSize();
+
+ return Math.max(0, Math.min(totalSize - containerSize, idealOffset));
+ },
+
+ getVisibleCellRange: function (containerSize, offset) {
+ var totalSize = this.getTotalSize();
+
+ if (totalSize === 0) {
+ return {}
+ }
+
+ var maxOffset = offset + containerSize;
+ var start = this._findNearestCell(offset);
+
+ var datum = this.getSizeAndPositionOfCell(start);
+ offset = datum.offset + datum.size;
+
+ var stop = start;
+
+ while (offset < maxOffset && stop < this._cellCount - 1) {
+ stop++;
+ offset += this.getSizeAndPositionOfCell(stop).size;
+ }
+
+ return {
+ start: start,
+ stop: stop
+ }
+ },
+
+ resetCell: function (index) {
+ this._lastMeasuredIndex = Math.min(this._lastMeasuredIndex, index - 1)
+ },
+
+ _binarySearch: function (high, low, offset) {
+ var middle;
+ var currentOffset;
+
+ while (low <= high) {
+ middle = low + Math.floor((high - low) / 2);
+ currentOffset = this.getSizeAndPositionOfCell(middle).offset;
+
+ if (currentOffset === offset) {
+ return middle;
+ } else if (currentOffset < offset) {
+ low = middle + 1;
+ } else if (currentOffset > offset) {
+ high = middle - 1;
+ }
+ }
+
+ if (low > 0) {
+ return low - 1;
+ }
+ },
+
+ _exponentialSearch: function (index, offset) {
+ var interval = 1;
+
+ while (index < this._cellCount && this.getSizeAndPositionOfCell(index).offset < offset) {
+ index += interval;
+ interval *= 2;
+ }
+
+ return this._binarySearch(Math.min(index, this._cellCount - 1), Math.floor(index / 2), offset);
+ },
+
+ _findNearestCell: function (offset) {
+ if (isNaN(offset)) {
+ return;
+ }
+
+ offset = Math.max(0, offset);
+
+ var lastMeasuredCellSizeAndPosition = this.getSizeAndPositionOfLastMeasuredCell();
+ var lastMeasuredIndex = Math.max(0, this._lastMeasuredIndex);
+
+ if (lastMeasuredCellSizeAndPosition.offset >= offset) {
+ return this._binarySearch(lastMeasuredIndex, 0, offset);
+ } else {
+ return this._exponentialSearch(lastMeasuredIndex, offset);
+ }
+ }
+};
+
+BI.ScalingCellSizeAndPositionManager = function (cellCount, cellSizeGetter, estimatedCellSize, maxScrollSize) {
+ this._cellSizeAndPositionManager = new BI.CellSizeAndPositionManager(cellCount, cellSizeGetter, estimatedCellSize);
+ this._maxScrollSize = maxScrollSize || 10000000
+};
+
+BI.ScalingCellSizeAndPositionManager.prototype = {
+ constructor: BI.ScalingCellSizeAndPositionManager,
+
+ configure: function () {
+ this._cellSizeAndPositionManager.configure.apply(this._cellSizeAndPositionManager, arguments);
+ },
+
+ getCellCount: function () {
+ return this._cellSizeAndPositionManager.getCellCount()
+ },
+
+ getEstimatedCellSize: function () {
+ return this._cellSizeAndPositionManager.getEstimatedCellSize()
+ },
+
+ getLastMeasuredIndex: function () {
+ return this._cellSizeAndPositionManager.getLastMeasuredIndex()
+ },
+
+ getOffsetAdjustment: function (containerSize, offset) {
+ var totalSize = this._cellSizeAndPositionManager.getTotalSize();
+ var safeTotalSize = this.getTotalSize();
+ var offsetPercentage = this._getOffsetPercentage(containerSize, offset, safeTotalSize);
+
+ return Math.round(offsetPercentage * (safeTotalSize - totalSize));
+ },
+
+ getSizeAndPositionOfCell: function (index) {
+ return this._cellSizeAndPositionManager.getSizeAndPositionOfCell(index);
+ },
+
+ getSizeAndPositionOfLastMeasuredCell: function () {
+ return this._cellSizeAndPositionManager.getSizeAndPositionOfLastMeasuredCell();
+ },
+
+ getTotalSize: function () {
+ return Math.min(this._maxScrollSize, this._cellSizeAndPositionManager.getTotalSize());
+ },
+
+ getUpdatedOffsetForIndex: function (align, containerSize, currentOffset, targetIndex) {
+ currentOffset = this._safeOffsetToOffset(containerSize, currentOffset);
+
+ var offset = this._cellSizeAndPositionManager.getUpdatedOffsetForIndex(align, containerSize, currentOffset, targetIndex);
+
+ return this._offsetToSafeOffset(containerSize, offset);
+ },
+
+ getVisibleCellRange: function (containerSize, offset) {
+ offset = this._safeOffsetToOffset(containerSize, offset);
+
+ return this._cellSizeAndPositionManager.getVisibleCellRange(containerSize, offset);
+ },
+
+ resetCell: function (index) {
+ this._cellSizeAndPositionManager.resetCell(index)
+ },
+
+ _getOffsetPercentage: function (containerSize, offset, totalSize) {
+ return totalSize <= containerSize
+ ? 0
+ : offset / (totalSize - containerSize)
+ },
+
+ _offsetToSafeOffset: function (containerSize, offset) {
+ var totalSize = this._cellSizeAndPositionManager.getTotalSize();
+ var safeTotalSize = this.getTotalSize();
+
+ if (totalSize === safeTotalSize) {
+ return offset;
+ } else {
+ var offsetPercentage = this._getOffsetPercentage(containerSize, offset, totalSize);
+
+ return Math.round(offsetPercentage * (safeTotalSize - containerSize));
+ }
+ },
+
+ _safeOffsetToOffset: function (containerSize, offset) {
+ var totalSize = this._cellSizeAndPositionManager.getTotalSize();
+ var safeTotalSize = this.getTotalSize();
+
+ if (totalSize === safeTotalSize) {
+ return offset;
+ } else {
+ var offsetPercentage = this._getOffsetPercentage(containerSize, offset, safeTotalSize);
+
+ return Math.round(offsetPercentage * (totalSize - containerSize));
+ }
+ }
+};/**
+ * 汉字拼音索引
+ */
+;
+!(function () {
+ var _ChineseFirstPY = "YDYQSXMWZSSXJBYMGCCZQPSSQBYCDSCDQLDYLYBSSJGYZZJJFKCCLZDHWDWZJLJPFYYNWJJTMYHZWZHFLZPPQHGSCYYYNJQYXXGJHHSDSJNKKTMOMLCRXYPSNQSECCQZGGLLYJLMYZZSECYKYYHQWJSSGGYXYZYJWWKDJHYCHMYXJTLXJYQBYXZLDWRDJRWYSRLDZJPCBZJJBR"
+ + "CFTLECZSTZFXXZHTRQHYBDLYCZSSYMMRFMYQZPWWJJYFCRWFDFZQPYDDWYXKYJAWJFFXYPSFTZYHHYZYSWCJYXSCLCXXWZZXNBGNNXBXLZSZSBSGPYSYZDHMDZBQBZCWDZZYYTZHBTSYYBZGNTNXQYWQSKBPHHLXGYBFMJEBJHHGQTJCYSXSTKZHLYCKGLYSMZXYALMELDCCXGZ"
+ + "YRJXSDLTYZCQKCNNJWHJTZZCQLJSTSTBNXBTYXCEQXGKWJYFLZQLYHYXSPSFXLMPBYSXXXYDJCZYLLLSJXFHJXPJBTFFYABYXBHZZBJYZLWLCZGGBTSSMDTJZXPTHYQTGLJSCQFZKJZJQNLZWLSLHDZBWJNCJZYZSQQYCQYRZCJJWYBRTWPYFTWEXCSKDZCTBZHYZZYYJXZCFFZ"
+ + "ZMJYXXSDZZOTTBZLQWFCKSZSXFYRLNYJMBDTHJXSQQCCSBXYYTSYFBXDZTGBCNSLCYZZPSAZYZZSCJCSHZQYDXLBPJLLMQXTYDZXSQJTZPXLCGLQTZWJBHCTSYJSFXYEJJTLBGXSXJMYJQQPFZASYJNTYDJXKJCDJSZCBARTDCLYJQMWNQNCLLLKBYBZZSYHQQLTWLCCXTXLLZN"
+ + "TYLNEWYZYXCZXXGRKRMTCNDNJTSYYSSDQDGHSDBJGHRWRQLYBGLXHLGTGXBQJDZPYJSJYJCTMRNYMGRZJCZGJMZMGXMPRYXKJNYMSGMZJYMKMFXMLDTGFBHCJHKYLPFMDXLQJJSMTQGZSJLQDLDGJYCALCMZCSDJLLNXDJFFFFJCZFMZFFPFKHKGDPSXKTACJDHHZDDCRRCFQYJ"
+ + "KQCCWJDXHWJLYLLZGCFCQDSMLZPBJJPLSBCJGGDCKKDEZSQCCKJGCGKDJTJDLZYCXKLQSCGJCLTFPCQCZGWPJDQYZJJBYJHSJDZWGFSJGZKQCCZLLPSPKJGQJHZZLJPLGJGJJTHJJYJZCZMLZLYQBGJWMLJKXZDZNJQSYZMLJLLJKYWXMKJLHSKJGBMCLYYMKXJQLBMLLKMDXXK"
+ + "WYXYSLMLPSJQQJQXYXFJTJDXMXXLLCXQBSYJBGWYMBGGBCYXPJYGPEPFGDJGBHBNSQJYZJKJKHXQFGQZKFHYGKHDKLLSDJQXPQYKYBNQSXQNSZSWHBSXWHXWBZZXDMNSJBSBKBBZKLYLXGWXDRWYQZMYWSJQLCJXXJXKJEQXSCYETLZHLYYYSDZPAQYZCMTLSHTZCFYZYXYLJSD"
+ + "CJQAGYSLCQLYYYSHMRQQKLDXZSCSSSYDYCJYSFSJBFRSSZQSBXXPXJYSDRCKGJLGDKZJZBDKTCSYQPYHSTCLDJDHMXMCGXYZHJDDTMHLTXZXYLYMOHYJCLTYFBQQXPFBDFHHTKSQHZYYWCNXXCRWHOWGYJLEGWDQCWGFJYCSNTMYTOLBYGWQWESJPWNMLRYDZSZTXYQPZGCWXHN"
+ + "GPYXSHMYQJXZTDPPBFYHZHTJYFDZWKGKZBLDNTSXHQEEGZZYLZMMZYJZGXZXKHKSTXNXXWYLYAPSTHXDWHZYMPXAGKYDXBHNHXKDPJNMYHYLPMGOCSLNZHKXXLPZZLBMLSFBHHGYGYYGGBHSCYAQTYWLXTZQCEZYDQDQMMHTKLLSZHLSJZWFYHQSWSCWLQAZYNYTLSXTHAZNKZZ"
+ + "SZZLAXXZWWCTGQQTDDYZTCCHYQZFLXPSLZYGPZSZNGLNDQTBDLXGTCTAJDKYWNSYZLJHHZZCWNYYZYWMHYCHHYXHJKZWSXHZYXLYSKQYSPSLYZWMYPPKBYGLKZHTYXAXQSYSHXASMCHKDSCRSWJPWXSGZJLWWSCHSJHSQNHCSEGNDAQTBAALZZMSSTDQJCJKTSCJAXPLGGXHHGX"
+ + "XZCXPDMMHLDGTYBYSJMXHMRCPXXJZCKZXSHMLQXXTTHXWZFKHCCZDYTCJYXQHLXDHYPJQXYLSYYDZOZJNYXQEZYSQYAYXWYPDGXDDXSPPYZNDLTWRHXYDXZZJHTCXMCZLHPYYYYMHZLLHNXMYLLLMDCPPXHMXDKYCYRDLTXJCHHZZXZLCCLYLNZSHZJZZLNNRLWHYQSNJHXYNTT"
+ + "TKYJPYCHHYEGKCTTWLGQRLGGTGTYGYHPYHYLQYQGCWYQKPYYYTTTTLHYHLLTYTTSPLKYZXGZWGPYDSSZZDQXSKCQNMJJZZBXYQMJRTFFBTKHZKBXLJJKDXJTLBWFZPPTKQTZTGPDGNTPJYFALQMKGXBDCLZFHZCLLLLADPMXDJHLCCLGYHDZFGYDDGCYYFGYDXKSSEBDHYKDKDK"
+ + "HNAXXYBPBYYHXZQGAFFQYJXDMLJCSQZLLPCHBSXGJYNDYBYQSPZWJLZKSDDTACTBXZDYZYPJZQSJNKKTKNJDJGYYPGTLFYQKASDNTCYHBLWDZHBBYDWJRYGKZYHEYYFJMSDTYFZJJHGCXPLXHLDWXXJKYTCYKSSSMTWCTTQZLPBSZDZWZXGZAGYKTYWXLHLSPBCLLOQMMZSSLCM"
+ + "BJCSZZKYDCZJGQQDSMCYTZQQLWZQZXSSFPTTFQMDDZDSHDTDWFHTDYZJYQJQKYPBDJYYXTLJHDRQXXXHAYDHRJLKLYTWHLLRLLRCXYLBWSRSZZSYMKZZHHKYHXKSMDSYDYCJPBZBSQLFCXXXNXKXWYWSDZYQOGGQMMYHCDZTTFJYYBGSTTTYBYKJDHKYXBELHTYPJQNFXFDYKZH"
+ + "QKZBYJTZBXHFDXKDASWTAWAJLDYJSFHBLDNNTNQJTJNCHXFJSRFWHZFMDRYJYJWZPDJKZYJYMPCYZNYNXFBYTFYFWYGDBNZZZDNYTXZEMMQBSQEHXFZMBMFLZZSRXYMJGSXWZJSPRYDJSJGXHJJGLJJYNZZJXHGXKYMLPYYYCXYTWQZSWHWLYRJLPXSLSXMFSWWKLCTNXNYNPSJ"
+ + "SZHDZEPTXMYYWXYYSYWLXJQZQXZDCLEEELMCPJPCLWBXSQHFWWTFFJTNQJHJQDXHWLBYZNFJLALKYYJLDXHHYCSTYYWNRJYXYWTRMDRQHWQCMFJDYZMHMYYXJWMYZQZXTLMRSPWWCHAQBXYGZYPXYYRRCLMPYMGKSJSZYSRMYJSNXTPLNBAPPYPYLXYYZKYNLDZYJZCZNNLMZHH"
+ + "ARQMPGWQTZMXXMLLHGDZXYHXKYXYCJMFFYYHJFSBSSQLXXNDYCANNMTCJCYPRRNYTYQNYYMBMSXNDLYLYSLJRLXYSXQMLLYZLZJJJKYZZCSFBZXXMSTBJGNXYZHLXNMCWSCYZYFZLXBRNNNYLBNRTGZQYSATSWRYHYJZMZDHZGZDWYBSSCSKXSYHYTXXGCQGXZZSHYXJSCRHMKK"
+ + "BXCZJYJYMKQHZJFNBHMQHYSNJNZYBKNQMCLGQHWLZNZSWXKHLJHYYBQLBFCDSXDLDSPFZPSKJYZWZXZDDXJSMMEGJSCSSMGCLXXKYYYLNYPWWWGYDKZJGGGZGGSYCKNJWNJPCXBJJTQTJWDSSPJXZXNZXUMELPXFSXTLLXCLJXJJLJZXCTPSWXLYDHLYQRWHSYCSQYYBYAYWJJJ"
+ + "QFWQCQQCJQGXALDBZZYJGKGXPLTZYFXJLTPADKYQHPMATLCPDCKBMTXYBHKLENXDLEEGQDYMSAWHZMLJTWYGXLYQZLJEEYYBQQFFNLYXRDSCTGJGXYYNKLLYQKCCTLHJLQMKKZGCYYGLLLJDZGYDHZWXPYSJBZKDZGYZZHYWYFQYTYZSZYEZZLYMHJJHTSMQWYZLKYYWZCSRKQY"
+ + "TLTDXWCTYJKLWSQZWBDCQYNCJSRSZJLKCDCDTLZZZACQQZZDDXYPLXZBQJYLZLLLQDDZQJYJYJZYXNYYYNYJXKXDAZWYRDLJYYYRJLXLLDYXJCYWYWNQCCLDDNYYYNYCKCZHXXCCLGZQJGKWPPCQQJYSBZZXYJSQPXJPZBSBDSFNSFPZXHDWZTDWPPTFLZZBZDMYYPQJRSDZSQZ"
+ + "SQXBDGCPZSWDWCSQZGMDHZXMWWFYBPDGPHTMJTHZSMMBGZMBZJCFZWFZBBZMQCFMBDMCJXLGPNJBBXGYHYYJGPTZGZMQBQTCGYXJXLWZKYDPDYMGCFTPFXYZTZXDZXTGKMTYBBCLBJASKYTSSQYYMSZXFJEWLXLLSZBQJJJAKLYLXLYCCTSXMCWFKKKBSXLLLLJYXTYLTJYYTDP"
+ + "JHNHNNKBYQNFQYYZBYYESSESSGDYHFHWTCJBSDZZTFDMXHCNJZYMQWSRYJDZJQPDQBBSTJGGFBKJBXTGQHNGWJXJGDLLTHZHHYYYYYYSXWTYYYCCBDBPYPZYCCZYJPZYWCBDLFWZCWJDXXHYHLHWZZXJTCZLCDPXUJCZZZLYXJJTXPHFXWPYWXZPTDZZBDZCYHJHMLXBQXSBYLR"
+ + "DTGJRRCTTTHYTCZWMXFYTWWZCWJWXJYWCSKYBZSCCTZQNHXNWXXKHKFHTSWOCCJYBCMPZZYKBNNZPBZHHZDLSYDDYTYFJPXYNGFXBYQXCBHXCPSXTYZDMKYSNXSXLHKMZXLYHDHKWHXXSSKQYHHCJYXGLHZXCSNHEKDTGZXQYPKDHEXTYKCNYMYYYPKQYYYKXZLTHJQTBYQHXBM"
+ + "YHSQCKWWYLLHCYYLNNEQXQWMCFBDCCMLJGGXDQKTLXKGNQCDGZJWYJJLYHHQTTTNWCHMXCXWHWSZJYDJCCDBQCDGDNYXZTHCQRXCBHZTQCBXWGQWYYBXHMBYMYQTYEXMQKYAQYRGYZSLFYKKQHYSSQYSHJGJCNXKZYCXSBXYXHYYLSTYCXQTHYSMGSCPMMGCCCCCMTZTASMGQZJ"
+ + "HKLOSQYLSWTMXSYQKDZLJQQYPLSYCZTCQQPBBQJZCLPKHQZYYXXDTDDTSJCXFFLLCHQXMJLWCJCXTSPYCXNDTJSHJWXDQQJSKXYAMYLSJHMLALYKXCYYDMNMDQMXMCZNNCYBZKKYFLMCHCMLHXRCJJHSYLNMTJZGZGYWJXSRXCWJGJQHQZDQJDCJJZKJKGDZQGJJYJYLXZXXCDQ"
+ + "HHHEYTMHLFSBDJSYYSHFYSTCZQLPBDRFRZTZYKYWHSZYQKWDQZRKMSYNBCRXQBJYFAZPZZEDZCJYWBCJWHYJBQSZYWRYSZPTDKZPFPBNZTKLQYHBBZPNPPTYZZYBQNYDCPJMMCYCQMCYFZZDCMNLFPBPLNGQJTBTTNJZPZBBZNJKLJQYLNBZQHKSJZNGGQSZZKYXSHPZSNBCGZK"
+ + "DDZQANZHJKDRTLZLSWJLJZLYWTJNDJZJHXYAYNCBGTZCSSQMNJPJYTYSWXZFKWJQTKHTZPLBHSNJZSYZBWZZZZLSYLSBJHDWWQPSLMMFBJDWAQYZTCJTBNNWZXQXCDSLQGDSDPDZHJTQQPSWLYYJZLGYXYZLCTCBJTKTYCZJTQKBSJLGMGZDMCSGPYNJZYQYYKNXRPWSZXMTNCS"
+ + "ZZYXYBYHYZAXYWQCJTLLCKJJTJHGDXDXYQYZZBYWDLWQCGLZGJGQRQZCZSSBCRPCSKYDZNXJSQGXSSJMYDNSTZTPBDLTKZWXQWQTZEXNQCZGWEZKSSBYBRTSSSLCCGBPSZQSZLCCGLLLZXHZQTHCZMQGYZQZNMCOCSZJMMZSQPJYGQLJYJPPLDXRGZYXCCSXHSHGTZNLZWZKJCX"
+ + "TCFCJXLBMQBCZZWPQDNHXLJCTHYZLGYLNLSZZPCXDSCQQHJQKSXZPBAJYEMSMJTZDXLCJYRYYNWJBNGZZTMJXLTBSLYRZPYLSSCNXPHLLHYLLQQZQLXYMRSYCXZLMMCZLTZSDWTJJLLNZGGQXPFSKYGYGHBFZPDKMWGHCXMSGDXJMCJZDYCABXJDLNBCDQYGSKYDQTXDJJYXMSZ"
+ + "QAZDZFSLQXYJSJZYLBTXXWXQQZBJZUFBBLYLWDSLJHXJYZJWTDJCZFQZQZZDZSXZZQLZCDZFJHYSPYMPQZMLPPLFFXJJNZZYLSJEYQZFPFZKSYWJJJHRDJZZXTXXGLGHYDXCSKYSWMMZCWYBAZBJKSHFHJCXMHFQHYXXYZFTSJYZFXYXPZLCHMZMBXHZZSXYFYMNCWDABAZLXKT"
+ + "CSHHXKXJJZJSTHYGXSXYYHHHJWXKZXSSBZZWHHHCWTZZZPJXSNXQQJGZYZYWLLCWXZFXXYXYHXMKYYSWSQMNLNAYCYSPMJKHWCQHYLAJJMZXHMMCNZHBHXCLXTJPLTXYJHDYYLTTXFSZHYXXSJBJYAYRSMXYPLCKDUYHLXRLNLLSTYZYYQYGYHHSCCSMZCTZQXKYQFPYYRPFFLK"
+ + "QUNTSZLLZMWWTCQQYZWTLLMLMPWMBZSSTZRBPDDTLQJJBXZCSRZQQYGWCSXFWZLXCCRSZDZMCYGGDZQSGTJSWLJMYMMZYHFBJDGYXCCPSHXNZCSBSJYJGJMPPWAFFYFNXHYZXZYLREMZGZCYZSSZDLLJCSQFNXZKPTXZGXJJGFMYYYSNBTYLBNLHPFZDCYFBMGQRRSSSZXYSGTZ"
+ + "RNYDZZCDGPJAFJFZKNZBLCZSZPSGCYCJSZLMLRSZBZZLDLSLLYSXSQZQLYXZLSKKBRXBRBZCYCXZZZEEYFGKLZLYYHGZSGZLFJHGTGWKRAAJYZKZQTSSHJJXDCYZUYJLZYRZDQQHGJZXSSZBYKJPBFRTJXLLFQWJHYLQTYMBLPZDXTZYGBDHZZRBGXHWNJTJXLKSCFSMWLSDQYS"
+ + "JTXKZSCFWJLBXFTZLLJZLLQBLSQMQQCGCZFPBPHZCZJLPYYGGDTGWDCFCZQYYYQYSSCLXZSKLZZZGFFCQNWGLHQYZJJCZLQZZYJPJZZBPDCCMHJGXDQDGDLZQMFGPSYTSDYFWWDJZJYSXYYCZCYHZWPBYKXRYLYBHKJKSFXTZJMMCKHLLTNYYMSYXYZPYJQYCSYCWMTJJKQYRHL"
+ + "LQXPSGTLYYCLJSCPXJYZFNMLRGJJTYZBXYZMSJYJHHFZQMSYXRSZCWTLRTQZSSTKXGQKGSPTGCZNJSJCQCXHMXGGZTQYDJKZDLBZSXJLHYQGGGTHQSZPYHJHHGYYGKGGCWJZZYLCZLXQSFTGZSLLLMLJSKCTBLLZZSZMMNYTPZSXQHJCJYQXYZXZQZCPSHKZZYSXCDFGMWQRLLQ"
+ + "XRFZTLYSTCTMJCXJJXHJNXTNRZTZFQYHQGLLGCXSZSJDJLJCYDSJTLNYXHSZXCGJZYQPYLFHDJSBPCCZHJJJQZJQDYBSSLLCMYTTMQTBHJQNNYGKYRQYQMZGCJKPDCGMYZHQLLSLLCLMHOLZGDYYFZSLJCQZLYLZQJESHNYLLJXGJXLYSYYYXNBZLJSSZCQQCJYLLZLTJYLLZLL"
+ + "BNYLGQCHXYYXOXCXQKYJXXXYKLXSXXYQXCYKQXQCSGYXXYQXYGYTQOHXHXPYXXXULCYEYCHZZCBWQBBWJQZSCSZSSLZYLKDESJZWMYMCYTSDSXXSCJPQQSQYLYYZYCMDJDZYWCBTJSYDJKCYDDJLBDJJSODZYSYXQQYXDHHGQQYQHDYXWGMMMAJDYBBBPPBCMUUPLJZSMTXERXJ"
+ + "MHQNUTPJDCBSSMSSSTKJTSSMMTRCPLZSZMLQDSDMJMQPNQDXCFYNBFSDQXYXHYAYKQYDDLQYYYSSZBYDSLNTFQTZQPZMCHDHCZCWFDXTMYQSPHQYYXSRGJCWTJTZZQMGWJJTJHTQJBBHWZPXXHYQFXXQYWYYHYSCDYDHHQMNMTMWCPBSZPPZZGLMZFOLLCFWHMMSJZTTDHZZYFF"
+ + "YTZZGZYSKYJXQYJZQBHMBZZLYGHGFMSHPZFZSNCLPBQSNJXZSLXXFPMTYJYGBXLLDLXPZJYZJYHHZCYWHJYLSJEXFSZZYWXKZJLUYDTMLYMQJPWXYHXSKTQJEZRPXXZHHMHWQPWQLYJJQJJZSZCPHJLCHHNXJLQWZJHBMZYXBDHHYPZLHLHLGFWLCHYYTLHJXCJMSCPXSTKPNHQ"
+ + "XSRTYXXTESYJCTLSSLSTDLLLWWYHDHRJZSFGXTSYCZYNYHTDHWJSLHTZDQDJZXXQHGYLTZPHCSQFCLNJTCLZPFSTPDYNYLGMJLLYCQHYSSHCHYLHQYQTMZYPBYWRFQYKQSYSLZDQJMPXYYSSRHZJNYWTQDFZBWWTWWRXCWHGYHXMKMYYYQMSMZHNGCEPMLQQMTCWCTMMPXJPJJH"
+ + "FXYYZSXZHTYBMSTSYJTTQQQYYLHYNPYQZLCYZHZWSMYLKFJXLWGXYPJYTYSYXYMZCKTTWLKSMZSYLMPWLZWXWQZSSAQSYXYRHSSNTSRAPXCPWCMGDXHXZDZYFJHGZTTSBJHGYZSZYSMYCLLLXBTYXHBBZJKSSDMALXHYCFYGMQYPJYCQXJLLLJGSLZGQLYCJCCZOTYXMTMTTLLW"
+ + "TGPXYMZMKLPSZZZXHKQYSXCTYJZYHXSHYXZKXLZWPSQPYHJWPJPWXQQYLXSDHMRSLZZYZWTTCYXYSZZSHBSCCSTPLWSSCJCHNLCGCHSSPHYLHFHHXJSXYLLNYLSZDHZXYLSXLWZYKCLDYAXZCMDDYSPJTQJZLNWQPSSSWCTSTSZLBLNXSMNYYMJQBQHRZWTYYDCHQLXKPZWBGQY"
+ + "BKFCMZWPZLLYYLSZYDWHXPSBCMLJBSCGBHXLQHYRLJXYSWXWXZSLDFHLSLYNJLZYFLYJYCDRJLFSYZFSLLCQYQFGJYHYXZLYLMSTDJCYHBZLLNWLXXYGYYHSMGDHXXHHLZZJZXCZZZCYQZFNGWPYLCPKPYYPMCLQKDGXZGGWQBDXZZKZFBXXLZXJTPJPTTBYTSZZDWSLCHZHSLT"
+ + "YXHQLHYXXXYYZYSWTXZKHLXZXZPYHGCHKCFSYHUTJRLXFJXPTZTWHPLYXFCRHXSHXKYXXYHZQDXQWULHYHMJTBFLKHTXCWHJFWJCFPQRYQXCYYYQYGRPYWSGSUNGWCHKZDXYFLXXHJJBYZWTSXXNCYJJYMSWZJQRMHXZWFQSYLZJZGBHYNSLBGTTCSYBYXXWXYHXYYXNSQYXMQY"
+ + "WRGYQLXBBZLJSYLPSYTJZYHYZAWLRORJMKSCZJXXXYXCHDYXRYXXJDTSQFXLYLTSFFYXLMTYJMJUYYYXLTZCSXQZQHZXLYYXZHDNBRXXXJCTYHLBRLMBRLLAXKYLLLJLYXXLYCRYLCJTGJCMTLZLLCYZZPZPCYAWHJJFYBDYYZSMPCKZDQYQPBPCJPDCYZMDPBCYYDYCNNPLMTM"
+ + "LRMFMMGWYZBSJGYGSMZQQQZTXMKQWGXLLPJGZBQCDJJJFPKJKCXBLJMSWMDTQJXLDLPPBXCWRCQFBFQJCZAHZGMYKPHYYHZYKNDKZMBPJYXPXYHLFPNYYGXJDBKXNXHJMZJXSTRSTLDXSKZYSYBZXJLXYSLBZYSLHXJPFXPQNBYLLJQKYGZMCYZZYMCCSLCLHZFWFWYXZMWSXTY"
+ + "NXJHPYYMCYSPMHYSMYDYSHQYZCHMJJMZCAAGCFJBBHPLYZYLXXSDJGXDHKXXTXXNBHRMLYJSLTXMRHNLXQJXYZLLYSWQGDLBJHDCGJYQYCMHWFMJYBMBYJYJWYMDPWHXQLDYGPDFXXBCGJSPCKRSSYZJMSLBZZJFLJJJLGXZGYXYXLSZQYXBEXYXHGCXBPLDYHWETTWWCJMBTXC"
+ + "HXYQXLLXFLYXLLJLSSFWDPZSMYJCLMWYTCZPCHQEKCQBWLCQYDPLQPPQZQFJQDJHYMMCXTXDRMJWRHXCJZYLQXDYYNHYYHRSLSRSYWWZJYMTLTLLGTQCJZYABTCKZCJYCCQLJZQXALMZYHYWLWDXZXQDLLQSHGPJFJLJHJABCQZDJGTKHSSTCYJLPSWZLXZXRWGLDLZRLZXTGSL"
+ + "LLLZLYXXWGDZYGBDPHZPBRLWSXQBPFDWOFMWHLYPCBJCCLDMBZPBZZLCYQXLDOMZBLZWPDWYYGDSTTHCSQSCCRSSSYSLFYBFNTYJSZDFNDPDHDZZMBBLSLCMYFFGTJJQWFTMTPJWFNLBZCMMJTGBDZLQLPYFHYYMJYLSDCHDZJWJCCTLJCLDTLJJCPDDSQDSSZYBNDBJLGGJZXS"
+ + "XNLYCYBJXQYCBYLZCFZPPGKCXZDZFZTJJFJSJXZBNZYJQTTYJYHTYCZHYMDJXTTMPXSPLZCDWSLSHXYPZGTFMLCJTYCBPMGDKWYCYZCDSZZYHFLYCTYGWHKJYYLSJCXGYWJCBLLCSNDDBTZBSCLYZCZZSSQDLLMQYYHFSLQLLXFTYHABXGWNYWYYPLLSDLDLLBJCYXJZMLHLJDX"
+ + "YYQYTDLLLBUGBFDFBBQJZZMDPJHGCLGMJJPGAEHHBWCQXAXHHHZCHXYPHJAXHLPHJPGPZJQCQZGJJZZUZDMQYYBZZPHYHYBWHAZYJHYKFGDPFQSDLZMLJXKXGALXZDAGLMDGXMWZQYXXDXXPFDMMSSYMPFMDMMKXKSYZYSHDZKXSYSMMZZZMSYDNZZCZXFPLSTMZDNMXCKJMZTY"
+ + "YMZMZZMSXHHDCZJEMXXKLJSTLWLSQLYJZLLZJSSDPPMHNLZJCZYHMXXHGZCJMDHXTKGRMXFWMCGMWKDTKSXQMMMFZZYDKMSCLCMPCGMHSPXQPZDSSLCXKYXTWLWJYAHZJGZQMCSNXYYMMPMLKJXMHLMLQMXCTKZMJQYSZJSYSZHSYJZJCDAJZYBSDQJZGWZQQXFKDMSDJLFWEHK"
+ + "ZQKJPEYPZYSZCDWYJFFMZZYLTTDZZEFMZLBNPPLPLPEPSZALLTYLKCKQZKGENQLWAGYXYDPXLHSXQQWQCQXQCLHYXXMLYCCWLYMQYSKGCHLCJNSZKPYZKCQZQLJPDMDZHLASXLBYDWQLWDNBQCRYDDZTJYBKBWSZDXDTNPJDTCTQDFXQQMGNXECLTTBKPWSLCTYQLPWYZZKLPYG"
+ + "ZCQQPLLKCCYLPQMZCZQCLJSLQZDJXLDDHPZQDLJJXZQDXYZQKZLJCYQDYJPPYPQYKJYRMPCBYMCXKLLZLLFQPYLLLMBSGLCYSSLRSYSQTMXYXZQZFDZUYSYZTFFMZZSMZQHZSSCCMLYXWTPZGXZJGZGSJSGKDDHTQGGZLLBJDZLCBCHYXYZHZFYWXYZYMSDBZZYJGTSMTFXQYXQ"
+ + "STDGSLNXDLRYZZLRYYLXQHTXSRTZNGZXBNQQZFMYKMZJBZYMKBPNLYZPBLMCNQYZZZSJZHJCTZKHYZZJRDYZHNPXGLFZTLKGJTCTSSYLLGZRZBBQZZKLPKLCZYSSUYXBJFPNJZZXCDWXZYJXZZDJJKGGRSRJKMSMZJLSJYWQSKYHQJSXPJZZZLSNSHRNYPZTWCHKLPSRZLZXYJQ"
+ + "XQKYSJYCZTLQZYBBYBWZPQDWWYZCYTJCJXCKCWDKKZXSGKDZXWWYYJQYYTCYTDLLXWKCZKKLCCLZCQQDZLQLCSFQCHQHSFSMQZZLNBJJZBSJHTSZDYSJQJPDLZCDCWJKJZZLPYCGMZWDJJBSJQZSYZYHHXJPBJYDSSXDZNCGLQMBTSFSBPDZDLZNFGFJGFSMPXJQLMBLGQCYYXB"
+ + "QKDJJQYRFKZTJDHCZKLBSDZCFJTPLLJGXHYXZCSSZZXSTJYGKGCKGYOQXJPLZPBPGTGYJZGHZQZZLBJLSQFZGKQQJZGYCZBZQTLDXRJXBSXXPZXHYZYCLWDXJJHXMFDZPFZHQHQMQGKSLYHTYCGFRZGNQXCLPDLBZCSCZQLLJBLHBZCYPZZPPDYMZZSGYHCKCPZJGSLJLNSCDSL"
+ + "DLXBMSTLDDFJMKDJDHZLZXLSZQPQPGJLLYBDSZGQLBZLSLKYYHZTTNTJYQTZZPSZQZTLLJTYYLLQLLQYZQLBDZLSLYYZYMDFSZSNHLXZNCZQZPBWSKRFBSYZMTHBLGJPMCZZLSTLXSHTCSYZLZBLFEQHLXFLCJLYLJQCBZLZJHHSSTBRMHXZHJZCLXFNBGXGTQJCZTMSFZKJMSS"
+ + "NXLJKBHSJXNTNLZDNTLMSJXGZJYJCZXYJYJWRWWQNZTNFJSZPZSHZJFYRDJSFSZJZBJFZQZZHZLXFYSBZQLZSGYFTZDCSZXZJBQMSZKJRHYJZCKMJKHCHGTXKXQGLXPXFXTRTYLXJXHDTSJXHJZJXZWZLCQSBTXWXGXTXXHXFTSDKFJHZYJFJXRZSDLLLTQSQQZQWZXSYQTWGWB"
+ + "ZCGZLLYZBCLMQQTZHZXZXLJFRMYZFLXYSQXXJKXRMQDZDMMYYBSQBHGZMWFWXGMXLZPYYTGZYCCDXYZXYWGSYJYZNBHPZJSQSYXSXRTFYZGRHZTXSZZTHCBFCLSYXZLZQMZLMPLMXZJXSFLBYZMYQHXJSXRXSQZZZSSLYFRCZJRCRXHHZXQYDYHXSJJHZCXZBTYNSYSXJBQLPXZ"
+ + "QPYMLXZKYXLXCJLCYSXXZZLXDLLLJJYHZXGYJWKJRWYHCPSGNRZLFZWFZZNSXGXFLZSXZZZBFCSYJDBRJKRDHHGXJLJJTGXJXXSTJTJXLYXQFCSGSWMSBCTLQZZWLZZKXJMLTMJYHSDDBXGZHDLBMYJFRZFSGCLYJBPMLYSMSXLSZJQQHJZFXGFQFQBPXZGYYQXGZTCQWYLTLGW"
+ + "SGWHRLFSFGZJMGMGBGTJFSYZZGZYZAFLSSPMLPFLCWBJZCLJJMZLPJJLYMQDMYYYFBGYGYZMLYZDXQYXRQQQHSYYYQXYLJTYXFSFSLLGNQCYHYCWFHCCCFXPYLYPLLZYXXXXXKQHHXSHJZCFZSCZJXCPZWHHHHHAPYLQALPQAFYHXDYLUKMZQGGGDDESRNNZLTZGCHYPPYSQJJH"
+ + "CLLJTOLNJPZLJLHYMHEYDYDSQYCDDHGZUNDZCLZYZLLZNTNYZGSLHSLPJJBDGWXPCDUTJCKLKCLWKLLCASSTKZZDNQNTTLYYZSSYSSZZRYLJQKCQDHHCRXRZYDGRGCWCGZQFFFPPJFZYNAKRGYWYQPQXXFKJTSZZXSWZDDFBBXTBGTZKZNPZZPZXZPJSZBMQHKCYXYLDKLJNYPK"
+ + "YGHGDZJXXEAHPNZKZTZCMXCXMMJXNKSZQNMNLWBWWXJKYHCPSTMCSQTZJYXTPCTPDTNNPGLLLZSJLSPBLPLQHDTNJNLYYRSZFFJFQWDPHZDWMRZCCLODAXNSSNYZRESTYJWJYJDBCFXNMWTTBYLWSTSZGYBLJPXGLBOCLHPCBJLTMXZLJYLZXCLTPNCLCKXTPZJSWCYXSFYSZDK"
+ + "NTLBYJCYJLLSTGQCBXRYZXBXKLYLHZLQZLNZCXWJZLJZJNCJHXMNZZGJZZXTZJXYCYYCXXJYYXJJXSSSJSTSSTTPPGQTCSXWZDCSYFPTFBFHFBBLZJCLZZDBXGCXLQPXKFZFLSYLTUWBMQJHSZBMDDBCYSCCLDXYCDDQLYJJWMQLLCSGLJJSYFPYYCCYLTJANTJJPWYCMMGQYYS"
+ + "XDXQMZHSZXPFTWWZQSWQRFKJLZJQQYFBRXJHHFWJJZYQAZMYFRHCYYBYQWLPEXCCZSTYRLTTDMQLYKMBBGMYYJPRKZNPBSXYXBHYZDJDNGHPMFSGMWFZMFQMMBCMZZCJJLCNUXYQLMLRYGQZCYXZLWJGCJCGGMCJNFYZZJHYCPRRCMTZQZXHFQGTJXCCJEAQCRJYHPLQLSZDJRB"
+ + "CQHQDYRHYLYXJSYMHZYDWLDFRYHBPYDTSSCNWBXGLPZMLZZTQSSCPJMXXYCSJYTYCGHYCJWYRXXLFEMWJNMKLLSWTXHYYYNCMMCWJDQDJZGLLJWJRKHPZGGFLCCSCZMCBLTBHBQJXQDSPDJZZGKGLFQYWBZYZJLTSTDHQHCTCBCHFLQMPWDSHYYTQWCNZZJTLBYMBPDYYYXSQKX"
+ + "WYYFLXXNCWCXYPMAELYKKJMZZZBRXYYQJFLJPFHHHYTZZXSGQQMHSPGDZQWBWPJHZJDYSCQWZKTXXSQLZYYMYSDZGRXCKKUJLWPYSYSCSYZLRMLQSYLJXBCXTLWDQZPCYCYKPPPNSXFYZJJRCEMHSZMSXLXGLRWGCSTLRSXBZGBZGZTCPLUJLSLYLYMTXMTZPALZXPXJTJWTCYY"
+ + "ZLBLXBZLQMYLXPGHDSLSSDMXMBDZZSXWHAMLCZCPJMCNHJYSNSYGCHSKQMZZQDLLKABLWJXSFMOCDXJRRLYQZKJMYBYQLYHETFJZFRFKSRYXFJTWDSXXSYSQJYSLYXWJHSNLXYYXHBHAWHHJZXWMYLJCSSLKYDZTXBZSYFDXGXZJKHSXXYBSSXDPYNZWRPTQZCZENYGCXQFJYKJ"
+ + "BZMLJCMQQXUOXSLYXXLYLLJDZBTYMHPFSTTQQWLHOKYBLZZALZXQLHZWRRQHLSTMYPYXJJXMQSJFNBXYXYJXXYQYLTHYLQYFMLKLJTMLLHSZWKZHLJMLHLJKLJSTLQXYLMBHHLNLZXQJHXCFXXLHYHJJGBYZZKBXSCQDJQDSUJZYYHZHHMGSXCSYMXFEBCQWWRBPYYJQTYZCYQY"
+ + "QQZYHMWFFHGZFRJFCDPXNTQYZPDYKHJLFRZXPPXZDBBGZQSTLGDGYLCQMLCHHMFYWLZYXKJLYPQHSYWMQQGQZMLZJNSQXJQSYJYCBEHSXFSZPXZWFLLBCYYJDYTDTHWZSFJMQQYJLMQXXLLDTTKHHYBFPWTYYSQQWNQWLGWDEBZWCMYGCULKJXTMXMYJSXHYBRWFYMWFRXYQMXY"
+ + "SZTZZTFYKMLDHQDXWYYNLCRYJBLPSXCXYWLSPRRJWXHQYPHTYDNXHHMMYWYTZCSQMTSSCCDALWZTCPQPYJLLQZYJSWXMZZMMYLMXCLMXCZMXMZSQTZPPQQBLPGXQZHFLJJHYTJSRXWZXSCCDLXTYJDCQJXSLQYCLZXLZZXMXQRJMHRHZJBHMFLJLMLCLQNLDXZLLLPYPSYJYSXC"
+ + "QQDCMQJZZXHNPNXZMEKMXHYKYQLXSXTXJYYHWDCWDZHQYYBGYBCYSCFGPSJNZDYZZJZXRZRQJJYMCANYRJTLDPPYZBSTJKXXZYPFDWFGZZRPYMTNGXZQBYXNBUFNQKRJQZMJEGRZGYCLKXZDSKKNSXKCLJSPJYYZLQQJYBZSSQLLLKJXTBKTYLCCDDBLSPPFYLGYDTZJYQGGKQT"
+ + "TFZXBDKTYYHYBBFYTYYBCLPDYTGDHRYRNJSPTCSNYJQHKLLLZSLYDXXWBCJQSPXBPJZJCJDZFFXXBRMLAZHCSNDLBJDSZBLPRZTSWSBXBCLLXXLZDJZSJPYLYXXYFTFFFBHJJXGBYXJPMMMPSSJZJMTLYZJXSWXTYLEDQPJMYGQZJGDJLQJWJQLLSJGJGYGMSCLJJXDTYGJQJQJ"
+ + "CJZCJGDZZSXQGSJGGCXHQXSNQLZZBXHSGZXCXYLJXYXYYDFQQJHJFXDHCTXJYRXYSQTJXYEFYYSSYYJXNCYZXFXMSYSZXYYSCHSHXZZZGZZZGFJDLTYLNPZGYJYZYYQZPBXQBDZTZCZYXXYHHSQXSHDHGQHJHGYWSZTMZMLHYXGEBTYLZKQWYTJZRCLEKYSTDBCYKQQSAYXCJXW"
+ + "WGSBHJYZYDHCSJKQCXSWXFLTYNYZPZCCZJQTZWJQDZZZQZLJJXLSBHPYXXPSXSHHEZTXFPTLQYZZXHYTXNCFZYYHXGNXMYWXTZSJPTHHGYMXMXQZXTSBCZYJYXXTYYZYPCQLMMSZMJZZLLZXGXZAAJZYXJMZXWDXZSXZDZXLEYJJZQBHZWZZZQTZPSXZTDSXJJJZNYAZPHXYYSR"
+ + "NQDTHZHYYKYJHDZXZLSWCLYBZYECWCYCRYLCXNHZYDZYDYJDFRJJHTRSQTXYXJRJHOJYNXELXSFSFJZGHPZSXZSZDZCQZBYYKLSGSJHCZSHDGQGXYZGXCHXZJWYQWGYHKSSEQZZNDZFKWYSSTCLZSTSYMCDHJXXYWEYXCZAYDMPXMDSXYBSQMJMZJMTZQLPJYQZCGQHXJHHLXXH"
+ + "LHDLDJQCLDWBSXFZZYYSCHTYTYYBHECXHYKGJPXHHYZJFXHWHBDZFYZBCAPNPGNYDMSXHMMMMAMYNBYJTMPXYYMCTHJBZYFCGTYHWPHFTWZZEZSBZEGPFMTSKFTYCMHFLLHGPZJXZJGZJYXZSBBQSCZZLZCCSTPGXMJSFTCCZJZDJXCYBZLFCJSYZFGSZLYBCWZZBYZDZYPSWYJ"
+ + "ZXZBDSYUXLZZBZFYGCZXBZHZFTPBGZGEJBSTGKDMFHYZZJHZLLZZGJQZLSFDJSSCBZGPDLFZFZSZYZYZSYGCXSNXXCHCZXTZZLJFZGQSQYXZJQDCCZTQCDXZJYQJQCHXZTDLGSCXZSYQJQTZWLQDQZTQCHQQJZYEZZZPBWKDJFCJPZTYPQYQTTYNLMBDKTJZPQZQZZFPZSBNJLG"
+ + "YJDXJDZZKZGQKXDLPZJTCJDQBXDJQJSTCKNXBXZMSLYJCQMTJQWWCJQNJNLLLHJCWQTBZQYDZCZPZZDZYDDCYZZZCCJTTJFZDPRRTZTJDCQTQZDTJNPLZBCLLCTZSXKJZQZPZLBZRBTJDCXFCZDBCCJJLTQQPLDCGZDBBZJCQDCJWYNLLZYZCCDWLLXWZLXRXNTQQCZXKQLSGDF"
+ + "QTDDGLRLAJJTKUYMKQLLTZYTDYYCZGJWYXDXFRSKSTQTENQMRKQZHHQKDLDAZFKYPBGGPZREBZZYKZZSPEGJXGYKQZZZSLYSYYYZWFQZYLZZLZHWCHKYPQGNPGBLPLRRJYXCCSYYHSFZFYBZYYTGZXYLXCZWXXZJZBLFFLGSKHYJZEYJHLPLLLLCZGXDRZELRHGKLZZYHZLYQSZ"
+ + "ZJZQLJZFLNBHGWLCZCFJYSPYXZLZLXGCCPZBLLCYBBBBUBBCBPCRNNZCZYRBFSRLDCGQYYQXYGMQZWTZYTYJXYFWTEHZZJYWLCCNTZYJJZDEDPZDZTSYQJHDYMBJNYJZLXTSSTPHNDJXXBYXQTZQDDTJTDYYTGWSCSZQFLSHLGLBCZPHDLYZJYCKWTYTYLBNYTSDSYCCTYSZYYE"
+ + "BHEXHQDTWNYGYCLXTSZYSTQMYGZAZCCSZZDSLZCLZRQXYYELJSBYMXSXZTEMBBLLYYLLYTDQYSHYMRQWKFKBFXNXSBYCHXBWJYHTQBPBSBWDZYLKGZSKYHXQZJXHXJXGNLJKZLYYCDXLFYFGHLJGJYBXQLYBXQPQGZTZPLNCYPXDJYQYDYMRBESJYYHKXXSTMXRCZZYWXYQYBMC"
+ + "LLYZHQYZWQXDBXBZWZMSLPDMYSKFMZKLZCYQYCZLQXFZZYDQZPZYGYJYZMZXDZFYFYTTQTZHGSPCZMLCCYTZXJCYTJMKSLPZHYSNZLLYTPZCTZZCKTXDHXXTQCYFKSMQCCYYAZHTJPCYLZLYJBJXTPNYLJYYNRXSYLMMNXJSMYBCSYSYLZYLXJJQYLDZLPQBFZZBLFNDXQKCZFY"
+ + "WHGQMRDSXYCYTXNQQJZYYPFZXDYZFPRXEJDGYQBXRCNFYYQPGHYJDYZXGRHTKYLNWDZNTSMPKLBTHBPYSZBZTJZSZZJTYYXZPHSSZZBZCZPTQFZMYFLYPYBBJQXZMXXDJMTSYSKKBJZXHJCKLPSMKYJZCXTMLJYXRZZQSLXXQPYZXMKYXXXJCLJPRMYYGADYSKQLSNDHYZKQXZY"
+ + "ZTCGHZTLMLWZYBWSYCTBHJHJFCWZTXWYTKZLXQSHLYJZJXTMPLPYCGLTBZZTLZJCYJGDTCLKLPLLQPJMZPAPXYZLKKTKDZCZZBNZDYDYQZJYJGMCTXLTGXSZLMLHBGLKFWNWZHDXUHLFMKYSLGXDTWWFRJEJZTZHYDXYKSHWFZCQSHKTMQQHTZHYMJDJSKHXZJZBZZXYMPAGQMS"
+ + "TPXLSKLZYNWRTSQLSZBPSPSGZWYHTLKSSSWHZZLYYTNXJGMJSZSUFWNLSOZTXGXLSAMMLBWLDSZYLAKQCQCTMYCFJBSLXCLZZCLXXKSBZQCLHJPSQPLSXXCKSLNHPSFQQYTXYJZLQLDXZQJZDYYDJNZPTUZDSKJFSLJHYLZSQZLBTXYDGTQFDBYAZXDZHZJNHHQBYKNXJJQCZML"
+ + "LJZKSPLDYCLBBLXKLELXJLBQYCXJXGCNLCQPLZLZYJTZLJGYZDZPLTQCSXFDMNYCXGBTJDCZNBGBQYQJWGKFHTNPYQZQGBKPBBYZMTJDYTBLSQMPSXTBNPDXKLEMYYCJYNZCTLDYKZZXDDXHQSHDGMZSJYCCTAYRZLPYLTLKXSLZCGGEXCLFXLKJRTLQJAQZNCMBYDKKCXGLCZJ"
+ + "ZXJHPTDJJMZQYKQSECQZDSHHADMLZFMMZBGNTJNNLGBYJBRBTMLBYJDZXLCJLPLDLPCQDHLXZLYCBLCXZZJADJLNZMMSSSMYBHBSQKBHRSXXJMXSDZNZPXLGBRHWGGFCXGMSKLLTSJYYCQLTSKYWYYHYWXBXQYWPYWYKQLSQPTNTKHQCWDQKTWPXXHCPTHTWUMSSYHBWCRWXHJM"
+ + "KMZNGWTMLKFGHKJYLSYYCXWHYECLQHKQHTTQKHFZLDXQWYZYYDESBPKYRZPJFYYZJCEQDZZDLATZBBFJLLCXDLMJSSXEGYGSJQXCWBXSSZPDYZCXDNYXPPZYDLYJCZPLTXLSXYZYRXCYYYDYLWWNZSAHJSYQYHGYWWAXTJZDAXYSRLTDPSSYYFNEJDXYZHLXLLLZQZSJNYQYQQX"
+ + "YJGHZGZCYJCHZLYCDSHWSHJZYJXCLLNXZJJYYXNFXMWFPYLCYLLABWDDHWDXJMCXZTZPMLQZHSFHZYNZTLLDYWLSLXHYMMYLMBWWKYXYADTXYLLDJPYBPWUXJMWMLLSAFDLLYFLBHHHBQQLTZJCQJLDJTFFKMMMBYTHYGDCQRDDWRQJXNBYSNWZDBYYTBJHPYBYTTJXAAHGQDQT"
+ + "MYSTQXKBTZPKJLZRBEQQSSMJJBDJOTGTBXPGBKTLHQXJJJCTHXQDWJLWRFWQGWSHCKRYSWGFTGYGBXSDWDWRFHWYTJJXXXJYZYSLPYYYPAYXHYDQKXSHXYXGSKQHYWFDDDPPLCJLQQEEWXKSYYKDYPLTJTHKJLTCYYHHJTTPLTZZCDLTHQKZXQYSTEEYWYYZYXXYYSTTJKLLPZM"
+ + "CYHQGXYHSRMBXPLLNQYDQHXSXXWGDQBSHYLLPJJJTHYJKYPPTHYYKTYEZYENMDSHLCRPQFDGFXZPSFTLJXXJBSWYYSKSFLXLPPLBBBLBSFXFYZBSJSSYLPBBFFFFSSCJDSTZSXZRYYSYFFSYZYZBJTBCTSBSDHRTJJBYTCXYJEYLXCBNEBJDSYXYKGSJZBXBYTFZWGENYHHTHZH"
+ + "HXFWGCSTBGXKLSXYWMTMBYXJSTZSCDYQRCYTWXZFHMYMCXLZNSDJTTTXRYCFYJSBSDYERXJLJXBBDEYNJGHXGCKGSCYMBLXJMSZNSKGXFBNBPTHFJAAFXYXFPXMYPQDTZCXZZPXRSYWZDLYBBKTYQPQJPZYPZJZNJPZJLZZFYSBTTSLMPTZRTDXQSJEHBZYLZDHLJSQMLHTXTJE"
+ + "CXSLZZSPKTLZKQQYFSYGYWPCPQFHQHYTQXZKRSGTTSQCZLPTXCDYYZXSQZSLXLZMYCPCQBZYXHBSXLZDLTCDXTYLZJYYZPZYZLTXJSJXHLPMYTXCQRBLZSSFJZZTNJYTXMYJHLHPPLCYXQJQQKZZSCPZKSWALQSBLCCZJSXGWWWYGYKTJBBZTDKHXHKGTGPBKQYSLPXPJCKBMLL"
+ + "XDZSTBKLGGQKQLSBKKTFXRMDKBFTPZFRTBBRFERQGXYJPZSSTLBZTPSZQZSJDHLJQLZBPMSMMSXLQQNHKNBLRDDNXXDHDDJCYYGYLXGZLXSYGMQQGKHBPMXYXLYTQWLWGCPBMQXCYZYDRJBHTDJYHQSHTMJSBYPLWHLZFFNYPMHXXHPLTBQPFBJWQDBYGPNZTPFZJGSDDTQSHZE"
+ + "AWZZYLLTYYBWJKXXGHLFKXDJTMSZSQYNZGGSWQSPHTLSSKMCLZXYSZQZXNCJDQGZDLFNYKLJCJLLZLMZZNHYDSSHTHZZLZZBBHQZWWYCRZHLYQQJBEYFXXXWHSRXWQHWPSLMSSKZTTYGYQQWRSLALHMJTQJSMXQBJJZJXZYZKXBYQXBJXSHZTSFJLXMXZXFGHKZSZGGYLCLSARJ"
+ + "YHSLLLMZXELGLXYDJYTLFBHBPNLYZFBBHPTGJKWETZHKJJXZXXGLLJLSTGSHJJYQLQZFKCGNNDJSSZFDBCTWWSEQFHQJBSAQTGYPQLBXBMMYWXGSLZHGLZGQYFLZBYFZJFRYSFMBYZHQGFWZSYFYJJPHZBYYZFFWODGRLMFTWLBZGYCQXCDJYGZYYYYTYTYDWEGAZYHXJLZYYHL"
+ + "RMGRXXZCLHNELJJTJTPWJYBJJBXJJTJTEEKHWSLJPLPSFYZPQQBDLQJJTYYQLYZKDKSQJYYQZLDQTGJQYZJSUCMRYQTHTEJMFCTYHYPKMHYZWJDQFHYYXWSHCTXRLJHQXHCCYYYJLTKTTYTMXGTCJTZAYYOCZLYLBSZYWJYTSJYHBYSHFJLYGJXXTMZYYLTXXYPZLXYJZYZYYPN"
+ + "HMYMDYYLBLHLSYYQQLLNJJYMSOYQBZGDLYXYLCQYXTSZEGXHZGLHWBLJHEYXTWQMAKBPQCGYSHHEGQCMWYYWLJYJHYYZLLJJYLHZYHMGSLJLJXCJJYCLYCJPCPZJZJMMYLCQLNQLJQJSXYJMLSZLJQLYCMMHCFMMFPQQMFYLQMCFFQMMMMHMZNFHHJGTTHHKHSLNCHHYQDXTMMQ"
+ + "DCYZYXYQMYQYLTDCYYYZAZZCYMZYDLZFFFMMYCQZWZZMABTBYZTDMNZZGGDFTYPCGQYTTSSFFWFDTZQSSYSTWXJHXYTSXXYLBYQHWWKXHZXWZNNZZJZJJQJCCCHYYXBZXZCYZTLLCQXYNJYCYYCYNZZQYYYEWYCZDCJYCCHYJLBTZYYCQWMPWPYMLGKDLDLGKQQBGYCHJXY";
+
+ //此处收录了375个多音字,数据来自于http://www.51window.net/page/pinyin
+ var oMultiDiff = {
+ "19969": "DZ",
+ "19975": "WM",
+ "19988": "QJ",
+ "20048": "YL",
+ "20056": "SC",
+ "20060": "NM",
+ "20094": "QG",
+ "20127": "QJ",
+ "20167": "QC",
+ "20193": "YG",
+ "20250": "KH",
+ "20256": "ZC",
+ "20282": "SC",
+ "20285": "QJG",
+ "20291": "TD",
+ "20314": "YD",
+ "20340": "NE",
+ "20375": "TD",
+ "20389": "YJ",
+ "20391": "CZ",
+ "20415": "PB",
+ "20446": "YS",
+ "20447": "SQ",
+ "20504": "TC",
+ "20608": "KG",
+ "20854": "QJ",
+ "20857": "ZC",
+ "20911": "PF",
+ "20504": "TC",
+ "20608": "KG",
+ "20854": "QJ",
+ "20857": "ZC",
+ "20911": "PF",
+ "20985": "AW",
+ "21032": "PB",
+ "21048": "XQ",
+ "21049": "SC",
+ "21089": "YS",
+ "21119": "JC",
+ "21242": "SB",
+ "21273": "SC",
+ "21305": "YP",
+ "21306": "QO",
+ "21330": "ZC",
+ "21333": "SDC",
+ "21345": "QK",
+ "21378": "CA",
+ "21397": "SC",
+ "21414": "XS",
+ "21442": "SC",
+ "21477": "JG",
+ "21480": "TD",
+ "21484": "ZS",
+ "21494": "YX",
+ "21505": "YX",
+ "21512": "HG",
+ "21523": "XH",
+ "21537": "PB",
+ "21542": "PF",
+ "21549": "KH",
+ "21571": "E",
+ "21574": "DA",
+ "21588": "TD",
+ "21589": "O",
+ "21618": "ZC",
+ "21621": "KHA",
+ "21632": "ZJ",
+ "21654": "KG",
+ "21679": "LKG",
+ "21683": "KH",
+ "21710": "A",
+ "21719": "YH",
+ "21734": "WOE",
+ "21769": "A",
+ "21780": "WN",
+ "21804": "XH",
+ "21834": "A",
+ "21899": "ZD",
+ "21903": "RN",
+ "21908": "WO",
+ "21939": "ZC",
+ "21956": "SA",
+ "21964": "YA",
+ "21970": "TD",
+ "22003": "A",
+ "22031": "JG",
+ "22040": "XS",
+ "22060": "ZC",
+ "22066": "ZC",
+ "22079": "MH",
+ "22129": "XJ",
+ "22179": "XA",
+ "22237": "NJ",
+ "22244": "TD",
+ "22280": "JQ",
+ "22300": "YH",
+ "22313": "XW",
+ "22331": "YQ",
+ "22343": "YJ",
+ "22351": "PH",
+ "22395": "DC",
+ "22412": "TD",
+ "22484": "PB",
+ "22500": "PB",
+ "22534": "ZD",
+ "22549": "DH",
+ "22561": "PB",
+ "22612": "TD",
+ "22771": "KQ",
+ "22831": "HB",
+ "22841": "JG",
+ "22855": "QJ",
+ "22865": "XQ",
+ "23013": "ML",
+ "23081": "WM",
+ "23487": "SX",
+ "23558": "QJ",
+ "23561": "YW",
+ "23586": "YW",
+ "23614": "YW",
+ "23615": "SN",
+ "23631": "PB",
+ "23646": "ZS",
+ "23663": "ZT",
+ "23673": "YG",
+ "23762": "TD",
+ "23769": "ZS",
+ "23780": "QJ",
+ "23884": "QK",
+ "24055": "XH",
+ "24113": "DC",
+ "24162": "ZC",
+ "24191": "GA",
+ "24273": "QJ",
+ "24324": "NL",
+ "24377": "TD",
+ "24378": "QJ",
+ "24439": "PF",
+ "24554": "ZS",
+ "24683": "TD",
+ "24694": "WE",
+ "24733": "LK",
+ "24925": "TN",
+ "25094": "ZG",
+ "25100": "XQ",
+ "25103": "XH",
+ "25153": "PB",
+ "25170": "PB",
+ "25179": "KG",
+ "25203": "PB",
+ "25240": "ZS",
+ "25282": "FB",
+ "25303": "NA",
+ "25324": "KG",
+ "25341": "ZY",
+ "25373": "WZ",
+ "25375": "XJ",
+ "25384": "A",
+ "25457": "A",
+ "25528": "SD",
+ "25530": "SC",
+ "25552": "TD",
+ "25774": "ZC",
+ "25874": "ZC",
+ "26044": "YW",
+ "26080": "WM",
+ "26292": "PB",
+ "26333": "PB",
+ "26355": "ZY",
+ "26366": "CZ",
+ "26397": "ZC",
+ "26399": "QJ",
+ "26415": "ZS",
+ "26451": "SB",
+ "26526": "ZC",
+ "26552": "JG",
+ "26561": "TD",
+ "26588": "JG",
+ "26597": "CZ",
+ "26629": "ZS",
+ "26638": "YL",
+ "26646": "XQ",
+ "26653": "KG",
+ "26657": "XJ",
+ "26727": "HG",
+ "26894": "ZC",
+ "26937": "ZS",
+ "26946": "ZC",
+ "26999": "KJ",
+ "27099": "KJ",
+ "27449": "YQ",
+ "27481": "XS",
+ "27542": "ZS",
+ "27663": "ZS",
+ "27748": "TS",
+ "27784": "SC",
+ "27788": "ZD",
+ "27795": "TD",
+ "27812": "O",
+ "27850": "PB",
+ "27852": "MB",
+ "27895": "SL",
+ "27898": "PL",
+ "27973": "QJ",
+ "27981": "KH",
+ "27986": "HX",
+ "27994": "XJ",
+ "28044": "YC",
+ "28065": "WG",
+ "28177": "SM",
+ "28267": "QJ",
+ "28291": "KH",
+ "28337": "ZQ",
+ "28463": "TL",
+ "28548": "DC",
+ "28601": "TD",
+ "28689": "PB",
+ "28805": "JG",
+ "28820": "QG",
+ "28846": "PB",
+ "28952": "TD",
+ "28975": "ZC",
+ "29100": "A",
+ "29325": "QJ",
+ "29575": "SL",
+ "29602": "FB",
+ "30010": "TD",
+ "30044": "CX",
+ "30058": "PF",
+ "30091": "YSP",
+ "30111": "YN",
+ "30229": "XJ",
+ "30427": "SC",
+ "30465": "SX",
+ "30631": "YQ",
+ "30655": "QJ",
+ "30684": "QJG",
+ "30707": "SD",
+ "30729": "XH",
+ "30796": "LG",
+ "30917": "PB",
+ "31074": "NM",
+ "31085": "JZ",
+ "31109": "SC",
+ "31181": "ZC",
+ "31192": "MLB",
+ "31293": "JQ",
+ "31400": "YX",
+ "31584": "YJ",
+ "31896": "ZN",
+ "31909": "ZY",
+ "31995": "XJ",
+ "32321": "PF",
+ "32327": "ZY",
+ "32418": "HG",
+ "32420": "XQ",
+ "32421": "HG",
+ "32438": "LG",
+ "32473": "GJ",
+ "32488": "TD",
+ "32521": "QJ",
+ "32527": "PB",
+ "32562": "ZSQ",
+ "32564": "JZ",
+ "32735": "ZD",
+ "32793": "PB",
+ "33071": "PF",
+ "33098": "XL",
+ "33100": "YA",
+ "33152": "PB",
+ "33261": "CX",
+ "33324": "BP",
+ "33333": "TD",
+ "33406": "YA",
+ "33426": "WM",
+ "33432": "PB",
+ "33445": "JG",
+ "33486": "ZN",
+ "33493": "TS",
+ "33507": "QJ",
+ "33540": "QJ",
+ "33544": "ZC",
+ "33564": "XQ",
+ "33617": "YT",
+ "33632": "QJ",
+ "33636": "XH",
+ "33637": "YX",
+ "33694": "WG",
+ "33705": "PF",
+ "33728": "YW",
+ "33882": "SR",
+ "34067": "WM",
+ "34074": "YW",
+ "34121": "QJ",
+ "34255": "ZC",
+ "34259": "XL",
+ "34425": "JH",
+ "34430": "XH",
+ "34485": "KH",
+ "34503": "YS",
+ "34532": "HG",
+ "34552": "XS",
+ "34558": "YE",
+ "34593": "ZL",
+ "34660": "YQ",
+ "34892": "XH",
+ "34928": "SC",
+ "34999": "QJ",
+ "35048": "PB",
+ "35059": "SC",
+ "35098": "ZC",
+ "35203": "TQ",
+ "35265": "JX",
+ "35299": "JX",
+ "35782": "SZ",
+ "35828": "YS",
+ "35830": "E",
+ "35843": "TD",
+ "35895": "YG",
+ "35977": "MH",
+ "36158": "JG",
+ "36228": "QJ",
+ "36426": "XQ",
+ "36466": "DC",
+ "36710": "JC",
+ "36711": "ZYG",
+ "36767": "PB",
+ "36866": "SK",
+ "36951": "YW",
+ "37034": "YX",
+ "37063": "XH",
+ "37218": "ZC",
+ "37325": "ZC",
+ "38063": "PB",
+ "38079": "TD",
+ "38085": "QY",
+ "38107": "DC",
+ "38116": "TD",
+ "38123": "YD",
+ "38224": "HG",
+ "38241": "XTC",
+ "38271": "ZC",
+ "38415": "YE",
+ "38426": "KH",
+ "38461": "YD",
+ "38463": "AE",
+ "38466": "PB",
+ "38477": "XJ",
+ "38518": "YT",
+ "38551": "WK",
+ "38585": "ZC",
+ "38704": "XS",
+ "38739": "LJ",
+ "38761": "GJ",
+ "38808": "SQ",
+ "39048": "JG",
+ "39049": "XJ",
+ "39052": "HG",
+ "39076": "CZ",
+ "39271": "XT",
+ "39534": "TD",
+ "39552": "TD",
+ "39584": "PB",
+ "39647": "SB",
+ "39730": "LG",
+ "39748": "TPB",
+ "40109": "ZQ",
+ "40479": "ND",
+ "40516": "HG",
+ "40536": "HG",
+ "40583": "QJ",
+ "40765": "YQ",
+ "40784": "QJ",
+ "40840": "YK",
+ "40863": "QJG"
+ };
+
+ var _checkPYCh = function (ch) {
+ var uni = ch.charCodeAt(0);
+ // 如果不在汉字处理范围之内,返回原字符,也可以调用自己的处理函数
+ if (uni > 40869 || uni < 19968)
+ return ch; // dealWithOthers(ch);
+ return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968)));
+ };
+
+ var _mkPYRslt = function (arr) {
+ var arrRslt = [""], k;
+ for (var i = 0, len = arr.length; i < len; i++) {
+ var str = arr[i];
+ var strlen = str.length;
+ if (strlen == 1) {
+ for (k = 0; k < arrRslt.length; k++) {
+ arrRslt[k] += str;
+ }
+ } else {
+ var tmpArr = arrRslt.slice(0);
+ arrRslt = [];
+ for (k = 0; k < strlen; k++) {
+ // 复制一个相同的arrRslt
+ var tmp = tmpArr.slice(0);
+ // 把当前字符str[k]添加到每个元素末尾
+ for (var j = 0; j < tmp.length; j++) {
+ tmp[j] += str.charAt(k);
+ }
+ // 把复制并修改后的数组连接到arrRslt上
+ arrRslt = arrRslt.concat(tmp);
+ }
+ }
+ }
+ return arrRslt.join("").toLowerCase();
+ };
+
+ _.extend(BI, {
+ makeFirstPY: function (str) {
+ if (typeof (str) != "string")
+ return '' + str;
+ var arrResult = []; // 保存中间结果的数组
+ for (var i = 0, len = str.length; i < len; i++) {
+ // 获得unicode码
+ var ch = str.charAt(i);
+ // 检查该unicode码是否在处理范围之内,在则返回该码对映汉字的拼音首字母,不在则调用其它函数处理
+ arrResult.push(_checkPYCh(ch));
+ }
+ // 处理arrResult,返回所有可能的拼音首字母串数组
+ return _mkPYRslt(arrResult);
+ }
+ });
+})();/**
+ * Detect Element Resize.
+ * Forked in order to guard against unsafe 'window' and 'document' references.
+ *
+ * https://github.com/sdecima/javascript-detect-element-resize
+ * Sebastian Decima
+ *
+ * version: 0.5.3
+ **/
+!(function () {
+ // Check `document` and `window` in case of server-side rendering
+ var _window
+ if (typeof window !== 'undefined') {
+ _window = window
+ } else if (typeof self !== 'undefined') {
+ _window = self
+ } else {
+ _window = this
+ }
+
+ var addEventListener = typeof document !== 'undefined' && document.addEventListener;
+ var stylesCreated = false;
+
+ if (addEventListener) {
+ var requestFrame = (function () {
+ var raf = _window.requestAnimationFrame || _window.mozRequestAnimationFrame || _window.webkitRequestAnimationFrame ||
+ function (fn) {
+ return _window.setTimeout(fn, 20);
+ };
+ return function (fn) {
+ return raf(fn);
+ };
+ })();
+
+ var cancelFrame = (function () {
+ var cancel = _window.cancelAnimationFrame || _window.mozCancelAnimationFrame || _window.webkitCancelAnimationFrame ||
+ _window.clearTimeout;
+ return function (id) {
+ return cancel(id);
+ };
+ })();
+
+ var resetTriggers = function (element) {
+ var triggers = element.__resizeTriggers__,
+ expand = triggers.firstElementChild,
+ contract = triggers.lastElementChild,
+ expandChild = expand.firstElementChild;
+ contract.scrollLeft = contract.scrollWidth;
+ contract.scrollTop = contract.scrollHeight;
+ expandChild.style.width = expand.offsetWidth + 1 + 'px';
+ expandChild.style.height = expand.offsetHeight + 1 + 'px';
+ expand.scrollLeft = expand.scrollWidth;
+ expand.scrollTop = expand.scrollHeight;
+ };
+
+ var checkTriggers = function (element) {
+ return element.offsetWidth !== element.__resizeLast__.width ||
+ element.offsetHeight !== element.__resizeLast__.height;
+ }
+
+ var scrollListener = function (e) {
+ var element = this;
+ resetTriggers(this);
+ if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
+ this.__resizeRAF__ = requestFrame(function () {
+ if (checkTriggers(element)) {
+ element.__resizeLast__.width = element.offsetWidth;
+ element.__resizeLast__.height = element.offsetHeight;
+ element.__resizeListeners__.forEach(function (fn) {
+ fn.call(element, e);
+ });
+ }
+ });
+ };
+
+ /* Detect CSS Animations support to detect element display/re-attach */
+ var animation = false,
+ animationstring = 'animation',
+ keyframeprefix = '',
+ animationstartevent = 'animationstart',
+ domPrefixes = 'Webkit Moz O ms'.split(' '),
+ startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' '),
+ pfx = '';
+ {
+ var elm = document.createElement('fakeelement');
+ if (elm.style.animationName !== undefined) {
+ animation = true;
+ }
+
+ if (animation === false) {
+ for (var i = 0; i < domPrefixes.length; i++) {
+ if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
+ pfx = domPrefixes[i];
+ animationstring = pfx + 'Animation';
+ keyframeprefix = '-' + pfx.toLowerCase() + '-';
+ animationstartevent = startEvents[i];
+ animation = true;
+ break;
+ }
+ }
+ }
+ }
+
+ var animationName = 'resizeanim';
+ var animationKeyframes = '@' + keyframeprefix + 'keyframes ' + animationName + ' { from { opacity: 0; } to { opacity: 0; } } ';
+ var animationStyle = keyframeprefix + 'animation: 1ms ' + animationName + '; ';
+ }
+
+ var createStyles = function () {
+ if (!stylesCreated) {
+ //opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360
+ var css = (animationKeyframes ? animationKeyframes : '') +
+ '.resize-triggers { ' + (animationStyle ? animationStyle : '') + 'visibility: hidden; opacity: 0; } ' +
+ '.resize-triggers, .resize-triggers > div, .contract-trigger:before { content: \" \"; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }',
+ head = document.head || document.getElementsByTagName('head')[0],
+ style = document.createElement('style');
+
+ style.type = 'text/css';
+ if (style.styleSheet) {
+ style.styleSheet.cssText = css;
+ } else {
+ style.appendChild(document.createTextNode(css));
+ }
+
+ head.appendChild(style);
+ stylesCreated = true;
+ }
+ }
+
+ var addResizeListener = function (element, fn) {
+ if (addEventListener){
+ if (!element.__resizeTriggers__) {
+ if (getComputedStyle(element).position === 'static') element.style.position = 'relative';
+ createStyles();
+ element.__resizeLast__ = {};
+ element.__resizeListeners__ = [];
+ (element.__resizeTriggers__ = document.createElement('div')).className = 'resize-triggers';
+ element.__resizeTriggers__.innerHTML = '
' +
+ '
';
+ element.appendChild(element.__resizeTriggers__);
+ resetTriggers(element);
+ element.addEventListener('scroll', scrollListener, true);
+
+ /* Listen for a css animation to detect element display/re-attach */
+ animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
+ if (e.animationName === animationName)
+ resetTriggers(element);
+ });
+ }
+ element.__resizeListeners__.push(fn);
+
+ } else {
+ element.attachEvent('onresize', fn);
+ }
+ };
+
+ var removeResizeListener = function (element, fn) {
+ if (addEventListener) {
+ element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
+ if (!element.__resizeListeners__.length) {
+ element.removeEventListener('scroll', scrollListener, true);
+ element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
+ }
+ } else {
+ element.detachEvent('onresize', fn);
+ }
+ };
+
+ BI.ResizeDetector = {
+ addResizeListener: function (widget, fn) {
+ addResizeListener(widget.element[0], fn);
+ return function () {
+ removeResizeListener(widget.element[0], fn);
+ }
+ },
+ removeResizeListener: function (widget, fn) {
+ removeResizeListener(widget.element[0], fn);
+ }
+ };
+}());
+;
+(function () {
+ function defaultComparator(a, b) {
+ return a < b;
+ }
+
+ BI.Heap = function (items, comparator) {
+ this._items = items || [];
+ this._size = this._items.length;
+ this._comparator = comparator || defaultComparator;
+ this._heapify();
+ };
+
+ BI.Heap.prototype = {
+ constructor: BI.Heap,
+ empty: function () {
+ return this._size === 0;
+ },
+
+ pop: function () {
+ if (this._size === 0) {
+ return;
+ }
+
+ var elt = this._items[0];
+
+ var lastElt = this._items.pop();
+ this._size--;
+
+ if (this._size > 0) {
+ this._items[0] = lastElt;
+ this._sinkDown(0);
+ }
+
+ return elt;
+ },
+
+ push: function (item) {
+ this._items[this._size++] = item;
+ this._bubbleUp(this._size - 1);
+ },
+
+ size: function () {
+ return this._size;
+ },
+
+ peek: function () {
+ if (this._size === 0) {
+ return;
+ }
+
+ return this._items[0];
+ },
+
+ _heapify: function () {
+ for (var index = Math.floor((this._size + 1) / 2); index >= 0; index--) {
+ this._sinkDown(index);
+ }
+ },
+
+ _bubbleUp: function (index) {
+ var elt = this._items[index];
+ while (index > 0) {
+ var parentIndex = Math.floor((index + 1) / 2) - 1;
+ var parentElt = this._items[parentIndex];
+
+ // if parentElt < elt, stop
+ if (this._comparator(parentElt, elt)) {
+ return;
+ }
+
+ // swap
+ this._items[parentIndex] = elt;
+ this._items[index] = parentElt;
+ index = parentIndex;
+ }
+ },
+
+ _sinkDown: function (index) {
+ var elt = this._items[index];
+
+ while (true) {
+ var leftChildIndex = 2 * (index + 1) - 1;
+ var rightChildIndex = 2 * (index + 1);
+ var swapIndex = -1;
+
+ if (leftChildIndex < this._size) {
+ var leftChild = this._items[leftChildIndex];
+ if (this._comparator(leftChild, elt)) {
+ swapIndex = leftChildIndex;
+ }
+ }
+
+ if (rightChildIndex < this._size) {
+ var rightChild = this._items[rightChildIndex];
+ if (this._comparator(rightChild, elt)) {
+ if (swapIndex === -1 ||
+ this._comparator(rightChild, this._items[swapIndex])) {
+ swapIndex = rightChildIndex;
+ }
+ }
+ }
+
+ // if we don't have a swap, stop
+ if (swapIndex === -1) {
+ return;
+ }
+
+ this._items[index] = this._items[swapIndex];
+ this._items[swapIndex] = elt;
+ index = swapIndex;
+ }
+ }
+ }
+})();
+;(function () {
+ var clamp = function (min, value, max) {
+ if (value < min) {
+ return min;
+ }
+ if (value > max) {
+ return max;
+ }
+ return value;
+ };
+
+ var BUFFER_ROWS = 5;
+ var NO_ROWS_SCROLL_RESULT = {
+ index: 0,
+ offset: 0,
+ position: 0,
+ contentHeight: 0
+ };
+
+ BI.TableScrollHelper = function (rowCount,
+ defaultRowHeight,
+ viewportHeight,
+ rowHeightGetter) {
+ this._rowOffsets = BI.PrefixIntervalTree.uniform(rowCount, defaultRowHeight);
+ this._storedHeights = new Array(rowCount);
+ for (var i = 0; i < rowCount; ++i) {
+ this._storedHeights[i] = defaultRowHeight;
+ }
+ this._rowCount = rowCount;
+ this._position = 0;
+ this._contentHeight = rowCount * defaultRowHeight;
+ this._defaultRowHeight = defaultRowHeight;
+ this._rowHeightGetter = rowHeightGetter ?
+ rowHeightGetter : function () {
+ return defaultRowHeight
+ };
+ this._viewportHeight = viewportHeight;
+
+ this._updateHeightsInViewport(0, 0);
+ };
+
+ BI.TableScrollHelper.prototype = {
+ constructor: BI.TableScrollHelper,
+ setRowHeightGetter: function (rowHeightGetter) {
+ this._rowHeightGetter = rowHeightGetter;
+ },
+
+ setViewportHeight: function (viewportHeight) {
+ this._viewportHeight = viewportHeight;
+ },
+
+ getContentHeight: function () {
+ return this._contentHeight;
+ },
+
+ _updateHeightsInViewport: function (firstRowIndex,
+ firstRowOffset) {
+ var top = firstRowOffset;
+ var index = firstRowIndex;
+ while (top <= this._viewportHeight && index < this._rowCount) {
+ this._updateRowHeight(index);
+ top += this._storedHeights[index];
+ index++;
+ }
+ },
+
+ _updateHeightsAboveViewport: function (firstRowIndex) {
+ var index = firstRowIndex - 1;
+ while (index >= 0 && index >= firstRowIndex - BUFFER_ROWS) {
+ var delta = this._updateRowHeight(index);
+ this._position += delta;
+ index--;
+ }
+ },
+
+ _updateRowHeight: function (rowIndex) {
+ if (rowIndex < 0 || rowIndex >= this._rowCount) {
+ return 0;
+ }
+ var newHeight = this._rowHeightGetter(rowIndex);
+ if (newHeight !== this._storedHeights[rowIndex]) {
+ var change = newHeight - this._storedHeights[rowIndex];
+ this._rowOffsets.set(rowIndex, newHeight);
+ this._storedHeights[rowIndex] = newHeight;
+ this._contentHeight += change;
+ return change;
+ }
+ return 0;
+ },
+
+ getRowPosition: function (rowIndex) {
+ this._updateRowHeight(rowIndex);
+ return this._rowOffsets.sumUntil(rowIndex);
+ },
+
+ scrollBy: function (delta) {
+ if (this._rowCount === 0) {
+ return NO_ROWS_SCROLL_RESULT;
+ }
+ var firstRow = this._rowOffsets.greatestLowerBound(this._position);
+ firstRow = clamp(firstRow, 0, Math.max(this._rowCount - 1, 0));
+ var firstRowPosition = this._rowOffsets.sumUntil(firstRow);
+ var rowIndex = firstRow;
+ var position = this._position;
+
+ var rowHeightChange = this._updateRowHeight(rowIndex);
+ if (firstRowPosition !== 0) {
+ position += rowHeightChange;
+ }
+ var visibleRowHeight = this._storedHeights[rowIndex] -
+ (position - firstRowPosition);
+
+ if (delta >= 0) {
+
+ while (delta > 0 && rowIndex < this._rowCount) {
+ if (delta < visibleRowHeight) {
+ position += delta;
+ delta = 0;
+ } else {
+ delta -= visibleRowHeight;
+ position += visibleRowHeight;
+ rowIndex++;
+ }
+ if (rowIndex < this._rowCount) {
+ this._updateRowHeight(rowIndex);
+ visibleRowHeight = this._storedHeights[rowIndex];
+ }
+ }
+ } else if (delta < 0) {
+ delta = -delta;
+ var invisibleRowHeight = this._storedHeights[rowIndex] - visibleRowHeight;
+
+ while (delta > 0 && rowIndex >= 0) {
+ if (delta < invisibleRowHeight) {
+ position -= delta;
+ delta = 0;
+ } else {
+ position -= invisibleRowHeight;
+ delta -= invisibleRowHeight;
+ rowIndex--;
+ }
+ if (rowIndex >= 0) {
+ var change = this._updateRowHeight(rowIndex);
+ invisibleRowHeight = this._storedHeights[rowIndex];
+ position += change;
+ }
+ }
+ }
+
+ var maxPosition = this._contentHeight - this._viewportHeight;
+ position = clamp(position, 0, maxPosition);
+ this._position = position;
+ var firstRowIndex = this._rowOffsets.greatestLowerBound(position);
+ firstRowIndex = clamp(firstRowIndex, 0, Math.max(this._rowCount - 1, 0));
+ firstRowPosition = this._rowOffsets.sumUntil(firstRowIndex);
+ var firstRowOffset = firstRowPosition - position;
+
+ this._updateHeightsInViewport(firstRowIndex, firstRowOffset);
+ this._updateHeightsAboveViewport(firstRowIndex);
+
+ return {
+ index: firstRowIndex,
+ offset: firstRowOffset,
+ position: this._position,
+ contentHeight: this._contentHeight
+ };
+ },
+
+ _getRowAtEndPosition: function (rowIndex) {
+ // We need to update enough rows above the selected one to be sure that when
+ // we scroll to selected position all rows between first shown and selected
+ // one have most recent heights computed and will not resize
+ this._updateRowHeight(rowIndex);
+ var currentRowIndex = rowIndex;
+ var top = this._storedHeights[currentRowIndex];
+ while (top < this._viewportHeight && currentRowIndex >= 0) {
+ currentRowIndex--;
+ if (currentRowIndex >= 0) {
+ this._updateRowHeight(currentRowIndex);
+ top += this._storedHeights[currentRowIndex];
+ }
+ }
+ var position = this._rowOffsets.sumTo(rowIndex) - this._viewportHeight;
+ if (position < 0) {
+ position = 0;
+ }
+ return position;
+ },
+
+ scrollTo: function (position) {
+ if (this._rowCount === 0) {
+ return NO_ROWS_SCROLL_RESULT;
+ }
+ if (position <= 0) {
+ // If position less than or equal to 0 first row should be fully visible
+ // on top
+ this._position = 0;
+ this._updateHeightsInViewport(0, 0);
+
+ return {
+ index: 0,
+ offset: 0,
+ position: this._position,
+ contentHeight: this._contentHeight
+ };
+ } else if (position >= this._contentHeight - this._viewportHeight) {
+ // If position is equal to or greater than max scroll value, we need
+ // to make sure to have bottom border of last row visible.
+ var rowIndex = this._rowCount - 1;
+ position = this._getRowAtEndPosition(rowIndex);
+ }
+ this._position = position;
+
+ var firstRowIndex = this._rowOffsets.greatestLowerBound(position);
+ firstRowIndex = clamp(firstRowIndex, 0, Math.max(this._rowCount - 1, 0));
+ var firstRowPosition = this._rowOffsets.sumUntil(firstRowIndex);
+ var firstRowOffset = firstRowPosition - position;
+
+ this._updateHeightsInViewport(firstRowIndex, firstRowOffset);
+ this._updateHeightsAboveViewport(firstRowIndex);
+
+ return {
+ index: firstRowIndex,
+ offset: firstRowOffset,
+ position: this._position,
+ contentHeight: this._contentHeight
+ };
+ },
+
+ /**
+ * Allows to scroll to selected row with specified offset. It always
+ * brings that row to top of viewport with that offset
+ */
+ scrollToRow: function (rowIndex, offset) {
+ rowIndex = clamp(rowIndex, 0, Math.max(this._rowCount - 1, 0));
+ offset = clamp(offset, -this._storedHeights[rowIndex], 0);
+ var firstRow = this._rowOffsets.sumUntil(rowIndex);
+ return this.scrollTo(firstRow - offset);
+ },
+
+ /**
+ * Allows to scroll to selected row by bringing it to viewport with minimal
+ * scrolling. This that if row is fully visible, scroll will not be changed.
+ * If top border of row is above top of viewport it will be scrolled to be
+ * fully visible on the top of viewport. If the bottom border of row is
+ * below end of viewport, it will be scrolled up to be fully visible on the
+ * bottom of viewport.
+ */
+ scrollRowIntoView: function (rowIndex) {
+ rowIndex = clamp(rowIndex, 0, Math.max(this._rowCount - 1, 0));
+ var rowBegin = this._rowOffsets.sumUntil(rowIndex);
+ var rowEnd = rowBegin + this._storedHeights[rowIndex];
+ if (rowBegin < this._position) {
+ return this.scrollTo(rowBegin);
+ } else if (this._position + this._viewportHeight < rowEnd) {
+ var position = this._getRowAtEndPosition(rowIndex);
+ return this.scrollTo(position);
+ }
+ return this.scrollTo(this._position);
+ }
+ };
+
+})();
+// Data structure that allows to store values and assign positions to them
+// in a way to minimize changing positions of stored values when new ones are
+// added or when some values are replaced. Stored elements are alwasy assigned
+// a consecutive set of positoins startin from 0 up to count of elements less 1
+// Following actions can be executed
+// * get position assigned to given value (null if value is not stored)
+// * create new entry for new value and get assigned position back
+// * replace value that is furthest from specified value range with new value
+// and get it's position back
+// All operations take amortized log(n) time where n is number of elements in
+// the set.
+BI.IntegerBufferSet = function () {
+ this._valueToPositionMap = {};
+ this._size = 0;
+ this._smallValues = new BI.Heap(
+ [], // Initial data in the heap
+ this._smallerComparator
+ );
+ this._largeValues = new BI.Heap(
+ [], // Initial data in the heap
+ this._greaterComparator
+ );
+
+};
+
+BI.IntegerBufferSet.prototype = {
+ constructor: BI.IntegerBufferSet,
+ getSize: function () /*number*/ {
+ return this._size;
+ },
+
+ getValuePosition: function (/*number*/ value) /*?number*/ {
+ if (this._valueToPositionMap[value] === undefined) {
+ return null;
+ }
+ return this._valueToPositionMap[value];
+ },
+
+ getNewPositionForValue: function (/*number*/ value) /*number*/ {
+ var newPosition = this._size;
+ this._size++;
+ this._pushToHeaps(newPosition, value);
+ this._valueToPositionMap[value] = newPosition;
+ return newPosition;
+ },
+
+ replaceFurthestValuePosition: function (/*number*/ lowValue,
+ /*number*/ highValue,
+ /*number*/ newValue) /*?number*/ {
+ this._cleanHeaps();
+ if (this._smallValues.empty() || this._largeValues.empty()) {
+ // Threre are currently no values stored. We will have to create new
+ // position for this value.
+ return null;
+ }
+
+ var minValue = this._smallValues.peek().value;
+ var maxValue = this._largeValues.peek().value;
+ if (minValue >= lowValue && maxValue <= highValue) {
+ // All values currently stored are necessary, we can't reuse any of them.
+ return null;
+ }
+
+ var valueToReplace;
+ if (lowValue - minValue > maxValue - highValue) {
+ // minValue is further from provided range. We will reuse it's position.
+ valueToReplace = minValue;
+ this._smallValues.pop();
+ } else {
+ valueToReplace = maxValue;
+ this._largeValues.pop();
+ }
+ var position = this._valueToPositionMap[valueToReplace];
+ delete this._valueToPositionMap[valueToReplace];
+ this._valueToPositionMap[newValue] = position;
+ this._pushToHeaps(position, newValue);
+
+ return position;
+ },
+
+ _pushToHeaps: function (/*number*/ position, /*number*/ value) {
+ var element = {
+ position: position,
+ value:value
+ };
+ // We can reuse the same object in both heaps, because we don't mutate them
+ this._smallValues.push(element);
+ this._largeValues.push(element);
+ },
+
+ _cleanHeaps: function () {
+ // We not usually only remove object from one heap while moving value.
+ // Here we make sure that there is no stale data on top of heaps.
+ this._cleanHeap(this._smallValues);
+ this._cleanHeap(this._largeValues);
+ var minHeapSize =
+ Math.min(this._smallValues.size(), this._largeValues.size());
+ var maxHeapSize =
+ Math.max(this._smallValues.size(), this._largeValues.size());
+ if (maxHeapSize > 10 * minHeapSize) {
+ // There are many old values in one of heaps. We nned to get rid of them
+ // to not use too avoid memory leaks
+ this._recreateHeaps();
+ }
+ },
+
+ _recreateHeaps: function () {
+ var sourceHeap = this._smallValues.size() < this._largeValues.size() ?
+ this._smallValues :
+ this._largeValues;
+ var newSmallValues = new Heap(
+ [], // Initial data in the heap
+ this._smallerComparator
+ );
+ var newLargeValues = new Heap(
+ [], // Initial datat in the heap
+ this._greaterComparator
+ );
+ while (!sourceHeap.empty()) {
+ var element = sourceHeap.pop();
+ // Push all stil valid elements to new heaps
+ if (this._valueToPositionMap[element.value] !== undefined) {
+ newSmallValues.push(element);
+ newLargeValues.push(element);
+ }
+ }
+ this._smallValues = newSmallValues;
+ this._largeValues = newLargeValues;
+ },
+
+ _cleanHeap: function (/*object*/ heap) {
+ while (!heap.empty() &&
+ this._valueToPositionMap[heap.peek().value] === undefined) {
+ heap.pop();
+ }
+ },
+
+ _smallerComparator: function (/*object*/ lhs, /*object*/ rhs) /*boolean*/ {
+ return lhs.value < rhs.value;
+ },
+
+ _greaterComparator: function (/*object*/ lhs, /*object*/ rhs) /*boolean*/ {
+ return lhs.value > rhs.value;
+ }
+};
+;
+!(function () {
+ BI.LinkHashMap = function () {
+ this.array = [];
+ this.map = {};
+ };
+ BI.LinkHashMap.prototype = {
+ constructor: BI.LinkHashMap,
+ has: function (key) {
+ if (key in this.map) {
+ return true;
+ }
+ return false;
+ },
+
+ add: function (key, value) {
+ if (typeof key == 'undefined') {
+ return;
+ }
+ if (key in this.map) {
+ this.map[key] = value;
+ } else {
+ this.array.push(key);
+ this.map[key] = value;
+ }
+ },
+
+ remove: function (key) {
+ if (key in this.map) {
+ delete this.map[key];
+ for (var i = 0; i < this.array.length; i++) {
+ if (this.array[i] == key) {
+ this.array.splice(i, 1);
+ break;
+ }
+ }
+ }
+ },
+
+ size: function () {
+ return this.array.length;
+ },
+
+ each: function (fn, scope) {
+ var scope = scope || window;
+ var fn = fn || null;
+ if (fn == null || typeof (fn) != "function") {
+ return;
+ }
+ for (var i = 0; i < this.array.length; i++) {
+ var key = this.array[i];
+ var value = this.map[key];
+ var re = fn.call(scope, key, value, i, this.array, this.map);
+ if (re == false) {
+ break;
+ }
+ }
+ },
+
+ get: function (key) {
+ return this.map[key];
+ },
+
+ toArray: function () {
+ var array = [];
+ this.each(function (key, value) {
+ array.push(value);
+ })
+ return array;
+ }
+ }
+})();window.BI = window.BI || {};
+
+$.extend(BI, {
+ $defaultImport: function (options) {
+ var config = $.extend({
+ op: 'resource',
+ path: null,
+ type: null,
+ must: false
+ }, options);
+ config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path;
+ this.$import(config.url, config.type,config.must);
+ },
+ $import: function () {
+ var _LOADED = {}; // alex:保存加载过的
+ function loadReady(src, must) {
+ var $scripts = $("head script");
+ $.each($scripts, function (i, item) {
+ if (item.src.indexOf(src) != -1) {
+ _LOADED[src] = true;
+ }
+ });
+ var $links = $("head link");
+ $.each($links, function (i, item) {
+ if (item.href.indexOf(src) != -1 && must) {
+ _LOADED[src] = false;
+ $(item).remove();
+ }
+ });
+ }
+
+ // must=true 强行加载
+ return function (src, ext, must) {
+ loadReady(src, must);
+ // alex:如果已经加载过了的,直接return
+ if (_LOADED[src] === true) {
+ return;
+ }
+ if (ext === 'css') {
+ var link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.type = 'text/css';
+ link.href = src;
+ var head = document.getElementsByTagName('head')[0];
+ head.appendChild(link);
+ _LOADED[src] = true;
+ } else {
+ // alex:这里用同步调用的方式,必须等待ajax完成
+ $.ajax({
+ url: src,
+ dataType: "script", // alex:指定dataType为script,jquery会帮忙做globalEval的事情
+ async: false,
+ cache: true,
+ complete: function (res, status) {
+ /*
+ * alex:发现jquery会很智能地判断一下返回的数据类型是不是script,然后做一个globalEval
+ * 所以当status为success时就不需要再把其中的内容加到script里面去了
+ */
+ if (status == 'success') {
+ _LOADED[src] = true;
+ }
+ }
+ })
+ }
+ }
+ }()
+});;
+!(function () {
+ BI.LRU = function (limit) {
+ this.size = 0;
+ this.limit = limit;
+ this.head = this.tail = undefined;
+ this._keymap = {};
+ };
+
+ var p = BI.LRU.prototype;
+
+ p.put = function (key, value) {
+ var removed;
+ if (this.size === this.limit) {
+ removed = this.shift();
+ }
+
+ var entry = this.get(key, true);
+ if (!entry) {
+ entry = {
+ key: key
+ };
+ this._keymap[key] = entry;
+ if (this.tail) {
+ this.tail.newer = entry;
+ entry.older = this.tail
+ } else {
+ this.head = entry
+ }
+ this.tail = entry;
+ this.size++;
+ }
+ entry.value = value;
+
+ return removed;
+ };
+
+ p.shift = function () {
+ var entry = this.head;
+ if (entry) {
+ this.head = this.head.newer;
+ this.head.older = undefined;
+ entry.newer = entry.older = undefined;
+ this._keymap[entry.key] = undefined;
+ this.size--;
+ }
+ return entry;
+ };
+
+
+ p.get = function (key, returnEntry) {
+ var entry = this._keymap[key];
+ if (entry === undefined) return;
+ if (entry === this.tail) {
+ return returnEntry
+ ? entry
+ : entry.value
+ }
+ // HEAD--------------TAIL
+ // <.older .newer>
+ // <--- add direction --
+ // A B C
E
+ if (entry.newer) {
+ if (entry === this.head) {
+ this.head = entry.newer
+ }
+ entry.newer.older = entry.older; // C <-- E.
+ }
+ if (entry.older) {
+ entry.older.newer = entry.newer; // C. --> E
+ }
+ entry.newer = undefined; // D --x
+ entry.older = this.tail; // D. --> E
+ if (this.tail) {
+ this.tail.newer = entry; // E. <-- D
+ }
+ this.tail = entry;
+ return returnEntry
+ ? entry
+ : entry.value
+ };
+})();;
+!(function () {
+ var MD5 = function (hexcase) {
+ this.hexcase = !hexcase ? 0 : 1;
+ /* hex output format. 0 - lowercase; 1 - uppercase */
+ this.b64pad = "";
+ /* base-64 pad character. "=" for strict RFC compliance */
+ this.chrsz = 8;
+ /* bits per input character. 8 - ASCII; 16 - Unicode */
+ };
+
+ /*
+ * These are the functions you'll usually want to call
+ * They take string arguments and return either hex or base-64 encoded strings
+ */
+ MD5.prototype.hex_md5 = function (s) {
+ return this.binl2hex(this.core_md5(this.str2binl(s), s.length * this.chrsz));
+ };
+
+ MD5.prototype.hex_md5_salt = function (s) {
+ var md5ed = this.hex_md5(s);
+
+ var items1 = [];
+ var items2 = [];
+ for (var i = 0; i < md5ed.length; i++) {
+ if (i % 2 === 0) {
+ items1.push(md5ed.charAt(i));
+ } else {
+ items2.push(md5ed.charAt(i));
+ }
+ }
+ var result = ":" + items1.join("") + items2.join("");
+ return result;
+ };
+
+ MD5.prototype.b64_md5 = function (s) {
+ return this.binl2b64(this.core_md5(this.str2binl(s), s.length * this.chrsz));
+ };
+
+ MD5.prototype.hex_hmac_md5 = function (key, data) {
+ return this.binl2hex(this.core_hmac_md5(key, data));
+ };
+
+ MD5.prototype.b64_hmac_md5 = function (key, data) {
+ return this.binl2b64(this.core_hmac_md5(key, data));
+ };
+
+ /* Backwards compatibility - same as hex_md5() */
+ MD5.prototype.calcMD5 = function (s) {
+ return this.binl2hex(this.core_md5(this.str2binl(s), s.length * this.chrsz));
+ };
+
+ MD5.prototype.core_md5 = function (x, len) {
+ /* append padding */
+ x[len >> 5] |= 0x80 << ((len) % 32);
+ x[(((len + 64) >>> 9) << 4) + 14] = len;
+
+ var a = 1732584193;
+ var b = -271733879;
+ var c = -1732584194;
+ var d = 271733878;
+
+ for (var i = 0; i < x.length; i += 16) {
+ var olda = a;
+ var oldb = b;
+ var oldc = c;
+ var oldd = d;
+
+ a = this.md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
+ d = this.md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
+ c = this.md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
+ b = this.md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
+ a = this.md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
+ d = this.md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
+ c = this.md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
+ b = this.md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
+ a = this.md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
+ d = this.md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
+ c = this.md5_ff(c, d, a, b, x[i + 10], 17, -42063);
+ b = this.md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
+ a = this.md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
+ d = this.md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
+ c = this.md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
+ b = this.md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
+
+ a = this.md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
+ d = this.md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
+ c = this.md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
+ b = this.md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
+ a = this.md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
+ d = this.md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
+ c = this.md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
+ b = this.md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
+ a = this.md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
+ d = this.md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
+ c = this.md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
+ b = this.md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
+ a = this.md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
+ d = this.md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
+ c = this.md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
+ b = this.md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
+
+ a = this.md5_hh(a, b, c, d, x[i + 5], 4, -378558);
+ d = this.md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
+ c = this.md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
+ b = this.md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
+ a = this.md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
+ d = this.md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
+ c = this.md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
+ b = this.md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
+ a = this.md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
+ d = this.md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
+ c = this.md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
+ b = this.md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
+ a = this.md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
+ d = this.md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
+ c = this.md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
+ b = this.md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
+
+ a = this.md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
+ d = this.md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
+ c = this.md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
+ b = this.md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
+ a = this.md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
+ d = this.md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
+ c = this.md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
+ b = this.md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
+ a = this.md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
+ d = this.md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
+ c = this.md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
+ b = this.md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
+ a = this.md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
+ d = this.md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
+ c = this.md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
+ b = this.md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
+
+ a = this.safe_add(a, olda);
+ b = this.safe_add(b, oldb);
+ c = this.safe_add(c, oldc);
+ d = this.safe_add(d, oldd);
+ }
+ return Array(a, b, c, d);
+
+ };
+
+ /*
+ * These functions implement the four basic operations the algorithm uses.
+ */
+ MD5.prototype.md5_cmn = function (q, a, b, x, s, t) {
+ return this.safe_add(this.bit_rol(this.safe_add(this.safe_add(a, q), this.safe_add(x, t)), s), b);
+ };
+ MD5.prototype.md5_ff = function (a, b, c, d, x, s, t) {
+ return this.md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
+ };
+ MD5.prototype.md5_gg = function (a, b, c, d, x, s, t) {
+ return this.md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
+ };
+ MD5.prototype.md5_hh = function (a, b, c, d, x, s, t) {
+ return this.md5_cmn(b ^ c ^ d, a, b, x, s, t);
+ };
+ MD5.prototype.md5_ii = function (a, b, c, d, x, s, t) {
+ return this.md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
+ };
+
+ /*
+ * Calculate the HMAC-MD5, of a key and some data
+ */
+ MD5.prototype.core_hmac_md5 = function (key, data) {
+ var bkey = this.str2binl(key);
+ if (bkey.length > 16)
+ bkey = this.core_md5(bkey, key.length * this.chrsz);
+
+ var ipad = Array(16), opad = Array(16);
+ for (var i = 0; i < 16; i++) {
+ ipad[i] = bkey[i] ^ 0x36363636;
+ opad[i] = bkey[i] ^ 0x5C5C5C5C;
+ }
+
+ var hash = this.core_md5(ipad.concat(this.str2binl(data)), 512 + data.length * this.chrsz);
+ return this.core_md5(opad.concat(hash), 512 + 128);
+ };
+
+ /*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
+ MD5.prototype.safe_add = function (x, y) {
+ var lsw = (x & 0xFFFF) + (y & 0xFFFF);
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+ return (msw << 16) | (lsw & 0xFFFF);
+ };
+
+ /*
+ * Bitwise rotate a 32-bit number to the left.
+ */
+ MD5.prototype.bit_rol = function (num, cnt) {
+ return (num << cnt) | (num >>> (32 - cnt));
+ };
+
+ /*
+ * Convert a string to an array of little-endian words
+ * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
+ */
+ MD5.prototype.str2binl = function (str) {
+ var bin = Array();
+ var mask = (1 << this.chrsz) - 1;
+ for (var i = 0; i < str.length * this.chrsz; i += this.chrsz)
+ bin[i >> 5] |= (str.charCodeAt(i / this.chrsz) & mask) << (i % 32);
+ return bin;
+ };
+
+ /*
+ * Convert an array of little-endian words to a hex string.
+ */
+ MD5.prototype.binl2hex = function (binarray) {
+ var hex_tab = this.hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
+ var str = "";
+ for (var i = 0; i < binarray.length * 4; i++) {
+ str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF)
+ + hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF);
+ }
+ return str;
+ };
+
+ /*
+ * Convert an array of little-endian words to a base-64 string
+ */
+ MD5.prototype.binl2b64 = function (binarray) {
+ var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ var str = "";
+ for (var i = 0; i < binarray.length * 4; i += 3) {
+ var triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16)
+ | (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8)
+ | ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF);
+ for (var j = 0; j < 4; j++) {
+ if (i * 8 + j * 6 > binarray.length * 32)
+ str += this.b64pad;
+ else
+ str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
+ }
+ }
+ return str;
+ };
+ BI.MD5 = new MD5();
+})();//线段树
+;(function () {
+ var parent = function (node) {
+ return Math.floor(node / 2);
+ };
+
+ var Int32Array = window.Int32Array || function (size) {
+ var xs = [];
+ for (var i = size - 1; i >= 0; --i) {
+ xs[i] = 0;
+ }
+ return xs;
+ };
+
+ var ceilLog2 = function (x) {
+ var y = 1;
+ while (y < x) {
+ y *= 2;
+ }
+ return y;
+ };
+
+ BI.PrefixIntervalTree = function (xs) {
+ this._size = xs.length;
+ this._half = ceilLog2(this._size);
+ this._heap = new Int32Array(2 * this._half);
+
+ var i;
+ for (i = 0; i < this._size; ++i) {
+ this._heap[this._half + i] = xs[i];
+ }
+
+ for (i = this._half - 1; i > 0; --i) {
+ this._heap[i] = this._heap[2 * i] + this._heap[2 * i + 1];
+ }
+ };
+
+ BI.PrefixIntervalTree.prototype = {
+ constructor: BI.PrefixIntervalTree,
+ set: function (index, value) {
+ var node = this._half + index;
+ this._heap[node] = value;
+
+ node = parent(node);
+ for (; node !== 0; node = parent(node)) {
+ this._heap[node] =
+ this._heap[2 * node] + this._heap[2 * node + 1];
+ }
+ },
+
+ get: function (index) {
+ var node = this._half + index;
+ return this._heap[node];
+ },
+
+ getSize: function () {
+ return this._size;
+ },
+
+ /**
+ * get(0) + get(1) + ... + get(end - 1).
+ */
+ sumUntil: function (end) {
+ if (end === 0) {
+ return 0;
+ }
+
+ var node = this._half + end - 1;
+ var sum = this._heap[node];
+ for (; node !== 1; node = parent(node)) {
+ if (node % 2 === 1) {
+ sum += this._heap[node - 1];
+ }
+ }
+
+ return sum;
+ },
+
+ /**
+ * get(0) + get(1) + ... + get(inclusiveEnd).
+ */
+ sumTo: function (inclusiveEnd) {
+ return this.sumUntil(inclusiveEnd + 1);
+ },
+
+ /**
+ * sum get(begin) + get(begin + 1) + ... + get(end - 1).
+ */
+ sum: function (begin, end) {
+ return this.sumUntil(end) - this.sumUntil(begin);
+ },
+
+ /**
+ * Returns the smallest i such that 0 <= i <= size and sumUntil(i) <= t, or
+ * -1 if no such i exists.
+ */
+ greatestLowerBound: function (t) {
+ if (t < 0) {
+ return -1;
+ }
+
+ var node = 1;
+ if (this._heap[node] <= t) {
+ return this._size;
+ }
+
+ while (node < this._half) {
+ var leftSum = this._heap[2 * node];
+ if (t < leftSum) {
+ node = 2 * node;
+ } else {
+ node = 2 * node + 1;
+ t -= leftSum;
+ }
+ }
+
+ return node - this._half;
+ },
+
+ /**
+ * Returns the smallest i such that 0 <= i <= size and sumUntil(i) < t, or
+ * -1 if no such i exists.
+ */
+ greatestStrictLowerBound: function (t) {
+ if (t <= 0) {
+ return -1;
+ }
+
+ var node = 1;
+ if (this._heap[node] < t) {
+ return this._size;
+ }
+
+ while (node < this._half) {
+ var leftSum = this._heap[2 * node];
+ if (t <= leftSum) {
+ node = 2 * node;
+ } else {
+ node = 2 * node + 1;
+ t -= leftSum;
+ }
+ }
+
+ return node - this._half;
+ },
+
+ /**
+ * Returns the smallest i such that 0 <= i <= size and t <= sumUntil(i), or
+ * size + 1 if no such i exists.
+ */
+ leastUpperBound: function (t) {
+ return this.greatestStrictLowerBound(t) + 1;
+ },
+
+ /**
+ * Returns the smallest i such that 0 <= i <= size and t < sumUntil(i), or
+ * size + 1 if no such i exists.
+ */
+ leastStrictUpperBound: function (t) {
+ return this.greatestLowerBound(t) + 1;
+ }
+ };
+
+ BI.PrefixIntervalTree.uniform = function (size, initialValue) {
+ var xs = [];
+ for (var i = size - 1; i >= 0; --i) {
+ xs[i] = initialValue;
+ }
+
+ return new BI.PrefixIntervalTree(xs);
+ };
+
+ BI.PrefixIntervalTree.empty = function (size) {
+ return BI.PrefixIntervalTree.uniform(size, 0);
+ };
+
+})();
+;
+!(function () {
+ BI.Queue = function (capacity) {
+ this.capacity = capacity;
+ this.array = [];
+ };
+ BI.Queue.prototype = {
+ constructor: BI.Queue,
+
+ contains: function (v) {
+ return this.array.contains(v);
+ },
+
+ indexOf: function (v) {
+ return this.array.contains(v);
+ },
+
+ getElementByIndex: function(index) {
+ return this.array[index];
+ },
+
+ push: function (v) {
+ this.array.push(v);
+ if (this.capacity && this.array.length > this.capacity) {
+ this.array.shift();
+ }
+ },
+
+ pop: function () {
+ this.array.pop();
+ },
+
+ shift: function () {
+ this.array.shift();
+ },
+
+ unshift: function (v) {
+ this.array.unshift(v);
+ if (this.capacity && this.array.length > this.capacity) {
+ this.array.pop();
+ }
+ },
+
+ remove: function (v) {
+ this.array.remove(v);
+ },
+
+ splice: function() {
+ this.array.splice.apply(this.array, arguments);
+ },
+
+ slice: function() {
+ this.array.slice.apply(this.array, arguments);
+ },
+
+ size: function () {
+ return this.array.length;
+ },
+
+ each: function (fn, scope) {
+ var scope = scope || window;
+ var fn = fn || null;
+ if (fn == null || typeof (fn) != "function") {
+ return;
+ }
+ for (var i = 0; i < this.array.length; i++) {
+ var re = fn.call(scope, i, this.array[i], this.array);
+ if (re == false) {
+ break;
+ }
+ }
+ },
+
+ toArray: function () {
+ return this.array;
+ },
+
+ fromArray: function (array) {
+ var self = this;
+ BI.each(array, function (i, v) {
+ self.push(v);
+ })
+ },
+
+ clear: function () {
+ this.array.clear();
+ }
+ }
+})();!(function () {
+ var Section = function (height, width, x, y) {
+ this.height = height;
+ this.width = width;
+ this.x = x;
+ this.y = y;
+
+ this._indexMap = {};
+ this._indices = [];
+ };
+
+ Section.prototype = {
+ constructor: Section,
+ addCellIndex: function (index) {
+ if (!this._indexMap[index]) {
+ this._indexMap[index] = true;
+ this._indices.push(index);
+ }
+ },
+
+ getCellIndices: function () {
+ return this._indices
+ }
+ };
+
+ var SECTION_SIZE = 100;
+ BI.SectionManager = function (sectionSize) {
+ this._sectionSize = sectionSize || SECTION_SIZE;
+ this._cellMetadata = [];
+ this._sections = {};
+ };
+
+ BI.SectionManager.prototype = {
+ constructor: BI.SectionManager,
+ getCellIndices: function (height, width, x, y) {
+ var indices = {};
+
+ BI.each(this.getSections(height, width, x, y), function (i, section) {
+ BI.each(section.getCellIndices(), function (j, index) {
+ indices[index] = index
+ })
+ });
+
+ return BI.map(BI.keys(indices), function (i, index) {
+ return indices[index]
+ });
+ },
+
+ getCellMetadata: function (index) {
+ return this._cellMetadata[index];
+ },
+
+ getSections: function (height, width, x, y) {
+ var sectionXStart = Math.floor(x / this._sectionSize);
+ var sectionXStop = Math.floor((x + width - 1) / this._sectionSize);
+ var sectionYStart = Math.floor(y / this._sectionSize);
+ var sectionYStop = Math.floor((y + height - 1) / this._sectionSize);
+
+ var sections = [];
+
+ for (var sectionX = sectionXStart; sectionX <= sectionXStop; sectionX++) {
+ for (var sectionY = sectionYStart; sectionY <= sectionYStop; sectionY++) {
+ var key = sectionX + "." + sectionY;
+
+ if (!this._sections[key]) {
+ this._sections[key] = new Section(this._sectionSize, this._sectionSize, sectionX * this._sectionSize, sectionY * this._sectionSize)
+ }
+
+ sections.push(this._sections[key])
+ }
+ }
+
+ return sections
+ },
+
+ getTotalSectionCount: function () {
+ return BI.size(this._sections);
+ },
+
+ registerCell: function (cellMetadatum, index) {
+ this._cellMetadata[index] = cellMetadatum;
+
+ BI.each(this.getSections(cellMetadatum.height, cellMetadatum.width, cellMetadatum.x, cellMetadatum.y), function (i, section) {
+ section.addCellIndex(index);
+ });
+ }
+ }
+})();if (typeof Set !== 'undefined' && Set.toString().match(/native code/)) {
+
+} else {
+ Set = function () {
+ this.set = {}
+ };
+ Set.prototype.has = function (key) {
+ return this.set[key] !== undefined;
+ };
+ Set.prototype.add = function (key) {
+ this.set[key] = 1
+ };
+ Set.prototype.clear = function () {
+ this.set = {}
+ };
+};
+(function () {
+ var clamp = function (value, min, max) {
+ if (value < min) {
+ return min;
+ }
+ if (value > max) {
+ return max;
+ }
+ return value;
+ };
+ var MIN_BUFFER_ROWS = 6;
+ var MAX_BUFFER_ROWS = 10;
+
+ BI.TableRowBuffer = function (rowsCount,
+ defaultRowHeight,
+ viewportHeight,
+ rowHeightGetter) {
+ this._bufferSet = new BI.IntegerBufferSet();
+ this._defaultRowHeight = defaultRowHeight;
+ this._viewportRowsBegin = 0;
+ this._viewportRowsEnd = 0;
+ this._maxVisibleRowCount = Math.ceil(viewportHeight / defaultRowHeight) + 1;
+ // this._bufferRowsCount = Math.floor(this._maxVisibleRowCount / 2);
+ this._bufferRowsCount = clamp(
+ Math.floor(this._maxVisibleRowCount / 2),
+ MIN_BUFFER_ROWS,
+ MAX_BUFFER_ROWS
+ );
+ this._rowsCount = rowsCount;
+ this._rowHeightGetter = rowHeightGetter;
+ this._rows = [];
+ this._viewportHeight = viewportHeight;
+
+ };
+ BI.TableRowBuffer.prototype = {
+ constructor: BI.TableRowBuffer,
+
+ getRowsWithUpdatedBuffer: function () {
+ var remainingBufferRows = 2 * this._bufferRowsCount;
+ var bufferRowIndex =
+ Math.max(this._viewportRowsBegin - this._bufferRowsCount, 0);
+ while (bufferRowIndex < this._viewportRowsBegin) {
+ this._addRowToBuffer(
+ bufferRowIndex,
+ this._viewportRowsBegin,
+ this._viewportRowsEnd - 1
+ );
+ bufferRowIndex++;
+ remainingBufferRows--;
+ }
+ bufferRowIndex = this._viewportRowsEnd;
+ while (bufferRowIndex < this._rowsCount && remainingBufferRows > 0) {
+ this._addRowToBuffer(
+ bufferRowIndex,
+ this._viewportRowsBegin,
+ this._viewportRowsEnd - 1
+ );
+ bufferRowIndex++;
+ remainingBufferRows--;
+ }
+ return this._rows;
+ },
+
+ getRows: function (firstRowIndex,
+ firstRowOffset) {
+ var top = firstRowOffset;
+ var totalHeight = top;
+ var rowIndex = firstRowIndex;
+ var endIndex =
+ Math.min(firstRowIndex + this._maxVisibleRowCount, this._rowsCount);
+
+ this._viewportRowsBegin = firstRowIndex;
+ while (rowIndex < endIndex ||
+ (totalHeight < this._viewportHeight && rowIndex < this._rowsCount)) {
+ this._addRowToBuffer(
+ rowIndex,
+ firstRowIndex,
+ endIndex - 1
+ );
+ totalHeight += this._rowHeightGetter(rowIndex);
+ ++rowIndex;
+ // Store index after the last viewport row as end, to be able to
+ // distinguish when there are no rows rendered in viewport
+ this._viewportRowsEnd = rowIndex;
+ }
+
+ return this._rows;
+ },
+
+ _addRowToBuffer: function (rowIndex,
+ firstViewportRowIndex,
+ lastViewportRowIndex) {
+ var rowPosition = this._bufferSet.getValuePosition(rowIndex);
+ var viewportRowsCount = lastViewportRowIndex - firstViewportRowIndex + 1;
+ var allowedRowsCount = viewportRowsCount + this._bufferRowsCount * 2;
+ if (rowPosition === null &&
+ this._bufferSet.getSize() >= allowedRowsCount) {
+ rowPosition =
+ this._bufferSet.replaceFurthestValuePosition(
+ firstViewportRowIndex,
+ lastViewportRowIndex,
+ rowIndex
+ );
+ }
+ if (rowPosition === null) {
+ // We can't reuse any of existing positions for this row. We have to
+ // create new position
+ rowPosition = this._bufferSet.getNewPositionForValue(rowIndex);
+ this._rows[rowPosition] = rowIndex;
+ } else {
+ // This row already is in the table with rowPosition position or it
+ // can replace row that is in that position
+ this._rows[rowPosition] = rowIndex;
+ }
+ }
+ }
+
+})();
+;
+(function () {
+ BI.Tree = function () {
+ this.root = new BI.Node(BI.UUID());
+ };
+
+ BI.Tree.prototype = {
+ constructor: BI.Tree,
+ addNode: function (node, newNode, index) {
+ if (BI.isNull(newNode)) {
+ this.root.addChild(node, index);
+ } else if (BI.isNull(node)) {
+ this.root.addChild(newNode, index);
+ } else {
+ node.addChild(newNode, index);
+ }
+ },
+
+ isRoot: function (node) {
+ return node === this.root;
+ },
+
+ getRoot: function () {
+ return this.root;
+ },
+
+ clear: function () {
+ this.root.clear();
+ },
+
+ initTree: function (nodes) {
+ var self = this;
+ this.clear();
+ var queue = [];
+ BI.each(nodes, function (i, node) {
+ var n = new BI.Node(node);
+ n.set("data", node);
+ self.addNode(n);
+ queue.push(n);
+ });
+ while (!BI.isEmpty(queue)) {
+ var parent = queue.shift();
+ var node = parent.get("data");
+ BI.each(node.children, function (i, child) {
+ var n = new BI.Node(child);
+ n.set("data", child);
+ queue.push(n);
+ self.addNode(parent, n);
+ })
+ }
+ },
+
+ _toJSON: function (node) {
+ var self = this;
+ var children = [];
+ BI.each(node.getChildren(), function (i, child) {
+ children.push(self._toJSON(child));
+ });
+ return BI.extend({
+ id: node.id
+ }, BI.deepClone(node.get("data")), (children.length > 0 ? {
+ children: children
+ } : {}));
+ },
+
+ toJSON: function (node) {
+ var self = this, result = [];
+ BI.each((node || this.root).getChildren(), function (i, child) {
+ result.push(self._toJSON(child));
+ });
+ return result;
+ },
+
+ _toJSONWithNode: function (node) {
+ var self = this;
+ var children = [];
+ BI.each(node.getChildren(), function (i, child) {
+ children.push(self._toJSONWithNode(child));
+ });
+ return BI.extend({
+ id: node.id
+ }, BI.deepClone(node.get("data")), {
+ node: node
+ }, (children.length > 0 ? {
+ children: children
+ } : {}));
+ },
+
+ toJSONWithNode: function (node) {
+ var self = this, result = [];
+ BI.each((node || this.root).getChildren(), function (i, child) {
+ result.push(self._toJSONWithNode(child));
+ });
+ return result;
+ },
+
+ search: function (root, target, param) {
+ if (!(root instanceof BI.Node)) {
+ return arguments.callee.apply(this, [this.root, root, target]);
+ }
+ var self = this, next = null;
+
+ if (BI.isNull(target)) {
+ return null;
+ }
+ if (BI.isEqual(root[param || "id"], target)) {
+ return root;
+ }
+ BI.any(root.getChildren(), function (i, child) {
+ next = self.search(child, target, param);
+ if (null !== next) {
+ return true;
+ }
+ });
+ return next;
+ },
+
+ _traverse: function (node, callback) {
+ var queue = [];
+ queue.push(node);
+ while (!BI.isEmpty(queue)) {
+ var temp = queue.shift();
+ var b = callback && callback(temp);
+ if (b === false) {
+ break;
+ }
+ if (b === true) {
+ continue;
+ }
+ if (temp != null) {
+ queue = queue.concat(temp.getChildren());
+ }
+ }
+ },
+
+ traverse: function (callback) {
+ this._traverse(this.root, callback);
+ },
+
+ _recursion: function (node, route, callback) {
+ var self = this;
+ return BI.every(node.getChildren(), function (i, child) {
+ var next = BI.clone(route);
+ next.push(child.id);
+ var b = callback && callback(child, next);
+ if (b === false) {
+ return false;
+ }
+ if (b === true) {
+ return true;
+ }
+ return self._recursion(child, next, callback);
+ });
+ },
+
+ recursion: function (callback) {
+ this._recursion(this.root, [], callback);
+ },
+
+ inOrderTraverse: function (callback) {
+ this._inOrderTraverse(this.root, callback);
+ },
+
+ //中序遍历(递归)
+ _inOrderTraverse: function (node, callback) {
+ if (node != null) {
+ this._inOrderTraverse(node.getLeft());
+ callback && callback(node);
+ this._inOrderTraverse(node.getRight());
+ }
+ },
+
+ //中序遍历(非递归)
+ nrInOrderTraverse: function (callback) {
+
+ var stack = [];
+ var node = this.root;
+ while (node != null || !BI.isEmpty(stack)) {
+ while (node != null) {
+ stack.push(node);
+ node = node.getLeft();
+ }
+ node = stack.pop();
+ callback && callback(node);
+ node = node.getRight();
+ }
+ },
+
+ preOrderTraverse: function (callback) {
+ this._preOrderTraverse(this.root, callback);
+ },
+
+ //先序遍历(递归)
+ _preOrderTraverse: function (node, callback) {
+ if (node != null) {
+ callback && callback(node);
+ this._preOrderTraverse(node.getLeft());
+ this._preOrderTraverse(node.getRight());
+ }
+ },
+
+ //先序遍历(非递归)
+ nrPreOrderTraverse: function (callback) {
+
+ var stack = [];
+ var node = this.root;
+
+ while (node != null || !BI.isEmpty(stack)) {
+
+ while (node != null) {
+ callback && callback(node);
+ stack.push(node);
+ node = node.getLeft();
+ }
+ node = stack.pop();
+ node = node.getRight();
+ }
+ },
+
+ postOrderTraverse: function (callback) {
+ this._postOrderTraverse(this.root, callback);
+ },
+
+ //后序遍历(递归)
+ _postOrderTraverse: function (node, callback) {
+ if (node != null) {
+ this._postOrderTraverse(node.getLeft());
+ this._postOrderTraverse(node.getRight());
+ callback && callback(node);
+ }
+ },
+
+ //后续遍历(非递归)
+ nrPostOrderTraverse: function (callback) {
+
+ var stack = [];
+ var node = this.root;
+ var preNode = null;//表示最近一次访问的节点
+
+ while (node != null || !BI.isEmpty(stack)) {
+
+ while (node != null) {
+ stack.push(node);
+ node = node.getLeft();
+ }
+
+ node = BI.last(stack);
+
+ if (node.getRight() == null || node.getRight() == preNode) {
+ callback && callback(node);
+ node = stack.pop();
+ preNode = node;
+ node = null;
+ } else {
+ node = node.getRight();
+ }
+ }
+ }
+ };
+
+ BI.Node = function (id) {
+ if (BI.isObject(id)) {
+ BI.extend(this, id);
+ } else {
+ this.id = id;
+ }
+ this.clear.apply(this, arguments);
+ };
+
+ BI.Node.prototype = {
+ constructor: BI.Node,
+
+ set: function (key, value) {
+ if (BI.isObject(key)) {
+ BI.extend(this, key);
+ return;
+ }
+ this[key] = value;
+ },
+
+ get: function (key) {
+ return this[key];
+ },
+
+ isLeaf: function () {
+ return BI.isEmpty(this.children);
+ },
+
+ getChildren: function () {
+ return this.children;
+ },
+
+ getChildrenLength: function () {
+ return this.children.length;
+ },
+
+ getFirstChild: function () {
+ return BI.first(this.children);
+ },
+
+ getLastChild: function () {
+ return BI.last(this.children);
+ },
+
+ setLeft: function (left) {
+ this.left = left;
+ },
+
+ getLeft: function () {
+ return this.left;
+ },
+
+ setRight: function (right) {
+ this.right = right;
+ },
+
+ getRight: function () {
+ return this.right;
+ },
+
+ setParent: function (parent) {
+ this.parent = parent;
+ },
+
+ getParent: function () {
+ return this.parent;
+ },
+
+ getChild: function (index) {
+ return this.children[index];
+ },
+
+ getChildIndex: function (id) {
+ return BI.findIndex(this.children, function (i, ch) {
+ return ch.get("id") === id;
+ });
+ },
+
+ removeChild: function (id) {
+ this.removeChildByIndex(this.getChildIndex(id));
+ },
+
+ removeChildByIndex: function (index) {
+ var before = this.getChild(index - 1);
+ var behind = this.getChild(index + 1);
+ if (before != null) {
+ before.setRight(behind || null);
+ }
+ if (behind != null) {
+ behind.setLeft(before || null);
+ }
+ this.children.splice(index, 1);
+ },
+
+ removeAllChilds: function () {
+ this.children = [];
+ },
+
+ addChild: function (child, index) {
+ var cur = null;
+ if (BI.isUndefined(index)) {
+ cur = this.children.length - 1;
+ } else {
+ cur = index - 1;
+ }
+ child.setParent(this);
+ if (cur >= 0) {
+ this.getChild(cur).setRight(child);
+ child.setLeft(this.getChild(cur));
+ }
+ if (BI.isUndefined(index)) {
+ this.children.push(child);
+ } else {
+ this.children.splice(index, 0, child);
+ }
+ },
+
+ equals: function (obj) {
+ return this === obj || this.id === obj.id;
+ },
+
+ clear: function () {
+ this.parent = null;
+ this.left = null;
+ this.right = null;
+ this.children = [];
+ }
+ };
+
+ BI.extend(BI.Tree, {
+ transformToArrayFormat: function (nodes, pId) {
+ if (!nodes) return [];
+ var r = [];
+ if (BI.isArray(nodes)) {
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ var node = BI.clone(nodes[i]);
+ node.pId = node.pId == null ? pId : node.pId;
+ delete node.children;
+ r.push(node);
+ if (nodes[i]["children"]) {
+ r = r.concat(BI.Tree.transformToArrayFormat(nodes[i]["children"], node.id));
+ }
+ }
+ } else {
+ var newNodes = BI.clone(nodes);
+ newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
+ delete newNodes.children;
+ r.push(newNodes);
+ if (nodes["children"]) {
+ r = r.concat(BI.Tree.transformToArrayFormat(nodes["children"], newNodes.id));
+ }
+ }
+ return r;
+ },
+
+ arrayFormat: function (nodes, pId) {
+ if (!nodes) {
+ return [];
+ }
+ var r = [];
+ if (BI.isArray(nodes)) {
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ var node = nodes[i];
+ node.pId = node.pId == null ? pId : node.pId;
+ r.push(node);
+ if (nodes[i]["children"]) {
+ r = r.concat(BI.Tree.arrayFormat(nodes[i]["children"], node.id));
+ }
+ }
+ } else {
+ var newNodes = nodes;
+ newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
+ r.push(newNodes);
+ if (nodes["children"]) {
+ r = r.concat(BI.Tree.arrayFormat(nodes["children"], newNodes.id));
+ }
+ }
+ return r;
+ },
+
+ transformToTreeFormat: function (sNodes) {
+ var i, l;
+ if (!sNodes) {
+ return [];
+ }
+
+ if (BI.isArray(sNodes)) {
+ var r = [];
+ var tmpMap = [];
+ for (i = 0, l = sNodes.length; i < l; i++) {
+ if (BI.isNull(sNodes[i].id)) {
+ return sNodes;
+ }
+ tmpMap[sNodes[i].id] = BI.clone(sNodes[i]);
+ }
+ for (i = 0, l = sNodes.length; i < l; i++) {
+ if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
+ if (!tmpMap[sNodes[i].pId].children) {
+ tmpMap[sNodes[i].pId].children = [];
+ }
+ tmpMap[sNodes[i].pId].children.push(tmpMap[sNodes[i].id]);
+ } else {
+ r.push(tmpMap[sNodes[i].id]);
+ }
+ delete tmpMap[sNodes[i].id].pId;
+ }
+ return r;
+ } else {
+ return [sNodes];
+ }
+ },
+
+ treeFormat: function (sNodes) {
+ var i, l;
+ if (!sNodes) {
+ return [];
+ }
+
+ if (BI.isArray(sNodes)) {
+ var r = [];
+ var tmpMap = [];
+ for (i = 0, l = sNodes.length; i < l; i++) {
+ if (BI.isNull(sNodes[i].id)) {
+ return sNodes;
+ }
+ tmpMap[sNodes[i].id] = sNodes[i];
+ }
+ for (i = 0, l = sNodes.length; i < l; i++) {
+ if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
+ if (!tmpMap[sNodes[i].pId].children) {
+ tmpMap[sNodes[i].pId].children = [];
+ }
+ tmpMap[sNodes[i].pId].children.push(tmpMap[sNodes[i].id]);
+ } else {
+ r.push(tmpMap[sNodes[i].id]);
+ }
+ }
+ return r;
+ } else {
+ return [sNodes];
+ }
+ },
+
+ traversal: function (array, callback) {
+ if (BI.isNull(array)) {
+ return;
+ }
+ var self = this;
+ BI.any(array, function (i, item) {
+ if (callback(i, item) === false) {
+ return true;
+ }
+ self.traversal(item.children, callback);
+ })
+ }
+ })
+})();//向量操作
+BI.Vector = function (x, y) {
+ this.x = x;
+ this.y = y;
+};
+BI.Vector.prototype = {
+ constructor: BI.Vector,
+ cross: function (v) {
+ return (this.x * v.y - this.y * v.x);
+ },
+ length: function (v) {
+ return (Math.sqrt(this.x * v.x + this.y * v.y));
+ }
+};
+BI.Region = function (x, y, w, h) {
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+};
+BI.Region.prototype = {
+ constructor: BI.Region,
+ //判断两个区域是否相交,若相交,则要么顶点互相包含,要么矩形边界(或对角线)相交
+ isIntersects: function (obj) {
+ if (this.isPointInside(obj.x, obj.y) ||
+ this.isPointInside(obj.x + obj.w, obj.y) ||
+ this.isPointInside(obj.x, obj.y + obj.h) ||
+ this.isPointInside(obj.x + obj.w, obj.y + obj.h)) {
+ return true;
+ } else if (obj.isPointInside(this.x, this.y) ||
+ obj.isPointInside(this.x + this.w, this.y) ||
+ obj.isPointInside(this.x, this.y + this.h) ||
+ obj.isPointInside(this.x + this.w, this.y + this.h)) {
+ return true;
+ } else if (obj.x != null && obj.y != null)//判断矩形对角线相交 |v1 X v2||v1 X v3| < 0
+ {
+ var vector1 = new BI.Vector(this.w, this.h);//矩形对角线向量
+ var vector2 = new BI.Vector(obj.x - this.x, obj.y - this.y);
+ var vector3 = new BI.Vector(vector2.x + obj.w, vector2.y + obj.h);
+ if ((vector1.cross(vector2) * vector1.cross(vector3)) < 0) {
+ return true;
+ }
+ }
+ return false;
+ },
+ //判断一个点是否在这个区域内部
+ isPointInside: function (x, y) {
+ if (this.x == null || this.y == null) {
+ return false;
+ }
+ if (x >= this.x && x <= this.x + this.w && y >= this.y && y <= this.y + this.h) {
+ return true;
+ }
+ return false;
+ },
+ //返回区域的重心,因为是矩形所以返回中点
+ getPosition: function () {
+ var pos = [];
+ pos.push(this.x + this.w / 2);
+ pos.push(this.y + this.h / 2);
+ return pos;
+ }
+};;
+!(function (BI) {
+
+ if (BI.isIE()) {
+ XMLSerializer = null;
+ DOMParser = null;
+ }
+
+
+ var XML = {
+ Document: {
+ NodeType: {
+ ELEMENT: 1,
+ ATTRIBUTE: 2,
+ TEXT: 3,
+ CDATA_SECTION: 4,
+ ENTITY_REFERENCE: 5,
+ ENTITY: 6,
+ PROCESSING_INSTRUCTION: 7,
+ COMMENT: 8,
+ DOCUMENT: 9,
+ DOCUMENT_TYPE: 10,
+ DOCUMENT_FRAGMENT: 11,
+ NOTATION: 12
+ }
+ }
+ };
+
+ XML.ResultType = {
+ single: 'single',
+ array: 'array'
+ };
+
+ XML.fromString = function (xmlStr) {
+ try {
+ var parser = new DOMParser();
+ return parser.parseFromString(xmlStr, "text/xml");
+ } catch (e) {
+ var arrMSXML = ["MSXML2.DOMDocument.6.0", "MSXML2.DOMDocument.3.0"];
+ for (var i = 0; i < arrMSXML.length; i++) {
+ try {
+ var xmlDoc = new ActiveXObject(arrMSXML[i]);
+ xmlDoc.setProperty("SelectionLanguage", "XPath");
+ xmlDoc.async = false;
+ xmlDoc.loadXML(xmlStr);
+ return xmlDoc;
+ } catch (xmlError) {
+ }
+ }
+ }
+ };
+
+ XML.toString = function (xmlNode) {
+ if (!BI.isIE()) {
+ var xmlSerializer = new XMLSerializer();
+ return xmlSerializer.serializeToString(xmlNode);
+ } else
+ return xmlNode.xml;
+ };
+
+ XML.getNSResolver = function (str) {
+ if (!str) {
+ return null;
+ }
+ var list = str.split(' ');
+ var namespaces = {};
+ for (var i = 0; i < list.length; i++) {
+ var pair = list[i].split('=');
+ var fix = BI.trim(pair[0]).replace("xmlns:", "");
+ namespaces[fix] = BI.trim(pair[1]).replace(/"/g, "").replace(/'/g, "");
+ }
+ return function (prefix) {
+ return namespaces[prefix];
+ };
+ };
+
+ XML.eval = function (context, xpathExp, resultType, namespaces) {
+ if ((BI.isIE() && ('undefined' === typeof(context.selectSingleNode) || 'undefined' === typeof(context.selectNodes)))) {
+ return XML.eval2(context, xpathExp, resultType, namespaces);
+ } else {
+ if (BI.isIE()) {
+ namespaces = namespaces ? namespaces : "";
+ var doc = (context.nodeType == XML.Document.NodeType.DOCUMENT) ? context : context.ownerDocument;
+ doc.setProperty("SelectionNamespaces", namespaces);
+ var result;
+ if (resultType == this.ResultType.single) {
+ result = context.selectSingleNode(xpathExp);
+ } else {
+ result = context.selectNodes(xpathExp) || [];
+ }
+ doc.setProperty("SelectionNamespaces", "");
+ return result;
+ } else {
+ var node = context;
+ var xmlDoc = (context.nodeName.indexOf("document") == -1) ? context.ownerDocument : context;
+ var retType = (resultType == this.ResultType.single) ? XPathResult.FIRST_ORDERED_NODE_TYPE : XPathResult.ANY_TYPE;
+ var col = xmlDoc.evaluate(xpathExp, node, XML.getNSResolver(namespaces), retType, null);
+
+ if (retType == XPathResult.FIRST_ORDERED_NODE_TYPE) {
+ return col.singleNodeValue;
+ } else {
+ var thisColMemb = col.iterateNext();
+ var rowsCol = [];
+ while (thisColMemb) {
+ rowsCol[rowsCol.length] = thisColMemb;
+ thisColMemb = col.iterateNext();
+ }
+ return rowsCol;
+ }
+ }
+ }
+ };
+
+ XML.eval2 = function (context, xpathExp, resultType, namespaces) {
+ if (resultType !== "single" && resultType !== undefined && resultType !== null) {
+ throw new Error("justep.SimpleXML.eval only be resultType='single', not" + resultType);
+ }
+
+ if (context === null || context === undefined || xpathExp === null || xpathExp === undefined) {
+ return context;
+ }
+
+ if (context.nodeType == XML.Document.NodeType.DOCUMENT) {
+ context = context.documentElement;
+ }
+
+ var childs, i;
+ if (xpathExp.indexOf("/") != -1) {
+ var items = xpathExp.split("/");
+ var isAbs = xpathExp.substring(0, 1) == "/";
+ for (i = 0; i < items.length; i++) {
+ var item = items[i];
+ if (item === "") {
+ continue;
+ } else {
+ var next = null;
+ var ii = i + 1;
+ for (; ii < items.length; ii++) {
+ if (next === null) {
+ next = items[ii];
+ } else {
+ next = next + "/" + items[ii];
+ }
+ }
+
+ if (item == ".") {
+ return this.eval(context, next, resultType);
+
+ } else if (item == "..") {
+ return this.eval2(context.parentNode, next, resultType);
+
+ } else if (item == "*") {
+ if (isAbs) {
+ return this.eval2(context, next, resultType);
+
+ } else {
+ childs = context.childNodes;
+ for (var j = 0; j < childs.length; j++) {
+ var tmp = this.eval2(childs[j], next, resultType);
+ if (tmp !== null) {
+ return tmp;
+ }
+ }
+ return null;
+ }
+
+ } else {
+ if (isAbs) {
+ if (context.nodeName == item) {
+ return this.eval2(context, next, resultType);
+ } else {
+ return null;
+ }
+ } else {
+ var child = this.getChildByName(context, item);
+ if (child !== null) {
+ return this.eval2(child, next, resultType);
+ } else {
+ return null;
+ }
+
+ }
+ }
+
+ }
+ }
+
+ return null;
+
+ } else {
+ if ("text()" == xpathExp) {
+ childs = context.childNodes;
+ for (i = 0; i < childs.length; i++) {
+ if (childs[i].nodeType == XML.Document.NodeType.TEXT) {
+ return childs[i];
+ }
+ }
+ return null;
+ } else {
+ return this.getChildByName(context, xpathExp);
+ }
+ }
+ };
+
+ XML.getChildByName = function (context, name) {
+ if (context === null || context === undefined || name === null || name === undefined) {
+ return null;
+ }
+
+ if (context.nodeType == XML.Document.NodeType.DOCUMENT) {
+ context = context.documentElement;
+ }
+
+ var childs = context.childNodes;
+ for (var i = 0; i < childs.length; i++) {
+ if (childs[i].nodeType == XML.Document.NodeType.ELEMENT && (childs[i].nodeName == name || name == "*")) {
+ return childs[i];
+ }
+ }
+
+ return null;
+ };
+
+ XML.appendChildren = function (context, xpathExp, nodes, isBefore) {
+ nodes = (typeof nodes.length != "undefined") ? nodes : [nodes];
+ var finded = this.eval(context, xpathExp);
+ var count = finded.length;
+ for (var i = 0; i < count; i++) {
+ if (isBefore && finded[i].firstNode) {
+ this._insertBefore(finded[i], nodes, finded[i].firstNode);
+ } else {
+ for (var j = 0; j < nodes.length; j++) {
+ finded[i].appendChild(nodes[j]);
+ }
+ }
+ }
+ return count;
+ };
+
+ XML.removeNodes = function (context, xpathExp) {
+ var nodes = this.eval(context, xpathExp);
+ for (var i = 0; i < nodes.length; i++) {
+ nodes[i].parentNode.removeChild(nodes[i]);
+ }
+ };
+
+ XML._insertBefore = function (parent, newchildren, refchild) {
+ for (var i = 0; i < newchildren.length; i++) {
+ parent.insertBefore(newchildren[i], refchild);
+ }
+ };
+
+ XML.insertNodes = function (context, xpathExp, nodes, isBefore) {
+ nodes = (typeof nodes.length != "undefined") ? nodes : [nodes];
+ var finded = this.eval(context, xpathExp);
+ var count = finded.length;
+ for (var i = 0; i < count; i++) {
+ var refnode = (isBefore) ? finded[i] : finded[i].nextSibling;
+ this._insertBefore(finded[i].parentNode, nodes, refnode);
+ }
+ return count;
+ };
+
+ XML.replaceNodes = function (context, xpathExp, nodes) {
+ nodes = (typeof nodes.length != "undefined") ? nodes : [nodes];
+ var finded = this.eval(context, xpathExp);
+ var count = finded.length;
+ for (var i = 0; i < count; i++) {
+ var refnode = finded[i];
+ var parent = refnode.parentNode;
+ this._insertBefore(parent, nodes, refnode);
+ parent.removeChild(refnode);
+ }
+ return count;
+ };
+
+ XML.setNodeText = function (context, xpathExp, text) {
+ var finded = this.eval(context, xpathExp, this.ResultType.single);
+ if (finded === null) {
+ return;
+ }
+ if (finded.nodeType == XML.Document.NodeType.ELEMENT) {
+ var textNode = this.eval(finded, "./text()", this.ResultType.single);
+ if (!textNode) {
+ textNode = finded.ownerDocument.createTextNode("");
+ finded.appendChild(textNode);
+ }
+ textNode.nodeValue = text;
+ } else {
+ finded.nodeValue = text;
+ }
+ return;
+ };
+
+ XML.getNodeText = function (context, xpathExp, defaultValue) {
+ var finded = xpathExp ? this.eval(context, xpathExp, this.ResultType.single) : context;
+ if (finded && (finded.nodeType == XML.Document.NodeType.ELEMENT)) {
+ finded = this.eval(finded, "./text()", this.ResultType.single);
+ }
+ return (finded && finded.nodeValue) ? "" + finded.nodeValue : (defaultValue !== undefined) ? defaultValue : null;
+ };
+
+ XML.Namespaces = {
+ XMLSCHEMA: "http://www.w3.org/2001/XMLSchema#",
+ XMLSCHEMA_STRING: "http://www.w3.org/2001/XMLSchema#String",
+ XMLSCHEMA_LONG: "http://www.w3.org/2001/XMLSchema#Long",
+ XMLSCHEMA_INTEGER: 'http://www.w3.org/2001/XMLSchema#Integer',
+ XMLSCHEMA_FLOAT: 'http://www.w3.org/2001/XMLSchema#Float',
+ XMLSCHEMA_DOUBLE: 'http://www.w3.org/2001/XMLSchema#Double',
+ XMLSCHEMA_DECIMAL: 'http://www.w3.org/2001/XMLSchema#Decimal',
+ XMLSCHEMA_DATE: 'http://www.w3.org/2001/XMLSchema#Date',
+ XMLSCHEMA_TIME: 'http://www.w3.org/2001/XMLSchema#Time',
+ XMLSCHEMA_DATETIME: 'http://www.w3.org/2001/XMLSchema#DateTime',
+ XMLSCHEMA_BOOLEAN: 'http://www.w3.org/2001/XMLSchema#Boolean',
+ XMLSCHEMA_SYMBOL: 'http://www.w3.org/2001/XMLSchema#Symbol',
+ JUSTEPSCHEMA: "http://www.justep.com/xbiz#",
+ RDF: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+ JUSTEP: "http://www.justep.com/x5#",
+ 'get': function (type) {
+ type = type ? type.toLowerCase() : "string";
+ if ("string" == type) {
+ return XML.Namespaces.XMLSCHEMA_STRING;
+ }
+ else if ("integer" == type) {
+ return XML.Namespaces.XMLSCHEMA_INTEGER;
+ }
+ else if ("long" == type) {
+ return XML.Namespaces.XMLSCHEMA_LONG;
+ }
+ else if ("float" == type) {
+ return XML.Namespaces.XMLSCHEMA_FLOAT;
+ }
+ else if ("double" == type) {
+ return XML.Namespaces.XMLSCHEMA_DOUBLE;
+ }
+ else if ("decimal" == type) {
+ return XML.Namespaces.XMLSCHEMA_DECIMAL;
+ }
+ else if ("date" == type) {
+ return XML.Namespaces.XMLSCHEMA_DATE;
+ }
+ else if ("time" == type) {
+ return XML.Namespaces.XMLSCHEMA_TIME;
+ }
+ else if ("datetime" == type) {
+ return XML.Namespaces.XMLSCHEMA_DATETIME;
+ }
+ else if ("boolean" == type) {
+ return XML.Namespaces.XMLSCHEMA_BOOLEAN;
+ }
+ }
+ };
+})(BI);BI.BehaviorFactory = {
+ createBehavior: function(key, options){
+ var behavior;
+ switch (key){
+ case "highlight":
+ behavior = BI.HighlightBehavior;
+ break;
+ case "redmark":
+ behavior = BI.RedMarkBehavior;
+ break;
+ }
+ return new behavior(options);
+ }
+}
+
+/**
+ * guy
+ * 行为控件
+ * @class BI.Behavior
+ * @extends BI.OB
+ */
+BI.Behavior = BI.inherit(BI.OB, {
+ _defaultConfig: function() {
+ return BI.extend(BI.Behavior.superclass._defaultConfig.apply(this, arguments), {
+ rule: function(){return true;}
+ });
+ },
+
+ _init : function() {
+ BI.Behavior.superclass._init.apply(this, arguments);
+
+ },
+
+ doBehavior: function(){
+
+ }
+});/**
+ * 布局容器类
+ * @class BI.Layout
+ * @extends BI.Widget
+ *
+ * @cfg {JSON} options 配置属性
+ * @cfg {Boolean} [options.scrollable=false] 子组件超出容器边界之后是否会出现滚动条
+ * @cfg {Boolean} [options.scrollx=false] 子组件超出容器边界之后是否会出现横向滚动条
+ * @cfg {Boolean} [options.scrolly=false] 子组件超出容器边界之后是否会出现纵向滚动条
+ */
+BI.Layout = BI.inherit(BI.Widget, {
+ props: function () {
+ return {
+ scrollable: null, //true, false, null
+ scrollx: false, //true, false
+ scrolly: false, //true, false
+ items: []
+ };
+ },
+
+ render: function () {
+ this._init4Margin();
+ this._init4Scroll();
+ },
+
+ _init4Margin: function () {
+ if (this.options.top) {
+ this.element.css('top', this.options.top);
+ }
+ if (this.options.left) {
+ this.element.css('left', this.options.left);
+ }
+ if (this.options.bottom) {
+ this.element.css('bottom', this.options.bottom);
+ }
+ if (this.options.right) {
+ this.element.css('right', this.options.right);
+ }
+ },
+
+ _init4Scroll: function () {
+ switch (this.options.scrollable) {
+ case true:
+ this.element.css("overflow", "auto");
+ break;
+ case false:
+ this.element.css("overflow", "hidden");
+ break;
+ default :
+ break;
+ }
+ if (this.options.scrollx) {
+ this.element.css({
+ "overflow-x": "auto",
+ "overflow-y": "hidden"
+ });
+ }
+ if (this.options.scrolly) {
+ this.element.css({
+ "overflow-x": "hidden",
+ "overflow-y": "auto"
+ });
+ }
+ },
+
+ _mountChildren: function () {
+ var self = this;
+ var frag = document.createDocumentFragment();
+ var hasChild = false;
+ BI.each(this._children, function (i, widget) {
+ if (widget.element !== self.element) {
+ frag.appendChild(widget.element[0]);
+ hasChild = true;
+ }
+ });
+ if (hasChild === true) {
+ this.element.append(frag);
+ }
+ },
+
+ _getChildName: function (index) {
+ return index + "";
+ },
+
+ _addElement: function (i, item) {
+ var self = this, w;
+ if (!this.hasWidget(this._getChildName(i))) {
+ w = BI.createWidget(item);
+ w.on(BI.Events.DESTROY, function () {
+ BI.each(self._children, function (name, child) {
+ if (child === w) {
+ BI.remove(self._children, child);
+ self.removeItemAt(name | 0);
+ }
+ });
+ });
+ this.addWidget(this._getChildName(i), w);
+ } else {
+ w = this.getWidgetByName(this._getChildName(i));
+ }
+ return w;
+ },
+
+ _getOptions: function (item) {
+ if (item instanceof BI.Widget) {
+ item = item.options;
+ }
+ item = BI.stripEL(item);
+ if (item instanceof BI.Widget) {
+ item = item.options;
+ }
+ return item;
+ },
+
+ _compare: function (item1, item2) {
+ var self = this;
+ return eq(item1, item2);
+
+ //不比较函数
+ function eq(a, b, aStack, bStack) {
+ if (a === b) {
+ return a !== 0 || 1 / a === 1 / b;
+ }
+ if (a == null || b == null) {
+ return a === b;
+ }
+ var className = Object.prototype.toString.call(a);
+ switch (className) {
+ case '[object RegExp]':
+ case '[object String]':
+ return '' + a === '' + b;
+ case '[object Number]':
+ if (+a !== +a) {
+ return +b !== +b;
+ }
+ return +a === 0 ? 1 / +a === 1 / b : +a === +b;
+ case '[object Date]':
+ case '[object Boolean]':
+ return +a === +b;
+ }
+
+ var areArrays = className === '[object Array]';
+ if (!areArrays) {
+ if (BI.isFunction(a) && BI.isFunction(b)) {
+ return true;
+ }
+ a = self._getOptions(a);
+ b = self._getOptions(b);
+ }
+
+ aStack = aStack || [];
+ bStack = bStack || [];
+ var length = aStack.length;
+ while (length--) {
+ if (aStack[length] === a) {
+ return bStack[length] === b;
+ }
+ }
+
+ aStack.push(a);
+ bStack.push(b);
+
+ if (areArrays) {
+ length = a.length;
+ if (length !== b.length) {
+ return false;
+ }
+ while (length--) {
+ if (!eq(a[length], b[length], aStack, bStack)) {
+ return false;
+ }
+ }
+ } else {
+ var keys = _.keys(a), key;
+ length = keys.length;
+ if (_.keys(b).length !== length) {
+ return false;
+ }
+ while (length--) {
+ key = keys[length];
+ if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) {
+ return false;
+ }
+ }
+ }
+ aStack.pop();
+ bStack.pop();
+ return true;
+ }
+ },
+
+ _getWrapper: function () {
+ return this.element;
+ },
+
+ _addItemAt: function (index, item) {
+ for (var i = this.options.items.length; i > index; i--) {
+ this._children[this._getChildName(i)] = this._children[this._getChildName(i - 1)];
+ }
+ delete this._children[this._getChildName(index)];
+ this.options.items.splice(index, 0, item);
+ },
+
+ _removeItemAt: function (index) {
+ for (var i = index; i < this.options.items.length - 1; i++) {
+ this._children[this._getChildName(i)] = this._children[this._getChildName(i + 1)];
+ }
+ delete this._children[this._getChildName(this.options.items.length - 1)];
+ this.options.items.splice(index, 1);
+ },
+
+ /**
+ * 添加一个子组件到容器中
+ * @param {JSON/BI.Widget} item 子组件
+ */
+ addItem: function (item) {
+ return this.addItemAt(this.options.items.length, item);
+ },
+
+ prependItem: function (item) {
+ return this.addItemAt(0, item);
+ },
+
+ addItemAt: function (index, item) {
+ if (index < 0 || index > this.options.items.length) {
+ return;
+ }
+ this._addItemAt(index, item);
+ var w = this._addElement(index, item);
+ if (index > 0) {
+ this._children[this._getChildName(index - 1)].element.after(w.element);
+ } else {
+ w.element.prependTo(this._getWrapper());
+ }
+ w._mount();
+ return w;
+ },
+
+ removeItemAt: function (indexes) {
+ indexes = BI.isArray(indexes) ? indexes : [indexes];
+ var deleted = [];
+ var newItems = [], newChildren = {};
+ for (var i = 0, len = this.options.items.length; i < len; i++) {
+ var child = this._children[this._getChildName(i)];
+ if (indexes.contains(i)) {
+ child && deleted.push(child);
+ } else {
+ newChildren[this._getChildName(newItems.length)] = child;
+ newItems.push(this.options.items[i]);
+ }
+ }
+ this.options.items = newItems;
+ this._children = newChildren;
+ BI.each(deleted, function (i, c) {
+ c._destroy();
+ });
+ },
+
+ updateItemAt: function (index, item) {
+ if (index < 0 || index > this.options.items.length - 1) {
+ return;
+ }
+
+ var child = this._children[this._getChildName(index)];
+ var updated;
+ if (updated = child.update(this._getOptions(item))) {
+ return updated;
+ }
+ var del = this._children[this._getChildName(index)];
+ delete this._children[this._getChildName(index)];
+ this.options.items.splice(index, 1);
+ var w = this._addElement(index, item);
+ this.options.items.splice(index, 0, item);
+ this._children[this._getChildName(index)] = w;
+ if (index > 0) {
+ this._children[this._getChildName(index - 1)].element.after(w.element);
+ } else {
+ w.element.prependTo(this._getWrapper());
+ }
+ del._destroy();
+ w._mount();
+ },
+
+ addItems: function (items) {
+ var self = this, o = this.options;
+ var fragment = document.createDocumentFragment();
+ var added = [];
+ BI.each(items, function (i, item) {
+ var w = self._addElement(o.items.length, item);
+ self._children[self._getChildName(o.items.length)] = w;
+ o.items.push(item);
+ added.push(w);
+ fragment.appendChild(w.element[0]);
+ });
+ this._getWrapper().append(fragment);
+ BI.each(added, function (i, w) {
+ w._mount();
+ })
+ },
+
+ prependItems: function (items) {
+ var self = this;
+ items = items || [];
+ var fragment = document.createDocumentFragment();
+ var added = [];
+ for (var i = items.length - 1; i >= 0; i--) {
+ this._addItemAt(0, items[i]);
+ var w = this._addElement(0, items[i]);
+ self._children[self._getChildName(0)] = w;
+ this.options.items.unshift(items[i]);
+ added.push(w);
+ fragment.appendChild(w.element[0]);
+ }
+ this._getWrapper().prepend(fragment);
+ BI.each(added, function (i, w) {
+ w._mount();
+ })
+ },
+
+ getValue: function () {
+ var self = this, value = [], child;
+ BI.each(this.options.items, function (i) {
+ if (child = self._children[self._getChildName(i)]) {
+ var v = child.getValue();
+ v = BI.isArray(v) ? v : [v];
+ value = value.concat(v);
+ }
+ });
+ return value;
+ },
+
+ setValue: function (v) {
+ var self = this, child;
+ BI.each(this.options.items, function (i) {
+ if (child = self._children[self._getChildName(i)]) {
+ child.setValue(v);
+ }
+ })
+ },
+
+ setText: function (v) {
+ var self = this, child;
+ BI.each(this.options.items, function (i) {
+ if (child = self._children[self._getChildName(i)]) {
+ child.setText(v);
+ }
+ })
+ },
+
+ update: function (item) {
+ var o = this.options;
+ var items = item.items || [];
+ var updated, i, len;
+ for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) {
+ if (!this._compare(o.items[i], items[i])) {
+ updated = this.updateItemAt(i, items[i]) || updated;
+ }
+ }
+ if (o.items.length > items.length) {
+ var deleted = [];
+ for (i = items.length; i < o.items.length; i++) {
+ deleted.push(this._children[this._getChildName(i)]);
+ delete this._children[this._getChildName(i)];
+ }
+ o.items.splice(items.length);
+ BI.each(deleted, function (i, w) {
+ w._destroy();
+ })
+ } else if (items.length > o.items.length) {
+ for (i = o.items.length; i < items.length; i++) {
+ this.addItemAt(i, items[i]);
+ }
+ }
+ return updated;
+ },
+
+ stroke: function (items) {
+ var self = this;
+ BI.each(items, function (i, item) {
+ if (!!item) {
+ self._addElement(i, item);
+ }
+ });
+ },
+
+ removeWidget: function (nameOrWidget) {
+ var removeIndex;
+ if (BI.isWidget(nameOrWidget)) {
+ BI.each(this._children, function (name, child) {
+ if (child === nameOrWidget) {
+ removeIndex = name;
+ }
+ })
+ } else {
+ removeIndex = nameOrWidget;
+ }
+ if (removeIndex) {
+ this._removeItemAt(removeIndex | 0);
+ }
+ },
+
+ empty: function () {
+ BI.Layout.superclass.empty.apply(this, arguments);
+ this.options.items = [];
+ },
+
+ destroy: function () {
+ BI.Layout.superclass.destroy.apply(this, arguments);
+ this.options.items = [];
+ },
+
+ populate: function (items) {
+ var self = this, o = this.options;
+ items = items || [];
+ if (this._isMounted) {
+ this.update({items: items});
+ return;
+ }
+ this.options.items = items;
+ this.stroke(items);
+ },
+
+ resize: function () {
+
+ }
+});
+BI.shortcut('bi.layout', BI.Layout);/**
+ * guy
+ * 由一个元素切换到另一个元素的行为
+ * @class BI.Action
+ * @extends BI.OB
+ * @abstract
+ */
+BI.Action = BI.inherit(BI.OB, {
+ _defaultConfig: function() {
+ return BI.extend(BI.Action.superclass._defaultConfig.apply(this, arguments), {
+ src: null,
+ tar: null
+ });
+ },
+
+ _init : function() {
+ BI.Action.superclass._init.apply(this, arguments);
+ },
+
+ actionPerformed: function(src, tar, callback){
+
+ },
+
+ actionBack: function(tar, src, callback){
+
+ }
+});
+
+BI.ActionFactory = {
+ createAction: function(key, options){
+ var action;
+ switch (key){
+ case "show":
+ action = BI.ShowAction;
+ break;
+ }
+ return new action(options);
+ }
+}/**
+ * guy
+ * 由一个元素切换到另一个元素的行为
+ * @class BI.ShowAction
+ * @extends BI.Action
+ */
+BI.ShowAction = BI.inherit(BI.Action, {
+ _defaultConfig: function () {
+ return BI.extend(BI.ShowAction.superclass._defaultConfig.apply(this, arguments), {});
+ },
+
+ _init: function () {
+ BI.ShowAction.superclass._init.apply(this, arguments);
+ },
+
+ actionPerformed: function (src, tar, callback) {
+ tar = tar || this.options.tar;
+ tar.setVisible(true);
+ callback && callback();
+ },
+
+ actionBack: function (tar, src, callback) {
+ tar = tar || this.options.tar;
+ tar.setVisible(false);
+ callback && callback();
+ }
+});/**
+ * @class BI.FloatSection
+ * @extends BI.View
+ * @abstract
+ */
+BI.FloatSection = BI.inherit(BI.View, {
+ _init : function() {
+ BI.FloatSection.superclass._init.apply(this, arguments);
+ var self = this;
+ var flatten = ["_init", "_defaultConfig", "_vessel", "_render", "getName", "listenEnd", "local", "refresh", "load", "change"];
+ flatten = BI.makeObject(flatten, true);
+ BI.each(this.constructor.caller.caller.caller.prototype, function (key) {
+ if (flatten[key]) {
+ return;
+ }
+ var f = self[key];
+ if (BI.isFunction(f)) {
+ self[key] = BI.bind(function () {
+ if (this.model._start === true) {
+ this._F.push({f: f, arg: arguments});
+ return;
+ }
+ return f.apply(this, arguments);
+ }, self);
+ }
+ })
+ },
+
+ rebuildNorth : function(north) {
+ return true;
+ },
+ rebuildCenter : function(center) {},
+ rebuildSouth : function(south) {
+ return false;
+ },
+ close: function(){
+ this.notifyParentEnd();
+ this.trigger(BI.PopoverSection.EVENT_CLOSE);
+ },
+ end: function(){
+
+ }
+});
+
+/**
+ * 弹出层
+ * @class BI.PopoverSection
+ * @extends BI.Widget
+ * @abstract
+ */
+BI.PopoverSection = BI.inherit(BI.Widget, {
+ _init : function() {
+ BI.PopoverSection.superclass._init.apply(this, arguments);
+ },
+
+ rebuildNorth : function(north) {
+ return true;
+ },
+ rebuildCenter : function(center) {},
+ rebuildSouth : function(south) {
+ return false;
+ },
+ close: function(){
+ this.fireEvent(BI.PopoverSection.EVENT_CLOSE);
+ },
+ end: function(){
+
+ }
+});
+BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
+ if (!window.BI) {
+ window.BI = {};
+ }
+ function isEmpty(value) {
+ // 判断是否为空值
+ var result = value === "" || value === null || value === undefined;
+ return result;
+ }
+
+ // 判断是否是无效的日期
+ function isInvalidDate(date) {
+ return date == "Invalid Date" || date == "NaN";
+ }
+
+ /**
+ * 科学计数格式
+ */
+ function _eFormat(text, fmt) {
+ var e = fmt.indexOf("E");
+ var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1);
+ if (/^[0\.-]+$/.test(text)) {
+ text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright)
+ } else {
+ var isNegative = text < 0;
+ if (isNegative) {
+ text = text.substr(1);
+ }
+ var elvl = (eleft.split('.')[0] || '').length;
+ var point = text.indexOf(".");
+ if (point < 0) {
+ point = text.length;
+ }
+ var i = 0; //第一个不为0的数的位置
+ text = text.replace('.', '');
+ for (var len = text.length; i < len; i++) {
+ var ech = text.charAt(i);
+ if (ech <= '9' && ech >= '1') {
+ break;
+ }
+ }
+ var right = point - i - elvl;
+ var left = text.substr(i, elvl);
+ var dis = i + elvl - text.length;
+ if (dis > 0) {
+ //末位补全0
+ for (var k = 0; k < dis; k++) {
+ left += '0';
+ }
+ } else {
+ left += '.' + text.substr(i + elvl);
+ }
+ left = left.replace(/^[0]+/, '');
+ if (right < 0 && eright.indexOf('-') < 0) {
+ eright += ';-' + eright;
+ }
+ text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright);
+ if (isNegative) {
+ text = '-' + text;
+ }
+ }
+ return text;
+ }
+
+ /**
+ * 数字格式
+ */
+ function _numberFormat(text, format) {
+ var text = text + '';
+ //数字格式,区分正负数
+ var numMod = format.indexOf(';');
+ if (numMod > -1) {
+ if (text >= 0) {
+ return _numberFormat(text + "", format.substring(0, numMod));
+ } else {
+ return _numberFormat((-text) + "", format.substr(numMod + 1));
+ }
+ }
+ var tp = text.split('.'), fp = format.split('.'),
+ tleft = tp[0] || '', fleft = fp[0] || '',
+ tright = tp[1] || '', fright = fp[1] || '';
+ //百分比,千分比的小数点移位处理
+ if (/[%‰]$/.test(format)) {
+ var paddingZero = /[%]$/.test(format) ? '00' : '000';
+ tright += paddingZero;
+ tleft += tright.substr(0, paddingZero.length);
+ tleft = tleft.replace(/^0+/gi, '');
+ tright = tright.substr(paddingZero.length).replace(/0+$/gi, '');
+ }
+ var right = _dealWithRight(tright, fright);
+ if (right.leftPlus) {
+ //小数点后有进位
+ tleft = parseInt(tleft) + 1 + '';
+
+ tleft = isNaN(tleft) ? '1' : tleft;
+ }
+ right = right.num;
+ var left = _dealWithLeft(tleft, fleft);
+ if (!(/[0-9]/.test(left))) {
+ left = left + '0';
+ }
+ if (!(/[0-9]/.test(right))) {
+ return left + right;
+ } else {
+ return left + '.' + right;
+ }
+ }
+
+ /**
+ * 处理小数点右边小数部分
+ * @param tright 右边内容
+ * @param fright 右边格式
+ * @returns {JSON} 返回处理结果和整数部分是否需要进位
+ * @private
+ */
+ function _dealWithRight(tright, fright) {
+ var right = '', j = 0, i = 0;
+ for (var len = fright.length; i < len; i++) {
+ var ch = fright.charAt(i);
+ var c = tright.charAt(j);
+ switch (ch) {
+ case '0':
+ if (isEmpty(c)) {
+ c = '0';
+ }
+ right += c;
+ j++;
+ break;
+ case '#':
+ right += c;
+ j++;
+ break;
+ default :
+ right += ch;
+ break;
+ }
+ }
+ var rll = tright.substr(j);
+ var result = {};
+ if (!isEmpty(rll) && rll.charAt(0) > 4) {
+ //有多余字符,需要四舍五入
+ result.leftPlus = true;
+ var numReg = right.match(/^[0-9]+/);
+ if (numReg) {
+ var num = numReg[0];
+ var orilen = num.length;
+ var newnum = parseInt(num) + 1 + '';
+ //进位到整数部分
+ if (newnum.length > orilen) {
+ newnum = newnum.substr(1);
+ } else {
+ newnum = String.leftPad(newnum, orilen, '0');
+ result.leftPlus = false;
+ }
+ right = right.replace(/^[0-9]+/, newnum);
+ }
+ }
+ result.num = right;
+ return result;
+ }
+
+ /**
+ * 处理小数点左边整数部分
+ * @param tleft 左边内容
+ * @param fleft 左边格式
+ * @returns {string} 返回处理结果
+ * @private
+ */
+ function _dealWithLeft(tleft, fleft) {
+ var left = '';
+ var j = tleft.length - 1;
+ var combo = -1, last = -1;
+ var i = fleft.length - 1;
+ for (; i >= 0; i--) {
+ var ch = fleft.charAt(i);
+ var c = tleft.charAt(j);
+ switch (ch) {
+ case '0':
+ if (isEmpty(c)) {
+ c = '0';
+ }
+ last = -1;
+ left = c + left;
+ j--;
+ break;
+ case '#':
+ last = i;
+ left = c + left;
+ j--;
+ break;
+ case ',':
+ if (!isEmpty(c)) {
+ //计算一个,分隔区间的长度
+ var com = fleft.match(/,[#0]+/);
+ if (com) {
+ combo = com[0].length - 1;
+ }
+ left = ',' + left;
+ }
+ break;
+ default :
+ left = ch + left;
+ break;
+ }
+ }
+ if (last > -1) {
+ //处理剩余字符
+ var tll = tleft.substr(0, j + 1);
+ left = left.substr(0, last) + tll + left.substr(last);
+ }
+ if (combo > 0) {
+ //处理,分隔区间
+ var res = left.match(/[0-9]+,/);
+ if (res) {
+ res = res[0];
+ var newstr = '', n = res.length - 1 - combo;
+ for (; n >= 0; n = n - combo) {
+ newstr = res.substr(n, combo) + ',' + newstr;
+ }
+ var lres = res.substr(0, n + combo);
+ if (!isEmpty(lres)) {
+ newstr = lres + ',' + newstr;
+ }
+ }
+ left = left.replace(/[0-9]+,/, newstr);
+ }
+ return left;
+ }
+
+ BI.cjkEncode = function (text) {
+ // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
+ if (typeof text !== 'string') {
+ return text;
+ }
+
+ var newText = "";
+ for (var i = 0; i < text.length; i++) {
+ var code = text.charCodeAt(i);
+ if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]".
+ newText += "[" + code.toString(16) + "]";
+ } else {
+ newText += text.charAt(i);
+ }
+ }
+
+ return newText
+ };
+
+ BI.cjkEncodeDO = function (o) {
+ if (BI.isPlainObject(o)) {
+ var result = {};
+ $.each(o, function (k, v) {
+ if (!(typeof v == "string")) {
+ v = BI.jsonEncode(v);
+ }
+ //wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。
+ k = BI.cjkEncode(k);
+ result[k] = BI.cjkEncode(v);
+ });
+ return result;
+ }
+ return o;
+ };
+
+ BI.jsonEncode = function (o) {
+ //james:这个Encode是抄的EXT的
+ var useHasOwn = {}.hasOwnProperty ? true : false;
+
+ // crashes Safari in some instances
+ //var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/;
+
+ var m = {
+ "\b": '\\b',
+ "\t": '\\t',
+ "\n": '\\n',
+ "\f": '\\f',
+ "\r": '\\r',
+ '"': '\\"',
+ "\\": '\\\\'
+ };
+
+ var encodeString = function (s) {
+ if (/["\\\x00-\x1f]/.test(s)) {
+ return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) {
+ var c = m[b];
+ if (c) {
+ return c;
+ }
+ c = b.charCodeAt();
+ return "\\u00" +
+ Math.floor(c / 16).toString(16) +
+ (c % 16).toString(16);
+ }) + '"';
+ }
+ return '"' + s + '"';
+ };
+
+ var encodeArray = function (o) {
+ var a = ["["], b, i, l = o.length, v;
+ for (i = 0; i < l; i += 1) {
+ v = o[i];
+ switch (typeof v) {
+ case "undefined":
+ case "function":
+ case "unknown":
+ break;
+ default:
+ if (b) {
+ a.push(',');
+ }
+ a.push(v === null ? "null" : BI.jsonEncode(v));
+ b = true;
+ }
+ }
+ a.push("]");
+ return a.join("");
+ };
+
+ if (typeof o == "undefined" || o === null) {
+ return "null";
+ } else if (BI.isArray(o)) {
+ return encodeArray(o);
+ } else if (o instanceof Date) {
+ /*
+ * alex:原来只是把年月日时分秒简单地拼成一个String,无法decode
+ * 现在这么处理就可以decode了,但是JS.jsonDecode和Java.JSONObject也要跟着改一下
+ */
+ return BI.jsonEncode({
+ __time__: o.getTime()
+ })
+ } else if (typeof o == "string") {
+ return encodeString(o);
+ } else if (typeof o == "number") {
+ return isFinite(o) ? String(o) : "null";
+ } else if (typeof o == "boolean") {
+ return String(o);
+ } else if (BI.isFunction(o)) {
+ return String(o);
+ } else {
+ var a = ["{"], b, i, v;
+ for (i in o) {
+ if (!useHasOwn || o.hasOwnProperty(i)) {
+ v = o[i];
+ switch (typeof v) {
+ case "undefined":
+ case "unknown":
+ break;
+ default:
+ if (b) {
+ a.push(',');
+ }
+ a.push(BI.jsonEncode(i), ":",
+ v === null ? "null" : BI.jsonEncode(v));
+ b = true;
+ }
+ }
+ }
+ a.push("}");
+ return a.join("");
+ }
+ };
+
+ BI.jsonDecode = function (text) {
+
+ try {
+ // 注意0啊
+ //var jo = $.parseJSON(text) || {};
+ var jo = $.parseJSON(text);
+ if (jo == null) {
+ jo = {};
+ }
+ } catch (e) {
+ /*
+ * richie:浏览器只支持标准的JSON字符串转换,而jQuery会默认调用浏览器的window.JSON.parse()函数进行解析
+ * 比如:var str = "{'a':'b'}",这种形式的字符串转换为JSON就会抛异常
+ */
+ try {
+ jo = new Function("return " + text)() || {};
+ } catch (e) {
+ //do nothing
+ }
+ if (jo == null) {
+ jo = [];
+ }
+ }
+ if (!_hasDateInJson(text)) {
+ return jo;
+ }
+
+ function _hasDateInJson(json) {
+ if (!json || typeof json !== "string") {
+ return false;
+ }
+ return json.indexOf("__time__") != -1;
+ }
+
+ return (function (o) {
+ if (typeof o === "string") {
+ return o;
+ }
+ if (o && o.__time__ != null) {
+ return new Date(o.__time__);
+ }
+ for (var a in o) {
+ if (o[a] == o || typeof o[a] == 'object' || $.isFunction(o[a])) {
+ break;
+ }
+ o[a] = arguments.callee(o[a]);
+ }
+
+ return o;
+ })(jo);
+ };
+
+ BI.contentFormat = function (cv, fmt) {
+ if (isEmpty(cv)) {
+ //原值为空,返回空字符
+ return '';
+ }
+ var text = cv.toString();
+ if (isEmpty(fmt)) {
+ //格式为空,返回原字符
+ return text;
+ }
+ if (fmt.match(/^T/)) {
+ //T - 文本格式
+ return text;
+ } else if (fmt.match(/^D/)) {
+ //D - 日期(时间)格式
+ if (!(cv instanceof Date)) {
+ if (typeof cv === 'number') {
+ //毫秒数类型
+ cv = new Date(cv);
+ } else {
+ //字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构
+ cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long);
+ }
+ }
+ if (!BI.isNull(cv)) {
+ var needTrim = fmt.match(/^DT/);
+ text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1));
+ }
+ } else if (fmt.match(/E/)) {
+ //科学计数格式
+ text = _eFormat(text, fmt);
+ } else {
+ //数字格式
+ text = _numberFormat(text, fmt);
+ }
+ //¤ - 货币格式
+ text = text.replace(/¤/g, '¥');
+ return text;
+ };
+
+ /**
+ * 把日期对象按照指定格式转化成字符串
+ *
+ * @example
+ * var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
+ * var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
+ *
+ * @class BI.date2Str
+ * @param date 日期
+ * @param format 日期格式
+ * @returns {String}
+ */
+ BI.date2Str = function (date, format) {
+ if (!date) {
+ return '';
+ }
+ // O(len(format))
+ var len = format.length, result = '';
+ if (len > 0) {
+ var flagch = format.charAt(0), start = 0, str = flagch;
+ for (var i = 1; i < len; i++) {
+ var ch = format.charAt(i);
+ if (flagch !== ch) {
+ result += compileJFmt({
+ 'char': flagch,
+ 'str': str,
+ 'len': i - start
+ }, date);
+ flagch = ch;
+ start = i;
+ str = flagch;
+ } else {
+ str += ch;
+ }
+ }
+ result += compileJFmt({
+ 'char': flagch,
+ 'str': str,
+ 'len': len - start
+ }, date);
+ }
+ return result;
+
+ function compileJFmt(jfmt, date) {
+ var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
+ switch (ch) {
+ case 'E': //星期
+ str = Date._DN[date.getDay()];
+ break;
+ case 'y': //年
+ if (len <= 3) {
+ str = (date.getFullYear() + '').slice(2, 4);
+ } else {
+ str = date.getFullYear();
+ }
+ break;
+ case 'M': //月
+ if (len > 2) {
+ str = Date._MN[date.getMonth()];
+ } else if (len < 2) {
+ str = date.getMonth() + 1;
+ } else {
+ str = String.leftPad(date.getMonth() + 1 + '', 2, '0');
+ }
+ break;
+ case 'd': //日
+ if (len > 1) {
+ str = String.leftPad(date.getDate() + '', 2, '0');
+ } else {
+ str = date.getDate();
+ }
+ break;
+ case 'h': //时(12)
+ var hour = date.getHours() % 12;
+ if (hour === 0) {
+ hour = 12;
+ }
+ if (len > 1) {
+ str = String.leftPad(hour + '', 2, '0');
+ } else {
+ str = hour;
+ }
+ break;
+ case 'H': //时(24)
+ if (len > 1) {
+ str = String.leftPad(date.getHours() + '', 2, '0');
+ } else {
+ str = date.getHours();
+ }
+ break;
+ case 'm':
+ if (len > 1) {
+ str = String.leftPad(date.getMinutes() + '', 2, '0');
+ } else {
+ str = date.getMinutes();
+ }
+ break;
+ case 's':
+ if (len > 1) {
+ str = String.leftPad(date.getSeconds() + '', 2, '0');
+ } else {
+ str = date.getSeconds();
+ }
+ break;
+ case 'a':
+ str = date.getHours() < 12 ? 'am' : 'pm';
+ break;
+ case 'z':
+ str = date.getTimezone();
+ break;
+ default:
+ str = jfmt.str;
+ break;
+ }
+ return str;
+ }
+ };
+
+ BI.object2Number = function (value) {
+ if (value == null) {
+ return 0;
+ }
+ if (typeof value == 'number') {
+ return value;
+ } else {
+ var str = value + "";
+ if (str.indexOf(".") === -1) {
+ return parseInt(str);
+ } else {
+ return parseFloat(str);
+ }
+ }
+ };
+
+ BI.object2Date = function (obj) {
+ if (obj == null) {
+ return new Date();
+ }
+ if (obj instanceof Date) {
+ return obj;
+ } else if (typeof obj == 'number') {
+ return new Date(obj);
+ } else {
+ var str = obj + "";
+ str = str.replace(/-/g, '/');
+ var dt = new Date(str);
+ if (!isInvalidDate(dt)) {
+ return dt;
+ }
+
+ return new Date();
+ }
+ };
+
+ BI.object2Time = function (obj) {
+ if (obj == null) {
+ return new Date();
+ }
+ if (obj instanceof Date) {
+ return obj;
+ } else {
+ var str = obj + "";
+ str = str.replace(/-/g, '/');
+ var dt = new Date(str);
+ if (!isInvalidDate(dt)) {
+ return dt;
+ }
+ if (str.indexOf('/') === -1 && str.indexOf(':') !== -1) {
+ dt = new Date("1970/01/01 " + str);
+ if (!isInvalidDate(dt)) {
+ return dt;
+ }
+ }
+ dt = BI.str2Date(str, "HH:mm:ss");
+ if (!isInvalidDate(dt)) {
+ return dt;
+ }
+ return new Date();
+ }
+ };
+})();
+/**
+ * guy
+ *
+ * @class BI.HighlightBehavior
+ * @extends BI.Behavior
+ */
+BI.HighlightBehavior = BI.inherit(BI.Behavior, {
+ _defaultConfig: function () {
+ return BI.extend(BI.HighlightBehavior.superclass._defaultConfig.apply(this, arguments), {});
+ },
+
+ _init: function () {
+ BI.HighlightBehavior.superclass._init.apply(this, arguments);
+
+ },
+
+ doBehavior: function (items) {
+ var args = Array.prototype.slice.call(arguments, 1),
+ o = this.options;
+ BI.each(items, function (i, item) {
+ if (item instanceof BI.Single) {
+ var rule = o.rule(item.getValue(), item);
+
+ function doBe(run) {
+ if (run === true) {
+ item.doHighLight.apply(item, args);
+ } else {
+ item.unHighLight.apply(item, args);
+ }
+ }
+
+ if (BI.isFunction(rule)) {
+ rule(doBe);
+ } else {
+ doBe(rule);
+ }
+ } else {
+ item.doBehavior.apply(item, args);
+ }
+ })
+ }
+});/**
+ * guy
+ * 标红行为
+ * @class BI.RedMarkBehavior
+ * @extends BI.Behavior
+ */
+BI.RedMarkBehavior = BI.inherit(BI.Behavior, {
+ _defaultConfig: function() {
+ return BI.extend(BI.RedMarkBehavior.superclass._defaultConfig.apply(this, arguments), {
+
+ });
+ },
+
+ _init : function() {
+ BI.RedMarkBehavior.superclass._init.apply(this, arguments);
+
+ },
+
+ doBehavior: function(items){
+ var args = Array.prototype.slice.call(arguments, 1),
+ o = this.options;
+ BI.each(items, function(i, item){
+ if(item instanceof BI.Single) {
+ if (o.rule(item.getValue(), item)) {
+ item.doRedMark.apply(item, args);
+ } else {
+ item.unRedMark.apply(item, args);
+ }
+ } else {
+ item.doBehavior.apply(item, args);
+ }
+ })
+ }
+});/**
+ * guy
+ * 控制器
+ * Controller层超类
+ * @class BI.Controller
+ * @extends BI.OB
+ * @abstract
+ */
+BI.Controller = BI.inherit(BI.OB, {
+ _defaultConfig: function() {
+ return BI.extend(BI.Controller.superclass._defaultConfig.apply(this, arguments), {
+
+ })
+ },
+ _init : function() {
+ BI.Controller.superclass._init.apply(this, arguments);
+ },
+
+ destroy: function(){
+
+ }
+});
+BI.Controller.EVENT_CHANGE = "__EVENT_CHANGE__";/**
+ * 广播
+ *
+ * Created by GUY on 2015/12/23.
+ * @class
+ */
+BI.BroadcastController = BI.inherit(BI.Controller, {
+ _defaultConfig: function () {
+ return BI.extend(BI.BroadcastController.superclass._defaultConfig.apply(this, arguments), {});
+ },
+
+ _init: function () {
+ BI.BroadcastController.superclass._init.apply(this, arguments);
+ this._broadcasts = {};
+ },
+
+ on: function (name, fn) {
+ var self = this;
+ if (!this._broadcasts[name]) {
+ this._broadcasts[name] = [];
+ }
+ this._broadcasts[name].push(fn);
+ return function () {
+ self.remove(name, fn);
+ }
+ },
+
+ send: function (name) {
+ var args = [].slice.call(arguments, 1);
+ BI.each(this._broadcasts[name], function (i, fn) {
+ fn.apply(null, args);
+ });
+ },
+
+ remove: function (name, fn) {
+ if (fn) {
+ this._broadcasts[name].remove(fn);
+ if (this._broadcasts[name].length === 0) {
+ delete this._broadcasts[name];
+ }
+ } else {
+ delete this._broadcasts[name];
+ }
+ return this;
+ }
+});/**
+ * 气泡图控制器
+ * 控制气泡图的显示方向
+ *
+ * Created by GUY on 2015/8/21.
+ * @class
+ */
+BI.BubblesController = BI.inherit(BI.Controller, {
+ _defaultConfig: function () {
+ return BI.extend(BI.BubblesController.superclass._defaultConfig.apply(this, arguments), {});
+ },
+
+ _const: {
+ bubbleHeight: 35
+ },
+
+ _init: function () {
+ BI.BubblesController.superclass._init.apply(this, arguments);
+ this.bubblesManager = {};
+ this.storeBubbles = {};
+ },
+
+ _createBubble: function (direct, text, height) {
+ return BI.createWidget({
+ type: "bi.bubble",
+ text: text,
+ height: height || 35,
+ direction: direct
+ });
+ },
+
+ _getOffsetLeft: function (name, context, offsetStyle) {
+ var left = 0;
+ if ("center" === offsetStyle) {
+ left = context.element.offset().left + (context.element.bounds().width - this.get(name).element.bounds().width) / 2;
+ if (left < 0) {
+ left = 0;
+ }
+ return left;
+ }
+ if ("right" === offsetStyle) {
+ left = context.element.offset().left + context.element.bounds().width - this.get(name).element.bounds().width;
+ if (left < 0) {
+ left = 0;
+ }
+ return left;
+ }
+ return context.element.offset().left;
+ },
+
+ _getOffsetTop: function (name, context, offsetStyle) {
+ var top = 0;
+ if ("center" === offsetStyle) {
+ top = context.element.offset().top + (context.element.bounds().height - this.get(name).element.bounds().height) / 2;
+ if (top < 0) {
+ top = 0;
+ }
+ return top;
+ } else if ("right" === offsetStyle) {
+ top = context.element.offset().top + context.element.bounds().height - this.get(name).element.bounds().height;
+ if (top < 0) {
+ top = 0;
+ }
+ return top;
+ }
+ return context.element.offset().top;
+ },
+
+ _getLeftPosition: function (name, context, offsetStyle) {
+ var position = $.getLeftPosition(context, this.get(name));
+ position.top = this._getOffsetTop(name, context, offsetStyle);
+ return position;
+ },
+
+ _getBottomPosition: function (name, context, offsetStyle) {
+ var position = $.getBottomPosition(context, this.get(name));
+ position.left = this._getOffsetLeft(name, context, offsetStyle);
+ return position;
+ },
+
+ _getTopPosition: function (name, context, offsetStyle) {
+ var position = $.getTopPosition(context, this.get(name));
+ position.left = this._getOffsetLeft(name, context, offsetStyle);
+ return position;
+ },
+
+ _getRightPosition: function (name, context, offsetStyle) {
+ var position = $.getRightPosition(context, this.get(name));
+ position.top = this._getOffsetTop(name, context, offsetStyle);
+ return position;
+ },
+
+ /**
+ *
+ * @param name
+ * @param text
+ * @param context
+ * @param offsetStyle center, left, right三种类型, 默认left
+ * @returns {BI.BubblesController}
+ */
+ show: function (name, text, context, opt) {
+ opt || (opt = {});
+ var container = opt.container || context;
+ var offsetStyle = opt.offsetStyle || {};
+ if (!this.storeBubbles[name]) {
+ this.storeBubbles[name] = {};
+ }
+ if (!this.storeBubbles[name]["top"]) {
+ this.storeBubbles[name]["top"] = this._createBubble("top", text);
+ }
+ BI.createWidget({
+ type: "bi.absolute",
+ element: container,
+ items: [{
+ el: this.storeBubbles[name]["top"]
+ }]
+ });
+ this.set(name, this.storeBubbles[name]["top"]);
+ var position = this._getTopPosition(name, context, offsetStyle);
+ this.get(name).element.css({left: position.left, top: position.top});
+ this.get(name).invisible();
+ if (!$.isTopSpaceEnough(context, this.get(name))) {
+ if (!this.storeBubbles[name]["left"]) {
+ this.storeBubbles[name]["left"] = this._createBubble("left", text, 30);
+ }
+ BI.createWidget({
+ type: "bi.absolute",
+ element: container,
+ items: [{
+ el: this.storeBubbles[name]["left"]
+ }]
+ });
+ this.set(name, this.storeBubbles[name]["left"]);
+ var position = this._getLeftPosition(name, context, offsetStyle);
+ this.get(name).element.css({left: position.left, top: position.top});
+ this.get(name).invisible();
+ if (!$.isLeftSpaceEnough(context, this.get(name))) {
+ if (!this.storeBubbles[name]["right"]) {
+ this.storeBubbles[name]["right"] = this._createBubble("right", text, 30);
+ }
+ BI.createWidget({
+ type: "bi.absolute",
+ element: container,
+ items: [{
+ el: this.storeBubbles[name]["right"]
+ }]
+ });
+ this.set(name, this.storeBubbles[name]["right"]);
+ var position = this._getRightPosition(name, context, offsetStyle);
+ this.get(name).element.css({left: position.left, top: position.top});
+ this.get(name).invisible();
+ if (!$.isRightSpaceEnough(context, this.get(name))) {
+ if (!this.storeBubbles[name]["bottom"]) {
+ this.storeBubbles[name]["bottom"] = this._createBubble("bottom", text);
+ }
+ BI.createWidget({
+ type: "bi.absolute",
+ element: container,
+ items: [{
+ el: this.storeBubbles[name]["bottom"]
+ }]
+ });
+ this.set(name, this.storeBubbles[name]["bottom"]);
+ var position = this._getBottomPosition(name, context, offsetStyle);
+ this.get(name).element.css({left: position.left, top: position.top});
+ this.get(name).invisible();
+ }
+ }
+ }
+ this.get(name).setText(text);
+ this.get(name).visible();
+ return this;
+ },
+
+ hide: function (name) {
+ if (!this.has(name)) {
+ return this;
+ }
+ this.get(name).invisible();
+ return this;
+ },
+
+ add: function (name, bubble) {
+ if (this.has(name)) {
+ return this;
+ }
+ this.set(name, bubble);
+ return this;
+ },
+
+ get: function (name) {
+ return this.bubblesManager[name];
+ },
+
+ set: function (name, bubble) {
+ this.bubblesManager[name] = bubble;
+ },
+
+ has: function (name) {
+ return this.bubblesManager[name] != null;
+ },
+
+ remove: function (name) {
+ if (!this.has(name)) {
+ return this;
+ }
+ BI.each(this.storeBubbles[name], function (dir, bubble) {
+ bubble.destroy();
+ });
+ delete this.storeBubbles[name];
+ delete this.bubblesManager[name];
+ return this;
+ }
+});/**
+ * guy
+ * FloatBox弹出层控制器, z-index在100w层级
+ * @class BI.FloatBoxController
+ * @extends BI.Controller
+ */
+BI.FloatBoxController = BI.inherit(BI.Controller, {
+ _defaultConfig: function () {
+ return BI.extend(BI.FloatBoxController.superclass._defaultConfig.apply(this, arguments), {
+ modal: true, // 模态窗口
+ render: "body"
+ });
+ },
+
+ _init: function () {
+ BI.FloatBoxController.superclass._init.apply(this, arguments);
+ this.modal = this.options.modal;
+ this.floatManager = {};
+ this.floatLayer = {};
+ this.floatContainer = {};
+ this.floatOpened = {};
+ this.zindex = BI.zIndex_floatbox;
+ this.zindexMap = {};
+ },
+
+ _check: function (name) {
+ return BI.isNotNull(this.floatManager[name]);
+ },
+
+ create: function (name, section, options) {
+ if (this._check(name)) {
+ return this;
+ }
+ var floatbox = BI.createWidget({
+ type: "bi.float_box"
+ }, options);
+ floatbox.populate(section);
+ this.add(name, floatbox, options);
+ return this;
+ },
+
+ add: function (name, floatbox, options) {
+ var self = this;
+ options || (options = {});
+ if (this._check(name)) {
+ return this;
+ }
+ this.floatContainer[name] = BI.createWidget({
+ type: "bi.absolute",
+ cls: "bi-popup-view",
+ items: [{
+ el: (this.floatLayer[name] = BI.createWidget({
+ type: 'bi.absolute',
+ items: [floatbox]
+ })),
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ this.floatManager[name] = floatbox;
+ (function (key) {
+ floatbox.on(BI.FloatBox.EVENT_FLOAT_BOX_CLOSED, function () {
+ self.close(key);
+ })
+ })(name);
+ BI.createWidget({
+ type: "bi.absolute",
+ element: options.container || this.options.render,
+ items: [{
+ el: this.floatContainer[name],
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ return this;
+ },
+
+ open: function (name) {
+ if (!this._check(name)) {
+ return this;
+ }
+ if (!this.floatOpened[name]) {
+ this.floatOpened[name] = true;
+ var container = this.floatContainer[name];
+ container.element.css("zIndex", this.zindex++);
+ this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]);
+ this.zindexMap[name] = this.zindex;
+ this.modal && container.element.__buildZIndexMask__(this.zindex++);
+ this.get(name).setZindex(this.zindex++);
+ this.floatContainer[name].visible();
+ var floatbox = this.get(name);
+ floatbox.show();
+ var W = $(this.options.render).width(), H = $(this.options.render).height();
+ var w = floatbox.element.width(), h = floatbox.element.height();
+ var left = (W - w) / 2, top = (H - h) / 2;
+ if (left < 0) {
+ left = 0;
+ }
+ if (top < 0) {
+ top = 0;
+ }
+ floatbox.element.css({
+ left: left + "px",
+ top: top + "px"
+ });
+ }
+ return this;
+ },
+
+ close: function (name) {
+ if (!this._check(name)) {
+ return this;
+ }
+ if (this.floatOpened[name]) {
+ delete this.floatOpened[name];
+ this.floatContainer[name].invisible();
+ this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]);
+ }
+ return this;
+ },
+
+ get: function (name) {
+ return this.floatManager[name];
+ },
+
+ remove: function (name) {
+ if (!this._check(name)) {
+ return this;
+ }
+ this.floatContainer[name].destroy();
+ this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]);
+ delete this.floatManager[name];
+ delete this.floatLayer[name];
+ delete this.zindexMap[name];
+ delete this.floatContainer[name];
+ delete this.floatOpened[name];
+ return this;
+ }
+});/**
+ * 弹出层面板控制器, z-index在10w层级
+ *
+ * Created by GUY on 2015/6/24.
+ * @class
+ */
+BI.LayerController = BI.inherit(BI.Controller, {
+ _defaultConfig: function () {
+ return BI.extend(BI.LayerController.superclass._defaultConfig.apply(this, arguments), {
+ render: "body"
+ });
+ },
+
+ _init: function () {
+ BI.LayerController.superclass._init.apply(this, arguments);
+ this.layerManager = {};
+ this.layouts = {};
+ this.zindex = BI.zIndex_layer;
+ BI.Resizers.add("layerController" + BI.uniqueId(), BI.bind(this._resize, this));
+ },
+
+ _resize: function () {
+ BI.each(this.layouts, function (i, layer) {
+ if (layer.element.is(":visible")) {
+ layer.element.trigger("__resize__");
+ }
+ })
+ },
+
+ make: function (name, container, op) {
+ if (this.has(name)) {
+ return this.get(name);
+ }
+ op || (op = {});
+ var widget = BI.createWidget((op.render || {}), {
+ type: "bi.layout"
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: container || this.options.render,
+ items: [BI.extend({
+ el: widget
+ }, {
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }, op.offset)]
+ });
+ this.add(name, widget, widget);
+ return widget;
+ },
+
+ create: function (name, from, op) {
+ if (this.has(name)) {
+ return this.get(name);
+ }
+ op || (op = {});
+ var offset = op.offset || {};
+ var w = from;
+ if (BI.isWidget(from)) {
+ w = from.element;
+ }
+ if (BI.isNotEmptyString(w)) {
+ w = $(w);
+ }
+ if (this.has(name)) {
+ return this.get(name);
+ }
+ var widget = BI.createWidget((op.render || {}), {
+ type: "bi.layout",
+ cls: op.cls
+ });
+ var layout = BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: widget,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: op.container || this.options.render,
+ items: [{
+ el: layout,
+ left: offset.left || 0,
+ right: offset.right || 0,
+ top: offset.top || 0,
+ bottom: offset.bottom || 0
+ }]
+ });
+ if (w) {
+ layout.element.addClass("bi-popup-view");
+ layout.element.css({
+ left: w.offset().left + (offset.left || 0),
+ top: w.offset().top + (offset.top || 0),
+ width: offset.width || (w.outerWidth() - (offset.right || 0)) || "",
+ height: offset.height || (w.outerHeight() - (offset.bottom || 0)) || ""
+ });
+ layout.element.on("__resize__", function () {
+ w.is(":visible") &&
+ layout.element.css({
+ left: w.offset().left + (offset.left || 0),
+ top: w.offset().top + (offset.top || 0),
+ width: offset.width || (w.outerWidth() - (offset.right || 0)) || "",
+ height: offset.height || (w.outerHeight() - (offset.bottom || 0)) || ""
+ });
+ });
+ }
+ this.add(name, widget, layout);
+ return widget;
+ },
+
+ hide: function (name, callback) {
+ if (!this.has(name)) {
+ return this;
+ }
+ this._getLayout(name).invisible();
+ this._getLayout(name).element.hide(0, callback);
+ return this;
+ },
+
+ show: function (name, callback) {
+ if (!this.has(name)) {
+ return this;
+ }
+ this._getLayout(name).visible();
+ this._getLayout(name).element.css("z-index", this.zindex++).show(0, callback).trigger("__resize__");
+ return this;
+ },
+
+ isVisible: function (name) {
+ return this.has(name) && this._getLayout(name).isVisible();
+ },
+
+ add: function (name, layer, layout) {
+ if (this.has(name)) {
+ throw new Error("name is already exist");
+ }
+ layout.setVisible(false);
+ this.layerManager[name] = layer;
+ this.layouts[name] = layout;
+ layout.element.css("z-index", this.zindex++);
+ return this;
+ },
+
+ _getLayout: function (name) {
+ return this.layouts[name];
+ },
+
+ get: function (name) {
+ return this.layerManager[name];
+ },
+
+ has: function (name) {
+ return this.layerManager[name] != null;
+ },
+
+ remove: function (name) {
+ if (!this.has(name)) {
+ return this;
+ }
+ this.layerManager[name].destroy();
+ this.layouts[name].destroy();
+ delete this.layerManager[name];
+ delete this.layouts[name];
+ return this;
+ }
+});/**
+ * 遮罩面板, z-index在1亿层级
+ *
+ * Created by GUY on 2015/6/24.
+ * @class
+ */
+BI.MaskersController = BI.inherit(BI.LayerController, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MaskersController.superclass._defaultConfig.apply(this, arguments), {});
+ },
+
+ _init: function () {
+ BI.MaskersController.superclass._init.apply(this, arguments);
+ this.zindex = BI.zIndex_masker;
+ }
+});/**
+ * window.resize 控制器
+ *
+ * Created by GUY on 2015/6/24.
+ * @class
+ */
+BI.ResizeController = BI.inherit(BI.Controller, {
+ _defaultConfig: function () {
+ return BI.extend(BI.ResizeController.superclass._defaultConfig.apply(this, arguments), {});
+ },
+
+ _init: function () {
+ BI.ResizeController.superclass._init.apply(this, arguments);
+ var self = this;
+ this.resizerManger = {};
+ var fn = BI.debounce(function (ev) {
+ //if (BI.isWindow(ev.target)) {
+ self._resize(ev);
+ //}
+ }, 30);
+ $(window).resize(fn);
+ },
+
+ _resize: function (ev) {
+ BI.each(this.resizerManger, function (key, resizer) {
+ if (resizer instanceof $) {
+ if (resizer.is(":visible")) {
+ resizer.trigger("__resize__");
+ }
+ return;
+ }
+ if (resizer instanceof BI.Layout) {
+ resizer.resize();
+ return;
+ }
+ if (BI.isFunction(resizer)) {
+ resizer(ev);
+ return;
+ }
+ })
+ },
+
+ add: function (name, resizer) {
+ var self = this;
+ if (this.has(name)) {
+ return this;
+ }
+ this.resizerManger[name] = resizer;
+ return function () {
+ self.remove(name);
+ };
+ },
+
+ get: function (name) {
+ return this.resizerManger[name];
+ },
+
+ has: function (name) {
+ return this.resizerManger[name] != null;
+ },
+
+ remove: function (name) {
+ if (!this.has(name)) {
+ return this;
+ }
+ delete this.resizerManger[name];
+ return this;
+ }
+});/**
+ * tooltip控制器
+ * 控制tooltip的显示, 且页面中只有一个tooltip显示
+ *
+ * Created by GUY on 2015/9/8.
+ * @class BI.TooltipsController
+ * @extends BI.Controller
+ */
+BI.TooltipsController = BI.inherit(BI.Controller, {
+ _defaultConfig: function () {
+ return BI.extend(BI.TooltipsController.superclass._defaultConfig.apply(this, arguments), {});
+ },
+
+ _const: {
+ height: 20
+ },
+
+ _init: function () {
+ BI.TooltipsController.superclass._init.apply(this, arguments);
+ this.tooltipsManager = {};
+ this.showingTips = {};//存储正在显示的tooltip
+ },
+
+ _createTooltip: function (text, level) {
+ return BI.createWidget({
+ type: "bi.tooltip",
+ text: text,
+ level: level,
+ stopEvent: true,
+ height: this._const.height
+ });
+ },
+
+ hide: function (name, callback) {
+ if (!this.has(name)) {
+ return this;
+ }
+ delete this.showingTips[name];
+ this.get(name).element.hide(0, callback);
+ this.get(name).invisible();
+ return this;
+ },
+
+ create: function (name, text, level, context) {
+ if (!this.has(name)) {
+ var tooltip = this._createTooltip(text, level);
+ this.add(name, tooltip);
+ BI.createWidget({
+ type: "bi.absolute",
+ element: context || "body",
+ items: [{
+ el: tooltip
+ }]
+ });
+ tooltip.invisible();
+ }
+ return this.get(name);
+ },
+
+ //opt: {container: '', belowMouse: false}
+ show: function (e, name, text, level, context, opt) {
+ opt || (opt = {});
+ var self = this;
+ BI.each(this.showingTips, function (i, tip) {
+ self.hide(i);
+ });
+ this.showingTips = {};
+ if (!this.has(name)) {
+ this.create(name, text, level, opt.container || context);
+ }
+
+ var offset = context.element.offset();
+ var bounds = context.element.bounds();
+
+ var top = offset.top + bounds.height + 5;
+ var tooltip = this.get(name);
+ tooltip.setText(text);
+ tooltip.element.css({
+ left: "0px",
+ top: "0px"
+ });
+ tooltip.visible();
+ tooltip.element.height(tooltip.element[0].scrollHeight);
+ this.showingTips[name] = true;
+ var x = e.pageX || e.clientX, y = (e.pageY || e.clientY) + 15;
+ if (x + tooltip.element.outerWidth() > $("body").outerWidth()) {
+ x -= tooltip.element.outerWidth();
+ }
+ if (y + tooltip.element.outerHeight() > $("body").outerHeight()) {
+ y -= tooltip.element.outerHeight() + 15;
+ top = offset.top - tooltip.element.outerHeight() - 5;
+ !opt.belowMouse && (y = Math.min(y, top));
+ } else {
+ !opt.belowMouse && (y = Math.max(y, top));
+ }
+ tooltip.element.css({
+ left: x < 0 ? 0 : x + "px",
+ top: y < 0 ? 0 : y + "px"
+ });
+ tooltip.element.hover(function () {
+ self.remove(name);
+ context.element.trigger("mouseleave.title" + context.getName());
+ });
+ return this;
+ },
+
+ add: function (name, bubble) {
+ if (this.has(name)) {
+ return this;
+ }
+ this.set(name, bubble);
+ return this;
+ },
+
+ get: function (name) {
+ return this.tooltipsManager[name];
+ },
+
+ set: function (name, bubble) {
+ this.tooltipsManager[name] = bubble;
+ },
+
+ has: function (name) {
+ return this.tooltipsManager[name] != null;
+ },
+
+ remove: function (name) {
+ if (!this.has(name)) {
+ return this;
+ }
+ this.tooltipsManager[name].destroy();
+ delete this.tooltipsManager[name];
+ return this;
+ }
+});/**
+ *
+ * @class BI.FloatBoxRouter
+ * @extends BI.WRouter
+ */
+BI.FloatBoxRouter = BI.inherit(BI.WRouter, {
+ routes: {},
+
+ _init: function () {
+ this.store = {};
+ this.views = {};
+ },
+
+ createView: function (url, modelData, viewData, context) {
+ return BI.Factory.createView(url, this.get(url), modelData || {}, viewData || {}, context)
+ },
+
+ open: function (url, modelData, viewData, context, options) {
+ var self = this, isValid = BI.isKey(modelData);
+ options || (options = {});
+ url = context.rootURL + "/" + url;
+ var data = void 0;
+ if (isValid) {
+ modelData = modelData + "";//避免modelData是数字
+ var keys = modelData.split('.');
+ BI.each(keys, function (i, k) {
+ if (i === 0) {
+ data = context.model.get(k) || {};
+ } else {
+ data = data[k] || {};
+ }
+ });
+ data.id = options.id || keys[keys.length - 1];
+ } else {
+ data = modelData;
+ }
+ BI.extend(data, options.data);
+ if (!this.controller) {
+ this.controller = new BI.FloatBoxController();
+ }
+ if (!this.store[url]) {
+ this.store[url] = BI.createWidget({
+ type: "bi.float_box"
+ }, options);
+ var view = this.createView(url, data, viewData, context);
+ isValid && context.model.addChild(modelData, view.model);
+ view.listenTo(view.model, "destroy", function () {
+ self.remove(url, context);
+ });
+ context.on(BI.Events.UNMOUNT, function () {
+ self.remove(url, context);
+ });
+ this.store[url].populate(view);
+ this.views[url] = view;
+ this.controller.add(url, this.store[url]);
+ context && context.on("end:" + view.cid, function () {
+ BI.nextTick(function () {
+ self.close(url);
+// view.end();
+ (context.listenEnd.apply(context, isValid ? modelData.split('.') : [modelData]) !== false) && context.populate();
+ }, 30)
+ }).on("change:" + view.cid, _.bind(context.notifyParent, context))
+ }
+ this.controller.open(url);
+ this.views[url].populate(data, options.force || true);
+ return this;
+ },
+
+ close: function (url) {
+ if (this.controller) {
+ this.controller.close(url);
+ }
+ return this;
+ },
+
+ remove: function (url, context) {
+ url = context.rootURL + "/" + url;
+ if (this.controller) {
+ this.controller.remove(url);
+ delete this.store[url];
+ this.views[url] && this.views[url].model.destroy();
+ delete this.views[url];
+ }
+ return this;
+ }
+});/**
+ * 统一绑定事件
+ * @type {*|void|Object}
+ */
+BI.EventList = BI.inherit(BI.OB, {
+ _defaultConfig: function() {
+ return BI.extend(BI.EventList.superclass._defaultConfig.apply(this, arguments), {
+ event: "click",
+ callback: BI.emptyFn,
+ handle: "",
+ items:[]
+ });
+ },
+
+ _init : function() {
+ BI.EventList.superclass._init.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _getHandle: function(item){
+ var handle = this.options.handle ? _.result(item, this.options.handle) : item;
+ return handle.element || handle;
+ },
+
+ populate: function(items){
+ var self = this,
+ event = this.options.event,
+ callback = this.options.callback;
+ BI.nextTick(function(){
+ BI.each(items, function(i, item){
+ var fn = callback(item);
+ BI.isFunction(fn) && (fn = BI.debounce(fn, BI.EVENT_RESPONSE_TIME, true));
+ self._getHandle(item)[event](fn);
+ })
+ })
+
+ }
+});/**
+ * 统一监听jquery事件
+ * @type {*|void|Object}
+ */
+BI.ListenerList = BI.inherit(BI.OB, {
+ _defaultConfig: function() {
+ return BI.extend(BI.ListenerList.superclass._defaultConfig.apply(this, arguments), {
+ event: "click",
+ callback: BI.emptyFn,
+ items:[]
+ });
+ },
+
+ _init : function() {
+ BI.ListenerList.superclass._init.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _getHandle: function(item){
+ var handle = this.options.handle ? _.result(item, this.options.handle) : item;
+ return handle.element || handle;
+ },
+
+ populate: function(items){
+ var self = this,
+ event = this.options.event,
+ callback = this.options.callback;
+ BI.nextTick(function(){
+ BI.each(items, function(i, item){
+ var fn = callback(item);
+ BI.isFunction(fn) && (fn = BI.debounce(fn, BI.EVENT_RESPONSE_TIME, true));
+ self._getHandle(item).on(event, fn);
+ })
+ })
+ }
+});/**
+ * Created by GUY on 2015/6/25.
+ */
+/**
+ * 统一监听jquery事件
+ * @type {*|void|Object}
+ */
+BI.OffList = BI.inherit(BI.OB, {
+ _defaultConfig: function() {
+ return BI.extend(BI.OffList.superclass._defaultConfig.apply(this, arguments), {
+ event: "click",
+ items:[]
+ });
+ },
+
+ _init : function() {
+ BI.OffList.superclass._init.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _getHandle: function(item){
+ var handle = this.options.handle ? _.result(item, this.options.handle) : item;
+ return handle.element || handle;
+ },
+
+ populate: function(items){
+ var self = this,
+ event = this.options.event;
+ BI.each(items, function(i, item){
+ self._getHandle(item).off(event);
+ })
+ }
+});/**
+ * 事件集合
+ * @class BI.Events
+ */
+_.extend(BI, {
+ Events: {
+
+ /**
+ * @static
+ * @property keydown事件
+ */
+ KEYDOWN: "_KEYDOWN",
+
+ /**
+ * @static
+ * @property 回撤事件
+ */
+ BACKSPACE: "_BACKSPACE",
+
+ /**
+ * @static
+ * @property 空格事件
+ */
+ SPACE: "_SPACE",
+
+ /**
+ * @static
+ * @property 回车事件
+ */
+ ENTER: "_ENTER",
+
+ /**
+ * @static
+ * @property 确定事件
+ */
+ CONFIRM: '_CONFIRM',
+
+ /**
+ * @static
+ * @property 错误事件
+ */
+ ERROR: '_ERROR',
+
+ /**
+ * @static
+ * @property 暂停事件
+ */
+ PAUSE: '_PAUSE',
+
+ /**
+ * @static
+ * @property destroy事件
+ */
+ DESTROY: '_DESTROY',
+
+ /**
+ * @static
+ * @property 取消挂载事件
+ */
+ UNMOUNT: '_UNMOUNT',
+
+ /**
+ * @static
+ * @property 清除选择
+ */
+ CLEAR: '_CLEAR',
+
+ /**
+ * @static
+ * @property 添加数据
+ */
+ ADD: '_ADD',
+
+ /**
+ * @static
+ * @property 正在编辑状态事件
+ */
+ EDITING: '_EDITING',
+
+ /**
+ * @static
+ * @property 空状态事件
+ */
+ EMPTY: '_EMPTY',
+
+ /**
+ * @static
+ * @property 显示隐藏事件
+ */
+ VIEW: '_VIEW',
+
+ /**
+ * @static
+ * @property 窗体改变大小
+ */
+ RESIZE: "_RESIZE",
+
+ /**
+ * @static
+ * @property 编辑前事件
+ */
+ BEFOREEDIT: '_BEFOREEDIT',
+
+ /**
+ * @static
+ * @property 编辑后事件
+ */
+ AFTEREDIT: '_AFTEREDIT',
+
+ /**
+ * @static
+ * @property 开始编辑事件
+ */
+ STARTEDIT: '_STARTEDIT',
+
+ /**
+ * @static
+ * @property 停止编辑事件
+ */
+ STOPEDIT: '_STOPEDIT',
+
+ /**
+ * @static
+ * @property 值改变事件
+ */
+ CHANGE: '_CHANGE',
+
+ /**
+ * @static
+ * @property 下拉弹出菜单事件
+ */
+ EXPAND: '_EXPAND',
+
+ /**
+ * @static
+ * @property 关闭下拉菜单事件
+ */
+ COLLAPSE: '_COLLAPSE',
+
+ /**
+ * @static
+ * @property 回调事件
+ */
+ CALLBACK: '_CALLBACK',
+
+ /**
+ * @static
+ * @property 点击事件
+ */
+ CLICK: '_CLICK',
+
+ /**
+ * @static
+ * @property 状态改变事件,一般是用在复选按钮和单选按钮
+ */
+ STATECHANGE: '_STATECHANGE',
+
+ /**
+ * @static
+ * @property 状态改变前事件
+ */
+ BEFORESTATECHANGE: '_BEFORESTATECHANGE',
+
+
+ /**
+ * @static
+ * @property 初始化事件
+ */
+ INIT: '_INIT',
+
+ /**
+ * @static
+ * @property 初始化后事件
+ */
+ AFTERINIT: '_AFTERINIT',
+
+ /**
+ * @static
+ * @property 滚动条滚动事件
+ */
+ SCROLL: '_SCROLL',
+
+
+ /**
+ * @static
+ * @property 开始加载事件
+ */
+ STARTLOAD: '_STARTLOAD',
+
+ /**
+ * @static
+ * @property 加载后事件
+ */
+ AFTERLOAD: '_AFTERLOAD',
+
+
+ /**
+ * @static
+ * @property 提交前事件
+ */
+ BS: 'beforesubmit',
+
+ /**
+ * @static
+ * @property 提交后事件
+ */
+ AS: 'aftersubmit',
+
+ /**
+ * @static
+ * @property 提交完成事件
+ */
+ SC: 'submitcomplete',
+
+ /**
+ * @static
+ * @property 提交失败事件
+ */
+ SF: 'submitfailure',
+
+ /**
+ * @static
+ * @property 提交成功事件
+ */
+ SS: 'submitsuccess',
+
+ /**
+ * @static
+ * @property 校验提交前事件
+ */
+ BVW: 'beforeverifywrite',
+
+ /**
+ * @static
+ * @property 校验提交后事件
+ */
+ AVW: 'afterverifywrite',
+
+ /**
+ * @static
+ * @property 校验后事件
+ */
+ AV: 'afterverify',
+
+ /**
+ * @static
+ * @property 填报前事件
+ */
+ BW: 'beforewrite',
+
+ /**
+ * @static
+ * @property 填报后事件
+ */
+ AW: 'afterwrite',
+
+ /**
+ * @static
+ * @property 填报成功事件
+ */
+ WS: 'writesuccess',
+
+ /**
+ * @static
+ * @property 填报失败事件
+ */
+ WF: 'writefailure',
+
+ /**
+ * @static
+ * @property 添加行前事件
+ */
+ BA: 'beforeappend',
+
+ /**
+ * @static
+ * @property 添加行后事件
+ */
+ AA: 'afterappend',
+
+ /**
+ * @static
+ * @property 删除行前事件
+ */
+ BD: 'beforedelete',
+
+ /**
+ * @static
+ * @property 删除行后事件
+ */
+ AD: 'beforedelete',
+
+ /**
+ * @static
+ * @property 未提交离开事件
+ */
+ UC: 'unloadcheck',
+
+
+ /**
+ * @static
+ * @property PDF导出前事件
+ */
+ BTOPDF: 'beforetopdf',
+
+ /**
+ * @static
+ * @property PDF导出后事件
+ */
+ ATOPDF: 'aftertopdf',
+
+ /**
+ * @static
+ * @property Excel导出前事件
+ */
+ BTOEXCEL: 'beforetoexcel',
+
+ /**
+ * @static
+ * @property Excel导出后事件
+ */
+ ATOEXCEL: 'aftertoexcel',
+
+ /**
+ * @static
+ * @property Word导出前事件
+ */
+ BTOWORD: 'beforetoword',
+
+ /**
+ * @static
+ * @property Word导出后事件
+ */
+ ATOWORD: 'aftertoword',
+
+ /**
+ * @static
+ * @property 图片导出前事件
+ */
+ BTOIMAGE: 'beforetoimage',
+
+ /**
+ * @static
+ * @property 图片导出后事件
+ */
+ ATOIMAGE: 'aftertoimage',
+
+ /**
+ * @static
+ * @property HTML导出前事件
+ */
+ BTOHTML: 'beforetohtml',
+
+ /**
+ * @static
+ * @property HTML导出后事件
+ */
+ ATOHTML: 'aftertohtml',
+
+ /**
+ * @static
+ * @property Excel导入前事件
+ */
+ BIMEXCEL: 'beforeimportexcel',
+
+ /**
+ * @static
+ * @property Excel导出后事件
+ */
+ AIMEXCEL: 'afterimportexcel',
+
+ /**
+ * @static
+ * @property PDF打印前事件
+ */
+ BPDFPRINT: 'beforepdfprint',
+
+ /**
+ * @static
+ * @property PDF打印后事件
+ */
+ APDFPRINT: 'afterpdfprint',
+
+ /**
+ * @static
+ * @property Flash打印前事件
+ */
+ BFLASHPRINT: 'beforeflashprint',
+
+ /**
+ * @static
+ * @property Flash打印后事件
+ */
+ AFLASHPRINT: 'afterflashprint',
+
+ /**
+ * @static
+ * @property Applet打印前事件
+ */
+ BAPPLETPRINT: 'beforeappletprint',
+
+ /**
+ * @static
+ * @property Applet打印后事件
+ */
+ AAPPLETPRINT: 'afterappletprint',
+
+ /**
+ * @static
+ * @property 服务器打印前事件
+ */
+ BSEVERPRINT: 'beforeserverprint',
+
+ /**
+ * @static
+ * @property 服务器打印后事件
+ */
+ ASERVERPRINT: 'afterserverprint',
+
+ /**
+ * @static
+ * @property 邮件发送前事件
+ */
+ BEMAIL: 'beforeemail',
+
+ /**
+ * @static
+ * @property 邮件发送后事件
+ */
+ AEMAIL: 'afteremail'
+ }
+});/**
+ * guy
+ * 最基础的dom操作
+ */
+BI.extend(jQuery.fn, {
+
+ destroy: function () {
+ this.remove();
+ if (BI.isIE() === true) {
+ this[0].outerHTML = '';
+ }
+ },
+ /**
+ * 高亮显示
+ * @param text 必需
+ * @param keyword
+ * @param py 必需
+ * @returns {*}
+ * @private
+ */
+ __textKeywordMarked__: function (text, keyword, py) {
+ if (!BI.isKey(keyword)) {
+ return this.text((text + "").replaceAll(" ", " "));
+ }
+ keyword = keyword + "";
+ keyword = BI.toUpperCase(keyword);
+ var textLeft = (text || "") + "";
+ py = (py || BI.makeFirstPY(text)) + "";
+ if (py != null) {
+ py = BI.toUpperCase(py);
+ }
+ this.empty();
+ while (true) {
+ var tidx = BI.toUpperCase(textLeft).indexOf(keyword);
+ var pidx = null;
+ if (py != null) {
+ pidx = py.indexOf(keyword);
+ if (pidx >= 0) {
+ pidx = pidx % text.length;
+ }
+ }
+
+ if (tidx >= 0) {
+ this.append(textLeft.substr(0, tidx));
+ this.append($("").addClass("bi-keyword-red-mark")
+ .text(textLeft.substr(tidx, keyword.length).replaceAll(" ", " ")));
+
+ textLeft = textLeft.substr(tidx + keyword.length);
+ if (py != null) {
+ py = py.substr(tidx + keyword.length);
+ }
+ } else if (pidx != null && pidx >= 0 && Math.floor(pidx / text.length) === Math.floor((pidx + keyword.length - 1) / text.length)) {
+ this.append(textLeft.substr(0, pidx));
+ this.append($("").addClass("bi-keyword-red-mark")
+ .text(textLeft.substr(pidx, keyword.length).replaceAll(" ", " ")));
+ if (py != null) {
+ py = py.substr(pidx + keyword.length);
+ }
+ textLeft = textLeft.substr(pidx + keyword.length);
+ } else {
+ this.append(textLeft);
+ break;
+ }
+ }
+
+ return this;
+ },
+
+ getDomHeight: function (parent) {
+ var clone = $(this).clone();
+ clone.appendTo($(parent || "body"));
+ var height = clone.height();
+ clone.remove();
+ return height;
+ },
+
+ //是否有竖直滚动条
+ hasVerticalScroll: function () {
+ return this.height() > 0 && this[0].clientWidth < this[0].offsetWidth;
+ },
+
+ //是否有水平滚动条
+ hasHorizonScroll: function () {
+ return this.width() > 0 && this[0].clientHeight < this[0].offsetHeight;
+ },
+
+ //获取计算后的样式
+ getStyle: function (name) {
+ var node = this[0];
+ var computedStyle = void 0;
+
+ // W3C Standard
+ if (window.getComputedStyle) {
+ // In certain cases such as within an iframe in FF3, this returns null.
+ computedStyle = window.getComputedStyle(node, null);
+ if (computedStyle) {
+ return computedStyle.getPropertyValue(BI.hyphenate(name));
+ }
+ }
+ // Safari
+ if (document.defaultView && document.defaultView.getComputedStyle) {
+ computedStyle = document.defaultView.getComputedStyle(node, null);
+ // A Safari bug causes this to return null for `display: none` elements.
+ if (computedStyle) {
+ return computedStyle.getPropertyValue(BI.hyphenate(name));
+ }
+ if (name === 'display') {
+ return 'none';
+ }
+ }
+ // Internet Explorer
+ if (node.currentStyle) {
+ if (name === 'float') {
+ return node.currentStyle.cssFloat || node.currentStyle.styleFloat;
+ }
+ return node.currentStyle[BI.camelize(name)];
+ }
+ return node.style && node.style[BI.camelize(name)];
+ },
+
+ __isMouseInBounds__: function (e) {
+ var offset2Body = this.offset();
+ return !(e.pageX < offset2Body.left || e.pageX > offset2Body.left + this.outerWidth()
+ || e.pageY < offset2Body.top || e.pageY > offset2Body.top + this.outerHeight())
+ },
+
+ __hasZIndexMask__: function (zindex) {
+ return zindex && this.zIndexMask[zindex] != null;
+ },
+
+ __buildZIndexMask__: function (zindex, domArray) {
+ this.zIndexMask = this.zIndexMask || {};//存储z-index的mask
+ this.indexMask = this.indexMask || [];//存储mask
+ var mask = BI.createWidget({
+ type: "bi.center_adapt",
+ cls: "bi-z-index-mask",
+ items: domArray
+ });
+
+ mask.element.css({"z-index": zindex});
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: mask,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ this.indexMask.push(mask);
+ zindex && (this.zIndexMask[zindex] = mask);
+ return mask.element;
+ },
+
+ __releaseZIndexMask__: function (zindex) {
+ if (zindex && this.zIndexMask[zindex]) {
+ this.indexMask.remove(this.zIndexMask[zindex]);
+ this.zIndexMask[zindex].destroy();
+ return;
+ }
+ this.indexMask = this.indexMask || [];
+ var indexMask = this.indexMask.pop();
+ indexMask && indexMask.destroy();
+ }
+});
+
+BI.extend(jQuery, {
+
+ getLeftPosition: function (combo, popup, extraWidth) {
+ return {
+ left: combo.element.offset().left - popup.element.outerWidth() - (extraWidth || 0)
+ };
+ },
+
+ getRightPosition: function (combo, popup, extraWidth) {
+ var el = combo.element;
+ return {
+ left: el.offset().left + el.outerWidth() + (extraWidth || 0)
+ }
+ },
+
+ getTopPosition: function (combo, popup, extraHeight) {
+ return {
+ top: combo.element.offset().top - popup.element.outerHeight() - (extraHeight || 0)
+ };
+ },
+
+ getBottomPosition: function (combo, popup, extraHeight) {
+ var el = combo.element;
+ return {
+ top: el.offset().top + el.outerHeight() + (extraHeight || 0)
+ };
+ },
+
+ isLeftSpaceEnough: function (combo, popup, extraWidth) {
+ return $.getLeftPosition(combo, popup, extraWidth).left >= 0;
+ },
+
+ isRightSpaceEnough: function (combo, popup, extraWidth) {
+ var viewBounds = popup.element.bounds(), windowBounds = $("body").bounds();
+ return $.getRightPosition(combo, popup, extraWidth).left + viewBounds.width <= windowBounds.width;
+ },
+
+ isTopSpaceEnough: function (combo, popup, extraHeight) {
+ return $.getTopPosition(combo, popup, extraHeight).top >= 0;
+ },
+
+ isBottomSpaceEnough: function (combo, popup, extraHeight) {
+ var viewBounds = popup.element.bounds(), windowBounds = $("body").bounds();
+ return $.getBottomPosition(combo, popup, extraHeight).top + viewBounds.height <= windowBounds.height;
+ },
+
+ isRightSpaceLarger: function (combo) {
+ var windowBounds = $("body").bounds();
+ return windowBounds.width - combo.element.offset().left - combo.element.bounds().width >= combo.element.offset().left;
+ },
+
+ isBottomSpaceLarger: function (combo) {
+ var windowBounds = $("body").bounds();
+ return windowBounds.height - combo.element.offset().top - combo.element.bounds().height >= combo.element.offset().top;
+ },
+
+ getLeftAlignPosition: function (combo, popup, extraWidth) {
+ var viewBounds = popup.element.bounds(), windowBounds = $("body").bounds();
+ var left = combo.element.offset().left + extraWidth;
+ if (left + viewBounds.width > windowBounds.width) {
+ left = windowBounds.width - viewBounds.width;
+ }
+ if (left < 0) {
+ left = 0;
+ }
+ return {
+ left: left
+ }
+ },
+
+ getLeftAdaptPosition: function (combo, popup, extraWidth) {
+ if ($.isLeftSpaceEnough(combo, popup, extraWidth)) {
+ return $.getLeftPosition(combo, popup, extraWidth);
+ }
+ return {
+ left: 0
+ }
+ },
+
+ getRightAlignPosition: function (combo, popup, extraWidth) {
+ var comboBounds = combo.element.bounds(), viewBounds = popup.element.bounds();
+ var left = combo.element.offset().left + comboBounds.width - viewBounds.width - extraWidth;
+ if (left < 0) {
+ left = 0;
+ }
+ return {
+ left: left
+ }
+ },
+
+ getRightAdaptPosition: function (combo, popup, extraWidth) {
+ if ($.isRightSpaceEnough(combo, popup, extraWidth)) {
+ return $.getRightPosition(combo, popup, extraWidth);
+ }
+ return {
+ left: $("body").bounds().width - popup.element.bounds().width
+ }
+ },
+
+ getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
+ var comboOffset = combo.element.offset();
+ var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
+ windowBounds = $("body").bounds();
+ var top, adaptHeight;
+ if ($.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
+ top = comboOffset.top + extraHeight;
+ } else if (needAdaptHeight) {
+ top = comboOffset.top + extraHeight;
+ adaptHeight = windowBounds.height - top;
+ } else {
+ top = windowBounds.height - popupBounds.height;
+ if (top < extraHeight) {
+ adaptHeight = windowBounds.height - extraHeight;
+ }
+ }
+ if (top < extraHeight) {
+ top = extraHeight;
+ }
+ return adaptHeight ? {
+ top: top,
+ adaptHeight: adaptHeight
+ } : {
+ top: top
+ }
+ },
+
+ getTopAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
+ var popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
+ if ($.isTopSpaceEnough(combo, popup, extraHeight)) {
+ return $.getTopPosition(combo, popup, extraHeight);
+ }
+ if (needAdaptHeight) {
+ return {
+ top: 0,
+ adaptHeight: combo.element.offset().top - extraHeight
+ }
+ }
+ if (popupBounds.height + extraHeight > windowBounds.height) {
+ return {
+ top: 0,
+ adaptHeight: windowBounds.height - extraHeight
+ }
+ }
+ return {
+ top: 0
+ }
+ },
+
+ getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
+ var comboOffset = combo.element.offset();
+ var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
+ windowBounds = $("body").bounds();
+ var top, adaptHeight;
+ if ($.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
+ top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight;
+ } else if (needAdaptHeight) {
+ top = 0;
+ adaptHeight = comboOffset.top + comboBounds.height - extraHeight;
+ } else {
+ top = 0;
+ if (popupBounds.height + extraHeight > windowBounds.height) {
+ adaptHeight = windowBounds.height - extraHeight;
+ }
+ }
+ if (top < 0) {
+ top = 0;
+ }
+ return adaptHeight ? {
+ top: top,
+ adaptHeight: adaptHeight
+ } : {
+ top: top
+ }
+ },
+
+ getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
+ var comboOffset = combo.element.offset();
+ var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
+ windowBounds = $("body").bounds();
+ if ($.isBottomSpaceEnough(combo, popup, extraHeight)) {
+ return $.getBottomPosition(combo, popup, extraHeight);
+ }
+ if (needAdaptHeight) {
+ return {
+ top: comboOffset.top + comboBounds.height + extraHeight,
+ adaptHeight: windowBounds.height - comboOffset.top - comboBounds.height - extraHeight
+ }
+ }
+ if (popupBounds.height + extraHeight > windowBounds.height) {
+ return {
+ top: extraHeight,
+ adaptHeight: windowBounds.height - extraHeight
+ }
+ }
+ return {
+ top: windowBounds.height - popupBounds.height - extraHeight
+ }
+ },
+
+ getCenterAdaptPosition: function (combo, popup) {
+ var comboOffset = combo.element.offset();
+ var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
+ windowBounds = $("body").bounds();
+ var left;
+ if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) {
+ left = windowBounds.width - popupBounds.width;
+ } else {
+ left = comboOffset.left + comboBounds.width / 2 - popupBounds.width / 2;
+ }
+ if (left < 0) {
+ left = 0;
+ }
+ return {
+ left: left
+ }
+ },
+
+ getMiddleAdaptPosition: function (combo, popup) {
+ var comboOffset = combo.element.offset();
+ var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
+ windowBounds = $("body").bounds();
+ var top;
+ if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) {
+ top = windowBounds.height - popupBounds.height;
+ } else {
+ top = comboOffset.top + comboBounds.height / 2 - popupBounds.height / 2;
+ }
+ if (top < 0) {
+ top = 0;
+ }
+ return {
+ top: top
+ }
+ },
+
+ getComboPositionByDirections: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions) {
+ extraWidth || (extraWidth = 0);
+ extraHeight || (extraHeight = 0);
+ var i, direct;
+ var leftRight = [], topBottom = [];
+ var isNeedAdaptHeight = false, tbFirst = false, lrFirst = false;
+ var left, top, pos;
+ for (i = 0; i < directions.length; i++) {
+ direct = directions[i];
+ switch (direct) {
+ case "left":
+ leftRight.push(direct);
+ break;
+ case "right":
+ leftRight.push(direct);
+ break;
+ case "top":
+ topBottom.push(direct);
+ break;
+ case "bottom":
+ topBottom.push(direct);
+ break;
+ }
+ }
+ for (i = 0; i < directions.length; i++) {
+ direct = directions[i];
+ switch (direct) {
+ case "left":
+ if (!isNeedAdaptHeight) {
+ var tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight;
+ if ($.isLeftSpaceEnough(combo, popup, tW)) {
+ left = $.getLeftPosition(combo, popup, tW).left;
+ if (topBottom[0] === "bottom") {
+ pos = $.getTopAlignPosition(combo, popup, tH, needAdaptHeight);
+ pos.dir = "left,bottom";
+ } else {
+ pos = $.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
+ pos.dir = "left,top";
+ }
+ if (tbFirst) {
+ pos.change = "left";
+ }
+ pos.left = left;
+ return pos;
+ }
+ }
+ lrFirst = true;
+ break;
+ case "right":
+ if (!isNeedAdaptHeight) {
+ var tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? extraWidth : extraHeight;
+ if ($.isRightSpaceEnough(combo, popup, tW)) {
+ left = $.getRightPosition(combo, popup, tW).left;
+ if (topBottom[0] === "bottom") {
+ pos = $.getTopAlignPosition(combo, popup, tH, needAdaptHeight);
+ pos.dir = "right,bottom";
+ } else {
+ pos = $.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
+ pos.dir = "right,top";
+ }
+ if (tbFirst) {
+ pos.change = "right";
+ }
+ pos.left = left;
+ return pos;
+ }
+ }
+ lrFirst = true;
+ break;
+ case "top":
+ var tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
+ if ($.isTopSpaceEnough(combo, popup, tH)) {
+ top = $.getTopPosition(combo, popup, tH).top;
+ if (leftRight[0] === "right") {
+ pos = $.getLeftAlignPosition(combo, popup, tW, needAdaptHeight);
+ pos.dir = "top,right";
+ } else {
+ pos = $.getRightAlignPosition(combo, popup, tW);
+ pos.dir = "top,left";
+ }
+ if (lrFirst) {
+ pos.change = "top";
+ }
+ pos.top = top;
+ return pos;
+ }
+ if (needAdaptHeight) {
+ isNeedAdaptHeight = true;
+ }
+ tbFirst = true;
+ break;
+ case "bottom":
+ var tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
+ if ($.isBottomSpaceEnough(combo, popup, tH)) {
+ top = $.getBottomPosition(combo, popup, tH).top;
+ if (leftRight[0] === "right") {
+ pos = $.getLeftAlignPosition(combo, popup, tW, needAdaptHeight);
+ pos.dir = "bottom,right";
+ } else {
+ pos = $.getRightAlignPosition(combo, popup, tW);
+ pos.dir = "bottom,left";
+ }
+ if (lrFirst) {
+ pos.change = "bottom";
+ }
+ pos.top = top;
+ return pos;
+ }
+ if (needAdaptHeight) {
+ isNeedAdaptHeight = true;
+ }
+ tbFirst = true;
+ break;
+ }
+ }
+
+ switch (directions[0]) {
+ case "left":
+ case "right":
+ if ($.isRightSpaceLarger(combo)) {
+ left = $.getRightAdaptPosition(combo, popup, extraWidth).left;
+ } else {
+ left = $.getLeftAdaptPosition(combo, popup, extraWidth).left;
+ }
+ if (topBottom[0] === "bottom") {
+ pos = $.getTopAlignPosition(combo, popup, extraHeight, needAdaptHeight);
+ pos.left = left;
+ pos.dir = directions[0] + ",bottom";
+ return pos;
+ }
+ pos = $.getBottomAlignPosition(combo, popup, extraHeight, needAdaptHeight);
+ pos.left = left;
+ pos.dir = directions[0] + ",top";
+ return pos;
+ default :
+ if ($.isBottomSpaceLarger(combo)) {
+ pos = $.getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight);
+ } else {
+ pos = $.getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight);
+ }
+ if (leftRight[0] === "right") {
+ left = $.getLeftAlignPosition(combo, popup, extraWidth, needAdaptHeight).left;
+ pos.left = left;
+ pos.dir = directions[0] + ",right";
+ return pos;
+ }
+ left = $.getRightAlignPosition(combo, popup, extraWidth).left;
+ pos.left = left;
+ pos.dir = directions[0] + ",left";
+ return pos;
+ }
+ },
+
+
+ getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle) {
+ extraWidth || (extraWidth = 0);
+ extraHeight || (extraHeight = 0);
+ var bodyHeight = $("body").bounds().height - extraHeight;
+ var maxHeight = Math.min(popup.attr("maxHeight") || bodyHeight, bodyHeight);
+ popup.resetHeight && popup.resetHeight(maxHeight);
+ var position = $.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ['bottom', 'top', 'right', 'left']);
+ switch (offsetStyle) {
+ case "center":
+ if (position.change) {
+ var p = $.getMiddleAdaptPosition(combo, popup);
+ position.top = p.top;
+ } else {
+ var p = $.getCenterAdaptPosition(combo, popup);
+ position.left = p.left;
+ }
+ break;
+ case "middle":
+ if (position.change) {
+ var p = $.getCenterAdaptPosition(combo, popup);
+ position.left = p.left;
+ } else {
+ var p = $.getMiddleAdaptPosition(combo, popup);
+ position.top = p.top;
+ }
+ break;
+ }
+ if (needAdaptHeight === true) {
+ popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight));
+ }
+ return position;
+ }
+});/**
+ * 基本的函数
+ * Created by GUY on 2015/6/24.
+ */
+BI.Func = {};
+BI.extend(BI.Func, {
+
+ /**
+ * 获取搜索结果
+ * @param items
+ * @param keyword
+ * @param param 搜索哪个属性
+ */
+ getSearchResult: function (items, keyword, param) {
+ var isArray = BI.isArray(items);
+ items = isArray ? BI.flatten(items) : items;
+ param || (param = "text");
+ if (!BI.isKey(keyword)) {
+ return {
+ finded: BI.deepClone(items),
+ matched: isArray ? [] : {}
+ };
+ }
+ var t, text, py;
+ keyword = BI.toUpperCase(keyword);
+ var matched = isArray ? [] : {}, finded = isArray ? [] : {};
+ BI.each(items, function (i, item) {
+ item = BI.deepClone(item);
+ t = BI.stripEL(item);
+ text = t[param] || t.text || t.value || t.name || t;
+ py = BI.makeFirstPY(text);
+ text = BI.toUpperCase(text);
+ py = BI.toUpperCase(py);
+ var pidx;
+ if (text.indexOf(keyword) > -1) {
+ if (text === keyword) {
+ isArray ? matched.push(item) : (matched[i] = item);
+ } else {
+ isArray ? finded.push(item) : (finded[i] = item);
+ }
+ } else if (pidx = py.indexOf(keyword), (pidx > -1 && Math.floor(pidx / text.length) === Math.floor((pidx + keyword.length - 1) / text.length))) {
+ if (text === keyword || keyword.length === text.length) {
+ isArray ? matched.push(item) : (matched[i] = item);
+ } else {
+ isArray ? finded.push(item) : (finded[i] = item);
+ }
+ }
+ });
+ return {
+ matched: matched,
+ finded: finded
+ }
+ },
+});
+
+/**
+ * 对DOM操作的通用函数
+ * @type {{}}
+ */
+BI.DOM = {};
+BI.extend(BI.DOM, {
+
+ /**
+ * 把dom数组或元素悬挂起来,使其不对html产生影响
+ * @param dom
+ */
+ hang: function (doms) {
+ if (BI.isEmpty(doms)) {
+ return;
+ }
+ var frag = document.createDocumentFragment();
+ BI.each(doms, function (i, dom) {
+ dom instanceof BI.Widget && (dom = dom.element);
+ dom instanceof $ && dom[0] && frag.appendChild(dom[0]);
+ });
+ return frag;
+ },
+
+ isExist: function (obj) {
+ return $("body").find(obj.element).length > 0;
+ },
+
+ //预加载图片
+ preloadImages: function (srcArray, onload) {
+ var count = 0, images = [];
+
+ function complete() {
+ count++;
+ if (count >= srcArray.length) {
+ onload();
+ }
+ }
+
+ BI.each(srcArray, function (i, src) {
+ images[i] = new Image();
+ images[i].src = src;
+ images[i].onload = function () {
+ complete()
+ };
+ images[i].onerror = function () {
+ complete()
+ };
+ });
+ },
+
+ isColor: function (color) {
+ return color && (this.isRGBColor(color) || this.isHexColor(color));
+ },
+
+ isRGBColor: function (color) {
+ if (!color) {
+ return false;
+ }
+ return color.substr(0, 3) === "rgb";
+ },
+
+ isHexColor: function (color) {
+ if (!color) {
+ return false;
+ }
+ return color[0] === "#" && color.length === 7;
+ },
+
+ isDarkColor: function (hex) {
+ if (!hex || !this.isHexColor(hex)) {
+ return false;
+ }
+ var rgb = this.rgb2json(this.hex2rgb(hex));
+ var grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114);
+ if (grayLevel < 192/**网上给的是140**/) {
+ return true;
+ }
+ return false;
+ },
+
+ //获取对比颜色
+ getContrastColor: function (color) {
+ if (!color || !this.isColor(color)) {
+ return "";
+ }
+ if (this.isDarkColor(color)) {
+ return "#ffffff";
+ }
+ return "#1a1a1a";
+ },
+
+ rgb2hex: function (rgbColour) {
+ if (!rgbColour || rgbColour.substr(0, 3) != "rgb") {
+ return "";
+ }
+ var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
+ var red = BI.parseInt(rgbValues[0]);
+ var green = BI.parseInt(rgbValues[1]);
+ var blue = BI.parseInt(rgbValues[2]);
+
+ var hexColour = "#" + this.int2hex(red) + this.int2hex(green) + this.int2hex(blue);
+
+ return hexColour;
+ },
+
+ rgb2json: function (rgbColour) {
+ if (!rgbColour) {
+ return {};
+ }
+ if (!this.isRGBColor(rgbColour)) {
+ return {};
+ }
+ var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
+ return {
+ r: BI.parseInt(rgbValues[0]),
+ g: BI.parseInt(rgbValues[1]),
+ b: BI.parseInt(rgbValues[2])
+ };
+ },
+
+ rgba2json: function (rgbColour) {
+ if (!rgbColour) {
+ return {};
+ }
+ var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
+ return {
+ r: BI.parseInt(rgbValues[0]),
+ g: BI.parseInt(rgbValues[1]),
+ b: BI.parseInt(rgbValues[2]),
+ a: BI.parseFloat(rgbValues[3])
+ };
+ },
+
+ json2rgb: function (rgb) {
+ if (!BI.isKey(rgb.r) || !BI.isKey(rgb.g) || !BI.isKey(rgb.b)) {
+ return "";
+ }
+ return "rgb(" + rgb.r + "," + rgb.g + "," + rgb.b + ")";
+ },
+
+ json2rgba: function (rgba) {
+ if (!BI.isKey(rgba.r) || !BI.isKey(rgba.g) || !BI.isKey(rgba.b)) {
+ return "";
+ }
+ return "rgba(" + rgba.r + "," + rgba.g + "," + rgba.b + "," + rgba.a + ")";
+ },
+
+ int2hex: function (strNum) {
+ var hexdig = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
+
+ return hexdig[strNum >>> 4] + '' + hexdig[strNum & 15];
+ },
+
+ hex2rgb: function (color) {
+ if (!color) {
+ return "";
+ }
+ if (!this.isHexColor(color)) {
+ return color;
+ }
+ var tempValue = "rgb(", colorArray;
+
+ if (color.length === 7) {
+ colorArray = [BI.parseInt('0x' + color.substring(1, 3)),
+ BI.parseInt('0x' + color.substring(3, 5)),
+ BI.parseInt('0x' + color.substring(5, 7))];
+ }
+ else if (color.length === 4) {
+ colorArray = [BI.parseInt('0x' + color.substring(1, 2)),
+ BI.parseInt('0x' + color.substring(2, 3)),
+ BI.parseInt('0x' + color.substring(3, 4))];
+ }
+ tempValue += colorArray[0] + ",";
+ tempValue += colorArray[1] + ",";
+ tempValue += colorArray[2] + ")";
+
+ return tempValue;
+ },
+
+ rgba2rgb: function (rgbColour, BGcolor) {
+ if (BI.isNull(BGcolor)) {
+ BGcolor = 1;
+ }
+ if (rgbColour.substr(0, 4) != "rgba") {
+ return "";
+ }
+ var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
+ if (rgbValues.length < 4) {
+ return "";
+ }
+ var R = BI.parseFloat(rgbValues[0]);
+ var G = BI.parseFloat(rgbValues[1]);
+ var B = BI.parseFloat(rgbValues[2]);
+ var A = BI.parseFloat(rgbValues[3]);
+
+ return "rgb(" + Math.floor(255 * (BGcolor * (1 - A )) + R * A) + "," +
+ Math.floor(255 * (BGcolor * (1 - A )) + G * A) + "," +
+ Math.floor(255 * (BGcolor * (1 - A )) + B * A) + ")";
+ },
+
+ getTextSizeWidth: function (text, fontSize) {
+ var span = $(" ").addClass("text-width-span").appendTo($("body"));
+
+ if (fontSize == null) {
+ fontSize = 12;
+ }
+ fontSize = fontSize + "px";
+
+ span.css("font-size", fontSize).text(text);
+
+ var width = span.width();
+ span.remove();
+
+ return width;
+ },
+
+ //获取滚动条的宽度
+ getScrollWidth: function () {
+ if (this._scrollWidth == null) {
+ var ul = $("").width(50).height(50).css({
+ position: "absolute",
+ top: "-9999px",
+ overflow: "scroll"
+ }).appendTo($("body"));
+ this._scrollWidth = ul[0].offsetWidth - ul[0].clientWidth;
+ ul.destroy();
+ }
+ return this._scrollWidth;
+ }
+});/**
+ * guy
+ * 检测某个Widget的EventChange事件然后去show某个card
+ * @type {*|void|Object}
+ * @class BI.ShowListener
+ * @extends BI.OB
+ */
+BI.ShowListener = BI.inherit(BI.OB, {
+ _defaultConfig: function () {
+ return BI.extend(BI.ShowListener.superclass._defaultConfig.apply(this, arguments), {
+ eventObj: BI.createWidget(),
+ cardLayout: null,
+ cardNameCreator: function (v) {
+ return v;
+ },
+ cardCreator: BI.emptyFn,
+ afterCardCreated: BI.emptyFn,
+ afterCardShow: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.ShowListener.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ o.eventObj.on(BI.Controller.EVENT_CHANGE, function (type, v, ob) {
+ if (type === BI.Events.CLICK) {
+ v = v || o.eventObj.getValue();
+ v = BI.isArray(v) ? (v.length > 1 ? v.toString() : v[0]) : v;
+ if (BI.isNull(v)) {
+ throw new Error("value cannot be null");
+ }
+ var cardName = o.cardNameCreator(v);
+ if (!o.cardLayout.isCardExisted(cardName)) {
+ var card = o.cardCreator(cardName);
+ o.cardLayout.addCardByName(cardName, card);
+ o.afterCardCreated(cardName);
+ }
+ o.cardLayout.showCardByName(cardName);
+ BI.nextTick(function () {
+ o.afterCardShow(cardName);
+ self.fireEvent(BI.ShowListener.EVENT_CHANGE, cardName);
+ });
+ }
+ })
+ }
+});
+BI.ShowListener.EVENT_CHANGE = "ShowListener.EVENT_CHANGE";/**
+ * style加载管理器
+ *
+ * Created by GUY on 2015/9/7.
+ * @class
+ */
+BI.StyleLoaderManager = BI.inherit(BI.OB, {
+ _defaultConfig: function () {
+ return BI.extend(BI.StyleLoaderManager.superclass._defaultConfig.apply(this, arguments), {});
+ },
+
+ _init: function () {
+ BI.StyleLoaderManager.superclass._init.apply(this, arguments);
+ this.stylesManager = {};
+ },
+
+ loadStyle: function (name, styleString) {
+ var d = document, styles = d.createElement('style');
+ d.getElementsByTagName('head')[0].appendChild(styles);
+ styles.setAttribute('type', 'text/css');
+ if (styles.styleSheet) {
+ styles.styleSheet.cssText = styleString;
+ } else {
+ styles.appendChild(document.createTextNode(styleString));
+ }
+ this.stylesManager[name] = styles;
+
+ return this;
+ },
+
+ get: function (name) {
+ return this.stylesManager[name];
+ },
+
+ has: function (name) {
+ return this.stylesManager[name] != null;
+ },
+
+ removeStyle: function (name) {
+ if (!this.has(name)) {
+ return this;
+ }
+ this.stylesManager[name].parentNode.removeChild(this.stylesManager[name]);
+ delete this.stylesManager[name];
+ return this;
+ }
+});/**
+ * @class BI.Logic
+ * @extends BI.OB
+ */
+BI.Logic = BI.inherit(BI.OB, {
+ createLogic: function () {
+ return this.options || {};
+ }
+});
+
+BI.LogicFactory = {
+ Type: {
+ Vertical: "vertical",
+ Horizontal: "horizontal",
+ Table: "table",
+ HorizontalFill: "horizontal_fill"
+ },
+ createLogic: function (key, options) {
+ var logic;
+ switch (key) {
+ case BI.LogicFactory.Type.Vertical:
+ logic = BI.VerticalLayoutLogic;
+ break;
+ case BI.LogicFactory.Type.Horizontal:
+ logic = BI.HorizontalLayoutLogic;
+ break;
+ case BI.LogicFactory.Type.Table:
+ logic = BI.TableLayoutLogic;
+ break;
+ case BI.LogicFactory.Type.HorizontalFill:
+ logic = BI.HorizontalFillLayoutLogic;
+ break;
+ default :
+ logic = BI.Logic;
+ break;
+ }
+ return new logic(options).createLogic();
+ },
+
+ createLogicTypeByDirection: function (direction) {
+ switch (direction) {
+ case BI.Direction.Top:
+ case BI.Direction.Bottom:
+ case BI.Direction.Custom:
+ return BI.LogicFactory.Type.Vertical;
+ break;
+ case BI.Direction.Left:
+ case BI.Direction.Right:
+ return BI.LogicFactory.Type.Horizontal;
+ }
+ },
+
+ createLogicItemsByDirection: function (direction) {
+ var layout;
+ var items = Array.prototype.slice.call(arguments, 1);
+ items = BI.map(items, function (i, item) {
+ if (BI.isWidget(item)) {
+ return {
+ el: item,
+ width: item.options.width,
+ height: item.options.height
+ }
+ }
+ return item;
+ });
+ switch (direction) {
+ case BI.Direction.Bottom:
+ layout = BI.LogicFactory.Type.Vertical;
+ items.reverse();
+ break;
+ case BI.Direction.Right:
+ layout = BI.LogicFactory.Type.Horizontal;
+ items.reverse();
+ break;
+ case BI.Direction.Custom:
+ items = items.slice(1);
+ break;
+ }
+ return items;
+ }
+};/**
+ * guy
+ * 上下布局逻辑
+ * 上下布局的时候要考虑到是动态布局还是静态布局
+ *
+ * @class BI.VerticalLayoutLogic
+ * @extends BI.Logic
+ */
+BI.VerticalLayoutLogic = BI.inherit(BI.Logic, {
+ _defaultConfig: function () {
+ return BI.extend(BI.VerticalLayoutLogic.superclass._defaultConfig.apply(this, arguments), {
+ dynamic: false,
+ scrollable: null,
+ scrolly: false,
+ scrollx: false,
+ items: [],
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+
+ createLogic: function () {
+ var layout, o = this.options;
+ if (o.dynamic) {
+ layout = "bi.vertical";
+ } else {
+ layout = "bi.vtape";
+ }
+ return {
+ type: layout,
+ scrollable: o.scrollable,
+ scrolly: o.scrolly,
+ scrollx: o.scrollx,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ items: o.items
+ }
+ },
+
+ _init: function () {
+ BI.VerticalLayoutLogic.superclass._init.apply(this, arguments);
+ }
+});
+
+
+/**
+ * guy
+ * 左右布局逻辑
+ * 左右布局的时候要考虑到是动态布局还是静态布局
+ *
+ * @class BI.HorizontalLayoutLogic
+ * @extends BI.Logic
+ */
+BI.HorizontalLayoutLogic = BI.inherit(BI.Logic, {
+ _defaultConfig: function () {
+ return BI.extend(BI.HorizontalLayoutLogic.superclass._defaultConfig.apply(this, arguments), {
+ dynamic: false,
+ scrollable: null,
+ scrolly: false,
+ scrollx: false,
+ items: [],
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+
+ createLogic: function () {
+ var layout, o = this.options;
+ if (o.dynamic) {
+ layout = "bi.horizontal";
+ } else {
+ layout = "bi.htape";
+ }
+ return {
+ type: layout,
+ scrollable: o.scrollable,
+ scrolly: o.scrolly,
+ scrollx: o.scrollx,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ items: o.items
+ }
+ },
+
+ _init: function () {
+ BI.HorizontalLayoutLogic.superclass._init.apply(this, arguments);
+ }
+});
+
+/**
+ * guy
+ * 表格布局逻辑
+ * 表格布局的时候要考虑到是动态布局还是静态布局
+ *
+ * @class BI.TableLayoutLogic
+ * @extends BI.OB
+ */
+BI.TableLayoutLogic = BI.inherit(BI.Logic, {
+ _defaultConfig: function () {
+ return BI.extend(BI.TableLayoutLogic.superclass._defaultConfig.apply(this, arguments), {
+ dynamic: false,
+ scrollable: null,
+ scrolly: false,
+ scrollx: false,
+ columns: 0,
+ rows: 0,
+ columnSize: [],
+ rowSize: [],
+ hgap: 0,
+ vgap: 0,
+ items: []
+ });
+ },
+
+ createLogic: function () {
+ var layout, o = this.options;
+ if (o.dynamic) {
+ layout = "bi.table";
+ } else {
+ layout = "bi.window";
+ }
+ return {
+ type: layout,
+ scrollable: o.scrollable,
+ scrolly: o.scrolly,
+ scrollx: o.scrollx,
+ columns: o.columns,
+ rows: o.rows,
+ columnSize: o.columnSize,
+ rowSize: o.rowSize,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ items: o.items
+ }
+ },
+
+ _init: function () {
+ BI.TableLayoutLogic.superclass._init.apply(this, arguments);
+ }
+});
+
+/**
+ * guy
+ * 左右充满布局逻辑
+ *
+ * @class BI.HorizontalFillLayoutLogic
+ * @extends BI.Logic
+ */
+BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, {
+ _defaultConfig: function () {
+ return BI.extend(BI.HorizontalFillLayoutLogic.superclass._defaultConfig.apply(this, arguments), {
+ dynamic: false,
+ scrollable: null,
+ scrolly: false,
+ scrollx: false,
+ items: [],
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+
+ createLogic: function () {
+ var layout, o = this.options;
+ var columnSize = [];
+ BI.each(o.items, function (i, item) {
+ columnSize.push(item.width || 0);
+ });
+ if (o.dynamic) {
+ layout = "bi.horizontal_adapt";
+ } else {
+ layout = "bi.htape";
+ }
+ return {
+ type: layout,
+ columnSize: columnSize,
+ scrollable: o.scrollable,
+ scrolly: o.scrolly,
+ scrollx: o.scrollx,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ items: o.items
+ }
+ },
+
+ _init: function () {
+ BI.HorizontalFillLayoutLogic.superclass._init.apply(this, arguments);
+ }
+});BI.Plugin = BI.Plugin || {};
+;
+(function () {
+ var _WidgetsPlugin = {};
+ var _ObjectPlugin = {};
+ BI.extend(BI.Plugin, {
+
+ getWidget: function (type, options) {
+ if (_WidgetsPlugin[type]) {
+ var res;
+ for (var i = _WidgetsPlugin[type].length-1; i >=0; i--) {
+ if (res = _WidgetsPlugin[type][i](options)) {
+ return res;
+ }
+ }
+ }
+ return options;
+ },
+
+ registerWidget: function (type, fn) {
+ if (!_WidgetsPlugin[type]) {
+ _WidgetsPlugin[type] = [];
+ }
+ if (_WidgetsPlugin[type].length > 0) {
+ console.log("组件已经注册过了!");
+ }
+ _WidgetsPlugin[type].push(fn);
+ },
+
+ relieveWidget: function (type) {
+ delete _WidgetsPlugin[type];
+ },
+
+ getObject: function (type, object) {
+ if (_ObjectPlugin[type]) {
+ var res;
+ for (var i = 0, len = _ObjectPlugin[type].length; i < len; i++) {
+ res = _ObjectPlugin[type][i](object);
+ }
+ }
+ return res || object;
+ },
+
+ registerObject: function (type, fn) {
+ if (!_ObjectPlugin[type]) {
+ _ObjectPlugin[type] = [];
+ }
+ if (_ObjectPlugin[type].length > 0) {
+ console.log("对象已经注册过了!");
+ }
+ _ObjectPlugin[type].push(fn);
+ },
+
+ relieveObject: function (type) {
+ delete _ObjectPlugin[type];
+ }
+ });
+})();/**
+ * 对数组对象的扩展
+ * @class Array
+ */
+$.extend(Array.prototype, {
+ contains: function (o) {
+ return this.indexOf(o) > -1;
+ },
+
+ /**
+ * 从数组中移除指定的值,如果值不在数组中,则不产生任何效果
+ * @param {Object} o 要移除的值
+ * @return {Array} 移除制定值后的数组
+ */
+ remove: function (o) {
+ var index = this.indexOf(o);
+ if (index !== -1) {
+ this.splice(index, 1);
+ }
+ return this;
+ },
+
+ pushArray: function (array) {
+ for (var i = 0; i < array.length; i++) {
+ this.push(array[i]);
+ }
+ },
+ pushDistinct: function (obj) {
+ if (!this.contains(obj)) {
+ this.push(obj);
+ }
+ },
+ pushDistinctArray: function (array) {
+ for (var i = 0, len = array.length; i < len; i++) {
+ this.pushDistinct(array[i]);
+ }
+ }
+});
+
+BI.Cache = {
+ _prefix: "bi",
+ setUsername: function (username) {
+ localStorage.setItem(BI.Cache._prefix + ".username", (username + "" || "").toUpperCase());
+ },
+ getUsername: function () {
+ return localStorage.getItem(BI.Cache._prefix + ".username") || "";
+ },
+ _getKeyPrefix: function () {
+ return BI.Cache.getUsername() + "." + BI.Cache._prefix + ".";
+ },
+ _generateKey: function (key) {
+ return BI.Cache._getKeyPrefix() + (key || "");
+ },
+ getItem: function (key) {
+ return localStorage.getItem(BI.Cache._generateKey(key));
+ },
+ setItem: function (key, value) {
+ localStorage.setItem(BI.Cache._generateKey(key), value);
+ },
+ removeItem: function (key) {
+ localStorage.removeItem(BI.Cache._generateKey(key));
+ },
+ clear: function () {
+ for (var i = localStorage.length; i >= 0; i--) {
+ var key = localStorage.key(i);
+ if (key) {
+ if (key.indexOf(BI.Cache._getKeyPrefix()) === 0) {
+ localStorage.removeItem(key);
+ }
+ }
+ }
+ },
+ keys: function () {
+ var result = [];
+ for (var i = localStorage.length; i >= 0; i--) {
+ var key = localStorage.key(i);
+ if (key) {
+ var prefix = BI.Cache._getKeyPrefix();
+ if (key.indexOf(prefix) === 0) {
+ result[result.length] = key.substring(prefix.length);
+ }
+ }
+ }
+ return result;
+ },
+
+ addCookie: function (name, value, path, expiresHours) {
+ var cookieString = name + "=" + escape(value);
+ // 判断是否设置过期时间
+ if (expiresHours && expiresHours > 0) {
+ var date = new Date();
+ date.setTime(date.getTime() + expiresHours * 3600 * 1000);
+ cookieString = cookieString + "; expires=" + date.toGMTString();
+ }
+ if (path) {
+ cookieString = cookieString + "; path=" + path;
+ }
+ document.cookie = cookieString;
+ },
+ getCookie: function (name) {
+ var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
+ if (arr = document.cookie.match(reg))
+ return unescape(arr[2]);
+ else
+ return null;
+ },
+ deleteCookie: function (name, path) {
+ var date = new Date();
+ date.setTime(date.getTime() - 10000);
+ var cookieString = name + "=v; expires=" + date.toGMTString();
+ if (path) {
+ cookieString = cookieString + "; path=" + path;
+ }
+ document.cookie = cookieString;
+ }
+};// full day names
+Date._DN = [BI.i18nText("BI-Basic_Sunday"),
+ BI.i18nText("BI-Basic_Monday"),
+ BI.i18nText("BI-Basic_Tuesday"),
+ BI.i18nText("BI-Basic_Wednesday"),
+ BI.i18nText("BI-Basic_Thursday"),
+ BI.i18nText("BI-Basic_Friday"),
+ BI.i18nText("BI-Basic_Saturday"),
+ BI.i18nText("BI-Basic_Sunday")];
+
+// short day names
+Date._SDN = [BI.i18nText("BI-Basic_Simple_Sunday"),
+ BI.i18nText("BI-Basic_Simple_Monday"),
+ BI.i18nText("BI-Basic_Simple_Tuesday"),
+ BI.i18nText("BI-Basic_Simple_Wednesday"),
+ BI.i18nText("BI-Basic_Simple_Thursday"),
+ BI.i18nText("BI-Basic_Simple_Friday"),
+ BI.i18nText("BI-Basic_Simple_Saturday"),
+ BI.i18nText("BI-Basic_Simple_Sunday")];
+
+// Monday first, etc.
+Date._FD = 1;
+
+// full month namesdat
+Date._MN = [
+ BI.i18nText("BI-Basic_January"),
+ BI.i18nText("BI-Basic_February"),
+ BI.i18nText("BI-Basic_March"),
+ BI.i18nText("BI-Basic_April"),
+ BI.i18nText("BI-Basic_May"),
+ BI.i18nText("BI-Basic_June"),
+ BI.i18nText("BI-Basic_July"),
+ BI.i18nText("BI-Basic_August"),
+ BI.i18nText("BI-Basic_September"),
+ BI.i18nText("BI-Basic_October"),
+ BI.i18nText("BI-Basic_November"),
+ BI.i18nText("BI-Basic_December")];
+
+// short month names
+Date._SMN = [0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11];
+
+Date._QN = ["", BI.i18nText("BI-Quarter_1"),
+ BI.i18nText("BI-Quarter_2"),
+ BI.i18nText("BI-Quarter_3"),
+ BI.i18nText("BI-Quarter_4")];
+
+/** Adds the number of days array to the Date object. */
+Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
+
+/** Constants used for time computations */
+Date.SECOND = 1000 /* milliseconds */;
+Date.MINUTE = 60 * Date.SECOND;
+Date.HOUR = 60 * Date.MINUTE;
+Date.DAY = 24 * Date.HOUR;
+Date.WEEK = 7 * Date.DAY;
+
+/**
+ * 获取时区
+ * @returns {String}
+ */
+Date.prototype.getTimezone = function () {
+ return this.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");
+};
+
+/** Returns the number of days in the current month */
+Date.prototype.getMonthDays = function (month) {
+ var year = this.getFullYear();
+ if (typeof month == "undefined") {
+ month = this.getMonth();
+ }
+ if (((0 == (year % 4)) && ( (0 != (year % 100)) || (0 == (year % 400)))) && month == 1) {
+ return 29;
+ } else {
+ return Date._MD[month];
+ }
+};
+
+/** Returns the number of day in the year. */
+Date.prototype.getDayOfYear = function () {
+ var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
+ var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
+ var time = now - then;
+ return Math.floor(time / Date.DAY);
+};
+
+/** Returns the number of the week in year, as defined in ISO 8601. */
+Date.prototype.getWeekNumber = function () {
+ var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
+ var week = d.getDay();
+ if (this.getMonth() === 0 && this.getDate() <= week) {
+ return 1;
+ }
+ d.setDate(this.getDate() - week);
+ var ms = d.valueOf(); // GMT
+ d.setMonth(0);
+ d.setDate(1);
+ var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
+ if (d.getDay() > 0) {
+ offset++;
+ }
+ return offset;
+};
+
+//离当前时间多少天的时间
+Date.prototype.getOffsetDate = function (offset) {
+ return new Date(this.getTime() + offset * 864e5);
+};
+
+Date.prototype.getAfterMulQuarter = function (n) {
+ var dt = new Date(this.getTime());
+ dt.setMonth(dt.getMonth() + n * 3);
+ return dt;
+};
+//获得n个季度前的日期
+Date.prototype.getBeforeMulQuarter = function (n) {
+ var dt = new Date(this.getTime());
+ dt.setMonth(dt.getMonth() - n * 3);
+ return dt;
+};
+//得到本季度的起始月份
+Date.prototype.getQuarterStartMonth = function () {
+ var quarterStartMonth = 0;
+ var nowMonth = this.getMonth();
+ if (nowMonth < 3) {
+ quarterStartMonth = 0;
+ }
+ if (2 < nowMonth && nowMonth < 6) {
+ quarterStartMonth = 3;
+ }
+ if (5 < nowMonth && nowMonth < 9) {
+ quarterStartMonth = 6;
+ }
+ if (nowMonth > 8) {
+ quarterStartMonth = 9;
+ }
+ return quarterStartMonth;
+};
+//获得本季度的起始日期
+Date.prototype.getQuarterStartDate = function () {
+ return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1);
+};
+//得到本季度的结束日期
+Date.prototype.getQuarterEndDate = function () {
+ var quarterEndMonth = this.getQuarterStartMonth() + 2;
+ return new Date(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth));
+};
+Date.prototype.getAfterMultiMonth = function (n) {
+ var dt = new Date(this.getTime());
+ dt.setMonth(dt.getMonth() + n | 0);
+ return dt;
+};
+Date.prototype.getBeforeMultiMonth = function (n) {
+ var dt = new Date(this.getTime());
+ dt.setMonth(dt.getMonth() - n | 0);
+ return dt;
+};
+
+Date.prototype.getAfterMulQuarter = function (n) {
+ var dt = new Date(this.getTime());
+ dt.setMonth(dt.getMonth() + n * 3);
+ return dt;
+};
+//获得n个季度前的日期
+Date.prototype.getBeforeMulQuarter = function (n) {
+ var dt = new Date(this.getTime());
+ dt.setMonth(dt.getMonth() - n * 3);
+ return dt;
+};
+//得到本季度的起始月份
+Date.prototype.getQuarterStartMonth = function () {
+ var quarterStartMonth = 0;
+ var nowMonth = this.getMonth();
+ if (nowMonth < 3) {
+ quarterStartMonth = 0;
+ }
+ if (2 < nowMonth && nowMonth < 6) {
+ quarterStartMonth = 3;
+ }
+ if (5 < nowMonth && nowMonth < 9) {
+ quarterStartMonth = 6;
+ }
+ if (nowMonth > 8) {
+ quarterStartMonth = 9;
+ }
+ return quarterStartMonth;
+};
+
+//指定日期n个月之前或之后的日期
+Date.prototype.getOffsetMonth = function (n) {
+ var dt = new Date(this.getTime());
+ var day = dt.getDate();
+ var monthDay = new Date(dt.getFullYear(), dt.getMonth() + parseInt(n), 1).getMonthDays();
+ if (day > monthDay) {
+ day = monthDay;
+ }
+ dt.setDate(day);
+ dt.setMonth(dt.getMonth() + parseInt(n));
+ return dt;
+};
+
+//获得本周的起始日期
+Date.prototype.getWeekStartDate = function () {
+ var w = this.getDay();
+ return this.getOffsetDate(-w);
+};
+//得到本周的结束日期
+Date.prototype.getWeekEndDate = function () {
+ var w = this.getDay();
+ var offset = (w === 0 ? 6 : 6 - w);
+ return this.getOffsetDate(offset);
+};
+
+//获得本季度的起始日期
+Date.prototype.getQuarterStartDate = function () {
+ return new Date(this.getFullYear(), this.getQuarterStartMonth(), 1);
+};
+//得到本季度的结束日期
+Date.prototype.getQuarterEndDate = function () {
+ var quarterEndMonth = this.getQuarterStartMonth() + 2;
+ return new Date(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth));
+};
+Date.prototype.getAfterMultiMonth = function (n) {
+ var dt = new Date(this.getTime());
+ dt.setMonth(dt.getMonth() + n | 0);
+ return dt;
+};
+Date.prototype.getBeforeMultiMonth = function (n) {
+ var dt = new Date(this.getTime());
+ dt.setMonth(dt.getMonth() - n | 0);
+ return dt;
+};
+
+/** Checks date and time equality */
+Date.prototype.equalsTo = function (date) {
+ return ((this.getFullYear() == date.getFullYear()) &&
+ (this.getMonth() == date.getMonth()) &&
+ (this.getDate() == date.getDate()) &&
+ (this.getHours() == date.getHours()) &&
+ (this.getMinutes() == date.getMinutes()) &&
+ (this.getSeconds() == date.getSeconds()));
+};
+
+/** Set only the year, month, date parts (keep existing time) */
+Date.prototype.setDateOnly = function (date) {
+ var tmp = new Date(date);
+ this.setDate(1);
+ this.setFullYear(tmp.getFullYear());
+ this.setMonth(tmp.getMonth());
+ this.setDate(tmp.getDate());
+};
+/** Prints the date in a string according to the given format. */
+Date.prototype.print = function (str) {
+ var m = this.getMonth();
+ var d = this.getDate();
+ var y = this.getFullYear();
+ var wn = this.getWeekNumber();
+ var w = this.getDay();
+ var s = {};
+ var hr = this.getHours();
+ var pm = (hr >= 12);
+ var ir = (pm) ? (hr - 12) : hr;
+ var dy = this.getDayOfYear();
+ if (ir == 0) {
+ ir = 12;
+ }
+ var min = this.getMinutes();
+ var sec = this.getSeconds();
+ s["%a"] = Date._SDN[w]; // abbreviated weekday name [FIXME: I18N]
+ s["%A"] = Date._DN[w]; // full weekday name
+ s["%b"] = Date._SMN[m]; // abbreviated month name [FIXME: I18N]
+ s["%B"] = Date._MN[m]; // full month name
+ // FIXME: %c : preferred date and time representation for the current locale
+ s["%C"] = 1 + Math.floor(y / 100); // the century number
+ s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)
+ s["%e"] = d; // the day of the month (range 1 to 31)
+ // FIXME: %D : american date style: %m/%d/%y
+ // FIXME: %E, %F, %G, %g, %h (man strftime)
+ s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
+ s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
+ s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
+ s["%k"] = hr; // hour, range 0 to 23 (24h format)
+ s["%l"] = ir; // hour, range 1 to 12 (12h format)
+ s["%X"] = (m < 9) ? ("0" + (1 + m)) : (1 + m); // month, range 01 to 12
+ s["%x"] = m + 1 // month, range 1 to 12
+ s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
+ s["%n"] = "\n"; // a newline character
+ s["%p"] = pm ? "PM" : "AM";
+ s["%P"] = pm ? "pm" : "am";
+ // FIXME: %r : the time in am/pm notation %I:%M:%S %p
+ // FIXME: %R : the time in 24-hour notation %H:%M
+ s["%s"] = Math.floor(this.getTime() / 1000);
+ s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
+ s["%t"] = "\t"; // a tab character
+ // FIXME: %T : the time in 24-hour notation (%H:%M:%S)
+ s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
+ s["%u"] = w + 1; // the day of the week (range 1 to 7, 1 = MON)
+ s["%w"] = w; // the day of the week (range 0 to 6, 0 = SUN)
+ // FIXME: %x : preferred date representation for the current locale without the time
+ // FIXME: %X : preferred time representation for the current locale without the date
+ s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
+ s["%Y"] = y; // year with the century
+ s["%%"] = "%"; // a literal '%' character
+
+ var re = /%./g;
+ if (!BI.isKhtml()) {
+ return str.replace(re, function (par) {
+ return s[par] || par;
+ });
+ }
+
+ var a = str.match(re);
+ for (var i = 0; i < a.length; i++) {
+ var tmp = s[a[i]];
+ if (tmp) {
+ re = new RegExp(a[i], 'g');
+ str = str.replace(re, tmp);
+ }
+ }
+
+ return str;
+};
+
+/**
+ * 是否是闰年
+ * @param year
+ * @returns {boolean}
+ */
+Date.isLeap = function (year) {
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
+};
+
+/**
+ * 检测是否在有效期
+ *
+ * @param YY 年
+ * @param MM 月
+ * @param DD 日
+ * @param minDate '1900-01-01'
+ * @param maxDate '2099-12-31'
+ * @returns {Array} 若无效返回无效状态
+ */
+Date.checkVoid = function (YY, MM, DD, minDate, maxDate) {
+ var back = [];
+ YY = YY | 0;
+ MM = MM | 0;
+ DD = DD | 0;
+ minDate = BI.isString(minDate) ? minDate.match(/\d+/g) : minDate;
+ maxDate = BI.isString(maxDate) ? maxDate.match(/\d+/g) : maxDate;
+ if (YY < minDate[0]) {
+ back = ['y'];
+ } else if (YY > maxDate[0]) {
+ back = ['y', 1];
+ } else if (YY >= minDate[0] && YY <= maxDate[0]) {
+ if (YY == minDate[0]) {
+ if (MM < minDate[1]) {
+ back = ['m'];
+ } else if (MM == minDate[1]) {
+ if (DD < minDate[2]) {
+ back = ['d'];
+ }
+ }
+ }
+ if (YY == maxDate[0]) {
+ if (MM > maxDate[1]) {
+ back = ['m', 1];
+ } else if (MM == maxDate[1]) {
+ if (DD > maxDate[2]) {
+ back = ['d', 1];
+ }
+ }
+ }
+ }
+ return back;
+};
+
+Date.checkLegal = function (str) {
+ var ar = str.match(/\d+/g);
+ var YY = ar[0] | 0, MM = ar[1] | 0, DD = ar[2] | 0;
+ if (ar.length <= 1) {
+ return true;
+ }
+ if (ar.length <= 2) {
+ return MM >= 1 && MM <= 12;
+ }
+ var MD = Date._MD.slice(0);
+ MD[1] = Date.isLeap(YY) ? 29 : 28;
+ return MM >= 1 && MM <= 12 && DD <= MD[MM - 1];
+};
+
+Date.parseDateTime = function (str, fmt) {
+ var today = new Date();
+ var y = 0;
+ var m = 0;
+ var d = 1;
+ //wei : 对于fmt为‘YYYYMM’或者‘YYYYMMdd’的格式,str的值为类似'201111'的形式,因为年月之间没有分隔符,所以正则表达式分割无效,导致bug7376。
+ var a = str.split(/\W+/);
+ if (fmt.toLowerCase() == '%y%x' || fmt.toLowerCase() == '%y%x%d') {
+ var yearlength = 4;
+ var otherlength = 2;
+ a[0] = str.substring(0, yearlength);
+ a[1] = str.substring(yearlength, yearlength + otherlength);
+ a[2] = str.substring(yearlength + otherlength, yearlength + otherlength * 2);
+ }
+ var b = fmt.match(/%./g);
+ var i = 0, j = 0;
+ var hr = 0;
+ var min = 0;
+ var sec = 0;
+ for (i = 0; i < a.length; ++i) {
+ switch (b[i]) {
+ case "%d":
+ case "%e":
+ d = parseInt(a[i], 10);
+ break;
+
+ case "%X":
+ m = parseInt(a[i], 10) - 1;
+ break;
+ case "%x":
+ m = parseInt(a[i], 10) - 1;
+ break;
+
+ case "%Y":
+ case "%y":
+ y = parseInt(a[i], 10);
+ (y < 100) && (y += (y > 29) ? 1900 : 2000);
+ break;
+
+ case "%b":
+ case "%B":
+ for (j = 0; j < 12; ++j) {
+ if (Date._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) {
+ m = j;
+ break;
+ }
+ }
+ break;
+
+ case "%H":
+ case "%I":
+ case "%k":
+ case "%l":
+ hr = parseInt(a[i], 10);
+ break;
+
+ case "%P":
+ case "%p":
+ if (/pm/i.test(a[i]) && hr < 12) {
+ hr += 12;
+ } else if (/am/i.test(a[i]) && hr >= 12) {
+ hr -= 12;
+ }
+ break;
+
+ case "%M":
+ min = parseInt(a[i], 10);
+ case "%S":
+ sec = parseInt(a[i], 10);
+ break;
+ }
+ }
+// if (!a[i]) {
+// continue;
+// }
+ if (isNaN(y)) {
+ y = today.getFullYear();
+ }
+ if (isNaN(m)) {
+ m = today.getMonth();
+ }
+ if (isNaN(d)) {
+ d = today.getDate();
+ }
+ if (isNaN(hr)) {
+ hr = today.getHours();
+ }
+ if (isNaN(min)) {
+ min = today.getMinutes();
+ }
+ if (isNaN(sec)) {
+ sec = today.getSeconds();
+ }
+ if (y != 0) {
+ return new Date(y, m, d, hr, min, sec);
+ }
+ y = 0;
+ m = -1;
+ d = 0;
+ for (i = 0; i < a.length; ++i) {
+ if (a[i].search(/[a-zA-Z]+/) != -1) {
+ var t = -1;
+ for (j = 0; j < 12; ++j) {
+ if (Date._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) {
+ t = j;
+ break;
+ }
+ }
+ if (t != -1) {
+ if (m != -1) {
+ d = m + 1;
+ }
+ m = t;
+ }
+ } else if (parseInt(a[i], 10) <= 12 && m == -1) {
+ m = a[i] - 1;
+ } else if (parseInt(a[i], 10) > 31 && y == 0) {
+ y = parseInt(a[i], 10);
+ (y < 100) && (y += (y > 29) ? 1900 : 2000);
+ } else if (d == 0) {
+ d = a[i];
+ }
+ }
+ if (y == 0) {
+ y = today.getFullYear();
+ }
+ if (m != -1 && d != 0) {
+ return new Date(y, m, d, hr, min, sec);
+ }
+ return today;
+};
+/*
+ * 给jQuery.Event对象添加的工具方法
+ */
+$.extend($.Event.prototype, {
+ // event.stopEvent
+ stopEvent: function () {
+ this.stopPropagation();
+ this.preventDefault();
+ }
+});Function.prototype.before = function (func) {
+ var __self = this;
+ return function () {
+ if (func.apply(this, arguments) === false) {
+ return false;
+ }
+ return __self.apply(this, arguments);
+ }
+};
+
+Function.prototype.after = function (func) {
+ var __self = this;
+ return function () {
+ var ret = __self.apply(this, arguments);
+ if (ret === false) {
+ return false;
+ }
+ func.apply(this, arguments);
+ return ret;
+ }
+};/*!
+ * jLayout JQuery Plugin v0.11
+ *
+ * Licensed under the revised BSD License.
+ * Copyright 2008, Bram Stein
+ * All rights reserved.
+ */
+if (jQuery) {
+ (function ($) {
+ // richer:容器在其各个边缘留出的空间
+ if (!$.fn.insets) {
+ $.fn.insets = function () {
+ var p = this.padding(),
+ b = this.border();
+ return {
+ 'top': p.top,
+ 'bottom': p.bottom + b.bottom + b.top,
+ 'left': p.left,
+ 'right': p.right + b.right + b.left
+ };
+ };
+ }
+
+ // richer:获取 && 设置jQuery元素的边界
+ if (!$.fn.bounds) {
+ $.fn.bounds = function (value) {
+ var tmp = {hasIgnoredBounds: true};
+
+ if (value) {
+ if (!isNaN(value.x)) {
+ tmp.left = value.x;
+ }
+ if (!isNaN(value.y)) {
+ tmp.top = value.y;
+ }
+ if (value.width != null) {
+ tmp.width = (value.width - (this.outerWidth(true) - this.width()));
+ tmp.width = (tmp.width >= 0) ? tmp.width : value.width;
+ // fix chrome
+ //tmp.width = (tmp.width >= 0) ? tmp.width : 0;
+ }
+ if (value.height != null) {
+ tmp.height = value.height - (this.outerHeight(true) - this.height());
+ tmp.height = (tmp.height >= 0) ? tmp.height : value.height;
+ // fix chrome
+ //tmp.height = (tmp.height >= 0) ? tmp.height : value.0;
+ }
+ this.css(tmp);
+ return this;
+ }
+ else {
+ // richer:注意此方法只对可见元素有效
+ tmp = this.position();
+ return {
+ 'x': tmp.left,
+ 'y': tmp.top,
+ // richer:这里计算外部宽度和高度的时候,都不包括边框
+ 'width': this.outerWidth(),
+ 'height': this.outerHeight()
+ };
+ }
+ };
+ }
+ })(jQuery);
+}
+;if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
+ (0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' ||
+ (1000000000000000128).toFixed(0) !== "1000000000000000128") {
+ (function () {
+ var base, size, data, i;
+ base = 1e7;
+ size = 6;
+ data = [0, 0, 0, 0, 0, 0];
+ function multiply(n, c) {
+ var i = -1;
+ while (++i < size) {
+ c += n * data[i];
+ data[i] = c % base;
+ c = Math.floor(c / base);
+ }
+ }
+
+ function divide(n) {
+ var i = size, c = 0;
+ while (--i >= 0) {
+ c += data[i];
+ data[i] = Math.floor(c / n);
+ c = (c % n) * base;
+ }
+ }
+
+ function toString() {
+ var i = size;
+ var s = '';
+ while (--i >= 0) {
+ if (s !== '' || i === 0 || data[i] !== 0) {
+ var t = String(data[i]);
+ if (s === '') {
+ s = t;
+ } else {
+ s += '0000000'.slice(0, 7 - t.length) + t;
+ }
+ }
+ }
+ return s;
+ }
+
+ function pow(x, n, acc) {
+ return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x)
+ : pow(x * x, n / 2, acc)));
+ }
+
+ function log(x) {
+ var n = 0;
+ while (x >= 4096) {
+ n += 12;
+ x /= 4096;
+ }
+ while (x >= 2) {
+ n += 1;
+ x /= 2;
+ }
+ return n;
+ }
+
+ Number.prototype.toFixed = function (fractionDigits) {
+ var f, x, s, m, e, z, j, k;
+ f = Number(fractionDigits);
+ f = f !== f ? 0 : Math.floor(f);
+
+ if (f < 0 || f > 20) {
+ throw new RangeError('Number.toFixed called with invalid number of decimals');
+ }
+
+ x = Number(this);
+
+ if (x !== x) {
+ return "NaN";
+ }
+
+ if (x <= -1e21 || x > 1e21) {
+ return String(x);
+ }
+
+ s = "";
+
+ if (x < 0) {
+ s = "-";
+ x = -x;
+ }
+
+ m = "0";
+
+ if (x > 1e-21) {
+ //1e-21
0) {
+ multiply(0, z);
+ j = f;
+
+ while (j >= 7) {
+ multiply(1e7, 0);
+ j -= 7;
+ }
+
+ multiply(pow(10, j, 1), 0);
+ j = e - 1;
+
+ while (j >= 23) {
+ divide(1 << 23);
+ j -= 23;
+ }
+ divide(1 << j);
+ multiply(1, 1);
+ divide(2);
+ m = toString();
+ } else {
+ multiply(0, z);
+ multiply(1 << (-e), 0);
+ m = toString() + '0.00000000000000000000'.slice(2, 2 + f);
+ }
+ }
+
+ if (f > 0) {
+ k = m.length;
+
+ if (k <= f) {
+ m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
+ } else {
+ m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
+ }
+ } else {
+ m = s + m;
+ }
+
+ return m;
+ }
+
+ })();
+}
+
+
+/**
+ ** 加法函数,用来得到精确的加法结果
+ ** 说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
+ ** 调用:accAdd(arg1,arg2)
+ ** 返回值:arg1加上arg2的精确结果
+ **/
+function accAdd(arg1, arg2) {
+ var r1, r2, m, c;
+ try {
+ r1 = arg1.toString().split(".")[1].length;
+ }
+ catch (e) {
+ r1 = 0;
+ }
+ try {
+ r2 = arg2.toString().split(".")[1].length;
+ }
+ catch (e) {
+ r2 = 0;
+ }
+ c = Math.abs(r1 - r2);
+ m = Math.pow(10, Math.max(r1, r2));
+ if (c > 0) {
+ var cm = Math.pow(10, c);
+ if (r1 > r2) {
+ arg1 = Number(arg1.toString().replace(".", ""));
+ arg2 = Number(arg2.toString().replace(".", "")) * cm;
+ } else {
+ arg1 = Number(arg1.toString().replace(".", "")) * cm;
+ arg2 = Number(arg2.toString().replace(".", ""));
+ }
+ } else {
+ arg1 = Number(arg1.toString().replace(".", ""));
+ arg2 = Number(arg2.toString().replace(".", ""));
+ }
+ return (arg1 + arg2) / m;
+}
+
+//给Number类型增加一个add方法,调用起来更加方便。
+Number.prototype.add = function (arg) {
+ return accAdd(arg, this);
+};
+/**
+ ** 减法函数,用来得到精确的减法结果
+ ** 说明:javascript的减法结果会有误差,在两个浮点数相减的时候会比较明显。这个函数返回较为精确的减法结果。
+ ** 调用:accSub(arg1,arg2)
+ ** 返回值:arg1加上arg2的精确结果
+ **/
+function accSub(arg1, arg2) {
+ var r1, r2, m, n;
+ try {
+ r1 = arg1.toString().split(".")[1].length;
+ }
+ catch (e) {
+ r1 = 0;
+ }
+ try {
+ r2 = arg2.toString().split(".")[1].length;
+ }
+ catch (e) {
+ r2 = 0;
+ }
+ m = Math.pow(10, Math.max(r1, r2)); //last modify by deeka //动态控制精度长度
+ n = (r1 >= r2) ? r1 : r2;
+ return ((arg1 * m - arg2 * m) / m).toFixed(n);
+}
+
+// 给Number类型增加一个mul方法,调用起来更加方便。
+Number.prototype.sub = function (arg) {
+ return accSub(this, arg);
+};
+/**
+ ** 乘法函数,用来得到精确的乘法结果
+ ** 说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
+ ** 调用:accMul(arg1,arg2)
+ ** 返回值:arg1乘以 arg2的精确结果
+ **/
+function accMul(arg1, arg2) {
+ var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
+ try {
+ m += s1.split(".")[1].length;
+ }
+ catch (e) {
+ }
+ try {
+ m += s2.split(".")[1].length;
+ }
+ catch (e) {
+ }
+ return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
+}
+
+// 给Number类型增加一个mul方法,调用起来更加方便。
+Number.prototype.mul = function (arg) {
+ return accMul(arg, this);
+};
+/**
+ ** 除法函数,用来得到精确的除法结果
+ ** 说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
+ ** 调用:accDiv(arg1,arg2)
+ ** 返回值:arg1除以arg2的精确结果
+ **/
+function accDiv(arg1, arg2) {
+ var t1 = 0, t2 = 0, r1, r2;
+ try {
+ t1 = arg1.toString().split(".")[1].length;
+ }
+ catch (e) {
+ }
+ try {
+ t2 = arg2.toString().split(".")[1].length;
+ }
+ catch (e) {
+ }
+ with (Math) {
+ r1 = Number(arg1.toString().replace(".", ""));
+ r2 = Number(arg2.toString().replace(".", ""));
+ return (t2 > t1) ? (r1 / r2) * pow(10, t2 - t1) : (r1 / r2) / pow(10, t1 - t2);
+ }
+}
+
+//给Number类型增加一个div方法,调用起来更加方便。
+Number.prototype.div = function (arg) {
+ return accDiv(this, arg);
+};/**
+ * 对字符串对象的扩展
+ * @class String
+ */
+$.extend(String.prototype, {
+
+ /**
+ * 判断字符串是否已指定的字符串开始
+ * @param {String} startTag 指定的开始字符串
+ * @return {Boolean} 如果字符串以指定字符串开始则返回true,否则返回false
+ */
+ startWith: function (startTag) {
+ if (startTag == null || startTag == "" || this.length === 0 || startTag.length > this.length) {
+ return false;
+ }
+ return this.substr(0, startTag.length) == startTag;
+ },
+ /**
+ * 判断字符串是否以指定的字符串结束
+ * @param {String} endTag 指定的字符串
+ * @return {Boolean} 如果字符串以指定字符串结束则返回true,否则返回false
+ */
+ endWith: function (endTag) {
+ if (endTag == null || endTag == "" || this.length === 0 || endTag.length > this.length) {
+ return false;
+ }
+ return this.substring(this.length - endTag.length) == endTag;
+ },
+
+ /**
+ * 获取url中指定名字的参数
+ * @param {String} name 参数的名字
+ * @return {String} 参数的值
+ */
+ getQuery: function (name) {
+ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+ var r = this.substr(this.indexOf("?") + 1).match(reg);
+ if (r) {
+ return unescape(r[2]);
+ }
+ return null;
+ },
+
+ /**
+ * 给url加上给定的参数
+ * @param {Object} paras 参数对象,是一个键值对对象
+ * @return {String} 添加了给定参数的url
+ */
+ appendQuery: function (paras) {
+ if (!paras) {
+ return this;
+ }
+ var src = this;
+ // 没有问号说明还没有参数
+ if (src.indexOf("?") === -1) {
+ src += "?";
+ }
+ // 如果以问号结尾,说明没有其他参数
+ if (src.endWith("?") !== false) {
+ } else {
+ src += "&";
+ }
+ $.each(paras, function (name, value) {
+ if (typeof(name) === 'string') {
+ src += name + "=" + value + "&";
+ }
+ });
+ src = src.substr(0, src.length - 1);
+ return src;
+ },
+ /**
+ * 将所有符合第一个字符串所表示的字符串替换成为第二个字符串
+ * @param {String} s1 要替换的字符串的正则表达式
+ * @param {String} s2 替换的结果字符串
+ * @returns {String} 替换后的字符串
+ */
+ replaceAll: function (s1, s2) {
+ return this.replace(new RegExp(s1, "gm"), s2);
+ },
+ /**
+ * 总是让字符串以指定的字符开头
+ * @param {String} start 指定的字符
+ * @returns {String} 以指定字符开头的字符串
+ */
+ perfectStart: function (start) {
+ if (this.startWith(start)) {
+ return this;
+ } else {
+ return start + this;
+ }
+ },
+
+ /**
+ * 获取字符串中某字符串的所有项位置数组
+ * @param {String} sub 子字符串
+ * @return {Number[]} 子字符串在父字符串中出现的所有位置组成的数组
+ */
+ allIndexOf: function (sub) {
+ if (typeof sub != 'string') {
+ return [];
+ }
+ var str = this;
+ var location = [];
+ var offset = 0;
+ while (str.length > 0) {
+ var loc = str.indexOf(sub);
+ if (loc === -1) {
+ break;
+ }
+ location.push(offset + loc);
+ str = str.substring(loc + sub.length, str.length);
+ offset += loc + sub.length;
+ }
+ return location;
+ }
+});
+
+/**
+ * 对字符串对象的扩展
+ * @class String
+ */
+$.extend(String, {
+
+ /**
+ * 对字符串中的'和\做编码处理
+ * @static
+ * @param {String} string 要做编码处理的字符串
+ * @return {String} 编码后的字符串
+ */
+ escape: function (string) {
+ return string.replace(/('|\\)/g, "\\$1");
+ },
+
+ /**
+ * 让字符串通过指定字符做补齐的函数
+ *
+ * var s = String.leftPad('123', 5, '0');//s的值为:'00123'
+ *
+ * @static
+ * @param {String} val 原始值
+ * @param {Number} size 总共需要的位数
+ * @param {String} ch 用于补齐的字符
+ * @return {String} 补齐后的字符串
+ */
+ leftPad: function (val, size, ch) {
+ var result = String(val);
+ if (!ch) {
+ ch = " ";
+ }
+ while (result.length < size) {
+ result = ch + result;
+ }
+ return result.toString();
+ },
+
+ /**
+ * 对字符串做替换的函数
+ *
+ * var cls = 'my-class', text = 'Some text';
+ * var res = String.format('Some text
';
+ *
+ * @static
+ * @param {String} format 要做替换的字符串,替换字符串1,替换字符串2...
+ * @return {String} 做了替换后的字符串
+ */
+ format: function (format) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ return format.replace(/\{(\d+)\}/g, function (m, i) {
+ return args[i];
+ });
+ }
+});BI.EventListener = {
+ listen: function listen(target, eventType, callback) {
+ if (target.addEventListener) {
+ target.addEventListener(eventType, callback, false);
+ return {
+ remove: function remove() {
+ target.removeEventListener(eventType, callback, false);
+ }
+ };
+ } else if (target.attachEvent) {
+ target.attachEvent('on' + eventType, callback);
+ return {
+ remove: function remove() {
+ target.detachEvent('on' + eventType, callback);
+ }
+ };
+ }
+ },
+
+ capture: function capture(target, eventType, callback) {
+ if (target.addEventListener) {
+ target.addEventListener(eventType, callback, true);
+ return {
+ remove: function remove() {
+ target.removeEventListener(eventType, callback, true);
+ }
+ };
+ } else {
+ return {
+ remove: BI.emptyFn
+ };
+ }
+ },
+
+ registerDefault: function registerDefault() {
+ }
+};!(function () {
+ var cancelAnimationFrame =
+ window.cancelAnimationFrame ||
+ window.webkitCancelAnimationFrame ||
+ window.mozCancelAnimationFrame ||
+ window.oCancelAnimationFrame ||
+ window.msCancelAnimationFrame ||
+ window.clearTimeout;
+
+ var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || window.setTimeout;
+
+
+ BI.MouseMoveTracker = function (onMove, onMoveEnd, domNode) {
+ this._isDragging = false;
+ this._animationFrameID = null;
+ this._domNode = domNode;
+ this._onMove = onMove;
+ this._onMoveEnd = onMoveEnd;
+
+ this._onMouseMove = BI.bind(this._onMouseMove, this);
+ this._onMouseUp = BI.bind(this._onMouseUp, this);
+ this._didMouseMove = BI.bind(this._didMouseMove, this);
+ };
+ BI.MouseMoveTracker.prototype = {
+ constructor: BI.MouseMoveTracker,
+ captureMouseMoves: function (/*object*/ event) {
+ if (!this._eventMoveToken && !this._eventUpToken) {
+ this._eventMoveToken = BI.EventListener.listen(
+ this._domNode,
+ 'mousemove',
+ this._onMouseMove
+ );
+ this._eventUpToken = BI.EventListener.listen(
+ this._domNode,
+ 'mouseup',
+ this._onMouseUp
+ );
+ }
+
+ if (!this._isDragging) {
+ this._deltaX = 0;
+ this._deltaY = 0;
+ this._isDragging = true;
+ this._x = event.clientX;
+ this._y = event.clientY;
+ }
+ event.preventDefault ? event.preventDefault() : (event.returnValue = false);
+ },
+
+ releaseMouseMoves: function () {
+ if (this._eventMoveToken && this._eventUpToken) {
+ this._eventMoveToken.remove();
+ this._eventMoveToken = null;
+ this._eventUpToken.remove();
+ this._eventUpToken = null;
+ }
+
+ if (this._animationFrameID !== null) {
+ cancelAnimationFrame(this._animationFrameID);
+ this._animationFrameID = null;
+ }
+
+ if (this._isDragging) {
+ this._isDragging = false;
+ this._x = null;
+ this._y = null;
+ }
+ },
+
+ isDragging: function () /*boolean*/ {
+ return this._isDragging;
+ },
+
+ _onMouseMove: function (/*object*/ event) {
+ var x = event.clientX;
+ var y = event.clientY;
+
+ this._deltaX += (x - this._x);
+ this._deltaY += (y - this._y);
+
+ if (this._animationFrameID === null) {
+ // The mouse may move faster then the animation frame does.
+ // Use `requestAnimationFrame` to avoid over-updating.
+ this._animationFrameID =
+ requestAnimationFrame(this._didMouseMove);
+ }
+
+ this._x = x;
+ this._y = y;
+ event.preventDefault ? event.preventDefault() : (event.returnValue = false);
+ },
+
+ _didMouseMove: function () {
+ this._animationFrameID = null;
+ this._onMove(this._deltaX, this._deltaY);
+ this._deltaX = 0;
+ this._deltaY = 0;
+ },
+
+ _onMouseUp: function () {
+ if (this._animationFrameID) {
+ this._didMouseMove();
+ }
+ this._onMoveEnd();
+ }
+ };
+})();!(function () {
+ var PIXEL_STEP = 10;
+ var LINE_HEIGHT = 40;
+ var PAGE_HEIGHT = 800;
+ var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || window.setTimeout;
+
+ function normalizeWheel(/*object*/event) /*object*/ {
+ var sX = 0,
+ sY = 0,
+ // spinX, spinY
+ pX = 0,
+ pY = 0; // pixelX, pixelY
+
+ // Legacy
+ if ('detail' in event) {
+ sY = event.detail;
+ }
+ if ('wheelDelta' in event) {
+ sY = -event.wheelDelta / 120;
+ }
+ if ('wheelDeltaY' in event) {
+ sY = -event.wheelDeltaY / 120;
+ }
+ if ('wheelDeltaX' in event) {
+ sX = -event.wheelDeltaX / 120;
+ }
+
+ // side scrolling on FF with DOMMouseScroll
+ if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {
+ sX = sY;
+ sY = 0;
+ }
+
+ pX = sX * PIXEL_STEP;
+ pY = sY * PIXEL_STEP;
+
+ if ('deltaY' in event) {
+ pY = event.deltaY;
+ }
+ if ('deltaX' in event) {
+ pX = event.deltaX;
+ }
+
+ if ((pX || pY) && event.deltaMode) {
+ if (event.deltaMode === 1) {
+ // delta in LINE units
+ pX *= LINE_HEIGHT;
+ pY *= LINE_HEIGHT;
+ } else {
+ // delta in PAGE units
+ pX *= PAGE_HEIGHT;
+ pY *= PAGE_HEIGHT;
+ }
+ }
+
+ // Fall-back if spin cannot be determined
+ if (pX && !sX) {
+ sX = pX < 1 ? -1 : 1;
+ }
+ if (pY && !sY) {
+ sY = pY < 1 ? -1 : 1;
+ }
+
+ return {
+ spinX: sX,
+ spinY: sY,
+ pixelX: pX,
+ pixelY: pY
+ };
+ }
+
+ BI.WheelHandler = function (onWheel, handleScrollX, handleScrollY, stopPropagation) {
+ this._animationFrameID = null;
+ this._deltaX = 0;
+ this._deltaY = 0;
+ this._didWheel = BI.bind(this._didWheel, this);
+ if (typeof handleScrollX !== 'function') {
+ handleScrollX = handleScrollX ?
+ function () {
+ return true
+ } :
+ function () {
+ return false
+ };
+ }
+
+ if (typeof handleScrollY !== 'function') {
+ handleScrollY = handleScrollY ?
+ function () {
+ return true
+ } :
+ function () {
+ return false
+ };
+ }
+
+ if (typeof stopPropagation !== 'function') {
+ stopPropagation = stopPropagation ?
+ function () {
+ return true
+ } :
+ function () {
+ return false
+ };
+ }
+
+ this._handleScrollX = handleScrollX;
+ this._handleScrollY = handleScrollY;
+ this._stopPropagation = stopPropagation;
+ this._onWheelCallback = onWheel;
+ this.onWheel = BI.bind(this.onWheel, this);
+ };
+ BI.WheelHandler.prototype = {
+ constructor: BI.WheelHandler,
+ onWheel: function (/*object*/ event) {
+ var normalizedEvent = normalizeWheel(event);
+ var deltaX = this._deltaX + normalizedEvent.pixelX;
+ var deltaY = this._deltaY + normalizedEvent.pixelY;
+ var handleScrollX = this._handleScrollX(deltaX, deltaY);
+ var handleScrollY = this._handleScrollY(deltaY, deltaX);
+ if (!handleScrollX && !handleScrollY) {
+ return;
+ }
+
+ this._deltaX += handleScrollX ? normalizedEvent.pixelX : 0;
+ this._deltaY += handleScrollY ? normalizedEvent.pixelY : 0;
+ event.preventDefault ? event.preventDefault() : (event.returnValue = false);
+
+ var changed;
+ if (this._deltaX !== 0 || this._deltaY !== 0) {
+ if (this._stopPropagation()) {
+ event.stopPropagation ? event.stopPropagation() : (event.cancelBubble = true);
+ }
+ changed = true;
+ }
+
+ if (changed === true && this._animationFrameID === null) {
+ this._animationFrameID = requestAnimationFrame(this._didWheel);
+ }
+ },
+
+ _didWheel: function () {
+ this._animationFrameID = null;
+ this._onWheelCallback(this._deltaX, this._deltaY);
+ this._deltaX = 0;
+ this._deltaY = 0;
+ }
+ };
+})();/**
+ * 常量
+ */
+
+_.extend(BI, {
+ MAX: 0xfffffffffffffff,
+ MIN: -0xfffffffffffffff,
+ EVENT_RESPONSE_TIME: 200,
+ zIndex_layer: 1e5,
+ zIndex_floatbox: 1e6,
+ zIndex_popup: 1e7,
+ zIndex_masker: 1e8,
+ zIndex_tip: 1e9,
+ emptyStr: "",
+ emptyFn: function () {
+ },
+ empty: null,
+ KeyCode: {
+ BACKSPACE: 8,
+ COMMA: 188,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ LEFT: 37,
+ NUMPAD_ADD: 107,
+ NUMPAD_DECIMAL: 110,
+ NUMPAD_DIVIDE: 111,
+ NUMPAD_ENTER: 108,
+ NUMPAD_MULTIPLY: 106,
+ NUMPAD_SUBTRACT: 109,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38
+ },
+ Status: {
+ SUCCESS: 1,
+ WRONG: 2,
+ START: 3,
+ END: 4,
+ WAITING: 5,
+ READY: 6,
+ RUNNING: 7,
+ OUTOFBOUNDS: 8,
+ NULL: -1
+ },
+ Direction: {
+ Top: "top",
+ Bottom: "bottom",
+ Left: "left",
+ Right: "right",
+ Custom: "custom"
+ },
+ Axis: {
+ Vertical: "vertical",
+ Horizontal: "horizontal"
+ },
+ Selection: {
+ Default: -2,
+ None: -1,
+ Single: 0,
+ Multi: 1,
+ All: 2
+ },
+ HorizontalAlign: {
+ Left: "left",
+ Right: "right",
+ Center: "center"
+ },
+ VerticalAlign: {
+ Middle: "middle",
+ Top: "top",
+ Bottom: "bottom"
+ }
+});BI.version = "2.0";/**
+ * absolute实现的居中布局
+ * @class BI.AbsoluteCenterLayout
+ * @extends BI.Layout
+ */
+BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.AbsoluteCenterLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-absolute-center-layout",
+ hgap: 0,
+ lgap: 0,
+ rgap: 0,
+ vgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+
+ render: function () {
+ BI.AbsoluteCenterLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.AbsoluteCenterLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({
+ "position": "absolute",
+ "left": o.hgap + o.lgap + (item.lgap || 0),
+ "right": o.hgap + o.rgap + (item.rgap || 0),
+ "top": o.vgap + o.tgap + (item.tgap || 0),
+ "bottom": o.vgap + o.bgap + (item.bgap || 0),
+ "margin": "auto"
+ });
+ return w;
+ },
+
+ resize: function () {
+ // console.log("absolute_center_adapt布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.AbsoluteCenterLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.absolute_center_adapt', BI.AbsoluteCenterLayout);/**
+ * absolute实现的居中布局
+ * @class BI.AbsoluteHorizontalLayout
+ * @extends BI.Layout
+ */
+BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.AbsoluteHorizontalLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-absolute-horizontal-layout",
+ hgap: 0,
+ lgap: 0,
+ rgap: 0,
+ vgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+
+ render: function () {
+ BI.AbsoluteHorizontalLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.AbsoluteHorizontalLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({
+ "position": "absolute",
+ "left": o.hgap + o.lgap + (item.lgap || 0),
+ "right": o.hgap + o.rgap + (item.rgap || 0),
+ "margin": "auto"
+ });
+ if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
+ w.element.css("top", o.vgap + o.tgap + (item.tgap || 0));
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
+ w.element.css("bottom", o.vgap + o.bgap + (item.bgap || 0));
+ }
+ return w;
+ },
+
+ resize: function () {
+ // console.log("absolute_horizontal_adapt布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.AbsoluteHorizontalLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.absolute_horizontal_adapt', BI.AbsoluteHorizontalLayout);/**
+ * absolute实现的居中布局
+ * @class BI.AbsoluteVerticalLayout
+ * @extends BI.Layout
+ */
+BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.AbsoluteVerticalLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-absolute-vertical-layout",
+ hgap: 0,
+ lgap: 0,
+ rgap: 0,
+ vgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+
+ render: function () {
+ BI.AbsoluteVerticalLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.AbsoluteVerticalLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({
+ "position": "absolute",
+ "left": item.lgap,
+ "right": item.rgap,
+ "top": o.vgap + o.tgap + (item.tgap || 0),
+ "bottom": o.vgap + o.bgap + (item.bgap || 0),
+ "margin": "auto"
+ });
+ if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
+ w.element.css("left", o.hgap + o.lgap + (item.lgap || 0));
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
+ w.element.css("right", o.hgap + o.rgap + (item.rgap || 0));
+ }
+ return w;
+ },
+
+ resize: function () {
+ // console.log("absolute_vertical_adapt布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.AbsoluteVerticalLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.absolute_vertical_adapt', BI.AbsoluteVerticalLayout);/**
+ * 自适应水平和垂直方向都居中容器
+ * @class BI.CenterAdaptLayout
+ * @extends BI.Layout
+ */
+BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.CenterAdaptLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-center-adapt-layout",
+ columnSize: [],
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.CenterAdaptLayout.superclass.render.apply(this, arguments);
+ this.$table = $("").attr({"cellspacing": 0, "cellpadding": 0}).css({
+ "position": "relative",
+ "width": "100%",
+ "height": "100%",
+ "white-space": "nowrap",
+ "border-spacing": "0px",
+ "border": "none",
+ "border-collapse": "separate"
+ });
+ this.$tr = $("");
+ this.$tr.appendTo(this.$table);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var td;
+ var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
+ if (!this.hasWidget(this._getChildName(i))) {
+ var w = BI.createWidget(item);
+ w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"});
+ td = BI.createWidget({
+ type: "bi.default",
+ tagName: "td",
+ attributes: {
+ width: width
+ },
+ items: [w]
+ });
+ this.addWidget(this._getChildName(i), td);
+ } else {
+ td = this.getWidgetByName(this._getChildName(i));
+ td.element.attr("width", width);
+ }
+ td.element.css({"max-width": o.columnSize[i]});
+ if (i === 0) {
+ td.element.addClass("first-element");
+ }
+ td.element.css({
+ "position": "relative",
+ "height": "100%",
+ "vertical-align": "middle",
+ "margin": "0",
+ "padding": "0",
+ "border": "none"
+ });
+ if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return td;
+ },
+
+ _mountChildren: function () {
+ var self = this;
+ var frag = document.createDocumentFragment();
+ var hasChild = false;
+ BI.each(this._children, function (i, widget) {
+ if (widget.element !== self.element) {
+ frag.appendChild(widget.element[0]);
+ hasChild = true;
+ }
+ });
+ if (hasChild === true) {
+ this.$tr.append(frag);
+ this.element.append(this.$table);
+ }
+ },
+
+ resize: function () {
+ // console.log("center_adapt布局不需要resize");
+ },
+
+ _getWrapper: function(){
+ return this.$tr;
+ },
+
+ populate: function (items) {
+ BI.CenterAdaptLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.center_adapt', BI.CenterAdaptLayout);/**
+ * 水平方向居中容器
+ * @class BI.HorizontalAdaptLayout
+ * @extends BI.Layout
+ */
+BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.HorizontalAdaptLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-horizontal-adapt-layout",
+ verticalAlign: BI.VerticalAlign.Middle,
+ columnSize: [],
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
+ this.$table = $("").attr({"cellspacing": 0, "cellpadding": 0}).css({
+ "position": "relative",
+ "width": "100%",
+ "white-space": "nowrap",
+ "border-spacing": "0px",
+ "border": "none",
+ "border-collapse": "separate"
+ });
+ this.$tr = $("");
+ this.$tr.appendTo(this.$table);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var td;
+ var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
+ if (!this.hasWidget(this._getChildName(i))) {
+ var w = BI.createWidget(item);
+ w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"});
+ td = BI.createWidget({
+ type: "bi.default",
+ tagName: "td",
+ attributes: {
+ width: width
+ },
+ items: [w]
+ });
+ this.addWidget(this._getChildName(i), td);
+ } else {
+ td = this.getWidgetByName(this._getChildName(i));
+ td.element.attr("width", width);
+ }
+ td.element.css({"max-width": o.columnSize[i] + "px"});
+ if (i === 0) {
+ td.element.addClass("first-element");
+ }
+ td.element.css({
+ "position": "relative",
+ "vertical-align": o.verticalAlign,
+ "margin": "0",
+ "padding": "0",
+ "border": "none"
+ });
+ if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return td;
+ },
+
+ _mountChildren: function () {
+ var self = this;
+ var frag = document.createDocumentFragment();
+ var hasChild = false;
+ BI.each(this._children, function (i, widget) {
+ if (widget.element !== self.element) {
+ frag.appendChild(widget.element[0]);
+ hasChild = true;
+ }
+ });
+ if (hasChild === true) {
+ this.$tr.append(frag);
+ this.element.append(this.$table);
+ }
+ },
+
+ resize: function () {
+ // console.log("horizontal_adapt布局不需要resize");
+ },
+
+ _getWrapper: function () {
+ return this.$tr;
+ },
+
+ populate: function (items) {
+ BI.HorizontalAdaptLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.horizontal_adapt', BI.HorizontalAdaptLayout);/**
+ * 左右分离,垂直方向居中容器
+ * items:{
+ left: [{el:{type:"bi.button"}}],
+ right:[{el:{type:"bi.button"}}]
+ }
+ * @class BI.LeftRightVerticalAdaptLayout
+ * @extends BI.Layout
+ */
+BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-left-right-vertical-adapt-layout",
+ items: {},
+ llgap: 0,
+ lrgap: 0,
+ lhgap: 0,
+ rlgap: 0,
+ rrgap: 0,
+ rhgap: 0
+ });
+ },
+ render: function () {
+ BI.LeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ // console.log("left_right_vertical_adapt布局不需要resize");
+ },
+
+ addItem: function () {
+ //do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function (items) {
+ var o = this.options;
+ if ("left" in items) {
+ var left = BI.createWidget({
+ type: "bi.vertical_adapt",
+ items: items.left,
+ hgap: o.lhgap,
+ lgap: o.llgap,
+ rgap: o.lrgap
+ });
+ left.element.css("height", "100%");
+ BI.createWidget({
+ type: "bi.left",
+ element: this,
+ items: [left]
+ });
+ }
+ if ("right" in items) {
+ var right = BI.createWidget({
+ type: "bi.vertical_adapt",
+ items: items.right,
+ hgap: o.rhgap,
+ lgap: o.rlgap,
+ rgap: o.rrgap
+ });
+ right.element.css("height", "100%");
+ BI.createWidget({
+ type: "bi.right",
+ element: this,
+ items: [right]
+ });
+ }
+ },
+
+ populate: function (items) {
+ BI.LeftRightVerticalAdaptLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.left_right_vertical_adapt', BI.LeftRightVerticalAdaptLayout);
+
+
+BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-left-vertical-adapt-layout",
+ items: [],
+ lgap: 0,
+ rgap: 0,
+ hgap: 0
+ });
+ },
+ render: function () {
+ BI.LeftVerticalAdaptLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ // console.log("left_vertical_adapt布局不需要resize");
+ },
+
+ addItem: function () {
+ //do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function (items) {
+ var o = this.options;
+ var left = BI.createWidget({
+ type: "bi.vertical_adapt",
+ items: items,
+ lgap: o.lgap,
+ hgap: o.hgap,
+ rgap: o.rgap
+ });
+ left.element.css("height", "100%");
+ BI.createWidget({
+ type: "bi.left",
+ element: this,
+ items: [left]
+ });
+ },
+
+ populate: function (items) {
+ BI.LeftVerticalAdaptLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.left_vertical_adapt', BI.LeftVerticalAdaptLayout);
+
+BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.RightVerticalAdaptLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-right-vertical-adapt-layout",
+ items: [],
+ lgap: 0,
+ rgap: 0,
+ hgap: 0
+ });
+ },
+ render: function () {
+ BI.RightVerticalAdaptLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+
+ },
+
+ addItem: function () {
+ //do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function (items) {
+ var o = this.options;
+ var right = BI.createWidget({
+ type: "bi.vertical_adapt",
+ items: items,
+ lgap: o.lgap,
+ hgap: o.hgap,
+ rgap: o.rgap
+ });
+ right.element.css("height", "100%");
+ BI.createWidget({
+ type: "bi.right",
+ element: this,
+ items: [right]
+ });
+ },
+
+ populate: function (items) {
+ BI.RightVerticalAdaptLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.right_vertical_adapt', BI.RightVerticalAdaptLayout);/**
+ * 垂直方向居中容器
+ * @class BI.VerticalAdaptLayout
+ * @extends BI.Layout
+ */
+BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
+ props: {
+ baseCls: "bi-vertical-adapt-layout",
+ columnSize: [],
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ },
+ render: function () {
+ BI.VerticalAdaptLayout.superclass.render.apply(this, arguments);
+ this.$table = $("").attr({"cellspacing": 0, "cellpadding": 0}).css({
+ "position": "relative",
+ "height": "100%",
+ "white-space": "nowrap",
+ "border-spacing": "0px",
+ "border": "none",
+ "border-collapse": "separate"
+ });
+ this.$tr = $("");
+ this.$tr.appendTo(this.$table);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var td;
+ var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
+ if (!this.hasWidget(this._getChildName(i))) {
+ var w = BI.createWidget(item);
+ w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"});
+ td = BI.createWidget({
+ type: "bi.default",
+ tagName: "td",
+ attributes: {
+ width: width
+ },
+ items: [w]
+ });
+ this.addWidget(this._getChildName(i), td);
+ } else {
+ td = this.getWidgetByName(this._getChildName(i));
+ td.element.attr("width", width);
+ }
+
+ if (i === 0) {
+ td.element.addClass("first-element");
+ }
+ td.element.css({
+ "position": "relative",
+ "height": "100%",
+ "vertical-align": "middle",
+ "margin": "0",
+ "padding": "0",
+ "border": "none"
+ });
+ if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return td;
+ },
+
+ _mountChildren: function () {
+ var self = this;
+ var frag = document.createDocumentFragment();
+ var hasChild = false;
+ BI.each(this._children, function (i, widget) {
+ if (widget.element !== self.element) {
+ frag.appendChild(widget.element[0]);
+ hasChild = true;
+ }
+ });
+ if (hasChild === true) {
+ this.$tr.append(frag);
+ this.element.append(this.$table);
+ }
+ },
+
+ _getWrapper: function(){
+ return this.$tr;
+ },
+
+ resize: function () {
+ // console.log("vertical_adapt布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.VerticalAdaptLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.vertical_adapt', BI.VerticalAdaptLayout);/**
+ * 水平方向居中自适应容器
+ * @class BI.HorizontalAutoLayout
+ * @extends BI.Layout
+ */
+BI.HorizontalAutoLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.HorizontalAutoLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-horizon-auto-layout",
+ hgap: 0,
+ lgap: 0,
+ rgap: 0,
+ vgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+
+ render: function () {
+ BI.HorizontalAutoLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.HorizontalAutoLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({
+ "position": "relative",
+ "margin": "0px auto"
+ });
+ if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return w;
+ },
+
+ resize: function () {
+ // console.log("horizontal_adapt布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.HorizontalAutoLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.horizontal_auto', BI.HorizontalAutoLayout);/**
+ * 浮动的居中布局
+ */
+BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FloatCenterAdaptLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-float-center-adapt-layout",
+ items: [],
+ hgap: 0,
+ vgap: 0,
+ tgap: 0,
+ bgap: 0,
+ lgap: 0,
+ rgap: 0
+ });
+ },
+ render: function () {
+ BI.FloatCenterAdaptLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ // console.log("float_center_adapt布局不需要resize");
+ },
+
+ addItem: function () {
+ //do nothing
+ throw new Error("cannot be added")
+ },
+
+ mounted: function () {
+ var width = this.left.element.outerWidth(),
+ height = this.left.element.outerHeight();
+ this.left.element.width(width).height(height).css("float", "none");
+ BI.createWidget({
+ type: "bi.center_adapt",
+ element: this,
+ items: [this.left]
+ });
+ this.removeWidget(this.container);
+ },
+
+ stroke: function (items) {
+ var self = this, o = this.options;
+ this.left = BI.createWidget({
+ type: "bi.vertical",
+ items: items,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ lgap: o.lgap,
+ rgap: o.rgap
+ });
+
+ this.container = BI.createWidget({
+ type: "bi.left",
+ element: this,
+ items: [this.left]
+ });
+
+ },
+
+ populate: function (items) {
+ BI.FloatCenterAdaptLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.float_center_adapt', BI.FloatCenterAdaptLayout);/**
+ * 浮动的水平居中布局
+ */
+BI.FloatHorizontalLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FloatHorizontalLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-float-horizontal-adapt-layout",
+ items: [],
+ hgap: 0,
+ vgap: 0,
+ tgap: 0,
+ bgap: 0,
+ lgap: 0,
+ rgap: 0
+ });
+ },
+ render: function () {
+ BI.FloatHorizontalLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ // console.log("float_horizontal_adapt布局不需要resize");
+ },
+
+ mounted: function () {
+ var width = this.left.element.width(),
+ height = this.left.element.height();
+ this.left.element.width(width).height(height).css("float", "none");
+ BI.createWidget({
+ type: "bi.horizontal_auto",
+ element: this,
+ items: [this.left]
+ });
+ this.removeWidget(this.container);
+ },
+
+ _addElement: function (i, item) {
+ var self = this, o = this.options;
+ this.left = BI.createWidget({
+ type: "bi.vertical",
+ items: [item],
+ hgap: o.hgap,
+ vgap: o.vgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ lgap: o.lgap,
+ rgap: o.rgap
+ });
+
+ this.container = BI.createWidget({
+ type: "bi.left",
+ element: this,
+ items: [this.left]
+ });
+
+ return this.left;
+ },
+
+ populate: function (items) {
+ BI.HorizontalAutoLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.horizontal_float', BI.FloatHorizontalLayout);/**
+ *自适应水平和垂直方向都居中容器
+ * Created by GUY on 2016/12/2.
+ *
+ * @class BI.FlexCenterLayout
+ * @extends BI.Layout
+ */
+BI.FlexCenterLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FlexCenterLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-flex-center-layout"
+ });
+ },
+ render: function () {
+ BI.FlexCenterLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.FlexCenterLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({"position": "relative", "flex-shrink": "0"});
+ return w;
+ },
+
+ resize: function () {
+ // console.log("flex_center布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.FlexCenterLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.flex_center', BI.FlexCenterLayout);/**
+ *自适应水平和垂直方向都居中容器
+ * Created by GUY on 2016/12/2.
+ *
+ * @class BI.FlexHorizontalLayout
+ * @extends BI.Layout
+ */
+BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FlexHorizontalLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-flex-horizontal-layout",
+ verticalAlign: "middle",
+ columnSize: [],
+ scrollx: true,
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.FlexHorizontalLayout.superclass.render.apply(this, arguments);
+ var o = this.options;
+ this.element.addClass(o.verticalAlign);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.FlexHorizontalLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({"position": "relative", "flex-shrink": "0"});
+ if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return w;
+ },
+
+ resize: function () {
+ // console.log("flex_horizontal布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.FlexHorizontalLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.flex_horizontal', BI.FlexHorizontalLayout);/**
+ *自适应水平和垂直方向都居中容器
+ * Created by GUY on 2016/12/2.
+ *
+ * @class BI.FlexVerticalCenter
+ * @extends BI.Layout
+ */
+BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FlexVerticalCenter.superclass.props.apply(this, arguments), {
+ baseCls: "bi-flex-vertical-center",
+ columnSize: [],
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.FlexVerticalCenter.superclass.render.apply(this, arguments);
+ var o = this.options;
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.FlexVerticalCenter.superclass._addElement.apply(this, arguments);
+ w.element.css({"position": "relative", "flex-shrink": "0"});
+ if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return w;
+ },
+
+ resize: function () {
+ // console.log("flex_vertical_center布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.FlexVerticalCenter.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.flex_vertical_center', BI.FlexVerticalCenter);/**
+ *自适应水平和垂直方向都居中容器
+ * Created by GUY on 2016/12/2.
+ *
+ * @class BI.FlexCenterLayout
+ * @extends BI.Layout
+ */
+BI.FlexCenterLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FlexCenterLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-flex-wrapper-center-layout clearfix"
+ });
+ },
+ render: function () {
+ BI.FlexCenterLayout.superclass.render.apply(this, arguments);
+ this.$wrapper = $("").addClass("flex-wrapper-center-layout-wrapper");
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.FlexCenterLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({"position": "relative"});
+ return w;
+ },
+
+ _mountChildren: function () {
+ var self = this;
+ var frag = document.createDocumentFragment();
+ var hasChild = false;
+ BI.each(this._children, function (i, widget) {
+ if (widget.element !== self.element) {
+ frag.appendChild(widget.element[0]);
+ hasChild = true;
+ }
+ });
+ if (hasChild === true) {
+ this.$wrapper.append(frag);
+ this.element.append(this.$wrapper);
+ }
+ },
+
+ _getWrapper: function(){
+ return this.$wrapper;
+ },
+
+ resize: function () {
+ // console.log("flex_center布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.FlexCenterLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.flex_wrapper_center', BI.FlexCenterLayout);/**
+ *自适应水平和垂直方向都居中容器
+ * Created by GUY on 2016/12/2.
+ *
+ * @class BI.FlexHorizontalLayout
+ * @extends BI.Layout
+ */
+BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FlexHorizontalLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-flex-wrapper-horizontal-layout clearfix",
+ verticalAlign: "middle",
+ columnSize: [],
+ scrollx: true,
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.FlexHorizontalLayout.superclass.render.apply(this, arguments);
+ var o = this.options;
+ this.$wrapper = $("
").addClass("flex-wrapper-horizontal-layout-wrapper " + o.verticalAlign);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.FlexHorizontalLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({"position": "relative"});
+ if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return w;
+ },
+
+ _mountChildren: function () {
+ var self = this;
+ var frag = document.createDocumentFragment();
+ var hasChild = false;
+ BI.each(this._children, function (i, widget) {
+ if (widget.element !== self.element) {
+ frag.appendChild(widget.element[0]);
+ hasChild = true;
+ }
+ });
+ if (hasChild === true) {
+ this.$wrapper.append(frag);
+ this.element.append(this.$wrapper);
+ }
+ },
+
+ _getWrapper: function(){
+ return this.$wrapper;
+ },
+
+ resize: function () {
+ // console.log("flex_horizontal布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.FlexHorizontalLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.flex_wrapper_horizontal', BI.FlexHorizontalLayout);/**
+ *自适应水平和垂直方向都居中容器
+ * Created by GUY on 2016/12/2.
+ *
+ * @class BI.FlexVerticalCenter
+ * @extends BI.Layout
+ */
+BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FlexVerticalCenter.superclass.props.apply(this, arguments), {
+ baseCls: "bi-flex-wrapper-vertical-center clearfix",
+ columnSize: [],
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.FlexVerticalCenter.superclass.render.apply(this, arguments);
+ var o = this.options;
+ this.$wrapper = $("
").addClass("flex-wrapper-vertical-center-wrapper");
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.FlexVerticalCenter.superclass._addElement.apply(this, arguments);
+ w.element.css({"position": "relative"});
+ if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return w;
+ },
+
+ _mountChildren: function () {
+ var self = this;
+ var frag = document.createDocumentFragment();
+ var hasChild = false;
+ BI.each(this._children, function (i, widget) {
+ if (widget.element !== self.element) {
+ frag.appendChild(widget.element[0]);
+ hasChild = true;
+ }
+ });
+ if (hasChild === true) {
+ this.$wrapper.append(frag);
+ this.element.append(this.$wrapper);
+ }
+ },
+
+ _getWrapper: function(){
+ return this.$wrapper;
+ },
+
+ resize: function () {
+ // console.log("flex_vertical_center布局不需要resize");
+ },
+
+ populate: function (items) {
+ BI.FlexVerticalCenter.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.flex_wrapper_vertical_center', BI.FlexVerticalCenter);/**
+ * 固定子组件上下左右的布局容器
+ * @class BI.AbsoluteLayout
+ * @extends BI.Layout
+ */
+BI.AbsoluteLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.AbsoluteLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-absolute-layout",
+ hgap: null,
+ vgap: null,
+ lgap: null,
+ rgap: null,
+ tgap: null,
+ bgap: null
+ });
+ },
+ render: function () {
+ BI.AbsoluteLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.AbsoluteLayout.superclass._addElement.apply(this, arguments);
+ var left = 0, right = 0, top = 0, bottom = 0;
+ if (BI.isNotNull(item.left)) {
+ w.element.css({"left": item.left});
+ left += item.left;
+ }
+ if (BI.isNotNull(item.right)) {
+ w.element.css({"right": item.right});
+ right += item.right;
+ }
+ if (BI.isNotNull(item.top)) {
+ w.element.css({"top": item.top});
+ top += item.top;
+ }
+ if (BI.isNotNull(item.bottom)) {
+ w.element.css({"bottom": item.bottom});
+ bottom += item.bottom;
+ }
+
+ if (BI.isNotNull(o.hgap)) {
+ left += o.hgap;
+ w.element.css({"left": left});
+ right += o.hgap;
+ w.element.css({"right": right});
+ }
+ if (BI.isNotNull(o.vgap)) {
+ top += o.vgap;
+ w.element.css({"top": top});
+ bottom += o.vgap;
+ w.element.css({"bottom": bottom});
+ }
+
+ if (BI.isNotNull(o.lgap)) {
+ left += o.lgap;
+ w.element.css({"left": left});
+ }
+ if (BI.isNotNull(o.rgap)) {
+ right += o.rgap;
+ w.element.css({"right": right});
+ }
+ if (BI.isNotNull(o.tgap)) {
+ top += o.tgap;
+ w.element.css({"top": top});
+ }
+ if (BI.isNotNull(o.bgap)) {
+ bottom += o.bgap;
+ w.element.css({"bottom": bottom});
+ }
+
+
+ if (BI.isNotNull(item.width)) {
+ w.element.css({"width": item.width});
+ }
+ if (BI.isNotNull(item.height)) {
+ w.element.css({"height": item.height});
+ }
+ w.element.css({"position": "absolute"});
+ return w;
+ },
+
+ resize: function () {
+ this.stroke(this.options.items);
+ },
+
+ stroke: function (items) {
+ this.options.items = items || [];
+ var self = this;
+ BI.each(items, function (i, item) {
+ if (!!item) {
+ if (!BI.isWidget(item) && !item.el) {
+ throw new Error("el must be exist");
+ }
+ self._addElement(i, item);
+ }
+ });
+ },
+
+ populate: function (items) {
+ BI.AbsoluteLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.absolute', BI.AbsoluteLayout);BI.AdaptiveLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.AdaptiveLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-adaptive-layout",
+ hgap: null,
+ vgap: null,
+ lgap: null,
+ rgap: null,
+ tgap: null,
+ bgap: null
+ });
+ },
+ render: function () {
+ BI.AdaptiveLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.AdaptiveLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({"position": "relative"});
+ var left = 0, right = 0, top = 0, bottom = 0;
+ if (BI.isNotNull(item.left)) {
+ w.element.css({
+ "margin-left": item.left
+ })
+ }
+ if (BI.isNotNull(item.right)) {
+ w.element.css({
+ "margin-right": item.right
+ })
+ }
+ if (BI.isNotNull(item.top)) {
+ w.element.css({
+ "margin-top": item.top
+ })
+ }
+ if (BI.isNotNull(item.bottom)) {
+ w.element.css({
+ "margin-bottom": item.bottom
+ })
+ }
+
+ if (BI.isNotNull(o.hgap)) {
+ left += o.hgap;
+ w.element.css({"left": left});
+ right += o.hgap;
+ w.element.css({"right": right});
+ }
+ if (BI.isNotNull(o.vgap)) {
+ top += o.vgap;
+ w.element.css({"top": top});
+ bottom += o.vgap;
+ w.element.css({"bottom": bottom});
+ }
+
+ if (BI.isNotNull(o.lgap)) {
+ left += o.lgap;
+ w.element.css({"left": left});
+ }
+ if (BI.isNotNull(o.rgap)) {
+ right += o.rgap;
+ w.element.css({"right": right});
+ }
+ if (BI.isNotNull(o.tgap)) {
+ top += o.tgap;
+ w.element.css({"top": top});
+ }
+ if (BI.isNotNull(o.bgap)) {
+ bottom += o.bgap;
+ w.element.css({"bottom": bottom});
+ }
+
+ if (BI.isNotNull(item.width)) {
+ w.element.css({"width": item.width});
+ }
+ if (BI.isNotNull(item.height)) {
+ w.element.css({"height": item.height});
+ }
+ return w;
+ },
+
+ resize: function () {
+ this.stroke(this.options.items);
+ },
+
+ populate: function (items) {
+ BI.AbsoluteLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.adaptive', BI.AdaptiveLayout);/**
+ * 上下的高度固定/左右的宽度固定,中间的高度/宽度自适应
+ *
+ * @class BI.BorderLayout
+ * @extends BI.Layout
+ */
+BI.BorderLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.BorderLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-border-layout",
+ items: {}
+ });
+ },
+ render: function () {
+ BI.BorderLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ this.stroke(this.options.items);
+ },
+
+ addItem: function (item) {
+ // do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function(regions){
+ var item;
+ var top = 0;
+ var bottom = 0;
+ var left = 0;
+ var right = 0;
+ if ("north" in regions) {
+ item = regions["north"];
+ if (item != null) {
+ if (item.el) {
+ if (!this.hasWidget(this.getName() + "north")) {
+ var w = BI.createWidget(item);
+ this.addWidget(this.getName() + "north", w);
+ }
+ this.getWidgetByName(this.getName() + "north").element.height(item.height)
+ .css({
+ "position": "absolute",
+ "top": (item.top || 0),
+ "left": (item.left || 0),
+ "right": (item.right || 0),
+ "bottom": "initial"
+ });
+ }
+ top = (item.height || 0) + (item.top || 0) + (item.bottom || 0);
+ }
+ }
+ if ("south" in regions) {
+ item = regions["south"];
+ if (item != null) {
+ if (item.el) {
+ if (!this.hasWidget(this.getName() + "south")) {
+ var w = BI.createWidget(item);
+ this.addWidget(this.getName() + "south", w);
+ }
+ this.getWidgetByName(this.getName() + "south").element.height(item.height)
+ .css({
+ "position": "absolute",
+ "bottom": (item.bottom || 0),
+ "left": (item.left || 0),
+ "right": (item.right || 0),
+ "top": "initial"
+ });
+ }
+ bottom = (item.height || 0) + (item.top || 0) + (item.bottom || 0);
+ }
+ }
+ if ("west" in regions) {
+ item = regions["west"];
+ if (item != null) {
+ if (item.el) {
+ if (!this.hasWidget(this.getName() + "west")) {
+ var w = BI.createWidget(item);
+ this.addWidget(this.getName() + "west", w);
+ }
+ this.getWidgetByName(this.getName() + "west").element.width(item.width)
+ .css({
+ "position": "absolute",
+ "left": (item.left || 0),
+ top: top,
+ bottom: bottom,
+ "right": "initial"
+ });
+ }
+ left = (item.width || 0) + (item.left || 0) + (item.right || 0);
+ }
+ }
+ if ("east" in regions) {
+ item = regions["east"];
+ if (item != null) {
+ if (item.el) {
+ if (!this.hasWidget(this.getName() + "east")) {
+ var w = BI.createWidget(item);
+ this.addWidget(this.getName() + "east", w);
+ }
+ this.getWidgetByName(this.getName() + "east").element.width(item.width)
+ .css({
+ "position": "absolute",
+ "right": (item.right || 0),
+ top: top,
+ bottom: bottom,
+ "left": "initial"
+ });
+ }
+ right = (item.width || 0) + (item.left || 0) + (item.right || 0);
+ }
+ }
+ if ("center" in regions) {
+ item = regions["center"];
+ if (item != null) {
+ if (!this.hasWidget(this.getName() + "center")) {
+ var w = BI.createWidget(item);
+ this.addWidget(this.getName() + "center", w);
+ }
+ this.getWidgetByName(this.getName() + "center").element
+ .css({"position": "absolute", "top": top, "bottom": bottom, "left": left, "right": right});
+ }
+ }
+ },
+
+ populate: function (items) {
+ BI.BorderLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.border', BI.BorderLayout);/**
+ * 卡片布局,可以做到当前只显示一个组件,其他的都隐藏
+ * @class BI.CardLayout
+ * @extends BI.Layout
+ *
+ * @cfg {JSON} options 配置属性
+ * @cfg {String} options.defaultShowName 默认展示的子组件名
+ */
+BI.CardLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.CardLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-card-layout",
+ items: []
+ });
+ },
+ render: function () {
+ BI.CardLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ // console.log("default布局不需要resize");
+ },
+
+ stroke: function (items) {
+ var self = this, o = this.options;
+ this.showIndex = void 0;
+ BI.each(items, function (i, item) {
+ if (!!item) {
+ if (!self.hasWidget(item.cardName)) {
+ var w = BI.createWidget(item);
+ w.on(BI.Events.DESTROY, function () {
+ var index = BI.findIndex(o.items, function (i, tItem) {
+ return tItem.cardName == item.cardName;
+ });
+ if (index > -1) {
+ o.items.splice(index, 1);
+ }
+ });
+ self.addWidget(item.cardName, w);
+ } else {
+ var w = self.getWidgetByName(item.cardName);
+ }
+ w.element.css({"position": "absolute", "top": "0", "right": "0", "bottom": "0", "left": "0"});
+ w.setVisible(false);
+ }
+ });
+ },
+
+ update: function () {
+ },
+
+ empty: function () {
+ BI.CardLayout.superclass.empty.apply(this, arguments);
+ this.options.items = [];
+ },
+
+ populate: function (items) {
+ BI.CardLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ this.options.defaultShowName && this.showCardByName(this.options.defaultShowName);
+ },
+
+ isCardExisted: function (cardName) {
+ return BI.some(this.options.items, function (i, item) {
+ return item.cardName == cardName && item.el;
+ });
+ },
+
+ getCardByName: function (cardName) {
+ if (!this.isCardExisted(cardName)) {
+ throw new Error("cardName is not exist");
+ }
+ return this._children[cardName];
+ },
+
+ _deleteCardByName: function (cardName) {
+ delete this._children[cardName];
+ var index = BI.findIndex(this.options.items, function (i, item) {
+ return item.cardName == cardName;
+ });
+ if (index > -1) {
+ this.options.items.splice(index, 1);
+ }
+ },
+
+ deleteCardByName: function (cardName) {
+ if (!this.isCardExisted(cardName)) {
+ throw new Error("cardName is not exist");
+ }
+
+ var child = this._children[cardName];
+ this._deleteCardByName(cardName);
+ child && child._destroy();
+ },
+
+ addCardByName: function (cardName, cardItem) {
+ if (this.isCardExisted(cardName)) {
+ throw new Error("cardName is already exist");
+ }
+ var widget = BI.createWidget(cardItem);
+ widget.element.css({
+ "position": "relative",
+ "top": "0",
+ "left": "0",
+ "width": "100%",
+ "height": "100%"
+ }).appendTo(this.element);
+ widget.invisible();
+ this.addWidget(cardName, widget);
+ this.options.items.push({el: cardItem, cardName: cardName});
+ return widget;
+ },
+
+ showCardByName: function (name, action, callback) {
+ var self = this;
+ //name不存在的时候全部隐藏
+ var exist = this.isCardExisted(name);
+ if (this.showIndex != null) {
+ this.lastShowIndex = this.showIndex;
+ }
+ this.showIndex = name;
+ var flag = false;
+ BI.each(this.options.items, function (i, item) {
+ var el = self._children[item.cardName];
+ if (el) {
+ if (name != item.cardName) {
+ //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了
+ !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible();
+ } else {
+ (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback())
+ }
+ }
+ });
+ },
+
+ showLastCard: function () {
+ var self = this;
+ this.showIndex = this.lastShowIndex;
+ BI.each(this.options.items, function (i, item) {
+ self._children[item.cardName].setVisible(self.showIndex == i);
+ })
+ },
+
+ setDefaultShowName: function (name) {
+ this.options.defaultShowName = name;
+ return this;
+ },
+
+ getDefaultShowName: function () {
+ return this.options.defaultShowName;
+ },
+
+ getAllCardNames: function () {
+ return BI.map(this.options.items, function (i, item) {
+ return item.cardName;
+ })
+ },
+
+ getShowingCard: function () {
+ if (!BI.isKey(this.showIndex)) {
+ return void 0;
+ }
+ return this.getWidgetByName(this.showIndex);
+ },
+
+ deleteAllCard: function () {
+ var self = this;
+ BI.each(this.getAllCardNames(), function (i, name) {
+ self.deleteCardByName(name);
+ })
+ },
+
+ hideAllCard: function () {
+ var self = this;
+ BI.each(this.options.items, function (i, item) {
+ self._children[item.cardName].invisible();
+ });
+ },
+
+ isAllCardHide: function () {
+ var self = this;
+ var flag = true;
+ BI.some(this.options.items, function (i, item) {
+ if (self._children[item.cardName].isVisible()) {
+ flag = false;
+ return false;
+ }
+ });
+ return flag;
+ },
+
+ removeWidget: function (nameOrWidget) {
+ var removeName;
+ if (BI.isWidget(nameOrWidget)) {
+ BI.each(this._children, function (name, child) {
+ if (child === nameOrWidget) {
+ removeName = name;
+ }
+ })
+ } else {
+ removeName = nameOrWidget;
+ }
+ if (removeName) {
+ this._deleteCardByName(removeName);
+ }
+ }
+});
+BI.shortcut('bi.card', BI.CardLayout);/**
+ * 默认的布局方式
+ *
+ * @class BI.DefaultLayout
+ * @extends BI.Layout
+ */
+BI.DefaultLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.DefaultLayout.superclass.props.apply(this, arguments), {
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ items: []
+ });
+ },
+ render: function () {
+ BI.DefaultLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.DefaultLayout.superclass._addElement.apply(this, arguments);
+ if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return w;
+ },
+
+ resize: function () {
+ // console.log("default布局不需要resize")
+ },
+
+ populate: function (items) {
+ BI.DefaultLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.default', BI.DefaultLayout);/**
+ * 分隔容器的控件,按照宽度和高度所占比平分整个容器
+ *
+ * @class BI.DivisionLayout
+ * @extends BI.Layout
+ */
+BI.DivisionLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.DivisionLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-division-layout",
+ columns: null,
+ rows: null,
+ items: []
+ // [
+ // {
+ // column: 0,
+ // row: 0,
+ // width: 0.25,
+ // height: 0.33,
+ // el: {type: 'bi.button', text: 'button1'}
+ // },
+ // {
+ // column: 1,
+ // row: 1,
+ // width: 0.25,
+ // height: 0.33,
+ // el: {type: 'bi.button', text: 'button2'}
+ // },
+ // {
+ // column: 3,
+ // row: 2,
+ // width: 0.25,
+ // height: 0.33,
+ // el: {type: 'bi.button', text: 'button3'}
+ // }
+ //]
+ });
+ },
+ render: function () {
+ BI.DivisionLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ this.stroke(this.opitons.items);
+ },
+
+ addItem: function (item) {
+ // do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function(items){
+ var o = this.options;
+ var rows = o.rows || o.items.length, columns = o.columns || ((o.items[0] && o.items[0].length) | 0);
+ var map = BI.makeArray(rows), widths = {}, heights = {};
+ function firstElement(item, row, col) {
+ if (row === 0) {
+ item.addClass("first-row")
+ }
+ if (col === 0) {
+ item.addClass("first-col");
+ }
+ item.addClass(BI.isOdd(row + 1) ? "odd-row" : "even-row");
+ item.addClass(BI.isOdd(col + 1) ? "odd-col" : "even-col");
+ item.addClass("center-element");
+ }
+
+ function firstObject(item, row, col) {
+ var cls = "";
+ if (row === 0) {
+ cls += " first-row";
+ }
+ if (col === 0) {
+ cls += " first-col";
+ }
+ BI.isOdd(row + 1) ? (cls += " odd-row") : (cls += " even-row");
+ BI.isOdd(col + 1) ? (cls += " odd-col") : (cls += " even-col");
+ item.cls = (item.cls || "") + cls + " center-element";
+ }
+
+ function first(item, row, col) {
+ if (item instanceof BI.Widget) {
+ firstElement(item.element, row, col);
+ } else if (item.el instanceof BI.Widget) {
+ firstElement(item.el.element, row, col);
+ } else if (item.el) {
+ firstObject(item.el, row, col)
+ } else {
+ firstObject(item, row, col);
+ }
+ }
+ BI.each(map, function (i) {
+ map[i] = BI.makeArray(columns);
+ });
+ BI.each(items, function (i, item) {
+ if (BI.isArray(item)) {
+ BI.each(item, function (j, el) {
+ widths[i] = (widths[i] || 0) + item.width;
+ heights[j] = (heights[j] || 0) + item.height;
+ map[i][j] = el;
+ });
+ return;
+ }
+ widths[item.row] = (widths[item.row] || 0) + item.width;
+ heights[item.column] = (heights[item.column] || 0) + item.height;
+ map[item.row][item.column] = item;
+ });
+ for (var i = 0; i < rows; i++) {
+ var totalW = 0;
+ for (var j = 0; j < columns; j++) {
+ if (!map[i][j]) {
+ throw new Error("item be required");
+ }
+ if(!this.hasWidget(this.getName() + i + "_" + j)) {
+ var w = BI.createWidget(map[i][j]);
+ this.addWidget(this.getName() + i + "_" + j, w);
+ } else {
+ w = this.getWidgetByName(this.getName() + i + "_" + j);
+ }
+ var left = totalW * 100 / widths[i];
+ w.element.css({"position": "absolute", "left": left + "%"});
+ if (j > 0) {
+ var lastW = this.getWidgetByName(this.getName() + i + "_" + (j - 1));
+ lastW.element.css({"right": (100 - left) + "%"});
+ }
+ if (j == o.columns - 1) {
+ w.element.css({"right": "0%"});
+ }
+ first(w, i, j);
+ totalW += map[i][j].width;
+ }
+ }
+ for (var j = 0; j < o.columns; j++) {
+ var totalH = 0;
+ for (var i = 0; i < o.rows; i++) {
+ var w = this.getWidgetByName(this.getName() + i + "_" + j);
+ var top = totalH * 100 / heights[j];
+ w.element.css({"top": top + "%"});
+ if (i > 0) {
+ var lastW = this.getWidgetByName(this.getName() + (i - 1) + "_" + j);
+ lastW.element.css({"bottom": (100 - top) + "%"});
+ }
+ if (i == o.rows - 1) {
+ w.element.css({"bottom": "0%"});
+ }
+ totalH += map[i][j].height;
+ }
+ }
+ },
+
+ populate: function (items) {
+ BI.DivisionLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.division', BI.DivisionLayout);/**
+ * 靠左对齐的自由浮动布局
+ * @class BI.FloatLeftLayout
+ * @extends BI.Layout
+ *
+ * @cfg {JSON} options 配置属性
+ * @cfg {Number} [hgap=0] 水平间隙
+ * @cfg {Number} [vgap=0] 垂直间隙
+ */
+BI.FloatLeftLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FloatLeftLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-float-left-layout clearfix",
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.FloatLeftLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.FloatLeftLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({"position": "relative", "float": "left"});
+ if (BI.isNotNull(item.left)) {
+ w.element.css({"left": item.left});
+ }
+ if (BI.isNotNull(item.right)) {
+ w.element.css({"right": item.right});
+ }
+ if (BI.isNotNull(item.top)) {
+ w.element.css({"top": item.top});
+ }
+ if ((item.lgap || 0) + o.hgap + o.lgap !== 0) {
+ w.element.css("margin-left", (item.lgap || 0) + o.hgap + o.lgap);
+ }
+ if ((item.rgap || 0) + o.hgap + o.rgap !== 0) {
+ w.element.css("margin-right", (item.rgap || 0) + o.hgap + o.rgap);
+ }
+ if ((item.tgap || 0) + o.vgap + o.tgap !== 0) {
+ w.element.css("margin-top", (item.tgap || 0) + o.vgap + o.tgap);
+ }
+ if ((item.bgap || 0) + o.vgap + o.bgap !== 0) {
+ w.element.css("margin-bottom", (item.bgap || 0) + o.vgap + o.bgap);
+ }
+ return w;
+ },
+
+ resize: function () {
+ this.stroke(this.options.items);
+ },
+
+ populate: function (items) {
+ BI.FloatLeftLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.left', BI.FloatLeftLayout);
+
+/**
+ * 靠右对齐的自由浮动布局
+ * @class BI.FloatRightLayout
+ * @extends BI.Layout
+ *
+ * @cfg {JSON} options 配置属性
+ * @cfg {Number} [hgap=0] 水平间隙
+ * @cfg {Number} [vgap=0] 垂直间隙
+ */
+BI.FloatRightLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FloatRightLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-float-right-layout clearfix",
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.FloatRightLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.FloatRightLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({"position": "relative", "float": "right"});
+ if (BI.isNotNull(item.left)) {
+ w.element.css({"left": item.left});
+ }
+ if (BI.isNotNull(item.right)) {
+ w.element.css({"right": item.right});
+ }
+ if (BI.isNotNull(item.top)) {
+ w.element.css({"top": item.top});
+ }
+ if ((item.lgap || 0) + o.hgap + o.lgap !== 0) {
+ w.element.css("margin-left", (item.lgap || 0) + o.hgap + o.lgap);
+ }
+ if ((item.rgap || 0) + o.hgap + o.rgap !== 0) {
+ w.element.css("margin-right", (item.rgap || 0) + o.hgap + o.rgap);
+ }
+ if ((item.tgap || 0) + o.vgap + o.tgap !== 0) {
+ w.element.css("margin-top", (item.tgap || 0) + o.vgap + o.tgap);
+ }
+ if ((item.bgap || 0) + o.vgap + o.bgap !== 0) {
+ w.element.css("margin-bottom", (item.bgap || 0) + o.vgap + o.bgap);
+ }
+ return w;
+ },
+
+ resize: function () {
+ this.stroke(this.options.items);
+ },
+
+ populate: function (items) {
+ BI.FloatRightLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.right', BI.FloatRightLayout);/**
+ * 上下的高度固定/左右的宽度固定,中间的高度/宽度自适应
+ *
+ * @class BI.BorderLayout
+ * @extends BI.Layout
+ */
+BI.GridLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.GridLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-grid-layout",
+ columns: null,
+ rows: null,
+ items: []
+ /*[
+ {
+ column: 0,
+ row: 0,
+ el: {type: 'bi.button', text: 'button1'}
+ },
+ {
+ column: 1,
+ row: 1,
+ el: {type: 'bi.button', text: 'button2'}
+ },
+ {
+ column: 3,
+ row: 2,
+ el: {type: 'bi.button', text: 'button3'}
+ }
+ ]*/
+ });
+ },
+ render: function () {
+ BI.GridLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ // console.log("grid布局不需要resize")
+ },
+
+ addItem: function () {
+ //do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function (items) {
+ var o = this.options;
+ var rows = o.rows || o.items.length, columns = o.columns || ((o.items[0] && o.items[0].length) | 0);
+ var width = 100 / columns, height = 100 / rows;
+ var els = [];
+ for (var i = 0; i < rows; i++) {
+ els[i] = [];
+ }
+ function firstElement(item, row, col) {
+ if (row === 0) {
+ item.addClass("first-row")
+ }
+ if (col === 0) {
+ item.addClass("first-col");
+ }
+ item.addClass(BI.isOdd(row + 1) ? "odd-row" : "even-row");
+ item.addClass(BI.isOdd(col + 1) ? "odd-col" : "even-col");
+ item.addClass("center-element");
+ }
+
+ function firstObject(item, row, col) {
+ var cls = "";
+ if (row === 0) {
+ cls += " first-row";
+ }
+ if (col === 0) {
+ cls += " first-col";
+ }
+ BI.isOdd(row + 1) ? (cls += " odd-row") : (cls += " even-row");
+ BI.isOdd(col + 1) ? (cls += " odd-col") : (cls += " even-col");
+ item.cls = (item.cls || "") + cls + " center-element";
+ }
+
+ function first(item, row, col) {
+ if (item instanceof BI.Widget) {
+ firstElement(item.element, row, col);
+ } else if (item.el instanceof BI.Widget) {
+ firstElement(item.el.element, row, col);
+ } else if (item.el) {
+ firstObject(item.el, row, col)
+ } else {
+ firstObject(item, row, col);
+ }
+ }
+
+ BI.each(items, function (i, item) {
+ if (BI.isArray(item)) {
+ BI.each(item, function (j, el) {
+ els[i][j] = BI.createWidget(el);
+ });
+ return;
+ }
+ els[item.row][item.column] = BI.createWidget(item);
+ });
+ for (var i = 0; i < rows; i++) {
+ for (var j = 0; j < columns; j++) {
+ if (!els[i][j]) {
+ els[i][j] = BI.createWidget({
+ type: "bi.layout"
+ });
+ }
+ first(els[i][j], i, j);
+ els[i][j].element.css({
+ "position": "absolute",
+ "top": height * i + "%",
+ "left": width * j + "%",
+ "right": (100 - (width * (j + 1))) + "%",
+ "bottom": (100 - (height * (i + 1))) + "%"
+ });
+ this.addWidget(els[i][j]);
+ }
+ }
+ },
+
+ populate: function (items) {
+ BI.GridLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.grid', BI.GridLayout);/**
+ * 水平布局
+ * @class BI.HorizontalLayout
+ * @extends BI.Layout
+ */
+BI.HorizontalLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.HorizontalLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-horizontal-layout",
+ verticalAlign: "middle",
+ columnSize: [],
+ scrollx: true,
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.HorizontalLayout.superclass.render.apply(this, arguments);
+ this.$table = $("
").attr({"cellspacing": 0, "cellpadding": 0}).css({
+ "position": "relative",
+ "white-space": "nowrap",
+ "border-spacing": "0px",
+ "border": "none",
+ "border-collapse": "separate"
+ });
+ this.$tr = $("");
+ this.$tr.appendTo(this.$table);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var td;
+ var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
+ if (!this.hasWidget(this._getChildName(i))) {
+ var w = BI.createWidget(item);
+ w.element.css({"position": "relative", "margin": "0px auto"});
+ td = BI.createWidget({
+ type: "bi.default",
+ tagName: "td",
+ attributes: {
+ width: width
+ },
+ items: [w]
+ });
+ this.addWidget(this._getChildName(i), td);
+ } else {
+ td = this.getWidgetByName(this._getChildName(i));
+ td.element.attr("width", width);
+ }
+
+ if (i === 0) {
+ td.element.addClass("first-element");
+ }
+ td.element.css({
+ "position": "relative",
+ "vertical-align": o.verticalAlign,
+ "margin": "0",
+ "padding": "0",
+ "border": "none"
+ });
+ if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return td;
+ },
+
+ _mountChildren: function () {
+ var self = this;
+ var frag = document.createDocumentFragment();
+ var hasChild = false;
+ BI.each(this._children, function (i, widget) {
+ if (widget.element !== self.element) {
+ frag.appendChild(widget.element[0]);
+ hasChild = true;
+ }
+ });
+ if (hasChild === true) {
+ this.$tr.append(frag);
+ this.element.append(this.$table);
+ }
+ },
+
+
+ resize: function () {
+ // console.log("horizontal layout do not need to resize");
+ },
+
+ _getWrapper: function(){
+ return this.$tr;
+ },
+
+ populate: function (items) {
+ BI.HorizontalLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.horizontal', BI.HorizontalLayout);
+
+/**
+ * 水平布局
+ * @class BI.HorizontalCellLayout
+ * @extends BI.Layout
+ */
+BI.HorizontalCellLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.HorizontalCellLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-horizontal-cell-layout",
+ scrollable: true,
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.HorizontalCellLayout.superclass.render.apply(this, arguments);
+ this.element.css({"display": "table", "vertical-align": "top"});
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.HorizontalCellLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({"position": "relative", "display": "table-cell", "vertical-align": "middle"});
+ if (o.hgap + o.lgap > 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + "px"
+ })
+ }
+ if (o.hgap + o.rgap > 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + "px"
+ })
+ }
+ if (o.vgap + o.tgap > 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + "px"
+ })
+ }
+ if (o.vgap + o.bgap > 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + "px"
+ })
+ }
+ return w;
+ },
+
+ resize: function () {
+ // console.log("horizontal do not need to resize");
+ },
+
+ populate: function (items) {
+ BI.HorizontalCellLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.horizontal_cell', BI.HorizontalCellLayout);/**
+ * 靠左对齐的自由浮动布局
+ * @class BI.LatticeLayout
+ * @extends BI.Layout
+ *
+ * @cfg {JSON} options 配置属性
+ * @cfg {Number} [hgap=0] 水平间隙
+ * @cfg {Number} [vgap=0] 垂直间隙
+ */
+BI.LatticeLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.LatticeLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-lattice-layout clearfix"
+ //columnSize: [0.2, 0.2, 0.6],
+ });
+ },
+ render: function () {
+ BI.LatticeLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.LatticeLayout.superclass._addElement.apply(this, arguments);
+ if (o.columnSize && o.columnSize[i]) {
+ var width = o.columnSize[i] / BI.sum(o.columnSize) * 100 + "%";
+ } else {
+ var width = 1 / this.options.items.length * 100 + "%"
+ }
+ w.element.css({"position": "relative", "float": "left", "width": width});
+ return w;
+ },
+
+ addItem: function (item) {
+ var w = BI.LatticeLayout.superclass.addItem.apply(this, arguments);
+ this.resize();
+ return w;
+ },
+
+ addItemAt: function (item) {
+ var w = BI.LatticeLayout.superclass.addItemAt.apply(this, arguments);
+ this.resize();
+ return w;
+ },
+
+ resize: function () {
+ this.stroke(this.options.items);
+ },
+
+ populate: function (items) {
+ BI.LatticeLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.lattice', BI.LatticeLayout);/**
+ * 上下的高度固定/左右的宽度固定,中间的高度/宽度自适应
+ *
+ * @class BI.TableLayout
+ * @extends BI.Layout
+ */
+BI.TableLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.TableLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-table-layout",
+ scrolly: true,
+ columnSize: [200, 200, 'fill'],
+ rowSize: 30, //or [30,30,30]
+ hgap: 0,
+ vgap: 0,
+ items: [[
+ {
+ el: {text: 'label1'}
+ },
+ {
+ el: {text: 'label2'}
+ },
+ {
+ el: {text: 'label3'}
+ }
+ ]]
+ });
+ },
+ render: function () {
+ BI.TableLayout.superclass.render.apply(this, arguments);
+ this.rows = 0;
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (idx, arr) {
+ var o = this.options;
+ var abs = [], left = 0, right = 0, i, j;
+
+ function firstElement(item, row, col) {
+ if (row === 0) {
+ item.addClass("first-row")
+ }
+ if (col === 0) {
+ item.addClass("first-col");
+ }
+ item.addClass(BI.isOdd(row + 1) ? "odd-row" : "even-row");
+ item.addClass(BI.isOdd(col + 1) ? "odd-col" : "even-col");
+ item.addClass("center-element");
+ }
+
+ function firstObject(item, row, col) {
+ var cls = "";
+ if (row === 0) {
+ cls += " first-row";
+ }
+ if (col === 0) {
+ cls += " first-col";
+ }
+ BI.isOdd(row + 1) ? (cls += " odd-row") : (cls += " even-row");
+ BI.isOdd(col + 1) ? (cls += " odd-col") : (cls += " even-col");
+ item.cls = (item.cls || "") + cls + " center-element";
+ }
+
+ function first(item, row, col) {
+ if (item instanceof BI.Widget) {
+ firstElement(item.element, row, col);
+ } else if (item.el instanceof BI.Widget) {
+ firstElement(item.el.element, row, col);
+ } else if (item.el) {
+ firstObject(item.el, row, col)
+ } else {
+ firstObject(item, row, col);
+ }
+ }
+
+ for (i = 0; i < arr.length; i++) {
+ if (BI.isNumber(o.columnSize[i])) {
+ first(arr[i], this.rows, i);
+ abs.push(BI.extend({
+ top: 0,
+ bottom: 0,
+ left: o.columnSize[i] <= 1 ? left * 100 + "%" : left,
+ width: o.columnSize[i] <= 1 ? o.columnSize[i] * 100 + "%" : o.columnSize[i]
+ }, arr[i]));
+ left += o.columnSize[i] + (o.columnSize[i] < 1 ? 0 : o.hgap);
+ } else {
+ break;
+ }
+ }
+ for (j = arr.length - 1; j > i; j--) {
+ if (BI.isNumber(o.columnSize[j])) {
+ first(arr[j], this.rows, j);
+ abs.push(BI.extend({
+ top: 0,
+ bottom: 0,
+ right: o.columnSize[j] <= 1 ? right * 100 + "%" : right,
+ width: o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j]
+ }, arr[j]))
+ right += o.columnSize[j] + (o.columnSize[j] < 1 ? 0 : o.hgap);
+ } else {
+ throw new Error("item with fill can only be one");
+ }
+ }
+ if (i >= 0 && i < arr.length) {
+ first(arr[i], this.rows, i);
+ abs.push(BI.extend({
+ top: 0,
+ bottom: 0,
+ left: left <= 1 ? left * 100 + "%" : left,
+ right: right <= 1 ? right * 100 + "%" : right
+ }, arr[i]))
+ }
+ var w = BI.createWidget({
+ type: "bi.absolute",
+ height: BI.isArray(o.rowSize) ? o.rowSize[this.rows] : o.rowSize,
+ items: abs
+ });
+ if (this.rows > 0) {
+ this.getWidgetByName(this.getName() + (this.rows - 1)).element.css({
+ "margin-bottom": o.vgap
+ })
+ }
+ w.element.css({
+ "position": "relative"
+ });
+ this.addWidget(this.getName() + (this.rows++), w);
+ return w;
+ },
+
+ resize: function () {
+ // console.log("table布局不需要resize");
+ },
+
+ addItem: function (arr) {
+ if (!BI.isArray(arr)) {
+ throw new Error("item must be array");
+ }
+ return BI.TableLayout.superclass.addItem.apply(this, arguments);
+ },
+
+ populate: function (items) {
+ BI.TableLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.table', BI.TableLayout);/**
+ * 水平tape布局
+ * @class BI.HTapeLayout
+ * @extends BI.Layout
+ */
+BI.HTapeLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.HTapeLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-h-tape-layout",
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ items: [
+ {
+ width: 100,
+ el: {type: 'bi.button', text: 'button1'}
+ },
+ {
+ width: 'fill',
+ el: {type: 'bi.button', text: 'button2'}
+ },
+ {
+ width: 200,
+ el: {type: 'bi.button', text: 'button3'}
+ }
+ ]
+ });
+ },
+ render: function () {
+ BI.HTapeLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ this.stroke(this.options.items);
+ },
+ addItem: function (item) {
+ // do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function (items) {
+ var self = this, o = this.options;
+ items = BI.compact(items);
+ BI.each(items, function (i, item) {
+ if (!self.hasWidget(self.getName() + i + "")) {
+ var w = BI.createWidget(item);
+ self.addWidget(self.getName() + i + "", w);
+ } else {
+ w = self.getWidgetByName(self.getName() + i + "");
+ }
+ w.element.css({"position": "absolute", top: o.vgap + o.tgap + "px", bottom: o.vgap + o.bgap + "px"});
+ });
+
+ var left = {}, right = {};
+ left[0] = 0;
+ right[items.length - 1] = 0;
+
+ BI.any(items, function (i, item) {
+ var w = self.getWidgetByName(self.getName() + i + "");
+ if (BI.isNull(left[i])) {
+ left[i] = left[i - 1] + items[i - 1].width + 2 * o.hgap + o.lgap + o.rgap;
+ }
+ if (item.width < 1 && item.width >= 0) {
+ w.element.css({"left": left[i] * 100 + "%", width: item.width * 100 + "%"})
+ } else {
+ w.element.css({
+ "left": left[i] + o.hgap + o.lgap + "px",
+ width: BI.isNumber(item.width) ? item.width : ""
+ });
+ }
+ if (!BI.isNumber(item.width)) {
+ return true;
+ }
+ });
+ BI.backAny(items, function (i, item) {
+ var w = self.getWidgetByName(self.getName() + i + "");
+ if (BI.isNull(right[i])) {
+ right[i] = right[i + 1] + items[i + 1].width + 2 * o.hgap + o.lgap + o.rgap;
+ }
+ if (item.width < 1 && item.width >= 0) {
+ w.element.css({"right": right[i] * 100 + "%", width: item.width * 100 + "%"})
+ } else {
+ w.element.css({
+ "right": right[i] + o.hgap + o.rgap + "px",
+ width: BI.isNumber(item.width) ? item.width : ""
+ });
+ }
+ if (!BI.isNumber(item.width)) {
+ return true;
+ }
+ })
+ },
+
+ populate: function (items) {
+ BI.HTapeLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.htape', BI.HTapeLayout);
+
+/**
+ * 垂直tape布局
+ * @class BI.VTapeLayout
+ * @extends BI.Layout
+ */
+BI.VTapeLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.VTapeLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-v-tape-layout",
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ items: [
+ {
+ height: 100,
+ el: {type: 'bi.button', text: 'button1'}
+ },
+ {
+ height: 'fill',
+ el: {type: 'bi.button', text: 'button2'}
+ },
+ {
+ height: 200,
+ el: {type: 'bi.button', text: 'button3'}
+ }
+ ]
+ });
+ },
+ render: function () {
+ BI.VTapeLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ this.stroke(this.options.items);
+ },
+
+ addItem: function (item) {
+ // do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function (items) {
+ var self = this, o = this.options;
+ items = BI.compact(items);
+ BI.each(items, function (i, item) {
+ if (!self.hasWidget(self.getName() + i + "")) {
+ var w = BI.createWidget(item);
+ self.addWidget(self.getName() + i + "", w);
+ } else {
+ w = self.getWidgetByName(self.getName() + i + "");
+ }
+ w.element.css({"position": "absolute", left: o.hgap + o.lgap + "px", right: o.hgap + o.rgap + "px"});
+ });
+
+ var top = {}, bottom = {};
+ top[0] = 0;
+ bottom[items.length - 1] = 0;
+
+ BI.any(items, function (i, item) {
+ var w = self.getWidgetByName(self.getName() + i + "");
+ if (BI.isNull(top[i])) {
+ top[i] = top[i - 1] + items[i - 1].height + 2 * o.vgap + o.tgap + o.bgap;
+ }
+ if (item.height < 1 && item.height >= 0) {
+ w.element.css({"top": top[i] * 100 + "%", height: item.height * 100 + "%"})
+ } else {
+ w.element.css({
+ "top": top[i] + o.vgap + o.tgap + "px",
+ height: BI.isNumber(item.height) ? item.height : ""
+ });
+ }
+ if (!BI.isNumber(item.height)) {
+ return true;
+ }
+ });
+ BI.backAny(items, function (i, item) {
+ var w = self.getWidgetByName(self.getName() + i + "");
+ if (BI.isNull(bottom[i])) {
+ bottom[i] = bottom[i + 1] + items[i + 1].height + 2 * o.vgap + o.tgap + o.bgap;
+ }
+ if (item.height < 1 && item.height >= 0) {
+ w.element.css({"bottom": bottom[i] * 100 + "%", height: item.height * 100 + "%"})
+ } else {
+ w.element.css({
+ "bottom": bottom[i] + o.vgap + o.bgap + "px",
+ height: BI.isNumber(item.height) ? item.height : ""
+ });
+ }
+ if (!BI.isNumber(item.height)) {
+ return true;
+ }
+ })
+ },
+
+ populate: function (items) {
+ BI.VTapeLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.vtape', BI.VTapeLayout);/**
+ * td布局
+ * @class BI.TdLayout
+ * @extends BI.Layout
+ */
+BI.TdLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.TdLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-td-layout",
+ columnSize: [200, 200, 200],
+ hgap: 0,
+ vgap: 0,
+ items: [[
+ {
+ el: {text: 'label1'}
+ },
+ {
+ el: {text: 'label2'}
+ },
+ {
+ el: {text: 'label3'}
+ }
+ ]]
+ });
+ },
+ render: function () {
+ BI.TdLayout.superclass.render.apply(this, arguments);
+ this.$table = $("").attr({"cellspacing": 0, "cellpadding": 0}).css({
+ "position": "relative",
+ "width": "100%",
+ "height": "100%",
+ "border-spacing": "0px",
+ "border": "none",
+ "border-collapse": "separate"
+ });
+ this.rows = 0;
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (idx, arr) {
+ var o = this.options;
+
+ function firstElement(item, row, col) {
+ if (row === 0) {
+ item.addClass("first-row")
+ }
+ if (col === 0) {
+ item.addClass("first-col");
+ }
+ item.addClass(BI.isOdd(row + 1) ? "odd-row" : "even-row");
+ item.addClass(BI.isOdd(col + 1) ? "odd-col" : "even-col");
+ item.addClass("center-element");
+ }
+
+ function firstObject(item, row, col) {
+ var cls = "";
+ if (row === 0) {
+ cls += " first-row";
+ }
+ if (col === 0) {
+ cls += " first-col";
+ }
+ BI.isOdd(row + 1) ? (cls += " odd-row") : (cls += " even-row");
+ BI.isOdd(col + 1) ? (cls += " odd-col") : (cls += " even-col");
+ item.cls = (item.cls || "") + cls + " center-element";
+ }
+
+ function first(item, row, col) {
+ if (item instanceof BI.Widget) {
+ firstElement(item.element, row, col);
+ } else if (item.el instanceof BI.Widget) {
+ firstElement(item.el.element, row, col);
+ } else if (item.el) {
+ firstObject(item.el, row, col)
+ } else {
+ firstObject(item, row, col);
+ }
+ }
+
+ var tr = BI.createWidget({
+ type: "bi.default",
+ tagName: "tr"
+ });
+
+ for (var i = 0; i < arr.length; i++) {
+ var w = BI.createWidget(arr[i]);
+ w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"});
+ first(w, this.rows++, i);
+ var td = BI.createWidget({
+ type: 'bi.default',
+ attributes: {
+ width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]
+ },
+ tagName: 'td',
+ items: [w]
+ });
+ td.element.css({
+ "position": "relative",
+ "vertical-align": "middle",
+ "margin": "0",
+ "padding": "0",
+ "border": "none"
+ });
+ tr.addItem(td);
+ }
+ this.addWidget(this.getName() + idx, tr);
+ return tr;
+ },
+
+ _mountChildren: function(){
+ var self = this;
+ var frag = document.createDocumentFragment();
+ var hasChild = false;
+ BI.each(this._children, function (i, widget) {
+ if (widget.element !== self.element) {
+ frag.appendChild(widget.element[0]);
+ hasChild = true;
+ }
+ });
+ if (hasChild === true) {
+ this.$table.append(frag);
+ this.element.append(this.$table);
+ }
+ },
+
+ resize: function () {
+ // console.log("td布局不需要resize");
+ },
+
+ addItem: function (arr) {
+ if (!BI.isArray(arr)) {
+ throw new Error("item must be array");
+ }
+ return BI.TdLayout.superclass.addItem.apply(this, arguments);
+ },
+
+ populate: function (items) {
+ BI.TdLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.td', BI.TdLayout);/**
+ * 垂直布局
+ * @class BI.VerticalLayout
+ * @extends BI.Layout
+ */
+BI.VerticalLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.VerticalLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-vertical-layout",
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ scrolly: true
+ });
+ },
+ render: function () {
+ BI.VerticalLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _addElement: function (i, item) {
+ var o = this.options;
+ var w = BI.VerticalLayout.superclass._addElement.apply(this, arguments);
+ w.element.css({
+ "position": "relative"
+ });
+ if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
+ w.element.css({
+ "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
+ w.element.css({
+ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
+ })
+ }
+ if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
+ w.element.css({
+ "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
+ })
+ }
+ if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
+ w.element.css({
+ "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
+ })
+ }
+ return w;
+ },
+
+ resize: function () {
+ this.stroke(this.options.items);
+ },
+
+ populate: function (items) {
+ BI.VerticalLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.vertical', BI.VerticalLayout);/**
+ *
+ * @class BI.WindowLayout
+ * @extends BI.Layout
+ */
+BI.WindowLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.WindowLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-window-layout",
+ columns: 3,
+ rows: 2,
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ columnSize: [100, "fill", 200],
+ rowSize: [100, "fill"],
+ items: [[
+ {
+ el: {type: 'bi.button', text: 'button1'}
+ },
+ {
+ el: {type: 'bi.button', text: 'button2'}
+ },
+ {
+ el: {type: 'bi.button', text: 'button3'}
+ }
+ ]]
+ });
+ },
+ render: function () {
+ BI.WindowLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ this.stroke(this.options.items);
+ },
+
+ addItem: function (item) {
+ // do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function (items) {
+ var o = this.options;
+ if (BI.isNumber(o.rowSize)) {
+ o.rowSize = BI.makeArray(o.items.length, 1 / o.items.length);
+ }
+ if (BI.isNumber(o.columnSize)) {
+ o.columnSize = BI.makeArray(o.items[0].length, 1 / o.items[0].length);
+ }
+ function firstElement(item, row, col) {
+ if (row === 0) {
+ item.addClass("first-row")
+ }
+ if (col === 0) {
+ item.addClass("first-col");
+ }
+ item.addClass(BI.isOdd(row + 1) ? "odd-row" : "even-row");
+ item.addClass(BI.isOdd(col + 1) ? "odd-col" : "even-col");
+ item.addClass("center-element");
+ }
+
+ function firstObject(item, row, col) {
+ var cls = "";
+ if (row === 0) {
+ cls += " first-row";
+ }
+ if (col === 0) {
+ cls += " first-col";
+ }
+ BI.isOdd(row + 1) ? (cls += " odd-row") : (cls += " even-row");
+ BI.isOdd(col + 1) ? (cls += " odd-col") : (cls += " even-col");
+ item.cls = (item.cls || "") + cls + " center-element";
+ }
+
+ function first(item, row, col) {
+ if (item instanceof BI.Widget) {
+ firstElement(item.element, row, col);
+ } else if (item.el instanceof BI.Widget) {
+ firstElement(item.el.element, row, col);
+ } else if (item.el) {
+ firstObject(item.el, row, col)
+ } else {
+ firstObject(item, row, col);
+ }
+ }
+
+ for (var i = 0; i < o.rows; i++) {
+ for (var j = 0; j < o.columns; j++) {
+ if (!o.items[i][j]) {
+ throw new Error("item be required");
+ }
+ if (!this.hasWidget(this.getName() + i + "_" + j)) {
+ var w = BI.createWidget(o.items[i][j]);
+ w.element.css({"position": "absolute"});
+ this.addWidget(this.getName() + i + "_" + j, w);
+ }
+ }
+ }
+ var left = {}, right = {}, top = {}, bottom = {};
+ left[0] = 0;
+ top[0] = 0;
+ right[o.columns - 1] = 0;
+ bottom[o.rows - 1] = 0;
+ //从上到下
+ for (var i = 0; i < o.rows; i++) {
+ for (var j = 0; j < o.columns; j++) {
+ var wi = this.getWidgetByName(this.getName() + i + "_" + j);
+ if (BI.isNull(top[i])) {
+ top[i] = top[i - 1] + (o.rowSize[i - 1] < 1 ? o.rowSize[i - 1] : o.rowSize[i - 1] + o.vgap + o.bgap);
+ }
+ var t = top[i] <= 1 ? top[i] * 100 + "%" : top[i] + o.vgap + o.tgap + "px", h = "";
+ if (BI.isNumber(o.rowSize[i])) {
+ h = o.rowSize[i] <= 1 ? o.rowSize[i] * 100 + "%" : o.rowSize[i] + "px";
+ }
+ wi.element.css({"top": t, height: h});
+ first(wi, i, j);
+ }
+ if (!BI.isNumber(o.rowSize[i])) {
+ break;
+ }
+ }
+ //从下到上
+ for (var i = o.rows - 1; i >= 0; i--) {
+ for (var j = 0; j < o.columns; j++) {
+ var wi = this.getWidgetByName(this.getName() + i + "_" + j);
+ if (BI.isNull(bottom[i])) {
+ bottom[i] = bottom[i + 1] + (o.rowSize[i + 1] < 1 ? o.rowSize[i + 1] : o.rowSize[i + 1] + o.vgap + o.tgap);
+ }
+ var b = bottom[i] <= 1 ? bottom[i] * 100 + "%" : bottom[i] + o.vgap + o.bgap + "px", h = "";
+ if (BI.isNumber(o.rowSize[i])) {
+ h = o.rowSize[i] <= 1 ? o.rowSize[i] * 100 + "%" : o.rowSize[i] + "px";
+ }
+ wi.element.css({"bottom": b, height: h});
+ first(wi, i, j);
+ }
+ if (!BI.isNumber(o.rowSize[i])) {
+ break;
+ }
+ }
+ //从左到右
+ for (var j = 0; j < o.columns; j++) {
+ for (var i = 0; i < o.rows; i++) {
+ var wi = this.getWidgetByName(this.getName() + i + "_" + j);
+ if (BI.isNull(left[j])) {
+ left[j] = left[j - 1] + (o.columnSize[j - 1] < 1 ? o.columnSize[j - 1] : o.columnSize[j - 1] + o.hgap + o.rgap);
+ }
+ var l = left[j] <= 1 ? left[j] * 100 + "%" : left[j] + o.hgap + o.lgap + "px", w = "";
+ if (BI.isNumber(o.columnSize[j])) {
+ w = o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] + "px";
+ }
+ wi.element.css({"left": l, width: w});
+ first(wi, i, j);
+ }
+ if (!BI.isNumber(o.columnSize[j])) {
+ break;
+ }
+ }
+ //从右到左
+ for (var j = o.columns - 1; j >= 0; j--) {
+ for (var i = 0; i < o.rows; i++) {
+ var wi = this.getWidgetByName(this.getName() + i + "_" + j);
+ if (BI.isNull(right[j])) {
+ right[j] = right[j + 1] + (o.columnSize[j + 1] < 1 ? o.columnSize[j + 1] : o.columnSize[j + 1] + o.hgap + o.lgap)
+ }
+ var r = right[j] <= 1 ? right[j] * 100 + "%" : right[j] + o.hgap + o.rgap + "px", w = "";
+ if (BI.isNumber(o.columnSize[j])) {
+ w = o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] + "px";
+ }
+ wi.element.css({"right": r, width: w});
+ first(wi, i, j);
+ }
+ if (!BI.isNumber(o.columnSize[j])) {
+ break;
+ }
+ }
+ },
+
+ populate: function (items) {
+ BI.WindowLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.window', BI.WindowLayout);/**
+ * 水平和垂直方向都居中容器, 非自适应,用于宽度高度固定的面板
+ * @class BI.CenterLayout
+ * @extends BI.Layout
+ */
+BI.CenterLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.CenterLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-center-layout",
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+
+ render: function () {
+ BI.CenterLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ // console.log("center布局不需要resize");
+ },
+
+ addItem: function (item) {
+ //do nothing
+ throw new Error("cannot be added");
+ },
+
+ stroke: function (items) {
+ var self = this, o = this.options;
+ var list = [];
+ BI.each(items, function (i) {
+ list.push({
+ column: i,
+ row: 0,
+ el: BI.createWidget({
+ type: "bi.default",
+ cls: "center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "")
+ })
+ });
+ });
+ BI.each(items, function (i, item) {
+ if (!!item) {
+ var w = BI.createWidget(item);
+ w.element.css({
+ position: "absolute",
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap,
+ width: "auto",
+ height: "auto"
+ });
+ list[i].el.addItem(w);
+ }
+ });
+ BI.createWidget({
+ type: "bi.grid",
+ element: this,
+ columns: list.length,
+ rows: 1,
+ items: list
+ });
+ },
+
+ populate: function (items) {
+ BI.CenterLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.center', BI.CenterLayout);/**
+ * 浮动布局实现的居中容器
+ * @class BI.FloatCenterLayout
+ * @extends BI.Layout
+ */
+BI.FloatCenterLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.FloatCenterLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-float-center-layout",
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.FloatCenterLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ // console.log("floatcenter布局不需要resize");
+ },
+
+ addItem: function (item) {
+ //do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function (items) {
+ var self = this, o = this.options;
+ var list = [], width = 100 / items.length;
+ BI.each(items, function (i) {
+ var widget = BI.createWidget({
+ type: "bi.default"
+ });
+ widget.element.addClass("center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "")).css({
+ width: width + "%",
+ height: "100%"
+ });
+ list.push({
+ el: widget
+ });
+ });
+ BI.each(items, function (i, item) {
+ if (!!item) {
+ var w = BI.createWidget(item);
+ w.element.css({
+ position: "absolute",
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap,
+ width: "auto",
+ height: "auto"
+ });
+ list[i].el.addItem(w);
+ }
+ });
+ BI.createWidget({
+ type: "bi.left",
+ element: this,
+ items: list
+ });
+ },
+
+ populate: function (items) {
+ BI.FloatCenterLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.float_center', BI.FloatCenterLayout);/**
+ * 水平和垂直方向都居中容器, 非自适应,用于宽度高度固定的面板
+ * @class BI.HorizontalCenterLayout
+ * @extends BI.Layout
+ */
+BI.HorizontalCenterLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.HorizontalCenterLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-horizontal-center-layout",
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.HorizontalCenterLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ // console.log("horizontal_center布局不需要resize");
+ },
+
+ addItem: function (item) {
+ //do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function (items) {
+ var o = this.options;
+ var list = [];
+ BI.each(items, function (i) {
+ list.push({
+ column: i,
+ row: 0,
+ el: BI.createWidget({
+ type: "bi.default",
+ cls: "center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "")
+ })
+ });
+ });
+ BI.each(items, function (i, item) {
+ if (!!item) {
+ var w = BI.createWidget(item);
+ w.element.css({
+ position: "absolute",
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap,
+ width: "auto"
+ });
+ list[i].el.addItem(w);
+ }
+ });
+ BI.createWidget({
+ type: "bi.grid",
+ element: this,
+ columns: list.length,
+ rows: 1,
+ items: list
+ });
+ },
+
+ populate: function (items) {
+ BI.HorizontalCenterLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.horizontal_center', BI.HorizontalCenterLayout);/**
+ * 垂直方向都居中容器, 非自适应,用于高度不固定的面板
+ * @class BI.VerticalCenterLayout
+ * @extends BI.Layout
+ */
+BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
+ props: function () {
+ return BI.extend(BI.VerticalCenterLayout.superclass.props.apply(this, arguments), {
+ baseCls: "bi-vertical-center-layout",
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0
+ });
+ },
+ render: function () {
+ BI.VerticalCenterLayout.superclass.render.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ resize: function () {
+ // console.log("vertical_center布局不需要resize");
+ },
+
+ addItem: function (item) {
+ //do nothing
+ throw new Error("cannot be added")
+ },
+
+ stroke: function (items) {
+ var self = this, o = this.options;
+ var list = [];
+ BI.each(items, function (i) {
+ list.push({
+ column: 0,
+ row: i,
+ el: BI.createWidget({
+ type: "bi.default",
+ cls: "center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "")
+ })
+ });
+ });
+ BI.each(items, function (i, item) {
+ if (!!item) {
+ var w = BI.createWidget(item);
+ w.element.css({
+ position: "absolute",
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap,
+ height: "auto"
+ });
+ list[i].el.addItem(w);
+ }
+ });
+ BI.createWidget({
+ type: "bi.grid",
+ element: this,
+ columns: 1,
+ rows: list.length,
+ items: list
+ });
+ },
+
+ populate: function (items) {
+ BI.VerticalCenterLayout.superclass.populate.apply(this, arguments);
+ this._mount();
+ }
+});
+BI.shortcut('bi.vertical_center', BI.VerticalCenterLayout);/**
+ * 保存数据,将js里面用到的常量数据都分离
+ *
+ */
+BI.Data = Data = {};
+
+/**
+ * 存放bi里面通用的一些常量
+ * @type {{}}
+ */
+Data.Constant = BI.Constant = BICst = {};
+/**
+ * 缓冲池
+ * @type {{Buffer: {}}}
+ */
+;
+(function () {
+ var Buffer = {};
+ var MODE = false;//设置缓存模式为关闭
+
+ Data.BufferPool = {
+ put: function (name, cache) {
+ if (BI.isNotNull(Buffer[name])) {
+ throw new Error("Buffer Pool has the key already!");
+ }
+ Buffer[name] = cache;
+ },
+
+ get: function (name) {
+ return Buffer[name];
+ },
+ };
+})();/**
+ * 共享池
+ * @type {{Shared: {}}}
+ */
+;
+(function () {
+ var _Shared = {};
+ Data.SharingPool = {
+ _Shared: _Shared,
+ put: function (name, shared) {
+ _Shared[name] = shared;
+ },
+
+ cat: function () {
+ var args = Array.prototype.slice.call(arguments, 0),
+ copy = _Shared;
+ for (var i = 0; i < args.length; i++) {
+ copy = copy[args[i]];
+ }
+ return copy;
+ },
+
+ get: function () {
+ return BI.deepClone(this.cat.apply(this, arguments));
+ },
+
+ remove: function (key) {
+ delete _Shared[key];
+ }
+ };
+})();Data.Req = {
+
+};
+Data.Source = BISource = {
+
+};//工程配置
+$(function () {
+ //注册布局
+ var isSupportFlex = BI.isSupportCss3("flex");
+ BI.Plugin.registerWidget("bi.horizontal", function (ob) {
+ if (isSupportFlex) {
+ return BI.extend(ob, {type: "bi.flex_horizontal"});
+ } else {
+ return ob;
+ }
+ });
+ BI.Plugin.registerWidget("bi.center_adapt", function (ob) {
+ if (isSupportFlex && ob.items && ob.items.length <= 1) {
+ //有滚动条的情况下需要用到flex_wrapper_center布局
+ if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
+ //不是IE用flex_wrapper_center布局
+ if (!BI.isIE()) {
+ return BI.extend(ob, {type: "bi.flex_wrapper_center"});
+ }
+ return ob;
+ }
+ return BI.extend(ob, {type: "bi.flex_center"});
+ } else {
+ return ob;
+ }
+ });
+ BI.Plugin.registerWidget("bi.vertical_adapt", function (ob) {
+ if (isSupportFlex) {
+ //有滚动条的情况下需要用到flex_wrapper_center布局
+ if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
+ //不是IE用flex_wrapper_center布局
+ if (!BI.isIE()) {
+ return BI.extend({}, ob, {type: "bi.flex_wrapper_vertical_center"});
+ }
+ return ob;
+ }
+ return BI.extend(ob, {type: "bi.flex_vertical_center"});
+ } else {
+ return ob;
+ }
+ });
+ BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) {
+ if (isSupportFlex) {
+ //有滚动条的情况下需要用到flex_wrapper_center布局
+ if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
+ //不是IE用flex_wrapper_center布局
+ if (!BI.isIE()) {
+ return BI.extend({}, ob, {type: "bi.flex_wrapper_center"});
+ }
+ return ob;
+ }
+ return BI.extend(ob, {type: "bi.flex_center"});
+ } else {
+ return ob;
+ }
+ });
+ //注册滚动条
+ BI.Plugin.registerWidget("bi.grid_table_scrollbar", function (ob) {
+ if (BI.isIE9Below()) {
+ return BI.extend(ob, {type: "bi.native_table_scrollbar"});
+ } else {
+ return ob;
+ }
+ });
+ BI.Plugin.registerWidget("bi.grid_table_horizontal_scrollbar", function (ob) {
+ if (BI.isIE9Below()) {
+ return BI.extend(ob, {type: "bi.native_table_horizontal_scrollbar"});
+ } else {
+ return ob;
+ }
+ });
+
+ //注册控件
+ BI.Plugin.registerWidget("bi.grid_table", function (ob) {
+ //非chrome下滚动条滑动效果不好,禁止掉
+ if (!(BI.isChrome() && BI.isWindows() && !BI.isEdge())) {
+ return BI.extend(ob, {type: "bi.quick_grid_table"});
+ } else {
+ return ob;
+ }
+ });
+ BI.Plugin.registerWidget("bi.collection_table", function (ob) {
+ //非chrome下滚动条滑动效果不好,禁止掉
+ if (!(BI.isChrome() && BI.isWindows() && !BI.isEdge())) {
+ return BI.extend(ob, {type: "bi.quick_collection_table"});
+ } else {
+ return ob;
+ }
+ });
+ //IE8下滚动条用原生的
+ if (BI.isIE9Below()) {
+ BI.GridTableScrollbar.SIZE = 18;
+ }
+=======
/*!
* jQuery JavaScript Library v1.9.1
* http://jquery.com/
@@ -28690,4 +57370,5 @@ $(function () {
if (BI.isIE9Below()) {
BI.GridTableScrollbar.SIZE = 18;
}
+>>>>>>> f7ab8fadf8581f5a532908fdb0283047312fd570
});
\ No newline at end of file
diff --git a/docs/demo.css b/docs/demo.css
index 9b3f8c0bc..c6ff93cb2 100644
--- a/docs/demo.css
+++ b/docs/demo.css
@@ -48,6 +48,52 @@ body {
.bi-theme-dark body {
background-color: #191B2B;
}
+.demo-editor {
+ border: 1px solid #cccccc;
+}
+.bi-slider-track .background-track {
+ background-color: rgba(153, 153, 153, 0);
+ _filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#33999999, 99, endColorstr=#33999999, 99);
+ -webkit-border-radius: 12px;
+ -moz-border-radius: 12px;
+ border-radius: 12px;
+}
+.bi-slider-track .gray-track {
+ background: #cccccc;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+.bi-slider-track .blue-track {
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+.widget-slider-icon .x-icon {
+ display: block;
+ background: url('icon/slider.png') no-repeat;
+ _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-normal.png');
+ _background: none;
+ background-size: 100% 100%;
+}
+.widget-slider-icon:hover .x-icon {
+ display: block;
+ background: url('icon/双向箭头.png') no-repeat;
+ _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
+ _background: none;
+ background-size: 100% 100%;
+}
+.widget-slider-icon::focus .x-icon {
+ display: block;
+ background: url('icon/双向箭头.png') no-repeat;
+ _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
+ _background: none;
+ background-size: 100% 100%;
+}
+.widget-slider-icon.native .x-icon,
+.widget-slider-icon.disabled .x-icon {
+ display: block;
+}
.demo-north {
background-color: #3c8dbc;
}
diff --git a/docs/demo.js b/docs/demo.js
index 6c8745e71..7e2c5babf 100644
--- a/docs/demo.js
+++ b/docs/demo.js
@@ -2908,7 +2908,7 @@ BI.shortcut("demo.value_chooser_combo", Demo.ValueChooserCombo);Demo.ValueChoose
BI.shortcut("demo.value_chooser_pane", Demo.ValueChooserPane);Demo.BASE_CONFIG = [{
id: 2,
text: "基础控件",
- open: true
+ open: false
}, {
pId: 2,
text: "bi.label",
@@ -3024,7 +3024,7 @@ BI.shortcut("demo.value_chooser_pane", Demo.ValueChooserPane);Demo.BASE_CONFIG =
}];Demo.CASE_CONFIG = [{
id: 3,
text: "实例控件",
- open: true,
+ open: false
}, {
pId: 3,
id: 301,
@@ -3338,53 +3338,274 @@ Demo.COMPONENT_CONFIG = [{
text: "pane",
value: "demo.pane"
}];Demo.WIDGET_CONFIG = [{
- id: 4,
- text: "详细控件"
-}, {
- id: 401,
- pId: 4,
- text: "table"
-}, {
- pId: 401,
- text: "bi.preview_table",
- value: "demo.preview_table"
-}, {
- pId: 401,
- text: "bi.responsive_table",
- value: "demo.responsive_table"
-}, {
- pId: 401,
- text: "bi.sequence_table",
- value: "demo.sequence_table"
-}, {
- pId: 401,
- text: "bi.page_table",
- value: "demo.page_table"
-}, {
- id: 402,
- pId: 4,
- text: "tree"
-}, {
- pId: 402,
- text: "bi.multilayer_select_tree_combo",
- value: "demo.multilayer_select_tree_combo"
-}, {
- pId: 4,
- text: "bi.multi_select_combo",
- value: "demo.multi_select_combo"
-}, {
- pId: 4,
- text: "bi.path_chooser",
- value: "demo.path_chooser"
-}, {
- pId: 4,
- text: "bi.relation_view",
- value: "demo.relation_view"
-}, {
- pId: 4,
- text: "bi.interactive_arrangement",
- value: "demo.interactive_arrangement"
-}];Demo.Func = BI.inherit(BI.Widget, {
+ id: 4,
+ text: "详细控件",
+ open: true
+ }, {
+ id: 400,
+ pId: 4,
+ text: "tree"
+ }, {
+ pId: 400,
+ text: "bi.multi_tree_combo",
+ value: "demo.multi_tree_combo"
+ }, {
+ id: 401,
+ pId: 4,
+ text: "table"
+ }, {
+ pId: 401,
+ text: "bi.preview_table",
+ value: "demo.preview_table"
+ }, {
+ pId: 401,
+ text: "bi.responsive_table",
+ value: "demo.responsive_table"
+ }, {
+ pId: 401,
+ text: "bi.excel_table",
+ value: "demo.excel_table"
+ }, {
+ pId: 4,
+ id: 402,
+ text: "年份控件",
+ open: false
+ }, {
+ pId: 402,
+ text: "bi.year_combo",
+ value: "demo.year"
+ }, {
+ pId: 4,
+ id: 403,
+ text: "月份控件",
+ open: false
+ }, {
+ pId: 403,
+ text: "bi.month_combo",
+ value: "demo.month"
+ }, {
+ pId: 4,
+ id: 404,
+ text: "季度控件",
+ open: false
+ }, {
+ pId: 404,
+ text: "bi.quarter_combo",
+ value: "demo.quarter"
+ }, {
+ pId: 4,
+ id: 405,
+ text: "下拉列表",
+ open: false
+ }, {
+ pId: 405,
+ text: "bi.down_list_combo",
+ value: "demo.down_list"
+ }, {
+ pId: 4,
+ id: 406,
+ text: "文本框控件",
+ open: false
+ }, {
+ pId: 406,
+ text: "bi.text_editor",
+ value: "demo.text_editor"
+ }, {
+ pId: 406,
+ text: "bi.search_editor",
+ value: "demo.search_editor"
+ }, {
+ pId: 406,
+ text: "bi.sign_editor",
+ value: "demo.sign_editor"
+ }, {
+ pId: 406,
+ text: "bi.sign_initial_editor",
+ value: "demo.sign_initial_editor"
+ }, {
+ pId: 406,
+ text: "bi.sign_style_editor",
+ value: "demo.sign_style_editor"
+ }, {
+ pId: 406,
+ text: "bi.state_editor",
+ value: "demo.state_editor"
+ }, {
+ pId: 406,
+ text: "bi.clear_editor",
+ value: "demo.clear_editor"
+ }, {
+ pId: 406,
+ text: "bi.record_editor",
+ value: "demo.record_editor"
+ }, {
+ pId: 406,
+ text: "bi.shelter_editor",
+ value: "demo.shelter_editor"
+ },
+ {
+ pId: 4,
+ id: 407,
+ text: "下拉框控件",
+ open: false
+ }, {
+ pId: 407,
+ text: "bi.text_value_combo",
+ value: "demo.text_value_combo"
+ }, {
+ pId: 407,
+ text: "bi.text_value_check_combo",
+ value: "demo.text_value_check_combo"
+ }, {
+ pId: 407,
+ text: "bi.text_value_down_list_combo",
+ value: "demo.text_value_down_list_combo"
+ }, {
+ pId: 407,
+ text: "bi.static_combo",
+ value: "demo.static_combo"
+ }, {
+ pId: 407,
+ text: "bi.icon_combo",
+ value: "demo.icon_combo"
+ }, {
+ pId: 407,
+ text: "bi.formula_combo",
+ value: "demo.formula_combo"
+ }, {
+ pId: 4,
+ id: 408,
+ text: "选择字段列表",
+ open: false
+ }, {
+ pId: 408,
+ text: "bi.placeholder"
+ }, {
+ pId: 4,
+ id: 409,
+ text: "公式编辑器",
+ open: false
+ }, {
+ pId: 409,
+ text: "bi.placeholder"
+ }, {
+ pId: 4,
+ id: 410,
+ text: "数值区间控件"
+ }, {
+ pId: 410,
+ text: "bi.numerical_interval",
+ value: "demo.numberical_interval"
+ }, {
+ pId: 4,
+ id: 411,
+ text: "下拉复选框有确定按钮"
+ }, {
+ pId: 411,
+ text: "bi.multi_select_combo",
+ value: "demo.multi_select_combo"
+ }, {
+ pId: 4,
+ id: 412,
+ text: "简单日期控件"
+ }, {
+ pId: 412,
+ text: "bi.date_combo",
+ value: "demo.date"
+ }, {
+ pId: 412,
+ text: "bi.date_pane_widget",
+ value: "demo.date_pane_widget"
+ }, {
+ pId: 412,
+ text: "bi.year_month_combo",
+ value: "demo.year_month_combo"
+ },{
+ pId: 412,
+ text: "bi.year_quarter_combo",
+ value: "demo.year_quarter_combo"
+ },{
+ pId: 4,
+ id: 413,
+ text: "简单下拉树"
+ }, {
+ pId: 413,
+ text: "bi.single_tree_combo",
+ value: "demo.single_tree_combo"
+ }, {
+ pId: 413,
+ text: "bi.multilayer_single_tree_combo",
+ value: "demo.multilayer_single_tree_combo"
+ }, {
+ pId: 4,
+ id: 414,
+ text: "可选下拉树"
+ }, {
+ pId: 414,
+ text: "bi.select_tree_combo",
+ value: "demo.select_tree_combo"
+ }, {
+ pId: 414,
+ text: "bi.multilayer_select_tree_combo",
+ value: "demo.multilayer_select_tree_combo"
+ }, {
+ pId: 4,
+ id: 415,
+ text: "路径选择"
+ }, {
+ pId: 415,
+ text: "bi.path_chooser",
+ value: "demo.path_chooser"
+ }, {
+ pId: 415,
+ text: "bi.direction_path_chooser",
+ value: "demo.direction_path_chooser"
+ }, {
+ pId: 4,
+ id: 416,
+ text: "关联视图"
+ }, {
+ pId: 416,
+ text: "bi.relation_view",
+ value: "demo.relation_view"
+ }, {
+ pId: 4,
+ id: 417,
+ text: "布局"
+ }, {
+ pId: 417,
+ text: "bi.adaptive_arrangement",
+ value: "demo.adaptive_arrangement"
+ }, {
+ pId: 417,
+ text: "bi.interactive_arrangement",
+ value: "demo.interactive_arrangement"
+ }, {
+ pId: 4,
+ id: 418,
+ text: "提示对话框"
+ }, {
+ pId: 418,
+ text: "bi.dialog",
+ value: "demo.dialog"
+ }, {
+ pId: 4,
+ id: 419,
+ text: "单值滑块"
+ }, {
+ pId: 419,
+ text: "bi.single_slider",
+ value: "demo.single_slider"
+ },{
+ pId: 4,
+ id: 420,
+ text: "区间滑块"
+ }, {
+ pId: 420,
+ text: "bi.interval_slider",
+ value: "demo.interval_slider"
+ },
+];Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
@@ -5947,7 +6168,127 @@ BI.shortcut("demo.preview", Demo.Preview);Demo.West = BI.inherit(BI.Widget, {
}
});
Demo.West.EVENT_VALUE_CHANGE = "EVENT_VALUE_CHANGE";
-BI.shortcut("demo.west", Demo.West);/**
+BI.shortcut("demo.west", Demo.West);Demo.AdaptiveArrangement = BI.inherit(BI.Widget, {
+
+ _createItem: function () {
+ var self = this;
+ var id = BI.UUID();
+ var item = BI.createWidget({
+ type: "bi.text_button",
+ id: id,
+ cls: "layout-bg" + BI.random(1, 8),
+ handler: function () {
+ self.arrangement.deleteRegion(id);
+ }
+ });
+ item.setValue(item.attr("id"));
+ return item;
+ },
+
+ render: function () {
+ var self = this;
+ this.arrangement = BI.createWidget({
+ type: "bi.adaptive_arrangement",
+ layoutType: BI.Arrangement.LAYOUT_TYPE.ADAPTIVE,
+ cls: "mvc-border",
+ width: 800,
+ height: 400,
+ items: []
+ });
+ var drag = BI.createWidget({
+ type: "bi.label",
+ cls: "mvc-border",
+ width: 100,
+ height: 25,
+ text: "drag me"
+ });
+
+ // drag.element.draggable &&
+ drag.element.draggable({
+ revert: true,
+ cursorAt: {
+ left: 0,
+ top: 0
+ },
+ drag: function (e, ui) {
+ self.arrangement.setPosition({
+ left: ui.position.left,
+ top: ui.position.top
+ }, {
+ width: 300,
+ height: 200
+ })
+ },
+ stop: function (e, ui) {
+ self.arrangement.addRegion({
+ el: self._createItem()
+ });
+ },
+ helper: function (e) {
+ var helper = self.arrangement.getHelper();
+ return helper.element;
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: drag,
+ left: 30,
+ top: 450
+ }, {
+ el: this.arrangement,
+ left: 30,
+ top: 30
+ }, {
+ el: {
+ type: "bi.button",
+ text: "回撤",
+ height: 25,
+ handler: function () {
+ //self.arrangement.revoke();
+ }
+ },
+ left: 130,
+ top: 450
+ }, {
+ el: {
+ type: "bi.button",
+ text: "getAllRegions",
+ height: 25,
+ handler: function () {
+ var items = [];
+ BI.each(self.arrangement.getAllRegions(), function (i, region) {
+ items.push({
+ id: region.id,
+ left: region.left,
+ top: region.top,
+ width: region.width,
+ height: region.height
+ });
+ });
+ BI.Msg.toast(JSON.stringify(items));
+ }
+ },
+ left: 230,
+ top: 450
+ }, {
+ el: {
+ type: "bi.button",
+ text: "relayout",
+ height: 25,
+ handler: function () {
+ self.arrangement.relayout();
+ }
+ },
+ left: 330,
+ top: 450
+ }]
+ });
+ }
+});
+
+BI.shortcut("demo.adaptive_arrangement", Demo.AdaptiveArrangement);/**
* Created by User on 2017/3/22.
*/
Demo.RelationView = BI.inherit(BI.Widget, {
@@ -5960,110 +6301,1115 @@ Demo.RelationView = BI.inherit(BI.Widget, {
}
});
BI.shortcut("demo.interactive_arrangement", Demo.RelationView);/**
- * Created by User on 2017/3/22.
+ * Created by Dailer on 2017/7/12.
*/
-Demo.MultiSelectCombo = BI.inherit(BI.Widget, {
+Demo.FormulaCombo = BI.inherit(BI.Widget, {
props: {
- baseCls: "demo-multi-select-combo"
+ baseCls: ""
},
- _createMultiSelectCombo: function () {
+ render: function () {
+
var self = this;
- var widget = BI.createWidget({
- type: 'bi.multi_select_combo',
- itemsCreator: BI.bind(this._itemsCreator, this),
- width: 200
- });
- widget.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
- BI.Msg.toast(JSON.stringify(this.getValue()));
- });
- return widget;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.formula_combo",
+ fieldItems: [{
+ text: "A",
+ value: "A",
+ fieldType: 16
+ }],
+ width: 200,
+ height: 30
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.formula_combo", Demo.FormulaCombo);/**
+ * Created by Dailer on 2017/7/12.
+ */
+Demo.IconCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
},
- _getItemsByTimes: function (items, times) {
- var res = [];
- for (var i = (times - 1) * 3; items[i] && i < times * 3; i++) {
- res.push(items[i]);
+ render: function () {
+
+ var self = this;
+
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.icon_combo",
+ ref:function(_ref){
+ self.refs=_ref;
+ },
+ // iconClass: "pull-down-ha-font",
+ items: [{
+ value: "第一项",
+ iconClass: "delete-font"
+ }, {
+ value: "第二项",
+ iconClass: "rename-font"
+ }, {
+ value: "第三项",
+ iconClass: "move-font"
+ }]
+ }],
+ vgap: 20
}
- return res;
+ }
+})
+
+BI.shortcut("demo.icon_combo", Demo.IconCombo);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.StaticCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
},
- _hasNextByTimes: function (items, times) {
- return times * 3 < items.length;
+
+ beforeMounted: function () {
+ this.refs.setValue(2);
},
- _itemsCreator: function (options, callback) {
+ render: function () {
+
var self = this;
- var items = Demo.CONSTANTS.ITEMS;
- var keywords = (options.keywords || []).slice();
- if (options.keyword) {
- keywords.push(options.keyword);
- }
- BI.each(keywords, function (i, kw) {
- var search = BI.Func.getSearchResult(items, kw);
- items = search.matched.concat(search.finded);
- });
- if (options.selectedValues) {//过滤
- var filter = BI.makeObject(options.selectedValues, true);
- items = BI.filter(items, function (i, ob) {
- return !filter[ob.value];
- });
- }
- if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
- callback({
- items: items
- });
- return;
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.static_combo",
+ text: "Value 不变",
+ width: 300,
+ ref: function (_ref) {
+ self.refs = _ref;
+ },
+ items: [
+ {
+ text: "MVC-1",
+ value: 1
+ }, {
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }
+ ]
+ }],
+ vgap: 20
}
- if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
- callback({count: items.length});
- return;
+ }
+})
+
+BI.shortcut("demo.static_combo", Demo.StaticCombo);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.TextValueCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.text_value_combo",
+ text: "天气热死了",
+ width: 300,
+ items: [{
+ text: "MVC-1",
+ value: 1
+ }, {
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }]
+ },{
+ type: "bi.text_value_check_combo",
+ text: "天气热死了",
+ width: 300,
+ items: [{
+ text: "MVC-1",
+ value: 1
+ }, {
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }]
+ },{
+ type: "bi.text_value_combo",
+ text: "天气热死了",
+ width: 300,
+ items: [{
+ text: "MVC-1",
+ value: 1
+ }, {
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }]
+ }],
+ vgap: 20
}
- BI.delay(function () {
- callback({
- items: self._getItemsByTimes(items, options.times),
- hasNext: self._hasNextByTimes(items, options.times)
- });
- }, 1000);
+ }
+})
+
+BI.shortcut("demo.text_value_combo", Demo.TextValueCombo);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.TextValueDownListCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+
+ beforeMounted:function(){
+ this.refs.setValue(2);
},
render: function () {
+
+ var self = this;
+
return {
- type: 'bi.absolute',
- scrolly: false,
+ type: "bi.horizontal_auto",
items: [{
- el: this._createMultiSelectCombo(),
- right: 10,
- top: 10
- }]
+ type: "bi.label",
+ cls: "layout-bg2",
+ text: "分组+二级",
+ width: 300
+ }, {
+ type: "bi.text_value_down_list_combo",
+ text: "天气热死了",
+ width: 300,
+ ref: function (_ref) {
+ self.refs = _ref;
+ },
+ items: [
+ [{
+ el: {
+ text: "MVC-1",
+ value: 1
+ },
+ children: [{
+ text: "MVC-1-1",
+ value: 11
+ }]
+ }],
+ [{
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }]
+ ]
+ }],
+ vgap: 20
}
}
-});
-BI.shortcut("demo.multi_select_combo", Demo.MultiSelectCombo);/**
- * Created by User on 2017/3/22.
+})
+
+BI.shortcut("demo.text_value_down_list_combo", Demo.TextValueDownListCombo);/**
+ * Created by Dailer on 2017/7/11.
*/
-Demo.PathChooser = BI.inherit(BI.Widget, {
+Demo.TextValueCheckCombo = BI.inherit(BI.Widget, {
props: {
- baseCls: "demo-path-chooser"
+ baseCls: ""
},
render: function () {
- var pathchooser = BI.createWidget({
- type: "bi.path_chooser",
- width: 800,
- height: 400,
- items: // [
- // [{region: "区域X", value: "X1"},
- // {region: "区域Q", value: "Q"},
- // {region: "区域A", value: "A"},
- // {region: "区域B", value: "B"},
- // {region: "区域D", value: "D"},
- // {region: "区域E", value: "E"},
- // {region: "区域G", value: "G"},
- // {region: "区域I", value: "I"},
- // {region: "区域J", value: "J"}],
- // [{region: "区域X", value: "X"},
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.text_value_check_combo",
+ text: "天气热死了",
+ width: 300,
+ items: [{
+ text: "MVC-1",
+ value: 1
+ }, {
+ text: "MVC-2",
+ value: 2
+ }, {
+ text: "MVC-3",
+ value: 3
+ }]
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.text_value_check_combo", Demo.TextValueCheckCombo);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.Date = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-date"
+ },
+
+ _init: function () {
+ Demo.Date.superclass._init.apply(this, arguments);
+ },
+
+ render: function () {
+
+ return {
+ type: "bi.horizontal_auto",
+ vgap: 10,
+ items: [{
+ type: "bi.date_combo",
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ height: 50,
+ width: 300
+ }]
+ }
+ }
+})
+
+BI.shortcut("demo.date", Demo.Date);Demo.DatePane = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-datepane"
+ },
+ render: function () {
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.vertical",
+ vgap: 10,
+ items: [{
+ type: "bi.label",
+ cls: "layout-bg2",
+ text: "bi.date_pane_widget"
+ }, {
+ type: "bi.date_pane_widget",
+ selectedTime: {
+ year: 2017,
+ month: 12,
+ day: 11
+ },
+ height:300
+ },
+ {
+ type: "bi.button",
+ text: "getValue",
+ handler: function () {
+ BI.Msg.toast("date" + JSON.stringify(datepane.getValue()));
+ }
+ }
+ ],
+ width: "50%"
+ }]
+ }
+ }
+})
+
+BI.shortcut("demo.date_pane_widget", Demo.DatePane);Demo.DialogView = BI.inherit(BI.Widget, {
+
+ render: function () {
+ var items = [{
+ el: {
+ type: 'bi.button',
+ text: '弹出对话框',
+ level: 'common',
+ height: 30
+ }
+ }];
+ BI.each(items, function (i, item) {
+ item.el.handler = function () {
+ BI.Msg.alert('提示', "这是一段可以换行的文字,为了使它换行我要多写几个字,但是我又凑不够这么多的字,万般焦急下,只能随便写写");
+ }
+ });
+
+ return {
+ type: "bi.left",
+ vgap: 200,
+ hgap: 20,
+ items: items
+ }
+ }
+});
+
+BI.shortcut("demo.dialog", Demo.DialogView);Demo.Downlist = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-downlist"
+ },
+
+ mounted: function () {
+ var downlist = this.downlist;
+ var label = this.label;
+ downlist.on(BI.DownListCombo.EVENT_CHANGE, function (value, fatherValue) {
+ label.setValue(JSON.stringify(downlist.getValue()));
+ });
+
+ this.downlist.on(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
+ label.setValue(JSON.stringify(downlist.getValue()));
+ });
+ },
+
+
+ render: function () {
+ self = this;
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.down_list_combo",
+ ref: function (_ref) {
+ self.downlist = _ref;
+ },
+ cls:"layout-bg3",
+ height: 30,
+ width: 100,
+ items: [
+ [{
+ el: {
+ text: "column 1111",
+ iconCls1: "check-mark-e-font",
+ value: 11
+ },
+ children: [{
+ text: "column 1.1",
+ value: 21,
+ cls: "dot-e-font",
+ selected: true
+ }, {
+ text: "column 1.222222222222222222222222222222222222",
+ cls: "dot-e-font",
+ value: 22,
+ }]
+ }],
+ [{
+ el: {
+ type: "bi.icon_text_icon_item",
+ text: "column 2",
+ iconCls1: "chart-type-e-font",
+ cls: "dot-e-font",
+ value: 12
+ },
+ disabled: true,
+ children: [{
+ type: "bi.icon_text_item",
+ cls: "dot-e-font",
+ height: 25,
+ text: "column 2.1",
+ value: 11
+ }, {
+ text: "column 2.2",
+ value: 12,
+ cls: "dot-e-font"
+ }]
+ }],
+ [{
+ text: "column 8",
+ value: 18,
+ cls: "dot-e-font",
+ selected: true
+ },
+ {
+
+ text: "column 9",
+ cls: "dot-e-font",
+ value: 19
+ }
+ ],
+ [{
+ text: "column 10",
+ value: 20,
+ cls: "dot-e-font",
+ selected: true
+ },
+ {
+
+ text: "column 11",
+ cls: "dot-e-font",
+ value: 21
+ },
+ {
+
+ text: "column 12",
+ cls: "dot-e-font",
+ value: 22
+ },
+ {
+
+ text: "column 13",
+ cls: "dot-e-font",
+ value: 23
+ },
+ {
+
+ text: "column 14",
+ cls: "dot-e-font",
+ value: 24
+ },
+ {
+
+ text: "column 15",
+ cls: "dot-e-font",
+ value: 23
+ }
+ ]
+
+ ]
+ }, {
+ type: "bi.label",
+ text: "显示选择值",
+ width:500,
+ cls:"layout-bg4",
+ ref: function (_ref) {
+ self.label = _ref;
+ }
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.down_list", Demo.Downlist);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.AdaptEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+
+
+ //这东西好奇怪,不支持设置宽度,那么渲染出来宽度几乎没有,无奈之下只能假装给他个默认值了
+ beforeMounted: function () {
+ this.refs.setValue("Winter is coming !")
+ },
+
+ render: function () {
+ var self = this;
+ var editor = BI.createWidget({
+ type: "bi.adapt_editor",
+ cls: "layout-bg5",
+ ref: function (_ref) {
+ self.refs = _ref;
+ }
+ })
+
+ var text=["You know nothing! Jon Snow","A Lannister always pays his debts.","Power is a curious thing."]
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ el: editor
+ }, {
+ type: "bi.button",
+ text: "为了展示长度真的是可变的,每点一下就换一行字",
+ handler: function () {
+ var temp=text.shift();
+ editor.setValue(temp);
+ text.push(temp);
+ }
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.adapt_editor", Demo.AdaptEditor);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.ClearEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.clear_editor",
+ cls: "bi-border",
+ width: 300,
+ watermark: "这个是带清除按钮的"
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.clear_editor", Demo.ClearEditor);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.RecordEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.record_editor",
+ cls: "bi-border",
+ width: 300,
+ watermark: "这个是可以记录输入的"
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.record_editor", Demo.RecordEditor);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.SearchEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.search_editor",
+ width: 300,
+ watermark:"添加合法性判断",
+ errorText: "长度必须大于4",
+ validationChecker:function(){
+ return this.getValue().length > 4 ? true : false
+ }
+ },{
+ type: "bi.small_search_editor",
+ width: 300,
+ watermark:"这个是 small,小一号"
+ }],
+ vgap:20
+ }
+ }
+})
+
+BI.shortcut("demo.search_editor", Demo.SearchEditor);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.ClearEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ var editor;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.shelter_editor",
+ cls: "bi-border",
+ ref:function(_ref){
+ editor=_ref;
+ },
+ width: 300,
+ watermark: "这个是带标记的"
+ },{
+ type:"bi.button",
+ text:"setValue",
+ width:300,
+ handler:function(){
+ editor.setValue("凛冬将至");
+ }
+ },{
+ type:"bi.button",
+ text:"doHighLight",
+ width:300,
+ handler:function(){
+ editor.doHighLight();
+ console.log(editor.getState());
+ }
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.shelter_editor", Demo.ClearEditor);/**
+ * Created by Dailer on 2017/7/14.
+ */
+Demo.SignEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.sign_editor",
+ // cls:"layout-bg5",
+ value: "123",
+ text: "456",
+ width: 300
+ }],
+ vgap: 20
+
+ }
+ }
+})
+
+BI.shortcut("demo.sign_editor", Demo.SignEditor);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.SignInitialEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.sign_initial_editor",
+ cls:"layout-bg5",
+ value:"123",
+ text:"456",
+ width: 300
+ }],
+ vgap:20
+
+ }
+ }
+})
+
+BI.shortcut("demo.sign_initial_editor", Demo.SignInitialEditor);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.SignStyleEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.sign_style_editor",
+ cls:"layout-bg5",
+ value:"12313",
+ width: 300
+ }],
+ vgap:20
+ }
+ }
+})
+
+BI.shortcut("demo.sign_style_editor", Demo.SignStyleEditor);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.StateEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.state_editor",
+ cls:"bi-border",
+ value:"123",
+ text:"456",
+ width: 300
+ }],
+ vgap:20
+
+ }
+ }
+})
+
+BI.shortcut("demo.state_editor", Demo.StateEditor);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.TextEditor = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.text_editor",
+ watermark:"这是水印,watermark",
+ width: 300
+ },{
+ type: "bi.text_editor",
+ watermark:"这个不予许空",
+ allowBlank: false,
+ errorText: "非空!",
+ width: 300
+ }],
+ vgap:20
+
+ }
+ }
+})
+
+BI.shortcut("demo.text_editor", Demo.TextEditor);/**
+ * Created by Dailer on 2017/7/14.
+ */
+Demo.IntervalSlider = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+ var min = BI.createWidget({
+ type: "bi.text_editor",
+ watermark: "min",
+ width: 100
+ });
+ var max = BI.createWidget({
+ type: "bi.text_editor",
+ watermark: "max",
+ width: 100
+ })
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.interval_slider",
+ ref: function (_ref) {
+ self.slider = _ref;
+ },
+ width: 300,
+ height: 90
+ }, {
+ type: "bi.center_adapt",
+ width: 300,
+ items: [{
+ type: "bi.text",
+ text: "min"
+ }, min, {
+ type: "bi.text",
+ text: "max"
+ }, max]
+ }, {
+ type: "bi.button",
+ text: "populate",
+ handler: function () {
+ self.slider.setMinAndMax({
+ min: min.getValue() || 0,
+ max: max.getValue() || 100
+ });
+ self.slider.populate();
+ },
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "setValue",
+ handler: function () {
+
+ //既然 setVlaue后要重新 populate 才能生效,为何不直接在 setValue方法的结尾调用 populate 方法呢?
+ self.slider.setValue({
+ min: 20,
+ max: 80
+ });
+ self.slider.populate();
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.interval_slider", Demo.IntervalSlider);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.Month = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.month_combo",
+ width: 300
+ }]
+
+ }
+ }
+})
+
+BI.shortcut("demo.month", Demo.Month);/**
+ * Created by User on 2017/3/22.
+ */
+Demo.MultiSelectCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-multi-select-combo"
+ },
+
+ _createMultiSelectCombo: function () {
+ var self = this;
+ var widget = BI.createWidget({
+ type: 'bi.multi_select_combo',
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ width: 200
+ });
+
+ widget.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
+ BI.Msg.toast(JSON.stringify(this.getValue()));
+ });
+
+ return widget;
+ },
+
+ _getItemsByTimes: function (items, times) {
+ var res = [];
+ for (var i = (times - 1) * 3; items[i] && i < times * 3; i++) {
+ res.push(items[i]);
+ }
+ return res;
+ },
+
+ _hasNextByTimes: function (items, times) {
+ return times * 3 < items.length;
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this;
+ var items = Demo.CONSTANTS.ITEMS;
+ var keywords = (options.keywords || []).slice();
+ if (options.keyword) {
+ keywords.push(options.keyword);
+ }
+ BI.each(keywords, function (i, kw) {
+ var search = BI.Func.getSearchResult(items, kw);
+ items = search.matched.concat(search.finded);
+ });
+ if (options.selected_values) {//过滤
+ var filter = BI.makeObject(options.selected_values, true);
+ items = BI.filter(items, function (i, ob) {
+ return !filter[ob.value];
+ });
+ }
+ if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ callback({
+ items: items
+ });
+ return;
+ }
+ if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ callback({count: items.length});
+ return;
+ }
+ BI.delay(function () {
+ callback({
+ items: self._getItemsByTimes(items, options.times),
+ hasNext: self._hasNextByTimes(items, options.times)
+ });
+ }, 1000);
+ },
+
+ render: function () {
+ return {
+ type: 'bi.absolute',
+ scrolly: false,
+ items: [{
+ el: this._createMultiSelectCombo(),
+ right: "50%",
+ top: 10
+ }]
+ }
+ }
+});
+BI.shortcut("demo.multi_select_combo", Demo.MultiSelectCombo);/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.MultiTreeCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+ var items = BI.deepClone(Demo.CONSTANTS.TREE);
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.multi_tree_combo",
+ ref: function (_ref) {
+ self.tree = _ref;
+ },
+ itemsCreator: function (options, callback) {
+ console.log(options);
+
+
+ callback({
+ items: items
+ });
+ },
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(JSON.stringify(self.tree.getValue()));
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.multi_tree_combo", Demo.MultiTreeCombo);/**
+ * Created by Dailer on 2017/7/12.
+ */
+Demo.NumericalInterval = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+
+ mounted: function () {
+ var numerical = this.numerical;
+ var label = this.label;
+ numerical.on(BI.NumericalInterval.EVENT_CHANGE, function () {
+ var temp = numerical.getValue();
+ var res = "大于" + (temp.closemin ? "等于 " : " ") + temp.min + " 小于" + (temp.closemax ? "等于 " : " ") + temp.max;
+ label.setValue(res);
+ })
+ },
+
+
+
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.numerical_interval",
+ ref: function (_ref) {
+ self.numerical = _ref;
+ },
+ width: 500
+ }, {
+ type: "bi.label",
+ ref: function (_ref) {
+ self.label = _ref;
+ },
+ text: "显示结果"
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.numberical_interval", Demo.NumericalInterval);
+
+
+Demo.DirectionPathChooser = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-direction-path-chooser"
+ },
+
+ render: function () {
+ return {
+ type: "bi.center_adapt",
+ items: [
+ {
+ type: "bi.direction_path_chooser",
+ items: [[{
+ "region": "8c4460bc3605685e",
+ "regionText": "采购订单XXX",
+ "text": "ID",
+ "value": "1"
+ }, {
+ "region": "0fbd0dc648f41e97",
+ "regionText": "采购订单",
+ "text": "学号",
+ "value": "3"
+ }, {
+ "region": "c6d72d6c7e19a667",
+ "regionText": "供应商基本信息",
+ "text": "ID",
+ "value": "5"
+ }], [{
+ "region": "ed013e18cc7c8637",
+ "regionText": "采购订单XXX",
+ "text": "ID",
+ "value": "1"
+ }, {
+ "region": "153d75878431f8ee",
+ "regionText": "A3",
+ "text": "学号",
+ "value": "2"
+ }, {
+ "region": "3861fb024c7d7825",
+ "regionText": "采购订单",
+ "text": "学号",
+ "value": "3"
+ }, {
+ "region": "88e3e5071bd10bc5",
+ "regionText": "供应商",
+ "text": "ID",
+ "value": "4"
+ }, {
+ "region": "8476c77ab5c147e0",
+ "regionText": "供应商基本信息",
+ "text": "ID",
+ "value": "5"
+ }], [{
+ "region": "f00f67fbb9fba6fe",
+ "regionText": "采购订单XXX",
+ "text": "ID",
+ "value": "1"
+ }, {
+ "region": "1e8badf5d5793408",
+ "regionText": "A3",
+ "text": "学号",
+ "value": "2"
+ }, {
+ "region": "de1ebd3d0986a294",
+ "regionText": "供应商基本信息",
+ "text": "ID",
+ "value": "5"
+ }]]
+ }
+ ]
+ }
+ }
+})
+
+BI.shortcut("demo.direction_path_chooser",Demo.DirectionPathChooser);/**
+ * Created by User on 2017/3/22.
+ */
+Demo.PathChooser = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-path-chooser"
+ },
+ render: function () {
+ var pathchooser = BI.createWidget({
+ type: "bi.path_chooser",
+ width: 800,
+ height: 400,
+ items: // [
+ // [{region: "区域X", value: "X1"},
+ // {region: "区域Q", value: "Q"},
+ // {region: "区域A", value: "A"},
+ // {region: "区域B", value: "B"},
+ // {region: "区域D", value: "D"},
+ // {region: "区域E", value: "E"},
+ // {region: "区域G", value: "G"},
+ // {region: "区域I", value: "I"},
+ // {region: "区域J", value: "J"}],
+ // [{region: "区域X", value: "X"},
// {region: "区域Q", value: "Q"},
// {region: "区域A", value: "A"},
// {region: "区域B", value: "B"},
@@ -6145,143 +7491,677 @@ Demo.PathChooser = BI.inherit(BI.Widget, {
"text": "ID",
"value": "1"
}, {
- "region": "0fbd0dc648f41e97",
- "regionText": "采购订单",
- "text": "学号",
- "value": "3"
+ "region": "0fbd0dc648f41e97",
+ "regionText": "采购订单",
+ "text": "学号",
+ "value": "3"
+ }, {
+ "region": "c6d72d6c7e19a667",
+ "regionText": "供应商基本信息",
+ "text": "ID",
+ "value": "5"
+ }], [{
+ "region": "ed013e18cc7c8637",
+ "regionText": "采购订单XXX",
+ "text": "ID",
+ "value": "1"
+ }, {
+ "region": "153d75878431f8ee",
+ "regionText": "A3",
+ "text": "学号",
+ "value": "2"
+ }, {
+ "region": "3861fb024c7d7825",
+ "regionText": "采购订单",
+ "text": "学号",
+ "value": "3"
+ }, {
+ "region": "88e3e5071bd10bc5",
+ "regionText": "供应商",
+ "text": "ID",
+ "value": "4"
+ }, {
+ "region": "8476c77ab5c147e0",
+ "regionText": "供应商基本信息",
+ "text": "ID",
+ "value": "5"
+ }], [{
+ "region": "f00f67fbb9fba6fe",
+ "regionText": "采购订单XXX",
+ "text": "ID",
+ "value": "1"
+ }, {
+ "region": "1e8badf5d5793408",
+ "regionText": "A3",
+ "text": "学号",
+ "value": "2"
+ }, {
+ "region": "de1ebd3d0986a294",
+ "regionText": "供应商基本信息",
+ "text": "ID",
+ "value": "5"
+ }]]
+ });
+ pathchooser.setValue();
+ return {
+ type: "bi.absolute",
+ items: [{
+ el: pathchooser,
+ left: 100,
+ top: 100
+ }, {
+ el: {
+ type: "bi.button",
+ text: "getValue",
+ handler: function () {
+ BI.Msg.toast(JSON.stringify(pathchooser.getValue()));
+ }
+ },
+ left: 100,
+ bottom: 10
+ }]
+ }
+ }
+});
+BI.shortcut("demo.path_chooser", Demo.PathChooser);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.Quarter = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.quarter_combo",
+ width: 300
+ }]
+
+ }
+ }
+})
+
+BI.shortcut("demo.quarter", Demo.Quarter);/**
+ * Created by User on 2017/3/22.
+ */
+Demo.RelationView = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-relation-view"
+ },
+ render: function () {
+ var relationview = BI.createWidget({
+ type: "bi.relation_view",
+ items: [
+ {
+ primary: {
+ region: "B", regionText: "比", regionTitle: "bbb", regionHandler: function () {
+ alert("a")
+ },
+
+
+ title: "b2...",
+ value: "b2", text: "b2字段",
+ handler: function () {
+ alert("d")
+ }
+ },
+ foreign: {region: "C", value: "c1", text: "c1字段"}
+ },
+ {
+ primary: {region: "A", value: "a1", text: "a1字段"},
+ foreign: {region: "C", value: "c2", text: "c2字段"}
+ },
+ {
+ primary: {region: "C", value: "c3", text: "c3字段"},
+ foreign: {region: "D", value: "d1", text: "d1字段"}
+ },
+ {
+ primary: {region: "A", value: "a1", text: "a1字段"},
+ foreign: {region: "B", value: "b1", text: "b1字段"}
+ },
+
+ {
+ primary: {region: "X", value: "x1", text: "x1字段"},
+ foreign: {region: "Y", value: "y1", text: "y1字段"}
+ },
+ {
+ primary: {region: "X", value: "x2", text: "x2字段"},
+ foreign: {region: "Z", value: "z1", text: "z1字段"}
+ },
+ {
+ primary: {region: "X", value: "x2", text: "x2字段"},
+ foreign: {region: "B", value: "b1", text: "b1字段"}
+ },
+ {
+ primary: {region: "X33", value: "x233", text: "x233字段"},
+ }
+ ]
+ });
+ return {
+ type: "bi.float_center_adapt",
+ items: [{
+ el: relationview
+ }]
+ }
+ }
+});
+BI.shortcut("demo.relation_view", Demo.RelationView);/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+ var items = BI.deepClone(Demo.CONSTANTS.TREE);
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.multilayer_select_tree_combo",
+ ref: function (_ref) {
+ self.tree = _ref;
+ },
+ text: "默认值",
+ items: items,
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(self.tree.getValue()[0]);
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiLayerSelectTreeCombo);/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.SelectTreeCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+
+ render: function () {
+ var self = this;
+ var items = [{
+ id: 1,
+ text: "第一项",
+ value: 1,
+ isParent: true,
+ title: "第一项"
+ }, {
+ id: 2,
+ text: "第二项",
+ value: 2,
+ isParent: true,
+ title: "第二项"
+ }, {
+ id: 3,
+ text: "第三项",
+ value: 3,
+ isParent: true,
+ open: true,
+ title: "第三项"
+ }, {
+ id: 4,
+ text: "第四项",
+ value: 4,
+ isParent: true,
+ title: "第四项"
+ }, {
+ id: 5,
+ text: "第五项",
+ value: 5,
+ isParent: true,
+ title: "第五项"
+ }, {
+ id: 6,
+ text: "第六项",
+ value: 6,
+ isParent: true,
+ open: true,
+ title: "第六项"
+ }, {
+ id: 7,
+ text: "第七项",
+ value: 7,
+ isParent: true,
+ open: true,
+ title: "第七项"
+ }, {
+ id: 11,
+ pId: 1,
+ text: "子项1",
+ value: 11,
+ title: "子项1"
+ }, {
+ id: 12,
+ pId: 1,
+ text: "子项2",
+ value: 12,
+ title: "子项2"
+ }, {
+ id: 13,
+ pId: 1,
+ text: "子项3",
+ value: 13,
+ title: "子项3"
+ }, {
+ id: 21,
+ pId: 2,
+ text: "子项1",
+ value: 21,
+ title: "子项1"
+ }, {
+ id: 22,
+ pId: 2,
+ text: "子项2",
+ value: 22,
+ title: "子项2"
+ }, {
+ id: 31,
+ pId: 3,
+ text: "子项1",
+ value: 31,
+ title: "子项1"
+ }, {
+ id: 32,
+ pId: 3,
+ text: "子项2",
+ value: 32,
+ title: "子项2"
+ }, {
+ id: 33,
+ pId: 3,
+ text: "子项3",
+ value: 33,
+ title: "子项3"
+ }, {
+ id: 41,
+ pId: 4,
+ text: "子项1",
+ value: 41,
+ title: "子项1"
+ }, {
+ id: 42,
+ pId: 4,
+ text: "子项2",
+ value: 42,
+ title: "子项2"
+ }, {
+ id: 43,
+ pId: 4,
+ text: "子项3",
+ value: 43,
+ title: "子项3"
+ }, {
+ id: 51,
+ pId: 5,
+ text: "子项1",
+ value: 51,
+ title: "子项1"
+ }, {
+ id: 52,
+ pId: 5,
+ text: "子项2",
+ value: 52,
+ title: "子项2"
+ }, {
+ id: 61,
+ pId: 6,
+ text: "子项1",
+ value: 61,
+ title: "子项1"
+ }, {
+ id: 62,
+ pId: 6,
+ text: "子项2",
+ value: 62,
+ title: "子项2"
+ }, {
+ id: 71,
+ pId: 7,
+ text: "子项1",
+ value: 71,
+ title: "子项1"
+ }, {
+ id: 72,
+ pId: 7,
+ text: "子项2",
+ value: 72,
+ title: "子项2"
+ }];
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.select_tree_combo",
+ ref: function (_ref) {
+ self.tree = _ref;
+ },
+ text: "默认值",
+ items: items,
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(self.tree.getValue()[0]);
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.select_tree_combo", Demo.SelectTreeCombo);/**
+ * Created by Dailer on 2017/7/14.
+ */
+Demo.SingleSlider = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.single_slider",
+ ref: function (_ref) {
+ self.slider = _ref;
+ },
+ width: 300,
+ height: 50
+ }, {
+ type: "bi.button",
+ text: "populate",
+ handler: function () {
+ self.slider.setMinAndMax({
+ min: 1,
+ max: 100
+ });
+ self.slider.populate();
+ },
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "setValue",
+ handler: function () {
+
+ //既然 setVlaue后要重新 populate 才能生效,为何不直接在 setValue方法的结尾调用 populate 方法呢?
+ self.slider.setValue(50);
+ self.slider.populate();
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.single_slider", Demo.SingleSlider);/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+
+ render: function () {
+ var self = this;
+ var items = BI.deepClone(Demo.CONSTANTS.TREE);
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.multilayer_single_tree_combo",
+ ref: function (_ref) {
+ self.tree = _ref;
+ },
+ text: "默认值",
+ items: items,
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(self.tree.getValue()[0]);
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.multilayer_single_tree_combo", Demo.MultiLayerSingleTreeCombo);/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.SingleTreeCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.single_tree_combo",
+ ref: function (_ref) {
+ self.tree = _ref;
+ },
+ text: "默认值",
+ items: [{
+ id: 1,
+ text: "第一项",
+ value: 1,
+ isParent: true,
+ title: "第一项"
+ }, {
+ id: 2,
+ text: "第二项",
+ value: 1,
+ isParent: true,
+ title: "第二项"
+ }, {
+ id: 3,
+ text: "第三项",
+ value: 1,
+ isParent: true,
+ open: true,
+ title: "第三项"
+ }, {
+ id: 4,
+ text: "第四项",
+ value: 1,
+ isParent: true,
+ title: "第四项"
+ }, {
+ id: 5,
+ text: "第五项",
+ value: 1,
+ isParent: true,
+ title: "第五项"
+ }, {
+ id: 6,
+ text: "第六项",
+ value: 1,
+ isParent: true,
+ open: true,
+ title: "第六项"
+ }, {
+ id: 7,
+ text: "第七项",
+ value: 1,
+ isParent: true,
+ open: true,
+ title: "第七项"
+ }, {
+ id: 11,
+ pId: 1,
+ text: "子项1",
+ value: 11,
+ title: "子项1"
+ }, {
+ id: 12,
+ pId: 1,
+ text: "子项2",
+ value: 12,
+ title: "子项2"
+ }, {
+ id: 13,
+ pId: 1,
+ text: "子项3",
+ value: 13,
+ title: "子项3"
+ }, {
+ id: 21,
+ pId: 2,
+ text: "子项1",
+ value: 21,
+ title: "子项1"
}, {
- "region": "c6d72d6c7e19a667",
- "regionText": "供应商基本信息",
- "text": "ID",
- "value": "5"
- }], [{
- "region": "ed013e18cc7c8637",
- "regionText": "采购订单XXX",
- "text": "ID",
- "value": "1"
+ id: 22,
+ pId: 2,
+ text: "子项2",
+ value: 22,
+ title: "子项2"
}, {
- "region": "153d75878431f8ee",
- "regionText": "A3",
- "text": "学号",
- "value": "2"
+ id: 31,
+ pId: 3,
+ text: "子项1",
+ value: 31,
+ title: "子项1"
}, {
- "region": "3861fb024c7d7825",
- "regionText": "采购订单",
- "text": "学号",
- "value": "3"
+ id: 32,
+ pId: 3,
+ text: "子项2",
+ value: 32,
+ title: "子项2"
}, {
- "region": "88e3e5071bd10bc5",
- "regionText": "供应商",
- "text": "ID",
- "value": "4"
+ id: 33,
+ pId: 3,
+ text: "子项3",
+ value: 33,
+ title: "子项3"
}, {
- "region": "8476c77ab5c147e0",
- "regionText": "供应商基本信息",
- "text": "ID",
- "value": "5"
- }], [{
- "region": "f00f67fbb9fba6fe",
- "regionText": "采购订单XXX",
- "text": "ID",
- "value": "1"
+ id: 41,
+ pId: 4,
+ text: "子项1",
+ value: 41,
+ title: "子项1"
}, {
- "region": "1e8badf5d5793408",
- "regionText": "A3",
- "text": "学号",
- "value": "2"
+ id: 42,
+ pId: 4,
+ text: "子项2",
+ value: 42,
+ title: "子项2"
}, {
- "region": "de1ebd3d0986a294",
- "regionText": "供应商基本信息",
- "text": "ID",
- "value": "5"
- }]]
- });
- pathchooser.setValue();
- return {
- type: "bi.absolute",
- items: [{
- el: pathchooser,
- left: 100,
- top: 100
+ id: 43,
+ pId: 4,
+ text: "子项3",
+ value: 43,
+ title: "子项3"
+ }, {
+ id: 51,
+ pId: 5,
+ text: "子项1",
+ value: 51,
+ title: "子项1"
+ }, {
+ id: 52,
+ pId: 5,
+ text: "子项2",
+ value: 52,
+ title: "子项2"
+ }, {
+ id: 61,
+ pId: 6,
+ text: "子项1",
+ value: 61,
+ title: "子项1"
+ }, {
+ id: 62,
+ pId: 6,
+ text: "子项2",
+ value: 62,
+ title: "子项2"
+ }, {
+ id: 71,
+ pId: 7,
+ text: "子项1",
+ value: 71,
+ title: "子项1"
+ }, {
+ id: 72,
+ pId: 7,
+ text: "子项2",
+ value: 72,
+ title: "子项2"
+ }],
+ width: 300
}, {
- el: {
- type: "bi.button",
- text: "getValue",
- handler: function () {
- BI.Msg.toast(JSON.stringify(pathchooser.getValue()));
- }
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(self.tree.getValue()[0]);
},
- left: 100,
- bottom: 10
- }]
+ width: 300
+ }],
+ vgap: 20
}
}
-});
-BI.shortcut("demo.path_chooser", Demo.PathChooser);/**
- * Created by User on 2017/3/22.
+})
+
+BI.shortcut("demo.single_tree_combo", Demo.SingleTreeCombo);/**
+ * Created by Dailer on 2017/7/12.
*/
-Demo.RelationView = BI.inherit(BI.Widget, {
+Demo.ExcelTable = BI.inherit(BI.Widget, {
props: {
- baseCls: "demo-relation-view"
+ baseCls: "demo-exceltable"
},
render: function () {
- var relationview = BI.createWidget({
- type: "bi.relation_view",
- items: [
- {
- primary: {
- region: "B", regionText: "比", regionTitle: "bbb", regionHandler: function () {
- alert("a")
- },
-
-
- title: "b2...",
- value: "b2", text: "b2字段",
- handler: function () {
- alert("d")
- }
- },
- foreign: {region: "C", value: "c1", text: "c1字段"}
- },
- {
- primary: {region: "A", value: "a1", text: "a1字段"},
- foreign: {region: "C", value: "c2", text: "c2字段"}
- },
- {
- primary: {region: "C", value: "c3", text: "c3字段"},
- foreign: {region: "D", value: "d1", text: "d1字段"}
- },
- {
- primary: {region: "A", value: "a1", text: "a1字段"},
- foreign: {region: "B", value: "b1", text: "b1字段"}
- },
-
- {
- primary: {region: "X", value: "x1", text: "x1字段"},
- foreign: {region: "Y", value: "y1", text: "y1字段"}
- },
- {
- primary: {region: "X", value: "x2", text: "x2字段"},
- foreign: {region: "Z", value: "z1", text: "z1字段"}
- },
- {
- primary: {region: "X", value: "x2", text: "x2字段"},
- foreign: {region: "B", value: "b1", text: "b1字段"}
- },
- {
- primary: {region: "X33", value: "x233", text: "x233字段"},
- }
- ]
- });
return {
- type: "bi.float_center_adapt",
+ type: "bi.horizontal_auto",
items: [{
- el: relationview
- }]
+ type: "bi.excel_table",
+ columnSize: [200,200,200,200,200],
+ items: [
+ [{
+ type: "bi.label",
+ cls: "layout-bg1",
+ text: "第一行第一列"
+ }, {
+ type: "bi.label",
+ cls: "layout-bg2",
+ text: "第一行第二列"
+ }],
+ [{
+ type: "bi.label",
+ cls: "layout-bg3",
+ text: "第二行第一列"
+ }, {
+ type: "bi.label",
+ cls: "layout-bg4",
+ text: "第二行第二列"
+ }]
+ ]
+ }],
+ width:500
}
}
-});
-BI.shortcut("demo.relation_view", Demo.RelationView);Demo.Func = BI.inherit(BI.Widget, {
+})
+
+BI.shortcut("demo.excel_table", Demo.ExcelTable);Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
@@ -7042,71 +8922,142 @@ BI.shortcut("demo.responsive_table", Demo.Func);Demo.Func = BI.inherit(BI.Widget
}
});
BI.shortcut("demo.sequence_table", Demo.Func);/**
- * Created by User on 2017/3/22.
+ * Created by Dailer on 2017/7/13.
*/
-Demo.MultiSelectCombo = BI.inherit(BI.Widget, {
- props: {},
+Demo.TimeInterval = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
- render: function (vessel) {
- var TREEWITHCHILDREN = [{
- id: -1, value: "根目录", text: "根目录", children: [
- {
- id: 1, value: "第一级目录1", text: "第一级目录1", children: [
- {id: 11, value: "第二级文件1", text: "第二级文件1"},
- {
- id: 12, value: "第二级目录2", text: "第二级目录2", children: [
- {
- id: 121, value: "第三级目录1", text: "第三级目录1", children: [
- {
- id: 1211, value: "第四级目录1", text: "第四级目录1", children: [
- {id: 12111, value: "第五级文件1", text: "第五级文件1"}
- ]
- }
- ]
- },
- {id: 122, value: "第三级文件1", text: "第三级文件1"}
- ]
- }
- ]
+ render: function () {
+ var self = this;
+ var items = BI.deepClone(Demo.CONSTANTS.TREE);
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.time_interval",
+ ref: function (_ref) {
+ self.interval = _ref;
},
- {
- id: 2, value: "第一级目录2", text: "第一级目录2", children: [
- {
- id: 21, value: "第二级目录3", text: "第二级目录3", children: [
- {
- id: 211, value: "第三级目录2", text: "第三级目录2", children: [
- {id: 2111, value: "第四级文件1", text: "第四级文件1"}
- ]
- },
- {id: 212, value: "第三级文件2", text: "第三级文件2"}
- ]
- },
- {id: 22, value: "第二级文件2", text: "第二级文件2"}
- ]
- }
- ]
- }];
- var items = BI.deepClone(TREEWITHCHILDREN);
- var combo = BI.createWidget({
- type: "bi.multilayer_select_tree_combo",
- });
+ width: 300
+ }, {
+ type: "bi.button",
+ text: "getVlaue",
+ handler: function () {
+ BI.Msg.toast(JSON.stringify(self.interval.getValue()));
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.time_interval", Demo.TimeInterval);/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.SwitchTree = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
- combo.populate(items);
+ var items = BI.deepClone(Demo.CONSTANTS.TREE);
return {
- type: "bi.vertical",
- items: [combo, {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.switch_tree",
+ items: items
+ },{
+ type:"bi.button",
+ text:"getValue"
+ }]
+ }
+ }
+})
+
+BI.shortcut("demo.switch_tree", Demo.SwitchTree);/**
+ * Created by Dailer on 2017/7/11.
+ */
+Demo.Year = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "demo-exceltable"
+ },
+ render: function () {
+ return {
+ type: "bi.horizontal_adapt",
+ items: [{
+ type: "bi.year_combo",
+ width: 300
+ }]
+ }
+ }
+})
+
+BI.shortcut("demo.year", Demo.Year);/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.YearMonthCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+
+ var self = this;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.year_month_combo",
+ ref: function (_ref) {
+ self.widget = _ref;
+ },
+ width: 300
+ }, {
type: "bi.button",
- width: 100,
text: "getValue",
handler: function () {
- BI.Msg.alert("", JSON.stringify(combo.getValue()));
- }
+ BI.Msg.toast(JSON.stringify(self.widget.getValue()))
+ },
+ width: 300
}],
- vgap: 100
+ vgap: 20
}
}
-});
-BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiSelectCombo);Demo.CONFIG = Demo.CORE_CONFIG.concat(Demo.BASE_CONFIG).concat(Demo.CASE_CONFIG).concat(Demo.WIDGET_CONFIG).concat(Demo.COMPONENT_CONFIG).concat(Demo.CHART_CONFIG);
+})
+
+BI.shortcut("demo.year_month_combo", Demo.YearMonthCombo);/**
+ * Created by Dailer on 2017/7/13.
+ */
+Demo.YearQuarterCombo = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: ""
+ },
+ render: function () {
+ var self=this;
+ return {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.year_quarter_combo",
+ width: 300,
+ ref:function(_ref){
+ self.widget=_ref;
+ },
+ yearBehaviors: {},
+ quarterBehaviors: {},
+ }, {
+ type: "bi.button",
+ text: "getValue",
+ handler:function(){
+ BI.Msg.toast(JSON.stringify(self.widget.getValue()))
+ },
+ width: 300
+ }],
+ vgap: 20
+ }
+ }
+})
+
+BI.shortcut("demo.year_quarter_combo", Demo.YearQuarterCombo);Demo.CONFIG = Demo.CORE_CONFIG.concat(Demo.BASE_CONFIG).concat(Demo.CASE_CONFIG).concat(Demo.WIDGET_CONFIG).concat(Demo.COMPONENT_CONFIG).concat(Demo.CHART_CONFIG);
Demo.CONSTANTS = {
ITEMS: BI.map("柳州市城贸金属材料有限责任公司 柳州市建福房屋租赁有限公司 柳州市迅昌数码办公设备有限责任公司 柳州市河海贸易有限责任公司 柳州市花篮制衣厂 柳州市兴溪物资有限公司 柳州市针织总厂 柳州市衡管物资有限公司 柳州市琪成机电设备有限公司 柳州市松林工程机械修理厂 柳州市积玉贸易有限公司 柳州市福运来贸易有限责任公司 柳州市钢义物资有限公司 柳州市洋力化工有限公司 柳州市悦盛贸易有限公司 柳州市雁城钢管物资有限公司 柳州市恒瑞钢材经营部 柳州市科拓电子有限公司 柳州市九方电子有限公司 柳州市桂龙汽车配件厂 柳州市制鞋工厂 柳州市炜力科贸有限公司 柳州市希翼贸易有限公司 柳州市兆金物资有限公司 柳州市和润电子科技有限责任公司 柳州市汇凯贸易有限公司 柳州市好机汇商贸有限公司 柳州市泛源商贸经营部 柳州市利汇达物资有限公司 广西全民药业有限责任公司 柳州超凡物资贸易有限责任公司 柳州市贵宏物资有限责任公司 柳州昊恒贸易有限责任公司 柳州市浦联物资有限公司 柳州市广通园林绿化工程有限责任公司 柳州市松发物资贸易有限责任公司 柳州市奥士达办公设备有限责任公司 柳州市海泰物资有限公司 柳州市金三环针织厂 柳州市钢贸物资有限公司 柳州市明阳纺织有限公司 柳州市世科科技发展有限公司 柳州市禄羊贸易有限公司 柳州市金兆阳商贸有限公司 柳州市汇昌物资经营部 柳州市林泰金属物资供应站 柳州市自来水管道材料设备公司 柳州市丹柳铝板有限公司 柳州市桂冶物资有限公司 柳州市宸业物资经营部 柳州市耀成贸易有限公司 柳州奥易自动化科技有限公司 柳州市萃丰科技有限责任公司 柳州市华储贸易有限责任公司 柳州市黄颜钢材有限责任公司 柳州市银盛物资有限责任公司 柳州市新仪化玻供应站 柳州市晶凯化工有限公司 广西柳州市柳江包装纸厂 柳州市志新物资有限责任公司 柳州市兆钢物资有限公司 柳州市友方科技发展有限责任公司 柳州市缝纫机台板家具总厂 柳州市晖海数码办公设备有限责任公司 柳州市富兰特服饰有限责任公司 柳州市柳北区富兴物资经营部 柳州市柳锌福利厂 柳州市海泉印刷有限责任公司 柳州市乾亨贸易有限公司 柳州市悦宁物资贸易有限公司 柳州市昊天贸易有限公司 广西惠字钢铁有限公司 柳州市名青物资有限公司 柳州市林郝物资有限公司 柳州市民政服装厂 柳州市多维劳保用品厂 柳州市轻工物资供应公司 柳州市程源物资有限责任公司 柳州市寿丰物资贸易有限责任公司 柳州市凯凡物资有限公司 柳州市利晖物资经营部 柳州市恒茂金属物资供应站 柳州市中储物资经营部 柳州市第二医疗器械厂 柳州市来鑫物资经营部 柳州市钢鑫物资贸易有限责任公司 柳州市双合袜业有限责任公司 柳州市茂松经贸有限责任公司 柳州市行行物资贸易有限公司 柳州市方一物资有限公司 柳州成异钢管销售有限公司 柳州广惠佳电脑有限公司 桂林市圣泽鑫物资有限公司柳州分公司 柳州市砼基建材贸易有限公司 柳州市海燕针织厂 上海浦光仪表厂柳州销售处 柳州市能电工贸有限责任公司 柳州市广贸物资有限公司 柳州市柳北区大昌电工灯饰经营部 柳州市金龙印务有限公司 柳州市奇缘婚典服务有限公司 柳州市盛博物资经营部 柳州市项元钢铁贸易有限公司 柳州市虞美人化妆品经营部 柳州市俊彦鞋厂 柳州市聚源特钢有限公司 柳州市迅龙科贸有限责任公司 柳州市恒飞电子有限责任公司 柳州市蓝正现代办公设备有限责任公司 柳州地区农业生产资料公司 柳州华菱钢管销售有限公司 柳州融通物资有限公司 柳州市可仁广告策划有限责任公司 柳州市鸟鑫物资有限责任公司 柳州市五丰钢材供应站 柳州市金江不锈钢有限公司 柳州市美日物资设备有限责任公司 柳州市鑫东物资贸易有限责任公司 柳州地区日用杂品公司 柳州市华纳物资贸易有限公司 柳州乾利金虹物资贸易有限责任公司 柳州市新迈计算机有限公司 柳州市富丽实业发展公司 柳州市石钢金属材料有限公司 柳州市力志传真机销售有限公司 广西宝森投资有限公司 柳州市嵘基商贸有限公司 柳州市景民商贸有限责任公司 柳州市银桥化玻有限责任公司 柳州市宏文糖烟店 柳州市科苑电脑网络有限公司 柳州市两面针旅游用品厂 柳州市立早室内装璜有限责任公司 柳州地化建材有限公司 柳州市涛达贸易有限公司 柳州市兰丰档案服务中心 柳州市惠贸物资有限责任公司 柳州市立文物资有限责任公司 柳州市致和商贸经营部 柳州市金色阳光信息咨询有限公司 柳州市赛利钢材经销部 柳州市日用化工厂 柳州市昆廷物资有限责任公司 柳州市邦盛贸易有限公司 柳州市济华贸易有限公司 柳州昕威橡塑化工经营部 柳州市联业贸易有限公司 柳州市兰钢贸易有限公司 柳州市子欣科技有限公司 柳州市狄龙机电设备有限公司 柳州市方真物资贸易有限公司 柳州市银鸥废旧回收中心 柳州市冠宝贸易有限公司 柳州市鑫盛德商务咨询有限责任公司 柳州市泰汇银通经贸有限公司 广西瀚维智测科技有限公司 柳州市钓鱼郎制衣有限责任公司 柳州溪水物资有限公司 柳州市融峰物资有限责任公司 广西新地科技有限责任公司 柳州市纺织装饰公司 柳州市粤翔冶金炉料有限公司 柳州市远腾贸易有限公司 柳州市东鸿城市改造有限公司 广西丛欣实业有限公司 柳州市服装厂 柳州市立安联合刀片有限公司 广西国扬投资有限责任公司 柳州市铭泰办公设备公司 柳州市桂钢物资供应站 柳州市昱升物资有限责任公司 柳州市鹰飞灿科贸有限公司 柳州市先导科贸有限公司 柳州市金秋建材物资经营部 柳州市童装厂 柳州市民泽物资有限公司 柳州市恒先物资贸易有限公司 柳州市银夏冷气工程有限责任公司 柳州粮食批发有限责任公司 柳州市金银华窗纱制造有限责任公司 柳州市三方贸易有限公司 柳州市丰涛商贸有限责任公司 柳州华智企业管理咨询有限责任公司 柳州市诚正建筑工程施工图审查有限公司 柳州市今科电讯设备营销中心 柳州市闽德电子有限公司 柳州市鑫虹针织厂 柳州市畅通通讯器材有限责任公司 柳州市正钢物资经营部 柳州市新柳饲料有限责任公司 柳州市黄村油库 柳州市天泰电力装饰工程有限公司 柳州市兆吉物资有限责任公司 柳州市八龙纸制品有限责任公司 柳州市巨佳电脑网络科技有限公司 ".match(/[^\s]+/g), function (i, v) {
@@ -7116,6 +9067,21 @@ Demo.CONSTANTS = {
title: v
}
}),
- TREEITEMS: [{"pId":"0","id":"0_0","text":"( 共25个 )","value":"","open":true},{"pId":"0_0","id":"0_0_0","text":"安徽省( 共1个 )","value":"安徽省","open":true},{"pId":"0_0_0","id":"0_0_0_0","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_0","id":"0_0_1","text":"北京市( 共6个 )","value":"北京市","open":true},{"pId":"0_0_1","id":"0_0_1_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_0_1","id":"0_0_1_1","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_0_1","id":"0_0_1_2","text":"东城区","value":"东城区","open":true},{"pId":"0_0_1","id":"0_0_1_3","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_0_1","id":"0_0_1_4","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_0_1","id":"0_0_1_5","text":"石景山区","value":"石景山区","open":true},{"pId":"0_0","id":"0_0_2","text":"福建省( 共2个 )","value":"福建省","open":true},{"pId":"0_0_2","id":"0_0_2_0","text":"莆田市","value":"莆田市","open":true},{"pId":"0_0_2","id":"0_0_2_1","text":"泉州市","value":"泉州市","open":true},{"pId":"0_0","id":"0_0_3","text":"甘肃省( 共1个 )","value":"甘肃省","open":true},{"pId":"0_0_3","id":"0_0_3_0","text":"兰州市","value":"兰州市","open":true},{"pId":"0_0","id":"0_0_4","text":"广东省( 共5个 )","value":"广东省","open":true},{"pId":"0_0_4","id":"0_0_4_0","text":"东莞市","value":"东莞市","open":true},{"pId":"0_0_4","id":"0_0_4_1","text":"广州市","value":"广州市","open":true},{"pId":"0_0_4","id":"0_0_4_2","text":"惠州市","value":"惠州市","open":true},{"pId":"0_0_4","id":"0_0_4_3","text":"深圳市","value":"深圳市","open":true},{"pId":"0_0_4","id":"0_0_4_4","text":"珠海市","value":"珠海市","open":true},{"pId":"0_0","id":"0_0_5","text":"广西壮族自治区( 共1个 )","value":"广西壮族自治区","open":true},{"pId":"0_0_5","id":"0_0_5_0","text":"南宁市","value":"南宁市","open":true},{"pId":"0_0","id":"0_0_6","text":"河北省( 共2个 )","value":"河北省","open":true},{"pId":"0_0_6","id":"0_0_6_0","text":"保定市","value":"保定市","open":true},{"pId":"0_0_6","id":"0_0_6_1","text":"邢台市","value":"邢台市","open":true},{"pId":"0_0","id":"0_0_7","text":"河南省( 共1个 )","value":"河南省","open":true},{"pId":"0_0_7","id":"0_0_7_0","text":"郑州市","value":"郑州市","open":true},{"pId":"0_0","id":"0_0_8","text":"黑龙江省( 共7个 )","value":"黑龙江省","open":true},{"pId":"0_0_8","id":"0_0_8_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_0_8","id":"0_0_8_1","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_0_8","id":"0_0_8_2","text":"鸡西市","value":"鸡西市","open":true},{"pId":"0_0_8","id":"0_0_8_3","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_0_8","id":"0_0_8_4","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_0_8","id":"0_0_8_5","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_0_8","id":"0_0_8_6","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_0","id":"0_0_9","text":"湖北省( 共1个 )","value":"湖北省","open":true},{"pId":"0_0_9","id":"0_0_9_0","text":"武汉市","value":"武汉市","open":true},{"pId":"0_0","id":"0_0_10","text":"湖南省( 共3个 )","value":"湖南省","open":true},{"pId":"0_0_10","id":"0_0_10_0","text":"常德市","value":"常德市","open":true},{"pId":"0_0_10","id":"0_0_10_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_0_10","id":"0_0_10_2","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_0","id":"0_0_11","text":"吉林省( 共4个 )","value":"吉林省","open":true},{"pId":"0_0_11","id":"0_0_11_0","text":"白山市","value":"白山市","open":true},{"pId":"0_0_11","id":"0_0_11_1","text":"长春市","value":"长春市","open":true},{"pId":"0_0_11","id":"0_0_11_2","text":"松原市","value":"松原市","open":true},{"pId":"0_0_11","id":"0_0_11_3","text":"通化市","value":"通化市","open":true},{"pId":"0_0","id":"0_0_12","text":"江苏省( 共8个 )","value":"江苏省","open":true},{"pId":"0_0_12","id":"0_0_12_0","text":"常州市","value":"常州市","open":true},{"pId":"0_0_12","id":"0_0_12_1","text":"南京市","value":"南京市","open":true},{"pId":"0_0_12","id":"0_0_12_2","text":"南通市","value":"南通市","open":true},{"pId":"0_0_12","id":"0_0_12_3","text":"苏州市","value":"苏州市","open":true},{"pId":"0_0_12","id":"0_0_12_4","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_0_12","id":"0_0_12_5","text":"泰州市","value":"泰州市","open":true},{"pId":"0_0_12","id":"0_0_12_6","text":"无锡市","value":"无锡市","open":true},{"pId":"0_0_12","id":"0_0_12_7","text":"盐城市","value":"盐城市","open":true},{"pId":"0_0","id":"0_0_13","text":"辽宁省( 共11个 )","value":"辽宁省","open":true},{"pId":"0_0_13","id":"0_0_13_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_0_13","id":"0_0_13_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_0_13","id":"0_0_13_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_0_13","id":"0_0_13_3","text":"大连市","value":"大连市","open":true},{"pId":"0_0_13","id":"0_0_13_4","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_0_13","id":"0_0_13_5","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_0_13","id":"0_0_13_6","text":"锦州市","value":"锦州市","open":true},{"pId":"0_0_13","id":"0_0_13_7","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_0_13","id":"0_0_13_8","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_0_13","id":"0_0_13_9","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_0_13","id":"0_0_13_10","text":"营口市","value":"营口市","open":true},{"pId":"0_0","id":"0_0_14","text":"内蒙古( 共1个 )","value":"内蒙古","open":true},{"pId":"0_0_14","id":"0_0_14_0","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_0","id":"0_0_15","text":"宁夏回族自治区( 共1个 )","value":"宁夏回族自治区","open":true},{"pId":"0_0_15","id":"0_0_15_0","text":"银川市","value":"银川市","open":true},{"pId":"0_0","id":"0_0_16","text":"山东省( 共7个 )","value":"山东省","open":true},{"pId":"0_0_16","id":"0_0_16_0","text":"济南市","value":"济南市","open":true},{"pId":"0_0_16","id":"0_0_16_1","text":"济宁市","value":"济宁市","open":true},{"pId":"0_0_16","id":"0_0_16_2","text":"聊城市","value":"聊城市","open":true},{"pId":"0_0_16","id":"0_0_16_3","text":"临沂市","value":"临沂市","open":true},{"pId":"0_0_16","id":"0_0_16_4","text":"青岛市","value":"青岛市","open":true},{"pId":"0_0_16","id":"0_0_16_5","text":"烟台市","value":"烟台市","open":true},{"pId":"0_0_16","id":"0_0_16_6","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_0","id":"0_0_17","text":"山西省( 共1个 )","value":"山西省","open":true},{"pId":"0_0_17","id":"0_0_17_0","text":"太原市","value":"太原市","open":true},{"pId":"0_0","id":"0_0_18","text":"陕西省( 共1个 )","value":"陕西省","open":true},{"pId":"0_0_18","id":"0_0_18_0","text":"西安市","value":"西安市","open":true},{"pId":"0_0","id":"0_0_19","text":"上海市( 共1个 )","value":"上海市","open":true},{"pId":"0_0_19","id":"0_0_19_0","text":"上海市区","value":"上海市区","open":true},{"pId":"0_0","id":"0_0_20","text":"四川省( 共1个 )","value":"四川省","open":true},{"pId":"0_0_20","id":"0_0_20_0","text":"成都市","value":"成都市","open":true},{"pId":"0_0","id":"0_0_21","text":"新疆维吾尔族自治区( 共2个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_0_21","id":"0_0_21_0","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_0_21","id":"0_0_21_1","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_0","id":"0_0_22","text":"云南省( 共1个 )","value":"云南省","open":true},{"pId":"0_0_22","id":"0_0_22_0","text":"昆明市","value":"昆明市","open":true},{"pId":"0_0","id":"0_0_23","text":"浙江省( 共5个 )","value":"浙江省","open":true},{"pId":"0_0_23","id":"0_0_23_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_0_23","id":"0_0_23_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_0_23","id":"0_0_23_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_0_23","id":"0_0_23_3","text":"宁波市","value":"宁波市","open":true},{"pId":"0_0_23","id":"0_0_23_4","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_0","id":"0_0_24","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_0_24","id":"0_0_24_0","text":"重庆市区","value":"重庆市区","open":true},{"pId":"0","id":"0_1","text":"中国( 共34个 )","value":"中国","open":true},{"pId":"0_1","id":"0_1_0","text":"安徽省( 共19个 )","value":"安徽省","open":true},{"pId":"0_1_0","id":"0_1_0_0","text":"安庆市","value":"安庆市","open":true},{"pId":"0_1_0","id":"0_1_0_1","text":"蚌埠市","value":"蚌埠市","open":true},{"pId":"0_1_0","id":"0_1_0_2","text":"亳州市","value":"亳州市","open":true},{"pId":"0_1_0","id":"0_1_0_3","text":"巢湖市","value":"巢湖市","open":true},{"pId":"0_1_0","id":"0_1_0_4","text":"池州市","value":"池州市","open":true},{"pId":"0_1_0","id":"0_1_0_5","text":"滁州市","value":"滁州市","open":true},{"pId":"0_1_0","id":"0_1_0_6","text":"阜阳市","value":"阜阳市","open":true},{"pId":"0_1_0","id":"0_1_0_7","text":"毫州市","value":"毫州市","open":true},{"pId":"0_1_0","id":"0_1_0_8","text":"合肥市","value":"合肥市","open":true},{"pId":"0_1_0","id":"0_1_0_9","text":"淮北市","value":"淮北市","open":true},{"pId":"0_1_0","id":"0_1_0_10","text":"淮南市","value":"淮南市","open":true},{"pId":"0_1_0","id":"0_1_0_11","text":"黄山市","value":"黄山市","open":true},{"pId":"0_1_0","id":"0_1_0_12","text":"六安市","value":"六安市","open":true},{"pId":"0_1_0","id":"0_1_0_13","text":"马鞍山市","value":"马鞍山市","open":true},{"pId":"0_1_0","id":"0_1_0_14","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_0","id":"0_1_0_15","text":"宿州市","value":"宿州市","open":true},{"pId":"0_1_0","id":"0_1_0_16","text":"铜陵市","value":"铜陵市","open":true},{"pId":"0_1_0","id":"0_1_0_17","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_1_0","id":"0_1_0_18","text":"宣城市","value":"宣城市","open":true},{"pId":"0_1","id":"0_1_1","text":"澳门特别行政区( 共1个 )","value":"澳门特别行政区","open":true},{"pId":"0_1_1","id":"0_1_1_0","text":"澳门","value":"澳门","open":true},{"pId":"0_1","id":"0_1_2","text":"北京市( 共17个 )","value":"北京市","open":true},{"pId":"0_1_2","id":"0_1_2_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_1_2","id":"0_1_2_1","text":"昌平区","value":"昌平区","open":true},{"pId":"0_1_2","id":"0_1_2_2","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_1_2","id":"0_1_2_3","text":"大兴区","value":"大兴区","open":true},{"pId":"0_1_2","id":"0_1_2_4","text":"东城区","value":"东城区","open":true},{"pId":"0_1_2","id":"0_1_2_5","text":"房山区","value":"房山区","open":true},{"pId":"0_1_2","id":"0_1_2_6","text":"丰台区","value":"丰台区","open":true},{"pId":"0_1_2","id":"0_1_2_7","text":"海淀区","value":"海淀区","open":true},{"pId":"0_1_2","id":"0_1_2_8","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_1_2","id":"0_1_2_9","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_1_2","id":"0_1_2_10","text":"门头沟区","value":"门头沟区","open":true},{"pId":"0_1_2","id":"0_1_2_11","text":"平谷区","value":"平谷区","open":true},{"pId":"0_1_2","id":"0_1_2_12","text":"石景山区","value":"石景山区","open":true},{"pId":"0_1_2","id":"0_1_2_13","text":"顺义区","value":"顺义区","open":true},{"pId":"0_1_2","id":"0_1_2_14","text":"通州区","value":"通州区","open":true},{"pId":"0_1_2","id":"0_1_2_15","text":"西城区","value":"西城区","open":true},{"pId":"0_1_2","id":"0_1_2_16","text":"西城区 ","value":"西城区 ","open":true},{"pId":"0_1","id":"0_1_3","text":"福建省( 共9个 )","value":"福建省","open":true},{"pId":"0_1_3","id":"0_1_3_0","text":"福州市","value":"福州市","open":true},{"pId":"0_1_3","id":"0_1_3_1","text":"龙岩市","value":"龙岩市","open":true},{"pId":"0_1_3","id":"0_1_3_2","text":"南平市","value":"南平市","open":true},{"pId":"0_1_3","id":"0_1_3_3","text":"宁德市","value":"宁德市","open":true},{"pId":"0_1_3","id":"0_1_3_4","text":"莆田市","value":"莆田市","open":true},{"pId":"0_1_3","id":"0_1_3_5","text":"泉州市","value":"泉州市","open":true},{"pId":"0_1_3","id":"0_1_3_6","text":"三明市","value":"三明市","open":true},{"pId":"0_1_3","id":"0_1_3_7","text":"厦门市","value":"厦门市","open":true},{"pId":"0_1_3","id":"0_1_3_8","text":"漳州市","value":"漳州市","open":true},{"pId":"0_1","id":"0_1_4","text":"甘肃省( 共12个 )","value":"甘肃省","open":true},{"pId":"0_1_4","id":"0_1_4_0","text":"白银市","value":"白银市","open":true},{"pId":"0_1_4","id":"0_1_4_1","text":"嘉峪关市","value":"嘉峪关市","open":true},{"pId":"0_1_4","id":"0_1_4_2","text":"金昌市","value":"金昌市","open":true},{"pId":"0_1_4","id":"0_1_4_3","text":"酒泉市","value":"酒泉市","open":true},{"pId":"0_1_4","id":"0_1_4_4","text":"兰州市","value":"兰州市","open":true},{"pId":"0_1_4","id":"0_1_4_5","text":"陇南市","value":"陇南市","open":true},{"pId":"0_1_4","id":"0_1_4_6","text":"平凉市","value":"平凉市","open":true},{"pId":"0_1_4","id":"0_1_4_7","text":"庆阳市","value":"庆阳市","open":true},{"pId":"0_1_4","id":"0_1_4_8","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_4","id":"0_1_4_9","text":"天水市","value":"天水市","open":true},{"pId":"0_1_4","id":"0_1_4_10","text":"武威市","value":"武威市","open":true},{"pId":"0_1_4","id":"0_1_4_11","text":"张掖市","value":"张掖市","open":true},{"pId":"0_1","id":"0_1_5","text":"广东省( 共21个 )","value":"广东省","open":true},{"pId":"0_1_5","id":"0_1_5_0","text":"潮州市","value":"潮州市","open":true},{"pId":"0_1_5","id":"0_1_5_1","text":"东莞市","value":"东莞市","open":true},{"pId":"0_1_5","id":"0_1_5_2","text":"佛山市","value":"佛山市","open":true},{"pId":"0_1_5","id":"0_1_5_3","text":"广州市","value":"广州市","open":true},{"pId":"0_1_5","id":"0_1_5_4","text":"河源市","value":"河源市","open":true},{"pId":"0_1_5","id":"0_1_5_5","text":"惠州市","value":"惠州市","open":true},{"pId":"0_1_5","id":"0_1_5_6","text":"江门市","value":"江门市","open":true},{"pId":"0_1_5","id":"0_1_5_7","text":"揭阳市","value":"揭阳市","open":true},{"pId":"0_1_5","id":"0_1_5_8","text":"茂名市","value":"茂名市","open":true},{"pId":"0_1_5","id":"0_1_5_9","text":"梅州市","value":"梅州市","open":true},{"pId":"0_1_5","id":"0_1_5_10","text":"清远市","value":"清远市","open":true},{"pId":"0_1_5","id":"0_1_5_11","text":"汕头市","value":"汕头市","open":true},{"pId":"0_1_5","id":"0_1_5_12","text":"汕尾市","value":"汕尾市","open":true},{"pId":"0_1_5","id":"0_1_5_13","text":"韶关市","value":"韶关市","open":true},{"pId":"0_1_5","id":"0_1_5_14","text":"深圳市","value":"深圳市","open":true},{"pId":"0_1_5","id":"0_1_5_15","text":"阳江市","value":"阳江市","open":true},{"pId":"0_1_5","id":"0_1_5_16","text":"云浮市","value":"云浮市","open":true},{"pId":"0_1_5","id":"0_1_5_17","text":"湛江市","value":"湛江市","open":true},{"pId":"0_1_5","id":"0_1_5_18","text":"肇庆市","value":"肇庆市","open":true},{"pId":"0_1_5","id":"0_1_5_19","text":"中山市","value":"中山市","open":true},{"pId":"0_1_5","id":"0_1_5_20","text":"珠海市","value":"珠海市","open":true},{"pId":"0_1","id":"0_1_6","text":"广西壮族自治区( 共14个 )","value":"广西壮族自治区","open":true},{"pId":"0_1_6","id":"0_1_6_0","text":"百色市","value":"百色市","open":true},{"pId":"0_1_6","id":"0_1_6_1","text":"北海市","value":"北海市","open":true},{"pId":"0_1_6","id":"0_1_6_2","text":"崇左市","value":"崇左市","open":true},{"pId":"0_1_6","id":"0_1_6_3","text":"防城港市","value":"防城港市","open":true},{"pId":"0_1_6","id":"0_1_6_4","text":"桂林市","value":"桂林市","open":true},{"pId":"0_1_6","id":"0_1_6_5","text":"贵港市","value":"贵港市","open":true},{"pId":"0_1_6","id":"0_1_6_6","text":"河池市","value":"河池市","open":true},{"pId":"0_1_6","id":"0_1_6_7","text":"贺州市","value":"贺州市","open":true},{"pId":"0_1_6","id":"0_1_6_8","text":"来宾市","value":"来宾市","open":true},{"pId":"0_1_6","id":"0_1_6_9","text":"柳州市","value":"柳州市","open":true},{"pId":"0_1_6","id":"0_1_6_10","text":"南宁市","value":"南宁市","open":true},{"pId":"0_1_6","id":"0_1_6_11","text":"钦州市","value":"钦州市","open":true},{"pId":"0_1_6","id":"0_1_6_12","text":"梧州市","value":"梧州市","open":true},{"pId":"0_1_6","id":"0_1_6_13","text":"玉林市","value":"玉林市","open":true},{"pId":"0_1","id":"0_1_7","text":"贵州省( 共9个 )","value":"贵州省","open":true},{"pId":"0_1_7","id":"0_1_7_0","text":"安顺市","value":"安顺市","open":true},{"pId":"0_1_7","id":"0_1_7_1","text":"毕节地区","value":"毕节地区","open":true},{"pId":"0_1_7","id":"0_1_7_2","text":"贵阳市","value":"贵阳市","open":true},{"pId":"0_1_7","id":"0_1_7_3","text":"六盘水市","value":"六盘水市","open":true},{"pId":"0_1_7","id":"0_1_7_4","text":"黔东南州","value":"黔东南州","open":true},{"pId":"0_1_7","id":"0_1_7_5","text":"黔南州","value":"黔南州","open":true},{"pId":"0_1_7","id":"0_1_7_6","text":"黔西南市","value":"黔西南市","open":true},{"pId":"0_1_7","id":"0_1_7_7","text":"铜仁地区","value":"铜仁地区","open":true},{"pId":"0_1_7","id":"0_1_7_8","text":"遵义市","value":"遵义市","open":true},{"pId":"0_1","id":"0_1_8","text":"海南省( 共2个 )","value":"海南省","open":true},{"pId":"0_1_8","id":"0_1_8_0","text":"海口市","value":"海口市","open":true},{"pId":"0_1_8","id":"0_1_8_1","text":"三亚市","value":"三亚市","open":true},{"pId":"0_1","id":"0_1_9","text":"河北省( 共12个 )","value":"河北省","open":true},{"pId":"0_1_9","id":"0_1_9_0","text":"保定市","value":"保定市","open":true},{"pId":"0_1_9","id":"0_1_9_1","text":"沧州市","value":"沧州市","open":true},{"pId":"0_1_9","id":"0_1_9_2","text":"承德市","value":"承德市","open":true},{"pId":"0_1_9","id":"0_1_9_3","text":"邯郸市","value":"邯郸市","open":true},{"pId":"0_1_9","id":"0_1_9_4","text":"衡水市","value":"衡水市","open":true},{"pId":"0_1_9","id":"0_1_9_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_9","id":"0_1_9_6","text":"秦皇岛市","value":"秦皇岛市","open":true},{"pId":"0_1_9","id":"0_1_9_7","text":"石家庄市","value":"石家庄市","open":true},{"pId":"0_1_9","id":"0_1_9_8","text":"唐山市","value":"唐山市","open":true},{"pId":"0_1_9","id":"0_1_9_9","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_9","id":"0_1_9_10","text":"邢台市","value":"邢台市","open":true},{"pId":"0_1_9","id":"0_1_9_11","text":"张家口市","value":"张家口市","open":true},{"pId":"0_1","id":"0_1_10","text":"河南省( 共19个 )","value":"河南省","open":true},{"pId":"0_1_10","id":"0_1_10_0","text":"安阳市","value":"安阳市","open":true},{"pId":"0_1_10","id":"0_1_10_1","text":"鹤壁市","value":"鹤壁市","open":true},{"pId":"0_1_10","id":"0_1_10_2","text":"济源市","value":"济源市","open":true},{"pId":"0_1_10","id":"0_1_10_3","text":"焦作市","value":"焦作市","open":true},{"pId":"0_1_10","id":"0_1_10_4","text":"开封市","value":"开封市","open":true},{"pId":"0_1_10","id":"0_1_10_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_10","id":"0_1_10_6","text":"洛阳市","value":"洛阳市","open":true},{"pId":"0_1_10","id":"0_1_10_7","text":"漯河市","value":"漯河市","open":true},{"pId":"0_1_10","id":"0_1_10_8","text":"南阳市","value":"南阳市","open":true},{"pId":"0_1_10","id":"0_1_10_9","text":"平顶山市","value":"平顶山市","open":true},{"pId":"0_1_10","id":"0_1_10_10","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_10","id":"0_1_10_11","text":"三门峡市","value":"三门峡市","open":true},{"pId":"0_1_10","id":"0_1_10_12","text":"商丘市","value":"商丘市","open":true},{"pId":"0_1_10","id":"0_1_10_13","text":"新乡市","value":"新乡市","open":true},{"pId":"0_1_10","id":"0_1_10_14","text":"信阳市","value":"信阳市","open":true},{"pId":"0_1_10","id":"0_1_10_15","text":"许昌市","value":"许昌市","open":true},{"pId":"0_1_10","id":"0_1_10_16","text":"郑州市","value":"郑州市","open":true},{"pId":"0_1_10","id":"0_1_10_17","text":"周口市","value":"周口市","open":true},{"pId":"0_1_10","id":"0_1_10_18","text":"驻马店市","value":"驻马店市","open":true},{"pId":"0_1","id":"0_1_11","text":"黑龙江省( 共13个 )","value":"黑龙江省","open":true},{"pId":"0_1_11","id":"0_1_11_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_11","id":"0_1_11_1","text":"大兴安岭地区","value":"大兴安岭地区","open":true},{"pId":"0_1_11","id":"0_1_11_2","text":"大兴安岭市","value":"大兴安岭市","open":true},{"pId":"0_1_11","id":"0_1_11_3","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_1_11","id":"0_1_11_4","text":"鹤港市","value":"鹤港市","open":true},{"pId":"0_1_11","id":"0_1_11_5","text":"黑河市","value":"黑河市","open":true},{"pId":"0_1_11","id":"0_1_11_6","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_1_11","id":"0_1_11_7","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_1_11","id":"0_1_11_8","text":"七台河市","value":"七台河市","open":true},{"pId":"0_1_11","id":"0_1_11_9","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_1_11","id":"0_1_11_10","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_1_11","id":"0_1_11_11","text":"绥化市","value":"绥化市","open":true},{"pId":"0_1_11","id":"0_1_11_12","text":"伊春市","value":"伊春市","open":true},{"pId":"0_1","id":"0_1_12","text":"湖北省( 共16个 )","value":"湖北省","open":true},{"pId":"0_1_12","id":"0_1_12_0","text":"鄂州市","value":"鄂州市","open":true},{"pId":"0_1_12","id":"0_1_12_1","text":"恩施土家族苗族自治州","value":"恩施土家族苗族自治州","open":true},{"pId":"0_1_12","id":"0_1_12_2","text":"黄冈市","value":"黄冈市","open":true},{"pId":"0_1_12","id":"0_1_12_3","text":"黄石市","value":"黄石市","open":true},{"pId":"0_1_12","id":"0_1_12_4","text":"荆门市","value":"荆门市","open":true},{"pId":"0_1_12","id":"0_1_12_5","text":"荆州市","value":"荆州市","open":true},{"pId":"0_1_12","id":"0_1_12_6","text":"神农架市","value":"神农架市","open":true},{"pId":"0_1_12","id":"0_1_12_7","text":"十堰市","value":"十堰市","open":true},{"pId":"0_1_12","id":"0_1_12_8","text":"随州市","value":"随州市","open":true},{"pId":"0_1_12","id":"0_1_12_9","text":"天门市","value":"天门市","open":true},{"pId":"0_1_12","id":"0_1_12_10","text":"武汉市","value":"武汉市","open":true},{"pId":"0_1_12","id":"0_1_12_11","text":"咸宁市","value":"咸宁市","open":true},{"pId":"0_1_12","id":"0_1_12_12","text":"襄樊市","value":"襄樊市","open":true},{"pId":"0_1_12","id":"0_1_12_13","text":"襄阳市","value":"襄阳市","open":true},{"pId":"0_1_12","id":"0_1_12_14","text":"孝感市","value":"孝感市","open":true},{"pId":"0_1_12","id":"0_1_12_15","text":"宜昌市","value":"宜昌市","open":true},{"pId":"0_1","id":"0_1_13","text":"湖南省( 共15个 )","value":"湖南省","open":true},{"pId":"0_1_13","id":"0_1_13_0","text":"常德市","value":"常德市","open":true},{"pId":"0_1_13","id":"0_1_13_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_1_13","id":"0_1_13_2","text":"郴州市","value":"郴州市","open":true},{"pId":"0_1_13","id":"0_1_13_3","text":"衡阳市","value":"衡阳市","open":true},{"pId":"0_1_13","id":"0_1_13_4","text":"怀化市","value":"怀化市","open":true},{"pId":"0_1_13","id":"0_1_13_5","text":"娄底市","value":"娄底市","open":true},{"pId":"0_1_13","id":"0_1_13_6","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_1_13","id":"0_1_13_7","text":"湘潭市","value":"湘潭市","open":true},{"pId":"0_1_13","id":"0_1_13_8","text":"湘西市","value":"湘西市","open":true},{"pId":"0_1_13","id":"0_1_13_9","text":"湘西土家族苗族自治州","value":"湘西土家族苗族自治州","open":true},{"pId":"0_1_13","id":"0_1_13_10","text":"益阳市","value":"益阳市","open":true},{"pId":"0_1_13","id":"0_1_13_11","text":"永州市","value":"永州市","open":true},{"pId":"0_1_13","id":"0_1_13_12","text":"岳阳市","value":"岳阳市","open":true},{"pId":"0_1_13","id":"0_1_13_13","text":"张家界市","value":"张家界市","open":true},{"pId":"0_1_13","id":"0_1_13_14","text":"株洲市","value":"株洲市","open":true},{"pId":"0_1","id":"0_1_14","text":"吉林省( 共10个 )","value":"吉林省","open":true},{"pId":"0_1_14","id":"0_1_14_0","text":"白城市","value":"白城市","open":true},{"pId":"0_1_14","id":"0_1_14_1","text":"白山市","value":"白山市","open":true},{"pId":"0_1_14","id":"0_1_14_2","text":"长春市","value":"长春市","open":true},{"pId":"0_1_14","id":"0_1_14_3","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_14","id":"0_1_14_4","text":"吉林市","value":"吉林市","open":true},{"pId":"0_1_14","id":"0_1_14_5","text":"辽源市","value":"辽源市","open":true},{"pId":"0_1_14","id":"0_1_14_6","text":"四平市","value":"四平市","open":true},{"pId":"0_1_14","id":"0_1_14_7","text":"松原市","value":"松原市","open":true},{"pId":"0_1_14","id":"0_1_14_8","text":"通化市","value":"通化市","open":true},{"pId":"0_1_14","id":"0_1_14_9","text":"延边朝鲜族自治州","value":"延边朝鲜族自治州","open":true},{"pId":"0_1","id":"0_1_15","text":"江苏省( 共13个 )","value":"江苏省","open":true},{"pId":"0_1_15","id":"0_1_15_0","text":"常州市","value":"常州市","open":true},{"pId":"0_1_15","id":"0_1_15_1","text":"淮安市","value":"淮安市","open":true},{"pId":"0_1_15","id":"0_1_15_2","text":"连云港市","value":"连云港市","open":true},{"pId":"0_1_15","id":"0_1_15_3","text":"南京市","value":"南京市","open":true},{"pId":"0_1_15","id":"0_1_15_4","text":"南通市","value":"南通市","open":true},{"pId":"0_1_15","id":"0_1_15_5","text":"苏州市","value":"苏州市","open":true},{"pId":"0_1_15","id":"0_1_15_6","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_1_15","id":"0_1_15_7","text":"泰州市","value":"泰州市","open":true},{"pId":"0_1_15","id":"0_1_15_8","text":"无锡市","value":"无锡市","open":true},{"pId":"0_1_15","id":"0_1_15_9","text":"徐州市","value":"徐州市","open":true},{"pId":"0_1_15","id":"0_1_15_10","text":"盐城市","value":"盐城市","open":true},{"pId":"0_1_15","id":"0_1_15_11","text":"扬州市","value":"扬州市","open":true},{"pId":"0_1_15","id":"0_1_15_12","text":"镇江市","value":"镇江市","open":true},{"pId":"0_1","id":"0_1_16","text":"江西省( 共10个 )","value":"江西省","open":true},{"pId":"0_1_16","id":"0_1_16_0","text":"抚州市","value":"抚州市","open":true},{"pId":"0_1_16","id":"0_1_16_1","text":"赣州市","value":"赣州市","open":true},{"pId":"0_1_16","id":"0_1_16_2","text":"景德镇市","value":"景德镇市","open":true},{"pId":"0_1_16","id":"0_1_16_3","text":"九江市","value":"九江市","open":true},{"pId":"0_1_16","id":"0_1_16_4","text":"南昌市","value":"南昌市","open":true},{"pId":"0_1_16","id":"0_1_16_5","text":"萍乡市","value":"萍乡市","open":true},{"pId":"0_1_16","id":"0_1_16_6","text":"上饶市","value":"上饶市","open":true},{"pId":"0_1_16","id":"0_1_16_7","text":"新余市","value":"新余市","open":true},{"pId":"0_1_16","id":"0_1_16_8","text":"宜春市","value":"宜春市","open":true},{"pId":"0_1_16","id":"0_1_16_9","text":"鹰潭市","value":"鹰潭市","open":true},{"pId":"0_1","id":"0_1_17","text":"辽宁省( 共14个 )","value":"辽宁省","open":true},{"pId":"0_1_17","id":"0_1_17_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_1_17","id":"0_1_17_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_1_17","id":"0_1_17_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_1_17","id":"0_1_17_3","text":"大连市","value":"大连市","open":true},{"pId":"0_1_17","id":"0_1_17_4","text":"丹东市","value":"丹东市","open":true},{"pId":"0_1_17","id":"0_1_17_5","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_1_17","id":"0_1_17_6","text":"阜新市","value":"阜新市","open":true},{"pId":"0_1_17","id":"0_1_17_7","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_1_17","id":"0_1_17_8","text":"锦州市","value":"锦州市","open":true},{"pId":"0_1_17","id":"0_1_17_9","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_1_17","id":"0_1_17_10","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_1_17","id":"0_1_17_11","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_1_17","id":"0_1_17_12","text":"铁岭市","value":"铁岭市","open":true},{"pId":"0_1_17","id":"0_1_17_13","text":"营口市","value":"营口市","open":true},{"pId":"0_1","id":"0_1_18","text":"内蒙古( 共10个 )","value":"内蒙古","open":true},{"pId":"0_1_18","id":"0_1_18_0","text":"包头市","value":"包头市","open":true},{"pId":"0_1_18","id":"0_1_18_1","text":"赤峰市","value":"赤峰市","open":true},{"pId":"0_1_18","id":"0_1_18_2","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_1_18","id":"0_1_18_3","text":"呼和浩特市","value":"呼和浩特市","open":true},{"pId":"0_1_18","id":"0_1_18_4","text":"呼伦贝尔市","value":"呼伦贝尔市","open":true},{"pId":"0_1_18","id":"0_1_18_5","text":"通辽市","value":"通辽市","open":true},{"pId":"0_1_18","id":"0_1_18_6","text":"乌海市","value":"乌海市","open":true},{"pId":"0_1_18","id":"0_1_18_7","text":"锡林郭勒市","value":"锡林郭勒市","open":true},{"pId":"0_1_18","id":"0_1_18_8","text":"兴安市","value":"兴安市","open":true},{"pId":"0_1_18","id":"0_1_18_9","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_19","text":"宁夏回族自治区( 共5个 )","value":"宁夏回族自治区","open":true},{"pId":"0_1_19","id":"0_1_19_0","text":"固原市","value":"固原市","open":true},{"pId":"0_1_19","id":"0_1_19_1","text":"石嘴山市","value":"石嘴山市","open":true},{"pId":"0_1_19","id":"0_1_19_2","text":"吴忠市","value":"吴忠市","open":true},{"pId":"0_1_19","id":"0_1_19_3","text":"银川市","value":"银川市","open":true},{"pId":"0_1_19","id":"0_1_19_4","text":"中卫市","value":"中卫市","open":true},{"pId":"0_1","id":"0_1_20","text":"青海省( 共4个 )","value":"青海省","open":true},{"pId":"0_1_20","id":"0_1_20_0","text":"海东地区","value":"海东地区","open":true},{"pId":"0_1_20","id":"0_1_20_1","text":"海南藏族自治州","value":"海南藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_2","text":"海西蒙古族藏族自治州","value":"海西蒙古族藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_3","text":"西宁市","value":"西宁市","open":true},{"pId":"0_1","id":"0_1_21","text":"山东省( 共17个 )","value":"山东省","open":true},{"pId":"0_1_21","id":"0_1_21_0","text":"滨州市","value":"滨州市","open":true},{"pId":"0_1_21","id":"0_1_21_1","text":"德州市","value":"德州市","open":true},{"pId":"0_1_21","id":"0_1_21_2","text":"东营市","value":"东营市","open":true},{"pId":"0_1_21","id":"0_1_21_3","text":"菏泽市","value":"菏泽市","open":true},{"pId":"0_1_21","id":"0_1_21_4","text":"济南市","value":"济南市","open":true},{"pId":"0_1_21","id":"0_1_21_5","text":"济宁市","value":"济宁市","open":true},{"pId":"0_1_21","id":"0_1_21_6","text":"莱芜市","value":"莱芜市","open":true},{"pId":"0_1_21","id":"0_1_21_7","text":"聊城市","value":"聊城市","open":true},{"pId":"0_1_21","id":"0_1_21_8","text":"临沂市","value":"临沂市","open":true},{"pId":"0_1_21","id":"0_1_21_9","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_21","id":"0_1_21_10","text":"日照市","value":"日照市","open":true},{"pId":"0_1_21","id":"0_1_21_11","text":"泰安市","value":"泰安市","open":true},{"pId":"0_1_21","id":"0_1_21_12","text":"威海市","value":"威海市","open":true},{"pId":"0_1_21","id":"0_1_21_13","text":"潍坊市","value":"潍坊市","open":true},{"pId":"0_1_21","id":"0_1_21_14","text":"烟台市","value":"烟台市","open":true},{"pId":"0_1_21","id":"0_1_21_15","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_1_21","id":"0_1_21_16","text":"淄博市","value":"淄博市","open":true},{"pId":"0_1","id":"0_1_22","text":"山西省( 共12个 )","value":"山西省","open":true},{"pId":"0_1_22","id":"0_1_22_0","text":"长治市","value":"长治市","open":true},{"pId":"0_1_22","id":"0_1_22_1","text":"大同市","value":"大同市","open":true},{"pId":"0_1_22","id":"0_1_22_2","text":"晋城市","value":"晋城市","open":true},{"pId":"0_1_22","id":"0_1_22_3","text":"晋中市","value":"晋中市","open":true},{"pId":"0_1_22","id":"0_1_22_4","text":"临汾市","value":"临汾市","open":true},{"pId":"0_1_22","id":"0_1_22_5","text":"吕梁市","value":"吕梁市","open":true},{"pId":"0_1_22","id":"0_1_22_6","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_22","id":"0_1_22_7","text":"朔州市","value":"朔州市","open":true},{"pId":"0_1_22","id":"0_1_22_8","text":"太原市","value":"太原市","open":true},{"pId":"0_1_22","id":"0_1_22_9","text":"忻州市","value":"忻州市","open":true},{"pId":"0_1_22","id":"0_1_22_10","text":"阳泉市","value":"阳泉市","open":true},{"pId":"0_1_22","id":"0_1_22_11","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_23","text":"陕西省( 共9个 )","value":"陕西省","open":true},{"pId":"0_1_23","id":"0_1_23_0","text":"安康市","value":"安康市","open":true},{"pId":"0_1_23","id":"0_1_23_1","text":"宝鸡市","value":"宝鸡市","open":true},{"pId":"0_1_23","id":"0_1_23_2","text":"汉中市","value":"汉中市","open":true},{"pId":"0_1_23","id":"0_1_23_3","text":"商洛市","value":"商洛市","open":true},{"pId":"0_1_23","id":"0_1_23_4","text":"渭南市","value":"渭南市","open":true},{"pId":"0_1_23","id":"0_1_23_5","text":"西安市","value":"西安市","open":true},{"pId":"0_1_23","id":"0_1_23_6","text":"咸阳市","value":"咸阳市","open":true},{"pId":"0_1_23","id":"0_1_23_7","text":"延安市","value":"延安市","open":true},{"pId":"0_1_23","id":"0_1_23_8","text":"榆林市","value":"榆林市","open":true},{"pId":"0_1","id":"0_1_24","text":"上海市( 共19个 )","value":"上海市","open":true},{"pId":"0_1_24","id":"0_1_24_0","text":"宝山区","value":"宝山区","open":true},{"pId":"0_1_24","id":"0_1_24_1","text":"长宁区","value":"长宁区","open":true},{"pId":"0_1_24","id":"0_1_24_2","text":"崇明县","value":"崇明县","open":true},{"pId":"0_1_24","id":"0_1_24_3","text":"奉贤区","value":"奉贤区","open":true},{"pId":"0_1_24","id":"0_1_24_4","text":"虹口区","value":"虹口区","open":true},{"pId":"0_1_24","id":"0_1_24_5","text":"黄浦区","value":"黄浦区","open":true},{"pId":"0_1_24","id":"0_1_24_6","text":"嘉定区","value":"嘉定区","open":true},{"pId":"0_1_24","id":"0_1_24_7","text":"金山区","value":"金山区","open":true},{"pId":"0_1_24","id":"0_1_24_8","text":"静安区","value":"静安区","open":true},{"pId":"0_1_24","id":"0_1_24_9","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_24","id":"0_1_24_10","text":"闵行区","value":"闵行区","open":true},{"pId":"0_1_24","id":"0_1_24_11","text":"普陀区","value":"普陀区","open":true},{"pId":"0_1_24","id":"0_1_24_12","text":"浦东新区","value":"浦东新区","open":true},{"pId":"0_1_24","id":"0_1_24_13","text":"青浦区","value":"青浦区","open":true},{"pId":"0_1_24","id":"0_1_24_14","text":"上海市区","value":"上海市区","open":true},{"pId":"0_1_24","id":"0_1_24_15","text":"松江区","value":"松江区","open":true},{"pId":"0_1_24","id":"0_1_24_16","text":"徐汇区","value":"徐汇区","open":true},{"pId":"0_1_24","id":"0_1_24_17","text":"杨浦区","value":"杨浦区","open":true},{"pId":"0_1_24","id":"0_1_24_18","text":"闸北区","value":"闸北区","open":true},{"pId":"0_1","id":"0_1_25","text":"四川省( 共21个 )","value":"四川省","open":true},{"pId":"0_1_25","id":"0_1_25_0","text":"阿坝藏族羌族自治州","value":"阿坝藏族羌族自治州","open":true},{"pId":"0_1_25","id":"0_1_25_1","text":"巴中市","value":"巴中市","open":true},{"pId":"0_1_25","id":"0_1_25_2","text":"成都市","value":"成都市","open":true},{"pId":"0_1_25","id":"0_1_25_3","text":"达州市","value":"达州市","open":true},{"pId":"0_1_25","id":"0_1_25_4","text":"德阳市","value":"德阳市","open":true},{"pId":"0_1_25","id":"0_1_25_5","text":"甘孜市","value":"甘孜市","open":true},{"pId":"0_1_25","id":"0_1_25_6","text":"广安市","value":"广安市","open":true},{"pId":"0_1_25","id":"0_1_25_7","text":"广元市","value":"广元市","open":true},{"pId":"0_1_25","id":"0_1_25_8","text":"乐山市","value":"乐山市","open":true},{"pId":"0_1_25","id":"0_1_25_9","text":"凉山市","value":"凉山市","open":true},{"pId":"0_1_25","id":"0_1_25_10","text":"泸州市","value":"泸州市","open":true},{"pId":"0_1_25","id":"0_1_25_11","text":"眉山市","value":"眉山市","open":true},{"pId":"0_1_25","id":"0_1_25_12","text":"绵阳市","value":"绵阳市","open":true},{"pId":"0_1_25","id":"0_1_25_13","text":"南充市","value":"南充市","open":true},{"pId":"0_1_25","id":"0_1_25_14","text":"内江市","value":"内江市","open":true},{"pId":"0_1_25","id":"0_1_25_15","text":"攀枝花市","value":"攀枝花市","open":true},{"pId":"0_1_25","id":"0_1_25_16","text":"遂宁市","value":"遂宁市","open":true},{"pId":"0_1_25","id":"0_1_25_17","text":"雅安市","value":"雅安市","open":true},{"pId":"0_1_25","id":"0_1_25_18","text":"宜宾市","value":"宜宾市","open":true},{"pId":"0_1_25","id":"0_1_25_19","text":"资阳市","value":"资阳市","open":true},{"pId":"0_1_25","id":"0_1_25_20","text":"自贡市","value":"自贡市","open":true},{"pId":"0_1","id":"0_1_26","text":"台湾( 共1个 )","value":"台湾","open":true},{"pId":"0_1_26","id":"0_1_26_0","text":"台北市","value":"台北市","open":true},{"pId":"0_1","id":"0_1_27","text":"天津市( 共1个 )","value":"天津市","open":true},{"pId":"0_1_27","id":"0_1_27_0","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1","id":"0_1_28","text":"西藏自治区( 共2个 )","value":"西藏自治区","open":true},{"pId":"0_1_28","id":"0_1_28_0","text":"阿里市","value":"阿里市","open":true},{"pId":"0_1_28","id":"0_1_28_1","text":"日喀则市","value":"日喀则市","open":true},{"pId":"0_1","id":"0_1_29","text":"香港特别行政区( 共1个 )","value":"香港特别行政区","open":true},{"pId":"0_1_29","id":"0_1_29_0","text":"香港","value":"香港","open":true},{"pId":"0_1","id":"0_1_30","text":"新疆维吾尔族自治区( 共11个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_1_30","id":"0_1_30_0","text":"巴音郭楞市","value":"巴音郭楞市","open":true},{"pId":"0_1_30","id":"0_1_30_1","text":"哈密市","value":"哈密市","open":true},{"pId":"0_1_30","id":"0_1_30_2","text":"和田市","value":"和田市","open":true},{"pId":"0_1_30","id":"0_1_30_3","text":"喀什地区","value":"喀什地区","open":true},{"pId":"0_1_30","id":"0_1_30_4","text":"克拉玛依市","value":"克拉玛依市","open":true},{"pId":"0_1_30","id":"0_1_30_5","text":"克孜勒苏柯州","value":"克孜勒苏柯州","open":true},{"pId":"0_1_30","id":"0_1_30_6","text":"石河子市","value":"石河子市","open":true},{"pId":"0_1_30","id":"0_1_30_7","text":"塔城市","value":"塔城市","open":true},{"pId":"0_1_30","id":"0_1_30_8","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_1_30","id":"0_1_30_9","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_1_30","id":"0_1_30_10","text":"伊犁市","value":"伊犁市","open":true},{"pId":"0_1","id":"0_1_31","text":"云南省( 共12个 )","value":"云南省","open":true},{"pId":"0_1_31","id":"0_1_31_0","text":"保山市","value":"保山市","open":true},{"pId":"0_1_31","id":"0_1_31_1","text":"楚雄彝族自治州","value":"楚雄彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_2","text":"大理白族自治州","value":"大理白族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_3","text":"红河哈尼族彝族自治州","value":"红河哈尼族彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_4","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_31","id":"0_1_31_5","text":"丽江市","value":"丽江市","open":true},{"pId":"0_1_31","id":"0_1_31_6","text":"临沧市","value":"临沧市","open":true},{"pId":"0_1_31","id":"0_1_31_7","text":"曲靖市","value":"曲靖市","open":true},{"pId":"0_1_31","id":"0_1_31_8","text":"思茅市","value":"思茅市","open":true},{"pId":"0_1_31","id":"0_1_31_9","text":"文山市","value":"文山市","open":true},{"pId":"0_1_31","id":"0_1_31_10","text":"玉溪市","value":"玉溪市","open":true},{"pId":"0_1_31","id":"0_1_31_11","text":"昭通市","value":"昭通市","open":true},{"pId":"0_1","id":"0_1_32","text":"浙江省( 共12个 )","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_1_32","id":"0_1_32_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_1_32","id":"0_1_32_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_1_32","id":"0_1_32_3","text":"金华市","value":"金华市","open":true},{"pId":"0_1_32","id":"0_1_32_4","text":"丽水市","value":"丽水市","open":true},{"pId":"0_1_32","id":"0_1_32_5","text":"宁波市","value":"宁波市","open":true},{"pId":"0_1_32","id":"0_1_32_6","text":"衢州市","value":"衢州市","open":true},{"pId":"0_1_32","id":"0_1_32_7","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_1_32","id":"0_1_32_8","text":"台州市","value":"台州市","open":true},{"pId":"0_1_32","id":"0_1_32_9","text":"温州市","value":"温州市","open":true},{"pId":"0_1_32","id":"0_1_32_10","text":"浙江省","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_11","text":"舟山市","value":"舟山市","open":true},{"pId":"0_1","id":"0_1_33","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_1_33","id":"0_1_33_0","text":"重庆市区","value":"重庆市区","open":true}]
+ TREEITEMS: [{"pId":"0","id":"0_0","text":"( 共25个 )","value":"","open":true},{"pId":"0_0","id":"0_0_0","text":"安徽省( 共1个 )","value":"安徽省","open":true},{"pId":"0_0_0","id":"0_0_0_0","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_0","id":"0_0_1","text":"北京市( 共6个 )","value":"北京市","open":true},{"pId":"0_0_1","id":"0_0_1_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_0_1","id":"0_0_1_1","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_0_1","id":"0_0_1_2","text":"东城区","value":"东城区","open":true},{"pId":"0_0_1","id":"0_0_1_3","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_0_1","id":"0_0_1_4","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_0_1","id":"0_0_1_5","text":"石景山区","value":"石景山区","open":true},{"pId":"0_0","id":"0_0_2","text":"福建省( 共2个 )","value":"福建省","open":true},{"pId":"0_0_2","id":"0_0_2_0","text":"莆田市","value":"莆田市","open":true},{"pId":"0_0_2","id":"0_0_2_1","text":"泉州市","value":"泉州市","open":true},{"pId":"0_0","id":"0_0_3","text":"甘肃省( 共1个 )","value":"甘肃省","open":true},{"pId":"0_0_3","id":"0_0_3_0","text":"兰州市","value":"兰州市","open":true},{"pId":"0_0","id":"0_0_4","text":"广东省( 共5个 )","value":"广东省","open":true},{"pId":"0_0_4","id":"0_0_4_0","text":"东莞市","value":"东莞市","open":true},{"pId":"0_0_4","id":"0_0_4_1","text":"广州市","value":"广州市","open":true},{"pId":"0_0_4","id":"0_0_4_2","text":"惠州市","value":"惠州市","open":true},{"pId":"0_0_4","id":"0_0_4_3","text":"深圳市","value":"深圳市","open":true},{"pId":"0_0_4","id":"0_0_4_4","text":"珠海市","value":"珠海市","open":true},{"pId":"0_0","id":"0_0_5","text":"广西壮族自治区( 共1个 )","value":"广西壮族自治区","open":true},{"pId":"0_0_5","id":"0_0_5_0","text":"南宁市","value":"南宁市","open":true},{"pId":"0_0","id":"0_0_6","text":"河北省( 共2个 )","value":"河北省","open":true},{"pId":"0_0_6","id":"0_0_6_0","text":"保定市","value":"保定市","open":true},{"pId":"0_0_6","id":"0_0_6_1","text":"邢台市","value":"邢台市","open":true},{"pId":"0_0","id":"0_0_7","text":"河南省( 共1个 )","value":"河南省","open":true},{"pId":"0_0_7","id":"0_0_7_0","text":"郑州市","value":"郑州市","open":true},{"pId":"0_0","id":"0_0_8","text":"黑龙江省( 共7个 )","value":"黑龙江省","open":true},{"pId":"0_0_8","id":"0_0_8_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_0_8","id":"0_0_8_1","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_0_8","id":"0_0_8_2","text":"鸡西市","value":"鸡西市","open":true},{"pId":"0_0_8","id":"0_0_8_3","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_0_8","id":"0_0_8_4","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_0_8","id":"0_0_8_5","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_0_8","id":"0_0_8_6","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_0","id":"0_0_9","text":"湖北省( 共1个 )","value":"湖北省","open":true},{"pId":"0_0_9","id":"0_0_9_0","text":"武汉市","value":"武汉市","open":true},{"pId":"0_0","id":"0_0_10","text":"湖南省( 共3个 )","value":"湖南省","open":true},{"pId":"0_0_10","id":"0_0_10_0","text":"常德市","value":"常德市","open":true},{"pId":"0_0_10","id":"0_0_10_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_0_10","id":"0_0_10_2","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_0","id":"0_0_11","text":"吉林省( 共4个 )","value":"吉林省","open":true},{"pId":"0_0_11","id":"0_0_11_0","text":"白山市","value":"白山市","open":true},{"pId":"0_0_11","id":"0_0_11_1","text":"长春市","value":"长春市","open":true},{"pId":"0_0_11","id":"0_0_11_2","text":"松原市","value":"松原市","open":true},{"pId":"0_0_11","id":"0_0_11_3","text":"通化市","value":"通化市","open":true},{"pId":"0_0","id":"0_0_12","text":"江苏省( 共8个 )","value":"江苏省","open":true},{"pId":"0_0_12","id":"0_0_12_0","text":"常州市","value":"常州市","open":true},{"pId":"0_0_12","id":"0_0_12_1","text":"南京市","value":"南京市","open":true},{"pId":"0_0_12","id":"0_0_12_2","text":"南通市","value":"南通市","open":true},{"pId":"0_0_12","id":"0_0_12_3","text":"苏州市","value":"苏州市","open":true},{"pId":"0_0_12","id":"0_0_12_4","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_0_12","id":"0_0_12_5","text":"泰州市","value":"泰州市","open":true},{"pId":"0_0_12","id":"0_0_12_6","text":"无锡市","value":"无锡市","open":true},{"pId":"0_0_12","id":"0_0_12_7","text":"盐城市","value":"盐城市","open":true},{"pId":"0_0","id":"0_0_13","text":"辽宁省( 共11个 )","value":"辽宁省","open":true},{"pId":"0_0_13","id":"0_0_13_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_0_13","id":"0_0_13_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_0_13","id":"0_0_13_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_0_13","id":"0_0_13_3","text":"大连市","value":"大连市","open":true},{"pId":"0_0_13","id":"0_0_13_4","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_0_13","id":"0_0_13_5","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_0_13","id":"0_0_13_6","text":"锦州市","value":"锦州市","open":true},{"pId":"0_0_13","id":"0_0_13_7","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_0_13","id":"0_0_13_8","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_0_13","id":"0_0_13_9","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_0_13","id":"0_0_13_10","text":"营口市","value":"营口市","open":true},{"pId":"0_0","id":"0_0_14","text":"内蒙古( 共1个 )","value":"内蒙古","open":true},{"pId":"0_0_14","id":"0_0_14_0","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_0","id":"0_0_15","text":"宁夏回族自治区( 共1个 )","value":"宁夏回族自治区","open":true},{"pId":"0_0_15","id":"0_0_15_0","text":"银川市","value":"银川市","open":true},{"pId":"0_0","id":"0_0_16","text":"山东省( 共7个 )","value":"山东省","open":true},{"pId":"0_0_16","id":"0_0_16_0","text":"济南市","value":"济南市","open":true},{"pId":"0_0_16","id":"0_0_16_1","text":"济宁市","value":"济宁市","open":true},{"pId":"0_0_16","id":"0_0_16_2","text":"聊城市","value":"聊城市","open":true},{"pId":"0_0_16","id":"0_0_16_3","text":"临沂市","value":"临沂市","open":true},{"pId":"0_0_16","id":"0_0_16_4","text":"青岛市","value":"青岛市","open":true},{"pId":"0_0_16","id":"0_0_16_5","text":"烟台市","value":"烟台市","open":true},{"pId":"0_0_16","id":"0_0_16_6","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_0","id":"0_0_17","text":"山西省( 共1个 )","value":"山西省","open":true},{"pId":"0_0_17","id":"0_0_17_0","text":"太原市","value":"太原市","open":true},{"pId":"0_0","id":"0_0_18","text":"陕西省( 共1个 )","value":"陕西省","open":true},{"pId":"0_0_18","id":"0_0_18_0","text":"西安市","value":"西安市","open":true},{"pId":"0_0","id":"0_0_19","text":"上海市( 共1个 )","value":"上海市","open":true},{"pId":"0_0_19","id":"0_0_19_0","text":"上海市区","value":"上海市区","open":true},{"pId":"0_0","id":"0_0_20","text":"四川省( 共1个 )","value":"四川省","open":true},{"pId":"0_0_20","id":"0_0_20_0","text":"成都市","value":"成都市","open":true},{"pId":"0_0","id":"0_0_21","text":"新疆维吾尔族自治区( 共2个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_0_21","id":"0_0_21_0","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_0_21","id":"0_0_21_1","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_0","id":"0_0_22","text":"云南省( 共1个 )","value":"云南省","open":true},{"pId":"0_0_22","id":"0_0_22_0","text":"昆明市","value":"昆明市","open":true},{"pId":"0_0","id":"0_0_23","text":"浙江省( 共5个 )","value":"浙江省","open":true},{"pId":"0_0_23","id":"0_0_23_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_0_23","id":"0_0_23_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_0_23","id":"0_0_23_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_0_23","id":"0_0_23_3","text":"宁波市","value":"宁波市","open":true},{"pId":"0_0_23","id":"0_0_23_4","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_0","id":"0_0_24","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_0_24","id":"0_0_24_0","text":"重庆市区","value":"重庆市区","open":true},{"pId":"0","id":"0_1","text":"中国( 共34个 )","value":"中国","open":true},{"pId":"0_1","id":"0_1_0","text":"安徽省( 共19个 )","value":"安徽省","open":true},{"pId":"0_1_0","id":"0_1_0_0","text":"安庆市","value":"安庆市","open":true},{"pId":"0_1_0","id":"0_1_0_1","text":"蚌埠市","value":"蚌埠市","open":true},{"pId":"0_1_0","id":"0_1_0_2","text":"亳州市","value":"亳州市","open":true},{"pId":"0_1_0","id":"0_1_0_3","text":"巢湖市","value":"巢湖市","open":true},{"pId":"0_1_0","id":"0_1_0_4","text":"池州市","value":"池州市","open":true},{"pId":"0_1_0","id":"0_1_0_5","text":"滁州市","value":"滁州市","open":true},{"pId":"0_1_0","id":"0_1_0_6","text":"阜阳市","value":"阜阳市","open":true},{"pId":"0_1_0","id":"0_1_0_7","text":"毫州市","value":"毫州市","open":true},{"pId":"0_1_0","id":"0_1_0_8","text":"合肥市","value":"合肥市","open":true},{"pId":"0_1_0","id":"0_1_0_9","text":"淮北市","value":"淮北市","open":true},{"pId":"0_1_0","id":"0_1_0_10","text":"淮南市","value":"淮南市","open":true},{"pId":"0_1_0","id":"0_1_0_11","text":"黄山市","value":"黄山市","open":true},{"pId":"0_1_0","id":"0_1_0_12","text":"六安市","value":"六安市","open":true},{"pId":"0_1_0","id":"0_1_0_13","text":"马鞍山市","value":"马鞍山市","open":true},{"pId":"0_1_0","id":"0_1_0_14","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_0","id":"0_1_0_15","text":"宿州市","value":"宿州市","open":true},{"pId":"0_1_0","id":"0_1_0_16","text":"铜陵市","value":"铜陵市","open":true},{"pId":"0_1_0","id":"0_1_0_17","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_1_0","id":"0_1_0_18","text":"宣城市","value":"宣城市","open":true},{"pId":"0_1","id":"0_1_1","text":"澳门特别行政区( 共1个 )","value":"澳门特别行政区","open":true},{"pId":"0_1_1","id":"0_1_1_0","text":"澳门","value":"澳门","open":true},{"pId":"0_1","id":"0_1_2","text":"北京市( 共17个 )","value":"北京市","open":true},{"pId":"0_1_2","id":"0_1_2_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_1_2","id":"0_1_2_1","text":"昌平区","value":"昌平区","open":true},{"pId":"0_1_2","id":"0_1_2_2","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_1_2","id":"0_1_2_3","text":"大兴区","value":"大兴区","open":true},{"pId":"0_1_2","id":"0_1_2_4","text":"东城区","value":"东城区","open":true},{"pId":"0_1_2","id":"0_1_2_5","text":"房山区","value":"房山区","open":true},{"pId":"0_1_2","id":"0_1_2_6","text":"丰台区","value":"丰台区","open":true},{"pId":"0_1_2","id":"0_1_2_7","text":"海淀区","value":"海淀区","open":true},{"pId":"0_1_2","id":"0_1_2_8","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_1_2","id":"0_1_2_9","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_1_2","id":"0_1_2_10","text":"门头沟区","value":"门头沟区","open":true},{"pId":"0_1_2","id":"0_1_2_11","text":"平谷区","value":"平谷区","open":true},{"pId":"0_1_2","id":"0_1_2_12","text":"石景山区","value":"石景山区","open":true},{"pId":"0_1_2","id":"0_1_2_13","text":"顺义区","value":"顺义区","open":true},{"pId":"0_1_2","id":"0_1_2_14","text":"通州区","value":"通州区","open":true},{"pId":"0_1_2","id":"0_1_2_15","text":"西城区","value":"西城区","open":true},{"pId":"0_1_2","id":"0_1_2_16","text":"西城区 ","value":"西城区 ","open":true},{"pId":"0_1","id":"0_1_3","text":"福建省( 共9个 )","value":"福建省","open":true},{"pId":"0_1_3","id":"0_1_3_0","text":"福州市","value":"福州市","open":true},{"pId":"0_1_3","id":"0_1_3_1","text":"龙岩市","value":"龙岩市","open":true},{"pId":"0_1_3","id":"0_1_3_2","text":"南平市","value":"南平市","open":true},{"pId":"0_1_3","id":"0_1_3_3","text":"宁德市","value":"宁德市","open":true},{"pId":"0_1_3","id":"0_1_3_4","text":"莆田市","value":"莆田市","open":true},{"pId":"0_1_3","id":"0_1_3_5","text":"泉州市","value":"泉州市","open":true},{"pId":"0_1_3","id":"0_1_3_6","text":"三明市","value":"三明市","open":true},{"pId":"0_1_3","id":"0_1_3_7","text":"厦门市","value":"厦门市","open":true},{"pId":"0_1_3","id":"0_1_3_8","text":"漳州市","value":"漳州市","open":true},{"pId":"0_1","id":"0_1_4","text":"甘肃省( 共12个 )","value":"甘肃省","open":true},{"pId":"0_1_4","id":"0_1_4_0","text":"白银市","value":"白银市","open":true},{"pId":"0_1_4","id":"0_1_4_1","text":"嘉峪关市","value":"嘉峪关市","open":true},{"pId":"0_1_4","id":"0_1_4_2","text":"金昌市","value":"金昌市","open":true},{"pId":"0_1_4","id":"0_1_4_3","text":"酒泉市","value":"酒泉市","open":true},{"pId":"0_1_4","id":"0_1_4_4","text":"兰州市","value":"兰州市","open":true},{"pId":"0_1_4","id":"0_1_4_5","text":"陇南市","value":"陇南市","open":true},{"pId":"0_1_4","id":"0_1_4_6","text":"平凉市","value":"平凉市","open":true},{"pId":"0_1_4","id":"0_1_4_7","text":"庆阳市","value":"庆阳市","open":true},{"pId":"0_1_4","id":"0_1_4_8","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_4","id":"0_1_4_9","text":"天水市","value":"天水市","open":true},{"pId":"0_1_4","id":"0_1_4_10","text":"武威市","value":"武威市","open":true},{"pId":"0_1_4","id":"0_1_4_11","text":"张掖市","value":"张掖市","open":true},{"pId":"0_1","id":"0_1_5","text":"广东省( 共21个 )","value":"广东省","open":true},{"pId":"0_1_5","id":"0_1_5_0","text":"潮州市","value":"潮州市","open":true},{"pId":"0_1_5","id":"0_1_5_1","text":"东莞市","value":"东莞市","open":true},{"pId":"0_1_5","id":"0_1_5_2","text":"佛山市","value":"佛山市","open":true},{"pId":"0_1_5","id":"0_1_5_3","text":"广州市","value":"广州市","open":true},{"pId":"0_1_5","id":"0_1_5_4","text":"河源市","value":"河源市","open":true},{"pId":"0_1_5","id":"0_1_5_5","text":"惠州市","value":"惠州市","open":true},{"pId":"0_1_5","id":"0_1_5_6","text":"江门市","value":"江门市","open":true},{"pId":"0_1_5","id":"0_1_5_7","text":"揭阳市","value":"揭阳市","open":true},{"pId":"0_1_5","id":"0_1_5_8","text":"茂名市","value":"茂名市","open":true},{"pId":"0_1_5","id":"0_1_5_9","text":"梅州市","value":"梅州市","open":true},{"pId":"0_1_5","id":"0_1_5_10","text":"清远市","value":"清远市","open":true},{"pId":"0_1_5","id":"0_1_5_11","text":"汕头市","value":"汕头市","open":true},{"pId":"0_1_5","id":"0_1_5_12","text":"汕尾市","value":"汕尾市","open":true},{"pId":"0_1_5","id":"0_1_5_13","text":"韶关市","value":"韶关市","open":true},{"pId":"0_1_5","id":"0_1_5_14","text":"深圳市","value":"深圳市","open":true},{"pId":"0_1_5","id":"0_1_5_15","text":"阳江市","value":"阳江市","open":true},{"pId":"0_1_5","id":"0_1_5_16","text":"云浮市","value":"云浮市","open":true},{"pId":"0_1_5","id":"0_1_5_17","text":"湛江市","value":"湛江市","open":true},{"pId":"0_1_5","id":"0_1_5_18","text":"肇庆市","value":"肇庆市","open":true},{"pId":"0_1_5","id":"0_1_5_19","text":"中山市","value":"中山市","open":true},{"pId":"0_1_5","id":"0_1_5_20","text":"珠海市","value":"珠海市","open":true},{"pId":"0_1","id":"0_1_6","text":"广西壮族自治区( 共14个 )","value":"广西壮族自治区","open":true},{"pId":"0_1_6","id":"0_1_6_0","text":"百色市","value":"百色市","open":true},{"pId":"0_1_6","id":"0_1_6_1","text":"北海市","value":"北海市","open":true},{"pId":"0_1_6","id":"0_1_6_2","text":"崇左市","value":"崇左市","open":true},{"pId":"0_1_6","id":"0_1_6_3","text":"防城港市","value":"防城港市","open":true},{"pId":"0_1_6","id":"0_1_6_4","text":"桂林市","value":"桂林市","open":true},{"pId":"0_1_6","id":"0_1_6_5","text":"贵港市","value":"贵港市","open":true},{"pId":"0_1_6","id":"0_1_6_6","text":"河池市","value":"河池市","open":true},{"pId":"0_1_6","id":"0_1_6_7","text":"贺州市","value":"贺州市","open":true},{"pId":"0_1_6","id":"0_1_6_8","text":"来宾市","value":"来宾市","open":true},{"pId":"0_1_6","id":"0_1_6_9","text":"柳州市","value":"柳州市","open":true},{"pId":"0_1_6","id":"0_1_6_10","text":"南宁市","value":"南宁市","open":true},{"pId":"0_1_6","id":"0_1_6_11","text":"钦州市","value":"钦州市","open":true},{"pId":"0_1_6","id":"0_1_6_12","text":"梧州市","value":"梧州市","open":true},{"pId":"0_1_6","id":"0_1_6_13","text":"玉林市","value":"玉林市","open":true},{"pId":"0_1","id":"0_1_7","text":"贵州省( 共9个 )","value":"贵州省","open":true},{"pId":"0_1_7","id":"0_1_7_0","text":"安顺市","value":"安顺市","open":true},{"pId":"0_1_7","id":"0_1_7_1","text":"毕节地区","value":"毕节地区","open":true},{"pId":"0_1_7","id":"0_1_7_2","text":"贵阳市","value":"贵阳市","open":true},{"pId":"0_1_7","id":"0_1_7_3","text":"六盘水市","value":"六盘水市","open":true},{"pId":"0_1_7","id":"0_1_7_4","text":"黔东南州","value":"黔东南州","open":true},{"pId":"0_1_7","id":"0_1_7_5","text":"黔南州","value":"黔南州","open":true},{"pId":"0_1_7","id":"0_1_7_6","text":"黔西南市","value":"黔西南市","open":true},{"pId":"0_1_7","id":"0_1_7_7","text":"铜仁地区","value":"铜仁地区","open":true},{"pId":"0_1_7","id":"0_1_7_8","text":"遵义市","value":"遵义市","open":true},{"pId":"0_1","id":"0_1_8","text":"海南省( 共2个 )","value":"海南省","open":true},{"pId":"0_1_8","id":"0_1_8_0","text":"海口市","value":"海口市","open":true},{"pId":"0_1_8","id":"0_1_8_1","text":"三亚市","value":"三亚市","open":true},{"pId":"0_1","id":"0_1_9","text":"河北省( 共12个 )","value":"河北省","open":true},{"pId":"0_1_9","id":"0_1_9_0","text":"保定市","value":"保定市","open":true},{"pId":"0_1_9","id":"0_1_9_1","text":"沧州市","value":"沧州市","open":true},{"pId":"0_1_9","id":"0_1_9_2","text":"承德市","value":"承德市","open":true},{"pId":"0_1_9","id":"0_1_9_3","text":"邯郸市","value":"邯郸市","open":true},{"pId":"0_1_9","id":"0_1_9_4","text":"衡水市","value":"衡水市","open":true},{"pId":"0_1_9","id":"0_1_9_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_9","id":"0_1_9_6","text":"秦皇岛市","value":"秦皇岛市","open":true},{"pId":"0_1_9","id":"0_1_9_7","text":"石家庄市","value":"石家庄市","open":true},{"pId":"0_1_9","id":"0_1_9_8","text":"唐山市","value":"唐山市","open":true},{"pId":"0_1_9","id":"0_1_9_9","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_9","id":"0_1_9_10","text":"邢台市","value":"邢台市","open":true},{"pId":"0_1_9","id":"0_1_9_11","text":"张家口市","value":"张家口市","open":true},{"pId":"0_1","id":"0_1_10","text":"河南省( 共19个 )","value":"河南省","open":true},{"pId":"0_1_10","id":"0_1_10_0","text":"安阳市","value":"安阳市","open":true},{"pId":"0_1_10","id":"0_1_10_1","text":"鹤壁市","value":"鹤壁市","open":true},{"pId":"0_1_10","id":"0_1_10_2","text":"济源市","value":"济源市","open":true},{"pId":"0_1_10","id":"0_1_10_3","text":"焦作市","value":"焦作市","open":true},{"pId":"0_1_10","id":"0_1_10_4","text":"开封市","value":"开封市","open":true},{"pId":"0_1_10","id":"0_1_10_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_10","id":"0_1_10_6","text":"洛阳市","value":"洛阳市","open":true},{"pId":"0_1_10","id":"0_1_10_7","text":"漯河市","value":"漯河市","open":true},{"pId":"0_1_10","id":"0_1_10_8","text":"南阳市","value":"南阳市","open":true},{"pId":"0_1_10","id":"0_1_10_9","text":"平顶山市","value":"平顶山市","open":true},{"pId":"0_1_10","id":"0_1_10_10","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_10","id":"0_1_10_11","text":"三门峡市","value":"三门峡市","open":true},{"pId":"0_1_10","id":"0_1_10_12","text":"商丘市","value":"商丘市","open":true},{"pId":"0_1_10","id":"0_1_10_13","text":"新乡市","value":"新乡市","open":true},{"pId":"0_1_10","id":"0_1_10_14","text":"信阳市","value":"信阳市","open":true},{"pId":"0_1_10","id":"0_1_10_15","text":"许昌市","value":"许昌市","open":true},{"pId":"0_1_10","id":"0_1_10_16","text":"郑州市","value":"郑州市","open":true},{"pId":"0_1_10","id":"0_1_10_17","text":"周口市","value":"周口市","open":true},{"pId":"0_1_10","id":"0_1_10_18","text":"驻马店市","value":"驻马店市","open":true},{"pId":"0_1","id":"0_1_11","text":"黑龙江省( 共13个 )","value":"黑龙江省","open":true},{"pId":"0_1_11","id":"0_1_11_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_11","id":"0_1_11_1","text":"大兴安岭地区","value":"大兴安岭地区","open":true},{"pId":"0_1_11","id":"0_1_11_2","text":"大兴安岭市","value":"大兴安岭市","open":true},{"pId":"0_1_11","id":"0_1_11_3","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_1_11","id":"0_1_11_4","text":"鹤港市","value":"鹤港市","open":true},{"pId":"0_1_11","id":"0_1_11_5","text":"黑河市","value":"黑河市","open":true},{"pId":"0_1_11","id":"0_1_11_6","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_1_11","id":"0_1_11_7","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_1_11","id":"0_1_11_8","text":"七台河市","value":"七台河市","open":true},{"pId":"0_1_11","id":"0_1_11_9","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_1_11","id":"0_1_11_10","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_1_11","id":"0_1_11_11","text":"绥化市","value":"绥化市","open":true},{"pId":"0_1_11","id":"0_1_11_12","text":"伊春市","value":"伊春市","open":true},{"pId":"0_1","id":"0_1_12","text":"湖北省( 共16个 )","value":"湖北省","open":true},{"pId":"0_1_12","id":"0_1_12_0","text":"鄂州市","value":"鄂州市","open":true},{"pId":"0_1_12","id":"0_1_12_1","text":"恩施土家族苗族自治州","value":"恩施土家族苗族自治州","open":true},{"pId":"0_1_12","id":"0_1_12_2","text":"黄冈市","value":"黄冈市","open":true},{"pId":"0_1_12","id":"0_1_12_3","text":"黄石市","value":"黄石市","open":true},{"pId":"0_1_12","id":"0_1_12_4","text":"荆门市","value":"荆门市","open":true},{"pId":"0_1_12","id":"0_1_12_5","text":"荆州市","value":"荆州市","open":true},{"pId":"0_1_12","id":"0_1_12_6","text":"神农架市","value":"神农架市","open":true},{"pId":"0_1_12","id":"0_1_12_7","text":"十堰市","value":"十堰市","open":true},{"pId":"0_1_12","id":"0_1_12_8","text":"随州市","value":"随州市","open":true},{"pId":"0_1_12","id":"0_1_12_9","text":"天门市","value":"天门市","open":true},{"pId":"0_1_12","id":"0_1_12_10","text":"武汉市","value":"武汉市","open":true},{"pId":"0_1_12","id":"0_1_12_11","text":"咸宁市","value":"咸宁市","open":true},{"pId":"0_1_12","id":"0_1_12_12","text":"襄樊市","value":"襄樊市","open":true},{"pId":"0_1_12","id":"0_1_12_13","text":"襄阳市","value":"襄阳市","open":true},{"pId":"0_1_12","id":"0_1_12_14","text":"孝感市","value":"孝感市","open":true},{"pId":"0_1_12","id":"0_1_12_15","text":"宜昌市","value":"宜昌市","open":true},{"pId":"0_1","id":"0_1_13","text":"湖南省( 共15个 )","value":"湖南省","open":true},{"pId":"0_1_13","id":"0_1_13_0","text":"常德市","value":"常德市","open":true},{"pId":"0_1_13","id":"0_1_13_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_1_13","id":"0_1_13_2","text":"郴州市","value":"郴州市","open":true},{"pId":"0_1_13","id":"0_1_13_3","text":"衡阳市","value":"衡阳市","open":true},{"pId":"0_1_13","id":"0_1_13_4","text":"怀化市","value":"怀化市","open":true},{"pId":"0_1_13","id":"0_1_13_5","text":"娄底市","value":"娄底市","open":true},{"pId":"0_1_13","id":"0_1_13_6","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_1_13","id":"0_1_13_7","text":"湘潭市","value":"湘潭市","open":true},{"pId":"0_1_13","id":"0_1_13_8","text":"湘西市","value":"湘西市","open":true},{"pId":"0_1_13","id":"0_1_13_9","text":"湘西土家族苗族自治州","value":"湘西土家族苗族自治州","open":true},{"pId":"0_1_13","id":"0_1_13_10","text":"益阳市","value":"益阳市","open":true},{"pId":"0_1_13","id":"0_1_13_11","text":"永州市","value":"永州市","open":true},{"pId":"0_1_13","id":"0_1_13_12","text":"岳阳市","value":"岳阳市","open":true},{"pId":"0_1_13","id":"0_1_13_13","text":"张家界市","value":"张家界市","open":true},{"pId":"0_1_13","id":"0_1_13_14","text":"株洲市","value":"株洲市","open":true},{"pId":"0_1","id":"0_1_14","text":"吉林省( 共10个 )","value":"吉林省","open":true},{"pId":"0_1_14","id":"0_1_14_0","text":"白城市","value":"白城市","open":true},{"pId":"0_1_14","id":"0_1_14_1","text":"白山市","value":"白山市","open":true},{"pId":"0_1_14","id":"0_1_14_2","text":"长春市","value":"长春市","open":true},{"pId":"0_1_14","id":"0_1_14_3","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_14","id":"0_1_14_4","text":"吉林市","value":"吉林市","open":true},{"pId":"0_1_14","id":"0_1_14_5","text":"辽源市","value":"辽源市","open":true},{"pId":"0_1_14","id":"0_1_14_6","text":"四平市","value":"四平市","open":true},{"pId":"0_1_14","id":"0_1_14_7","text":"松原市","value":"松原市","open":true},{"pId":"0_1_14","id":"0_1_14_8","text":"通化市","value":"通化市","open":true},{"pId":"0_1_14","id":"0_1_14_9","text":"延边朝鲜族自治州","value":"延边朝鲜族自治州","open":true},{"pId":"0_1","id":"0_1_15","text":"江苏省( 共13个 )","value":"江苏省","open":true},{"pId":"0_1_15","id":"0_1_15_0","text":"常州市","value":"常州市","open":true},{"pId":"0_1_15","id":"0_1_15_1","text":"淮安市","value":"淮安市","open":true},{"pId":"0_1_15","id":"0_1_15_2","text":"连云港市","value":"连云港市","open":true},{"pId":"0_1_15","id":"0_1_15_3","text":"南京市","value":"南京市","open":true},{"pId":"0_1_15","id":"0_1_15_4","text":"南通市","value":"南通市","open":true},{"pId":"0_1_15","id":"0_1_15_5","text":"苏州市","value":"苏州市","open":true},{"pId":"0_1_15","id":"0_1_15_6","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_1_15","id":"0_1_15_7","text":"泰州市","value":"泰州市","open":true},{"pId":"0_1_15","id":"0_1_15_8","text":"无锡市","value":"无锡市","open":true},{"pId":"0_1_15","id":"0_1_15_9","text":"徐州市","value":"徐州市","open":true},{"pId":"0_1_15","id":"0_1_15_10","text":"盐城市","value":"盐城市","open":true},{"pId":"0_1_15","id":"0_1_15_11","text":"扬州市","value":"扬州市","open":true},{"pId":"0_1_15","id":"0_1_15_12","text":"镇江市","value":"镇江市","open":true},{"pId":"0_1","id":"0_1_16","text":"江西省( 共10个 )","value":"江西省","open":true},{"pId":"0_1_16","id":"0_1_16_0","text":"抚州市","value":"抚州市","open":true},{"pId":"0_1_16","id":"0_1_16_1","text":"赣州市","value":"赣州市","open":true},{"pId":"0_1_16","id":"0_1_16_2","text":"景德镇市","value":"景德镇市","open":true},{"pId":"0_1_16","id":"0_1_16_3","text":"九江市","value":"九江市","open":true},{"pId":"0_1_16","id":"0_1_16_4","text":"南昌市","value":"南昌市","open":true},{"pId":"0_1_16","id":"0_1_16_5","text":"萍乡市","value":"萍乡市","open":true},{"pId":"0_1_16","id":"0_1_16_6","text":"上饶市","value":"上饶市","open":true},{"pId":"0_1_16","id":"0_1_16_7","text":"新余市","value":"新余市","open":true},{"pId":"0_1_16","id":"0_1_16_8","text":"宜春市","value":"宜春市","open":true},{"pId":"0_1_16","id":"0_1_16_9","text":"鹰潭市","value":"鹰潭市","open":true},{"pId":"0_1","id":"0_1_17","text":"辽宁省( 共14个 )","value":"辽宁省","open":true},{"pId":"0_1_17","id":"0_1_17_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_1_17","id":"0_1_17_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_1_17","id":"0_1_17_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_1_17","id":"0_1_17_3","text":"大连市","value":"大连市","open":true},{"pId":"0_1_17","id":"0_1_17_4","text":"丹东市","value":"丹东市","open":true},{"pId":"0_1_17","id":"0_1_17_5","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_1_17","id":"0_1_17_6","text":"阜新市","value":"阜新市","open":true},{"pId":"0_1_17","id":"0_1_17_7","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_1_17","id":"0_1_17_8","text":"锦州市","value":"锦州市","open":true},{"pId":"0_1_17","id":"0_1_17_9","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_1_17","id":"0_1_17_10","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_1_17","id":"0_1_17_11","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_1_17","id":"0_1_17_12","text":"铁岭市","value":"铁岭市","open":true},{"pId":"0_1_17","id":"0_1_17_13","text":"营口市","value":"营口市","open":true},{"pId":"0_1","id":"0_1_18","text":"内蒙古( 共10个 )","value":"内蒙古","open":true},{"pId":"0_1_18","id":"0_1_18_0","text":"包头市","value":"包头市","open":true},{"pId":"0_1_18","id":"0_1_18_1","text":"赤峰市","value":"赤峰市","open":true},{"pId":"0_1_18","id":"0_1_18_2","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_1_18","id":"0_1_18_3","text":"呼和浩特市","value":"呼和浩特市","open":true},{"pId":"0_1_18","id":"0_1_18_4","text":"呼伦贝尔市","value":"呼伦贝尔市","open":true},{"pId":"0_1_18","id":"0_1_18_5","text":"通辽市","value":"通辽市","open":true},{"pId":"0_1_18","id":"0_1_18_6","text":"乌海市","value":"乌海市","open":true},{"pId":"0_1_18","id":"0_1_18_7","text":"锡林郭勒市","value":"锡林郭勒市","open":true},{"pId":"0_1_18","id":"0_1_18_8","text":"兴安市","value":"兴安市","open":true},{"pId":"0_1_18","id":"0_1_18_9","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_19","text":"宁夏回族自治区( 共5个 )","value":"宁夏回族自治区","open":true},{"pId":"0_1_19","id":"0_1_19_0","text":"固原市","value":"固原市","open":true},{"pId":"0_1_19","id":"0_1_19_1","text":"石嘴山市","value":"石嘴山市","open":true},{"pId":"0_1_19","id":"0_1_19_2","text":"吴忠市","value":"吴忠市","open":true},{"pId":"0_1_19","id":"0_1_19_3","text":"银川市","value":"银川市","open":true},{"pId":"0_1_19","id":"0_1_19_4","text":"中卫市","value":"中卫市","open":true},{"pId":"0_1","id":"0_1_20","text":"青海省( 共4个 )","value":"青海省","open":true},{"pId":"0_1_20","id":"0_1_20_0","text":"海东地区","value":"海东地区","open":true},{"pId":"0_1_20","id":"0_1_20_1","text":"海南藏族自治州","value":"海南藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_2","text":"海西蒙古族藏族自治州","value":"海西蒙古族藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_3","text":"西宁市","value":"西宁市","open":true},{"pId":"0_1","id":"0_1_21","text":"山东省( 共17个 )","value":"山东省","open":true},{"pId":"0_1_21","id":"0_1_21_0","text":"滨州市","value":"滨州市","open":true},{"pId":"0_1_21","id":"0_1_21_1","text":"德州市","value":"德州市","open":true},{"pId":"0_1_21","id":"0_1_21_2","text":"东营市","value":"东营市","open":true},{"pId":"0_1_21","id":"0_1_21_3","text":"菏泽市","value":"菏泽市","open":true},{"pId":"0_1_21","id":"0_1_21_4","text":"济南市","value":"济南市","open":true},{"pId":"0_1_21","id":"0_1_21_5","text":"济宁市","value":"济宁市","open":true},{"pId":"0_1_21","id":"0_1_21_6","text":"莱芜市","value":"莱芜市","open":true},{"pId":"0_1_21","id":"0_1_21_7","text":"聊城市","value":"聊城市","open":true},{"pId":"0_1_21","id":"0_1_21_8","text":"临沂市","value":"临沂市","open":true},{"pId":"0_1_21","id":"0_1_21_9","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_21","id":"0_1_21_10","text":"日照市","value":"日照市","open":true},{"pId":"0_1_21","id":"0_1_21_11","text":"泰安市","value":"泰安市","open":true},{"pId":"0_1_21","id":"0_1_21_12","text":"威海市","value":"威海市","open":true},{"pId":"0_1_21","id":"0_1_21_13","text":"潍坊市","value":"潍坊市","open":true},{"pId":"0_1_21","id":"0_1_21_14","text":"烟台市","value":"烟台市","open":true},{"pId":"0_1_21","id":"0_1_21_15","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_1_21","id":"0_1_21_16","text":"淄博市","value":"淄博市","open":true},{"pId":"0_1","id":"0_1_22","text":"山西省( 共12个 )","value":"山西省","open":true},{"pId":"0_1_22","id":"0_1_22_0","text":"长治市","value":"长治市","open":true},{"pId":"0_1_22","id":"0_1_22_1","text":"大同市","value":"大同市","open":true},{"pId":"0_1_22","id":"0_1_22_2","text":"晋城市","value":"晋城市","open":true},{"pId":"0_1_22","id":"0_1_22_3","text":"晋中市","value":"晋中市","open":true},{"pId":"0_1_22","id":"0_1_22_4","text":"临汾市","value":"临汾市","open":true},{"pId":"0_1_22","id":"0_1_22_5","text":"吕梁市","value":"吕梁市","open":true},{"pId":"0_1_22","id":"0_1_22_6","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_22","id":"0_1_22_7","text":"朔州市","value":"朔州市","open":true},{"pId":"0_1_22","id":"0_1_22_8","text":"太原市","value":"太原市","open":true},{"pId":"0_1_22","id":"0_1_22_9","text":"忻州市","value":"忻州市","open":true},{"pId":"0_1_22","id":"0_1_22_10","text":"阳泉市","value":"阳泉市","open":true},{"pId":"0_1_22","id":"0_1_22_11","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_23","text":"陕西省( 共9个 )","value":"陕西省","open":true},{"pId":"0_1_23","id":"0_1_23_0","text":"安康市","value":"安康市","open":true},{"pId":"0_1_23","id":"0_1_23_1","text":"宝鸡市","value":"宝鸡市","open":true},{"pId":"0_1_23","id":"0_1_23_2","text":"汉中市","value":"汉中市","open":true},{"pId":"0_1_23","id":"0_1_23_3","text":"商洛市","value":"商洛市","open":true},{"pId":"0_1_23","id":"0_1_23_4","text":"渭南市","value":"渭南市","open":true},{"pId":"0_1_23","id":"0_1_23_5","text":"西安市","value":"西安市","open":true},{"pId":"0_1_23","id":"0_1_23_6","text":"咸阳市","value":"咸阳市","open":true},{"pId":"0_1_23","id":"0_1_23_7","text":"延安市","value":"延安市","open":true},{"pId":"0_1_23","id":"0_1_23_8","text":"榆林市","value":"榆林市","open":true},{"pId":"0_1","id":"0_1_24","text":"上海市( 共19个 )","value":"上海市","open":true},{"pId":"0_1_24","id":"0_1_24_0","text":"宝山区","value":"宝山区","open":true},{"pId":"0_1_24","id":"0_1_24_1","text":"长宁区","value":"长宁区","open":true},{"pId":"0_1_24","id":"0_1_24_2","text":"崇明县","value":"崇明县","open":true},{"pId":"0_1_24","id":"0_1_24_3","text":"奉贤区","value":"奉贤区","open":true},{"pId":"0_1_24","id":"0_1_24_4","text":"虹口区","value":"虹口区","open":true},{"pId":"0_1_24","id":"0_1_24_5","text":"黄浦区","value":"黄浦区","open":true},{"pId":"0_1_24","id":"0_1_24_6","text":"嘉定区","value":"嘉定区","open":true},{"pId":"0_1_24","id":"0_1_24_7","text":"金山区","value":"金山区","open":true},{"pId":"0_1_24","id":"0_1_24_8","text":"静安区","value":"静安区","open":true},{"pId":"0_1_24","id":"0_1_24_9","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_24","id":"0_1_24_10","text":"闵行区","value":"闵行区","open":true},{"pId":"0_1_24","id":"0_1_24_11","text":"普陀区","value":"普陀区","open":true},{"pId":"0_1_24","id":"0_1_24_12","text":"浦东新区","value":"浦东新区","open":true},{"pId":"0_1_24","id":"0_1_24_13","text":"青浦区","value":"青浦区","open":true},{"pId":"0_1_24","id":"0_1_24_14","text":"上海市区","value":"上海市区","open":true},{"pId":"0_1_24","id":"0_1_24_15","text":"松江区","value":"松江区","open":true},{"pId":"0_1_24","id":"0_1_24_16","text":"徐汇区","value":"徐汇区","open":true},{"pId":"0_1_24","id":"0_1_24_17","text":"杨浦区","value":"杨浦区","open":true},{"pId":"0_1_24","id":"0_1_24_18","text":"闸北区","value":"闸北区","open":true},{"pId":"0_1","id":"0_1_25","text":"四川省( 共21个 )","value":"四川省","open":true},{"pId":"0_1_25","id":"0_1_25_0","text":"阿坝藏族羌族自治州","value":"阿坝藏族羌族自治州","open":true},{"pId":"0_1_25","id":"0_1_25_1","text":"巴中市","value":"巴中市","open":true},{"pId":"0_1_25","id":"0_1_25_2","text":"成都市","value":"成都市","open":true},{"pId":"0_1_25","id":"0_1_25_3","text":"达州市","value":"达州市","open":true},{"pId":"0_1_25","id":"0_1_25_4","text":"德阳市","value":"德阳市","open":true},{"pId":"0_1_25","id":"0_1_25_5","text":"甘孜市","value":"甘孜市","open":true},{"pId":"0_1_25","id":"0_1_25_6","text":"广安市","value":"广安市","open":true},{"pId":"0_1_25","id":"0_1_25_7","text":"广元市","value":"广元市","open":true},{"pId":"0_1_25","id":"0_1_25_8","text":"乐山市","value":"乐山市","open":true},{"pId":"0_1_25","id":"0_1_25_9","text":"凉山市","value":"凉山市","open":true},{"pId":"0_1_25","id":"0_1_25_10","text":"泸州市","value":"泸州市","open":true},{"pId":"0_1_25","id":"0_1_25_11","text":"眉山市","value":"眉山市","open":true},{"pId":"0_1_25","id":"0_1_25_12","text":"绵阳市","value":"绵阳市","open":true},{"pId":"0_1_25","id":"0_1_25_13","text":"南充市","value":"南充市","open":true},{"pId":"0_1_25","id":"0_1_25_14","text":"内江市","value":"内江市","open":true},{"pId":"0_1_25","id":"0_1_25_15","text":"攀枝花市","value":"攀枝花市","open":true},{"pId":"0_1_25","id":"0_1_25_16","text":"遂宁市","value":"遂宁市","open":true},{"pId":"0_1_25","id":"0_1_25_17","text":"雅安市","value":"雅安市","open":true},{"pId":"0_1_25","id":"0_1_25_18","text":"宜宾市","value":"宜宾市","open":true},{"pId":"0_1_25","id":"0_1_25_19","text":"资阳市","value":"资阳市","open":true},{"pId":"0_1_25","id":"0_1_25_20","text":"自贡市","value":"自贡市","open":true},{"pId":"0_1","id":"0_1_26","text":"台湾( 共1个 )","value":"台湾","open":true},{"pId":"0_1_26","id":"0_1_26_0","text":"台北市","value":"台北市","open":true},{"pId":"0_1","id":"0_1_27","text":"天津市( 共1个 )","value":"天津市","open":true},{"pId":"0_1_27","id":"0_1_27_0","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1","id":"0_1_28","text":"西藏自治区( 共2个 )","value":"西藏自治区","open":true},{"pId":"0_1_28","id":"0_1_28_0","text":"阿里市","value":"阿里市","open":true},{"pId":"0_1_28","id":"0_1_28_1","text":"日喀则市","value":"日喀则市","open":true},{"pId":"0_1","id":"0_1_29","text":"香港特别行政区( 共1个 )","value":"香港特别行政区","open":true},{"pId":"0_1_29","id":"0_1_29_0","text":"香港","value":"香港","open":true},{"pId":"0_1","id":"0_1_30","text":"新疆维吾尔族自治区( 共11个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_1_30","id":"0_1_30_0","text":"巴音郭楞市","value":"巴音郭楞市","open":true},{"pId":"0_1_30","id":"0_1_30_1","text":"哈密市","value":"哈密市","open":true},{"pId":"0_1_30","id":"0_1_30_2","text":"和田市","value":"和田市","open":true},{"pId":"0_1_30","id":"0_1_30_3","text":"喀什地区","value":"喀什地区","open":true},{"pId":"0_1_30","id":"0_1_30_4","text":"克拉玛依市","value":"克拉玛依市","open":true},{"pId":"0_1_30","id":"0_1_30_5","text":"克孜勒苏柯州","value":"克孜勒苏柯州","open":true},{"pId":"0_1_30","id":"0_1_30_6","text":"石河子市","value":"石河子市","open":true},{"pId":"0_1_30","id":"0_1_30_7","text":"塔城市","value":"塔城市","open":true},{"pId":"0_1_30","id":"0_1_30_8","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_1_30","id":"0_1_30_9","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_1_30","id":"0_1_30_10","text":"伊犁市","value":"伊犁市","open":true},{"pId":"0_1","id":"0_1_31","text":"云南省( 共12个 )","value":"云南省","open":true},{"pId":"0_1_31","id":"0_1_31_0","text":"保山市","value":"保山市","open":true},{"pId":"0_1_31","id":"0_1_31_1","text":"楚雄彝族自治州","value":"楚雄彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_2","text":"大理白族自治州","value":"大理白族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_3","text":"红河哈尼族彝族自治州","value":"红河哈尼族彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_4","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_31","id":"0_1_31_5","text":"丽江市","value":"丽江市","open":true},{"pId":"0_1_31","id":"0_1_31_6","text":"临沧市","value":"临沧市","open":true},{"pId":"0_1_31","id":"0_1_31_7","text":"曲靖市","value":"曲靖市","open":true},{"pId":"0_1_31","id":"0_1_31_8","text":"思茅市","value":"思茅市","open":true},{"pId":"0_1_31","id":"0_1_31_9","text":"文山市","value":"文山市","open":true},{"pId":"0_1_31","id":"0_1_31_10","text":"玉溪市","value":"玉溪市","open":true},{"pId":"0_1_31","id":"0_1_31_11","text":"昭通市","value":"昭通市","open":true},{"pId":"0_1","id":"0_1_32","text":"浙江省( 共12个 )","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_1_32","id":"0_1_32_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_1_32","id":"0_1_32_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_1_32","id":"0_1_32_3","text":"金华市","value":"金华市","open":true},{"pId":"0_1_32","id":"0_1_32_4","text":"丽水市","value":"丽水市","open":true},{"pId":"0_1_32","id":"0_1_32_5","text":"宁波市","value":"宁波市","open":true},{"pId":"0_1_32","id":"0_1_32_6","text":"衢州市","value":"衢州市","open":true},{"pId":"0_1_32","id":"0_1_32_7","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_1_32","id":"0_1_32_8","text":"台州市","value":"台州市","open":true},{"pId":"0_1_32","id":"0_1_32_9","text":"温州市","value":"温州市","open":true},{"pId":"0_1_32","id":"0_1_32_10","text":"浙江省","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_11","text":"舟山市","value":"舟山市","open":true},{"pId":"0_1","id":"0_1_33","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_1_33","id":"0_1_33_0","text":"重庆市区","value":"重庆市区","open":true}],
+
+ TREE:[{id: -1, pId: -2, value: "根目录", text: "根目录"},
+ {id: 1, pId: -1, value: "第一级目录1", text: "第一级目录1"},
+ {id: 11, pId: 1, value: "第二级文件1", text: "第二级文件1"},
+ {id: 12, pId: 1, value: "第二级目录2", text: "第二级目录2"},
+ {id: 121, pId: 12, value: "第三级目录1", text: "第三级目录1"},
+ {id: 122, pId: 12, value: "第三级文件1", text: "第三级文件1"},
+ {id: 1211, pId: 121, value: "第四级目录1", text: "第四级目录1"},
+ {id: 12111, pId: 1211, value: "第五级文件1", text: "第五级文件1"},
+ {id: 2, pId: -1, value: "第一级目录2", text: "第一级目录2"},
+ {id: 21, pId: 2, value: "第二级目录3", text: "第二级目录3"},
+ {id: 22, pId: 2, value: "第二级文件2", text: "第二级文件2"},
+ {id: 211, pId: 21, value: "第三级目录2", text: "第三级目录2"},
+ {id: 212, pId: 21, value: "第三级文件2", text: "第三级文件2"},
+ {id: 2111, pId: 211, value: "第四级文件1", text: "第四级文件1"}]
};
diff --git a/docs/icon/arrow left right.png b/docs/icon/arrow left right.png
new file mode 100644
index 000000000..2a87a9b46
Binary files /dev/null and b/docs/icon/arrow left right.png differ
diff --git a/docs/icon/radio.png b/docs/icon/radio.png
new file mode 100644
index 000000000..489346819
Binary files /dev/null and b/docs/icon/radio.png differ
diff --git a/docs/icon/slider.png b/docs/icon/slider.png
new file mode 100644
index 000000000..0211186da
Binary files /dev/null and b/docs/icon/slider.png differ
diff --git a/docs/icon/双向箭头.png b/docs/icon/双向箭头.png
new file mode 100644
index 000000000..c816d0394
Binary files /dev/null and b/docs/icon/双向箭头.png differ
diff --git a/docs/index.html b/docs/index.html
index 0db30acc5..4c893684b 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1,33 +1,31 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
\ No newline at end of file
diff --git a/docs/polyfill.js b/docs/polyfill.js
index 1da80799f..f493c89a5 100644
--- a/docs/polyfill.js
+++ b/docs/polyfill.js
@@ -1,93 +1,93 @@
-if(![].indexOf){
- /**
- * 检查指定的值是否在数组中
- * @param {Object} o 要检查的值
- * @return {Number} o在数组中的索引(如果不在数组中则返回-1)
- */
- Array.prototype.indexOf = function (o) {
- for (var i = 0, len = this.length; i < len; i++) {
- if (_.isEqual(o, this[i])) {
- return i;
- }
- }
- return -1;
- }
-}
-if(![].lastIndexOf){
- /**
- * 检查指定的值是否在数组中
- * ie67不支持数组的这个方法
- * @param {Object} o 要检查的值
- * @return {Number} o在数组中的索引(如果不在数组中则返回-1)
- */
- Array.prototype.lastIndexOf = function (o) {
- for (var len = this.length, i = len - 1; i >= 0; i--) {
- if (_.isEqual(o, this[i])) {
- return i;
- }
- }
- return -1;
- }
-}/**
- * 特殊情况
- * Created by wang on 15/6/23.
- */
-//解决console未定义问题 guy
-window.console = window.console || (function () {
- var c = {};
- c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile
- = c.clear = c.exception = c.trace = c.assert = function () {
- };
- return c;
- })();
-/*
- * 前端缓存
- */
-window.localStorage || (window.localStorage = {
- items: {},
- setItem: function (k, v) {
- BI.Cache.addCookie(k, v);
- },
- getItem: function (k) {
- return BI.Cache.getCookie(k);
- },
- removeItem: function (k) {
- BI.Cache.deleteCookie(k);
- },
- key: function () {
-
- },
- clear: function () {
- this.items = {};
- }
-});//修复ie9下sort方法的bug
-!function (window) {
- var ua = window.navigator.userAgent.toLowerCase(),
- reg = /msie|applewebkit.+safari/;
- if (reg.test(ua)) {
- var _sort = Array.prototype.sort;
- Array.prototype.sort = function (fn) {
- if (!!fn && typeof fn === 'function') {
- if (this.length < 2) {
- return this;
- }
- var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0;
- for (; i < l; i++) {
- for (j = i + 1; j < l; j++) {
- t = fn.call(this, this[i], this[j]);
- r = (typeof t === 'number' ? t :
- !!t ? 1 : 0) > 0;
- if (r === true) {
- tmp = this[i];
- this[i] = this[j];
- this[j] = tmp;
- }
- }
- }
- return this;
- } else {
- return _sort.call(this);
- }
- };
- }
+if(![].indexOf){
+ /**
+ * 检查指定的值是否在数组中
+ * @param {Object} o 要检查的值
+ * @return {Number} o在数组中的索引(如果不在数组中则返回-1)
+ */
+ Array.prototype.indexOf = function (o) {
+ for (var i = 0, len = this.length; i < len; i++) {
+ if (_.isEqual(o, this[i])) {
+ return i;
+ }
+ }
+ return -1;
+ }
+}
+if(![].lastIndexOf){
+ /**
+ * 检查指定的值是否在数组中
+ * ie67不支持数组的这个方法
+ * @param {Object} o 要检查的值
+ * @return {Number} o在数组中的索引(如果不在数组中则返回-1)
+ */
+ Array.prototype.lastIndexOf = function (o) {
+ for (var len = this.length, i = len - 1; i >= 0; i--) {
+ if (_.isEqual(o, this[i])) {
+ return i;
+ }
+ }
+ return -1;
+ }
+}/**
+ * 特殊情况
+ * Created by wang on 15/6/23.
+ */
+//解决console未定义问题 guy
+window.console = window.console || (function () {
+ var c = {};
+ c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile
+ = c.clear = c.exception = c.trace = c.assert = function () {
+ };
+ return c;
+ })();
+/*
+ * 前端缓存
+ */
+window.localStorage || (window.localStorage = {
+ items: {},
+ setItem: function (k, v) {
+ BI.Cache.addCookie(k, v);
+ },
+ getItem: function (k) {
+ return BI.Cache.getCookie(k);
+ },
+ removeItem: function (k) {
+ BI.Cache.deleteCookie(k);
+ },
+ key: function () {
+
+ },
+ clear: function () {
+ this.items = {};
+ }
+});//修复ie9下sort方法的bug
+!function (window) {
+ var ua = window.navigator.userAgent.toLowerCase(),
+ reg = /msie|applewebkit.+safari/;
+ if (reg.test(ua)) {
+ var _sort = Array.prototype.sort;
+ Array.prototype.sort = function (fn) {
+ if (!!fn && typeof fn === 'function') {
+ if (this.length < 2) {
+ return this;
+ }
+ var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0;
+ for (; i < l; i++) {
+ for (j = i + 1; j < l; j++) {
+ t = fn.call(this, this[i], this[j]);
+ r = (typeof t === 'number' ? t :
+ !!t ? 1 : 0) > 0;
+ if (r === true) {
+ tmp = this[i];
+ this[i] = this[j];
+ this[j] = tmp;
+ }
+ }
+ }
+ return this;
+ } else {
+ return _sort.call(this);
+ }
+ };
+ }
}(window);
\ No newline at end of file
diff --git a/docs/widget.css b/docs/widget.css
index 0d58f4cd4..d07adc5bf 100644
--- a/docs/widget.css
+++ b/docs/widget.css
@@ -1,416 +1,416 @@
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-arrangement .arrangement-helper {
- background: #3f8ce8;
- z-index: 1000000000;
-}
-.bi-arrangement .arrangement-block {
- z-index: 1000000000;
-}
-.bi-arrangement .arrangement-drop-container {
- z-index: 1000000000;
-}
-.bi-arrangement .arrangement-drop-container .arrangement-drop-region {
- overflow: hidden;
-}
-.bi-arrangement .arrangement-drop-container .drop-devider {
- z-index: 1000000001;
- background: #3f8ce8;
-}
-.bi-arrangement .arrangement-drop-container .top-left,
-.bi-arrangement .arrangement-drop-container .top-right,
-.bi-arrangement .arrangement-drop-container .bottom-left,
-.bi-arrangement .arrangement-drop-container .bottom-right,
-.bi-arrangement .arrangement-drop-container .top-left-second,
-.bi-arrangement .arrangement-drop-container .top-right-second,
-.bi-arrangement .arrangement-drop-container .bottom-left-second,
-.bi-arrangement .arrangement-drop-container .bottom-right-second,
-.bi-arrangement .arrangement-drop-container .top-center,
-.bi-arrangement .arrangement-drop-container .bottom-center,
-.bi-arrangement .arrangement-drop-container .left-center,
-.bi-arrangement .arrangement-drop-container .right-center,
-.bi-arrangement .arrangement-drop-container .top-center-second,
-.bi-arrangement .arrangement-drop-container .bottom-center-second,
-.bi-arrangement .arrangement-drop-container .left-center-second,
-.bi-arrangement .arrangement-drop-container .right-center-second {
- z-index: 1000000001;
- background: #3f8ce8;
-}
-.bi-arrangement-droppable {
- z-index: 100000;
-}
-/****添加计算宽度的--运算符直接需要space****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-adapt-editor .adapt-editor-text {
- font-size: 14px;
-}
-/****添加计算宽度的--运算符直接需要space****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-/*************BI.SearchEditor******************/
-.bi-search-editor {
- border: 1px solid #d4dadd;
-}
-.bi-search-editor .close-font {
- font-size: 20px;
-}
-.bi-search-editor .search-font {
- font-size: 20px;
-}
-/****添加计算宽度的--运算符直接需要space****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-/*************BI.SearchEditor******************/
-.bi-small-search-editor .bi-editor {
- font-size: 12px;
-}
-.bi-small-search-editor .bi-editor .bi-input {
- font-size: 12px;
-}
-.bi-small-search-editor .bi-editor .bi-label {
- font-size: 12px;
-}
-.bi-small-search-editor .close-font {
- font-size: 18px;
-}
-.bi-small-search-editor .search-font {
- font-size: 18px;
-}
-/****添加计算宽度的--运算符直接需要space****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-sign-initial-editor .sign-initial-editor-text {
- font-size: 14px;
-}
-/****添加计算宽度的--运算符直接需要space****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-sign-style-editor .sign-style-editor-text {
- max-width: 100%;
- font-size: 12px;
-}
-.bi-sign-style-editor .sign-style-editor-tip {
- max-width: 100%;
- font-size: 12px;
- color: #808080;
-}
-/****添加计算宽度的--运算符直接需要space****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-text-editor {
- border: 1px solid #d4dadd;
-}
-/****添加计算宽度的--运算符直接需要space****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-/*************BI.SearchEditor******************/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-date-trigger {
- -webkit-border-radius: 2px;
- -moz-border-radius: 2px;
- border-radius: 2px;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-down-list-popup .bi-down-list-item .list-item-text {
- max-width: 203px;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-excel-table > div.bottom-right > div > div > table {
- border-right: 1px solid #d4dadd;
-}
-.bi-theme-dark .bi-excel-table > div.bottom-right > div > div > table {
- border-right: 1px solid #525466;
-}
-.bi-excel-table-header-cell {
- font-weight: bold;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-file-manager-nav-button .file-manager-nav-button-text {
- max-width: 200px;
-}
-.bi-file-manager-nav-button .file-manager-nav-button-text.active {
- background-color: #eff1f4;
- color: #999999;
-}
-.bi-file-manager-nav-button .file-manager-nav-button-triangle {
- z-index: 1;
-}
-.bi-theme-dark .bi-file-manager-nav-button .file-manager-nav-button-text.active {
- background-color: #191b2b;
- color: #999999;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-fine-tuning-number-editor {
- -webkit-border-radius: 2px;
- -moz-border-radius: 2px;
- border-radius: 2px;
-}
-.bi-interactive-arrangement .interactive-arrangement-dragtag-line {
- z-index: 1000000000;
- background-color: #f07d0a;
-}
-.bi-interactive-arrangement .interactive-arrangement-dragtag-icon {
- z-index: 1000000000;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-month-trigger {
- -webkit-border-radius: 2px;
- -moz-border-radius: 2px;
- border-radius: 2px;
-}
-.bi-multi-select-check-pane .multi-select-check-selected {
- text-decoration: underline;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-multi-select-combo .multi-select-trigger-icon-button {
- font-size: 16px;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-multi-select-trigger {
- -webkit-border-radius: 2px 2px 2px 2px;
- -moz-border-radius: 2px 2px 2px 2px;
- border-radius: 2px 2px 2px 2px;
-}
-.bi-multi-select-search-pane .multi-select-toolbar {
- color: #e85050;
-}
-.bi-multi-select-check-selected-button {
- z-index: 1;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-multi-tree-check-pane .multi-tree-check-selected {
- color: #3f8ce8;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-multi-tree-combo .multi-select-trigger-icon-button {
- font-size: 16px;
-}
-.bi-multi-tree-popup .popup-view-tree {
- min-height: 170px;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-multi-tree-check-selected-button .trigger-check-selected {
- color: #3f8ce8;
- z-index: 1;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-numerical-interval .numerical-interval-small-editor {
- -moz-border-radius-topleft: 2px;
- -webkit-border-top-left-radius: 2px;
- -moz-border-radius-bottomleft: 2px;
- -webkit-border-bottom-left-radius: 2px;
- border-top-left-radius: 2px;
- border-bottom-left-radius: 2px;
-}
-.bi-numerical-interval .numerical-interval-big-editor {
- -moz-border-radius-topright: 2px;
- -webkit-border-top-right-radius: 2px;
- -moz-border-radius-bottomright: 2px;
- -webkit-border-bottom-right-radius: 2px;
- border-top-right-radius: 2px;
- border-bottom-right-radius: 2px;
-}
-.bi-numerical-interval .numerical-interval-big-combo {
- -moz-border-radius-topleft: 2px;
- -webkit-border-top-left-radius: 2px;
- -moz-border-radius-bottomleft: 2px;
- -webkit-border-bottom-left-radius: 2px;
- border-top-left-radius: 2px;
- border-bottom-left-radius: 2px;
-}
-.bi-numerical-interval .numerical-interval-big-combo .bi-icon-combo-trigger .icon-combo-trigger-icon {
- font-size: 14px;
-}
-.bi-numerical-interval .numerical-interval-small-combo {
- -moz-border-radius-topright: 2px;
- -webkit-border-top-right-radius: 2px;
- -moz-border-radius-bottomright: 2px;
- -webkit-border-bottom-right-radius: 2px;
- border-top-right-radius: 2px;
- border-bottom-right-radius: 2px;
-}
-.bi-numerical-interval .numerical-interval-small-combo .bi-icon-combo-trigger .icon-combo-trigger-icon {
- font-size: 14px;
-}
-.bi-numerical-interval.number-error .bi-input {
- color: #e85050;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-page-table-cell {
- -webkit-user-select: initial;
- -khtml-user-select: initial;
- -moz-user-select: initial;
- -ms-user-select: initial;
- -o-user-select: initial;
- user-select: initial;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-path-chooser .path-chooser-radio {
- z-index: 1;
-}
-.bi-path-region .path-region-label {
- z-index: 1;
-}
-.bi-preview-table-cell {
- min-height: 25px;
- min-width: 80px;
- max-width: 220px;
-}
-.bi-preview-table {
- -webkit-user-select: initial;
- -khtml-user-select: initial;
- -moz-user-select: initial;
- -ms-user-select: initial;
- -o-user-select: initial;
- user-select: initial;
-}
-.bi-preview-table > div > table > thead > tr.odd,
-.bi-preview-table > div > div > div > table > thead > tr.odd {
- background-color: #eff1f4;
-}
-.bi-theme-dark .bi-preview-table > div > table > thead > tr.odd,
-.bi-theme-dark .bi-preview-table > div > div > div > table > thead > tr.odd {
- background-color: #191b2b;
-}
-.bi-preview-table-header-cell {
- font-weight: bold;
- min-height: 25px;
- min-width: 80px;
- max-width: 220px;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-quarter-trigger {
- -webkit-border-radius: 2px;
- -moz-border-radius: 2px;
- border-radius: 2px;
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-relation-view-region .relation-view-region-container {
- z-index: 1;
- -webkit-border-radius: 2px;
- -moz-border-radius: 2px;
- border-radius: 2px;
-}
-.bi-relation-view-region .relation-view-region-container.other-package {
- border-style: dashed;
-}
-.bi-sequence-table-dynamic-number .sequence-table-title-cell {
- overflow: hidden;
- overflow-x: hidden;
- overflow-y: hidden;
- -webkit-box-sizing: border-box;
- /*Safari3.2+*/
- -moz-box-sizing: border-box;
- /*Firefox3.5+*/
- -ms-box-sizing: border-box;
- /*IE8*/
- box-sizing: border-box;
- /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
-}
-.bi-sequence-table-dynamic-number .sequence-table-number-cell {
- -webkit-box-sizing: border-box;
- /*Safari3.2+*/
- -moz-box-sizing: border-box;
- /*Firefox3.5+*/
- -ms-box-sizing: border-box;
- /*IE8*/
- box-sizing: border-box;
- /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
-}
-.bi-sequence-table-list-number .sequence-table-title-cell {
- overflow: hidden;
- overflow-x: hidden;
- overflow-y: hidden;
- -webkit-box-sizing: border-box;
- /*Safari3.2+*/
- -moz-box-sizing: border-box;
- /*Firefox3.5+*/
- -ms-box-sizing: border-box;
- /*IE8*/
- box-sizing: border-box;
- /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
-}
-.bi-sequence-table-list-number .sequence-table-number-cell {
- -webkit-box-sizing: border-box;
- /*Safari3.2+*/
- -moz-box-sizing: border-box;
- /*Firefox3.5+*/
- -ms-box-sizing: border-box;
- /*IE8*/
- box-sizing: border-box;
- /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-sequence-table-tree-number .sequence-table-title-cell {
- overflow: hidden;
- overflow-x: hidden;
- overflow-y: hidden;
- -webkit-box-sizing: border-box;
- /*Safari3.2+*/
- -moz-box-sizing: border-box;
- /*Firefox3.5+*/
- -ms-box-sizing: border-box;
- /*IE8*/
- box-sizing: border-box;
- /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
-}
-.bi-sequence-table-tree-number .sequence-table-number-cell {
- -webkit-box-sizing: border-box;
- /*Safari3.2+*/
- -moz-box-sizing: border-box;
- /*Firefox3.5+*/
- -ms-box-sizing: border-box;
- /*IE8*/
- box-sizing: border-box;
- /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
-}
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-/****** common color(常用颜色,可用于普遍场景) *****/
-/**** custom color(自定义颜色,用于特定场景) ****/
-.bi-year-popup .year-popup-navigation {
- line-height: 30px;
-}
-.bi-year-popup .year-popup-navigation > .center-element {
- border-left: 1px solid #d4dadd;
-}
-.bi-year-popup .year-popup-navigation > .first-element {
- border-left: none;
-}
-.bi-theme-dark .bi-year-popup .year-popup-navigation > .center-element {
- border-left: 1px solid #525466;
-}
-.bi-theme-dark .bi-year-popup .year-popup-navigation > .first-element {
- border-left: none;
-}
-.bi-year-trigger {
- -webkit-border-radius: 2px;
- -moz-border-radius: 2px;
- border-radius: 2px;
-}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-arrangement .arrangement-helper {
+ background: #3f8ce8;
+ z-index: 1000000000;
+}
+.bi-arrangement .arrangement-block {
+ z-index: 1000000000;
+}
+.bi-arrangement .arrangement-drop-container {
+ z-index: 1000000000;
+}
+.bi-arrangement .arrangement-drop-container .arrangement-drop-region {
+ overflow: hidden;
+}
+.bi-arrangement .arrangement-drop-container .drop-devider {
+ z-index: 1000000001;
+ background: #3f8ce8;
+}
+.bi-arrangement .arrangement-drop-container .top-left,
+.bi-arrangement .arrangement-drop-container .top-right,
+.bi-arrangement .arrangement-drop-container .bottom-left,
+.bi-arrangement .arrangement-drop-container .bottom-right,
+.bi-arrangement .arrangement-drop-container .top-left-second,
+.bi-arrangement .arrangement-drop-container .top-right-second,
+.bi-arrangement .arrangement-drop-container .bottom-left-second,
+.bi-arrangement .arrangement-drop-container .bottom-right-second,
+.bi-arrangement .arrangement-drop-container .top-center,
+.bi-arrangement .arrangement-drop-container .bottom-center,
+.bi-arrangement .arrangement-drop-container .left-center,
+.bi-arrangement .arrangement-drop-container .right-center,
+.bi-arrangement .arrangement-drop-container .top-center-second,
+.bi-arrangement .arrangement-drop-container .bottom-center-second,
+.bi-arrangement .arrangement-drop-container .left-center-second,
+.bi-arrangement .arrangement-drop-container .right-center-second {
+ z-index: 1000000001;
+ background: #3f8ce8;
+}
+.bi-arrangement-droppable {
+ z-index: 100000;
+}
+/****添加计算宽度的--运算符直接需要space****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-adapt-editor .adapt-editor-text {
+ font-size: 14px;
+}
+/****添加计算宽度的--运算符直接需要space****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+/*************BI.SearchEditor******************/
+.bi-search-editor {
+ border: 1px solid #d4dadd;
+}
+.bi-search-editor .close-font {
+ font-size: 20px;
+}
+.bi-search-editor .search-font {
+ font-size: 20px;
+}
+/****添加计算宽度的--运算符直接需要space****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+/*************BI.SearchEditor******************/
+.bi-small-search-editor .bi-editor {
+ font-size: 12px;
+}
+.bi-small-search-editor .bi-editor .bi-input {
+ font-size: 12px;
+}
+.bi-small-search-editor .bi-editor .bi-label {
+ font-size: 12px;
+}
+.bi-small-search-editor .close-font {
+ font-size: 18px;
+}
+.bi-small-search-editor .search-font {
+ font-size: 18px;
+}
+/****添加计算宽度的--运算符直接需要space****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-sign-initial-editor .sign-initial-editor-text {
+ font-size: 14px;
+}
+/****添加计算宽度的--运算符直接需要space****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-sign-style-editor .sign-style-editor-text {
+ max-width: 100%;
+ font-size: 12px;
+}
+.bi-sign-style-editor .sign-style-editor-tip {
+ max-width: 100%;
+ font-size: 12px;
+ color: #808080;
+}
+/****添加计算宽度的--运算符直接需要space****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-text-editor {
+ border: 1px solid #d4dadd;
+}
+/****添加计算宽度的--运算符直接需要space****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+/*************BI.SearchEditor******************/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-date-trigger {
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-down-list-popup .bi-down-list-item .list-item-text {
+ max-width: 203px;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-excel-table > div.bottom-right > div > div > table {
+ border-right: 1px solid #d4dadd;
+}
+.bi-theme-dark .bi-excel-table > div.bottom-right > div > div > table {
+ border-right: 1px solid #525466;
+}
+.bi-excel-table-header-cell {
+ font-weight: bold;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-file-manager-nav-button .file-manager-nav-button-text {
+ max-width: 200px;
+}
+.bi-file-manager-nav-button .file-manager-nav-button-text.active {
+ background-color: #eff1f4;
+ color: #999999;
+}
+.bi-file-manager-nav-button .file-manager-nav-button-triangle {
+ z-index: 1;
+}
+.bi-theme-dark .bi-file-manager-nav-button .file-manager-nav-button-text.active {
+ background-color: #191b2b;
+ color: #999999;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-fine-tuning-number-editor {
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+}
+.bi-interactive-arrangement .interactive-arrangement-dragtag-line {
+ z-index: 1000000000;
+ background-color: #f07d0a;
+}
+.bi-interactive-arrangement .interactive-arrangement-dragtag-icon {
+ z-index: 1000000000;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-month-trigger {
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+}
+.bi-multi-select-check-pane .multi-select-check-selected {
+ text-decoration: underline;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-multi-select-combo .multi-select-trigger-icon-button {
+ font-size: 16px;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-multi-select-trigger {
+ -webkit-border-radius: 2px 2px 2px 2px;
+ -moz-border-radius: 2px 2px 2px 2px;
+ border-radius: 2px 2px 2px 2px;
+}
+.bi-multi-select-search-pane .multi-select-toolbar {
+ color: #e85050;
+}
+.bi-multi-select-check-selected-button {
+ z-index: 1;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-multi-tree-check-pane .multi-tree-check-selected {
+ color: #3f8ce8;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-multi-tree-combo .multi-select-trigger-icon-button {
+ font-size: 16px;
+}
+.bi-multi-tree-popup .popup-view-tree {
+ min-height: 170px;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-multi-tree-check-selected-button .trigger-check-selected {
+ color: #3f8ce8;
+ z-index: 1;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-numerical-interval .numerical-interval-small-editor {
+ -moz-border-radius-topleft: 2px;
+ -webkit-border-top-left-radius: 2px;
+ -moz-border-radius-bottomleft: 2px;
+ -webkit-border-bottom-left-radius: 2px;
+ border-top-left-radius: 2px;
+ border-bottom-left-radius: 2px;
+}
+.bi-numerical-interval .numerical-interval-big-editor {
+ -moz-border-radius-topright: 2px;
+ -webkit-border-top-right-radius: 2px;
+ -moz-border-radius-bottomright: 2px;
+ -webkit-border-bottom-right-radius: 2px;
+ border-top-right-radius: 2px;
+ border-bottom-right-radius: 2px;
+}
+.bi-numerical-interval .numerical-interval-big-combo {
+ -moz-border-radius-topleft: 2px;
+ -webkit-border-top-left-radius: 2px;
+ -moz-border-radius-bottomleft: 2px;
+ -webkit-border-bottom-left-radius: 2px;
+ border-top-left-radius: 2px;
+ border-bottom-left-radius: 2px;
+}
+.bi-numerical-interval .numerical-interval-big-combo .bi-icon-combo-trigger .icon-combo-trigger-icon {
+ font-size: 14px;
+}
+.bi-numerical-interval .numerical-interval-small-combo {
+ -moz-border-radius-topright: 2px;
+ -webkit-border-top-right-radius: 2px;
+ -moz-border-radius-bottomright: 2px;
+ -webkit-border-bottom-right-radius: 2px;
+ border-top-right-radius: 2px;
+ border-bottom-right-radius: 2px;
+}
+.bi-numerical-interval .numerical-interval-small-combo .bi-icon-combo-trigger .icon-combo-trigger-icon {
+ font-size: 14px;
+}
+.bi-numerical-interval.number-error .bi-input {
+ color: #e85050;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-page-table-cell {
+ -webkit-user-select: initial;
+ -khtml-user-select: initial;
+ -moz-user-select: initial;
+ -ms-user-select: initial;
+ -o-user-select: initial;
+ user-select: initial;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-path-chooser .path-chooser-radio {
+ z-index: 1;
+}
+.bi-path-region .path-region-label {
+ z-index: 1;
+}
+.bi-preview-table-cell {
+ min-height: 25px;
+ min-width: 80px;
+ max-width: 220px;
+}
+.bi-preview-table {
+ -webkit-user-select: initial;
+ -khtml-user-select: initial;
+ -moz-user-select: initial;
+ -ms-user-select: initial;
+ -o-user-select: initial;
+ user-select: initial;
+}
+.bi-preview-table > div > table > thead > tr.odd,
+.bi-preview-table > div > div > div > table > thead > tr.odd {
+ background-color: #eff1f4;
+}
+.bi-theme-dark .bi-preview-table > div > table > thead > tr.odd,
+.bi-theme-dark .bi-preview-table > div > div > div > table > thead > tr.odd {
+ background-color: #191b2b;
+}
+.bi-preview-table-header-cell {
+ font-weight: bold;
+ min-height: 25px;
+ min-width: 80px;
+ max-width: 220px;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-quarter-trigger {
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-relation-view-region .relation-view-region-container {
+ z-index: 1;
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+}
+.bi-relation-view-region .relation-view-region-container.other-package {
+ border-style: dashed;
+}
+.bi-sequence-table-dynamic-number .sequence-table-title-cell {
+ overflow: hidden;
+ overflow-x: hidden;
+ overflow-y: hidden;
+ -webkit-box-sizing: border-box;
+ /*Safari3.2+*/
+ -moz-box-sizing: border-box;
+ /*Firefox3.5+*/
+ -ms-box-sizing: border-box;
+ /*IE8*/
+ box-sizing: border-box;
+ /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
+}
+.bi-sequence-table-dynamic-number .sequence-table-number-cell {
+ -webkit-box-sizing: border-box;
+ /*Safari3.2+*/
+ -moz-box-sizing: border-box;
+ /*Firefox3.5+*/
+ -ms-box-sizing: border-box;
+ /*IE8*/
+ box-sizing: border-box;
+ /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
+}
+.bi-sequence-table-list-number .sequence-table-title-cell {
+ overflow: hidden;
+ overflow-x: hidden;
+ overflow-y: hidden;
+ -webkit-box-sizing: border-box;
+ /*Safari3.2+*/
+ -moz-box-sizing: border-box;
+ /*Firefox3.5+*/
+ -ms-box-sizing: border-box;
+ /*IE8*/
+ box-sizing: border-box;
+ /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
+}
+.bi-sequence-table-list-number .sequence-table-number-cell {
+ -webkit-box-sizing: border-box;
+ /*Safari3.2+*/
+ -moz-box-sizing: border-box;
+ /*Firefox3.5+*/
+ -ms-box-sizing: border-box;
+ /*IE8*/
+ box-sizing: border-box;
+ /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-sequence-table-tree-number .sequence-table-title-cell {
+ overflow: hidden;
+ overflow-x: hidden;
+ overflow-y: hidden;
+ -webkit-box-sizing: border-box;
+ /*Safari3.2+*/
+ -moz-box-sizing: border-box;
+ /*Firefox3.5+*/
+ -ms-box-sizing: border-box;
+ /*IE8*/
+ box-sizing: border-box;
+ /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
+}
+.bi-sequence-table-tree-number .sequence-table-number-cell {
+ -webkit-box-sizing: border-box;
+ /*Safari3.2+*/
+ -moz-box-sizing: border-box;
+ /*Firefox3.5+*/
+ -ms-box-sizing: border-box;
+ /*IE8*/
+ box-sizing: border-box;
+ /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
+}
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+/****** common color(常用颜色,可用于普遍场景) *****/
+/**** custom color(自定义颜色,用于特定场景) ****/
+.bi-year-popup .year-popup-navigation {
+ line-height: 30px;
+}
+.bi-year-popup .year-popup-navigation > .center-element {
+ border-left: 1px solid #d4dadd;
+}
+.bi-year-popup .year-popup-navigation > .first-element {
+ border-left: none;
+}
+.bi-theme-dark .bi-year-popup .year-popup-navigation > .center-element {
+ border-left: 1px solid #525466;
+}
+.bi-theme-dark .bi-year-popup .year-popup-navigation > .first-element {
+ border-left: none;
+}
+.bi-year-trigger {
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+}
diff --git a/docs/widget.js b/docs/widget.js
index 89c141e2c..79c275717 100644
--- a/docs/widget.js
+++ b/docs/widget.js
@@ -1,16131 +1,17182 @@
-/**
- *
- * Created by GUY on 2016/5/26.
- * @class BI.SequenceTableTreeNumber
- * @extends BI.Widget
- */
-BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-sequence-table-tree-number",
- isNeedFreeze: false,
- startSequence: 1,//开始的序号
- scrollTop: 0,
- headerRowSize: 25,
- rowSize: 25,
-
- sequenceHeaderCreator: null,
-
- header: [],
- items: [], //二维数组
-
- //交叉表头
- crossHeader: [],
- crossItems: []
- });
- },
-
- _init: function () {
- BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.vCurr = 1;
- this.hCurr = 1;
- this.tasks = [];
- this.renderedCells = [];
- this.renderedKeys = [];
-
- this.container = BI.createWidget({
- type: "bi.absolute",
- width: 60,
- scrollable: false
- });
-
- this.scrollContainer = BI.createWidget({
- type: "bi.vertical",
- scrollable: false,
- scrolly: false,
- items: [this.container]
- });
-
- this.headerContainer = BI.createWidget({
- type: "bi.absolute",
- cls: "bi-border",
- width: 58,
- scrollable: false
- });
-
- this.layout = BI.createWidget({
- type: "bi.vtape",
- element: this,
- items: [{
- el: this.headerContainer,
- height: this._getHeaderHeight() - 2
- }, {el: {type: "bi.layout"}, height: 2}, {
- el: this.scrollContainer
- }]
- });
- //缓存第一行对应的序号
- this.start = this.options.startSequence;
- this.cache = {};
- this._nextState();
-
- this._populate();
- },
-
- _getNextSequence: function (nodes) {
- var self = this;
- var start = this.start;
- var cnt = this.start;
-
- function track(node) {
- //如果已经有缓存了就不改计数了,复杂表会出现这种情况
- self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt);
- cnt++;
- }
-
- BI.each(nodes, function (i, node) {
- if (BI.isNotEmptyArray(node.children)) {
- BI.each(node.children, function (index, child) {
- if (index === 0) {
- if (self.cache[child.text || child.value]) {
- start = cnt = self.cache[child.text || child.value];
- }
- }
- track(child)
- });
- }
- });
- this.start = cnt;
- return start;
- },
-
- _getStart: function (nodes) {
- var self = this;
- var start = this.start;
- BI.some(nodes, function (i, node) {
- if (BI.isNotEmptyArray(node.children)) {
- return BI.some(node.children, function (index, child) {
- if (index === 0) {
- if (self.cache[child.text || child.value]) {
- start = self.cache[child.text || child.value];
- return true;
- }
- }
- });
- }
- });
- return start;
- },
-
- _formatNumber: function (nodes) {
- var self = this, o = this.options;
- var result = [];
- var count = this._getStart(nodes);
-
- function getLeafCount(node) {
- var cnt = 0;
- if (BI.isNotEmptyArray(node.children)) {
- BI.each(node.children, function (index, child) {
- cnt += getLeafCount(child);
- });
- if (/**node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) {
- cnt++;
- }
- } else {
- cnt++;
- }
- return cnt;
- }
-
- var start = 0, top = 0;
- BI.each(nodes, function (i, node) {
- if (BI.isArray(node.children)) {
- BI.each(node.children, function (index, child) {
- var cnt = getLeafCount(child);
- result.push({
- text: count++,
- start: start,
- top: top,
- cnt: cnt,
- index: index,
- height: cnt * o.rowSize
- });
- start += cnt;
- top += cnt * o.rowSize;
- });
- if (BI.isNotEmptyArray(node.values)) {
- result.push({
- text: BI.i18nText("BI-Summary_Values"),
- start: start++,
- top: top,
- cnt: 1,
- isSummary: true,
- height: o.rowSize
- });
- top += o.rowSize;
- }
- }
- });
- return result;
- },
-
- _layout: function () {
- var self = this, o = this.options;
- var headerHeight = this._getHeaderHeight() - 2;
- var items = this.layout.attr("items");
- if (o.isNeedFreeze === false) {
- items[0].height = 0;
- items[1].height = 0;
- } else if (o.isNeedFreeze === true) {
- items[0].height = headerHeight;
- items[1].height = 2;
- }
- this.layout.attr("items", items);
- this.layout.resize();
- try {
- this.scrollContainer.element.scrollTop(o.scrollTop);
- } catch (e) {
-
- }
- },
-
- _getHeaderHeight: function () {
- var o = this.options;
- return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0));
- },
-
- _nextState: function () {
- var o = this.options;
- this._getNextSequence(o.items);
- },
-
- _prevState: function () {
- var self = this, o = this.options;
- var firstChild;
- BI.some(o.items, function (i, node) {
- if (BI.isNotEmptyArray(node.children)) {
- return BI.some(node.children, function (j, child) {
- firstChild = child;
- return true;
- });
- }
- });
- if (firstChild && BI.isNotEmptyObject(this.cache)) {
- this.start = this.cache[firstChild.text || firstChild.value];
- } else {
- this.start = 1;
- }
- this._nextState();
- },
-
- _getMaxScrollTop: function (numbers) {
- var cnt = 0;
- BI.each(numbers, function (i, number) {
- cnt += number.cnt;
- });
- return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth());
- },
-
- _createHeader: function () {
- var o = this.options;
- BI.createWidget({
- type: "bi.absolute",
- element: this.headerContainer,
- items: [{
- el: o.sequenceHeaderCreator || {
- type: "bi.table_style_cell",
- cls: "sequence-table-title-cell",
- styleGetter: o.headerCellStyleGetter,
- text: BI.i18nText("BI-Number_Index")
- },
- left: 0,
- top: 0,
- right: 0,
- bottom: 0
- }]
- });
- },
-
- _calculateChildrenToRender: function () {
- var self = this, o = this.options;
-
- var renderedCells = [], renderedKeys = [];
- var numbers = this._formatNumber(o.items);
- var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0);
- BI.each(numbers, function (i, number) {
- intervalTree.set(i, number.height);
- });
- var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers));
- var index = intervalTree.greatestLowerBound(scrollTop);
- var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0));
- var height = offsetTop;
- var bodyHeight = o.height - this._getHeaderHeight();
- while (height < bodyHeight && index < numbers.length) {
- renderedKeys.push(index);
- offsetTop += numbers[index].height;
- height += numbers[index].height;
- index++;
- }
-
- BI.each(renderedKeys, function (i, key) {
- var index = BI.deepIndexOf(self.renderedKeys, key);
- if (index > -1) {
- if (numbers[key].height !== self.renderedCells[index]._height) {
- self.renderedCells[index]._height = numbers[key].height;
- self.renderedCells[index].el.setHeight(numbers[key].height);
- }
- if (numbers[key].top !== self.renderedCells[index].top) {
- self.renderedCells[index].top = numbers[key].top;
- self.renderedCells[index].el.element.css("top", numbers[key].top + "px");
- }
- renderedCells.push(self.renderedCells[index]);
- } else {
- var child = BI.createWidget(BI.extend({
- type: "bi.table_style_cell",
- cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",
- width: 60,
- styleGetter: numbers[key].isSummary === true ? function () {
- return o.summaryCellStyleGetter(true);
- } : function (key) {
- return function () {
- return o.sequenceCellStyleGetter(key);
- }
- }(numbers[key].index)
- }, numbers[key]));
- renderedCells.push({
- el: child,
- left: 0,
- top: numbers[key].top,
- _height: numbers[key].height
- });
- }
- });
-
- //已存在的, 需要添加的和需要删除的
- var existSet = {}, addSet = {}, deleteArray = [];
- BI.each(renderedKeys, function (i, key) {
- if (BI.deepContains(self.renderedKeys, key)) {
- existSet[i] = key;
- } else {
- addSet[i] = key;
- }
- });
- BI.each(this.renderedKeys, function (i, key) {
- if (BI.deepContains(existSet, key)) {
- return;
- }
- if (BI.deepContains(addSet, key)) {
- return;
- }
- deleteArray.push(i);
- });
- BI.each(deleteArray, function (i, index) {
- self.renderedCells[index].el.destroy();
- });
- var addedItems = [];
- BI.each(addSet, function (index) {
- addedItems.push(renderedCells[index])
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: addedItems
- });
- this.renderedCells = renderedCells;
- this.renderedKeys = renderedKeys;
-
- this.container.setHeight(intervalTree.sumUntil(numbers.length));
- },
-
- _restore: function () {
- BI.each(this.renderedCells, function (i, cell) {
- cell.el.destroy();
- });
- this.renderedCells = [];
- this.renderedKeys = [];
- },
-
- _populate: function () {
- var self = this;
- BI.each(this.tasks, function (i, task) {
- task.apply(self);
- });
- this.tasks = [];
- this.headerContainer.empty();
- this._createHeader();
- this._layout();
- this._calculateChildrenToRender();
- },
-
- setVerticalScroll: function (scrollTop) {
- if (this.options.scrollTop !== scrollTop) {
- this.options.scrollTop = scrollTop;
- try {
- this.scrollContainer.element.scrollTop(scrollTop);
- } catch (e) {
-
- }
- }
- },
-
- getVerticalScroll: function () {
- return this.options.scrollTop;
- },
-
- setVPage: function (v) {
- if (v <= 1) {
- this.cache = {};
- this.start = this.options.startSequence;
- this._restore();
- this.tasks.push(this._nextState);
- } else if (v === this.vCurr + 1) {
- this.tasks.push(this._nextState);
- } else if (v === this.vCurr - 1) {
- this.tasks.push(this._prevState);
- }
- this.vCurr = v;
- },
-
- setHPage: function (v) {
- if (v !== this.hCurr) {
- this.tasks.push(this._prevState);
- }
- this.hCurr = v;
- },
-
- restore: function () {
- this._restore();
- },
-
- populate: function (items, header, crossItems, crossHeader) {
- var o = this.options;
- if (items && items !== this.options.items) {
- o.items = items;
- this._restore();
- this.tasks.push(this._prevState);
- }
- if (header && header !== this.options.header) {
- o.header = header;
- }
- if (crossItems && crossItems !== this.options.crossItems) {
- o.crossItems = crossItems;
- }
- if (crossHeader && crossHeader !== this.options.crossHeader) {
- o.crossHeader = crossHeader;
- }
- this._populate();
- }
-});
-BI.shortcut('bi.sequence_table_tree_number', BI.SequenceTableTreeNumber);/**
- * 自适应布局
- *
- * 1、resize
- * 2、吸附
- * 3、当前组件在最上方
- * 4、可以撤销
- * 5、上下之间插入组件
- *
- * Created by GUY on 2016/2/23.
- * @class BI.AdaptiveArrangement
- * @extends BI.Widget
- */
-BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-adaptive-arrangement",
- resizable: true,
- layoutType: BI.Arrangement.LAYOUT_TYPE.FREE,
- items: []
- });
- },
-
- _init: function () {
- BI.AdaptiveArrangement.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.arrangement = BI.createWidget({
- type: "bi.arrangement",
- element: this,
- layoutType: o.layoutType,
- items: o.items
- });
- this.arrangement.on(BI.Arrangement.EVENT_SCROLL, function () {
- self.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL, arguments);
- });
- this.zIndex = 0;
- BI.each(o.items, function (i, item) {
- self._initResizable(item.el);
- });
-
- $(document).mousedown(function (e) {
- BI.each(self.getAllRegions(), function (i, region) {
- if (region.el.element.find(e.target).length === 0) {
- region.el.element.removeClass("selected");
- }
- });
- });
- BI.ResizeDetector.addResizeListener(this, function () {
- self.arrangement.resize();
- self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
- });
- },
-
- _isEqual: function () {
- return this.arrangement._isEqual.apply(this.arrangement, arguments);
- },
-
- _setSelect: function (item) {
- if (!item.element.hasClass("selected")) {
- item.element.css("zIndex", ++this.zIndex);
- BI.each(this.getAllRegions(), function (i, region) {
- region.el.element.removeClass("selected");
- });
- item.element.addClass("selected");
- }
- },
-
- _initResizable: function (item) {
- var self = this, o = this.options;
- item.element.css("zIndex", ++this.zIndex);
- item.element.mousedown(function () {
- self._setSelect(item)
- });
- // o.resizable && item.element.resizable({
- // handles: "e, s, se",
- // minWidth: 20,
- // minHeight: 20,
- // autoHide: true,
- // helper: "bi-resizer",
- // start: function () {
- // item.element.css("zIndex", ++self.zIndex);
- // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE);
- // },
- // resize: function (e, ui) {
- // // self._resize(item.attr("id"), ui.size);
- // self._resize(item.attr("id"), e, ui.size, ui.position);
- // },
- // stop: function (e, ui) {
- // self._stopResize(item.attr("id"), ui.size);
- // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size);
- // self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
- // }
- // });
- },
-
- // _resize: function (name, e, size, position) {
- // var self = this;
- // this.scrollInterval(e, false, true, function (changedSize) {
- // size.width += changedSize.offsetX;
- // size.height += changedSize.offsetY;
- // var containerWidth = self.arrangement.container.element.width();
- // var containerHeight = self.arrangement.container.element.height();
- // self.arrangement.container.element.width(containerWidth + changedSize.offsetX);
- // self.arrangement.container.element.height(containerHeight + changedSize.offsetY);
- // switch (self.getLayoutType()) {
- // case BI.Arrangement.LAYOUT_TYPE.FREE:
- // break;
- // case BI.Arrangement.LAYOUT_TYPE.GRID:
- // self.setRegionSize(name, size);
- // break;
- // }
- // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size);
- // });
- // },
- //
- // _stopResize: function (name, size) {
- // var self = this;
- // this.scrollEnd();
- // switch (this.getLayoutType()) {
- // case BI.Arrangement.LAYOUT_TYPE.FREE:
- // this.setRegionSize(name, size);
- // break;
- // case BI.Arrangement.LAYOUT_TYPE.GRID:
- // this.setRegionSize(name, size);
- // break;
- // }
- // },
-
- _getScrollOffset: function () {
- return this.arrangement._getScrollOffset();
- },
-
- getClientWidth: function () {
- return this.arrangement.getClientWidth();
- },
-
- getClientHeight: function () {
- return this.arrangement.getClientHeight();
- },
-
- addRegion: function (region, position) {
- this._initResizable(region.el);
- this._setSelect(region.el);
- var self = this, flag;
- var old = this.arrangement.getAllRegions();
- if (flag = this.arrangement.addRegion(region, position)) {
- this._old = old;
- }
- return flag;
- },
-
- deleteRegion: function (name) {
- var flag;
- var old = this.getAllRegions();
- if (flag = this.arrangement.deleteRegion(name)) {
- this._old = old;
- } else {
- this._old = this.getAllRegions();
- this.relayout();
- }
- return flag;
- },
-
- setRegionSize: function (name, size) {
- var flag;
- var old = this.getAllRegions();
- if (flag = this.arrangement.setRegionSize(name, size)) {
- this._old = old;
- }
- return flag;
- },
-
- setPosition: function (position, size) {
- var self = this;
- return this.arrangement.setPosition(position, size);
- },
-
- setRegionPosition: function (name, position) {
- var region = this.getRegionByName(name);
- return this.arrangement.setRegionPosition(name, position);
- },
-
- setDropPosition: function (position, size) {
- return this.arrangement.setDropPosition(position, size);
- },
-
- scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
- var self = this;
- var map = {
- top: [-1, 0],
- bottom: [1, 0],
- left: [0, -1],
- right: [0, 1]
- };
- var clientSize = this.element.bounds();
-
- function scrollTo(direction, callback) {
- if (direction === "") {
- self.lastActiveRegion = "";
- if (self._scrollInterval) {
- clearInterval(self._scrollInterval);
- self._scrollInterval = null;
- }
- return;
- }
- if (self.lastActiveRegion !== direction) {
- self.lastActiveRegion = direction;
- if (self._scrollInterval) {
- clearInterval(self._scrollInterval);
- self._scrollInterval = null;
- }
- self._scrollInterval = setInterval(function () {
- var offset = self._getScrollOffset();
- var t = offset.top + map[direction][0] * 40;
- var l = offset.left + map[direction][1] * 40;
- if (t < 0 || l < 0) {
- return;
- }
- callback({
- offsetX: map[direction][1] * 40,
- offsetY: map[direction][0] * 40
- });
- self.scrollTo({
- top: t,
- left: l
- });
- }, 300);
- }
- }
-
- cb({
- offsetX: 0,
- offsetY: 0
- });
- var offset = this.element.offset();
- var p = {
- left: e.pageX - offset.left,
- top: e.pageY - offset.top
- };
- //向上滚
- if (isBorderScroll && p.top >= 0 && p.top <= 30) {
- scrollTo("top", cb)
- }
- //向下滚
- else if (isBorderScroll && p.top >= clientSize.height - 30 && p.top <= clientSize.height) {
- scrollTo("bottom", cb)
- }
- //向左滚
- else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
- scrollTo("left", cb)
- }
- //向右滚
- else if (isBorderScroll && p.left >= clientSize.width - 30 && p.left <= clientSize.width) {
- scrollTo("right", cb)
- } else {
- if (isOverflowScroll === true) {
- if (p.top < 0) {
- scrollTo("top", cb);
- }
- else if (p.top > clientSize.height) {
- scrollTo("bottom", cb);
- }
- else if (p.left < 0) {
- scrollTo("left", cb);
- }
- else if (p.left > clientSize.width) {
- scrollTo("right", cb);
- } else {
- scrollTo("", cb);
- }
- } else {
- scrollTo("", cb);
- }
- }
- },
-
- scrollEnd: function () {
- this.lastActiveRegion = "";
- if (this._scrollInterval) {
- clearInterval(this._scrollInterval);
- this._scrollInterval = null;
- }
- },
-
- scrollTo: function (scroll) {
- this.arrangement.scrollTo(scroll);
- },
-
- zoom: function (ratio) {
- this.arrangement.zoom(ratio);
- },
-
- resize: function () {
- this.arrangement.resize();
- },
-
- relayout: function () {
- return this.arrangement.relayout();
- },
-
- setLayoutType: function (type) {
- var self = this;
- this.arrangement.setLayoutType(type);
- },
-
- getLayoutType: function () {
- return this.arrangement.getLayoutType();
- },
-
- getLayoutRatio: function () {
- return this.arrangement.getLayoutRatio();
- },
-
- getHelper: function () {
- return this.arrangement.getHelper();
- },
-
- getRegionByName: function (name) {
- return this.arrangement.getRegionByName(name);
- },
-
- getAllRegions: function () {
- return this.arrangement.getAllRegions();
- },
-
- revoke: function () {
- if (this._old) {
- this.populate(BI.toArray(this._old));
- }
- },
-
- populate: function (items) {
- var self = this;
- BI.each(items, function (i, item) {
- self._initResizable(item.el);
- });
- this.arrangement.populate(items);
- }
-});
-BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE";
-BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_RESIZE";
-BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE";
-BI.AdaptiveArrangement.EVENT_RESIZE = "AdaptiveArrangement.EVENT_RESIZE";
-BI.AdaptiveArrangement.EVENT_SCROLL = "AdaptiveArrangement.EVENT_SCROLL";
-BI.shortcut('bi.adaptive_arrangement', BI.AdaptiveArrangement);/**
- * Arrangement的block面板
- *
- * Created by GUY on 2016/3/1.
- * @class BI.ArrangementBlock
- * @extends BI.Widget
- */
-BI.ArrangementBlock = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-arrangement-block bi-mask"
- });
- }
-});
-BI.shortcut('bi.arrangement_block', BI.ArrangementBlock);/**
- * Arrangement的drop面板
- *
- * Created by GUY on 2016/3/1.
- * @class BI.ArrangementDroppable
- * @extends BI.Widget
- */
-BI.ArrangementDroppable = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-arrangement-droppable bi-resizer"
- });
- }
-});
-BI.shortcut('bi.arrangement_droppable', BI.ArrangementDroppable);/**
- * 布局
- *
- * Created by GUY on 2016/2/23.
- * @class BI.Arrangement
- * @extends BI.Widget
- */
-BI.Arrangement = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-arrangement",
- layoutType: BI.Arrangement.LAYOUT_TYPE.GRID,
- items: []
- });
- },
-
- _init: function () {
- BI.Arrangement.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.arrangement = BI.createWidget({
- type: "bi.arrangement_droppable",
- cls: "arrangement-block",
- invisible: true
- });
- this.block = BI.createWidget({
- type: "bi.arrangement_block",
- invisible: true
- });
- this.container = BI.createWidget({
- type: "bi.absolute",
- items: o.items.concat([this.block, this.arrangement])
- });
-
- this.scrollContainer = BI.createWidget({
- type: "bi.adaptive",
- width: "100%",
- height: "100%",
- scrollable: true,
- items: [this.container]
- });
- this.scrollContainer.element.scroll(function () {
- self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
- scrollLeft: self.scrollContainer.element.scrollLeft(),
- scrollTop: self.scrollContainer.element.scrollTop(),
- clientWidth: self.scrollContainer.element[0].clientWidth,
- clientHeight: self.scrollContainer.element[0].clientHeight
- });
- });
-
- BI.createWidget({
- type: "bi.adaptive",
- element: this,
- items: [this.scrollContainer]
- });
- this.regions = {};
- if (o.items.length > 0) {
- BI.nextTick(function () {
- self.populate(o.items);
- });
- }
- },
-
- ////初始化操作////
- _calculateRegions: function (items) {
- var self = this, o = this.options;
- this.regions = {};
- BI.each(items, function (i, item) {
- var region = self._createOneRegion(item);
- self.regions[region.id] = region;
- });
- },
-
- _isEqual: function (num1, num2) {
- return Math.abs(num1 - num2) < 2;
- },
-
- _isLessThan: function (num1, num2) {
- return num1 < num2 && !this._isEqual(num1, num2);
- },
-
- _isMoreThan: function (num1, num2) {
- return num1 > num2 && !this._isEqual(num1, num2);
- },
-
- _isLessThanEqual: function (num1, num2) {
- return num1 <= num2 || this._isEqual(num1, num2);
- },
-
- _isMoreThanEqual: function (num1, num2) {
- return num1 >= num2 || this._isEqual(num1, num2);
- },
-
- //获取占有的最大Region
- _getRegionOccupied: function (regions) {
- var self = this, o = this.options;
- if (BI.size(regions || this.regions) <= 0) {
- return {
- left: 0,
- top: 0,
- width: 0,
- height: 0
- }
- }
- var minLeft = BI.MAX, maxLeft = BI.MIN, minTop = BI.MAX, maxTop = BI.MIN;
- BI.each(regions || this.regions, function (id, region) {
- minLeft = Math.min(minLeft, region.left);
- maxLeft = Math.max(maxLeft, region.left + region.width);
- minTop = Math.min(minTop, region.top);
- maxTop = Math.max(maxTop, region.top + region.height);
- });
- return {
- left: minLeft,
- top: minTop,
- width: maxLeft - minLeft,
- height: maxTop - minTop
- }
- },
-
- //两个区域的交叉面积
- _getCrossArea: function (region1, region2) {
- if (region1.left <= region2.left) {
- if (region1.top <= region2.top) {
- if (region1.top + region1.height > region2.top && region1.left + region1.width > region2.left) {
- if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region1.left + region1.width, region2.left)) {
- return 0;
- }
- return (region1.top + region1.height - region2.top) * (region1.left + region1.width - region2.left);
- }
- } else {
- if (region2.top + region2.height > region1.top && region1.left + region1.width > region2.left) {
- if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region1.left + region1.width, region2.left)) {
- return 0;
- }
- return (region2.top + region2.height - region1.top) * (region1.left + region1.width - region2.left);
- }
- }
- } else {
- if (region1.top <= region2.top) {
- if (region1.top + region1.height > region2.top && region2.left + region2.width > region1.left) {
- if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region2.left + region2.width, region1.left)) {
- return 0;
- }
- return (region1.top + region1.height - region2.top) * (region2.left + region2.width - region1.left);
- }
- } else {
- if (region2.top + region2.height > region1.top && region2.left + region2.width > region1.left) {
- if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region2.left + region2.width, region1.left)) {
- return 0;
- }
- return (region2.top + region2.height - region1.top) * (region2.left + region2.width - region1.left);
- }
- }
- }
- return 0;
- },
-
- //是否有覆盖的组件
- _isRegionOverlay: function (regions) {
- var reg = [];
- BI.each(regions || this.regions, function (id, region) {
- reg.push(new BI.Region(region.left, region.top, region.width, region.height));
- });
- for (var i = 0, len = reg.length; i < len; i++) {
- for (var j = i + 1; j < len; j++) {
- var area1 = {
- left: reg[i].x,
- top: reg[i].y,
- width: reg[i].w,
- height: reg[i].h
- };
- var area2 = {
- left: reg[j].x,
- top: reg[j].y,
- width: reg[j].w,
- height: reg[j].h
- };
- if (reg[i].isIntersects(reg[j]) && this._getCrossArea(area1, area2) > 1) {
- return true;
- }
- }
- }
- return false;
- },
-
- //布局是否是优良的
- _isArrangeFine: function (regions) {
- switch (this.options.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- return true;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- // if (this._isRegionOverlay()) {
- // return false;
- // }
- }
- return true;
- },
-
- _getRegionNames: function (regions) {
- var names = [];
- BI.each(regions || this.regions, function (i, region) {
- names.push(region.id || region.attr("id"));
- });
- return names;
- },
-
- _getRegionsByNames: function (names, regions) {
- names = BI.isArray(names) ? names : [names];
- regions = regions || this.regions;
- if (BI.isArray(regions)) {
- var result = [];
- BI.each(regions, function (i, region) {
- if (names.contains(region.id || region.attr("id"))) {
- result.push(region);
- }
- });
- } else {
- var result = {};
- BI.each(names, function (i, name) {
- result[name] = regions[name];
- });
- }
- return result;
- },
-
- _cloneRegion: function (regions) {
- var clone = {};
- BI.each(regions || this.regions, function (id, region) {
- clone[id] = {};
- clone[id].el = region.el;
- clone[id].id = region.id;
- clone[id].left = region.left;
- clone[id].top = region.top;
- clone[id].width = region.width;
- clone[id].height = region.height;
- });
- return clone;
- },
-
- //测试合法性
- _test: function (regions) {
- var self = this;
- return !BI.any(regions || this.regions, function (i, region) {
- if (BI.isNaN(region.width) || BI.isNaN(region.height) || region.width <= 21 || region.height <= 21) {
- return true;
- }
- })
- },
-
- _getScrollOffset: function () {
- return {
- left: this.scrollContainer.element[0].scrollLeft,
- top: this.scrollContainer.element[0].scrollTop
- }
- },
-
- ////操作////
- _createOneRegion: function (item) {
- var el = BI.createWidget(item.el);
- el.setVisible(true);
- return {
- id: el.attr("id"),
- left: item.left,
- top: item.top,
- width: item.width,
- height: item.height,
- el: el
- }
- },
-
- _applyRegion: function (regions) {
- var self = this, o = this.options;
- BI.each(regions || this.regions, function (i, region) {
- region.el.element.css({
- left: region.left,
- top: region.top,
- width: region.width,
- height: region.height
- });
- });
- this._applyContainer();
- this.ratio = this.getLayoutRatio();
- },
-
- _renderRegion: function () {
- var self = this;
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: BI.toArray(this.regions)
- });
- },
-
- getClientWidth: function () {
- return this.scrollContainer.element[0].clientWidth;
- },
-
- getClientHeight: function () {
- return this.scrollContainer.element[0].clientHeight;
- },
-
- _applyContainer: function () {
- //先掩藏后显示能够明确滚动条是否出现
- this.scrollContainer.element.css("overflow", "hidden");
- var occupied = this._getRegionOccupied();
- this.container.element.width(occupied.left + occupied.width).height(occupied.top + occupied.height);
- this.scrollContainer.element.css("overflow", "auto");
- return occupied;
- },
-
- _modifyRegion: function (regions) {
- BI.each(this.regions, function (id, region) {
- if (regions[id]) {
- region.left = regions[id].left;
- region.top = regions[id].top;
- region.width = regions[id].width;
- region.height = regions[id].height;
- }
- });
- },
-
- _addRegion: function (item) {
- var region = this._createOneRegion(item);
- this.regions[region.id] = region;
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: [region]
- });
- },
-
- _deleteRegionByName: function (name) {
- this.regions[name].el.setVisible(false);
- delete this.regions[name];
- },
-
- _setArrangeSize: function (size) {
- this.arrangement.element.css({
- left: size.left,
- top: size.top,
- width: size.width,
- height: size.height
- })
- },
-
- //Grid
- _getOneWidthPortion: function () {
- return this.getClientWidth() / BI.Arrangement.PORTION;
- },
- _getOneHeightPortion: function () {
- return this.getClientHeight() / BI.Arrangement.H_PORTION;
- },
-
- _getGridPositionAndSize: function (position) {
- var perWidth = this._getOneWidthPortion();
- var perHeight = this._getOneHeightPortion();
- var widthPortion = Math.round(position.width / perWidth);
- var leftPortion = Math.round(position.left / perWidth);
- var topPortion = Math.round(position.top / perHeight);
- var heightPortion = Math.round(position.height / perHeight);
- // if (leftPortion > BI.Arrangement.PORTION) {
- // leftPortion = BI.Arrangement.PORTION;
- // }
- // if (widthPortion > BI.Arrangement.PORTION) {
- // widthPortion = BI.Arrangement.PORTION;
- // }
- // if (leftPortion + widthPortion > BI.Arrangement.PORTION) {
- // leftPortion = BI.Arrangement.PORTION - widthPortion;
- // }
- if (widthPortion === 0) {
- widthPortion = 1;
- }
- if (heightPortion === 0) {
- heightPortion = 1;
- }
- return {
- x: leftPortion,
- y: topPortion,
- w: widthPortion,
- h: heightPortion
- }
- },
-
- _getBlockPositionAndSize: function (position) {
- var perWidth = this._getOneWidthPortion();
- var perHeight = this._getOneHeightPortion();
- return {
- left: position.x * perWidth,
- top: position.y * perHeight,
- width: position.w * perWidth,
- height: position.h * perHeight
- };
- },
-
- _getLayoutsByRegions: function (regions) {
- var self = this;
- var result = [];
- BI.each(regions || this.regions, function (id, region) {
- result.push(BI.extend(self._getGridPositionAndSize(region), {
- i: region.id
- }))
- });
- return result;
- },
-
- _getLayoutIndexByName: function (layout, name) {
- return BI.findIndex(layout, function (i, l) {
- return l.i === name;
- });
- },
-
- _setBlockPositionAndSize: function (size) {
- this.block.element.css({
- left: size.left,
- top: size.top,
- width: size.width,
- height: size.height
- });
- },
-
- _getRegionsByLayout: function (layout) {
- var self = this;
- var regions = {};
- BI.each(layout, function (i, ly) {
- regions[ly.i] = BI.extend(self._getBlockPositionAndSize(ly), {
- id: ly.i
- });
- });
- return regions;
- },
-
- _setRegionsByLayout: function (regions, layout) {
- var self = this;
- regions || (regions = this.regions);
- BI.each(layout, function (i, ly) {
- if (regions[ly.i]) {
- BI.extend(regions[ly.i], self._getBlockPositionAndSize(ly));
- }
- });
- return regions;
- },
-
- _moveElement: function (layout, l, x, y, isUserAction) {
- var self = this;
- if (l._static) {
- return layout;
- }
-
- if (l.y === y && l.x === x) {
- return layout;
- }
-
- var movingUp = y && l.y > y;
- if (typeof x === 'number') {
- l.x = x;
- }
- if (typeof y === 'number') {
- l.y = y;
- }
- l.moved = true;
-
- var sorted = this._sortLayoutItemsByRowCol(layout);
- if (movingUp) {
- sorted = sorted.reverse();
- }
- var collisions = getAllCollisions(sorted, l);
-
- for (var i = 0, len = collisions.length; i < len; i++) {
- var collision = collisions[i];
- if (collision.moved) {
- continue;
- }
-
- if (l.y > collision.y && l.y - collision.y > collision.h / 4) {
- continue;
- }
-
- if (collision._static) {
- layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction);
- } else {
- layout = this._moveElementAwayFromCollision(layout, l, collision, isUserAction);
- }
- }
-
- return layout;
-
- function getAllCollisions(layout, layoutItem) {
- return BI.filter(layout, function (i, l) {
- return self._collides(l, layoutItem);
- });
- }
- },
-
- _sortLayoutItemsByRowCol: function (layout) {
- return [].concat(layout).sort(function (a, b) {
- if (a.y > b.y || (a.y === b.y && a.x > b.x)) {
- return 1;
- }
- return -1;
- });
- },
-
- _collides: function (l1, l2) {
- if (l1 === l2) {
- return false;
- } // same element
- if (l1.x + l1.w <= l2.x) {
- return false;
- } // l1 is left of l2
- if (l1.x >= l2.x + l2.w) {
- return false;
- } // l1 is right of l2
- if (l1.y + l1.h <= l2.y) {
- return false;
- } // l1 is above l2
- if (l1.y >= l2.y + l2.h) {
- return false;
- } // l1 is below l2
- return true; // boxes overlap
- },
-
- _getFirstCollision: function (layout, layoutItem) {
- for (var i = 0, len = layout.length; i < len; i++) {
- if (this._collides(layout[i], layoutItem)) {
- return layout[i];
- }
- }
- },
-
- _moveElementAwayFromCollision: function (layout, collidesWith,
- itemToMove, isUserAction) {
- if (isUserAction) {
- var fakeItem = {
- x: itemToMove.x,
- y: itemToMove.y,
- w: itemToMove.w,
- h: itemToMove.h,
- i: '-1'
- };
- fakeItem.y = Math.max(collidesWith.y - itemToMove.h, 0);
- if (!this._getFirstCollision(layout, fakeItem)) {
- return this._moveElement(layout, itemToMove, undefined, fakeItem.y);
- }
- }
-
- return this._moveElement(layout, itemToMove, undefined, itemToMove.y + 1);
- },
-
- _compactItem: function (compareWith, l, verticalCompact) {
- if (verticalCompact) {
- while (l.y > 0 && !this._getFirstCollision(compareWith, l)) {
- l.y--;
- }
- }
-
- var collides;
- while ((collides = this._getFirstCollision(compareWith, l))) {
- l.y = collides.y + collides.h;
- }
- return l;
- },
-
- compact: function (layout, verticalCompact) {
- var compareWith = getStatics(layout);
- var sorted = this._sortLayoutItemsByRowCol(layout);
- var out = [];
-
- for (var i = 0, len = sorted.length; i < len; i++) {
- var l = sorted[i];
-
- if (!l._static) {
- l = this._compactItem(compareWith, l, verticalCompact);
-
- compareWith.push(l);
- }
-
- out[layout.indexOf(l)] = l;
-
- l.moved = false;
- }
-
- return out;
- function getStatics(layout) {
- return BI.filter(layout, function (i, l) {
- return l._static;
- });
- }
- },
-
- ////公有方法////
- getRegionByName: function (name) {
- var obj = {};
- obj[name] = this.regions[name];
- return this._cloneRegion(obj)[name];
- },
-
- getAllRegions: function () {
- return BI.toArray(this._cloneRegion());
- },
-
- getHelper: function () {
- var helper = BI.createWidget({
- type: "bi.layout",
- width: 18,
- height: 18,
- cls: "arrangement-helper bi-border"
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [helper]
- });
- return helper;
- },
-
- _start: function () {
- if (this.options.layoutType === BI.Arrangement.LAYOUT_TYPE.GRID) {
- this.block.setVisible(true);
- } else {
- this.arrangement.setVisible(true);
- }
- },
-
- _stop: function () {
- this.arrangement.setVisible(false);
- this.block.setVisible(false);
- },
-
- ////公有操作////
- setLayoutType: function (type) {
- var self = this, o = this.options;
- if (type !== o.layoutType) {
- o.layoutType = type;
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- this.relayout();
- break;
- }
- }
- },
-
- getLayoutType: function () {
- return this.options.layoutType;
- },
-
- getLayoutRatio: function () {
- var occupied = this._getRegionOccupied();
- var width = this.getClientWidth(), height = this.getClientHeight();
- return {
- x: BI.parseFloat(BI.contentFormat((occupied.left + occupied.width) / width, "#.##;-#.##")),
- y: BI.parseFloat(BI.contentFormat((occupied.top + occupied.height) / height, "#.##;-#.##"))
- }
- },
-
- addRegion: function (region, position) {
- if (position) {
- this.setPosition(position, region);
- }
- var self = this, o = this.options;
- if (!this.position) {
- return false;
- }
- var test = this._cloneRegion();
- BI.each(this.position.regions, function (i, region) {
- test[region.id].left = region.left;
- test[region.id].top = region.top;
- test[region.id].width = region.width;
- test[region.id].height = region.height;
-
- });
- var item = BI.extend({}, region, {
- left: this.position.insert.left,
- top: this.position.insert.top,
- width: this.position.insert.width,
- height: this.position.insert.height
- });
- var added = this._createOneRegion(item);
- test[added.id] = added;
- if (this._test(test)) {
- delete test[added.id];
- this._modifyRegion(test);
- this._addRegion(item);
- this._populate(this.getAllRegions());
- return true;
- }
- return false;
- },
-
- deleteRegion: function (name) {
- if (!this.regions[name]) {
- return false;
- }
- var self = this, o = this.options;
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- this._deleteRegionByName(name);
- this._populate(this.getAllRegions());
- return true;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- this._deleteRegionByName(name);
- this._populate(this.getAllRegions());
- this.resize();
- return true;
- }
- return false;
- },
-
- setRegionSize: function (name, size) {
- var self = this, o = this.options;
- var flag = false;
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- var clone = this._cloneRegion();
- BI.extend(clone[name], {
- width: size.width,
- height: size.height
- });
- if (this._test(clone)) {
- this._modifyRegion(clone);
- flag = true;
- }
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- var clone = this._cloneRegion();
- BI.extend(clone[name], {
- width: size.width,
- height: size.height
- });
- if (this._test(clone)) {
- var layout = this._getLayoutsByRegions(clone);
- layout = this.compact(layout, true);
- var regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- flag = true;
- }
- break;
- }
- this._applyRegion();
- return flag;
- },
-
- setPosition: function (position, size) {
- var self = this, o = this.options;
- var insert, regions = [], cur;
- if (position.left < 0 || position.top < 0) {
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- this.resize();
- break;
- }
- this._stop();
- this.position = null;
- return null;
- }
- var offset = this._getScrollOffset();
- position = {
- left: position.left + offset.left,
- top: position.top + offset.top
- };
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- var insert = {
- top: position.top < 0 ? 0 : position.top,
- left: position.left < 0 ? 0 : position.left,
- width: size.width,
- height: size.height
- };
- this.position = {
- insert: insert
- };
- this._setArrangeSize(insert);
- this._start();
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- var p = {
- top: position.top < 0 ? 0 : position.top,
- left: position.left < 0 ? 0 : position.left,
- width: size.width,
- height: size.height
- };
- this._setArrangeSize(p);
- var cur = this._getGridPositionAndSize(p);
- var layout = [{
- x: 0, y: BI.MAX, w: cur.w, h: cur.h, i: cur.i
- }].concat(this._getLayoutsByRegions());
- layout = this._moveElement(layout, layout[0], cur.x, cur.y, true);
- layout = this.compact(layout, true);
- var regions = this._setRegionsByLayout(this._cloneRegion(), layout);
- var insert = this._getBlockPositionAndSize(layout[0]);
- this.position = {
- insert: insert,
- regions: regions
- };
- this._applyRegion(regions);
- this._setBlockPositionAndSize(insert);
- this._start();
- break;
- }
- return this.position;
- },
-
- setRegionPosition: function (name, position) {
- var self = this, o = this.options;
- var offset = this._getScrollOffset();
- position = BI.extend(position, {
- left: position.left + offset.left,
- top: position.top + offset.top
- });
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- BI.extend(this.regions[name], {
- left: position.left < 0 ? 0 : position.left,
- top: position.top < 0 ? 0 : position.top
- });
- this._applyRegion();
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- if (!position.stop) {
- BI.extend(this.regions[name], {
- left: position.left < 0 ? 0 : position.left,
- top: position.top < 0 ? 0 : position.top
- });
- var cloned = this._cloneRegion();
- var cur = this._getGridPositionAndSize(BI.extend(cloned[name], {
- left: position.left < 0 ? 0 : position.left,
- top: position.top < 0 ? 0 : position.top
- }));
- var x = cur.x, y = cur.y;
- cur = BI.extend(cur, {
- x: 0, y: BI.MAX, i: -1
- });
- delete cloned[name];
- var layout = this._getLayoutsByRegions(cloned);
- layout = this._moveElement([cur].concat(layout), cur, x, y, true);
- layout = this.compact(layout, true);
- var regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- this._applyRegion();
-
- this._setBlockPositionAndSize(this._getBlockPositionAndSize(cur));
- this.block.setVisible(true);
- } else {
- BI.extend(this.regions[name], {
- left: position.left < 0 ? 0 : position.left,
- top: position.top < 0 ? 0 : position.top
- });
- var cloned = this._cloneRegion();
- var layout = this._getLayoutsByRegions(cloned);
- layout = this.compact(layout, true);
- var regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- this._applyRegion();
- this.block.setVisible(false);
- }
- break;
- }
- },
-
- setDropPosition: function (position, size) {
- var self = this;
- this.arrangement.setVisible(true);
- var offset = this._getScrollOffset();
- this._setArrangeSize(BI.extend({}, size, {
- left: position.left + offset.left,
- top: position.top + offset.top
- }));
- return function () {
- self.arrangement.setVisible(false);
- }
- },
-
- scrollTo: function (scroll) {
- this.scrollContainer.element.scrollTop(scroll.top);
- this.scrollContainer.element.scrollLeft(scroll.left);
- },
-
- zoom: function (ratio) {
- var self = this, o = this.options;
- if (!ratio) {
- return;
- }
- var occupied = this._applyContainer();
- switch (this.getLayoutType()) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- if (this._isArrangeFine()) {
- var width = this.getClientWidth();
- var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width);
- //var yRatio = ratio.y * height / (occupied.top + occupied.height);
- var regions = this._cloneRegion();
- BI.each(regions, function (i, region) {
- region.left = region.left * xRatio;
- //region.top = region.top * yRatio;
- region.width = region.width * xRatio;
- //region.height = region.height * yRatio;
- });
- if (this._test(regions)) {
- this._modifyRegion(regions);
- this._applyRegion();
- }
- this.resize();
- // } else {
- this.relayout();
- }
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- if (this._isArrangeFine()) {
- var width = this.getClientWidth(), height = this.getClientHeight();
- var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width);
- var yRatio = (ratio.y || 1) * height / (occupied.top + occupied.height);
- var regions = this._cloneRegion();
- BI.each(regions, function (i, region) {
- region.left = region.left * xRatio;
- region.width = region.width * xRatio;
- region.top = region.top * yRatio;
- region.height = region.height * yRatio;
- //做一下自适应布局到网格布局的兼容
- var perWidth = self._getOneWidthPortion();
- var widthPortion = Math.round(region.width / perWidth);
- var leftPortion = Math.round(region.left / perWidth);
- var comparePortion = Math.round((region.width + region.left) / perWidth);
- if (leftPortion + widthPortion !== comparePortion) {
- region.left = leftPortion * perWidth;
- region.width = comparePortion * perWidth - region.left;
- }
- });
- if (this._test(regions)) {
- var layout = this._getLayoutsByRegions(regions);
- layout = this.compact(layout, true);
- regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- this._applyRegion();
- }
- } else {
- this.relayout();
- }
- break;
- }
- },
-
- resize: function () {
- var self = this, o = this.options;
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- this.zoom(this.ratio);
- var regions = this._cloneRegion();
- var layout = this._getLayoutsByRegions(regions);
- layout = this.compact(layout, true);
- regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- this._applyRegion();
- break;
- }
- },
-
- relayout: function () {
- var self = this, o = this.options;
- switch (o.layoutType) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- if (!this._isArrangeFine()) {
- var perHeight = this._getOneHeightPortion();
- var width = this.getClientWidth(), height = this.getClientHeight();
- var regions = this._cloneRegion();
- var clone = BI.toArray(regions);
- clone.sort(function (r1, r2) {
- if (self._isEqual(r1.top, r2.top)) {
- return r1.left - r2.left;
- }
- return r1.top - r2.top;
- });
- var count = clone.length;
- var cols = 4, rows = Math.floor((count - 1) / 4 + 1);
- var w = width / cols, h = height / rows;
- var store = {};
- BI.each(clone, function (i, region) {
- var row = Math.floor(i / 4), col = i % 4;
- BI.extend(region, {
- top: row * perHeight * 6,
- left: col * w,
- width: w,
- height: perHeight * 6
- });
- if (!store[row]) {
- store[row] = {};
- }
- store[row][col] = region;
- });
- //非4的倍数
- // if (count % 4 !== 0) {
- // var lasts = store[rows - 1];
- // var perWidth = width / (count % 4);
- // BI.each(lasts, function (i, region) {
- // BI.extend(region, {
- // left: BI.parseInt(i) * perWidth,
- // width: perWidth
- // });
- // });
- // }
- if (this._test(clone)) {
- var layout = this._getLayoutsByRegions(regions);
- layout = this.compact(layout, true);
- regions = this._getRegionsByLayout(layout);
- this._modifyRegion(regions);
- this._populate(clone);
- }
- } else {
- this.resize();
- }
- break;
- }
- },
-
- _populate: function (items) {
- this._stop();
- this._calculateRegions(items);
- this._applyRegion();
- },
-
- populate: function (items) {
- var self = this;
- BI.each(this.regions, function (name, region) {
- self.regions[name].el.setVisible(false);
- delete self.regions[name];
- });
- this._populate(items);
- this._renderRegion();
- }
-});
-BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL";
-BI.extend(BI.Arrangement, {
- PORTION: 36,
- H_PORTION: 18,
- LAYOUT_TYPE: {
- GRID: 0,
- FREE: 1
- }
-});
-BI.shortcut('bi.arrangement', BI.Arrangement);/**
- * 表关联树
- *
- * Created by GUY on 2015/12/15.
- * @class BI.BranchRelation
- * @extends BI.Widget
- */
-BI.BranchRelation = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.BranchRelation.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-branch-relation-tree",
- items: [],
-
- centerOffset: 0,//重心偏移量
- direction: BI.Direction.Bottom,
- align: BI.VerticalAlign.Top
- })
- },
-
- _init: function () {
- BI.BranchRelation.superclass._init.apply(this, arguments);
- this.populate(this.options.items);
- },
-
- //树分层
- _stratification: function () {
- var levels = [];
- this.tree.recursion(function (node, route) {
- //node.isRoot = route.length <= 1;
- node.leaf = node.isLeaf();
- if (!levels[route.length - 1]) {
- levels[route.length - 1] = [];
- }
- levels[route.length - 1].push(node);
- });
- return levels;
- },
-
- //计算所有节点的叶子结点个数
- _calculateLeaves: function () {
- var count = 0;
-
- function track(node) {
- var c = 0;
- if (node.isLeaf()) {
- return 1;
- }
- BI.each(node.getChildren(), function (i, child) {
- c += track(child);
- });
- node.set("leaves", c);
- return c;
- }
-
- count = track(this.tree.getRoot());
- return count;
- },
-
- //树平移
- _translate: function (levels) {
- var adjust = [];
- var maxLevel = levels.length;
- BI.each(levels, function (i, nodes) {
- if (!adjust[i]) {
- adjust[i] = [];
- }
- BI.each(nodes, function (j, node) {
- if (node.isLeaf() && i < maxLevel - 1) {
- var newNode = new BI.Node(BI.UUID());
- //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot;
- newNode.isNew = true;
- //把node向下一层移
- var tar = 0;
- if (j > 0) {
- var c = nodes[j - 1].getLastChild();
- tar = levels[i + 1].indexOf(c) + 1;
- }
- levels[i + 1].splice(tar, 0, node);
- //新增一个临时树节点
- var index = node.parent.getChildIndex(node.id);
- node.parent.removeChildByIndex(index);
- node.parent.addChild(newNode, index);
- newNode.addChild(node);
- adjust[i].push(newNode);
- nodes[j] = newNode;
- } else {
- adjust[i].push(node);
- }
- })
- });
- return adjust;
- },
-
- //树补白
- _fill: function (levels) {
- var adjust = [];
- var maxLevel = levels.length;
- BI.each(levels, function (i, nodes) {
- if (!adjust[i]) {
- adjust[i] = [];
- }
- BI.each(nodes, function (j, node) {
- if (node.isLeaf() && i < maxLevel - 1) {
- var newNode = new BI.Node(BI.UUID());
- newNode.leaf = true;
- newNode.width = node.width;
- newNode.height = node.height;
- newNode.isNew = true;
- //把node向下一层移
- var tar = 0;
- if (j > 0) {
- var c = nodes[j - 1].getLastChild();
- tar = levels[i + 1].indexOf(c) + 1;
- }
- levels[i + 1].splice(tar, 0, newNode);
- //新增一个临时树节点
- node.addChild(newNode);
- }
- adjust[i].push(node);
- })
- });
- return adjust;
- },
-
- //树调整
- _adjust: function (adjust) {
- while (true) {
- var isAllNeedAjust = false;
- BI.backEach(adjust, function (i, nodes) {
- BI.each(nodes, function (j, node) {
- if (!node.isNew) {
- var needAdjust = true;
- BI.any(node.getChildren(), function (k, n) {
- if (!n.isNew) {
- needAdjust = false;
- return true;
- }
- });
- if (!node.isLeaf() && needAdjust === true) {
- var allChilds = [];
- BI.each(node.getChildren(), function (k, n) {
- allChilds = allChilds.concat(n.getChildren());
- });
- node.removeAllChilds();
- BI.each(allChilds, function (k, c) {
- node.addChild(c);
- });
- var newNode = new BI.Node(BI.UUID());
- //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot;
- newNode.isNew = true;
- var index = node.parent.getChildIndex(node.id);
- node.parent.removeChildByIndex(index);
- node.parent.addChild(newNode, index);
- newNode.addChild(node);
- isAllNeedAjust = true;
- }
- }
- })
- });
- if (isAllNeedAjust === false) {
- break;
- } else {//树重构
- adjust = this._stratification();
- }
- }
- return adjust;
- },
-
- _calculateWidth: function () {
- var o = this.options;
- var width = 0;
-
- function track1(node) {
- var w = 0;
- if (node.isLeaf()) {
- return node.width;
- }
- BI.each(node.getChildren(), function (i, child) {
- w += track1(child);
- });
- return w;
- }
-
- function track2(node) {
- var w = 0;
- if (node.isLeaf()) {
- return node.height;
- }
- BI.each(node.getChildren(), function (i, child) {
- w += track2(child);
- });
- return w;
- }
-
- if (this._isVertical()) {
- width = track1(this.tree.getRoot());
- } else {
- width = track2(this.tree.getRoot());
- }
-
- return width;
- },
-
- _isVertical: function () {
- var o = this.options;
- return o.direction === BI.Direction.Top || o.direction === BI.Direction.Bottom;
- },
-
- _calculateHeight: function () {
- var o = this.options;
- var height = 0;
-
- function track1(node) {
- var h = 0;
- BI.each(node.getChildren(), function (i, child) {
- h = Math.max(h, track1(child));
- });
- return h + (node.height || 0);
- }
-
- function track2(node) {
- var h = 0;
- BI.each(node.getChildren(), function (i, child) {
- h = Math.max(h, track2(child));
- });
- return h + (node.width || 0);
- }
-
- if (this._isVertical()) {
- height = track1(this.tree.getRoot());
- } else {
- height = track2(this.tree.getRoot());
- }
- return height;
- },
-
- _calculateXY: function (levels) {
- var o = this.options;
- var width = this._calculateWidth();
- var height = this._calculateHeight();
- var levelCount = levels.length;
- var allLeavesCount = this._calculateLeaves();
- //计算坐标
- var xy = {};
- var levelHeight = height / levelCount;
- BI.each(levels, function (i, nodes) {
- //计算权重
- var weights = [];
- BI.each(nodes, function (j, node) {
- weights[j] = (node.get("leaves") || 1) / allLeavesCount;
- });
- BI.each(nodes, function (j, node) {
- //求前j个元素的权重
- var weight = BI.sum(weights.slice(0, j));
- //求坐标
- var x = weight * width + weights[j] * width / 2;
- var y = i * levelHeight + levelHeight / 2;
- xy[node.id] = {x: x, y: y};
- })
- });
- return xy;
- },
-
- _stroke: function (levels, xy) {
- var height = this._calculateHeight();
- var levelCount = levels.length;
- var levelHeight = height / levelCount;
- var self = this, o = this.options;
- switch (o.direction) {
- case BI.Direction.Top:
- BI.each(levels, function (i, nodes) {
- BI.each(nodes, function (j, node) {
- if (node.getChildrenLength() > 0 && !node.leaf) {
- var path = "";
- var start = xy[node.id];
- var split = start.y + levelHeight / 2;
- path += "M" + start.x + "," + (start.y + o.centerOffset) + "L" + start.x + "," + split;
- var end = [];
- BI.each(node.getChildren(), function (t, c) {
- var e = end[t] = xy[c.id];
- path += "M" + e.x + "," + (e.y + o.centerOffset) + "L" + e.x + "," + split;
- });
- if (end.length > 0) {
- path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split;
- }
- self.svg.path(path).attr("stroke", "#d4dadd");
- }
- })
- });
- break;
- case BI.Direction.Bottom:
- BI.each(levels, function (i, nodes) {
- BI.each(nodes, function (j, node) {
- if (node.getChildrenLength() > 0 && !node.leaf) {
- var path = "";
- var start = xy[node.id];
- var split = start.y - levelHeight / 2;
- path += "M" + start.x + "," + (start.y - o.centerOffset) + "L" + start.x + "," + split;
- var end = [];
- BI.each(node.getChildren(), function (t, c) {
- var e = end[t] = xy[c.id];
- path += "M" + e.x + "," + (e.y - o.centerOffset) + "L" + e.x + "," + split;
- });
- if (end.length > 0) {
- path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split;
- }
- self.svg.path(path).attr("stroke", "#d4dadd");
- }
- })
- });
- break;
- case BI.Direction.Left:
- BI.each(levels, function (i, nodes) {
- BI.each(nodes, function (j, node) {
- if (node.getChildrenLength() > 0 && !node.leaf) {
- var path = "";
- var start = xy[node.id];
- var split = start.y + levelHeight / 2;
- path += "M" + (start.y + o.centerOffset) + "," + start.x + "L" + split + "," + start.x;
- var end = [];
- BI.each(node.getChildren(), function (t, c) {
- var e = end[t] = xy[c.id];
- path += "M" + (e.y + o.centerOffset) + "," + e.x + "L" + split + "," + e.x;
- });
- if (end.length > 0) {
- path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x;
- }
- self.svg.path(path).attr("stroke", "#d4dadd");
- }
- })
- });
- break;
- case BI.Direction.Right:
- BI.each(levels, function (i, nodes) {
- BI.each(nodes, function (j, node) {
- if (node.getChildrenLength() > 0 && !node.leaf) {
- var path = "";
- var start = xy[node.id];
- var split = start.y - levelHeight / 2;
- path += "M" + (start.y - o.centerOffset) + "," + start.x + "L" + split + "," + start.x;
- var end = [];
- BI.each(node.getChildren(), function (t, c) {
- var e = end[t] = xy[c.id];
- path += "M" + (e.y - o.centerOffset) + "," + e.x + "L" + split + "," + e.x;
- });
- if (end.length > 0) {
- path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x;
- }
- self.svg.path(path).attr("stroke", "#d4dadd");
- }
- })
- });
- break;
- }
- },
-
- _createBranches: function (levels) {
- var self = this, o = this.options;
- if (o.direction === BI.Direction.Bottom || o.direction === BI.Direction.Right) {
- levels = levels.reverse();
- }
- var xy = this._calculateXY(levels);
- //画图
- this._stroke(levels, xy);
- },
-
- _isNeedAdjust: function () {
- var o = this.options;
- return o.direction === BI.Direction.Top && o.align === BI.VerticalAlign.Bottom || o.direction === BI.Direction.Bottom && o.align === BI.VerticalAlign.Top
- || o.direction === BI.Direction.Left && o.align === BI.HorizontalAlign.Right || o.direction === BI.Direction.Right && o.align === BI.HorizontalAlign.Left
- },
-
- setValue: function (value) {
-
- },
-
- getValue: function () {
-
- },
-
- _transformToTreeFormat: function (sNodes) {
- var i, l;
- if (!sNodes) {
- return [];
- }
-
- if (BI.isArray(sNodes)) {
- var r = [];
- var tmpMap = [];
- for (i = 0, l = sNodes.length; i < l; i++) {
- tmpMap[sNodes[i].id] = sNodes[i];
- }
- for (i = 0, l = sNodes.length; i < l; i++) {
- if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) {
- if (!tmpMap[sNodes[i].pId].children) {
- tmpMap[sNodes[i].pId].children = [];
- }
- tmpMap[sNodes[i].pId].children.push(sNodes[i]);
- } else {
- r.push(sNodes[i]);
- }
- }
- return r;
- } else {
- return [sNodes];
- }
- },
-
- populate: function (items) {
- var self = this, o = this.options;
- o.items = items || [];
- this.empty();
- items = this._transformToTreeFormat(o.items);
- this.tree = new BI.Tree();
- this.tree.initTree(items);
-
- this.svg = BI.createWidget({
- type: "bi.svg"
- });
-
- //树分层
- var levels = this._stratification();
-
- if (this._isNeedAdjust()) {
- //树平移
- var adjust = this._translate(levels);
- //树调整
- adjust = this._adjust(adjust);
-
- this._createBranches(adjust);
- } else {
- var adjust = this._fill(levels);
-
- this._createBranches(adjust);
- }
-
- var container = BI.createWidget({
- type: "bi.layout",
- width: this._isVertical() ? this._calculateWidth() : this._calculateHeight(),
- height: this._isVertical() ? this._calculateHeight() : this._calculateWidth()
- });
- BI.createWidget({
- type: "bi.absolute",
- element: container,
- items: [{
- el: this.svg,
- top: 0,
- left: 0,
- right: 0,
- bottom: 0
- }]
- });
- if (this._isVertical()) {
- items = [{
- type: "bi.handstand_branch_tree",
- expander: {
- direction: o.direction
- },
- el: {
- layouts: [{
- type: "bi.horizontal_adapt",
- verticalAlign: o.align
- }]
- },
- items: items
- }]
- } else {
- items = [{
- type: "bi.branch_tree",
- expander: {
- direction: o.direction
- },
- el: {
- layouts: [{
- type: "bi.vertical"
- }, {
- type: o.align === BI.HorizontalAlign.Left ? "bi.left" : "bi.right"
- }]
- },
- items: items
- }]
- }
- BI.createWidget({
- type: "bi.adaptive",
- element: container,
- items: items
- });
- BI.createWidget({
- type: "bi.center_adapt",
- scrollable: true,
- element: this,
- items: [container]
- });
- }
-});
-BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE";
-BI.shortcut("bi.branch_relation", BI.BranchRelation);/**
- * 日期控件中的月份下拉框
- *
- * Created by GUY on 2015/9/7.
- * @class BI.MonthDateCombo
- * @extends BI.Trigger
- */
-BI.MonthDateCombo = BI.inherit(BI.Trigger, {
- _defaultConfig: function() {
- return BI.extend( BI.MonthDateCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-month-combo",
- height: 25
- });
- },
- _init: function() {
- BI.MonthDateCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.date_triangle_trigger"
- });
-
- this.popup = BI.createWidget({
- type: "bi.month_popup"
- });
-
- this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){
- self.setValue(self.popup.getValue());
- })
-
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- offsetStyle: "center",
- element: this,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- minWidth: 85,
- stopPropagation: false,
- el: this.popup
- }
- })
- this.combo.on(BI.Combo.EVENT_CHANGE, function(){
- self.combo.hideView();
- self.fireEvent(BI.MonthDateCombo.EVENT_CHANGE);
- });
- },
-
- setValue: function(v){
- this.trigger.setValue(v + 1);
- this.popup.setValue(v);
- },
-
- getValue: function(){
- return this.popup.getValue();
- }
-});
-BI.MonthDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.month_date_combo', BI.MonthDateCombo);/**
- * 年份下拉框
- *
- * Created by GUY on 2015/9/7.
- * @class BI.YearDateCombo
- * @extends BI.Trigger
- */
-BI.YearDateCombo = BI.inherit(BI.Trigger, {
- _defaultConfig: function() {
- return BI.extend( BI.YearDateCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-year-combo",
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- height: 25
- });
- },
- _init: function() {
- BI.YearDateCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.date_triangle_trigger"
- });
-
- this.popup = BI.createWidget({
- type: "bi.year_popup",
- min: o.min,
- max: o.max
- });
-
- this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.YearDateCombo.EVENT_CHANGE);
- })
-
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- offsetStyle: "center",
- element: this,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- minWidth: 85,
- stopPropagation: false,
- el: this.popup
- }
- })
- this.combo.on(BI.Combo.EVENT_CHANGE, function(){
- self.fireEvent(BI.YearDateCombo.EVENT_CHANGE);
- })
- },
-
- setValue: function(v){
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function(){
- return this.popup.getValue();
- }
-});
-BI.YearDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.year_date_combo', BI.YearDateCombo);/**
- * Created by GUY on 2015/9/7.
- * @class BI.DatePicker
- * @extends BI.Widget
- */
-BI.DatePicker = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: "bi-date-picker bi-background",
- height: 25,
- min: '1900-01-01', //最小日期
- max: '2099-12-31' //最大日期
- })
- },
-
- _init: function () {
- BI.DatePicker.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this._year = new Date().getFullYear();
- this._month = new Date().getMonth();
- this.left = BI.createWidget({
- type: "bi.icon_button",
- cls: "pre-page-h-font",
- width: 25,
- height: 25
- });
- this.left.on(BI.IconButton.EVENT_CHANGE, function () {
- if (self._month === 0) {
- self.setValue({
- year: self.year.getValue() - 1,
- month: 11
- })
- } else {
- self.setValue({
- year: self.year.getValue(),
- month: self.month.getValue() - 1
- })
- }
- self.fireEvent(BI.DatePicker.EVENT_CHANGE);
- });
-
- this.right = BI.createWidget({
- type: "bi.icon_button",
- cls: "next-page-h-font",
- width: 25,
- height: 25
- });
-
- this.right.on(BI.IconButton.EVENT_CHANGE, function () {
- if (self._month === 11) {
- self.setValue({
- year: self.year.getValue() + 1,
- month: 0
- })
- } else {
- self.setValue({
- year: self.year.getValue(),
- month: self.month.getValue() + 1
- })
- }
- self.fireEvent(BI.DatePicker.EVENT_CHANGE);
- });
-
- this.year = BI.createWidget({
- type: "bi.year_date_combo",
- min: o.min,
- max: o.max
- });
- this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () {
- self.setValue({
- year: self.year.getValue(),
- month: self.month.getValue()
- });
- self.fireEvent(BI.DatePicker.EVENT_CHANGE);
- })
- this.month = BI.createWidget({
- type: "bi.month_date_combo"
- });
- this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () {
- self.setValue({
- year: self.year.getValue(),
- month: self.month.getValue()
- });
- self.fireEvent(BI.DatePicker.EVENT_CHANGE);
- });
-
- BI.createWidget({
- type: "bi.htape",
- element: this,
- items: [{
- el: this.left,
- width: 25
- }, {
- type: "bi.center_adapt",
- items: [{
- type: "bi.horizontal",
- width: 100,
- items: [this.year, this.month]
- }]
- }, {
- el: this.right,
- width: 25
- }]
- })
- this.setValue({
- year: this._year,
- month: this._month
- })
- },
-
- setValue: function (ob) {
- this._year = ob.year;
- this._month = ob.month;
- this.year.setValue(ob.year);
- this.month.setValue(ob.month);
- },
-
- getValue: function () {
- return {
- year: this.year.getValue(),
- month: this.month.getValue()
- }
- }
-});
-BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE"
-BI.shortcut("bi.date_picker", BI.DatePicker);/**
- * Created by GUY on 2015/9/7.
- * @class BI.DateCalendarPopup
- * @extends BI.Widget
- */
-BI.DateCalendarPopup = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: "bi-date-calendar-popup",
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- selectedTime: null
- })
- },
-
- _createNav: function (v) {
- var date = BI.Calendar.getDateJSONByPage(v);
- var calendar = BI.createWidget({
- type: "bi.calendar",
- logic: {
- dynamic: true
- },
- min: this.options.min,
- max: this.options.max,
- year: date.year,
- month: date.month,
- day: this.selectedTime.day
- });
- return calendar;
- },
-
- _init: function () {
- BI.DateCalendarPopup.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.today = new Date();
- this._year = this.today.getFullYear();
- this._month = this.today.getMonth();
- this._day = this.today.getDate();
-
- this.selectedTime = o.selectedTime || {
- year: this._year,
- month: this._month,
- day: this._day
- };
- this.datePicker = BI.createWidget({
- type: "bi.date_picker",
- min: o.min,
- max: o.max
- });
-
- this.calendar = BI.createWidget({
- direction: "top",
- element: this,
- logic: {
- dynamic: true
- },
- type: "bi.navigation",
- tab: this.datePicker,
- cardCreator: BI.bind(this._createNav, this),
-
- afterCardCreated: function () {
-
- },
-
- afterCardShow: function () {
- this.setValue(self.selectedTime);
- }
- });
-
- this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
- self.selectedTime = self.datePicker.getValue();
- self.selectedTime.day = 1;
- self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
- });
-
- this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
- self.selectedTime = self.calendar.getValue();
- self.setValue(self.selectedTime);
- self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
- });
- },
-
- setValue: function (timeOb) {
- this.datePicker.setValue(timeOb);
- this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb));
- this.calendar.setValue(timeOb);
- this.selectedTime = timeOb;
- },
-
- getValue: function () {
- return this.selectedTime;
- }
-});
-BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);/**
- * 日期控件中的年份或月份trigger
- *
- * Created by GUY on 2015/9/7.
- * @class BI.DateTriangleTrigger
- * @extends BI.Trigger
- */
-BI.DateTriangleTrigger = BI.inherit(BI.Trigger, {
- _const: {
- height: 25,
- iconWidth: 16,
- iconHeight: 13
- },
-
- _defaultConfig: function() {
- return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer",
- height: 25
- });
- },
- _init: function() {
- BI.DateTriangleTrigger.superclass._init.apply(this, arguments);
- var o = this.options, c = this._const;
- this.text = BI.createWidget({
- type: "bi.label",
- cls: "list-item-text",
- textAlign: "right",
- text: o.text,
- value: o.value,
- height: c.height
- })
- this.icon = BI.createWidget({
- type: "bi.icon",
- width: c.iconWidth,
- height: c.iconHeight
- });
-
- BI.createWidget({
- type: "bi.center_adapt",
- element: this,
- items: [{
- type: "bi.center_adapt",
- width: 50,
- height: c.height,
- items: [this.text, this.icon]
- }]
- })
- },
-
- setValue: function(v){
- this.text.setValue(v);
- },
-
- getValue: function(){
- return this.text.getValue();
- },
-
- setText: function(v){
- this.text.setText(v);
- },
-
- getText: function(){
- return this.item.getText();
- },
-
- getKey: function(){
-
- }
-});
-BI.shortcut('bi.date_triangle_trigger', BI.DateTriangleTrigger);/**
- * 日期下拉框
- *
- * Created by GUY on 2015/9/7.
- * @class BI.DateCombo
- * @extends BI.Widget
- */
-BI.DateCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-date-combo bi-border",
- height: 30
- });
- },
- _init: function () {
- BI.DateCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.date_trigger"
- });
-
- this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
- self.combo.toggle();
- });
-
- this.popup = BI.createWidget({
- type: "bi.date_calendar_popup"
- });
-
- this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- toggle: false,
- element: this,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- width: 270,
- el: this.popup,
- stopPropagation: false
- }
- })
- },
-
- setValue: function (v) {
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- }
-});
-BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, {
- _const: {
- hgap: 4,
- vgap: 2,
- triggerWidth: 30,
- yearLength: 4,
- yearMonthLength: 7
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-date-trigger",
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- height: 25
- });
- },
- _init: function () {
- BI.DateTrigger.superclass._init.apply(this, arguments);
- var self = this, o = this.options, c = this._const;
- this.editor = BI.createWidget({
- type: "bi.sign_editor",
- height: o.height,
- validationChecker: function (v) {
- var date = v.match(/\d+/g);
- self._autoAppend(v, date);
- return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({
- year: date[0],
- month: date[1],
- day: date[2]
- });
- },
- quitChecker: function () {
- return false;
- },
- hgap: c.hgap,
- vgap: c.vgap,
- allowBlank: true,
- watermark: BI.i18nText("BI-Basic_Unrestricted"),
- errorText: function () {
- if (self.editor.isEditing()) {
- return BI.i18nText("BI-Date_Trigger_Error_Text");
- }
- return BI.i18nText("BI-Year_Trigger_Invalid_Text");
- }
- });
- this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
- self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN)
- });
- this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
- self.fireEvent(BI.DateTrigger.EVENT_FOCUS);
- });
- this.editor.on(BI.SignEditor.EVENT_STOP, function () {
- self.fireEvent(BI.DateTrigger.EVENT_STOP);
- });
- this.editor.on(BI.SignEditor.EVENT_VALID, function () {
- self.fireEvent(BI.DateTrigger.EVENT_VALID);
- });
- this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
- self.fireEvent(BI.DateTrigger.EVENT_ERROR);
- });
- this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
- var value = self.editor.getValue();
- if (BI.isNotNull(value)) {
- self.editor.setState(value);
- }
-
- if (BI.isNotEmptyString(value)) {
- var date = value.split("-");
- self.store_value = {
- type: BI.DateTrigger.MULTI_DATE_CALENDAR,
- value:{
- year: date[0] | 0,
- month: date[1] - 1,
- day: date[2] | 0
- }
- };
- }
- self.fireEvent(BI.DateTrigger.EVENT_CONFIRM);
- });
- this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
- if (self.editor.isValid()) {
- self.editor.blur();
- }
- });
- this.editor.on(BI.SignEditor.EVENT_START, function () {
- self.fireEvent(BI.DateTrigger.EVENT_START);
- });
- this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
- self.fireEvent(BI.DateTrigger.EVENT_CHANGE);
- });
- BI.createWidget({
- type: "bi.htape",
- element: this,
- items: [{
- el: BI.createWidget(),
- width: 30
- }, {
- el: this.editor
- }]
- })
- },
- _dateCheck: function (date) {
- return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date;
- },
- _checkVoid: function (obj) {
- return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0];
- },
- _autoAppend: function (v, dateObj) {
- var self = this;
- var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d");
- var yearCheck = function (v) {
- return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max;
- };
- var monthCheck = function (v) {
- return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max;
- };
- if (BI.isNotNull(dateObj) && Date.checkLegal(v)) {
- switch (v.length) {
- case this._const.yearLength:
- if (yearCheck(v)) {
- this.editor.setValue(v + "-");
- }
- break;
- case this._const.yearMonthLength:
- if (monthCheck(v)) {
- this.editor.setValue(v + "-");
- }
- break;
- }
- }
- },
-
- setValue: function (v) {
- var type, value, self = this;
- var date = new Date();
- this.store_value = v;
- if (BI.isNotNull(v)) {
- type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value;
- if(BI.isNull(value)){
- value = v;
- }
- }
- var _setInnerValue = function (date, text) {
- var dateStr = date.print("%Y-%x-%e");
- self.editor.setState(dateStr);
- self.editor.setValue(dateStr);
- self.setTitle(text + ":" + dateStr);
- };
- switch (type) {
- case BI.DateTrigger.MULTI_DATE_YEAR_PREV:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];
- date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate());
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];
- date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate());
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];
- date = new Date(date.getFullYear(), 0, 1);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_YEAR_END:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];
- date = new Date(date.getFullYear(), 11, 31);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];
- date = new Date().getBeforeMulQuarter(value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];
- date = new Date().getAfterMulQuarter(value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];
- date = new Date().getQuarterStartDate();
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_QUARTER_END:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];
- date = new Date().getQuarterEndDate();
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_MONTH_PREV:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];
- date = new Date().getBeforeMultiMonth(value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];
- date = new Date().getAfterMultiMonth(value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];
- date = new Date(date.getFullYear(), date.getMonth(), 1);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_MONTH_END:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];
- date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate());
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_WEEK_PREV:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];
- date = date.getOffsetDate(-7 * value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];
- date = date.getOffsetDate(7 * value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_DAY_PREV:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];
- date = date.getOffsetDate(-1 * value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_DAY_AFTER:
- var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];
- date = date.getOffsetDate(1 * value);
- _setInnerValue(date, text);
- break;
- case BI.DateTrigger.MULTI_DATE_DAY_TODAY:
- var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];
- date = new Date();
- _setInnerValue(date, text);
- break;
- default:
- if (BI.isNull(value) || BI.isNull(value.day)) {
- this.editor.setState("");
- this.editor.setValue("");
- this.setTitle("");
- } else {
- var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day;
- this.editor.setState(dateStr);
- this.editor.setValue(dateStr);
- this.setTitle(dateStr);
- }
- break;
- }
- },
-
- getKey: function () {
- return this.editor.getValue();
- },
- getValue: function () {
- return this.store_value;
- }
-
-});
-
-BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1;
-BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2;
-BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3;
-BI.DateTrigger.MULTI_DATE_YEAR_END = 4;
-
-BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5;
-BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6;
-BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7;
-BI.DateTrigger.MULTI_DATE_MONTH_END = 8;
-
-BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9;
-BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10;
-BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11;
-BI.DateTrigger.MULTI_DATE_QUARTER_END = 12;
-
-BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13;
-BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14;
-
-BI.DateTrigger.MULTI_DATE_DAY_PREV = 15;
-BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16;
-BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17;
-
-BI.DateTrigger.MULTI_DATE_PARAM = 18;
-BI.DateTrigger.MULTI_DATE_CALENDAR = 19;
-
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {};
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End");
-
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End");
-
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End");
-
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next");
-
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next");
-BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today");
-
-BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
-BI.DateTrigger.EVENT_START = "EVENT_START";
-BI.DateTrigger.EVENT_STOP = "EVENT_STOP";
-BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
-BI.DateTrigger.EVENT_VALID = "EVENT_VALID";
-BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR";
-BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
-BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
-BI.shortcut("bi.date_trigger", BI.DateTrigger);/**
- * Created by zcf on 2017/2/20.
- */
-BI.DatePaneWidget = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: "bi-date-pane-widget",
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- selectedTime: null
- })
- },
- _init: function () {
- BI.DatePaneWidget.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.today = new Date();
- this._year = this.today.getFullYear();
- this._month = this.today.getMonth();
-
- this.selectedTime = o.selectedTime || {
- year: this._year,
- month: this._month
- };
-
- this.datePicker = BI.createWidget({
- type: "bi.date_picker",
- min: o.min,
- max: o.max
- });
- this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
- self.selectedTime = self.datePicker.getValue();
- // self.selectedTime.day = 1;
- self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
- });
-
- this.calendar = BI.createWidget({
- direction: "top",
- element: this,
- logic: {
- dynamic: false
- },
- type: "bi.navigation",
- tab: this.datePicker,
- cardCreator: BI.bind(this._createNav, this)
-
- // afterCardCreated: function () {
- //
- // },
- //
- // afterCardShow: function () {
- // // this.setValue(self.selectedTime);
- // }
- });
- this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
- self.selectedTime = self.calendar.getValue();
- self.calendar.empty();
- self.setValue(self.selectedTime);
- self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
- });
-
- },
-
- _createNav: function (v) {
- var date = BI.Calendar.getDateJSONByPage(v);
- var calendar = BI.createWidget({
- type: "bi.calendar",
- logic: {
- dynamic: false
- },
- min: this.options.min,
- max: this.options.max,
- year: date.year,
- month: date.month,
- day: this.selectedTime.day
- });
- return calendar;
- },
-
- _getNewCurrentDate: function () {
- var today = new Date();
- return {
- year: today.getFullYear(),
- month: today.getMonth()
- }
- },
-
- _setCalenderValue: function (date) {
- this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date));
- this.calendar.setValue(date);
- this.selectedTime = date;
- },
-
- _setDatePicker: function (timeOb) {
- if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) {
- this.datePicker.setValue(this._getNewCurrentDate());
- } else {
- this.datePicker.setValue(timeOb);
- }
- },
-
- _setCalendar: function (timeOb) {
- if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) {
- this.calendar.empty();
- this._setCalenderValue(this._getNewCurrentDate());
- } else {
- this._setCalenderValue(timeOb)
- }
- },
-
- setValue: function (timeOb) {
- this._setDatePicker(timeOb);
- this._setCalendar(timeOb);
- },
-
- getValue: function () {
- return this.selectedTime;
- }
-
-});
-BI.shortcut("bi.date_pane_widget", BI.DatePaneWidget);/**
- * 带有方向的pathchooser
- *
- * Created by GUY on 2016/4/21.
- * @class BI.DirectionPathChooser
- * @extends BI.Widget
- */
-BI.DirectionPathChooser = BI.inherit(BI.Widget, {
-
- _const: {
- lineColor: "#808080",
- selectLineColor: "#009de3"
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.DirectionPathChooser.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-excel-table",
- items: []
- });
- },
-
- _init: function () {
- BI.DirectionPathChooser.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.pathChooser = BI.createWidget({
- type: "bi.path_chooser",
- element: this,
- items: o.items
- });
- this.pathChooser.on(BI.PathChooser.EVENT_CHANGE, function (start, index) {
- //self._unselectAllArrows();
- self._setValue(start, index);
- self.fireEvent(BI.DirectionPathChooser.EVENT_CHANGE);
- });
- this._drawArrows();
-
- },
-
- _unselectAllArrows: function () {
- var self = this, lineColor = this._const.lineColor;
- BI.each(this.arrows, function (region, rs) {
- BI.each(rs, function (idx, arrows) {
- BI.each(arrows, function (i, arrow) {
- arrow.attr({fill: lineColor, stroke: lineColor});
- });
- });
- });
- },
-
- _drawOneArrow: function (dot, direction) {
- //0,1,2,3 上右下左
- var lineColor = this._const.lineColor;
- var selectLineColor = this._const.selectLineColor;
- var svg = this.pathChooser.svg;
- var path = "";
- switch (direction) {
- case 0:
- path = "M" + dot.x + "," + dot.y
- + "L" + (dot.x - 3) + "," + (dot.y + 5)
- + "L" + (dot.x + 3) + "," + (dot.y + 5)
- + "L" + dot.x + "," + dot.y;
- break;
- case 1:
- path = "M" + dot.x + "," + dot.y
- + "L" + (dot.x - 5) + "," + (dot.y - 3)
- + "L" + (dot.x - 5) + "," + (dot.y + 3)
- + "L" + dot.x + "," + dot.y;
- break;
- case 2:
- path = "M" + dot.x + "," + dot.y
- + "L" + (dot.x - 3) + "," + (dot.y - 5)
- + "L" + (dot.x + 3) + "," + (dot.y - 5)
- + "L" + dot.x + "," + dot.y;
- break;
- case 3:
- path = "M" + dot.x + "," + dot.y
- + "L" + (dot.x + 5) + "," + (dot.y - 3)
- + "L" + (dot.x + 5) + "," + (dot.y + 3)
- + "L" + dot.x + "," + dot.y;
- break;
- }
- return svg.path(path).attr({fill: lineColor, stroke: lineColor});
- },
-
- _drawArrows: function () {
- var self = this, o = this.options;
- var routes = this.pathChooser.routes;
- var pathes = this.pathChooser.pathes;
- var store = this.pathChooser.store;
- this.arrows = {};
- BI.each(routes, function (region, ps) {
- self.arrows[region] = [];
- BI.each(ps, function (idx, path) {
- self.arrows[region][idx] = [];
- var dots = pathes[region][idx];
- BI.each(dots, function (i, dot) {
- if (i > 0 && i < dots.length - 1) {
- var arrow;
- if (dot.y === dots[i - 1].y) {
- if (dots[i + 1].y != dot.y) {
- if (store[path[path.length - 2]].direction === -1) {
- if (i - 1 > 0) {
- arrow = self._drawOneArrow(dots[i - 1], 3);
- }
- } else {
- arrow = self._drawOneArrow(dots[i], 1);
- }
- }
- } else if (dot.x === dots[i - 1].x) {
- if (dot.y > dots[i - 1].y) {
- if (store[BI.first(path)].direction === -1) {
- arrow = self._drawOneArrow(dots[i - 1], 0);
- } else {
- arrow = self._drawOneArrow(dot, 2);
- }
- } else {
- if (store[path[path.length - 2]].direction === -1) {
- arrow = self._drawOneArrow(dots[i - 1], 2);
- } else {
- arrow = self._drawOneArrow(dot, 0);
- }
- }
- }
- if (arrow) {
- self.arrows[region][idx].push(arrow);
- }
- }
- });
- BI.each(path, function (i, node) {
- if (i !== 0) {
- var arrow;
- var from = path[i - 1];
- if (store[from].direction === -1) {
- var regionIndex = self.pathChooser.getRegionIndexById(from);
- var x = getXoffsetByRegionIndex(regionIndex, -1);
- var y = getYByXoffset(dots, x);
- arrow = self._drawOneArrow({x: x, y: y}, 3);
- } else {
- var regionIndex = self.pathChooser.getRegionIndexById(node);
- var x = getXoffsetByRegionIndex(regionIndex);
- var y = getYByXoffset(dots, x);
- arrow = self._drawOneArrow({x: x, y: y}, 1);
- }
- if (arrow) {
- self.arrows[region][idx].push(arrow);
- }
- }
- });
- })
- });
-
- function getXoffsetByRegionIndex(regionIndex, diregion) {
- if (diregion === -1) {
- return 100 * (regionIndex + 1) - 20;
- }
- return 100 * regionIndex + 20;
- }
-
- function getYByXoffset(dots, xoffset) {
- var finded = BI.find(dots, function (i, dot) {
- if (i > 0) {
- if (dots[i - 1].x < xoffset && dots[i].x > xoffset) {
- return true;
- }
- }
- });
- return finded.y;
- }
- },
-
- _setValue: function (start, index) {
- var self = this;
- var lineColor = this._const.lineColor;
- var selectLineColor = this._const.selectLineColor;
- var routes = this.pathChooser.routes;
- var starts = this.pathChooser.start;
- var each = [start];
- if (starts.contains(start)) {
- each = starts;
- }
- BI.each(each, function (i, s) {
- BI.each(self.arrows[s], function (j, arrows) {
- BI.each(arrows, function (k, arrow) {
- arrow.attr({fill: lineColor, stroke: lineColor}).toFront();
- });
- });
- });
- BI.each(this.arrows[start][index], function (i, arrow) {
- arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront();
- });
- var current = BI.last(routes[start][index]);
- while (current && routes[current] && routes[current].length === 1) {
- BI.each(self.arrows[current][0], function (i, arrow) {
- arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront();
- });
- current = BI.last(routes[current][0]);
- }
- },
-
- setValue: function (v) {
- this.pathChooser.setValue(v);
- this._unselectAllArrows();
- var routes = this.pathChooser.routes;
- var nodes = BI.keys(routes), self = this;
- var result = [], array = [];
- BI.each(v, function (i, val) {
- if (BI.contains(nodes, val)) {
- if (array.length > 0) {
- array.push(val);
- result.push(array);
- array = [];
- }
- }
- array.push(val);
- });
- if (array.length > 0) {
- result.push(array);
- }
- //画这n条路径
- BI.each(result, function (idx, path) {
- var start = path[0];
- var index = BI.findIndex(routes[start], function (idx, p) {
- if (BI.isEqual(path, p)) {
- return true;
- }
- });
- if (index >= 0) {
- self._setValue(start, index);
- }
- });
- },
-
- getValue: function () {
- return this.pathChooser.getValue();
- },
-
- populate: function (items) {
- this.pathChooser.populate(items);
- this._drawArrows();
- }
-});
-BI.DirectionPathChooser.EVENT_CHANGE = "DirectionPathChooser.EVENT_CHANGE";
-BI.shortcut('bi.direction_path_chooser', BI.DirectionPathChooser);/**
- * Created by roy on 15/8/14.
- */
-BI.DownListCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-down-list-combo",
- invalid: false,
- height: 25,
- items: [],
- adjustLength: 0,
- direction: "bottom",
- trigger: "click",
- el: {}
- })
- },
-
- _init: function () {
- BI.DownListCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.popupview = BI.createWidget({
- type: "bi.down_list_popup",
- items: o.items,
- chooseType: o.chooseType
- });
-
- this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) {
- self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
- self.downlistcombo.hideView();
- });
-
- this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
- self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
- self.downlistcombo.hideView();
- });
-
-
- this.downlistcombo = BI.createWidget({
- element: this,
- type: 'bi.combo',
- trigger: o.trigger,
- isNeedAdjustWidth: false,
- adjustLength: o.adjustLength,
- direction: o.direction,
- el: BI.createWidget(o.el, {
- type: "bi.icon_trigger",
- extraCls: o.iconCls ? o.iconCls : "pull-down-font",
- width: o.width,
- height: o.height
- }),
- popup: {
- el: this.popupview,
- stopPropagation: true,
- maxHeight: 1000
- }
- });
-
- this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
- });
- },
-
- hideView: function () {
- this.downlistcombo.hideView();
- },
-
- showView: function () {
- this.downlistcombo.showView();
- },
-
- populate: function (items) {
- this.popupview.populate(items);
- },
-
- setValue: function (v) {
- this.popupview.setValue(v);
- },
- getValue: function () {
- return this.popupview.getValue()
- }
-});
-BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
-BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-
-BI.shortcut("bi.down_list_combo", BI.DownListCombo);/**
- * Created by roy on 15/9/6.
- */
-BI.DownListGroup = BI.inherit(BI.Widget, {
- constants: {
- iconCls: "check-mark-ha-font"
- },
- _defaultConfig: function () {
- return BI.extend(BI.DownListGroup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-down-list-group",
- items: [
- {
- el: {}
- }
- ]
- })
- },
- _init: function () {
- BI.DownListGroup.superclass._init.apply(this, arguments);
- var o = this.options, self = this;
-
- this.downlistgroup = BI.createWidget({
- element: this,
- type: "bi.button_tree",
- items: o.items,
- chooseType: 0,//0单选,1多选
- layouts: [{
- type: "bi.vertical",
- hgap: 0,
- vgap: 0
- }]
- });
- this.downlistgroup.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if(type === BI.Events.CLICK) {
- self.fireEvent(BI.DownListGroup.EVENT_CHANGE, arguments);
- }
- })
- },
- getValue:function(){
- return this.downlistgroup.getValue();
- },
- setValue:function(v){
- this.downlistgroup.setValue(v);
- }
-
-
-})
-BI.DownListGroup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.down_list_group", BI.DownListGroup);BI.DownListItem = BI.inherit(BI.Single, {
- _defaultConfig: function () {
- var conf = BI.DownListItem.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: "bi-down-list-item bi-list-item-active",
- cls: "",
- height: 25,
- logic: {
- dynamic: true
- },
- selected: false,
- iconHeight: null,
- iconWidth: null,
- textHgap: 0,
- textVgap: 0,
- textLgap: 0,
- textRgap: 0
- })
- },
- _init: function () {
- BI.DownListItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.text = BI.createWidget({
- type: "bi.icon_text_item",
- element: this,
- height: o.height,
- text: o.text,
- value: o.value,
- logic: o.logic,
- selected: o.selected,
- disabled: o.disabled,
- iconHeight: o.iconHeight,
- iconWidth: o.iconWidth,
- textHgap: o.textHgap,
- textVgap: o.textVgap,
- textLgap: o.textLgap,
- textRgap: o.textRgap,
- father: o.father
- });
- this.text.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.text.on(BI.IconTextItem.EVENT_CHANGE, function () {
- self.fireEvent(BI.DownListItem.EVENT_CHANGE);
- });
- // this.setSelected(o.selected);
- },
-
- doRedMark: function () {
- this.text.doRedMark.apply(this.text, arguments);
- },
-
- unRedMark: function () {
- this.text.unRedMark.apply(this.text, arguments);
- },
-
- isSelected: function () {
- return this.text.isSelected();
- },
-
- setSelected: function (b) {
- this.text.setSelected(b);
- // if (b === true) {
- // this.element.addClass("dot-e-font");
- // } else {
- // this.element.removeClass("dot-e-font");
- // }
- },
-
- setValue: function (v) {
- this.text.setValue(v);
- },
-
- getValue: function () {
- return this.text.getValue();
- }
-});
-BI.DownListItem.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inherit(BI.BasicButton, {
- _defaultConfig: function () {
- var conf = BI.DownListGroupItem.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: (conf.baseCls || "") + " bi-down-list-group-item",
- logic: {
- dynamic: false
- },
- // invalid: true,
- iconCls1: "dot-e-font",
- iconCls2: "pull-right-e-font"
- })
- },
- _init: function () {
- BI.DownListGroupItem.superclass._init.apply(this, arguments);
- var o = this.options;
- var self = this;
- this.text = BI.createWidget({
- type: "bi.label",
- cls: "list-group-item-text",
- textAlign: "left",
- text: o.text,
- value: o.value,
- height: o.height
- });
-
- this.icon1 = BI.createWidget({
- type: "bi.icon_button",
- cls: o.iconCls1,
- width: 25,
- forceNotSelected: true
- });
-
- this.icon2 = BI.createWidget({
- type: "bi.icon_button",
- cls: o.iconCls2,
- width: 25,
- forceNotSelected: true
- });
-
- var blank = BI.createWidget({
- type: "bi.layout",
- width: 25
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.icon2,
- top: 0,
- bottom: 0,
- right: 0
- }]
- });
-
- BI.createWidget(BI.extend({
- element: this
- }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
- items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank)
- }))));
-
- this.element.hover(function () {
- if (self.isEnabled()) {
- self.hover();
- }
- }, function () {
- if (self.isEnabled()) {
- self.dishover()
- }
- });
- },
-
- hover: function () {
- BI.DownListGroupItem.superclass.hover.apply(this, arguments);
- this.icon1.element.addClass("hover");
- this.icon2.element.addClass("hover");
-
- },
-
- dishover: function () {
- BI.DownListGroupItem.superclass.dishover.apply(this, arguments);
- this.icon1.element.removeClass("hover");
- this.icon2.element.removeClass("hover");
- },
-
- doClick: function () {
- BI.DownListGroupItem.superclass.doClick.apply(this, arguments);
- if (this.isValid()) {
- this.fireEvent(BI.DownListGroupItem.EVENT_CHANGE, this.getValue());
- }
- },
-
- doRedMark: function () {
- this.text.doRedMark.apply(this.text, arguments);
- },
-
- unRedMark: function () {
- this.text.unRedMark.apply(this.text, arguments);
- },
-
- setValue: function (v) {
- var self = this, o = this.options;
- v = BI.isArray(v) ? v : [v];
- BI.find(v, function (idx, value) {
- if (BI.contains(o.childValues, value)) {
- self.icon1.setSelected(true);
- return true;
- } else {
- self.icon1.setSelected(false);
- }
- })
- }
-});
-BI.DownListGroupItem.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem);/**
- * Created by roy on 15/9/8.
- * 处理popup中的item分组样式
- * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项
- */
-BI.DownListPopup = BI.inherit(BI.Pane, {
- constants: {
- nextIcon: "pull-right-e-font",
- height: 25,
- iconHeight: 12,
- iconWidth: 12,
- hgap: 0,
- vgap: 0,
- border: 1
- },
- _defaultConfig: function () {
- var conf = BI.DownListPopup.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: "bi-down-list-popup",
- items: [],
- chooseType: BI.Selection.Multi
- })
- },
- _init: function () {
- BI.DownListPopup.superclass._init.apply(this, arguments);
- this.singleValues = [];
- this.childValueMap = {};
- this.fatherValueMap = {};
- var self = this, o = this.options, children = this._createChildren(o.items);
- this.popup = BI.createWidget({
- type: "bi.button_tree",
- items: BI.createItems(children,
- {}, {
- adjustLength: -2
- }
- ),
- layouts: [{
- type: "bi.vertical",
- hgap: this.constants.hgap,
- vgap: this.constants.vgap
- }],
- chooseType: o.chooseType
- });
-
- this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) {
- var changedValue = value;
- if (BI.isNotNull(self.childValueMap[value])) {
- changedValue = self.childValueMap[value];
- self.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, self.fatherValueMap[value])
- } else {
- self.fireEvent(BI.DownListPopup.EVENT_CHANGE, changedValue, object);
- }
-
-
- if (!self.singleValues.contains(changedValue)) {
- var item = self.getValue();
- var result = [];
- BI.each(item, function (i, valueObject) {
- if (valueObject.value != changedValue) {
- result.push(valueObject);
- }
- });
- self.setValue(result);
- }
-
- });
-
- BI.createWidget({
- type: "bi.vertical",
- element: this,
- items: [this.popup]
- });
-
- },
- _createChildren: function (items) {
- var self = this, result = [];
- BI.each(items, function (i, it) {
- var item_done = {
- type: "bi.down_list_group",
- items: []
- };
-
- BI.each(it, function (i, item) {
- if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) {
- item.type = "bi.combo_group";
- item.cls = "down-list-group";
- item.trigger = "hover";
- item.isNeedAdjustWidth = false;
- item.el.title = item.el.title || item.el.text;
- item.el.type = "bi.down_list_group_item";
- item.el.logic = {
- dynamic: true
- };
- item.el.height = self.constants.height;
- item.el.iconCls2 = self.constants.nextIcon;
- item.popup = {
- lgap: 4,
- el: {
- type: "bi.button_tree",
- chooseType: 0,
- layouts: [{
- type: "bi.vertical"
- }]
-
- }
- };
- item.el.childValues = [];
- BI.each(item.children, function (i, child) {
- var fatherValue = BI.deepClone(item.el.value);
- var childValue = BI.deepClone(child.value);
- self.singleValues.push(child.value);
- child.type = "bi.down_list_item";
- child.extraCls = " child-down-list-item";
- child.title = child.title || child.text;
- child.textRgap = 10;
- child.isNeedAdjustWidth = false;
- child.logic = {
- dynamic: true
- };
- child.father = fatherValue;
- self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
- self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
- child.value = self._createChildValue(fatherValue, childValue);
- item.el.childValues.push(child.value);
- })
- } else {
- item.type = "bi.down_list_item";
- item.title = item.title || item.text;
- item.textRgap = 10;
- item.isNeedAdjustWidth = false;
- item.logic = {
- dynamic: true
- }
- }
- var el_done = {};
- el_done.el = item;
- item_done.items.push(el_done);
- });
- if (self._isGroup(item_done.items)) {
- BI.each(item_done.items, function (i, item) {
- self.singleValues.push(item.el.value);
- })
- }
-
- result.push(item_done);
- if (self._needSpliter(i, items.length)) {
- var spliter_container = BI.createWidget({
- type: "bi.vertical",
- items: [{
- el: {
- type: "bi.layout",
- cls: "bi-down-list-spliter bi-border-top cursor-pointer",
- height: 0
- }
-
- }],
- cls: "bi-down-list-spliter-container cursor-pointer",
- lgap: 10,
- rgap: 10
- });
- result.push(spliter_container);
- }
- });
- return result;
- },
-
- _isGroup: function (i) {
- return i.length > 1;
- },
-
- _needSpliter: function (i, itemLength) {
- return i < itemLength - 1;
- },
-
- _createChildValue: function (fatherValue, childValue) {
- return fatherValue + "_" + childValue
- },
-
- populate: function (items) {
- BI.DownListPopup.superclass.populate.apply(this, arguments);
- var self = this;
- self.childValueMap = {};
- self.fatherValueMap = {};
- self.singleValues = [];
- var children = self._createChildren(items);
- var popupItem = BI.createItems(children,
- {}, {
- adjustLength: -2
- }
- );
- self.popup.populate(popupItem);
- },
-
- setValue: function (valueItem) {
- var self = this;
- var valueArray = [];
- BI.each(valueItem, function (i, item) {
- var value;
- if (BI.isNotNull(item.childValue)) {
- value = self._createChildValue(item.value, item.childValue);
- } else {
- value = item.value;
- }
- valueArray.push(value);
- }
- );
- this.popup.setValue(valueArray);
- },
-
- getValue: function () {
- var self = this, result = [];
- var values = this.popup.getValue();
- BI.each(values, function (i, value) {
- var valueItem = {};
- if (BI.isNotNull(self.childValueMap[value])) {
- var fartherValue = self.fatherValueMap[value];
- valueItem.childValue = self.childValueMap[value];
- valueItem.value = fartherValue;
- } else {
- valueItem.value = value;
- }
- result.push(valueItem);
- });
- return result;
- }
-
-
-});
-
-BI.DownListPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.DownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
-BI.shortcut("bi.down_list_popup", BI.DownListPopup);/**
- *
- * Created by GUY on 2016/3/28.
- * @class BI.ExcelTableCell
- * @extends BI.Widget
- */
-BI.ExcelTableCell = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ExcelTableCell.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-excel-table-cell",
- text: ""
- });
- },
-
- _init: function () {
- BI.ExcelTableCell.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- BI.createWidget({
- type: "bi.label",
- element: this,
- textAlign: "left",
- whiteSpace: "normal",
- height: this.options.height,
- text: this.options.text,
- value: this.options.value
- })
- }
-});
-BI.shortcut('bi.excel_table_cell', BI.ExcelTableCell);/**
- *
- * Created by GUY on 2016/3/28.
- * @class BI.ExcelTableHeaderCell
- * @extends BI.Widget
- */
-BI.ExcelTableHeaderCell = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ExcelTableHeaderCell.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-excel-table-header-cell bi-background",
- text: ""
- });
- },
-
- _init: function () {
- BI.ExcelTableHeaderCell.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- BI.createWidget({
- type: "bi.label",
- element: this,
- textAlign: BI.HorizontalAlign.Center,
- whiteSpace: "normal",
- height: this.options.height,
- text: this.options.text,
- value: this.options.value
- })
- }
-});
-BI.shortcut('bi.excel_table_header_cell', BI.ExcelTableHeaderCell);/**
- * Excel表格
- *
- * Created by GUY on 2016/3/28.
- * @class BI.ExcelTable
- * @extends BI.Widget
- */
-BI.ExcelTable = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-excel-table",
- el: {
- type: "bi.responsive_table"
- },
-
- isNeedResize: false,
- isResizeAdapt: true,
-
- isNeedMerge: false,//是否需要合并单元格
- mergeCols: [], //合并的单元格列号
- mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
- return BI.isEqual(row1, row2);
- },
-
- columnSize: [],
- headerRowSize: 37,
- footerRowSize: 37,
- rowSize: 37,
-
- regionColumnSize: false,
-
- items: [] //二维数组
- });
- },
-
- _init: function () {
- BI.ExcelTable.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- var mergeCols = [];
- BI.each(o.mergeCols, function (i, col) {
- mergeCols.push(col + 1);
- });
- this.table = BI.createWidget(o.el, {
- type: "bi.table_view",
- element: this,
-
- isNeedFreeze: false,
-
- isNeedMerge: o.isNeedMerge,
- mergeCols: mergeCols,
- mergeRule: o.mergeRule,
-
- columnSize: [""].concat(o.columnSize),
- headerRowSize: 18,
- rowSize: o.rowSize,
-
- regionColumnSize: o.regionColumnSize || [82, ""]
- });
-
- if (BI.isNotEmptyArray(o.items)) {
- this.populate(o.items);
- }
- BI.nextTick(function () {
- self.setRegionColumnSize(o.regionColumnSize || [82, ""]);
- });
- },
-
- resize: function () {
- this.table.resize();
- },
-
- setColumnSize: function (columnSize) {
- this.table.setColumnSize(columnSize);
- },
-
- getColumnSize: function () {
- return this.table.getColumnSize();
- },
-
- getCalculateColumnSize: function () {
- return this.table.getCalculateColumnSize();
- },
-
- setHeaderColumnSize: function (columnSize) {
- this.table.setHeaderColumnSize(columnSize);
- },
-
- setRegionColumnSize: function (columnSize) {
- this.table.setRegionColumnSize(columnSize);
- },
-
- getRegionColumnSize: function () {
- return this.table.getRegionColumnSize();
- },
-
- getCalculateRegionColumnSize: function () {
- return this.table.getCalculateRegionColumnSize();
- },
-
- getCalculateRegionRowSize: function () {
- return this.table.getCalculateRegionRowSize();
- },
-
- getClientRegionColumnSize: function () {
- return this.table.getClientRegionColumnSize();
- },
-
- getScrollRegionColumnSize: function () {
- return this.table.getScrollRegionColumnSize();
- },
-
- getScrollRegionRowSize: function () {
- return this.table.getScrollRegionRowSize();
- },
-
- hasVerticalScroll: function () {
- return this.table.hasVerticalScroll();
- },
-
- setVerticalScroll: function (scrollTop) {
- this.table.setVerticalScroll(scrollTop);
- },
-
- setLeftHorizontalScroll: function (scrollLeft) {
- this.table.setLeftHorizontalScroll(scrollLeft);
- },
-
- setRightHorizontalScroll: function (scrollLeft) {
- this.table.setRightHorizontalScroll(scrollLeft);
- },
-
- getVerticalScroll: function () {
- return this.table.getVerticalScroll();
- },
-
- getLeftHorizontalScroll: function () {
- return this.table.getLeftHorizontalScroll();
- },
-
- getRightHorizontalScroll: function () {
- return this.table.getRightHorizontalScroll();
- },
-
- getColumns: function () {
- return this.table.getColumns();
- },
-
- resizeHeader: function () {
- this.table.resize();
- this.table._resizeHeader && this.table._resizeHeader();
- },
-
- attr: function (key,value) {
- var self = this;
- if (BI.isObject(key)) {
- BI.each(key, function (k, v) {
- self.attr(k, v);
- });
- return;
- }
- BI.ExcelTable.superclass.attr.apply(this, arguments);
- switch (key){
- case "mergeCols":
- var mCols = [];
- BI.each(value, function (i, col) {
- mCols.push(col + 1);
- });
- value=mCols;
- break;
- }
- this.table.attr.apply(this.table, arguments);
- },
-
- populate: function (rows) {
- var self = this;
- var columnSize = this.getColumnSize();
- var items = [];
- var header = [{
- type: "bi.excel_table_header_cell"
- }];
- if (BI.isNotNull(rows)) {
- BI.each(columnSize, function (i, size) {
- header.push({
- type: "bi.excel_table_header_cell",
- text: BI.int2Abc(i + 1)
- });
- });
- BI.each(rows, function (i, row) {
- items.push([{
- type: "bi.excel_table_header_cell",
- text: (i + 1)
- }].concat(row));
- });
- }
- this.table.populate(items, [header]);
- },
-
- destroy: function () {
- this.table.destroy();
- BI.ExcelTable.superclass.destroy.apply(this, arguments);
- }
-});
-BI.shortcut('bi.excel_table', BI.ExcelTable);/**
- * 文件管理控件组
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerButtonGroup
- * @extends BI.Widget
- */
-BI.FileManagerButtonGroup = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-button_group",
- items: []
- })
- },
-
- _init: function () {
- BI.FileManagerButtonGroup.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.button_group = BI.createWidget({
- type: "bi.button_tree",
- element: this,
- chooseType: BI.Selection.Multi,
- items: this._formatItems(o.items),
- layouts: [{
- type: "bi.vertical"
- }]
- });
- this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- },
-
- _formatItems: function (items) {
- var self = this, o = this.options;
- BI.each(items, function (i, item) {
- if (item.children && item.children.length > 0) {
- item.type = "bi.file_manager_folder_item";
- } else {
- item.type = "bi.file_manager_file_item";
- }
- });
- return items;
- },
-
- setValue: function (v) {
- this.button_group.setValue(v);
- },
-
- getValue: function () {
- return this.button_group.getValue();
- },
-
- getNotSelectedValue: function () {
- return this.button_group.getNotSelectedValue();
- },
-
- getAllLeaves: function () {
- return this.button_group.getAllLeaves();
- },
-
- getAllButtons: function () {
- return this.button_group.getAllButtons();
- },
-
- getSelectedButtons: function () {
- return this.button_group.getSelectedButtons();
- },
-
- getNotSelectedButtons: function () {
- return this.button_group.getNotSelectedButtons();
- },
-
- populate: function (items) {
- this.button_group.populate(this._formatItems(items));
- }
-});
-BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/**
- * 文件管理控件
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManager
- * @extends BI.Widget
- */
-BI.FileManager = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager",
- el: {},
- items: []
- })
- },
-
- _init: function () {
- BI.FileManager.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.tree = new BI.Tree();
- var items = BI.Tree.transformToTreeFormat(o.items);
- this.tree.initTree(items);
- this.selectedValues = [];
- this.nav = BI.createWidget({
- type: "bi.file_manager_nav",
- items: BI.deepClone(items)
- });
- this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) {
- if (value == "-1") {//根节点
- self.populate({children: self.tree.toJSON()});
- } else {
- var node = self.tree.search(obj.attr("id"));
- self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)}));
- }
- self.setValue(self.selectedValues);
- });
- this.list = BI.createWidget(o.el, {
- type: "bi.file_manager_list",
- items: items
- });
- this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) {
- if (type === BI.Events.CHANGE) {
- var node = self.tree.search(obj.attr("id"));
- self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)}));
- } else if (type === BI.Events.CLICK) {
- var values = [];
- if (obj instanceof BI.MultiSelectBar) {
- var t = self.list.getValue();
- selected = t.type === BI.Selection.All;
- values = BI.concat(t.assist, t.value);
- } else {
- values = obj.getAllLeaves();
- }
- BI.each(values, function (i, v) {
- if (selected === true) {
- self.selectedValues.pushDistinct(v);
- } else {
- self.selectedValues.remove(v);
- }
- });
- }
- self.setValue(self.selectedValues);
- });
-
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.list,
- left: 0,
- right: 0,
- top: 0,
- bottom: 10
- }, {
- el: this.nav,
- left: 40,
- right: 100,
- top: 0
- }]
- });
- },
-
- setValue: function (value) {
- this.selectedValues = value || [];
- this.list.setValue(this.selectedValues);
- },
-
- getValue: function () {
- var obj = this.list.getValue();
- var res = obj.type === BI.Selection.All ? obj.assist : obj.value;
- res.pushDistinctArray(this.selectedValues);
- return res;
- },
-
- _populate: function (items) {
- this.list.populate(items);
- },
-
- getSelectedValue: function () {
- return this.nav.getValue()[0];
- },
-
- getSelectedId: function () {
- return this.nav.getId()[0];
- },
-
- populate: function (node) {
- var clone = BI.deepClone(node);
- this._populate(node.children);
- this.nav.populate(clone);
- }
-});
-BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE";
-BI.shortcut("bi.file_manager", BI.FileManager);/**
- * 文件管理控件
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerFileItem
- * @extends BI.Single
- */
-BI.FileManagerFileItem = BI.inherit(BI.Single, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom",
- height: 30
- })
- },
-
- _init: function () {
- BI.FileManagerFileItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.checked = BI.createWidget({
- type: "bi.multi_select_bar",
- text: "",
- width: 36,
- height: o.height
- });
- this.checked.on(BI.Controller.EVENT_CHANGE, function () {
- arguments[2] = self;
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- BI.createWidget({
- type: "bi.htape",
- element: this,
- items: [{
- el: this.checked,
- width: 36
- }, {
- el: {
- type: "bi.icon_button",
- cls: "create-by-me-file-font"
- },
- width: 20
- }, {
- el: {
- type: "bi.label",
- textAlign: "left",
- height: o.height,
- text: o.text,
- value: o.value
- }
- }]
- })
- },
-
- getAllLeaves: function(){
- return [this.options.value];
- },
-
- isSelected: function () {
- return this.checked.isSelected();
- },
-
- setSelected: function (v) {
- this.checked.setSelected(v);
- }
-});
-BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/**
- * 文件管理控件
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerFolderItem
- * @extends BI.Single
- */
-BI.FileManagerFolderItem = BI.inherit(BI.Single, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom",
- height: 30
- })
- },
-
- _init: function () {
- BI.FileManagerFolderItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.checked = BI.createWidget({
- type: "bi.multi_select_bar",
- text: "",
- width: 36,
- height: o.height
- });
- this.checked.on(BI.Controller.EVENT_CHANGE, function () {
- arguments[2] = self;
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.button = BI.createWidget({
- type: "bi.text_button",
- textAlign: "left",
- height: o.height,
- text: o.text,
- value: o.value
- });
- this.button.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self);
- });
-
- this.tree = new BI.Tree();
- this.tree.initTree([{
- id: o.id,
- children: o.children
- }]);
- this.selectValue = [];
-
- BI.createWidget({
- type: "bi.htape",
- element: this,
- items: [{
- el: this.checked,
- width: 36
- }, {
- el: {
- type: "bi.icon_button",
- cls: "create-by-me-folder-font"
- },
- width: 20
- }, {
- el: this.button
- }]
- })
- },
-
- setAllSelected: function (v) {
- this.checked.setSelected(v);
- this.selectValue = [];
- },
-
- setHalfSelected: function (v) {
- this.checked.setHalfSelected(v);
- if(!v){
- this.selectValue = [];
- }
- },
-
- setValue: function (v) {
- var self = this, o = this.options;
- var isHalf = false;
- var selectValue = [];
- this.tree.traverse(function (node) {
- if (node.isLeaf()) {
- if (BI.contains(v, node.get("data").value)) {
- selectValue.push(node.get("data").value);
- } else {
- isHalf = true;
- }
- }
- });
- this.setAllSelected(selectValue.length > 0 && !isHalf);
- this.setHalfSelected(selectValue.length > 0 && isHalf);
- if (this.checked.isHalfSelected()) {
- this.selectValue = selectValue;
- }
- },
-
- getAllButtons: function () {
- return [this];
- },
-
- getAllLeaves: function () {
- var o = this.options;
- var res = [];
- this.tree.traverse(function (node) {
- if (node.isLeaf()) {
- res.push(node.get("data").value)
- }
- });
- return res;
- },
-
- getNotSelectedValue: function () {
- var self = this, o = this.options;
- var res = [];
- var isAllSelected = this.checked.isSelected();
- if (isAllSelected === true) {
- return res;
- }
- var isHalfSelected = this.checked.isHalfSelected();
- this.tree.traverse(function (node) {
- if (node.isLeaf()) {
- var v = node.get("data").value;
- if (isHalfSelected === true) {
- if (!BI.contains(self.selectValue, node.get("data").value)) {
- res.push(v);
- }
- } else {
- res.push(v);
- }
- }
- });
- return res;
- },
-
- getValue: function () {
- var res = [];
- if (this.checked.isSelected()) {
- this.tree.traverse(function (node) {
- if (node.isLeaf()) {
- res.push(node.get("data").value);
- }
- });
- return res;
- }
- if (this.checked.isHalfSelected()) {
- return this.selectValue;
- }
- return [];
- }
-});
-BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/**
- * 文件管理控件列表
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerList
- * @extends BI.Widget
- */
-BI.FileManagerList = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-list",
- el: {},
- items: []
- })
- },
-
- _init: function () {
- BI.FileManagerList.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.list = BI.createWidget({
- type: "bi.select_list",
- element: this,
- items: o.items,
- toolbar: {
- type: "bi.multi_select_bar",
- height: 40,
- text: ""
- },
- el: {
- type: "bi.list_pane",
- el: BI.isWidget(o.el) ? o.el : BI.extend({
- type: "bi.file_manager_button_group"
- }, o.el)
- }
- });
- this.list.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- },
-
- setValue: function (v) {
- this.list.setValue({
- value: v
- });
- },
-
- getValue: function () {
- return this.list.getValue();
- },
-
- populate: function (items) {
- this.list.populate(items);
- this.list.setToolBarVisible(true);
- }
-});
-BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_list", BI.FileManagerList);/**
- * 文件管理导航按钮
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerNavButton
- * @extends BI.Widget
- */
-BI.FileManagerNavButton = BI.inherit(BI.Widget, {
-
- _const: {
- normal_color: "#ffffff",
- select_color: "#f4f4f4"
- },
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-nav-button",
- selected: false,
- height: 40
- })
- },
-
- _init: function () {
- BI.FileManagerNavButton.superclass._init.apply(this, arguments);
- var self = this, o = this.options, c = this._const;
- this.button = BI.createWidget({
- type: "bi.text_button",
- cls: "file-manager-nav-button-text bi-card",
- once: true,
- selected: o.selected,
- text: o.text,
- title: o.text,
- value: o.value,
- height: o.height,
- lgap: 20,
- rgap: 10
- });
- this.button.on(BI.Controller.EVENT_CHANGE, function () {
- arguments[2] = self;
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- var svg = BI.createWidget({
- type: "bi.svg",
- cls: "file-manager-nav-button-triangle",
- width: 15,
- height: o.height
- });
- var path = svg.path("M0,0L15,20L0,40").attr({
- "stroke": c.select_color,
- "fill": o.selected ? c.select_color : c.normal_color
- });
- this.button.on(BI.TextButton.EVENT_CHANGE, function () {
- if (this.isSelected()) {
- path.attr("fill", c.select_color);
- } else {
- path.attr("fill", c.normal_color);
- }
- });
- BI.createWidget({
- type: "bi.default",
- element: this,
- items: [this.button]
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: svg,
- right: -15,
- top: 0,
- bottom: 0
- }]
- })
- },
-
- isSelected: function () {
- return this.button.isSelected();
- },
-
- setValue: function (v) {
- this.button.setValue(v);
- },
-
- getValue: function () {
- return this.button.getValue();
- },
-
- populate: function (items) {
-
- }
-});
-BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/**
- * 文件管理导航
- *
- * Created by GUY on 2015/12/11.
- * @class BI.FileManagerNav
- * @extends BI.Widget
- */
-BI.FileManagerNav = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-file-manager-nav bi-border-left",
- height: 40,
- items: []
- })
- },
-
- _init: function () {
- BI.FileManagerNav.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.tree = new BI.Tree();
- this.refreshTreeData(o.items);
- this.tree.getRoot().set("data", {
- text: BI.i18nText("BI-Created_By_Me"),
- value: BI.FileManagerNav.ROOT_CREATE_BY_ME,
- id: BI.FileManagerNav.ROOT_CREATE_BY_ME
- });
- this.button_group = BI.createWidget({
- type: "bi.button_group",
- element: this,
- items: [{
- type: "bi.file_manager_nav_button",
- text: BI.i18nText("BI-Created_By_Me"),
- selected: true,
- id: BI.FileManagerNav.ROOT_CREATE_BY_ME,
- value: BI.FileManagerNav.ROOT_CREATE_BY_ME
- }],
- layouts: [{
- type: "bi.horizontal"
- }]
- });
- this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) {
- self.fireEvent(BI.FileManagerNav.EVENT_CHANGE, arguments);
- });
- },
-
- _getAllParents: function (id) {
- var node, res = [];
- if (!id) {
- node = this.tree.getRoot();
- } else {
- node = this.tree.search(id);
- }
- while (node.parent) {
- res.push(node);
- node = node.parent;
- }
- res.push(node);
- return res.reverse();
- },
-
- _formatNodes: function (nodes) {
- var res = [];
- BI.each(nodes, function (i, node) {
- res.push(BI.extend({
- type: "bi.file_manager_nav_button",
- id: node.id
- }, node.get("data")));
- });
- BI.last(res).selected = true;
- return res;
- },
-
- getValue: function () {
- return this.button_group.getValue();
- },
-
- getId: function () {
- var ids = [];
- BI.each(this.button_group.getSelectedButtons(), function (i, btn) {
- ids.push(btn.attr("id"));
- });
- return ids;
- },
-
- refreshTreeData: function(items){
- this.tree.initTree(BI.Tree.transformToTreeFormat(items));
- this.tree.getRoot().set("data", {
- text: BI.i18nText("BI-Created_By_Me"),
- value: BI.FileManagerNav.ROOT_CREATE_BY_ME,
- id: BI.FileManagerNav.ROOT_CREATE_BY_ME
- });
- },
-
- populate: function (node) {
- var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id);
- this.button_group.populate(this._formatNodes(parents));
- }
-});
-BI.extend(BI.FileManagerNav, {
- ROOT_CREATE_BY_ME: "-1"
-});
-BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE";
-BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/**
- * Created by windy on 2017/3/13.
- * 数值微调器
- */
-BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-fine-tuning-number-editor bi-border",
- value: -1
- })
- },
-
- _init: function () {
- BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.editor = BI.createWidget({
- type: "bi.sign_editor",
- value: this._alertInEditorValue(o.value),
- errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
- validationChecker: function(v){
- return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1;
- }
- });
- this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
- self._finetuning(0);
- self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
- });
- this.topBtn = BI.createWidget({
- type: "bi.icon_button",
- trigger: "lclick,",
- cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
- });
- this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
- self._finetuning(1);
- self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
- });
- this.bottomBtn = BI.createWidget({
- type: "bi.icon_button",
- trigger: "lclick,",
- cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
- });
- this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
- self._finetuning(-1);
- self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
- });
- this._finetuning(0);
- BI.createWidget({
- type: "bi.htape",
- element: this,
- items: [this.editor, {
- el: {
- type: "bi.grid",
- columns: 1,
- rows: 2,
- items: [{
- column: 0,
- row: 0,
- el: this.topBtn
- }, {
- column: 0,
- row: 1,
- el: this.bottomBtn
- }]
- },
- width: 30
- }]
- });
- },
-
- _alertOutEditorValue: function(v){
- return v === BI.i18nText("BI-Basic_Auto") ? -1 : v;
- },
-
- _alertInEditorValue: function(v){
- return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v;
- },
-
- //微调
- _finetuning: function(add){
- var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
- this.editor.setValue(this._alertInEditorValue(v + add));
- this.bottomBtn.setEnable((v + add) > -1);
- },
-
- getValue: function () {
- var v = this.editor.getValue();
- return this._alertOutEditorValue(v);
- },
-
- setValue: function (v) {
- this.editor.setValue(this._alertInEditorValue(v));
- this._finetuning(0);
- }
-
-});
-BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/**
- * 交互行为布局
- *
- *
- * Created by GUY on 2016/7/23.
- * @class BI.InteractiveArrangement
- * @extends BI.Widget
- */
-BI.InteractiveArrangement = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-interactive-arrangement",
- resizable: true,
- layoutType: BI.Arrangement.LAYOUT_TYPE.GRID,
- items: []
- });
- },
-
- _init: function () {
- BI.InteractiveArrangement.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.arrangement = BI.createWidget({
- type: "bi.adaptive_arrangement",
- element: this,
- resizable: o.resizable,
- layoutType: o.layoutType,
- items: o.items
- });
- this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL, function () {
- self.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL, arguments);
- });
- this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE, function () {
- self.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE, arguments);
- });
-
- this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, function (id, size) {
- var p = self._getRegionClientPosition(id);
- self.draw({
- left: p.left,
- top: p.top
- }, size, id);
- });
- this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, function (id, size) {
- self.stopDraw();
- self.setRegionSize(id, size);
- });
-
- this.tags = [];
-
- },
-
- _isEqual: function (num1, num2) {
- return this.arrangement._isEqual(num1, num2);
- },
-
- _getScrollOffset: function () {
- return this.arrangement._getScrollOffset();
- },
-
- _positionAt: function (position, regions) {
- var self = this;
- regions = regions || this.getAllRegions();
- var left = [], center = [], right = [], top = [], middle = [], bottom = [];
- BI.each(regions, function (i, region) {
- var client = self._getRegionClientPosition(region.id);
- if (Math.abs(client.left - position.left) <= 3) {
- left.push(region);
- }
- if (Math.abs(client.left + client.width / 2 - position.left) <= 3) {
- center.push(region);
- }
- if (Math.abs(client.left + client.width - position.left) <= 3) {
- right.push(region);
- }
- if (Math.abs(client.top - position.top) <= 3) {
- top.push(region);
- }
- if (Math.abs(client.top + client.height / 2 - position.top) <= 3) {
- middle.push(region);
- }
- if (Math.abs(client.top + client.height - position.top) <= 3) {
- bottom.push(region);
- }
- });
- return {
- left: left,
- center: center,
- right: right,
- top: top,
- middle: middle,
- bottom: bottom
- }
- },
-
- _getRegionClientPosition: function (name) {
- var region = this.getRegionByName(name);
- var offset = this.arrangement._getScrollOffset();
- return {
- top: region.top - offset.top,
- left: region.left - offset.left,
- width: region.width,
- height: region.height,
- id: region.id
- }
- },
-
- _vAlign: function (position, regions) {
- var self = this;
- var vs = this._positionAt(position, regions);
- var positions = [];
- var l;
- if (vs.left.length > 0) {
- l = this._getRegionClientPosition(vs.left[0].id).left;
- } else if (vs.right.length > 0) {
- var temp = this._getRegionClientPosition(vs.right[0].id);
- l = temp.left + temp.width;
- }
- var rs = vs.left.concat(vs.right);
- BI.each(rs, function (i, region) {
- var p = self._getRegionClientPosition(region.id);
- if (self._isEqual(p.left, l) || self._isEqual(p.left + p.width, l)) {
- var topPoint = {
- top: p.top + p.height / 2,
- left: l
- };
- positions.push({
- id: region.id,
- start: topPoint,
- end: {
- left: l,
- top: position.top
- }
- });
- }
- });
- return positions;
- },
-
- _leftAlign: function (position, size, regions) {
- var self = this;
- return this._vAlign({
- left: position.left,
- top: position.top + size.height / 2
- }, regions);
- },
-
- _rightAlign: function (position, size, regions) {
- var self = this;
- return this._vAlign({
- left: position.left + size.width,
- top: position.top + size.height / 2
- }, regions);
- },
-
- _hAlign: function (position, regions) {
- var self = this;
- var hs = this._positionAt(position, regions);
- var positions = [];
- var t;
- if (hs.top.length > 0) {
- var temp = this._getRegionClientPosition(hs.top[0].id);
- t = temp.top;
- } else if (hs.bottom.length > 0) {
- var temp = this._getRegionClientPosition(hs.bottom[0].id);
- t = temp.top + temp.height;
- }
- var rs = hs.top.concat(hs.bottom);
- BI.each(rs, function (i, region) {
- var p = self._getRegionClientPosition(region.id);
- if (self._isEqual(p.top, t) || self._isEqual(p.top + p.height, t)) {
- var leftPoint = {
- top: t,
- left: p.left + p.width / 2
- };
- positions.push({
- id: p.id,
- start: leftPoint,
- end: {
- left: position.left,
- top: t
- }
- });
- }
- });
- return positions;
- },
-
- _topAlign: function (position, size, regions) {
- var self = this;
- return this._hAlign({
- left: position.left + size.width / 2,
- top: position.top
- }, regions);
- },
-
- _bottomAlign: function (position, size, regions) {
- var self = this;
- return this._hAlign({
- left: position.left + size.width / 2,
- top: position.top + size.height
- }, regions);
- },
-
- _centerAlign: function (position, size, regions) {
- var self = this;
- var cs = this._positionAt({
- left: position.left + size.width / 2,
- top: position.top + size.height / 2
- }, regions);
- var positions = [];
- var l;
- if (cs.center.length > 0) {
- var temp = this._getRegionClientPosition(cs.center[0].id);
- l = temp.left + temp.width / 2;
- }
- BI.each(cs.center, function (i, region) {
- var p = self._getRegionClientPosition(region.id);
- if (self._isEqual(p.left + p.width / 2, l)) {
- var topPoint = {
- top: p.top + p.height / 2,
- left: p.left + p.width / 2
- };
- positions.push({
- id: p.id,
- start: topPoint,
- end: {
- left: l,
- top: position.top + size.height / 2
- }
- });
- }
- });
- return positions;
- },
-
- _middleAlign: function (position, size, regions) {
- var self = this;
- var cs = this._positionAt({
- left: position.left + size.width / 2,
- top: position.top + size.height / 2
- }, regions);
- var positions = [];
- var t;
- if (cs.middle.length > 0) {
- var temp = this._getRegionClientPosition(cs.middle[0].id);
- t = temp.top + temp.height / 2;
- }
- BI.each(cs.middle, function (i, region) {
- var p = self._getRegionClientPosition(region.id);
- if (self._isEqual(p.top + p.height / 2, t)) {
- var topPoint = {
- top: p.top + p.height / 2,
- left: p.left + p.width / 2
- };
- positions.push({
- id: p.id,
- start: topPoint,
- end: {
- left: position.left + size.width / 2,
- top: t
- }
- });
- }
- });
- return positions;
- },
-
-
- _drawOneTag: function (start, end) {
- var s = BI.createWidget({
- type: "bi.icon_button",
- //invisible: true,
- width: 13,
- height: 13,
- cls: "drag-tag-font interactive-arrangement-dragtag-icon"
- });
- var e = BI.createWidget({
- type: "bi.icon_button",
- //invisible: true,
- width: 13,
- height: 13,
- cls: "drag-tag-font interactive-arrangement-dragtag-icon"
- });
- if (this._isEqual(start.left, end.left)) {
- var line = BI.createWidget({
- type: "bi.layout",
- //invisible: true,
- cls: "interactive-arrangement-dragtag-line",
- width: 1,
- height: Math.abs(start.top - end.top)
- });
- } else {
- var line = BI.createWidget({
- type: "bi.layout",
- //invisible: true,
- cls: "interactive-arrangement-dragtag-line",
- height: 1,
- width: Math.abs(start.left - end.left)
- });
- }
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: s,
- left: start.left - 6,
- top: start.top - 7
- }, {
- el: e,
- left: end.left - 6,
- top: end.top - 7
- }, {
- el: line,
- left: Math.min(start.left, end.left),
- top: Math.min(start.top, end.top)
- }]
- });
- this.tags.push(s);
- this.tags.push(e);
- this.tags.push(line);
- },
-
- stopDraw: function () {
- BI.each(this.tags, function (i, w) {
- w.destroy();
- });
- this.tags = [];
- },
-
- _getRegionExcept: function (name, regions) {
- var other = [];
- BI.each(regions || this.getAllRegions(), function (i, region) {
- if (!(name && region.id === name)) {
- other.push(region);
- }
- });
- return other;
- },
-
- getClientWidth: function () {
- return this.arrangement.getClientWidth();
- },
-
- getClientHeight: function () {
- return this.arrangement.getClientHeight();
- },
-
- getPosition: function (name, position, size) {
- var regions = this.getAllRegions();
- var me;
- if (name) {
- me = this._getRegionClientPosition(name);
- }
- var other = this._getRegionExcept(name, regions);
- position = position || {
- left: me.left,
- top: me.top
- };
- size = size || {
- width: me.width,
- height: me.height
- };
- var left = this._leftAlign(position, size, other);
- var right = this._rightAlign(position, size, other);
- var top = this._topAlign(position, size, other, other);
- var bottom = this._bottomAlign(position, size, other);
- var center = this._centerAlign(position, size, other);
- var middle = this._middleAlign(position, size, other);
-
- BI.each(center, function (i, pos) {
- position.left = pos.end.left - size.width / 2;
- });
- BI.each(right, function (i, pos) {
- position.left = pos.end.left - size.width;
- });
- BI.each(left, function (i, pos) {
- position.left = pos.end.left;
- });
- BI.each(middle, function (i, pos) {
- position.top = pos.end.top - size.height / 2;
- });
- BI.each(bottom, function (i, pos) {
- position.top = pos.end.top - size.height;
- });
- BI.each(top, function (i, pos) {
- position.top = pos.end.top;
- });
- return position;
- },
-
- //position不动 变size
- getSize: function (name, position, size) {
- var regions = this.getAllRegions();
- var me;
- if (name) {
- me = this._getRegionClientPosition(name);
- }
- var other = this._getRegionExcept(name, regions);
- position = position || {
- left: me.left,
- top: me.top
- };
- size = size || {
- width: me.width,
- height: me.height
- };
- var left = this._leftAlign(position, size, other);
- var right = this._rightAlign(position, size, other);
- var top = this._topAlign(position, size, other, other);
- var bottom = this._bottomAlign(position, size, other);
- var center = this._centerAlign(position, size, other);
- var middle = this._middleAlign(position, size, other);
-
- BI.each(center, function (i, pos) {
- size.width = (pos.end.left - position.left) * 2;
- });
- BI.each(right, function (i, pos) {
- size.width = pos.end.left - position.left;
- });
- BI.each(left, function (i, pos) {
- });
- BI.each(middle, function (i, pos) {
- size.height = (pos.end.top - position.top) * 2;
- });
- BI.each(bottom, function (i, pos) {
- size.height = pos.end.top - position.top;
- });
- BI.each(top, function (i, pos) {
- });
- return size;
- },
-
- draw: function (position, size, name) {
- var self = this;
- this.stopDraw();
- switch (this.getLayoutType()) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- var other = this._getRegionExcept(name);
- var left = this._leftAlign(position, size, other);
- var right = this._rightAlign(position, size, other);
- var top = this._topAlign(position, size, other);
- var bottom = this._bottomAlign(position, size, other);
- var center = this._centerAlign(position, size, other);
- var middle = this._middleAlign(position, size, other);
-
- BI.each(center, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- BI.each(right, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- BI.each(left, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- BI.each(middle, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- BI.each(bottom, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- BI.each(top, function (i, pos) {
- self._drawOneTag(pos.start, pos.end);
- });
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- break;
- }
- },
-
- addRegion: function (region, position) {
- this.stopDraw();
- return this.arrangement.addRegion(region, position);
- },
-
- deleteRegion: function (name) {
- return this.arrangement.deleteRegion(name);
- },
-
- setRegionSize: function (name, size) {
- size = this.getSize(name, null, size);
- return this.arrangement.setRegionSize(name, size);
- },
-
- setPosition: function (position, size) {
- var self = this;
- this.stopDraw();
- if (position.left > 0 && position.top > 0) {
- switch (this.getLayoutType()) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- position = this.getPosition(null, position, size);
- this.draw(position, size);
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- break;
- }
- }
- var at = this.arrangement.setPosition(position, size);
- return at;
- },
-
- setRegionPosition: function (name, position) {
- if (position.left > 0 && position.top > 0) {
- switch (this.getLayoutType()) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- position = this.getPosition(name, position);
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- break;
- }
- }
- return this.arrangement.setRegionPosition(name, position);
- },
-
- setDropPosition: function (position, size) {
- var self = this;
- this.stopDraw();
- if (position.left > 0 && position.top > 0) {
- switch (this.getLayoutType()) {
- case BI.Arrangement.LAYOUT_TYPE.FREE:
- position = this.getPosition(null, position, size);
- this.draw(position, size);
- break;
- case BI.Arrangement.LAYOUT_TYPE.GRID:
- break;
- }
- }
- var callback = self.arrangement.setDropPosition(position, size);
- return function () {
- callback();
- self.stopDraw();
- }
- },
-
- scrollInterval: function () {
- this.arrangement.scrollInterval.apply(this.arrangement, arguments);
- },
-
- scrollEnd: function () {
- this.arrangement.scrollEnd.apply(this.arrangement, arguments);
- },
-
- scrollTo: function (scroll) {
- this.arrangement.scrollTo(scroll);
- },
-
- zoom: function (ratio) {
- this.arrangement.zoom(ratio);
- },
-
- resize: function () {
- return this.arrangement.resize();
- },
-
- relayout: function () {
- return this.arrangement.relayout();
- },
-
- setLayoutType: function (type) {
- this.arrangement.setLayoutType(type);
- },
-
- getLayoutType: function () {
- return this.arrangement.getLayoutType();
- },
-
- getLayoutRatio: function () {
- return this.arrangement.getLayoutRatio();
- },
-
- getHelper: function () {
- return this.arrangement.getHelper();
- },
-
- getRegionByName: function (name) {
- return this.arrangement.getRegionByName(name);
- },
-
- getAllRegions: function () {
- return this.arrangement.getAllRegions();
- },
-
- revoke: function () {
- return this.arrangement.revoke();
- },
-
- populate: function (items) {
- var self = this;
- this.arrangement.populate(items);
- }
-});
-BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE";
-BI.InteractiveArrangement.EVENT_SCROLL = "InteractiveArrangement.EVENT_SCROLL";
-BI.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/**
- * 月份下拉框
- *
- * Created by GUY on 2015/8/28.
- * @class BI.MonthCombo
- * @extends BI.Trigger
- */
-BI.MonthCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-month-combo",
- behaviors: {},
- height: 25
- });
- },
- _init: function () {
- BI.MonthCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.month_trigger"
- });
-
- this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) {
- if (this.getKey() && this.getKey() !== self.storeValue) {
- self.setValue(this.getValue());
- } else if (!this.getKey()) {
- self.setValue();
- }
- self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
- });
- this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () {
- self.storeValue = this.getKey();
- });
- this.trigger.on(BI.MonthTrigger.EVENT_START, function () {
- self.combo.hideView();
- });
- this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- });
- this.trigger.on(BI.MonthTrigger.EVENT_CHANGE, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- });
-
- this.popup = BI.createWidget({
- type: "bi.month_popup",
- behaviors: o.behaviors
- });
- this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- minWidth: 85,
- el: this.popup
- }
- });
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW);
- });
- },
-
- setValue: function (v) {
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- }
-});
-
-BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.month_combo', BI.MonthCombo);/**
- * 月份展示面板
- *
- * Created by GUY on 2015/9/2.
- * @class BI.MonthPopup
- * @extends BI.Trigger
- */
-BI.MonthPopup = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-month-popup",
- behaviors: {}
- });
- },
-
- _init: function () {
- BI.MonthPopup.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- //纵向排列月
- var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11];
- var items = [];
- items.push(month.slice(0, 2));
- items.push(month.slice(2, 4));
- items.push(month.slice(4, 6));
- items.push(month.slice(6, 8));
- items.push(month.slice(8, 10));
- items.push(month.slice(10, 12));
- items = BI.map(items, function (i, item) {
- return BI.map(item, function (j, td) {
- return {
- type: "bi.text_item",
- cls: "bi-list-item-active",
- textAlign: "center",
- whiteSpace: "nowrap",
- once: false,
- forceSelected: true,
- height: 23,
- width: 38,
- value: td,
- text: td + 1
- };
- });
- });
-
- this.month = BI.createWidget({
- type: "bi.button_group",
- element: this,
- behaviors: o.behaviors,
- items: BI.createItems(items, {}),
- layouts: [BI.LogicFactory.createLogic("table", BI.extend({
- dynamic: true
- }, {
- columns: 2,
- rows: 6,
- columnSize: [1 / 2, 1 / 2],
- rowSize: 25
- })), {
- type: "bi.center_adapt",
- vgap: 1,
- hgap: 2
- }]
- });
-
- this.month.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if (type === BI.Events.CLICK) {
- self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
- }
- })
- },
-
- getValue: function () {
- return this.month.getValue()[0];
- },
-
- setValue: function (v) {
- this.month.setValue([v]);
- }
-});
-BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.month_popup", BI.MonthPopup);/**
- * 月份trigger
- *
- * Created by GUY on 2015/8/21.
- * @class BI.MonthTrigger
- * @extends BI.Trigger
- */
-BI.MonthTrigger = BI.inherit(BI.Trigger, {
- _const: {
- hgap: 4,
- vgap: 2,
- triggerWidth: 25,
- errorText: BI.i18nText("BI-Month_Trigger_Error_Text")
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-month-trigger bi-border",
- height: 25
- });
- },
- _init: function () {
- BI.MonthTrigger.superclass._init.apply(this, arguments);
- var self = this, o = this.options, c = this._const;
- this.editor = BI.createWidget({
- type: "bi.sign_editor",
- height: o.height,
- validationChecker: function (v) {
- return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 12);
- },
- quitChecker: function (v) {
- return false;
- },
- hgap: c.hgap,
- vgap: c.vgap,
- allowBlank: true,
- errorText: c.errorText
- });
- this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
- self.fireEvent(BI.MonthTrigger.EVENT_FOCUS);
- });
- this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
- self.fireEvent(BI.MonthTrigger.EVENT_CHANGE);
- });
- this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
- var value = self.editor.getValue();
- if (BI.isNotNull(value)) {
- self.editor.setValue(value);
- self.editor.setTitle(value);
- }
- self.fireEvent(BI.MonthTrigger.EVENT_CONFIRM);
- });
- this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
- if (self.editor.isValid()) {
- self.editor.blur();
- }
- });
- this.editor.on(BI.SignEditor.EVENT_START, function () {
- self.fireEvent(BI.MonthTrigger.EVENT_START);
- });
- this.editor.on(BI.SignEditor.EVENT_STOP, function () {
- self.fireEvent(BI.MonthTrigger.EVENT_STOP);
- });
- BI.createWidget({
- element: this,
- type: 'bi.htape',
- items: [
- {
- el: this.editor
- }, {
- el: {
- type: "bi.text_button",
- text: BI.i18nText("BI-Multi_Date_Month"),
- baseCls: "bi-trigger-month-text",
- width: c.triggerWidth
- },
- width: c.triggerWidth
- }, {
- el: {
- type: "bi.trigger_icon_button",
- width: c.triggerWidth
- },
- width: c.triggerWidth
- }
- ]
- });
- },
- setValue: function (v) {
- if(BI.isNotNull(v)){
- this.editor.setState(v + 1);
- this.editor.setValue(v + 1);
- this.editor.setTitle(v + 1);
- return;
- }
- this.editor.setState();
- this.editor.setValue();
- this.editor.setTitle();
- },
- getKey: function () {
- return this.editor.getValue() | 0;
- },
- getValue: function () {
- return this.editor.getValue() - 1;
- }
-});
-BI.MonthTrigger.EVENT_FOCUS = "EVENT_FOCUS";
-BI.MonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.MonthTrigger.EVENT_START = "EVENT_START";
-BI.MonthTrigger.EVENT_STOP = "EVENT_STOP";
-BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.month_trigger", BI.MonthTrigger);/**
- * @class BI.MultiLayerSelectTreeCombo
- * @extends BI.Widget
- */
-BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSelectTreeCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer_select_tree-combo",
- isDefaultInit: false,
- height: 30,
- text: "",
- items: []
- });
- },
-
- _init: function () {
- BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.single_tree_trigger",
- text: o.text,
- height: o.height,
- items: o.items
- });
-
- this.popup = BI.createWidget({
- type: "bi.multilayer_select_tree_popup",
- isDefaultInit: o.isDefaultInit,
- items: o.items
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- adjustLength: 2,
- el: this.trigger,
- popup: {
- el: this.popup
- }
- });
-
- this.combo.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE);
- });
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- },
-
- populate: function (items) {
- this.combo.populate(items);
- }
-});
-BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
- * guy
- * 二级树
- * @class BI.MultiLayerSelectLevelTree
- * @extends BI.Select
- */
-BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSelectLevelTree.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer-select-level-tree",
- isDefaultInit: false,
- items: [],
- itemsCreator: BI.emptyFn
- })
- },
-
- _init: function () {
- BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments);
-
- this.initTree(this.options.items);
- },
-
- _formatItems: function (nodes, layer) {
- var self = this;
- BI.each(nodes, function (i, node) {
- var extend = {};
- node.layer = layer;
- if (!BI.isKey(node.id)) {
- node.id = BI.UUID();
- }
- if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
- switch (i) {
- case 0 :
- extend.type = "bi.multilayer_select_tree_first_plus_group_node";
- break;
- case nodes.length - 1 :
- extend.type = "bi.multilayer_select_tree_last_plus_group_node";
- break;
- default :
- extend.type = "bi.multilayer_select_tree_mid_plus_group_node";
- break;
- }
- BI.defaults(node, extend);
-
- self._formatItems(node.children, layer + 1);
- } else {
- switch (i) {
- case nodes.length - 1:
- extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
- break;
- default :
- extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
- }
- BI.defaults(node, extend);
- }
- });
- return nodes;
- },
-
- _assertId: function (sNodes) {
- BI.each(sNodes, function (i, node) {
- node.id = node.id || BI.UUID();
- });
- },
-
- //构造树结构,
- initTree: function (nodes) {
- var self = this, o = this.options;
- this.empty();
- this._assertId(nodes);
- this.tree = BI.createWidget({
- type: "bi.custom_tree",
- element: this,
- expander: {
- type: "bi.select_tree_expander",
- isDefaultInit: o.isDefaultInit,
- el: {},
- popup: {
- type: "bi.custom_tree"
- }
- },
-
- items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
- itemsCreator: o.itemsCreator,
-
- el: {
- type: "bi.button_tree",
- chooseType: BI.Selection.Single,
- layouts: [{
- type: "bi.vertical"
- }]
- }
- });
- this.tree.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if (type === BI.Events.CLICK) {
- self.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, arguments);
- }
- })
- },
-
- populate: function (nodes) {
- this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0));
- },
-
- setValue: function (v) {
- this.tree.setValue(v);
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- getAllLeaves: function () {
- return this.tree.getAllLeaves();
- },
-
- getNodeById: function (id) {
- return this.tree.getNodeById(id);
- },
-
- getNodeByValue: function (id) {
- return this.tree.getNodeByValue(id);
- }
-});
-BI.MultiLayerSelectLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
-
-BI.shortcut("bi.multilayer_select_level_tree", BI.MultiLayerSelectLevelTree);/**
- * Created by GUY on 2016/1/26.
- *
- * @class BI.MultiLayerSelectTreePopup
- * @extends BI.Pane
- */
-
-BI.MultiLayerSelectTreePopup = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer-select-tree-popup",
- tipText: BI.i18nText("BI-No_Selected_Item"),
- isDefaultInit: false,
- itemsCreator: BI.emptyFn,
- items: []
- });
- },
-
- _init: function () {
- BI.MultiLayerSelectTreePopup.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- this.tree = BI.createWidget({
- type: 'bi.multilayer_select_level_tree',
- isDefaultInit: o.isDefaultInit,
- items: o.items,
- itemsCreator: o.itemsCreator
- });
-
- BI.createWidget({
- type: "bi.vertical",
- scrolly: false,
- scrollable: true,
- element: this,
- items: [this.tree]
- });
-
- this.tree.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE);
- });
-
- this.check();
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.tree.setValue(v);
- },
-
- populate: function (items) {
- BI.MultiLayerSelectTreePopup.superclass.populate.apply(this, arguments);
- this.tree.populate(items);
- }
-});
-
-BI.MultiLayerSelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.multilayer_select_tree_popup", BI.MultiLayerSelectTreePopup);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSelectTreeFirstPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active",
- layer: 0,//第几层级
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.select_tree_first_plus_group_node",
- cls: "bi-list-item-none",
- stopPropagation: true,
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.setSelected(self.isSelected());
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- isOnce: function () {
- return true;
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- isSelected: function () {
- return this.node.isSelected();
- },
-
- setSelected: function (b) {
- BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this, arguments);
- this.node.setSelected(b);
- },
-
- doClick: function () {
- BI.NodeButton.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
- this.node.setOpened(v);
- }
-});
-
-BI.shortcut("bi.multilayer_select_tree_first_plus_group_node", BI.MultiLayerSelectTreeFirstPlusGroupNode);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSelectTreeLastPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-select-tree-last-plus-group-node bi-list-item-active",
- layer: 0,//第几层级
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.select_tree_last_plus_group_node",
- cls: "bi-list-item-none",
- stopPropagation: true,
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.setSelected(self.isSelected());
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- isSelected: function () {
- return this.node.isSelected();
- },
-
- setSelected: function (b) {
- BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this, arguments);
- this.node.setSelected(b);
- },
-
- doClick: function () {
- BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
- this.node.setOpened(v);
- }
-});
-
-BI.shortcut("bi.multilayer_select_tree_last_plus_group_node", BI.MultiLayerSelectTreeLastPlusGroupNode);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSelectTreeMidPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active",
- layer: 0,//第几层级
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.select_tree_mid_plus_group_node",
- cls: "bi-list-item-none",
- stopPropagation: true,
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.setSelected(self.isSelected());
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- isSelected: function () {
- return this.node.isSelected();
- },
-
- setSelected: function (b) {
- BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this, arguments);
- this.node.setSelected(b);
- },
-
- doClick: function () {
- BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
- this.node.setOpened(v);
- }
-});
-
-BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node", BI.MultiLayerSelectTreeMidPlusGroupNode);/**
- * 多层级下拉单选树
- * Created by GUY on 2016/1/26.
- *
- * @class BI.MultiLayerSingleTreeCombo
- * @extends BI.Widget
- */
-BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer-singletree-combo",
- isDefaultInit: false,
- height: 30,
- text: "",
- itemsCreator: BI.emptyFn,
- items: []
- });
- },
-
- _init: function () {
- BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.single_tree_trigger",
- text: o.text,
- height: o.height,
- items: o.items
- });
-
- this.popup = BI.createWidget({
- type: "bi.multilayer_single_tree_popup",
- isDefaultInit: o.isDefaultInit,
- items: o.items
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- adjustLength: 2,
- el: this.trigger,
- popup: {
- el: this.popup
- }
- });
-
- this.combo.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE);
- });
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- },
-
- populate: function (items) {
- this.combo.populate(items);
- }
-});
-
-BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
- * guy
- * 二级树
- * @class BI.MultiLayerSingleLevelTree
- * @extends BI.Single
- */
-BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleLevelTree.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer-single-level-tree",
- isDefaultInit: false,
- items: [],
- itemsCreator: BI.emptyFn
- })
- },
-
- _init: function () {
- BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments);
-
- this.initTree(this.options.items);
- },
-
- _formatItems: function (nodes, layer) {
- var self = this;
- BI.each(nodes, function (i, node) {
- var extend = {};
- node.layer = layer;
- if (!BI.isKey(node.id)) {
- node.id = BI.UUID();
- }
- if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
- switch (i) {
- case 0 :
- extend.type = "bi.multilayer_single_tree_first_plus_group_node";
- break;
- case nodes.length - 1 :
- extend.type = "bi.multilayer_single_tree_last_plus_group_node";
- break;
- default :
- extend.type = "bi.multilayer_single_tree_mid_plus_group_node";
- break;
- }
- BI.defaults(node, extend);
-
- self._formatItems(node.children, layer + 1);
- } else {
- switch (i) {
- case nodes.length - 1:
- extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
- break;
- default :
- extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
- }
- BI.defaults(node, extend);
- }
- });
- return nodes;
- },
-
- _assertId: function (sNodes) {
- BI.each(sNodes, function (i, node) {
- node.id = node.id || BI.UUID();
- });
- },
-
- //构造树结构,
- initTree: function (nodes) {
- var self = this, o = this.options;
- this.empty();
- this._assertId(nodes);
- this.tree = BI.createWidget({
- type: "bi.custom_tree",
- element: this,
- expander: {
- isDefaultInit: o.isDefaultInit,
- el: {},
- popup: {
- type: "bi.custom_tree"
- }
- },
-
- items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
- itemsCreator: function (op, callback) {
- o.itemsCreator(op, function (items) {
- callback(BI.Tree.transformToTreeFormat(items), 0)
- })
- },
-
- el: {
- type: "bi.button_tree",
- chooseType: BI.Selection.Single,
- layouts: [{
- type: "bi.vertical"
- }]
- }
- });
- this.tree.on(BI.Controller.EVENT_CHANGE, function (type, v) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if (type === BI.Events.CLICK) {
- self.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, v);
- }
- })
- },
-
- populate: function (nodes) {
- this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0));
- },
-
- setValue: function (v) {
- this.tree.setValue(v);
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- getAllLeaves: function () {
- return this.tree.getAllLeaves();
- },
-
- getNodeById: function (id) {
- return this.tree.getNodeById(id);
- },
-
- getNodeByValue: function (id) {
- return this.tree.getNodeByValue(id);
- }
-});
-BI.MultiLayerSingleLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
-
-BI.shortcut("bi.multilayer_single_level_tree", BI.MultiLayerSingleLevelTree);
-/**
- * Created by GUY on 2016/1/26.
- *
- * @class BI.MultiLayerSingleTreePopup
- * @extends BI.Pane
- */
-
-BI.MultiLayerSingleTreePopup = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multilayer-singletree-popup",
- tipText: BI.i18nText("BI-No_Selected_Item"),
- isDefaultInit: false,
- itemsCreator: BI.emptyFn,
- items: []
- });
- },
-
- _init: function () {
- BI.MultiLayerSingleTreePopup.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- this.tree = BI.createWidget({
- type: 'bi.multilayer_single_level_tree',
- isDefaultInit: o.isDefaultInit,
- items: o.items,
- itemsCreator: o.itemsCreator
- });
-
- BI.createWidget({
- type: "bi.vertical",
- scrolly: false,
- scrollable: true,
- element: this,
- items: [this.tree]
- });
-
- this.tree.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE);
- });
-
- this.check();
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.tree.setValue(v);
- },
-
- populate: function (items) {
- BI.MultiLayerSingleTreePopup.superclass.populate.apply(this, arguments);
- this.tree.populate(items);
- }
-});
-
-BI.MultiLayerSingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.multilayer_single_tree_popup", BI.MultiLayerSingleTreePopup);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeFirstPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSingleTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-single-tree-first-plus-group-node bi-list-item",
- layer: 0,//第几层级
- id: "",
- pId: "",
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.first_plus_group_node",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.node)) {
- this.node.setOpened(v);
- }
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_first_plus_group_node", BI.MultiLayerSingleTreeFirstPlusGroupNode);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeLastPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSingleTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-single-tree-last-plus-group-node bi-list-item",
- layer: 0,//第几层级
- id: "",
- pId: "",
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.last_plus_group_node",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.node)) {
- this.node.setOpened(v);
- }
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_last_plus_group_node", BI.MultiLayerSingleTreeLastPlusGroupNode);/**
- * 加号表示的组节点
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeMidPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.MultiLayerSingleTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- extraCls: "bi-multilayer-single-tree-mid-plus-group-node bi-list-item",
- layer: 0,//第几层级
- id: "",
- pId: "",
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.node = BI.createWidget({
- type: "bi.mid_plus_group_node",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- open: o.open,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.node);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.node.doRedMark.apply(this.node, arguments);
- },
-
- unRedMark: function () {
- this.node.unRedMark.apply(this.node, arguments);
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments);
- this.node.setSelected(this.isSelected());
- },
-
- setOpened: function (v) {
- BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.node)) {
- this.node.setOpened(v);
- }
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/**
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeFirstTreeLeafItem
- * @extends BI.BasicButton
- */
-BI.MultiLayerSingleTreeFirstTreeLeafItem = BI.inherit(BI.BasicButton, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-multilayer-single-tree-first-tree-leaf-item bi-list-item-active",
- logic: {
- dynamic: false
- },
- layer: 0,
- id: "",
- pId: "",
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.item = BI.createWidget({
- type: "bi.first_tree_leaf_item",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.item);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.item.doRedMark.apply(this.item, arguments);
- },
-
- unRedMark: function () {
- this.item.unRedMark.apply(this.item, arguments);
- },
-
- doHighLight: function () {
- this.item.doHighLight.apply(this.item, arguments);
- },
-
- unHighLight: function () {
- this.item.unHighLight.apply(this.item, arguments);
- },
-
- getId: function () {
- return this.options.id;
- },
-
- getPId: function () {
- return this.options.pId;
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this, arguments);
- this.item.setSelected(this.isSelected());
- },
-
- setSelected: function (v) {
- BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this, arguments);
- this.item.setSelected(v);
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item", BI.MultiLayerSingleTreeFirstTreeLeafItem);/**
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeLastTreeLeafItem
- * @extends BI.BasicButton
- */
-BI.MultiLayerSingleTreeLastTreeLeafItem = BI.inherit(BI.BasicButton, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-multilayer-single-tree-last-tree-leaf-item bi-list-item-active",
- logic: {
- dynamic: false
- },
- layer: 0,
- id: "",
- pId: "",
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.item = BI.createWidget({
- type: "bi.last_tree_leaf_item",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.item);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.item.doRedMark.apply(this.item, arguments);
- },
-
- unRedMark: function () {
- this.item.unRedMark.apply(this.item, arguments);
- },
-
- doHighLight: function () {
- this.item.doHighLight.apply(this.item, arguments);
- },
-
- unHighLight: function () {
- this.item.unHighLight.apply(this.item, arguments);
- },
-
- getId: function () {
- return this.options.id;
- },
-
- getPId: function () {
- return this.options.pId;
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this, arguments);
- this.item.setSelected(this.isSelected());
- },
-
- setSelected: function (v) {
- BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this, arguments);
- this.item.setSelected(v);
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item", BI.MultiLayerSingleTreeLastTreeLeafItem);/**
- *
- * Created by GUY on 2016/1/27.
- * @class BI.MultiLayerSingleTreeMidTreeLeafItem
- * @extends BI.BasicButton
- */
-BI.MultiLayerSingleTreeMidTreeLeafItem = BI.inherit(BI.BasicButton, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-multilayer-single-tree-mid-tree-leaf-item bi-list-item-active",
- logic: {
- dynamic: false
- },
- layer: 0,
- id: "",
- pId: "",
- height: 25
- })
- },
- _init: function () {
- BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.item = BI.createWidget({
- type: "bi.mid_tree_leaf_item",
- cls: "bi-list-item-none",
- logic: {
- dynamic: true
- },
- id: o.id,
- pId: o.pId,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {//本身实现click功能
- return;
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- var items = [];
- BI.count(0, o.layer, function () {
- items.push({
- type: "bi.layout",
- cls: "base-line-conn-background",
- width: 13,
- height: o.height
- })
- });
- items.push(this.item);
- BI.createWidget({
- type: "bi.td",
- element: this,
- columnSize: BI.makeArray(o.layer, 13),
- items: [items]
- })
- },
-
- doRedMark: function () {
- this.item.doRedMark.apply(this.item, arguments);
- },
-
- unRedMark: function () {
- this.item.unRedMark.apply(this.item, arguments);
- },
-
- doHighLight: function () {
- this.item.doHighLight.apply(this.item, arguments);
- },
-
- unHighLight: function () {
- this.item.unHighLight.apply(this.item, arguments);
- },
-
- getId: function () {
- return this.options.id;
- },
-
- getPId: function () {
- return this.options.pId;
- },
-
- doClick: function () {
- BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this, arguments);
- this.item.setSelected(this.isSelected());
- },
-
- setSelected: function (v) {
- BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this, arguments);
- this.item.setSelected(v);
- }
-});
-
-BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item", BI.MultiLayerSingleTreeMidTreeLeafItem);/**
- *
- * @class BI.MultiSelectCheckPane
- * @extends BI.Widget
- */
-BI.MultiSelectCheckPane = BI.inherit(BI.Widget, {
-
- constants: {
- height: 25,
- lgap: 10,
- tgap: 5
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-select-check-pane bi-background",
- items: [],
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- onClickContinueSelect: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiSelectCheckPane.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
-
- this.storeValue = {};
- this.display = BI.createWidget({
- type: 'bi.display_selected_list',
- items: opts.items,
- itemsCreator: function (op, callback) {
- op = BI.extend(op || {}, {
- selectedValues: self.storeValue.value
- });
- if (self.storeValue.type === BI.Selection.Multi) {
- callback({
- items: BI.map(self.storeValue.value, function (i, v) {
- var txt = opts.valueFormatter(v) || v;
- return {
- text: txt,
- value: v,
- title: txt
- }
- })
- });
- return;
- }
- opts.itemsCreator(op, callback);
- }
- });
-
- this.continueSelect = BI.createWidget({
- type: 'bi.text_button',
- text: BI.i18nText('BI-Continue_Select'),
- cls: 'multi-select-check-selected bi-high-light'
- });
-
- this.continueSelect.on(BI.TextButton.EVENT_CHANGE, function () {
- opts.onClickContinueSelect();
- });
-
- BI.createWidget({
- type: 'bi.vtape',
- element: this,
- items: [{
- height: this.constants.height,
- el: {
- type: 'bi.left',
- cls: 'multi-select-continue-select',
- items: [
- {
- el: {
- type: "bi.label",
- text: BI.i18nText('BI-Selected_Data')
- },
- lgap: this.constants.lgap,
- tgap: this.constants.tgap
- },
- {
- el: this.continueSelect,
- lgap: this.constants.lgap,
- tgap: this.constants.tgap
- }]
- }
- }, {
- height: 'fill',
- el: this.display
- }]
- });
- },
-
- setValue: function (v) {
- this.storeValue = v || {};
- },
-
- empty: function () {
- this.display.empty();
- },
-
- populate: function () {
- this.display.populate.apply(this.display, arguments);
- }
-});
-
-BI.shortcut("bi.multi_select_check_pane", BI.MultiSelectCheckPane);/**
- *
- *
- * 查看已选弹出层的展示面板
- * @class BI.DisplaySelectedList
- * @extends BI.Widget
- */
-BI.DisplaySelectedList = BI.inherit(BI.Pane, {
-
- constants: {
- height: 25,
- lgap: 10
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-display-list",
- itemsCreator: BI.emptyFn,
- items: []
- });
- },
-
- _init: function () {
- BI.DisplaySelectedList.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
-
- this.hasNext = false;
-
- this.button_group = BI.createWidget({
- type: "bi.list_pane",
- element: this,
- el: {
- type: "bi.loader",
- isDefaultInit: false,
- logic: {
- dynamic: true,
- scrolly: true
- },
- items: this._createItems(opts.items),
- chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
- layouts: [{
- type: "bi.vertical",
- lgap: 10
- }]
- },
- itemsCreator: function (options, callback) {
-
- opts.itemsCreator(options, function (ob) {
- self.hasNext = !!ob.hasNext;
- callback(self._createItems(ob.items));
- })
- },
- hasNext: function () {
- return self.hasNext;
- }
- });
- },
-
- _createItems: function (items) {
- return BI.createItems(items, {
- type: 'bi.icon_text_item',
- cls: 'cursor-default check-font display-list-item bi-tips',
- once: true,
- invalid: true,
- selected: true,
- height: this.constants.height,
- logic: {
- dynamic: true
- }
- });
- },
-
- empty: function () {
- this.button_group.empty();
- },
-
- populate: function (items) {
- if (arguments.length === 0) {
- this.button_group.populate();
- } else {
- this.button_group.populate(this._createItems(items));
- }
- }
-});
-
-BI.shortcut('bi.display_selected_list', BI.DisplaySelectedList);/**
- *
- * @class BI.MultiSelectCombo
- * @extends BI.Single
- */
-BI.MultiSelectCombo = BI.inherit(BI.Single, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-combo',
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- height: 28
- });
- },
-
- _init: function () {
- BI.MultiSelectCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- var assertShowValue = function () {
- BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
- self.trigger.getSearcher().setState(self.storeValue);
- self.trigger.getCounter().setButtonChecked(self.storeValue);
- };
- this.storeValue = {};
-
- this.trigger = BI.createWidget({
- type: "bi.multi_select_trigger",
- height: o.height,
- // adapter: this.popup,
- masker: {
- offset: {
- left: 1,
- top: 1,
- right: 2,
- bottom: 33
- }
- },
- valueFormatter: o.valueFormatter,
- itemsCreator: function (op, callback) {
- o.itemsCreator(op, function (res) {
- if (op.times === 1 && BI.isNotNull(op.keywords)) {
- //预防trigger内部把当前的storeValue改掉
- self.trigger.setValue(BI.deepClone(self.getValue()));
- }
- callback.apply(self, arguments);
- });
- }
- });
-
- this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
- self._setStartValue("");
- this.getSearcher().setValue(self.storeValue);
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
- self._setStartValue("");
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
- if (this.getSearcher().hasMatched()) {
- var keyword = this.getSearcher().getKeyword();
- self._join({
- type: BI.Selection.Multi,
- value: [keyword]
- }, function () {
- self.combo.setValue(self.storeValue);
- self._setStartValue(keyword);
- assertShowValue();
- self.populate();
- self._setStartValue("");
- })
- }
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
- var last = BI.last(keywords);
- keywords = BI.initial(keywords || []);
- if (keywords.length > 0) {
- self._joinKeywords(keywords, function () {
- if (BI.isEndWithBlank(last)) {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- self.combo.populate();
- self._setStartValue("");
- } else {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- }
- });
- }
- });
-
- this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
- if (obj instanceof BI.MultiSelectBar) {
- self._joinAll(this.getValue(), function () {
- assertShowValue();
- });
- } else {
- self._join(this.getValue(), function () {
- assertShowValue();
- });
- }
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
- this.getCounter().setValue(self.storeValue);
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- toggle: false,
- el: this.trigger,
- adjustLength: 1,
- popup: {
- type: 'bi.multi_select_popup_view',
- ref: function () {
- self.popup = this;
- self.trigger.setAdapter(this);
- },
- listeners: [{
- eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
- action: function () {
- self.storeValue = this.getValue();
- self._adjust(function () {
- assertShowValue();
- });
- }
- }, {
- eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,
- action: function () {
- self._defaultState();
- }
- }, {
- eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,
- action: function () {
- self.setValue();
- self._defaultState();
- }
- }],
- itemsCreator: o.itemsCreator,
- valueFormatter: o.valueFormatter,
- onLoaded: function () {
- BI.nextTick(function () {
- self.combo.adjustWidth();
- self.combo.adjustHeight();
- self.trigger.getCounter().adjustView();
- self.trigger.getSearcher().adjustView();
- });
- }
- },
- hideChecker: function (e) {
- return triggerBtn.element.find(e.target).length === 0;
- }
- });
-
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- this.setValue(self.storeValue);
- BI.nextTick(function () {
- self.populate();
- });
- });
- this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
- //important:关闭弹出时又可能没有退出编辑状态
- self.trigger.stopEditing();
- self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
- });
-
- var triggerBtn = BI.createWidget({
- type: "bi.trigger_icon_button",
- width: o.height,
- height: o.height,
- cls: "multi-select-trigger-icon-button bi-border-left"
- });
- triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
- self.trigger.getCounter().hideView();
- if (self.combo.isViewVisible()) {
- self.combo.hideView();
- } else {
- self.combo.showView();
- }
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.combo,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- }, {
- el: triggerBtn,
- right: 0,
- top: 0,
- bottom: 0
- }]
- })
- },
-
- _defaultState: function () {
- this.trigger.stopEditing();
- this.combo.hideView();
- },
-
- _assertValue: function (val) {
- val || (val = {});
- val.type || (val.type = BI.Selection.Multi);
- val.value || (val.value = []);
- },
-
- _makeMap: function (values) {
- return BI.makeObject(values || []);
- },
-
- _joinKeywords: function (keywords, callback) {
- var self = this, o = this.options;
- this._assertValue(this.storeValue);
- o.itemsCreator({
- type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
- keywords: keywords
- }, function (ob) {
- var values = BI.pluck(ob.items, "value");
- digest(values);
- });
-
- function digest(items) {
- var selectedMap = self._makeMap(items);
- BI.each(keywords, function (i, val) {
- if (BI.isNotNull(selectedMap[val])) {
- self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
- }
- });
- self._adjust(callback);
- }
- },
-
- _joinAll: function (res, callback) {
- var self = this, o = this.options;
- this._assertValue(res);
- o.itemsCreator({
- type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
- keywords: [this.trigger.getKey()]
- }, function (ob) {
- var items = BI.pluck(ob.items, "value");
- if (self.storeValue.type === res.type) {
- var change = false;
- var map = self._makeMap(self.storeValue.value);
- BI.each(items, function (i, v) {
- if (BI.isNotNull(map[v])) {
- change = true;
- delete map[v];
- }
- });
- change && (self.storeValue.value = BI.values(map));
- self._adjust(callback);
- return;
- }
- var selectedMap = self._makeMap(self.storeValue.value);
- var notSelectedMap = self._makeMap(res.value);
- var newItems = [];
- BI.each(items, function (i, item) {
- if (BI.isNotNull(selectedMap[items[i]])) {
- delete selectedMap[items[i]];
- }
- if (BI.isNull(notSelectedMap[items[i]])) {
- newItems.push(item);
- }
- });
- self.storeValue.value = newItems.concat(BI.values(selectedMap));
- self._adjust(callback);
- })
- },
-
- _adjust: function (callback) {
- var self = this, o = this.options;
- if (!this._count) {
- o.itemsCreator({
- type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
- }, function (res) {
- self._count = res.count;
- adjust();
- callback();
- });
- } else {
- adjust();
- callback();
- }
- function adjust() {
- if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
- self.storeValue = {
- type: BI.Selection.Multi,
- value: []
- }
- } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
- self.storeValue = {
- type: BI.Selection.All,
- value: []
- }
- }
- }
- },
-
- _join: function (res, callback) {
- var self = this, o = this.options;
- this._assertValue(res);
- this._assertValue(this.storeValue);
- if (this.storeValue.type === res.type) {
- var map = this._makeMap(this.storeValue.value);
- BI.each(res.value, function (i, v) {
- if (!map[v]) {
- self.storeValue.value.push(v);
- map[v] = v;
- }
- });
- var change = false;
- BI.each(res.assist, function (i, v) {
- if (BI.isNotNull(map[v])) {
- change = true;
- delete map[v];
- }
- });
- change && (this.storeValue.value = BI.values(map));
- self._adjust(callback);
- return;
- }
- this._joinAll(res, callback);
- },
-
- _setStartValue: function (value) {
- this._startValue = value;
- this.popup.setStartValue(value);
- },
-
- setValue: function (v) {
- this.storeValue = v || {};
- this._assertValue(this.storeValue);
- this.combo.setValue(this.storeValue);
- },
-
- getValue: function () {
- return this.storeValue;
- },
-
- populate: function () {
- this._count = null;
- this.combo.populate.apply(this.combo, arguments);
- }
-});
-
-BI.extend(BI.MultiSelectCombo, {
- REQ_GET_DATA_LENGTH: 0,
- REQ_GET_ALL_DATA: -1
-});
-
-BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-
-BI.shortcut('bi.multi_select_combo', BI.MultiSelectCombo);/**
- * 多选加载数据面板
- * Created by guy on 15/11/2.
- * @class BI.MultiSelectLoader
- * @extends Widget
- */
-BI.MultiSelectLoader = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectLoader.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-loader',
- logic: {
- dynamic: true
- },
- el: {
- height: 400
- },
- valueFormatter: BI.emptyFn,
- itemsCreator: BI.emptyFn,
- onLoaded: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiSelectLoader.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
- var hasNext = false;
-
- this.button_group = BI.createWidget({
- type: "bi.select_list",
- element: this,
- logic: opts.logic,
- el: BI.extend({
- onLoaded: opts.onLoaded,
- el: {
- type: "bi.loader",
- isDefaultInit: false,
- logic: {
- dynamic: true,
- scrolly: true
- },
- el: {
- chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
- behaviors: {
- redmark: function () {
- return true;
- }
- },
- layouts: [{
- type: "bi.vertical"
- }]
- }
- }
- }, opts.el),
- itemsCreator: function (op, callback) {
- var startValue = self._startValue;
- self.storeValue && (op = BI.extend(op || {}, {
- selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi
- ? self.storeValue.value.concat(startValue) : self.storeValue.value
- }));
- opts.itemsCreator(op, function (ob) {
- hasNext = ob.hasNext;
- var firstItems = [];
- if (op.times === 1 && self.storeValue) {
- var json = BI.map(self.storeValue.value, function (i, v) {
- var txt = opts.valueFormatter(v) || v;
- return {
- text: txt,
- value: v,
- title: txt,
- selected: self.storeValue.type === BI.Selection.Multi
- }
- });
- if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) {
- var txt = opts.valueFormatter(startValue) || startValue;
- json.unshift({
- text: txt,
- value: startValue,
- title: txt,
- selected: true
- })
- }
- firstItems = self._createItems(json);
- }
- callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
- if (op.times === 1 && self.storeValue) {
- BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue);
- self.setValue(self.storeValue);
- }
- (op.times === 1) && self._scrollToTop();
- });
- },
- hasNext: function () {
- return hasNext;
- }
- });
- this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE, arguments);
- });
- },
-
- _createItems: function (items) {
- return BI.createItems(items, {
- type: "bi.multi_select_item",
- logic: this.options.logic,
- height: 25,
- selected: this.isAllSelected()
- })
- },
-
- _scrollToTop: function () {
- var self = this;
- BI.delay(function () {
- self.button_group.element.scrollTop(0);
- }, 30);
- },
-
- isAllSelected: function () {
- return this.button_group.isAllSelected();
- },
-
- _assertValue: function (val) {
- val || (val = {});
- val.type || (val.type = BI.Selection.Multi);
- val.value || (val.value = []);
- },
-
- setStartValue: function (v) {
- this._startValue = v;
- },
-
- setValue: function (v) {
- this.storeValue = v || {};
- this._assertValue(this.storeValue);
- this.button_group.setValue(this.storeValue);
- },
-
- getValue: function () {
- return this.button_group.getValue();
- },
-
- getAllButtons: function () {
- return this.button_group.getAllButtons();
- },
-
- empty: function () {
- this.button_group.empty();
- },
-
- populate: function (items) {
- this.button_group.populate.apply(this.button_group, arguments);
- },
-
- resetHeight: function (h) {
- this.button_group.resetHeight(h);
- },
-
- resetWidth: function (w) {
- this.button_group.resetWidth(w);
- }
-});
-
-BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.multi_select_loader', BI.MultiSelectLoader);/**
- * 带加载的多选下拉面板
- * @class BI.MultiSelectPopupView
- * @extends Widget
- */
-BI.MultiSelectPopupView = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-popup-view',
- maxWidth: 'auto',
- minWidth: 135,
- maxHeight: 400,
- valueFormatter: BI.emptyFn,
- itemsCreator: BI.emptyFn,
- onLoaded: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiSelectPopupView.superclass._init.apply(this, arguments);
- var self = this, opts = this.options;
-
- this.loader = BI.createWidget({
- type: "bi.multi_select_loader",
- itemsCreator: opts.itemsCreator,
- valueFormatter: opts.valueFormatter,
- onLoaded: opts.onLoaded
- });
-
- this.popupView = BI.createWidget({
- type: "bi.multi_popup_view",
- stopPropagation: false,
- maxWidth: opts.maxWidth,
- minWidth: opts.minWidth,
- maxHeight: opts.maxHeight,
- element: this,
- buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')],
- el: this.loader
- });
-
- this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE);
- });
- this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
- switch (index) {
- case 0:
- self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR);
- break;
- case 1:
- self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM);
- break;
- }
- });
- },
-
- isAllSelected: function () {
- return this.loader.isAllSelected();
- },
-
- setStartValue: function (v) {
- this.loader.setStartValue(v);
- },
-
- setValue: function (v) {
- this.popupView.setValue(v);
- },
-
- getValue: function () {
- return this.popupView.getValue();
- },
-
- populate: function (items) {
- this.popupView.populate.apply(this.popupView, arguments);
- },
-
- resetHeight: function (h) {
- this.popupView.resetHeight(h);
- },
-
- resetWidth: function (w) {
- this.popupView.resetWidth(w);
- }
-});
-
-BI.MultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE";
-BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
-BI.MultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
-
-
-BI.shortcut('bi.multi_select_popup_view', BI.MultiSelectPopupView);/**
- *
- * 复选下拉框
- * @class BI.MultiSelectTrigger
- * @extends BI.Trigger
- */
-
-BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
-
- constants: {
- height: 14,
- rgap: 4,
- lgap: 4
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-select-trigger bi-border",
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- searcher: {},
- switcher: {},
-
- adapter: null,
- masker: {}
- });
- },
-
- _init: function () {
- BI.MultiSelectTrigger.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
- if (o.height) {
- this.setHeight(o.height - 2);
- }
-
- this.searcher = BI.createWidget(o.searcher, {
- type: "bi.multi_select_searcher",
- height: o.height,
- itemsCreator: o.itemsCreator,
- valueFormatter: o.valueFormatter,
- popup: {},
- adapter: o.adapter,
- masker: o.masker
- });
- this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_START);
- });
- this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE);
- });
- this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING, arguments);
- });
- this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_STOP);
- });
- this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE, arguments);
- });
- this.numberCounter = BI.createWidget(o.switcher, {
- type: 'bi.multi_select_check_selected_switcher',
- valueFormatter: o.valueFormatter,
- itemsCreator: o.itemsCreator,
- adapter: o.adapter,
- masker: o.masker
- });
- this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK);
- });
- this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
- });
-
- var wrapNumberCounter = BI.createWidget({
- type: 'bi.right_vertical_adapt',
- hgap: 4,
- items: [{
- el: this.numberCounter
- }]
- });
-
- var wrapper = BI.createWidget({
- type: 'bi.htape',
- element: this,
- items: [
- {
- el: this.searcher,
- width: 'fill'
- }, {
- el: wrapNumberCounter,
- width: 0
- }, {
- el: BI.createWidget(),
- width: 30
- }]
- });
-
- this.numberCounter.on(BI.Events.VIEW, function (b) {
- BI.nextTick(function () {//自动调整宽度
- wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
- wrapper.resize();
- });
- });
-
- this.element.click(function (e) {
- if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) {
- self.numberCounter.hideView();
- }
- });
- },
-
- getCounter: function () {
- return this.numberCounter;
- },
-
- getSearcher: function () {
- return this.searcher;
- },
-
- stopEditing: function () {
- this.searcher.stopSearch();
- this.numberCounter.hideView();
- },
-
- setAdapter: function (adapter) {
- this.searcher.setAdapter(adapter);
- this.numberCounter.setAdapter(adapter);
- },
-
- setValue: function (ob) {
- this.searcher.setValue(ob);
- this.numberCounter.setValue(ob);
- },
-
- getKey: function () {
- return this.searcher.getKey();
- },
-
- getValue: function () {
- return this.searcher.getValue();
- }
-});
-
-BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
-BI.MultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
-BI.MultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE";
-BI.MultiSelectTrigger.EVENT_START = "EVENT_START";
-BI.MultiSelectTrigger.EVENT_STOP = "EVENT_STOP";
-BI.MultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE";
-BI.MultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
-
-BI.shortcut('bi.multi_select_trigger', BI.MultiSelectTrigger);/**
- * 多选加载数据搜索loader面板
- * Created by guy on 15/11/4.
- * @class BI.MultiSelectSearchLoader
- * @extends Widget
- */
-BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-search-loader',
- itemsCreator: BI.emptyFn,
- keywordGetter: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- });
- },
-
- _init: function () {
- BI.MultiSelectSearchLoader.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
- var hasNext = false;
-
- this.button_group = BI.createWidget({
- type: "bi.select_list",
- element: this,
- logic: {
- dynamic: false
- },
- el: {
- tipText: BI.i18nText("BI-No_Select"),
- el: {
- type: "bi.loader",
- isDefaultInit: false,
- logic: {
- dynamic: true,
- scrolly: true
- },
- el: {
- chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
- behaviors: {
- redmark: function () {
- return true;
- }
- },
- layouts: [{
- type: "bi.vertical"
- }]
- }
- }
- },
- itemsCreator: function (op, callback) {
- self.storeValue && (op = BI.extend(op || {}, {
- selectedValues: self.storeValue.value
- }));
- opts.itemsCreator(op, function (ob) {
- var keyword = ob.keyword = opts.keywordGetter();
- hasNext = ob.hasNext;
- var firstItems = [];
- if (op.times === 1 && self.storeValue) {
- var json = self._filterValues(self.storeValue);
- firstItems = self._createItems(json);
- }
- callback(firstItems.concat(self._createItems(ob.items)), keyword);
- if (op.times === 1 && self.storeValue) {
- self.setValue(self.storeValue);
- }
- });
- },
- hasNext: function () {
- return hasNext;
- }
- });
- this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE, arguments);
- });
- },
-
- _createItems: function (items) {
- return BI.createItems(items, {
- type: "bi.multi_select_item",
- logic: {
- dynamic: false
- },
- height: 25,
- selected: this.isAllSelected()
- })
- },
-
- isAllSelected: function () {
- return this.button_group.isAllSelected();
- },
-
- _filterValues: function (src) {
- var o = this.options;
- var keyword = o.keywordGetter();
- var values = BI.deepClone(src.value) || [];
- var newValues = BI.map(values, function (i, v) {
- return {
- text: o.valueFormatter(v) || v,
- value: v
- };
- });
- if (BI.isKey(keyword)) {
- var search = BI.Func.getSearchResult(newValues, keyword);
- values = search.matched.concat(search.finded);
- }
- return BI.map(values, function (i, v) {
- return {
- text: v.text,
- title: v.text,
- value: v.value,
- selected: src.type === BI.Selection.All
- }
- })
- },
-
- setValue: function (v) {
- //暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
- this.storeValue = BI.deepClone(v);
- this.button_group.setValue(v);
- },
-
- getValue: function () {
- return this.button_group.getValue();
- },
-
- getAllButtons: function () {
- return this.button_group.getAllButtons();
- },
-
- empty: function () {
- this.button_group.empty();
- },
-
- populate: function (items) {
- this.button_group.populate.apply(this.button_group, arguments);
- },
-
- resetHeight: function (h) {
- this.button_group.resetHeight(h);
- },
-
- resetWidth: function (w) {
- this.button_group.resetWidth(w);
- }
-});
-
-BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.multi_select_search_loader', BI.MultiSelectSearchLoader);/**
- *
- * 在搜索框中输入文本弹出的面板
- * @class BI.MultiSelectSearchPane
- * @extends Widget
- */
-
-BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
-
- constants: {
- height: 25,
- lgap: 10,
- tgap: 5
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-select-search-pane bi-card",
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- keywordGetter: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiSelectSearchPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.tooltipClick = BI.createWidget({
- type: "bi.label",
- invisible: true,
- text: BI.i18nText('BI-Click_Blank_To_Select'),
- cls: 'multi-select-toolbar',
- height: this.constants.height
- });
-
- this.loader = BI.createWidget({
- type: "bi.multi_select_search_loader",
- keywordGetter: o.keywordGetter,
- valueFormatter: o.valueFormatter,
- itemsCreator: function (op, callback) {
- o.itemsCreator.apply(self, [op, function (res) {
- callback(res);
- self.setKeyword(o.keywordGetter());
- }]);
- }
- });
- this.loader.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.resizer = BI.createWidget({
- type: "bi.vtape",
- element: this,
- items: [{
- el: this.tooltipClick,
- height: 0
- }, {
- el: this.loader
- }]
- });
- this.tooltipClick.setVisible(false);
- },
-
- setKeyword: function (keyword) {
- var btn;
- var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue());
- if (isVisible !== this.tooltipClick.isVisible()) {
- this.tooltipClick.setVisible(isVisible);
- this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0);
- this.resizer.resize();
- }
- },
-
- isAllSelected: function () {
- return this.loader.isAllSelected();
- },
-
- hasMatched: function () {
- return this.tooltipClick.isVisible();
- },
-
- setValue: function (v) {
- this.loader.setValue(v);
- },
-
- getValue: function () {
- return this.loader.getValue();
- },
-
- empty: function () {
- this.loader.empty();
- },
-
- populate: function (items) {
- this.loader.populate.apply(this.loader, arguments);
- }
-});
-
-BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
-
-BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);/**
- * 查看已选按钮
- * Created by guy on 15/11/3.
- * @class BI.MultiSelectCheckSelectedButton
- * @extends BI.Single
- */
-BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, {
-
- _const: {
- checkSelected: BI.i18nText('BI-Check_Selected')
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-check-selected-button bi-high-light',
- itemsCreator: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments);
- var self = this;
- this.numberCounter = BI.createWidget({
- type: 'bi.text_button',
- element: this,
- hgap: 4,
- text: "0",
- textAlign: 'center',
- textHeight: 15
- });
- this.numberCounter.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.numberCounter.on(BI.TextButton.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
- });
-
- this.numberCounter.element.hover(function () {
- self.numberCounter.setTag(self.numberCounter.getText());
- self.numberCounter.setText(self._const.checkSelected);
- }, function () {
- self.numberCounter.setText(self.numberCounter.getTag());
- });
- this.setVisible(false);
- },
-
- setValue: function (ob) {
- var self = this, o = this.options;
- ob || (ob = {});
- ob.type || (ob.type = BI.Selection.Multi);
- ob.value || (ob.value = []);
- if (ob.type === BI.Selection.All) {
- o.itemsCreator({
- type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
- }, function (res) {
- var length = res.count - ob.value.length;
- BI.nextTick(function(){
- self.numberCounter.setText(length);
- self.setVisible(length > 0);
- });
- });
- return;
- }
- BI.nextTick(function(){
- self.numberCounter.setText(ob.value.length);
- self.setVisible(ob.value.length > 0);
- })
- },
-
- getValue: function () {
-
- }
-});
-
-BI.MultiSelectCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.multi_select_check_selected_button', BI.MultiSelectCheckSelectedButton);/**
- * 多选输入框
- * Created by guy on 15/11/3.
- * @class BI.MultiSelectEditor
- * @extends Widget
- */
-BI.MultiSelectEditor = BI.inherit(BI.Widget, {
-
- _const: {
- checkSelected: BI.i18nText('BI-Check_Selected')
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectEditor.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-editor',
- el: {}
- });
- },
-
- _init: function () {
- BI.MultiSelectEditor.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.editor = BI.createWidget(o.el, {
- type: 'bi.state_editor',
- element: this,
- height: o.height,
- watermark: BI.i18nText('BI-Basic_Search'),
- allowBlank: true
- });
-
- this.editor.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.editor.on(BI.StateEditor.EVENT_PAUSE, function () {
- self.fireEvent(BI.MultiSelectEditor.EVENT_PAUSE);
- });
- this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () {
-
- });
- },
-
- focus: function () {
- this.editor.focus();
- },
-
- blur: function () {
- this.editor.blur();
- },
-
- setState: function (state) {
- this.editor.setState(state);
- },
-
- setValue: function (v) {
- this.editor.setValue(v);
- },
-
- getValue: function () {
- var v = this.editor.getState();
- if (BI.isArray(v) && v.length > 0) {
- return v[v.length - 1];
- } else {
- return "";
- }
- },
-
- getKeywords: function () {
- var val = this.editor.getLastValidValue();
- var keywords = val.match(/[\S]+/g);
- if (BI.isEndWithBlank(val)) {
- return keywords.concat([' ']);
- }
- return keywords;
- },
-
- populate: function (items) {
-
- }
-});
-BI.MultiSelectEditor.EVENT_PAUSE = "MultiSelectEditor.EVENT_PAUSE";
-BI.shortcut('bi.multi_select_editor', BI.MultiSelectEditor);/**
- * searcher
- * Created by guy on 15/11/3.
- * @class BI.MultiSelectSearcher
- * @extends Widget
- */
-BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-searcher',
- itemsCreator: BI.emptyFn,
- el: {},
- popup: {},
- valueFormatter: BI.emptyFn,
- adapter: null,
- masker: {}
- });
- },
-
- _init: function () {
- BI.MultiSelectSearcher.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.editor = BI.createWidget(o.el, {
- type: 'bi.multi_select_editor',
- height: o.height
- });
-
- this.searcher = BI.createWidget({
- type: "bi.searcher",
- element: this,
- height: o.height,
- isAutoSearch: false,
- isAutoSync: false,
- onSearch: function (op, callback) {
- callback();
- },
- el: this.editor,
-
- popup: BI.extend({
- type: "bi.multi_select_search_pane",
- valueFormatter: o.valueFormatter,
- keywordGetter: function () {
- return self.editor.getValue();
- },
- itemsCreator: function (op, callback) {
- op.keyword = self.editor.getValue();
- this.setKeyword(op.keyword);
- o.itemsCreator(op, callback);
- }
- }, o.popup),
-
- adapter: o.adapter,
- masker: o.masker
- });
- this.searcher.on(BI.Searcher.EVENT_START, function () {
- self.fireEvent(BI.MultiSelectSearcher.EVENT_START);
- });
- this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
- if (this.hasMatched()) {
-
- }
- self.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE);
- });
- this.searcher.on(BI.Searcher.EVENT_STOP, function () {
- self.fireEvent(BI.MultiSelectSearcher.EVENT_STOP);
- });
- this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE, arguments);
- });
- this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
- var keywords = this.getKeywords();
- self.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING, keywords);
- });
- },
-
- adjustView: function () {
- this.searcher.adjustView();
- },
-
- isSearching: function () {
- return this.searcher.isSearching();
- },
-
- stopSearch: function () {
- this.searcher.stopSearch();
- },
-
- getKeyword: function () {
- return this.editor.getValue();
- },
-
- hasMatched: function () {
- return this.searcher.hasMatched();
- },
-
- hasChecked: function () {
- return this.searcher.getView() && this.searcher.getView().hasChecked();
- },
-
- setAdapter: function (adapter) {
- this.searcher.setAdapter(adapter);
- },
-
- setState: function (ob) {
- var o = this.options;
- ob || (ob = {});
- ob.value || (ob.value = []);
- if (ob.type === BI.Selection.All) {
- if (BI.size(ob.assist) === 1) {
- this.editor.setState(o.valueFormatter(ob.assist[0] + "") || (ob.assist[0] + ""));
- } else {
- this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All);
- }
- } else {
- if (BI.size(ob.value) === 1) {
- this.editor.setState(o.valueFormatter(ob.value[0] + "") || (ob.value[0] + ""));
- } else {
- this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None);
- }
- }
- },
-
- setValue: function (ob) {
- this.setState(ob);
- this.searcher.setValue(ob);
- },
-
- getKey: function () {
- return this.editor.getValue();
- },
-
- getValue: function () {
- return this.searcher.getValue();
- },
-
- populate: function (items) {
- this.searcher.populate.apply(this.searcher, arguments);
- }
-});
-
-BI.MultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.MultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE";
-BI.MultiSelectSearcher.EVENT_START = "EVENT_START";
-BI.MultiSelectSearcher.EVENT_STOP = "EVENT_STOP";
-BI.MultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE";
-BI.MultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.shortcut('bi.multi_select_searcher', BI.MultiSelectSearcher);/**
- * 查看已选switcher
- * Created by guy on 15/11/3.
- * @class BI.MultiSelectCheckSelectedSwitcher
- * @extends Widget
- */
-BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectCheckSelectedSwitcher.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-check-selected-switcher',
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
- el: {},
- popup: {},
- adapter: null,
- masker: {}
- });
- },
-
- _init: function () {
- BI.MultiSelectCheckSelectedSwitcher.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.button = BI.createWidget(o.el, {
- type: "bi.multi_select_check_selected_button",
- itemsCreator: o.itemsCreator
- });
- this.button.on(BI.Events.VIEW, function () {
- self.fireEvent(BI.Events.VIEW, arguments);
- });
- this.switcher = BI.createWidget({
- type: "bi.switcher",
- toggle: false,
- element: this,
- el: this.button,
- popup: BI.extend({
- type: "bi.multi_select_check_pane",
- valueFormatter: o.valueFormatter,
- itemsCreator: o.itemsCreator,
- onClickContinueSelect: function () {
- self.switcher.hideView();
- }
- }, o.popup),
- adapter: o.adapter,
- masker: o.masker
- });
- this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE, function () {
- self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE);
- });
- this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW);
- });
- this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW, function () {
- var me = this;
- BI.nextTick(function () {
- me.populate();
- });
- });
-
- this.switcher.element.click(function (e) {
- e.stopPropagation();
- });
- },
-
- adjustView: function () {
- this.switcher.adjustView();
- },
-
- hideView: function () {
- this.switcher.empty();
- this.switcher.hideView();
- },
-
- setAdapter: function (adapter) {
- this.switcher.setAdapter(adapter);
- },
-
- setValue: function (v) {
- this.switcher.setValue(v);
- },
-
- setButtonChecked: function (v) {
- this.button.setValue(v)
- },
-
- getValue: function () {
-
- },
-
- populate: function (items) {
- this.switcher.populate.apply(this.switcher, arguments);
- }
-});
-
-BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE";
-BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/**
- * Created by zcf_1 on 2017/5/2.
- */
-BI.MultiSelectList = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-list',
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn
- })
- },
- _init: function () {
- BI.MultiSelectList.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
- this.storeValue = {};
-
- var assertShowValue = function () {
- BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
- // self.trigger.setValue(self.storeValue);
- };
-
- this.adapter = BI.createWidget({
- type: "bi.multi_select_loader",
- cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom",
- itemsCreator: o.itemsCreator,
- valueFormatter: o.valueFormatter,
- // onLoaded: o.onLoaded,
- el: {
- height: ""
- }
- });
- this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
- self.storeValue = this.getValue();
- self._adjust(function () {
- assertShowValue();
- self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
- });
- });
-
- this.searcherPane = BI.createWidget({
- type: "bi.multi_select_search_pane",
- cls: "bi-border-left bi-border-right bi-border-bottom",
- valueFormatter: o.valueFormatter,
- keywordGetter: function () {
- return self.trigger.getKeyword();
- },
- itemsCreator: function (op, callback) {
- op.keyword = self.trigger.getKeyword();
- this.setKeyword(op.keyword);
- o.itemsCreator(op, callback);
- }
- });
- this.searcherPane.setVisible(false);
-
- this.trigger = BI.createWidget({
- type: "bi.searcher",
- isAutoSearch: false,
- isAutoSync: false,
- onSearch: function (op, callback) {
- callback();
- },
- adapter: this.adapter,
- popup: this.searcherPane,
- height: 200,
- masker: false,
- listeners: [{
- eventName: BI.Searcher.EVENT_START,
- action: function () {
- self._showSearcherPane();
- self._setStartValue("");
- this.setValue(BI.deepClone(self.storeValue));
- }
- }, {
- eventName: BI.Searcher.EVENT_STOP,
- action: function () {
- self._showAdapter();
- self._setStartValue("");
- self.adapter.setValue(self.storeValue);
- //需要刷新回到初始界面,否则搜索的结果不能放在最前面
- self.adapter.populate();
- }
- }, {
- eventName: BI.Searcher.EVENT_PAUSE,
- action: function () {
- if (this.hasMatched()) {
- var keyword = this.getKeyword();
- self._join({
- type: BI.Selection.Multi,
- value: [keyword]
- }, function () {
- self._showAdapter();
- self.adapter.setValue(self.storeValue);
- self._setStartValue(keyword);
- assertShowValue();
- self._setStartValue("");
- self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
- })
- } else {
- self._showAdapter();
- }
- }
- }, {
- eventName: BI.Searcher.EVENT_SEARCHING,
- action: function () {
- var keywords = this.getKeyword();
- var last = BI.last(keywords);
- keywords = BI.initial(keywords || []);
- if (keywords.length > 0) {
- self._joinKeywords(keywords, function () {
- if (BI.isEndWithBlank(last)) {
- self.adapter.setValue(self.storeValue);
- assertShowValue();
- self.adapter.populate();
- self._setStartValue("");
- } else {
- self.adapter.setValue(self.storeValue);
- assertShowValue();
- }
- });
- }
- }
- }, {
- eventName: BI.Searcher.EVENT_CHANGE,
- action: function (value, obj) {
- if (obj instanceof BI.MultiSelectBar) {
- self._joinAll(this.getValue(), function () {
- assertShowValue();
- });
- } else {
- self._join(this.getValue(), function () {//安徽省 北京
- assertShowValue();
- });
- }
- }
- }]
- });
-
- BI.createWidget({
- type: "bi.vtape",
- element: this,
- items: [{
- el: this.trigger,
- height: 30
- }, {
- el: this.adapter,
- height: "fill"
- }]
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.searcherPane,
- top: 30,
- bottom: 0,
- left: 0,
- right: 0
- }]
- })
- },
-
- _showAdapter: function () {
- this.adapter.setVisible(true);
- this.searcherPane.setVisible(false);
- },
-
- _showSearcherPane: function () {
- this.searcherPane.setVisible(true);
- this.adapter.setVisible(false);
- },
-
- _defaultState: function () {
- this.trigger.stopEditing();
- },
-
- _assertValue: function (val) {
- val || (val = {});
- val.type || (val.type = BI.Selection.Multi);
- val.value || (val.value = []);
- },
-
- _makeMap: function (values) {
- return BI.makeObject(values || []);
- },
-
- _joinKeywords: function (keywords, callback) {
- var self = this, o = this.options;
- this._assertValue(this.storeValue);
- if (!this._allData) {
- o.itemsCreator({
- type: BI.MultiSelectList.REQ_GET_ALL_DATA
- }, function (ob) {
- self._allData = BI.pluck(ob.items, "value");
- digest(self._allData);
- })
- } else {
- digest(this._allData)
- }
-
- function digest(items) {
- var selectedMap = self._makeMap(items);
- BI.each(keywords, function (i, val) {
- if (BI.isNotNull(selectedMap[val])) {
- self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
- }
- });
- self._adjust(callback);
- }
- },
-
- _joinAll: function (res, callback) {
- var self = this, o = this.options;
- this._assertValue(res);
- o.itemsCreator({
- type: BI.MultiSelectList.REQ_GET_ALL_DATA,
- keyword: self.trigger.getKeyword()
- }, function (ob) {
- var items = BI.pluck(ob.items, "value");
- if (self.storeValue.type === res.type) {
- var change = false;
- var map = self._makeMap(self.storeValue.value);
- BI.each(items, function (i, v) {
- if (BI.isNotNull(map[v])) {
- change = true;
- delete map[v];
- }
- });
- change && (self.storeValue.value = BI.values(map));
- self._adjust(callback);
- return;
- }
- var selectedMap = self._makeMap(self.storeValue.value);
- var notSelectedMap = self._makeMap(res.value);
- var newItems = [];
- BI.each(items, function (i, item) {
- if (BI.isNotNull(selectedMap[items[i]])) {
- delete selectedMap[items[i]];
- }
- if (BI.isNull(notSelectedMap[items[i]])) {
- newItems.push(item);
- }
- });
- self.storeValue.value = newItems.concat(BI.values(selectedMap));
- self._adjust(callback);
- })
- },
-
- _adjust: function (callback) {
- var self = this, o = this.options;
- if (!this._count) {
- o.itemsCreator({
- type: BI.MultiSelectList.REQ_GET_DATA_LENGTH
- }, function (res) {
- self._count = res.count;
- adjust();
- callback();
- });
- } else {
- adjust();
- callback();
- }
- function adjust() {
- if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
- self.storeValue = {
- type: BI.Selection.Multi,
- value: []
- }
- } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
- self.storeValue = {
- type: BI.Selection.All,
- value: []
- }
- }
- }
- },
-
- _join: function (res, callback) {
- var self = this, o = this.options;
- this._assertValue(res);
- this._assertValue(this.storeValue);
- if (this.storeValue.type === res.type) {
- var map = this._makeMap(this.storeValue.value);
- BI.each(res.value, function (i, v) {
- if (!map[v]) {
- self.storeValue.value.push(v);
- map[v] = v;
- }
- });
- var change = false;
- BI.each(res.assist, function (i, v) {
- if (BI.isNotNull(map[v])) {
- change = true;
- delete map[v];
- }
- });
- change && (this.storeValue.value = BI.values(map));
- self._adjust(callback);
- return;
- }
- this._joinAll(res, callback);
- },
-
- _setStartValue: function (value) {
- this._startValue = value;
- this.adapter.setStartValue(value);
- },
-
- isAllSelected: function () {
- return this.adapter.isAllSelected();
- },
-
- resize: function () {
- // this.trigger.getCounter().adjustView();
- // this.trigger.adjustView();
- },
- setValue: function (v) {
- this.storeValue = v || {};
- this._assertValue(this.storeValue);
- this.adapter.setValue(this.storeValue);
- this.trigger.setValue(this.storeValue);
- },
-
- getValue: function () {
- return this.storeValue;
- },
-
- populate: function () {
- this._count = null;
- this._allData = null;
- this.adapter.populate.apply(this.adapter, arguments);
- this.trigger.populate.apply(this.trigger, arguments);
- }
-});
-
-BI.extend(BI.MultiSelectList, {
- REQ_GET_DATA_LENGTH: 0,
- REQ_GET_ALL_DATA: -1
-});
-
-BI.MultiSelectList.EVENT_CHANGE = "BI.MultiSelectList.EVENT_CHANGE";
-BI.shortcut("bi.multi_select_list", BI.MultiSelectList);/**
- * Created by zcf_1 on 2017/5/11.
- */
-BI.MultiSelectTree = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-select-tree',
- itemsCreator: BI.emptyFn
- })
- },
-
- _init: function () {
- BI.MultiSelectTree.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.storeValue = {value: {}};
-
- this.adapter = BI.createWidget({
- type: "bi.multi_select_tree_popup",
- itemsCreator: o.itemsCreator
- });
- this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
- if (self.searcher.isSearching()) {
- self.storeValue = {value: self.searcherPane.getValue()};
- } else {
- self.storeValue = {value: self.adapter.getValue()};
- }
- self.setSelectedValue(self.storeValue.value);
- self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
- });
-
- //搜索中的时候用的是parttree,同adapter中的synctree不一样
- this.searcherPane = BI.createWidget({
- type: "bi.multi_tree_search_pane",
- cls: "bi-border-left bi-border-right bi-border-bottom",
- keywordGetter: function () {
- return self.searcher.getKeyword();
- },
- itemsCreator: function (op, callback) {
- op.keyword = self.searcher.getKeyword();
- o.itemsCreator(op, callback);
- }
- });
- this.searcherPane.setVisible(false);
-
- this.searcher = BI.createWidget({
- type: "bi.searcher",
- isAutoSearch: false,
- isAutoSync: false,
- onSearch: function (op, callback) {
- callback({
- keyword: self.searcher.getKeyword()
- });
- },
- adapter: this.adapter,
- popup: this.searcherPane,
- masker: false,
- listeners: [{
- eventName: BI.Searcher.EVENT_START,
- action: function () {
- self._showSearcherPane();
- // self.storeValue = {value: self.adapter.getValue()};
- // self.searcherPane.setSelectedValue(self.storeValue.value);
- }
- }, {
- eventName: BI.Searcher.EVENT_STOP,
- action: function () {
- self._showAdapter();
- // self.storeValue = {value: self.searcherPane.getValue()};
- // self.adapter.setSelectedValue(self.storeValue.value);
- BI.nextTick(function () {
- self.adapter.populate();
- });
- }
- }, {
- eventName: BI.Searcher.EVENT_CHANGE,
- action: function () {
- if (self.searcher.isSearching()) {
- self.storeValue = {value: self.searcherPane.getValue()};
- } else {
- self.storeValue = {value: self.adapter.getValue()};
- }
- self.setSelectedValue(self.storeValue.value);
- self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
- }
- }, {
- eventName: BI.Searcher.EVENT_PAUSE,
- action: function () {
- self._showAdapter();
- }
- }]
- });
-
- BI.createWidget({
- type: "bi.vtape",
- element: this,
- items: [{
- el: this.searcher,
- height: 30
- }, {
- el: this.adapter,
- height: "fill"
- }]
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.searcherPane,
- top: 30,
- bottom: 0,
- left: 0,
- right: 0
- }]
- })
-
- },
-
- _showAdapter: function () {
- this.adapter.setVisible(true);
- this.searcherPane.setVisible(false);
- },
-
- _showSearcherPane: function () {
- this.searcherPane.setVisible(true);
- this.adapter.setVisible(false);
- },
-
- resize: function () {
-
- },
-
- setSelectedValue: function (v) {
- this.storeValue.value = v || {};
- this.adapter.setSelectedValue(v);
- this.searcherPane.setSelectedValue(v);
- this.searcher.setValue({
- value: v || {}
- });
- },
-
- setValue: function (v) {
- this.adapter.setValue(v);
- },
-
- stopSearch: function () {
- this.searcher.stopSearch();
- },
-
- updateValue: function (v) {
- this.adapter.updateValue(v);
- },
-
- getValue: function () {
- return this.storeValue.value;
- },
-
- populate: function () {
- this.searcher.populate.apply(this.searcher, arguments);
- this.adapter.populate.apply(this.adapter, arguments);
- }
-});
-BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
-BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
- * Created by zcf on 2016/12/21.
- */
-BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom",
- itemsCreator: BI.emptyFn
- });
- },
- _init: function () {
- BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.popup = BI.createWidget({
- type: "bi.async_tree",
- element: this,
- itemsCreator: o.itemsCreator
- });
- this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
- self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)
- });
- this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)
- });
- },
-
- hasChecked: function () {
- return this.popup.hasChecked();
- },
-
- getValue: function () {
- return this.popup.getValue();
- },
-
- setValue: function (v) {
- v || (v = {});
- this.popup.setValue(v);
- },
-
- setSelectedValue: function (v) {
- v || (v = {});
- this.popup.setSelectedValue(v);
- },
-
- updateValue: function (v) {
- this.popup.updateValue(v);
- this.popup.refresh();
- },
-
- populate: function (config) {
- this.popup.stroke(config);
- }
-
-});
-BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
-BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
-BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);/**
- *
- * @class BI.MultiTreeCheckPane
- * @extends BI.Pane
- */
-BI.MultiTreeCheckPane = BI.inherit(BI.Pane, {
-
- constants: {
- height: 25,
- lgap: 10,
- tgap: 5
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-tree-check-pane bi-background",
- onClickContinueSelect: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiTreeCheckPane.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
-
- this.selectedValues = {};
-
- var continueSelect = BI.createWidget({
- type: 'bi.text_button',
- text: BI.i18nText('BI-Continue_Select'),
- cls: 'multi-tree-check-selected'
- });
- continueSelect.on(BI.TextButton.EVENT_CHANGE, function () {
- opts.onClickContinueSelect();
- BI.nextTick(function () {
- self.empty();
- });
- });
-
- var backToPopup = BI.createWidget({
- type: 'bi.left',
- cls: 'multi-tree-continue-select',
- items: [
- {
- el: {
- type: "bi.label",
- text: BI.i18nText('BI-Selected_Data')
- },
- lgap: this.constants.lgap,
- tgap: this.constants.tgap
- },
- {
- el: continueSelect,
- lgap: this.constants.lgap,
- tgap: this.constants.tgap
- }]
- });
-
- this.display = BI.createWidget({
- type: "bi.display_tree",
- cls: "bi-multi-tree-display",
- itemsCreator: function (op, callback) {
- op.type = BI.TreeView.REQ_TYPE_GET_SELECTED_DATA;
- opts.itemsCreator(op, callback);
- }
- });
-
- this.display.on(BI.Events.AFTERINIT, function () {
- self.fireEvent(BI.Events.AFTERINIT);
- });
-
- this.display.on(BI.TreeView.EVENT_INIT, function () {
- backToPopup.setVisible(false);
- });
-
- this.display.on(BI.TreeView.EVENT_AFTERINIT, function () {
- backToPopup.setVisible(true);
- });
-
- BI.createWidget({
- type: 'bi.vtape',
- element: this,
- items: [{
- height: this.constants.height,
- el: backToPopup
- }, {
- height: 'fill',
- el: this.display
- }]
- });
-
- },
-
- empty: function () {
- this.display.empty();
- },
-
- populate: function (configs) {
- this.display.stroke(configs);
- },
-
- setValue: function (v) {
- v || (v = {});
- this.display.setSelectedValue(v.value);
- },
-
- getValue: function () {
-
- }
-});
-
-BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK";
-
-
-BI.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/**
- *
- * @class BI.MultiTreeCombo
- * @extends BI.Single
- */
-
-BI.MultiTreeCombo = BI.inherit(BI.Single, {
-
- constants: {
- offset: {
- top: 1,
- left: 1,
- right: 2,
- bottom: 33
- }
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-tree-combo',
- itemsCreator: BI.emptyFn,
- height: 25
- });
- },
-
- _init: function () {
- BI.MultiTreeCombo.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- var isInit = false;
- var want2showCounter = false;
-
- this.trigger = BI.createWidget({
- type: "bi.multi_select_trigger",
- height: o.height,
- // adapter: this.popup,
- masker: {
- offset: this.constants.offset
- },
- searcher: {
- type: "bi.multi_tree_searcher",
- itemsCreator: o.itemsCreator
- },
- switcher: {
- el: {
- type: "bi.multi_tree_check_selected_button"
- },
- popup: {
- type: "bi.multi_tree_check_pane",
- itemsCreator: o.itemsCreator
- }
- }
-
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- toggle: false,
- el: this.trigger,
- adjustLength: 1,
- popup: {
- type: 'bi.multi_tree_popup_view',
- ref: function () {
- self.popup = this;
- self.trigger.setAdapter(this);
- },
- listeners: [{
- eventName: BI.MultiTreePopup.EVENT_AFTERINIT,
- action: function () {
- self.trigger.getCounter().adjustView();
- isInit = true;
- if (want2showCounter === true) {
- showCounter();
- }
- }
- }, {
- eventName: BI.MultiTreePopup.EVENT_CHANGE,
- action: function () {
- change = true;
- var val = {
- type: BI.Selection.Multi,
- value: this.hasChecked() ? {1: 1} : {}
- };
- self.trigger.getSearcher().setState(val);
- self.trigger.getCounter().setButtonChecked(val);
- }
- }, {
- eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM,
- action: function () {
- self.combo.hideView();
- }
- }, {
- eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR,
- action: function () {
- clear = true;
- self.setValue();
- self._defaultState();
- }
- }],
- itemsCreator: o.itemsCreator,
- onLoaded: function () {
- BI.nextTick(function () {
- self.trigger.getCounter().adjustView();
- self.trigger.getSearcher().adjustView();
- });
- }
- },
- hideChecker: function (e) {
- return triggerBtn.element.find(e.target).length === 0;
- }
- });
-
- this.storeValue = {value: {}};
- var change = false;
- var clear = false; //标识当前是否点击了清空
-
- var isSearching = function () {
- return self.trigger.getSearcher().isSearching();
- };
-
- var isPopupView = function () {
- return self.combo.isViewVisible();
- };
-
- this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
- self.storeValue = {value: self.combo.getValue()};
- this.setValue(self.storeValue);
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
- self.storeValue = {value: this.getValue()};
- self.combo.setValue(self.storeValue);
- BI.nextTick(function () {
- if (isPopupView()) {
- self.combo.populate();
- }
- });
- });
- function showCounter() {
- if (isSearching()) {
- self.storeValue = {value: self.trigger.getValue()};
- } else if (isPopupView()) {
- self.storeValue = {value: self.combo.getValue()};
- }
- self.trigger.setValue(self.storeValue);
- }
-
- this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
- if (want2showCounter === false) {
- want2showCounter = true;
- }
- if (isInit === true) {
- want2showCounter = null;
- showCounter();
- }
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () {
- self.combo.toggle();
- });
- this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- });
-
- this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
- var val = {
- type: BI.Selection.Multi,
- value: this.getSearcher().hasChecked() ? {1: 1} : {}
- };
- this.getSearcher().setState(val);
- this.getCounter().setButtonChecked(val);
- });
-
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- if (isSearching()) {
- return;
- }
- if (change === true) {
- self.storeValue = {value: self.combo.getValue()};
- change = false;
- }
- self.combo.setValue(self.storeValue);
- self.populate();
-
- });
- this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () {
- if (isSearching()) {
- self.trigger.stopEditing();
- self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
- }else{
- if (isPopupView()) {
- self.trigger.stopEditing();
- self.storeValue = {value: self.combo.getValue()};
- if (clear === true) {
- self.storeValue = {value: {}};
- }
- self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
- }
- }
- clear = false;
- change = false;
- });
-
- var triggerBtn = BI.createWidget({
- type: "bi.trigger_icon_button",
- width: o.height,
- height: o.height,
- cls: "multi-select-trigger-icon-button bi-border-left"
- });
- triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
- self.trigger.getCounter().hideView();
- if (self.combo.isViewVisible()) {
- self.combo.hideView();
- } else {
- self.combo.showView();
- }
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.combo,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- }, {
- el: triggerBtn,
- right: 0,
- top: 0,
- bottom: 0
- }]
- })
- },
-
- _defaultState: function () {
- this.trigger.stopEditing();
- this.combo.hideView();
- },
-
- setValue: function (v) {
- this.storeValue.value = v || {};
- this.combo.setValue({
- value: v || {}
- });
- },
-
- getValue: function () {
- return this.storeValue.value;
- },
-
- populate: function () {
- this.combo.populate.apply(this.combo, arguments);
- }
-});
-
-BI.MultiTreeCombo.EVENT_CONFIRM = "MultiTreeCombo.EVENT_CONFIRM";
-
-BI.shortcut('bi.multi_tree_combo', BI.MultiTreeCombo);/**
- * 带加载的多选下拉面板
- * @class BI.MultiTreePopup
- * @extends BI.Pane
- */
-BI.MultiTreePopup = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-tree-popup',
- maxWidth: 'auto',
- minWidth: 100,
- maxHeight: 400,
- onLoaded: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiTreePopup.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
-
- this.selectedValues = {};
-
- this.tree = BI.createWidget({
- type: "bi.async_tree",
- height: 400,
- cls:"popup-view-tree",
- itemsCreator: opts.itemsCreator,
- onLoaded: opts.onLoaded
- });
-
- this.popupView = BI.createWidget({
- type: "bi.multi_popup_view",
- element: this,
- stopPropagation: false,
- maxWidth: opts.maxWidth,
- minWidth: opts.minWidth,
- maxHeight: opts.maxHeight,
- buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')],
- el: this.tree
- });
-
- this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
- switch (index) {
- case 0:
- self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR);
- break;
- case 1:
- self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM);
- break;
- }
- });
-
- this.tree.on(BI.TreeView.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiTreePopup.EVENT_CHANGE);
- });
-
- this.tree.on(BI.TreeView.EVENT_AFTERINIT, function () {
- self.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT);
- });
-
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- setValue: function (v) {
- v || (v = {});
- this.tree.setSelectedValue(v.value);
- },
-
- populate: function (config) {
- this.tree.stroke(config);
- },
-
- hasChecked: function () {
- return this.tree.hasChecked();
- },
-
- resetHeight: function (h) {
- this.popupView.resetHeight(h);
- },
-
- resetWidth: function (w) {
- this.popupView.resetWidth(w);
- }
-});
-
-BI.MultiTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.MultiTreePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
-BI.MultiTreePopup.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
-BI.MultiTreePopup.EVENT_AFTERINIT = "EVENT_AFTERINIT";
-
-
-BI.shortcut('bi.multi_tree_popup_view', BI.MultiTreePopup);/**
- *
- * 在搜索框中输入文本弹出的面板
- * @class BI.MultiTreeSearchPane
- * @extends BI.Pane
- */
-
-BI.MultiTreeSearchPane = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-multi-tree-search-pane bi-card",
- itemsCreator: BI.emptyFn,
- keywordGetter: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiTreeSearchPane.superclass._init.apply(this, arguments);
-
- var self = this, opts = this.options;
-
- this.partTree = BI.createWidget({
- type: "bi.part_tree",
- element: this,
- tipText: BI.i18nText("BI-No_Select"),
- itemsCreator: function (op, callback) {
- op.keyword = opts.keywordGetter();
- opts.itemsCreator(op, callback);
- }
- });
-
- this.partTree.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.partTree.on(BI.TreeView.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE);
- });
- },
-
- hasChecked: function () {
- return this.partTree.hasChecked();
- },
-
- setValue: function (v) {
- this.setSelectedValue(v.value);
- },
-
- setSelectedValue: function (v) {
- v || (v = {});
- this.partTree.setSelectedValue(v);
- },
-
- getValue: function () {
- return this.partTree.getValue();
- },
-
- empty: function () {
- this.partTree.empty();
- },
-
- populate: function (op) {
- this.partTree.stroke.apply(this.partTree, arguments);
- }
-});
-
-BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
-
-BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
-BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
-
-BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane);/**
- * 查看已选按钮
- * Created by guy on 15/11/3.
- * @class BI.MultiTreeCheckSelectedButton
- * @extends BI.Single
- */
-BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, {
-
- _const: {
- checkSelected: BI.i18nText('BI-Check_Selected')
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreeCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-tree-check-selected-button',
- itemsCreator: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.MultiTreeCheckSelectedButton.superclass._init.apply(this, arguments);
- var self = this;
- this.indicator = BI.createWidget({
- type: 'bi.icon_button',
- cls: 'check-font trigger-check-selected',
- width: 15,
- height: 15,
- stopPropagation: true
- });
-
- this.checkSelected = BI.createWidget({
- type: 'bi.text_button',
- cls: "trigger-check-selected",
- invisible: true,
- hgap: 4,
- text: this._const.checkSelected,
- textAlign: 'center',
- textHeight: 15
- });
- this.checkSelected.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.checkSelected.on(BI.TextButton.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
- });
-
- BI.createWidget({
- type: "bi.horizontal",
- element: this,
- items: [this.indicator, this.checkSelected]
- })
-
- this.element.hover(function () {
- self.indicator.setVisible(false);
- self.checkSelected.setVisible(true);
- }, function () {
- self.indicator.setVisible(true);
- self.checkSelected.setVisible(false);
- });
- this.setVisible(false);
- },
-
- setValue: function (v) {
- v || (v = {});
- this.setVisible(BI.size(v.value) > 0);
- }
-});
-
-BI.MultiTreeCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut('bi.multi_tree_check_selected_button', BI.MultiTreeCheckSelectedButton);/**
- * searcher
- * Created by guy on 15/11/3.
- * @class BI.MultiTreeSearcher
- * @extends Widget
- */
-BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), {
- baseCls: 'bi-multi-tree-searcher',
- itemsCreator: BI.emptyFn,
- popup: {},
-
- adapter: null,
- masker: {}
- });
- },
-
- _init: function () {
- BI.MultiTreeSearcher.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.editor = BI.createWidget({
- type: 'bi.multi_select_editor',
- height: o.height,
- el: {
- type: "bi.simple_state_editor",
- height: o.height
- }
- });
-
- this.searcher = BI.createWidget({
- type: "bi.searcher",
- element: this,
- isAutoSearch: false,
- isAutoSync: false,
- onSearch: function (op, callback) {
- callback({
- keyword: self.editor.getValue()
- });
- },
- el: this.editor,
-
- popup: BI.extend({
- type: "bi.multi_tree_search_pane",
- keywordGetter: function () {
- return self.editor.getValue();
- },
- itemsCreator: function (op, callback) {
- op.keyword = self.editor.getValue();
- o.itemsCreator(op, callback);
- }
- }, o.popup),
-
- adapter: o.adapter,
- masker: o.masker
- });
- this.searcher.on(BI.Searcher.EVENT_START, function () {
- self.fireEvent(BI.MultiTreeSearcher.EVENT_START);
- });
- this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
- if (this.hasMatched()) {
-
- }
- self.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE);
- });
- this.searcher.on(BI.Searcher.EVENT_STOP, function () {
- self.fireEvent(BI.MultiTreeSearcher.EVENT_STOP);
- });
- this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
- self.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE, arguments);
- });
- },
-
- adjustView: function () {
- this.searcher.adjustView();
- },
-
- setAdapter: function (adapter) {
- this.searcher.setAdapter(adapter);
- },
-
- isSearching: function () {
- return this.searcher.isSearching();
- },
-
- stopSearch: function () {
- this.searcher.stopSearch();
- },
-
- getKeyword: function () {
- return this.editor.getValue();
- },
-
- hasMatched: function () {
- return this.searcher.hasMatched();
- },
-
- hasChecked: function () {
- return this.searcher.getView() && this.searcher.getView().hasChecked();
- },
-
- setState: function (ob) {
- ob || (ob = {});
- ob.value || (ob.value = []);
- if (ob.type === BI.Selection.All) {
- this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All);
- } else {
- this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None);
- }
- },
-
- setValue: function (ob) {
- this.setState(ob);
- this.searcher.setValue(ob);
- },
-
- getKey: function () {
- return this.editor.getValue();
- },
-
- getValue: function () {
- return this.searcher.getValue();
- },
-
- populate: function (items) {
- this.searcher.populate.apply(this.searcher, arguments);
- }
-});
-
-BI.MultiTreeSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE";
-BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
-BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
-BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
-BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);//小于号的值为:0,小于等于号的值为:1
-//closeMIn:最小值的符号,closeMax:最大值的符号
-/**
- * Created by roy on 15/9/17.
- *
- */
-BI.NumericalInterval = BI.inherit(BI.Single, {
- constants: {
- typeError: "typeBubble",
- numberError: "numberBubble",
- signalError: "signalBubble",
- editorWidth: 114,
- columns: 5,
- width: 30,
- rows: 1,
- numberErrorCls: "number-error",
- border: 1,
- less: 0,
- less_equal: 1,
- numTip: ""
- },
- _defaultConfig: function () {
- var conf = BI.NumericalInterval.superclass._defaultConfig.apply(this, arguments)
- return BI.extend(conf, {
- extraCls: "bi-numerical-interval",
- height: 25,
- validation: "valid"
- })
- },
- _init: function () {
- var self = this, c = this.constants, o = this.options;
- BI.NumericalInterval.superclass._init.apply(this, arguments)
- this.smallEditor = BI.createWidget({
- type: "bi.editor",
- height: o.height - 2,
- watermark: BI.i18nText("BI-Basic_Unrestricted"),
- allowBlank: true,
- value: o.min,
- level: "warning",
- tipType: "warning",
- quitChecker: function () {
- return false;
- },
- validationChecker: function (v) {
- if (!BI.isNumeric(v)) {
- self.smallEditorBubbleType = c.typeError;
- return false;
- }
- return true;
- },
- cls: "numerical-interval-small-editor bi-border-top bi-border-bottom bi-border-left"
- });
-
- this.smallTip = BI.createWidget({
- type: "bi.label",
- text: o.numTip,
- height: o.height - 2,
- invisible: true
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this.smallEditor.element,
- items: [{
- el: this.smallTip,
- top: 0,
- right: 5
- }]
- });
-
- this.bigEditor = BI.createWidget({
- type: "bi.editor",
- height: o.height - 2,
- watermark: BI.i18nText("BI-Basic_Unrestricted"),
- allowBlank: true,
- value: o.max,
- level: "warning",
- tipType: "warning",
- quitChecker: function () {
- return false;
- },
- validationChecker: function (v) {
- if (!BI.isNumeric(v)) {
- self.bigEditorBubbleType = c.typeError;
- return false;
- }
- return true;
- },
- cls: "numerical-interval-big-editor bi-border-top bi-border-bottom bi-border-right"
- });
-
- this.bigTip = BI.createWidget({
- type: "bi.label",
- text: o.numTip,
- height: o.height - 2,
- invisible: true
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this.bigEditor.element,
- items: [{
- el: this.bigTip,
- top: 0,
- right: 5
- }]
- });
-
- //this.smallCombo = BI.createWidget({
- // type: "bi.numerical_interval_combo",
- // cls: "numerical-interval-small-combo",
- // height: o.height,
- // value: o.closemin ? 1 : 0,
- // offsetStyle: "left"
- //});
- //
- //this.bigCombo = BI.createWidget({
- // type: "bi.numerical_interval_combo",
- // cls: "numerical-interval-big-combo",
- // height: o.height,
- // value: o.closemax ? 1 : 0,
- // offsetStyle: "left"
- //});
- this.smallCombo = BI.createWidget({
- type: "bi.icon_combo",
- cls: "numerical-interval-small-combo bi-border",
- height: o.height - 2,
- items: [{
- text: "(" + BI.i18nText("BI-Less_Than") + ")",
- iconClass: "less-font",
- value: 0
- }, {
- text: "(" + BI.i18nText("BI-Less_And_Equal") + ")",
- value: 1,
- iconClass: "less-equal-font"
- }]
- });
- if (o.closemin === true) {
- this.smallCombo.setValue(1);
- } else {
- this.smallCombo.setValue(0);
- }
- this.bigCombo = BI.createWidget({
- type: "bi.icon_combo",
- cls: "numerical-interval-big-combo bi-border",
- height: o.height - 2,
- items: [{
- text: "(" + BI.i18nText("BI-Less_Than") + ")",
- iconClass: "less-font",
- value: 0
- }, {
- text: "(" + BI.i18nText("BI-Less_And_Equal") + ")",
- value: 1,
- iconClass: "less-equal-font"
- }]
- });
- if (o.closemax === true) {
- this.bigCombo.setValue(1);
- } else {
- this.bigCombo.setValue(0);
- }
- this.label = BI.createWidget({
- type: "bi.label",
- text: BI.i18nText("BI-Basic_Value"),
- textHeight: o.height - c.border * 2,
- width: c.width - c.border * 2,
- height: o.height - c.border * 2,
- level: "warning",
- tipType: "warning"
- });
- this.left = BI.createWidget({
- type: "bi.htape",
- items: [{
- el: self.smallEditor
- }, {
- el: self.smallCombo,
- width: c.width - c.border * 2
- }]
-
- });
- this.right = BI.createWidget({
- type: "bi.htape",
- items: [{
- el: self.bigCombo,
- width: c.width - c.border * 2
- }, {
- el: self.bigEditor
- }]
- });
-
-
- BI.createWidget({
- element: self,
- type: "bi.center",
- hgap: 15,
- height: o.height,
- items: [
- {
- type: "bi.absolute",
- items: [{
- el: self.left,
- left: -15,
- right: 0,
- top: 0,
- bottom: 0
- }]
- }, {
- type: "bi.absolute",
- items: [{
- el: self.right,
- left: 0,
- right: -15,
- top: 0,
- bottom: 0
- }]
- }
- ]
- });
-
- BI.createWidget({
- element: self,
- type: "bi.horizontal_auto",
- items: [
- self.label
- ]
- });
-
-
- self._setValidEvent(self.bigEditor, c.bigEditor);
- self._setValidEvent(self.smallEditor, c.smallEditor);
- self._setErrorEvent(self.bigEditor, c.bigEditor);
- self._setErrorEvent(self.smallEditor, c.smallEditor);
- self._setBlurEvent(self.bigEditor);
- self._setBlurEvent(self.smallEditor);
- self._setFocusEvent(self.bigEditor);
- self._setFocusEvent(self.smallEditor);
- self._setComboValueChangedEvent(self.bigCombo);
- self._setComboValueChangedEvent(self.smallCombo);
- self._setEditorValueChangedEvent(self.bigEditor);
- self._setEditorValueChangedEvent(self.smallEditor);
- },
-
- _checkValidation: function () {
- var self = this, c = this.constants, o = this.options;
- self._setTitle("");
- BI.Bubbles.hide(c.typeError);
- BI.Bubbles.hide(c.numberError);
- BI.Bubbles.hide(c.signalError);
- if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) {
- self.element.removeClass("number-error");
- o.validation = "invalid";
- return c.typeError;
- } else {
- if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) {
- self.element.removeClass("number-error");
- o.validation = "valid";
- return "";
- } else {
- var smallValue = parseFloat(self.smallEditor.getValue()), bigValue = parseFloat(self.bigEditor.getValue()),
- bigComboValue = self.bigCombo.getValue(), smallComboValue = self.smallCombo.getValue();
- if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) {
- if (smallValue > bigValue) {
- self.element.addClass("number-error");
- o.validation = "invalid";
- return c.numberError;
- } else {
- self.element.removeClass("number-error");
- o.validation = "valid";
- return "";
- }
- } else {
- if (smallValue > bigValue) {
- self.element.addClass("number-error");
- o.validation = "invalid";
- return c.numberError;
- } else if (smallValue === bigValue) {
- self.element.addClass("number-error");
- o.validation = "invalid";
- return c.signalError;
- } else {
- self.element.removeClass("number-error");
- o.validation = "valid";
- return "";
- }
- }
- }
-
- }
- },
-
- _setTitle: function (v) {
- var self = this;
- self.bigEditor.setTitle(v);
- self.smallEditor.setTitle(v);
- self.label.setTitle(v);
- },
-
- _setFocusEvent: function (w) {
- var self = this, c = this.constants;
- w.on(BI.Editor.EVENT_FOCUS, function () {
- self._setTitle("");
- switch (self._checkValidation()) {
- case c.typeError:
- BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
- offsetStyle: "center"
- });
- break;
- case c.numberError:
- BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
- offsetStyle: "center"
- });
- break;
- case c.signalError:
- BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
- offsetStyle: "center"
- });
- break;
- default :
- return
- }
-
- })
- },
- _setBlurEvent: function (w) {
- var c = this.constants, self = this;
- w.on(BI.Editor.EVENT_BLUR, function () {
- BI.Bubbles.hide(c.typeError);
- BI.Bubbles.hide(c.numberError);
- BI.Bubbles.hide(c.signalError);
- switch (self._checkValidation()) {
- case c.typeError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));
- break;
- case c.numberError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));
- break;
- case c.signalError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));
- break;
- default:
- self._setTitle("");
- }
- })
- },
-
- _setErrorEvent: function (w) {
- var c = this.constants, self = this
- w.on(BI.Editor.EVENT_ERROR, function () {
- self._checkValidation();
- BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
- offsetStyle: "center"
- });
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- })
- },
-
-
- _setValidEvent: function (w) {
- var self = this, c = this.constants;
- w.on(BI.Editor.EVENT_VALID, function () {
- switch (self._checkValidation()) {
- case c.numberError:
- BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
- offsetStyle: "center"
- });
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- break;
- case c.signalError:
- BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
- offsetStyle: "center"
- });
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- break;
- default:
- self.fireEvent(BI.NumericalInterval.EVENT_VALID);
- }
- })
- },
-
-
- _setEditorValueChangedEvent: function (w) {
- var self = this, c = this.constants;
- w.on(BI.Editor.EVENT_CHANGE, function () {
- switch (self._checkValidation()) {
- case c.typeError:
- BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
- offsetStyle: "center"
- });
- break;
- case c.numberError:
- BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
- offsetStyle: "center"
- });
- break;
- case c.signalError:
- BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
- offsetStyle: "center"
- });
- break;
- default :
- break;
- }
- self.fireEvent(BI.NumericalInterval.EVENT_CHANGE);
- });
- },
-
- _setComboValueChangedEvent: function (w) {
- var self = this, c = this.constants;
- w.on(BI.IconCombo.EVENT_CHANGE, function () {
- switch (self._checkValidation()) {
- case c.typeError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- break;
- case c.numberError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- break;
- case c.signalError:
- self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));
- self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
- break;
- default :
- self.fireEvent(BI.NumericalInterval.EVENT_CHANGE);
- self.fireEvent(BI.NumericalInterval.EVENT_VALID);
- }
- })
- },
-
- isStateValid: function () {
- return this.options.validation === "valid";
- },
-
- setMinEnable: function (b) {
- this.smallEditor.setEnable(b);
- },
-
- setCloseMinEnable: function (b) {
- this.smallCombo.setEnable(b);
- },
-
- setMaxEnable: function (b) {
- this.bigEditor.setEnable(b);
- },
-
- setCloseMaxEnable: function (b) {
- this.bigCombo.setEnable(b);
- },
-
- showNumTip: function () {
- this.smallTip.setVisible(true);
- this.bigTip.setVisible(true);
- },
-
- hideNumTip: function () {
- this.smallTip.setVisible(false);
- this.bigTip.setVisible(false);
- },
-
- setNumTip: function(numTip) {
- this.smallTip.setText(numTip);
- this.bigTip.setText(numTip);
- },
-
- getNumTip: function() {
- return this.smallTip.getText();
- },
-
- setValue: function (data) {
- data = data || {};
- var self = this, combo_value;
- if (BI.isNumeric(data.min) || BI.isEmptyString(data.min)) {
- self.smallEditor.setValue(data.min);
- }
-
- if (!BI.isNotNull(data.min)) {
- self.smallEditor.setValue("");
- }
-
- if (BI.isNumeric(data.max) || BI.isEmptyString(data.max)) {
- self.bigEditor.setValue(data.max);
- }
-
- if (!BI.isNotNull(data.max)) {
- self.bigEditor.setValue("");
- }
-
- if (!BI.isNull(data.closemin)) {
- if (data.closemin === true) {
- combo_value = 1
- } else {
- combo_value = 0
- }
- self.smallCombo.setValue(combo_value);
- }
-
- if (!BI.isNull(data.closemax)) {
- if (data.closemax === true) {
- combo_value = 1
- } else {
- combo_value = 0
- }
- self.bigCombo.setValue(combo_value);
- }
- },
-
-
- getValue: function () {
- var self = this, value = {}, minComboValue = self.smallCombo.getValue(), maxComboValue = self.bigCombo.getValue();
- value.min = self.smallEditor.getValue();
- value.max = self.bigEditor.getValue();
- if (minComboValue[0] === 0) {
- value.closemin = false
- } else {
- value.closemin = true
- }
-
- if (maxComboValue[0] === 0) {
- value.closemax = false
- } else {
- value.closemax = true
- }
- return value;
- }
-});
-BI.NumericalInterval.EVENT_CHANGE = "EVENT_CHANGE";
-BI.NumericalInterval.EVENT_VALID = "EVENT_VALID";
-BI.NumericalInterval.EVENT_ERROR = "EVENT_ERROR";
-BI.shortcut("bi.numerical_interval", BI.NumericalInterval);/**
- *
- * 表格
- *
- * Created by GUY on 2015/9/22.
- * @class BI.PageTableCell
- * @extends BI.Single
- */
-BI.PageTableCell = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-page-table-cell",
- text: "",
- title: ""
- })
- },
-
- _init: function () {
- BI.PageTableCell.superclass._init.apply(this, arguments);
- var label = BI.createWidget({
- type: "bi.label",
- element: this,
- textAlign: "left",
- whiteSpace: "nowrap",
- height: this.options.height,
- text: this.options.text,
- title: this.options.title,
- value: this.options.value,
- lgap: 5,
- rgap: 5
- });
-
- if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) {
- this.element.css(this.options.styles);
- }
- }
-});
-
-BI.shortcut("bi.page_table_cell", BI.PageTableCell);/**
- * 分页表格
- *
- * Created by GUY on 2016/2/15.
- * @class BI.PageTable
- * @extends BI.Widget
- */
-BI.PageTable = BI.inherit(BI.Widget, {
-
- _const: {
- scrollWidth: 18,
- minScrollWidth: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-page-table",
- el: {
- type: "bi.sequence_table"
- },
- pager: {
- horizontal: {
- pages: false, //总页数
- curr: 1, //初始化当前页, pages为数字时可用
-
- hasPrev: BI.emptyFn,
- hasNext: BI.emptyFn,
- firstPage: 1,
- lastPage: BI.emptyFn
- },
- vertical: {
- pages: false, //总页数
- curr: 1, //初始化当前页, pages为数字时可用
-
- hasPrev: BI.emptyFn,
- hasNext: BI.emptyFn,
- firstPage: 1,
- lastPage: BI.emptyFn
- }
- },
-
- itemsCreator: BI.emptyFn,
-
- isNeedFreeze: false,//是否需要冻结单元格
- freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
-
- isNeedMerge: false,//是否需要合并单元格
- mergeCols: [], //合并的单元格列号
- mergeRule: BI.emptyFn,
-
- columnSize: [],
- minColumnSize: [],
- maxColumnSize: [],
- headerRowSize: 25,
- rowSize: 25,
-
- regionColumnSize: [],
-
- headerCellStyleGetter: BI.emptyFn,
- summaryCellStyleGetter: BI.emptyFn,
- sequenceCellStyleGetter: BI.emptyFn,
-
- header: [],
- items: [], //二维数组
-
- //交叉表头
- crossHeader: [],
- crossItems: []
- });
- },
-
- _init: function () {
- BI.PageTable.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.hCurr = 1;
- this.vCurr = 1;
-
- this.table = BI.createWidget(o.el, {
- type: "bi.sequence_table",
- width: o.width,
- height: o.height && o.height - 30,
-
- isNeedResize: true,
- isResizeAdapt: false,
-
- isNeedFreeze: o.isNeedFreeze,
- freezeCols: o.freezeCols,
-
- isNeedMerge: o.isNeedMerge,
- mergeCols: o.mergeCols,
- mergeRule: o.mergeRule,
-
- columnSize: o.columnSize,
- minColumnSize: o.minColumnSize,
- maxColumnSize: o.maxColumnSize,
- headerRowSize: o.headerRowSize,
- rowSize: o.rowSize,
-
- regionColumnSize: o.regionColumnSize,
-
- headerCellStyleGetter: o.headerCellStyleGetter,
- summaryCellStyleGetter: o.summaryCellStyleGetter,
- sequenceCellStyleGetter: o.sequenceCellStyleGetter,
-
- header: o.header,
- items: o.items,
- //交叉表头
- crossHeader: o.crossHeader,
- crossItems: o.crossItems
- });
-
- this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
- self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
- o.regionColumnSize = this.getRegionColumnSize();
- o.columnSize = this.getColumnSize();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
- o.regionColumnSize = this.getRegionColumnSize();
- o.columnSize = this.getColumnSize();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
- });
-
- this.pager = BI.createWidget(o.pager, {
- type: "bi.direction_pager",
- height: 30
- });
- this.pager.on(BI.Pager.EVENT_CHANGE, function () {
- var vpage = this.getVPage && this.getVPage();
- if (BI.isNull(vpage)) {
- vpage = this.getCurrentPage();
- }
- var hpage = this.getHPage && this.getHPage();
- o.itemsCreator({
- vpage: vpage,
- hpage: hpage
- }, function (items, header, crossItems, crossHeader) {
- self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage);
- self.table.setHPage && self.table.setHPage(hpage);
- self.populate.apply(self, arguments);
- });
- });
-
- BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.table,
- left: 0,
- top: 0
- }, {
- el: this.pager,
- left: 0,
- right: 0,
- bottom: 0
- }]
- })
- },
-
- setHPage: function (v) {
- this.hCurr = v;
- this.pager.setHPage && this.pager.setHPage(v);
- this.table.setHPage && this.table.setHPage(v);
- },
-
- setVPage: function (v) {
- this.vCurr = v;
- this.pager.setVPage && this.pager.setVPage(v);
- this.table.setVPage && this.table.setVPage(v);
- },
-
- getHPage: function () {
- var hpage = this.pager.getHPage && this.pager.getHPage();
- if (BI.isNotNull(hpage)) {
- return hpage;
- }
- hpage = this.pager.getCurrentPage && this.pager.getCurrentPage();
- if (BI.isNotNull(hpage)) {
- return hpage;
- }
- return this.hpage;
- },
-
- getVPage: function () {
- var vpage = this.pager.getVPage && this.pager.getVPage();
- if (BI.isNotNull(vpage)) {
- return vpage;
- }
- vpage = this.pager.getCurrentPage && this.pager.getCurrentPage();
- if (BI.isNotNull(vpage)) {
- return vpage;
- }
- return this.vpage;
- },
-
- setWidth: function (width) {
- BI.PageTable.superclass.setWidth.apply(this, arguments);
- this.table.setWidth(width);
- },
-
- setHeight: function (height) {
- BI.PageTable.superclass.setHeight.apply(this, arguments);
- var showPager = false;
- if (this.pager.alwaysShowPager) {
- showPager = true;
- } else if (this.pager.hasHNext && this.pager.hasHNext()) {
- showPager = true;
- } else if (this.pager.hasHPrev && this.pager.hasHPrev()) {
- showPager = true;
- } else if (this.pager.hasVNext && this.pager.hasVNext()) {
- showPager = true;
- } else if (this.pager.hasVPrev && this.pager.hasVPrev()) {
- showPager = true;
- } else if (this.pager.hasNext && this.pager.hasNext()) {
- showPager = true;
- } else if (this.pager.hasPrev && this.pager.hasPrev()) {
- showPager = true;
- }
- this.table.setHeight(height - (showPager ? 30 : 0));
- },
-
- setColumnSize: function (columnSize) {
- this.options.columnSize = columnSize;
- this.table.setColumnSize(columnSize);
- },
-
- getColumnSize: function () {
- return this.table.getColumnSize();
- },
-
- setRegionColumnSize: function (columnSize) {
- this.options.columnSize = columnSize;
- this.table.setRegionColumnSize(columnSize);
- },
-
- getRegionColumnSize: function () {
- return this.table.getRegionColumnSize();
- },
-
- getVerticalScroll: function () {
- return this.table.getVerticalScroll();
- },
-
- setLeftHorizontalScroll: function (scrollLeft) {
- this.table.setLeftHorizontalScroll(scrollLeft);
- },
-
- setRightHorizontalScroll: function (scrollLeft) {
- this.table.setRightHorizontalScroll(scrollLeft);
- },
-
- setVerticalScroll: function (scrollTop) {
- this.table.setVerticalScroll(scrollTop);
- },
-
- restore: function () {
- this.table.restore();
- },
-
- attr: function () {
- BI.PageTable.superclass.attr.apply(this, arguments);
- this.table.attr.apply(this.table, arguments);
- },
-
- populate: function () {
- this.pager.populate();
- this.table.populate.apply(this.table, arguments);
- },
-
- destroy: function () {
- this.table.destroy();
- this.pager && this.pager.destroy();
- BI.PageTable.superclass.destroy.apply(this, arguments);
- }
-});
-BI.shortcut('bi.page_table', BI.PageTable);/**
- * 路径选择
- *
- * Created by GUY on 2015/12/4.
- * @class BI.PathChooser
- * @extends BI.Widget
- */
-BI.PathChooser = BI.inherit(BI.Widget, {
-
- _const: {
- lineColor: "#d4dadd",
- selectLineColor: "#3f8ce8"
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-path-chooser",
- items: []
- })
- },
-
- _init: function () {
- BI.PathChooser.superclass._init.apply(this, arguments);
- this.populate(this.options.items);
- },
-
- _createRegions: function (regions) {
- var self = this;
- this.regions = BI.createWidgets(BI.map(regions, function (i, region) {
- return {
- type: "bi.path_region",
- title: self.texts[region] || region
- }
- }));
- this.regionMap = {};
- BI.each(regions, function (i, region) {
- self.regionMap[region] = i;
- });
- this.container = BI.createWidget({
- type: "bi.horizontal",
- verticalAlign: "top",
- scrollx: false,
- scrolly: false,
- hgap: 10,
- items: this.regions
- });
- BI.createWidget({
- type: "bi.vertical_adapt",
- element: this,
- scrollable: true,
- hgap: 10,
- items: [this.container]
- });
- },
-
- getRegionIndexById: function (id) {
- var node = this.store[id];
- var regionType = node.get("region");
- return this.regionMap[regionType];
- },
-
- _drawPath: function (start, offset, index) {
- var self = this;
- var starts = [];
- if (BI.contains(this.start, start)) {
- starts = this.start;
- } else {
- starts = [start];
- }
-
- BI.each(starts, function (i, s) {
- BI.each(self.radios[s], function (i, rad) {
- rad.setSelected(false);
- });
- BI.each(self.lines[s], function (i, line) {
- line.attr("stroke", self._const.lineColor);
- });
- BI.each(self.regionIndexes[s], function (i, idx) {
- self.regions[idx].reset();
- });
- });
-
- BI.each(this.routes[start][index], function (i, id) {
- var regionIndex = self.getRegionIndexById(id);
- self.regions[regionIndex].setSelect(offset + index, id);
- });
- var current = BI.last(this.routes[start][index]);
-
- while (current && this.routes[current] && this.routes[current].length === 1) {
- BI.each(this.routes[current][0], function (i, id) {
- var regionIndex = self.getRegionIndexById(id);
- self.regions[regionIndex].setSelect(0, id);
- });
- this.lines[current][0].attr("stroke", self._const.selectLineColor).toFront();
- current = BI.last(this.routes[current][0]);
- }
- this.lines[start][index].attr("stroke", self._const.selectLineColor).toFront();
- this.radios[start] && this.radios[start][index] && this.radios[start][index].setSelected(true);
- },
-
- _drawRadio: function (start, offset, index, x, y) {
- var self = this;
- var radio = BI.createWidget({
- type: "bi.radio",
- cls: "path-chooser-radio",
- selected: offset + index === 0,
- start: start,
- index: index
- });
- radio.on(BI.Radio.EVENT_CHANGE, function () {
- self._drawPath(start, offset, index);
- self.fireEvent(BI.PathChooser.EVENT_CHANGE, start, index);
- });
- if (!this.radios[start]) {
- this.radios[start] = [];
- }
- this.radios[start].push(radio);
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: [{
- el: radio,
- left: x - 6.5,
- top: y - 6.5
- }]
- })
- },
-
- _drawLine: function (start, lines) {
- var self = this;
- if (!this.lines[start]) {
- this.lines[start] = [];
- }
- if (!this.pathes[start]) {
- this.pathes[start] = [];
- }
- var startRegionIndex = this.getRegionIndexById(start);
- //start所在的位置,然后接着往下画其他的路径
- var offset = this.regions[startRegionIndex].getIndexByValue(start);
- BI.each(lines, function (i, line) {
- self.pathes[start][i] = [];
- var idx = i + offset;
- var path = "";
- var stop = 47.5 + 29 * idx;
- var sleft = 50 + 100 * startRegionIndex;
- var radioStartX = sleft, radioStartY = stop;
- var etop = stop;
- var endRegionIndex = self.getRegionIndexById(BI.last(line));
- var endOffset = self.regions[endRegionIndex].getIndexByValue(BI.last(line));
- var eleft = 50 + 100 * endRegionIndex;
- if (BI.contains(self.start, start)) {
- radioStartX = sleft - 50;
- path += "M" + (sleft - 50) + "," + stop;
- self.pathes[start][i].push({
- x: sleft - 50,
- y: stop
- })
- } else if (idx === 0) {
- radioStartX = sleft + 50;
- path += "M" + sleft + "," + stop;
- self.pathes[start][i].push({
- x: sleft,
- y: stop
- })
- } else {
- radioStartX = sleft + 50;
- path += "M" + sleft + "," + 47.5 + "L" + (sleft + 50) + "," + 47.5 + "L" + (sleft + 50) + "," + stop;
- self.pathes[start][i].push({
- x: sleft,
- y: 47.5
- });
- self.pathes[start][i].push({
- x: sleft + 50,
- y: 47.5
- });
- self.pathes[start][i].push({
- x: sleft + 50,
- y: stop
- });
- }
- if (idx > 0) {
- var endY = endOffset * 29 + 47.5;
- path += "L" + (eleft - 50) + "," + etop + "L" + (eleft - 50) + "," + endY + "L" + eleft + "," + endY;
- self.pathes[start][i].push({
- x: eleft - 50,
- y: etop
- });
- self.pathes[start][i].push({
- x: eleft - 50,
- y: endY
- });
- self.pathes[start][i].push({
- x: eleft,
- y: endY
- });
- } else {
- path += "L" + eleft + "," + etop;
- self.pathes[start][i].push({
- x: eleft,
- y: etop
- });
- }
-
- var graph = self.svg.path(path)
- .attr({
- stroke: idx === 0 ? self._const.selectLineColor : self._const.lineColor,
- 'stroke-dasharray': '-'
- });
- self.lines[start].push(graph);
- if (lines.length > 1) {
- self.lines[start][0].toFront();
- }
- //第一个元素无论有多少个都要显示radio
- if (BI.contains(self.start, start)) {
- self.lines[self.regions[0].getValueByIndex(0)][0].toFront();
- }
- if (lines.length > 1 || BI.contains(self.start, start)) {
- self._drawRadio(start, offset, i, radioStartX, radioStartY);
- }
- });
- },
-
- _drawLines: function (routes) {
- var self = this;
- this.lines = {};
- this.pathes = {};
- this.radios = {};
- this.regionIndexes = {};
- BI.each(routes, function (k, route) {
- if (!self.regionIndexes[k]) {
- self.regionIndexes[k] = [];
- }
- BI.each(route, function (i, rs) {
- BI.each(rs, function (j, id) {
- var regionIndex = self.getRegionIndexById(id);
- if (!BI.contains(self.regionIndexes[k], regionIndex)) {
- self.regionIndexes[k].push(regionIndex);
- }
- });
- })
- });
- BI.each(routes, function (k, route) {
- self._drawLine(k, route);
- });
- },
-
- _pushNodes: function (nodes) {
- var self = this;
- var indexes = [];
- for (var i = 0; i < nodes.length; i++) {
- var id = nodes[i];
- var index = self.getRegionIndexById(id);
- indexes.push(index);
- var region = self.regions[index];
- if (i === nodes.length - 1) {
- if (!region.hasItem(id)) {
- region.addItem(id, self.texts[id]);
- }
- break;
- }
- if (i > 0 || BI.contains(self.start, id)) {
- region.addItem(id, self.texts[id]);
- }
- }
- for (var i = BI.first(indexes); i < BI.last(indexes); i++) {
- if (!BI.contains(indexes, i)) {
- self.regions[i].addItem("");
- }
- }
- },
-
- _createNodes: function () {
- var self = this, o = this.options;
- this.store = {};
- this.texts = {};
- this.start = [];
- this.end = [];
- BI.each(o.items, function (i, item) {
- self.start.push(BI.first(item).value);
- self.end.push(BI.last(item).value);
- });
- this.start = BI.uniq(this.start);
- this.end = BI.uniq(this.end);
- var regions = [];
- var tree = new BI.Tree();
- var branches = {}, max = 0;
- BI.each(o.items, function (i, items) {
- BI.each(items, function (j, item) {
- if (!BI.has(branches, item.value)) {
- branches[item.value] = 0;
- }
- branches[item.value]++;
- max = Math.max(max, branches[item.value]);
- var prev = {};
- if (j > 0) {
- prev = items[j - 1];
- }
- var parent = self.store[prev.value || ""];
- var node = self.store[item.value] || new BI.Node(item.value);
- node.set(item);
- self.store[item.value] = node;
- self.texts[item.value] = item.text;
- self.texts[item.region] = item.regionText;
- parent = BI.isNull(parent) ? tree.getRoot() : parent;
- if (parent.getChildIndex(item.value) === -1) {
- tree.addNode(parent, node);
- }
- })
- });
-
- //算出区域列表
- tree.traverse(function (node) {
- BI.each(node.getChildren(), function (i, child) {
- if (BI.contains(regions, child.get("region"))) {
- var index1 = BI.indexOf(regions, node.get("region"));
- var index2 = BI.indexOf(regions, child.get("region"));
- //交换区域
- if (index1 > index2) {
- var t = regions[index2];
- for (var j = index2; j < index1; j++) {
- regions[j] = regions[j + 1];
- }
- regions[index1] = t;
- }
- } else {
- regions.push(child.get("region"));
- }
- });
- });
- this._createRegions(regions);
-
- //算出节点
- BI.each(branches, function (k, branch) {
- if (branch < max) {
- delete branches[k];
- }
- });
-
- //过滤节点
- var nodes = [];
- var n = tree.getRoot();
- while (n && n.getChildrenLength() === 1) {
- if (BI.has(branches, n.getChildren()[0].id)) {
- delete branches[n.getChildren()[0].id];
- n = n.getChildren()[0];
- } else {
- n = null;
- }
- }
- tree.traverse(function (node) {
- if (BI.has(branches, node.id)) {
- nodes.push(node.id);
- delete branches[node.id];
- }
- });
-
- //填充节点
- var routes = {};
- var s, e;
- for (var i = 0, len = nodes.length; i < len + 1; i++) {
- if (len === 0) {
- s = [];
- BI.each(this.start, function (i, id) {
- s.push(tree.search(id));
- });
- e = [];
- BI.each(this.end, function (i, id) {
- e.push(tree.search(id));
- });
- } else if (i === len) {
- s = e;
- e = [];
- BI.each(this.end, function (i, id) {
- e.push(tree.search(id));
- });
- } else if (i === 0) {
- s = [];
- BI.each(this.start, function (i, id) {
- s.push(tree.search(id));
- });
- e = [tree.search(nodes[i])];
- } else {
- s = [tree.search(e[0] || tree.getRoot(), nodes[i - 1])];
- e = [tree.search(s[0], nodes[i])];
- }
- BI.each(s, function (i, n) {
- tree._recursion(n, [n.id], function (node, route) {
- if (BI.contains(e, node)) {
- if (!routes[n.id]) {
- routes[n.id] = [];
- }
- routes[n.id].push(route);
- self._pushNodes(route);
- if (e.length <= 1) {
- return true;
- }
- }
- })
- });
- }
- this.routes = routes;
- this._drawLines(routes);
- },
-
- _unselectAllPath: function () {
- var self = this;
- BI.each(this.radios, function (idx, rad) {
- BI.each(rad, function (i, r) {
- r.setSelected(false);
- });
- });
- BI.each(this.lines, function (idx, line) {
- BI.each(line, function (i, li) {
- li.attr("stroke", self._const.lineColor);
- });
- });
- BI.each(this.regions, function (idx, region) {
- region.reset();
- });
- },
-
- populate: function (items) {
- this.options.items = items || [];
- var self = this;
- this.empty();
- if (this.options.items.length <= 0) {
- return;
- }
- this.svg = BI.createWidget({
- type: "bi.svg"
- });
- this._createNodes();
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: [{
- el: this.svg,
- top: 0,
- left: 0,
- right: 0,
- bottom: 0
- }]
- });
- },
-
- setValue: function (v) {
- this._unselectAllPath();
- var nodes = BI.keys(this.routes), self = this;
- var result = [], array = [];
- BI.each(v, function (i, val) {
- if (BI.contains(nodes, val)) {
- if (array.length > 0) {
- array.push(val);
- result.push(array);
- array = [];
- }
- }
- array.push(val);
- });
- if (array.length > 0) {
- result.push(array);
- }
- //画这n条路径
- BI.each(result, function (idx, path) {
- var start = path[0];
- var index = BI.findIndex(self.routes[start], function (idx, p) {
- if (BI.isEqual(path, p)) {
- return true;
- }
- });
- if (index >= 0) {
- var startRegionIndex = self.getRegionIndexById(start);
- var offset = self.regions[startRegionIndex].getIndexByValue(start);
- self._drawPath(start, offset, index);
- }
- });
- },
-
- getValue: function () {
- var path = [];
- BI.each(this.regions, function (i, region) {
- var val = region.getValue();
- if (BI.isKey(val)) {
- path.push(val);
- }
- });
- return path;
- }
-});
-BI.PathChooser.EVENT_CHANGE = "PathChooser.EVENT_CHANGE";
-BI.shortcut("bi.path_chooser", BI.PathChooser);/**
- * 路径选择区域
- *
- * Created by GUY on 2015/12/4.
- * @class BI.PathRegion
- * @extends BI.Widget
- */
-BI.PathRegion = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-path-region bi-background",
- width: 80,
- title: ""
- })
- },
-
- _init: function () {
- BI.PathRegion.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.zIndex = 100;
- var title = BI.createWidget({
- type: "bi.label",
- text: o.title,
- title: o.title,
- height: 30
- });
- title.element.css("zIndex", this.zIndex--);
- this.items = [];
- this.vertical = BI.createWidget({
- type: "bi.vertical",
- element: this,
- bgap: 5,
- hgap: 10,
- items: [title]
- })
- },
-
- hasItem: function (val) {
- return BI.any(this.items, function (i, item) {
- return val === item.getValue();
- });
- },
-
- addItem: function (value, text) {
- if (BI.isKey(value)) {
- var label = BI.createWidget({
- type: "bi.label",
- cls: "path-region-label bi-card bi-border bi-list-item-select",
- text: text,
- value: value,
- title: text || value,
- height: 22
- });
- } else {
- var label = BI.createWidget({
- type: "bi.layout",
- height: 24
- });
- }
- label.element.css("zIndex", this.zIndex--);
- this.items.push(label);
- this.vertical.addItem(label);
- if (this.items.length === 1) {
- this.setSelect(0, value);
- }
- },
-
- reset: function () {
- BI.each(this.items, function (i, item) {
- item.element.removeClass("active");
- });
- },
-
- setSelect: function (index, value) {
- this.reset();
- if (this.items.length <= 0) {
- return;
- }
- if (this.items.length === 1) {
- this.items[0].element.addClass("active");
- return;
- }
- if (this.items[index].attr("value") === value) {
- this.items[index].element.addClass("active");
- }
- },
-
- setValue: function (value) {
- this.setSelect(this.getIndexByValue(value), value);
- },
-
- getValueByIndex: function (idx) {
- return this.items[idx].attr("value");
- },
-
- getIndexByValue: function (value) {
- return BI.findIndex(this.items, function (i, item) {
- return item.attr("value") === value;
- });
- },
-
- getValue: function () {
- var res;
- BI.any(this.items, function (i, item) {
- if (item.element.hasClass("active")) {
- res = item.getValue();
- return true;
- }
- });
- return res;
- }
-});
-BI.PathRegion.EVENT_CHANGE = "PathRegion.EVENT_CHANGE";
-BI.shortcut("bi.path_region", BI.PathRegion);/**
- * 预览表列
- *
- * Created by GUY on 2015/12/25.
- * @class BI.PreviewTableCell
- * @extends BI.Widget
- */
-BI.PreviewTableCell = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-preview-table-cell",
- text: ""
- });
- },
-
- _init: function () {
- BI.PreviewTableCell.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- BI.createWidget({
- type: "bi.label",
- element: this,
- textAlign: "left",
- whiteSpace: "normal",
- height: this.options.height,
- text: this.options.text,
- value: this.options.value
- })
- }
-});
-BI.shortcut('bi.preview_table_cell', BI.PreviewTableCell);/**
- * 预览表
- *
- * Created by GUY on 2015/12/25.
- * @class BI.PreviewTableHeaderCell
- * @extends BI.Widget
- */
-BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-preview-table-header-cell",
- text: ""
- });
- },
-
- _init: function () {
- BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- BI.createWidget({
- type: "bi.label",
- element: this,
- textAlign: "left",
- whiteSpace: "normal",
- height: this.options.height,
- text: this.options.text,
- value: this.options.value
- })
- }
-});
-BI.shortcut('bi.preview_table_header_cell', BI.PreviewTableHeaderCell);/**
- * 预览表
- *
- * Created by GUY on 2015/12/25.
- * @class BI.PreviewTable
- * @extends BI.Widget
- */
-BI.PreviewTable = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-preview-table",
- isNeedFreeze: false,
- freezeCols: [],
- rowSize: null,
- columnSize: [],
- headerRowSize: 30,
- header: [],
- items: []
- });
- },
-
- _init: function () {
- BI.PreviewTable.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.table = BI.createWidget({
- type: "bi.table_view",
- element: this,
- isNeedResize: false,
-
- isResizeAdapt: false,
-
- isNeedFreeze: o.isNeedFreeze,
- freezeCols: o.freezeCols,
-
- rowSize: o.rowSize,
- columnSize: o.columnSize,
- headerRowSize: o.headerRowSize,
-
- header: BI.map(o.header, function (i, items) {
- return BI.map(items, function (j, item) {
- return BI.extend({
- type: "bi.preview_table_header_cell"
- }, item);
- });
- }),
- items: BI.map(o.items, function (i, items) {
- return BI.map(items, function (j, item) {
- return BI.extend({
- type: "bi.preview_table_cell"
- }, item);
- });
- })
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
- self._adjustColumns();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
- self._adjustColumns();
- });
- },
-
- //是否有自适应调节的列,即列宽为""
- _hasAdaptCol: function (columnSize) {
- return BI.any(columnSize, function (i, size) {
- return size === "";
- })
- },
-
- _isPercentage: function (columnSize) {
- return columnSize[0] <= 1;
- },
-
- _adjustColumns: function () {
- var self = this, o = this.options;
- if (o.isNeedFreeze === true) {
- //如果存在百分比的情况
- if (this._isPercentage(o.columnSize)) {
- if (this._hasAdaptCol(o.columnSize)) {
- var findCols = [], remain = 0;
- BI.each(o.columnSize, function (i, size) {
- if (size === "") {
- findCols.push(i);
- } else {
- remain += size;
- }
- });
- remain = 1 - remain;
- var average = remain / findCols.length;
- BI.each(findCols, function (i, col) {
- o.columnSize[col] = average;
- });
- }
- var isRight = BI.first(o.freezeCols) !== 0;
- var freezeSize = [], notFreezeSize = [];
- BI.each(o.columnSize, function (i, size) {
- if (o.freezeCols.contains(i)) {
- freezeSize.push(size);
- } else {
- notFreezeSize.push(size);
- }
- });
- var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize);
- BI.each(freezeSize, function (i, size) {
- freezeSize[i] = size / sumFreezeSize;
- });
- BI.each(notFreezeSize, function (i, size) {
- notFreezeSize[i] = size / sumNotFreezeSize;
- });
- this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]);
- this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize)));
- }
- } else {
- //如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100%
- if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) {
- this.table.setRegionColumnSize(["100%"]);
- }
- }
- },
-
- setColumnSize: function (columnSize) {
- return this.table.setColumnSize(columnSize);
- },
-
- getColumnSize: function () {
- return this.table.getColumnSize();
- },
-
- getCalculateColumnSize: function () {
- return this.table.getCalculateColumnSize();
- },
-
- setHeaderColumnSize: function (columnSize) {
- return this.table.setHeaderColumnSize(columnSize);
- },
-
- setRegionColumnSize: function (columnSize) {
- return this.table.setRegionColumnSize(columnSize);
- },
-
- getRegionColumnSize: function () {
- return this.table.getRegionColumnSize();
- },
-
- getCalculateRegionColumnSize: function () {
- return this.table.getCalculateRegionColumnSize();
- },
-
- getCalculateRegionRowSize: function () {
- return this.table.getCalculateRegionRowSize();
- },
-
- getClientRegionColumnSize: function () {
- return this.table.getClientRegionColumnSize();
- },
-
- getScrollRegionColumnSize: function () {
- return this.table.getScrollRegionColumnSize()
- },
-
- getScrollRegionRowSize: function () {
- return this.table.getScrollRegionRowSize()
- },
-
- hasVerticalScroll: function () {
- return this.table.hasVerticalScroll();
- },
-
- setVerticalScroll: function (scrollTop) {
- return this.table.setVerticalScroll(scrollTop);
- },
-
- setLeftHorizontalScroll: function (scrollLeft) {
- return this.table.setLeftHorizontalScroll(scrollLeft)
- },
-
- setRightHorizontalScroll: function (scrollLeft) {
- return this.table.setRightHorizontalScroll(scrollLeft);
- },
-
- getVerticalScroll: function () {
- return this.table.getVerticalScroll();
- },
-
- getLeftHorizontalScroll: function () {
- return this.table.getLeftHorizontalScroll();
- },
-
- getRightHorizontalScroll: function () {
- return this.table.getRightHorizontalScroll();
- },
-
- getColumns: function () {
- return this.table.getColumns();
- },
-
- populate: function (items, header) {
- this.table.populate(items, header);
- }
-});
-BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE";
-BI.shortcut('bi.preview_table', BI.PreviewTable);/**
- * 季度下拉框
- *
- * Created by GUY on 2015/8/28.
- * @class BI.QuarterCombo
- * @extends BI.Widget
- */
-BI.QuarterCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-quarter-combo",
- behaviors: {},
- height: 25
- });
- },
- _init: function () {
- BI.QuarterCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.storeValue = "";
- this.trigger = BI.createWidget({
- type: "bi.quarter_trigger"
- });
-
- this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS, function () {
- self.storeValue = this.getKey();
- });
- this.trigger.on(BI.QuarterTrigger.EVENT_CHANGE, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- });
- this.trigger.on(BI.QuarterTrigger.EVENT_START, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- });
- this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- });
- this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () {
- if (self.combo.isViewVisible()) {
- return;
- }
- if (this.getKey() && this.getKey() !== self.storeValue) {
- self.setValue(this.getKey());
- } else if (!this.getKey()) {
- self.setValue();
- }
- self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
- });
- this.popup = BI.createWidget({
- type: "bi.quarter_popup",
- behaviors: o.behaviors
- });
-
- this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- minWidth: 85,
- el: this.popup
- }
- });
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW);
- });
- },
-
- setValue: function (v) {
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue() || "";
- }
-});
-
-BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.quarter_combo', BI.QuarterCombo);/**
- * 季度展示面板
- *
- * Created by GUY on 2015/9/2.
- * @class BI.QuarterPopup
- * @extends BI.Trigger
- */
-BI.QuarterPopup = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-quarter-popup",
- behaviors: {}
- });
- },
-
- _init: function () {
- BI.QuarterPopup.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- var items = [{
- text: Date._QN[01],
- value: 1
- }, {
- text: Date._QN[2],
- value: 2
- }, {
- text: Date._QN[3],
- value: 3
- }, {
- text: Date._QN[4],
- value: 4
- }];
- items = BI.map(items, function (j, item) {
- return BI.extend(item, {
- type: "bi.text_item",
- cls: "bi-list-item-active",
- textAlign: "left",
- whiteSpace: "nowrap",
- once: false,
- forceSelected: true,
- height: 25
- });
- });
-
- this.quarter = BI.createWidget({
- type: "bi.button_group",
- element: this,
- behaviors: o.behaviors,
- items: BI.createItems(items, {}),
- layouts: [{
- type: "bi.vertical"
- }]
- });
-
- this.quarter.on(BI.Controller.EVENT_CHANGE, function (type) {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- if (type === BI.Events.CLICK) {
- self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
- }
- })
- },
-
- getValue: function () {
- return this.quarter.getValue()[0];
- },
-
- setValue: function (v) {
- this.quarter.setValue([v]);
- }
-});
-BI.QuarterPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.quarter_popup", BI.QuarterPopup);/**
- * 季度trigger
- *
- * Created by GUY on 2015/8/21.
- * @class BI.QuarterTrigger
- * @extends BI.Trigger
- */
-BI.QuarterTrigger = BI.inherit(BI.Trigger, {
- _const: {
- hgap: 4,
- vgap: 2,
- triggerWidth: 30,
- textWidth: 40,
- errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text")
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-quarter-trigger bi-border",
- height: 25
- });
- },
- _init: function () {
- BI.QuarterTrigger.superclass._init.apply(this, arguments);
- var self = this, o = this.options, c = this._const;
- this.editor = BI.createWidget({
- type: "bi.sign_editor",
- height: o.height,
- validationChecker: function (v) {
- return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 4);
- },
- quitChecker: function (v) {
- return false;
- },
- hgap: c.hgap,
- vgap: c.vgap,
- allowBlank: true,
- errorText: c.errorText
- });
- this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
- self.fireEvent(BI.QuarterTrigger.EVENT_FOCUS);
- });
- this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
- self.fireEvent(BI.QuarterTrigger.EVENT_CHANGE);
- });
- this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
- var value = self.editor.getValue();
- if (BI.isNotNull(value)) {
- self.editor.setValue(value);
- self.editor.setTitle(value);
- }
- self.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM);
- });
- this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
- if (self.editor.isValid()) {
- self.editor.blur();
- }
- });
- this.editor.on(BI.SignEditor.EVENT_START, function () {
- self.fireEvent(BI.QuarterTrigger.EVENT_START);
- });
- this.editor.on(BI.SignEditor.EVENT_STOP, function () {
- self.fireEvent(BI.QuarterTrigger.EVENT_STOP);
- });
-
- BI.createWidget({
- element: this,
- type: 'bi.htape',
- items: [
- {
- el: this.editor
- }, {
- el: {
- type: "bi.text_button",
- baseCls: "bi-trigger-quarter-text",
- text: BI.i18nText("BI-Multi_Date_Quarter"),
- width: c.textWidth
- },
- width: c.textWidth
- }, {
- el: {
- type: "bi.trigger_icon_button",
- width: c.triggerWidth
- },
- width: c.triggerWidth
- }
- ]
- });
- },
-
- setValue: function (v) {
- this.editor.setState(v);
- this.editor.setValue(v);
- this.editor.setTitle(v);
- },
-
- getKey: function () {
- return this.editor.getValue();
- }
-});
-BI.QuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS";
-BI.QuarterTrigger.EVENT_CHANGE = "EVENT_CHANGE";
-BI.QuarterTrigger.EVENT_START = "EVENT_START";
-BI.QuarterTrigger.EVENT_STOP = "EVENT_STOP";
-BI.QuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.shortcut("bi.quarter_trigger", BI.QuarterTrigger);/**
- * 关联视图字段Item
- *
- * Created by GUY on 2015/12/23.
- * @class BI.RelationViewItem
- * @extends BI.Widget
- */
-BI.RelationViewItem = BI.inherit(BI.BasicButton, {
-
- _defaultConfig: function () {
- return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-relation-view-item bi-list-item-active",
- height: 25,
- hoverIn: BI.emptyFn,
- hoverOut: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.RelationViewItem.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.element.hover(o.hoverIn, o.hoverOut);
- var items = [];
- if (o.isPrimary) {
- items.push({
- type: "bi.icon",
- width: 16,
- height: 16,
- title: BI.i18nText("BI-Primary_Key")
- });
- }
- items.push({
- type: "bi.label",
- text: o.text,
- value: o.value,
- height: o.height,
- textAlign: "left",
- width: o.isPrimary ? 70 : 90
- });
- BI.createWidget({
- type: "bi.vertical_adapt",
- element: this,
- items: items,
- cls: "primary-key-font",
- lgap: 5
- });
- },
-
- enableHover: function (opt) {
- BI.RelationViewRegion.superclass.enableHover.apply(this, [{
- container: "body"
- }]);
- },
-
- setSelected: function (b) {
- this.element[b ? "addClass" : "removeClass"]("active");
- }
-});
-BI.shortcut('bi.relation_view_item', BI.RelationViewItem);/**
- * 关联视图
- *
- * Created by GUY on 2015/12/22.
- * @class BI.RelationView
- * @extends BI.Widget
- */
-BI.RelationView = BI.inherit(BI.Widget, {
-
- _const: {
- lineColor: "#c4c6c6",
- selectLineColor: "#009de3"
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-relation-view",
- items: []
- });
- },
-
- _init: function () {
- BI.RelationView.superclass._init.apply(this, arguments);
- this.populate(this.options.items);
- },
-
- _calculateWidths: function () {
- var widths = [];
- BI.each(this.views, function (i, items) {
- BI.each(items, function (j, obj) {
- if (!widths[j]) {
- widths[j] = BI.MIN;
- }
- widths[j] = Math.max(widths[j], obj.getWidth());
- })
- });
- return widths;
- },
-
- _calculateHeights: function () {
- var heights = BI.makeArray(BI.size(this.views), BI.MIN);
- BI.each(this.views, function (i, items) {
- BI.each(items, function (j, obj) {
- heights[i] = Math.max(heights[i], obj.getHeight());
- })
- });
- return heights;
- },
-
- _hoverIn: function (target) {
- var self = this, c = this._const;
- BI.each(this.relations, function (start, rs) {
- BI.each(rs, function (end, relation) {
- if (relation[0].primary.value === target || relation[0].foreign.value === target) {
- self.lines[start][end].attr("stroke", c.selectLineColor).toFront();
- self.storeViews[start].setValue(relation[0].primary.value);
- self.storeViews[end].setValue(relation[0].foreign.value);
- }
- });
- });
- },
-
- _hoverOut: function (target) {
- var self = this, c = this._const;
- BI.each(this.relations, function (start, rs) {
- BI.each(rs, function (end, relation) {
- if (relation[0].primary.value === target || relation[0].foreign.value === target) {
- self.lines[start][end].attr("stroke", c.lineColor);
- self.storeViews[start].setValue([]);
- self.storeViews[end].setValue([]);
- }
- });
- });
- },
-
- previewRelationTables: function(relationTables, show) {
- if (!show) {
- BI.each(this.storeViews, function (i, view) {
- view.toggleRegion(true);
- view.setPreviewSelected(false);
- });
- BI.each(this.lines, function (i, lines) {
- BI.each(lines, function (j, line) {
- line.show();
- });
- });
- return;
- }
- BI.each(this.storeViews, function (id, view) {
- if (!relationTables.contains(id)) {
- view.toggleRegion(false);
- } else {
- view.setPreviewSelected(true);
- }
- });
- BI.each(this.lines, function (id, lines) {
- BI.each(lines, function (cId, line) {
- if (!relationTables.contains(id) || !relationTables.contains(cId)) {
- line.hide();
- }
- });
- });
- },
-
- populate: function (items) {
- var self = this, o = this.options, c = this._const;
- o.items = items || [];
- this.empty();
- this.svg = BI.createWidget({
- type: "bi.svg"
- });
-
- //算出所有的区域和关联
- var regions = this.regions = {}, relations = this.relations = {};
- BI.each(items, function (i, item) {
- var pr = item.primary.region, fr = item.foreign && item.foreign.region;
- if (pr && !relations[pr]) {
- relations[pr] = {};
- }
- if (pr && fr && !relations[pr][fr]) {
- relations[pr][fr] = [];
- }
- if (pr && !regions[pr]) {
- regions[pr] = [];
- }
- if (fr && !regions[fr]) {
- regions[fr] = [];
- }
- if (pr && !BI.deepContains(regions[pr], item.primary)) {
- regions[pr].push(item.primary);
- }
- if (fr && !BI.deepContains(regions[fr], item.foreign)) {
- regions[fr].push(item.foreign);
- }
- pr && fr && relations[pr][fr].push(item);
- });
- //求拓扑
- var topology = [];
- var rs = BI.clone(regions), store = {};
- while (!BI.isEmpty(rs)) {
- var clone = BI.clone(rs);
- BI.each(o.items, function (i, item) {
- if (!store[item.primary.region]) {
- delete clone[item.foreign && item.foreign.region];
- }
- });
- topology.push(BI.keys(clone));
- BI.extend(store, clone);
- BI.each(clone, function (k, v) {
- delete rs[k];
- });
- }
- //构建视图
- var views = this.views = {}, storeViews = this.storeViews = {}, indexes = this.indexes = {};
- var verticals = [];
- BI.each(topology, function (i, items) {
- if (!views[i]) {
- views[i] = {};
- }
- var horizontal = [];
- BI.each(items, function (j, region) {
- var items = regions[region];
- views[i][j] = storeViews[region] = BI.createWidget({
- type: "bi.relation_view_region_container",
- value: region,
- header: items[0].regionTitle,
- text: items.length > 0 ? items[0].regionText : "",
- handler: items.length > 0 ? items[0].regionHandler : BI.emptyFn,
- items: items,
- belongPackage: items.length > 0 ? items[0].belongPackage : true
- });
- if (BI.isNotNull(items[0]) && BI.isNotNull(items[0].keyword)) {
- views[i][j].doRedMark(items[0].keyword);
- }
- views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN, function (v) {
- self._hoverIn(v);
- });
- views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, function (v) {
- self._hoverOut(v);
- });
- views[i][j].on(BI.RelationViewRegionContainer.EVENT_PREVIEW, function (v) {
- self.fireEvent(BI.RelationView.EVENT_PREVIEW, region, v);
- });
- indexes[region] = {i: i, j: j};
- horizontal.push(views[i][j]);
- });
- verticals.push({
- type: "bi.horizontal",
- items: horizontal
- })
- });
-
- //求每一行的高度
- var heights = this._calculateHeights();
-
- //求每一列的宽度
- var widths = this._calculateWidths();
-
- //求相对宽度和高度
- var offsetWidths = [0], offsetHeights = [0];
- BI.each(heights, function (i, h) {
- if (i === 0) {
- return;
- }
- offsetHeights[i] = offsetHeights[i - 1] + heights[i - 1];
- });
- BI.each(widths, function (i, w) {
- if (i === 0) {
- return;
- }
- offsetWidths[i] = offsetWidths[i - 1] + widths[i - 1];
- });
-
- //画线
- var lines = this.lines = {};//缓存所有的线
- BI.each(relations, function (start, rs) {
- BI.each(rs, function (end, relation) {
- var startIndex = indexes[start], endIndex = indexes[end];
- var top = 0, right = 1, bottom = 2, left = 3;
- var startDirection = bottom, endDirection = top;
- // if (startIndex.j > endIndex.j) {
- // startDirection = left;
- // endDirection = right;
- // } else if (startIndex.j < endIndex.j) {
- // startDirection = right;
- // endDirection = left;
- // } else if (startIndex.i < endIndex.i) {
- // startDirection = bottom;
- // endDirection = top;
- // } else if (startIndex.i > endIndex.i) {
- // startDirection = top;
- // endDirection = bottom;
- // }
- var draw = function (i, j, direction, isForeign) {
- var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2;
- var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2;
- var path = "", position;
- switch (direction) {
- case top:
- position = isForeign ? views[i][j].getTopRightPosition() : views[i][j].getTopLeftPosition();
- x += position.x;
- y += position.y;
- path = "M" + x + "," + y + "L" + x + "," + (y - 10);
- y -= 10;
- break;
- case right:
- position = views[i][j].getRightPosition();
- x += position.x;
- y += position.y;
- path = "M" + x + "," + y + "L" + (x + 10) + "," + y;
- x += 10;
- break;
- case bottom:
- position = views[i][j].getBottomPosition();
- x += position.x;
- y += position.y;
- path = "M" + x + "," + y + "L" + x + "," + (y + 10);
- y += 10;
- break;
- case left:
- position = views[i][j].getLeftPosition();
- x += position.x;
- y += position.y;
- path = "M" + x + "," + y + "L" + (x - 10) + "," + y;
- x -= 10;
- break;
- }
- return {x: x, y: y, path: path};
- };
- var path = "";
- var si = draw(startIndex.i, startIndex.j, startDirection);
- var ei = draw(endIndex.i, endIndex.j, endDirection, true);
- path += si.path + ei.path;
- if (!lines[start]) {
- lines[start] = {};
- }
- path += "M" + si.x + "," + si.y + "L" + ei.x + "," + ei.y;
- var line = lines[start][end] = self.svg.path(path)
- .attr({"stroke": c.lineColor, "stroke-width": "2"})
- .hover(function () {
- line.attr("stroke", c.selectLineColor).toFront();
- storeViews[start].setValue(relation[0].primary.value);
- storeViews[end].setValue(relation[0].foreign.value);
- }, function () {
- line.attr("stroke", c.lineColor);
- storeViews[start].setValue([]);
- storeViews[end].setValue([]);
- });
- });
- });
- var container = BI.createWidget();
- BI.createWidget({
- type: "bi.vertical",
- element: container,
- items: verticals
- });
- BI.createWidget({
- type: "bi.absolute",
- element: container,
- items: [{
- el: this.svg,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- }]
- });
-
- BI.createWidget({
- type: "bi.center_adapt",
- scrollable: true,
- element: this,
- items: [container]
- });
- }
-});
-BI.RelationView.EVENT_CHANGE = "RelationView.EVENT_CHANGE";
-BI.RelationView.EVENT_PREVIEW = "EVENT_PREVIEW";
-BI.shortcut('bi.relation_view', BI.RelationView);/**
- * Created by Young's on 2017/3/10.
- */
-BI.RelationViewRegionContainer = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-relation-view-region-container",
- width: 150
- });
- },
-
- _init: function () {
- BI.RelationViewRegionContainer.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.region = BI.createWidget({
- type: "bi.relation_view_region",
- value: o.value,
- header: o.header,
- text: o.text,
- handler: o.handler,
- items: o.items,
- belongPackage: o.belongPackage
- });
- this.region.on(BI.RelationViewRegion.EVENT_PREVIEW, function (v) {
- self.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW, v);
- });
- this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN, function (v) {
- self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN, v);
- });
- this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT, function (v) {
- self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, v);
- });
- BI.createWidget({
- type: "bi.vertical",
- element: this,
- items: [this.region],
- width: this.region.getWidth(),
- height: this.region.getHeight()
- });
- },
-
- doRedMark: function () {
- this.region.doRedMark.apply(this.region, arguments);
- },
-
- unRedMark: function () {
- this.region.unRedMark.apply(this.region, arguments);
- },
-
- getWidth: function () {
- return this.region.getWidth();
- },
-
- getHeight: function () {
- return this.region.getHeight();
- },
-
- //获取上方开始划线的位置
- getTopLeftPosition: function () {
- return this.region.getTopLeftPosition();
- },
-
- getTopRightPosition: function () {
- return this.region.getTopRightPosition();
- },
-
- getBottomPosition: function () {
- return this.region.getBottomPosition();
- },
-
- getLeftPosition: function () {
- return this.region.getLeftPosition();
- },
-
- getRightPosition: function () {
- return this.region.getRightPosition();
- },
-
- setValue: function (v) {
- this.region.setValue(v);
- },
-
- toggleRegion: function (v) {
- v === true ? this.region.element.fadeIn() : this.region.element.fadeOut();
- },
-
- setPreviewSelected: function(v) {
- this.region.setPreviewSelected(v);
- }
-});
-BI.RelationViewRegionContainer.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN";
-BI.RelationViewRegionContainer.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT";
-BI.RelationViewRegionContainer.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW";
-BI.shortcut("bi.relation_view_region_container", BI.RelationViewRegionContainer);/**
- * 关联视图
- *
- * Created by GUY on 2015/12/23.
- * @class BI.RelationViewRegion
- * @extends BI.BasicButton
- */
-BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
-
- _defaultConfig: function () {
- return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-relation-view-region cursor-pointer",
- width: 150,
- text: "",
- value: "",
- header: "",
- items: [],
- belongPackage: true
- });
- },
-
- _init: function () {
- BI.RelationViewRegion.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.preview = BI.createWidget({
- type: "bi.icon_button",
- cls: "relation-table-preview-font",
- width: 25,
- height: 25,
- stopPropagation: true
- });
- this.preview.on(BI.IconButton.EVENT_CHANGE, function () {
- self.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW, this.isSelected());
- });
-
- this.title = BI.createWidget({
- type: "bi.label",
- height: 25,
- width: 70,
- text: o.text,
- value: o.value,
- textAlign: "left"
- });
- //title放body上
- if (BI.isKey(o.header)) {
- this.title.setTitle(o.header, {
- container: "body"
- })
- }
-
- this.button_group = BI.createWidget({
- type: "bi.button_group",
- items: this._createItems(o.items),
- layouts: [{
- type: "bi.vertical"
- }]
- });
-
- BI.createWidget({
- type: "bi.vertical",
- element: this,
- items: [{
- type: "bi.vertical",
- cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"),
- items: [{
- type: "bi.vertical_adapt",
- cls: "relation-view-region-title bi-border-bottom",
- items: [this.preview, this.title]
- }, this.button_group]
- }],
- hgap: 25,
- vgap: 20
- })
- },
-
- _createItems: function (items) {
- var self = this;
- return BI.map(items, function (i, item) {
- return BI.extend(item, {
- type: "bi.relation_view_item",
- hoverIn: function () {
- self.setValue(item.value);
- self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value);
- },
- hoverOut: function () {
- self.setValue([]);
- self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT, item.value);
- }
- })
- });
- },
-
- doRedMark: function () {
- this.title.doRedMark.apply(this.title, arguments);
- },
-
- unRedMark: function () {
- this.title.unRedMark.apply(this.title, arguments);
- },
-
- getWidth: function () {
- return this.options.width;
- },
-
- getHeight: function () {
- return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3;
- },
-
- //获取上方开始划线的位置
- getTopLeftPosition: function () {
- return {
- x: 25 + 10,
- y: 20
- }
- },
-
- getTopRightPosition: function () {
- return {
- x: this.getWidth() - 25 - 10,
- y: 20
- }
- },
-
- getBottomPosition: function () {
- return {
- x: 25 + 10,
- y: this.getHeight() - 20
- }
- },
-
- getLeftPosition: function () {
- return {
- x: 25,
- y: 20 + 10
- }
- },
-
- getRightPosition: function () {
- return {
- x: this.getWidth() - 25,
- y: 20 + 10
- }
- },
-
- setValue: function (v) {
- this.button_group.setValue(v);
- },
-
- setPreviewSelected: function(v) {
- this.preview.setSelected(v);
- }
-});
-BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN";
-BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT";
-BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW";
-BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/**
- * 自适应宽度的表格
- *
- * Created by GUY on 2016/2/3.
- * @class BI.ResponisveTable
- * @extends BI.Widget
- */
-BI.ResponisveTable = BI.inherit(BI.Widget, {
-
- _const: {
- perColumnSize: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-responsive-table",
- isNeedFreeze: false,//是否需要冻结单元格
- freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
-
- isNeedMerge: false,//是否需要合并单元格
- mergeCols: [], //合并的单元格列号
- mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
- return BI.isEqual(row1, row2);
- },
-
- columnSize: [],
- headerRowSize: 25,
- footerRowSize: 25,
- rowSize: 25,
-
- regionColumnSize: false,
-
- header: [],
- footer: false,
- items: [], //二维数组
-
- //交叉表头
- crossHeader: [],
- crossItems: []
- });
- },
-
- _init: function () {
- BI.ResponisveTable.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.table = BI.createWidget({
- type: "bi.table_view",
- element: this,
-
- isNeedFreeze: o.isNeedFreeze,
- freezeCols: o.freezeCols,
-
- isNeedMerge: o.isNeedMerge,
- mergeCols: o.mergeCols,
- mergeRule: o.mergeRule,
-
- columnSize: o.columnSize,
- headerRowSize: o.headerRowSize,
- footerRowSize: o.footerRowSize,
- rowSize: o.rowSize,
-
- regionColumnSize: o.regionColumnSize,
-
- header: o.header,
- footer: o.footer,
- items: o.items,
- //交叉表头
- crossHeader: o.crossHeader,
- crossItems: o.crossItems
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
- self._initRegionSize();
- self.table.resize();
- self._resizeHeader();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
- self._resizeRegion();
- self._resizeHeader();
- self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
- self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () {
- self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () {
- //important:在冻结并自适应列宽的情况下要随时变更表头宽度
- if (o.isNeedResize === true && self._isAdaptiveColumn()) {
- self._resizeHeader();
- }
- self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
- self._resizeHeader();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
- });
-
- this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () {
- self._resizeBody();
- self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () {
- self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
- self._resizeRegion();
- self._resizeHeader();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
- });
- },
-
- _initRegionSize: function () {
- var o = this.options;
- if (o.isNeedFreeze === true) {
- var regionColumnSize = this.table.getRegionColumnSize();
- var maxWidth = this.table.element.width();
- if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) {
- var freezeCols = o.freezeCols;
- if (freezeCols.length === 0) {
- this.table.setRegionColumnSize([0, "fill"]);
- } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) {
- var size = maxWidth / 3;
- if (freezeCols.length > o.columnSize.length / 2) {
- size = maxWidth * 2 / 3;
- }
- this.table.setRegionColumnSize([size, "fill"]);
- } else {
- this.table.setRegionColumnSize(["fill", 0]);
- }
- }
- }
- },
-
- _getBlockSize: function () {
- var o = this.options;
- var columnSize = this.table.getCalculateColumnSize();
- if (o.isNeedFreeze === true) {
- var columnSizeLeft = [], columnSizeRight = [];
- BI.each(columnSize, function (i, size) {
- if (o.freezeCols.contains(i)) {
- columnSizeLeft.push(size);
- } else {
- columnSizeRight.push(size);
- }
- });
- //因为有边框,所以加上数组长度的参数调整
- var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length,
- sumRight = BI.sum(columnSizeRight) + columnSizeRight.length;
- return {
- sumLeft: sumLeft,
- sumRight: sumRight,
- left: columnSizeLeft,
- right: columnSizeRight
- }
- }
- return {
- size: columnSize,
- sum: BI.sum(columnSize) + columnSize.length
- };
- },
-
- _isAdaptiveColumn: function (columnSize) {
- return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05);
- },
-
- _resizeHeader: function () {
- var self = this, o = this.options;
- if (o.isNeedFreeze === true) {
- //若是当前处于自适应调节阶段
- if (this._isAdaptiveColumn()) {
- var columnSize = this.table.getCalculateColumnSize();
- this.table.setHeaderColumnSize(columnSize);
- } else {
- var regionColumnSize = this.table.getClientRegionColumnSize();
- var block = this._getBlockSize();
- var sumLeft = block.sumLeft, sumRight = block.sumRight;
- var columnSizeLeft = block.left, columnSizeRight = block.right;
- columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft;
- columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight;
-
- var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight);
- newLeft[newLeft.length - 1] = "";
- newRight[newRight.length - 1] = "";
- this.table.setColumnSize(newLeft.concat(newRight));
-
- block = self._getBlockSize();
- if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) {
- columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1]
- }
- if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) {
- columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1]
- }
-
- self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight));
- }
- } else {
- if (!this._isAdaptiveColumn()) {
- var regionColumnSize = this.table.getClientRegionColumnSize();
- var block = this._getBlockSize();
- var sum = block.sum;
- var size = block.size;
-
- size[size.length - 1] += regionColumnSize[0] - sum;
-
- var newSize = BI.clone(size);
- newSize[newSize.length - 1] = "";
- this.table.setColumnSize(newSize);
- block = this._getBlockSize();
-
- if (size[size.length - 1] < block.size[block.size.length - 1]) {
- size[size.length - 1] = block.size[block.size.length - 1]
- }
- this.table.setColumnSize(size);
- }
- }
- },
-
- _resizeBody: function () {
- if (this._isAdaptiveColumn()) {
- var columnSize = this.table.getCalculateColumnSize();
- this.setColumnSize(columnSize);
- }
- },
-
- _adjustRegion: function () {
- var o = this.options;
- var regionColumnSize = this.table.getCalculateRegionColumnSize();
- if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
- var block = this._getBlockSize();
- var sumLeft = block.sumLeft, sumRight = block.sumRight;
- if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) {
- this.table.setRegionColumnSize([sumLeft, "fill"]);
- }
- this._resizeRegion();
- }
- },
-
- _resizeRegion: function () {
- var o = this.options;
- var regionColumnSize = this.table.getCalculateRegionColumnSize();
- if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
- var maxWidth = this.table.element.width();
- if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) {
- var freezeCols = o.freezeCols;
- var size = maxWidth / 3;
- if (freezeCols.length > o.columnSize.length / 2) {
- size = maxWidth * 2 / 3;
- }
- this.table.setRegionColumnSize([size, "fill"]);
- }
- }
- },
-
-
- resize: function () {
- this.table.resize();
- this._resizeRegion();
- this._resizeHeader();
- },
-
- setColumnSize: function (columnSize) {
- this.table.setColumnSize(columnSize);
- this._adjustRegion();
- this._resizeHeader();
- },
-
- getColumnSize: function () {
- return this.table.getColumnSize();
- },
-
- getCalculateColumnSize: function () {
- return this.table.getCalculateColumnSize();
- },
-
- setHeaderColumnSize: function (columnSize) {
- this.table.setHeaderColumnSize(columnSize);
- this._adjustRegion();
- this._resizeHeader();
- },
-
- setRegionColumnSize: function (columnSize) {
- this.table.setRegionColumnSize(columnSize);
- this._resizeHeader();
- },
-
- getRegionColumnSize: function () {
- return this.table.getRegionColumnSize();
- },
-
- getCalculateRegionColumnSize: function () {
- return this.table.getCalculateRegionColumnSize();
- },
-
- getCalculateRegionRowSize: function () {
- return this.table.getCalculateRegionRowSize();
- },
-
- getClientRegionColumnSize: function () {
- return this.table.getClientRegionColumnSize();
- },
-
- getScrollRegionColumnSize: function () {
- return this.table.getScrollRegionColumnSize();
- },
-
- getScrollRegionRowSize: function () {
- return this.table.getScrollRegionRowSize();
- },
-
- hasVerticalScroll: function () {
- return this.table.hasVerticalScroll();
- },
-
- setVerticalScroll: function (scrollTop) {
- this.table.setVerticalScroll(scrollTop);
- },
-
- setLeftHorizontalScroll: function (scrollLeft) {
- this.table.setLeftHorizontalScroll(scrollLeft);
- },
-
- setRightHorizontalScroll: function (scrollLeft) {
- this.table.setRightHorizontalScroll(scrollLeft);
- },
-
- getVerticalScroll: function () {
- return this.table.getVerticalScroll();
- },
-
- getLeftHorizontalScroll: function () {
- return this.table.getLeftHorizontalScroll();
- },
-
- getRightHorizontalScroll: function () {
- return this.table.getRightHorizontalScroll();
- },
-
- getColumns: function () {
- return this.table.getColumns();
- },
-
- attr: function () {
- BI.ResponisveTable.superclass.attr.apply(this, arguments);
- this.table.attr.apply(this.table, arguments);
- },
-
- populate: function (items) {
- var self = this, o = this.options;
- this.table.populate.apply(this.table, arguments);
- if (o.isNeedFreeze === true) {
- BI.nextTick(function () {
- self._initRegionSize();
- self.table.resize();
- self._resizeHeader();
- });
- }
- }
-});
-BI.shortcut('bi.responsive_table', BI.ResponisveTable);/**
- * 加号表示的组节点
- * Created by GUY on 2015/9/6.
- * @class BI.SelectTreeFirstPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: (conf.baseCls || "") + " bi-select-tree-first-plus-group-node bi-list-item-active",
- logic: {
- dynamic: false
- },
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.checkbox = BI.createWidget({
- type: "bi.first_tree_node_checkbox",
- stopPropagation: true
- });
- this.text = BI.createWidget({
- type: "bi.label",
- textAlign: "left",
- whiteSpace: "nowrap",
- textHeight: o.height,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {
- if (this.isSelected()) {
- self.triggerExpand();
- } else {
- self.triggerCollapse();
- }
- }
- });
- var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
- var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
- width: 25,
- el: this.checkbox
- }, this.text);
- BI.createWidget(BI.extend({
- element: this
- }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
- items: items
- }))));
- },
-
- isOnce: function () {
- return true;
- },
-
- doRedMark: function () {
- this.text.doRedMark.apply(this.text, arguments);
- },
-
- unRedMark: function () {
- this.text.unRedMark.apply(this.text, arguments);
- },
-
- doClick: function () {
- BI.NodeButton.superclass.doClick.apply(this, arguments);
- },
-
- setOpened: function (v) {
- BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.checkbox)) {
- this.checkbox.setSelected(v);
- }
- }
-});
-
-BI.shortcut("bi.select_tree_first_plus_group_node", BI.SelectTreeFirstPlusGroupNode);/**
- * 加号表示的组节点
- * Created by GUY on 2015/9/6.
- * @class BI.SelectTreeLastPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: (conf.baseCls || "") + " bi-select-tree-last-plus-group-node bi-list-item-active",
- logic: {
- dynamic: false
- },
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.checkbox = BI.createWidget({
- type: "bi.last_tree_node_checkbox",
- stopPropagation: true
- })
- this.text = BI.createWidget({
- type: "bi.label",
- textAlign: "left",
- whiteSpace: "nowrap",
- textHeight: o.height,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {
- if (this.isSelected()) {
- self.triggerExpand();
- } else {
- self.triggerCollapse();
- }
- }
- });
- var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
- var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
- width: 25,
- el: this.checkbox
- }, this.text);
- BI.createWidget(BI.extend({
- element: this
- }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
- items: items
- }))));
- },
-
- isOnce: function () {
- return true;
- },
-
- doRedMark: function () {
- this.text.doRedMark.apply(this.text, arguments);
- },
-
- unRedMark: function () {
- this.text.unRedMark.apply(this.text, arguments);
- },
-
- doClick: function () {
- BI.NodeButton.superclass.doClick.apply(this, arguments);
- },
-
- setOpened: function (v) {
- BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.checkbox)) {
- this.checkbox.setSelected(v);
- }
- }
-});
-
-BI.shortcut("bi.select_tree_last_plus_group_node", BI.SelectTreeLastPlusGroupNode);/**
- * 加号表示的组节点
- * Created by GUY on 2015/9/6.
- * @class BI.SelectTreeMidPlusGroupNode
- * @extends BI.NodeButton
- */
-BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
- _defaultConfig: function () {
- var conf = BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
- return BI.extend(conf, {
- baseCls: (conf.baseCls || "") + " bi-select-tree-mid-plus-group-node bi-list-item-active",
- logic: {
- dynamic: false
- },
- id: "",
- pId: "",
- readonly: true,
- open: false,
- height: 25
- })
- },
- _init: function () {
- BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.checkbox = BI.createWidget({
- type: "bi.mid_tree_node_checkbox",
- stopPropagation: true
- });
- this.text = BI.createWidget({
- type: "bi.label",
- textAlign: "left",
- whiteSpace: "nowrap",
- textHeight: o.height,
- height: o.height,
- hgap: o.hgap,
- text: o.text,
- value: o.value,
- py: o.py
- });
- this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {
- if (this.isSelected()) {
- self.triggerExpand();
- } else {
- self.triggerCollapse();
- }
- }
- });
- var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
- var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
- width: 25,
- el: this.checkbox
- }, this.text);
- BI.createWidget(BI.extend({
- element: this
- }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
- items: items
- }))));
- },
-
- isOnce: function () {
- return true;
- },
-
- doRedMark: function () {
- this.text.doRedMark.apply(this.text, arguments);
- },
-
- unRedMark: function () {
- this.text.unRedMark.apply(this.text, arguments);
- },
-
- doClick: function () {
- BI.NodeButton.superclass.doClick.apply(this, arguments);
- },
-
- setOpened: function (v) {
- BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
- if (BI.isNotNull(this.checkbox)) {
- this.checkbox.setSelected(v);
- }
- }
-});
-
-BI.shortcut("bi.select_tree_mid_plus_group_node", BI.SelectTreeMidPlusGroupNode);/**
- * @class BI.SelectTreeCombo
- * @extends BI.Widget
- */
-BI.SelectTreeCombo = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SelectTreeCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-select-tree-combo",
- height: 30,
- text: "",
- items: []
- });
- },
-
- _init: function () {
- BI.SelectTreeCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.single_tree_trigger",
- text: o.text,
- height: o.height,
- items: o.items
- });
-
- this.popup = BI.createWidget({
- type: "bi.select_tree_popup",
- items: o.items
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- adjustLength: 2,
- el: this.trigger,
- popup: {
- el: this.popup
- }
- });
-
- this.combo.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- });
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- },
-
- populate: function (items) {
- this.combo.populate(items);
- }
-});
-
-
-BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo);/**
- * @class BI.SelectTreeExpander
- * @extends BI.Widget
- */
-BI.SelectTreeExpander = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-select-tree-expander",
- trigger: "click",
- toggle: true,
- direction: "bottom",
- isDefaultInit: true,
- el: {},
- popup: {}
- });
- },
-
- _init: function () {
- BI.SelectTreeExpander.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget(BI.extend({stopPropagation: true}, o.el));
- this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {
- if (this.isSelected()) {
- self.expander.setValue([]);
- }
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.expander = BI.createWidget({
- type: "bi.expander",
- element: this,
- trigger: o.trigger,
- toggle: o.toggle,
- direction: o.direction,
- isDefaultInit: o.isDefaultInit,
- el: this.trigger,
- popup: o.popup
- });
- this.expander.on(BI.Controller.EVENT_CHANGE, function (type) {
- if (type === BI.Events.CLICK) {
- self.trigger.setSelected(false);
- }
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- },
-
- setValue: function (v) {
- if (BI.contains(v, this.trigger.getValue())) {
- this.trigger.setSelected(true);
- this.expander.setValue([]);
- } else {
- this.trigger.setSelected(false);
- this.expander.setValue(v);
- }
- },
-
- getValue: function () {
- if (this.trigger.isSelected()) {
- return [this.trigger.getValue()];
- }
- return this.expander.getValue();
- },
-
- populate: function (items) {
- this.expander.populate(items);
- }
-});
-
-BI.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);/**
- * @class BI.SelectTreePopup
- * @extends BI.Pane
- */
-
-BI.SelectTreePopup = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-select-tree-popup",
- tipText: BI.i18nText("BI-No_Selected_Item"),
- items: []
- });
- },
-
- _formatItems: function (nodes, layer) {
- var self = this;
- BI.each(nodes, function (i, node) {
- var extend = {layer: layer};
- node.id = node.id || BI.UUID();
- if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
- switch (i) {
- case 0 :
- extend.type = "bi.select_tree_first_plus_group_node";
- break;
- case nodes.length - 1 :
- extend.type = "bi.select_tree_last_plus_group_node";
- break;
- default :
- extend.type = "bi.select_tree_mid_plus_group_node";
- break;
- }
- BI.defaults(node, extend);
- self._formatItems(node.children);
- } else {
- switch (i) {
- case nodes.length - 1:
- extend.type = "bi.last_tree_leaf_item";
- break;
- default :
- extend.type = "bi.mid_tree_leaf_item";
- }
- BI.defaults(node, extend);
- }
- });
- return nodes;
- },
-
- _init: function () {
- BI.SelectTreePopup.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- this.tree = BI.createWidget({
- type: 'bi.level_tree',
- expander: {
- type: "bi.select_tree_expander",
- isDefaultInit: true
- },
- items: this._formatItems(BI.Tree.transformToTreeFormat(o.items)),
- chooseType: BI.Selection.Single
- });
-
- BI.createWidget({
- type: "bi.vertical",
- element: this,
- items: [this.tree]
- });
-
- this.tree.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.tree.on(BI.LevelTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.SelectTreePopup.EVENT_CHANGE);
- });
-
- this.check();
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.tree.setValue(v);
- },
-
- populate: function (items) {
- BI.SelectTreePopup.superclass.populate.apply(this, arguments);
- this.tree.populate(items);
- }
-});
-
-BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.select_tree_popup", BI.SelectTreePopup);/**
- *
- * Created by GUY on 2016/8/10.
- * @class BI.SequenceTableDynamicNumber
- * @extends BI.SequenceTableTreeNumber
- */
-BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-sequence-table-dynamic-number"
- });
- },
-
- _init: function () {
- BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments);
- },
-
- _formatNumber: function (nodes) {
- var self = this, o = this.options;
- var result = [];
- var count = this._getStart(nodes);
-
- function getLeafCount(node) {
- var cnt = 0;
- if (BI.isNotEmptyArray(node.children)) {
- BI.each(node.children, function (index, child) {
- cnt += getLeafCount(child);
- });
- if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) {
- cnt++;
- }
- } else {
- cnt++;
- }
- return cnt;
- }
-
- var start = 0, top = 0;
- BI.each(nodes, function (i, node) {
- if (BI.isArray(node.children)) {
- BI.each(node.children, function (index, child) {
- var cnt = getLeafCount(child);
- result.push({
- text: count++,
- start: start,
- top: top,
- cnt: cnt,
- index: index,
- height: cnt * o.rowSize
- });
- start += cnt;
- top += cnt * o.rowSize;
- });
- if (BI.isNotEmptyArray(node.values)) {
- result.push({
- text: BI.i18nText("BI-Summary_Values"),
- start: start++,
- top: top,
- cnt: 1,
- isSummary: true,
- height: o.rowSize
- });
- top += o.rowSize;
- }
- }
- });
- return result;
- }
-});
-BI.shortcut('bi.sequence_table_dynamic_number', BI.SequenceTableDynamicNumber);/**
- *
- * Created by GUY on 2016/5/26.
- * @class BI.SequenceTableListNumber
- * @extends BI.Widget
- */
-BI.SequenceTableListNumber = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-sequence-table-list-number",
- isNeedFreeze: false,
- scrollTop: 0,
- startSequence: 1,//开始的序号
- headerRowSize: 25,
- rowSize: 25,
-
- sequenceHeaderCreator: null,
-
- header: [],
- items: [], //二维数组
-
- //交叉表头
- crossHeader: [],
- crossItems: [],
-
- pageSize: 20
- });
- },
-
- _init: function () {
- BI.SequenceTableListNumber.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.start = o.startSequence;
- this.renderedCells = [];
- this.renderedKeys = [];
-
- this.container = BI.createWidget({
- type: "bi.absolute",
- width: 60,
- scrollable: false
- });
-
- this.scrollContainer = BI.createWidget({
- type: "bi.vertical",
- scrollable: false,
- scrolly: false,
- items: [this.container]
- });
-
- this.headerContainer = BI.createWidget({
- type: "bi.absolute",
- cls: "bi-border",
- width: 58,
- scrollable: false
- });
-
- this.layout = BI.createWidget({
- type: "bi.vtape",
- element: this,
- items: [{
- el: this.headerContainer,
- height: o.headerRowSize * o.header.length - 2
- }, {
- el: {type: "bi.layout"},
- height: 2
- }, {
- el: this.scrollContainer
- }]
- });
- this._populate();
- },
-
- _layout: function () {
- var self = this, o = this.options;
- var headerHeight = o.headerRowSize * o.header.length - 2;
- var items = this.layout.attr("items");
- if (o.isNeedFreeze === false) {
- items[0].height = 0;
- items[1].height = 0;
- } else if (o.isNeedFreeze === true) {
- items[0].height = headerHeight;
- items[1].height = 2;
- }
- this.layout.attr("items", items);
- this.layout.resize();
- this.container.setHeight(o.items.length * o.rowSize);
- try {
- this.scrollContainer.element.scrollTop(o.scrollTop);
- } catch (e) {
-
- }
- },
-
- _createHeader: function () {
- var o = this.options;
- BI.createWidget({
- type: "bi.absolute",
- element: this.headerContainer,
- items: [{
- el: o.sequenceHeaderCreator || {
- type: "bi.table_style_cell",
- cls: "sequence-table-title-cell",
- styleGetter: o.headerCellStyleGetter,
- text: BI.i18nText("BI-Number_Index")
- },
- left: 0,
- top: 0,
- right: 0,
- bottom: 0
- }]
- });
- },
-
- _calculateChildrenToRender: function () {
- var self = this, o = this.options;
- var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth());
- var start = Math.floor(scrollTop / o.rowSize);
- var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize);
- var renderedCells = [], renderedKeys = [];
- for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) {
- var index = BI.deepIndexOf(this.renderedKeys, this.start + i);
- var top = i * o.rowSize;
- if (index > -1) {
- if (o.rowSize !== this.renderedCells[index]._height) {
- this.renderedCells[index]._height = o.rowSize;
- this.renderedCells[index].el.setHeight(o.rowSize);
- }
- if (this.renderedCells[index].top !== top) {
- this.renderedCells[index].top = top;
- this.renderedCells[index].el.element.css("top", top + "px");
- }
- renderedCells.push(this.renderedCells[index]);
- } else {
- var child = BI.createWidget(BI.extend({
- type: "bi.table_style_cell",
- cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",
- width: 60,
- height: o.rowSize,
- text: this.start + i,
- styleGetter: function (index) {
- return function () {
- return o.sequenceCellStyleGetter(self.start + i - 1);
- }
- }(cnt)
- }));
- renderedCells.push({
- el: child,
- left: 0,
- top: top,
- _height: o.rowSize
- });
- }
- renderedKeys.push(this.start + i);
- }
-
- //已存在的, 需要添加的和需要删除的
- var existSet = {}, addSet = {}, deleteArray = [];
- BI.each(renderedKeys, function (i, key) {
- if (BI.deepContains(self.renderedKeys, key)) {
- existSet[i] = key;
- } else {
- addSet[i] = key;
- }
- });
- BI.each(this.renderedKeys, function (i, key) {
- if (BI.deepContains(existSet, key)) {
- return;
- }
- if (BI.deepContains(addSet, key)) {
- return;
- }
- deleteArray.push(i);
- });
- BI.each(deleteArray, function (i, index) {
- self.renderedCells[index].el.destroy();
- });
- var addedItems = [];
- BI.each(addSet, function (index) {
- addedItems.push(renderedCells[index])
- });
- BI.createWidget({
- type: "bi.absolute",
- element: this.container,
- items: addedItems
- });
- this.renderedCells = renderedCells;
- this.renderedKeys = renderedKeys;
- },
-
- _populate: function () {
- this.headerContainer.empty();
- this._createHeader();
- this._layout();
- this._calculateChildrenToRender();
- },
-
- setVerticalScroll: function (scrollTop) {
- if (this.options.scrollTop !== scrollTop) {
- this.options.scrollTop = scrollTop;
- try {
- this.scrollContainer.element.scrollTop(scrollTop);
- } catch (e) {
-
- }
- }
- },
-
- getVerticalScroll: function () {
- return this.options.scrollTop;
- },
-
- setVPage: function (v) {
- v = v < 1 ? 1 : v;
- var o = this.options;
- this.start = (v - 1) * o.pageSize + 1;
- },
-
- _restore: function () {
- var o = this.options;
- BI.each(this.renderedCells, function (i, cell) {
- cell.el.destroy();
- });
- this.renderedCells = [];
- this.renderedKeys = [];
- },
-
- restore: function () {
- this._restore();
- },
-
- populate: function (items, header) {
- var o = this.options;
- if (items && items !== this.options.items) {
- o.items = items;
- this._restore();
- }
- if (header && header !== this.options.header) {
- o.header = header;
- }
- this._populate();
- }
-});
-BI.shortcut('bi.sequence_table_list_number', BI.SequenceTableListNumber);/**
- * 带有序号的表格
- *
- * Created by GUY on 2016/5/26.
- * @class BI.SequenceTable
- * @extends BI.Widget
- */
-BI.SequenceTable = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-sequence-table",
- el: {
- type: "bi.adaptive_table"
- },
-
- sequence: {},
-
- isNeedResize: true,
- isResizeAdapt: false,
-
- isNeedFreeze: false,//是否需要冻结单元格
- freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
-
- isNeedMerge: false,//是否需要合并单元格
- mergeCols: [], //合并的单元格列号
- mergeRule: BI.emptyFn,
-
- columnSize: [],
- minColumnSize: [],
- maxColumnSize: [],
- headerRowSize: 25,
- rowSize: 25,
-
- regionColumnSize: [],
-
- headerCellStyleGetter: BI.emptyFn,
- summaryCellStyleGetter: BI.emptyFn,
- sequenceCellStyleGetter: BI.emptyFn,
-
- header: [],
- items: [], //二维数组
-
- //交叉表头
- crossHeader: [],
- crossItems: [],
-
- showSequence: false,
- startSequence: 1//开始的序号
- });
- },
-
- _init: function () {
- BI.SequenceTable.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.sequence = BI.createWidget(o.sequence, {
- type: "bi.sequence_table_list_number",
- invisible: o.showSequence === false,
- startSequence: o.startSequence,
- isNeedFreeze: o.isNeedFreeze,
- header: o.header,
- items: o.items,
- crossHeader: o.crossHeader,
- crossItems: o.crossItems,
- headerRowSize: o.headerRowSize,
- rowSize: o.rowSize,
- width: 60,
- height: o.height && o.height - BI.GridTableScrollbar.SIZE,
-
- headerCellStyleGetter: o.headerCellStyleGetter,
- summaryCellStyleGetter: o.summaryCellStyleGetter,
- sequenceCellStyleGetter: o.sequenceCellStyleGetter
- });
- this.table = BI.createWidget(o.el, {
- type: "bi.adaptive_table",
- width: o.showSequence === true ? o.width - 60 : o.width,
- height: o.height,
- isNeedResize: o.isNeedResize,
- isResizeAdapt: o.isResizeAdapt,
-
- isNeedFreeze: o.isNeedFreeze,
- freezeCols: o.freezeCols,
-
- isNeedMerge: o.isNeedMerge,
- mergeCols: o.mergeCols,
- mergeRule: o.mergeRule,
-
- columnSize: o.columnSize,
- minColumnSize: o.minColumnSize,
- maxColumnSize: o.maxColumnSize,
- headerRowSize: o.headerRowSize,
- rowSize: o.rowSize,
-
- regionColumnSize: o.regionColumnSize,
-
- headerCellStyleGetter: o.headerCellStyleGetter,
- summaryCellStyleGetter: o.summaryCellStyleGetter,
- sequenceCellStyleGetter: o.sequenceCellStyleGetter,
-
- header: o.header,
- items: o.items,
- //交叉表头
- crossHeader: o.crossHeader,
- crossItems: o.crossItems
- });
-
- this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) {
- if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) {
- self.sequence.setVerticalScroll(this.getVerticalScroll());
- self.sequence.populate();
- }
- self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
- o.regionColumnSize = this.getRegionColumnSize();
- o.columnSize = this.getColumnSize();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
- });
- this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
- o.regionColumnSize = this.getRegionColumnSize();
- o.columnSize = this.getColumnSize();
- self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
- });
-
- this.htape = BI.createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: this.sequence,
- left: 0,
- top: 0
- }, {
- el: this.table,
- top: 0,
- left: o.showSequence === true ? 60 : 0
- }]
- });
- this._populate();
- },
-
- _populate: function () {
- var o = this.options;
- this.sequence.attr({
- items: o.items,
- header: o.header,
- crossItems: o.crossItems,
- crossHeader: o.crossHeader
- });
- if (o.showSequence === true) {
- this.sequence.setVisible(true);
- this.table.element.css("left", "60px");
- this.table.setWidth(o.width - 60);
- } else {
- this.sequence.setVisible(false);
- this.table.element.css("left", "0px");
- this.table.setWidth(o.width);
- }
- },
-
- setWidth: function (width) {
- BI.PageTable.superclass.setWidth.apply(this, arguments);
- this.table.setWidth(this.options.showSequence ? width - 60 : width);
- },
-
- setHeight: function (height) {
- BI.PageTable.superclass.setHeight.apply(this, arguments);
- this.table.setHeight(height);
- this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE);
- },
-
- setColumnSize: function (columnSize) {
- this.options.columnSize = columnSize;
- this.table.setColumnSize(columnSize);
- },
-
- getColumnSize: function () {
- return this.table.getColumnSize();
- },
-
- setRegionColumnSize: function (columnSize) {
- this.options.columnSize = columnSize;
- this.table.setRegionColumnSize(columnSize);
- },
-
- getRegionColumnSize: function () {
- return this.table.getRegionColumnSize();
- },
-
- hasLeftHorizontalScroll: function () {
- return this.table.hasLeftHorizontalScroll();
- },
-
- hasRightHorizontalScroll: function () {
- return this.table.hasRightHorizontalScroll();
- },
-
- setLeftHorizontalScroll: function (scrollLeft) {
- this.table.setLeftHorizontalScroll(scrollLeft);
- },
-
- setRightHorizontalScroll: function (scrollLeft) {
- this.table.setRightHorizontalScroll(scrollLeft);
- },
-
- setVerticalScroll: function (scrollTop) {
- this.table.setVerticalScroll(scrollTop);
- this.sequence.setVerticalScroll(scrollTop);
- },
-
- getVerticalScroll: function () {
- return this.table.getVerticalScroll();
- },
-
- setVPage: function (page) {
- this.sequence.setVPage && this.sequence.setVPage(page);
- },
-
- setHPage: function (page) {
- this.sequence.setHPage && this.sequence.setHPage(page);
- },
-
- attr: function () {
- BI.SequenceTable.superclass.attr.apply(this, arguments);
- this.table.attr.apply(this.table, arguments);
- this.sequence.attr.apply(this.sequence, arguments);
- },
-
- restore: function () {
- this.table.restore();
- this.sequence.restore();
- },
-
- populate: function (items, header, crossItems, crossHeader) {
- var o = this.options;
- if (items) {
- o.items = items;
- }
- if (header) {
- o.header = header;
- }
- if (crossItems) {
- o.crossItems = crossItems;
- }
- if (crossHeader) {
- o.crossHeader = crossHeader;
- }
- this._populate();
- this.table.populate.apply(this.table, arguments);
- this.sequence.populate.apply(this.sequence, arguments);
- this.sequence.setVerticalScroll(this.table.getVerticalScroll());
- },
-
- destroy: function () {
- this.table.destroy();
- BI.SequenceTable.superclass.destroy.apply(this, arguments);
- }
-});
-BI.shortcut('bi.sequence_table', BI.SequenceTable);/**
- * @class BI.SingleTreeCombo
- * @extends BI.Widget
- */
-BI.SingleTreeCombo = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-single-tree-combo",
- trigger: {},
- height: 30,
- text: "",
- items: []
- });
- },
-
- _init: function () {
- BI.SingleTreeCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget(BI.extend({
- type: "bi.single_tree_trigger",
- text: o.text,
- height: o.height,
- items: o.items
- }, o.trigger));
-
- this.popup = BI.createWidget({
- type: "bi.single_tree_popup",
- items: o.items
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- adjustLength: 2,
- el: this.trigger,
- popup: {
- el: this.popup
- }
- });
-
- this.combo.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments);
- });
-
- this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE);
- });
- },
-
- populate: function (items) {
- this.combo.populate(items);
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.trigger.setValue(v);
- this.popup.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- }
-});
-
-BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE";
-BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/**
- * @class BI.SingleTreePopup
- * @extends BI.Pane
- */
-
-BI.SingleTreePopup = BI.inherit(BI.Pane, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-single-tree-popup",
- tipText: BI.i18nText("BI-No_Selected_Item"),
- items: []
- });
- },
-
- _init: function () {
- BI.SingleTreePopup.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- this.tree = BI.createWidget({
- type: 'bi.level_tree',
- expander: {
- isDefaultInit: true
- },
- items: o.items,
- chooseType: BI.Selection.Single
- });
-
- BI.createWidget({
- type: "bi.vertical",
- element: this,
- items: [this.tree]
- });
-
- this.tree.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- });
-
- this.tree.on(BI.LevelTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.SingleTreePopup.EVENT_CHANGE);
- });
-
- this.check();
- },
-
- getValue: function () {
- return this.tree.getValue();
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.tree.setValue(v);
- },
-
- populate: function (items) {
- BI.SingleTreePopup.superclass.populate.apply(this, arguments);
- this.tree.populate(items);
- }
-});
-
-BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.single_tree_popup", BI.SingleTreePopup);/**
- * @class BI.SingleTreeTrigger
- * @extends BI.Trigger
- */
-
-BI.SingleTreeTrigger = BI.inherit(BI.Trigger, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-single-tree-trigger",
- height: 30,
- text: "",
- items: []
- });
- },
-
- _init: function () {
- BI.SingleTreeTrigger.superclass._init.apply(this, arguments);
-
- var self = this, o = this.options;
-
- this.trigger = BI.createWidget({
- type: "bi.select_text_trigger",
- element: this,
- text: o.text,
- items: o.items,
- height: o.height
- });
- },
-
- _checkTitle: function () {
- var self = this, val = this.getValue();
- BI.any(this.options.items, function (i, item) {
- if (val.contains(item.value)) {
- self.trigger.setTitle(item.text || item.value);
- return true;
- }
- });
- },
-
- setValue: function (v) {
- v = BI.isArray(v) ? v : [v];
- this.options.value = v;
- this.trigger.setValue(v);
- this._checkTitle();
- },
-
- getValue: function () {
- return this.options.value || [];
- },
-
- populate: function (items) {
- BI.SingleTreeTrigger.superclass.populate.apply(this, arguments);
- this.trigger.populate(items);
- }
-
-});
-
-BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);/**
- * 可以单选多选切换的树
- *
- * Created by GUY on 2015/12/21.
- * @class BI.SwitchTree
- * @extends BI.Widget
- */
-BI.SwitchTree = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-switch-tree",
- items: []
- });
- },
-
- _init: function () {
- BI.SwitchTree.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.tab = BI.createWidget({
- type: "bi.tab",
- element: this,
- tab: null,
- defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect,
- cardCreator: BI.bind(this._createTree, this)
- });
- },
-
- _createTree: function (type) {
- var self = this, o = this.options;
- switch (type) {
- case BI.SwitchTree.SelectType.SingleSelect:
- this.levelTree = BI.createWidget({
- type: "bi.multilayer_single_level_tree",
- isDefaultInit: true,
- items: BI.deepClone(o.items)
- });
- this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments);
- });
- return this.levelTree;
- case BI.SwitchTree.SelectType.MultiSelect:
- this.tree = BI.createWidget({
- type: "bi.simple_tree",
- items: this._removeIsParent(BI.deepClone(o.items))
- });
- this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () {
- self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments);
- });
- return this.tree;
- }
- },
-
- _removeIsParent: function(items) {
- BI.each(items, function(i, item) {
- BI.isNotNull(item.isParent) && delete item.isParent;
- });
- return items;
- },
-
- switchSelect: function () {
- switch (this.getSelect()) {
- case BI.SwitchTree.SelectType.SingleSelect:
- this.setSelect(BI.SwitchTree.SelectType.MultiSelect);
- break;
- case BI.SwitchTree.SelectType.MultiSelect:
- this.setSelect(BI.SwitchTree.SelectType.SingleSelect);
- break;
- }
- },
-
- setSelect: function (v) {
- this.tab.setSelect(v);
- },
-
- getSelect: function () {
- return this.tab.getSelect();
- },
-
- setValue: function (v) {
- this.storeValue = v;
- switch (this.getSelect()) {
- case BI.SwitchTree.SelectType.SingleSelect:
- this.levelTree.setValue(v);
- break;
- case BI.SwitchTree.SelectType.MultiSelect:
- this.tree.setValue(v);
- break;
- }
- },
-
- getValue: function () {
- return this.tab.getValue();
- },
-
- populate: function (items) {
- this.options.items = items;
- if (BI.isNotNull(this.levelTree)) {
- this.levelTree.populate(BI.deepClone(items));
- }
- if (BI.isNotNull(this.tree)) {
- this.tree.populate(this._removeIsParent(BI.deepClone(items)));
- }
- }
-});
-BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE";
-BI.SwitchTree.SelectType = {
- SingleSelect: BI.Selection.Single,
- MultiSelect: BI.Selection.Multi
-};
-BI.shortcut('bi.switch_tree', BI.SwitchTree);
-/**
- * 年份下拉框
- *
- * Created by GUY on 2015/8/28.
- * @class BI.YearCombo
- * @extends BI.Widget
- */
-BI.YearCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-year-combo",
- behaviors: {},
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- height: 25
- });
- },
- _init: function () {
- BI.YearCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.storeValue = "";
- this.trigger = BI.createWidget({
- type: "bi.year_trigger",
- min: o.min,
- max: o.max
- });
- this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () {
- self.storeValue = this.getKey();
- });
- this.trigger.on(BI.YearTrigger.EVENT_START, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- });
- this.trigger.on(BI.YearTrigger.EVENT_STOP, function () {
- self.combo.showView();
- });
- this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- });
- this.trigger.on(BI.YearTrigger.EVENT_CONFIRM, function () {
- if (self.combo.isViewVisible()) {
- return;
- }
- if (this.getKey() && this.getKey() !== self.storeValue) {
- self.setValue(this.getKey());
- } else if (!this.getKey()) {
- self.setValue();
- }
- self.fireEvent(BI.YearCombo.EVENT_CONFIRM);
- });
-
- this.combo = BI.createWidget({
- type: "bi.combo",
- element: this,
- destroyWhenHide: true,
- isNeedAdjustHeight: false,
- isNeedAdjustWidth: false,
- el: this.trigger,
- popup: {
- minWidth: 85,
- stopPropagation: false,
- el: {
- type: "bi.year_popup",
- ref: function () {
- self.popup = this;
- },
- listeners: [{
- eventName: BI.YearPopup.EVENT_CHANGE,
- action: function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.YearCombo.EVENT_CONFIRM);
- }
- }],
- behaviors: o.behaviors,
- min: o.min,
- max: o.max
- }
- }
- });
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- var value = self.trigger.getKey();
- if (BI.isNotNull(value)) {
- self.popup.setValue(value);
- } else if (!value && value !== self.storeValue) {
- self.popup.setValue(self.storeValue);
- } else {
- self.setValue();
- }
- self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW);
- });
- },
-
- setValue: function (v) {
- this.combo.setValue(v);
- },
-
- getValue: function () {
- return this.popup.getValue();
- }
-});
-BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.year_combo', BI.YearCombo);/**
- * 年份展示面板
- *
- * Created by GUY on 2015/9/2.
- * @class BI.YearPopup
- * @extends BI.Trigger
- */
-BI.YearPopup = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-year-popup",
- behaviors: {},
- min: '1900-01-01', //最小日期
- max: '2099-12-31' //最大日期
- });
- },
-
- _createYearCalendar: function (v) {
- var o = this.options, y = this._year;
-
- var calendar = BI.createWidget({
- type: "bi.year_calendar",
- behaviors: o.behaviors,
- min: o.min,
- max: o.max,
- logic: {
- dynamic: true
- },
- year: y + v * 12
- });
- calendar.setValue(this._year);
- return calendar;
- },
-
- _init: function () {
- BI.YearPopup.superclass._init.apply(this, arguments);
- var self = this;
-
- this.selectedYear = this._year = new Date().getFullYear();
-
- var backBtn = BI.createWidget({
- type: "bi.icon_button",
- cls: "pre-page-h-font",
- width: 25,
- height: 25,
- value: -1
- });
-
- var preBtn = BI.createWidget({
- type: "bi.icon_button",
- cls: "next-page-h-font",
- width: 25,
- height: 25,
- value: 1
- });
-
- this.navigation = BI.createWidget({
- type: "bi.navigation",
- element: this,
- single: true,
- logic: {
- dynamic: true
- },
- tab: {
- cls: "year-popup-navigation bi-high-light bi-border-top",
- height: 25,
- items: [backBtn, preBtn]
- },
- cardCreator: BI.bind(this._createYearCalendar, this),
-
- afterCardShow: function () {
- this.setValue(self.selectedYear);
- var calendar = this.getSelectedCard();
- backBtn.setEnable(!calendar.isFrontYear());
- preBtn.setEnable(!calendar.isFinalYear());
- }
- });
-
- this.navigation.on(BI.Navigation.EVENT_CHANGE, function () {
- self.selectedYear = this.getValue();
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
- self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear);
- });
- },
-
- getValue: function () {
- return this.selectedYear;
- },
-
- setValue: function (v) {
- var o = this.options;
- if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) {
- v = new Date().getFullYear();
- this.selectedYear = "";
- this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
- this.navigation.setValue("");
- } else {
- this.selectedYear = v;
- this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
- this.navigation.setValue(v);
- }
- }
-});
-BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.year_popup", BI.YearPopup);/**
- * 年份trigger
- *
- * Created by GUY on 2015/8/21.
- * @class BI.YearTrigger
- * @extends BI.Trigger
- */
-BI.YearTrigger = BI.inherit(BI.Trigger, {
- _const: {
- hgap: 4,
- vgap: 2,
- triggerWidth: 25,
- errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
- errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text")
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), {
- extraCls: "bi-year-trigger bi-border",
- min: '1900-01-01', //最小日期
- max: '2099-12-31', //最大日期
- height: 25
- });
- },
- _init: function () {
- BI.YearTrigger.superclass._init.apply(this, arguments);
- var self = this, o = this.options, c = this._const;
- this.editor = BI.createWidget({
- type: "bi.sign_editor",
- height: o.height,
- validationChecker: function (v) {
- self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid);
- return v === "" || (BI.isPositiveInteger(v) && !Date.checkVoid(v, 1, 1, o.min, o.max)[0]);
- },
- quitChecker: function (v) {
- return false;
- },
- hgap: c.hgap,
- vgap: c.vgap,
- allowBlank: true,
- errorText: c.errorText
- })
- this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
- self.fireEvent(BI.YearTrigger.EVENT_FOCUS);
- });
- this.editor.on(BI.SignEditor.EVENT_STOP, function () {
- self.fireEvent(BI.YearTrigger.EVENT_STOP);
- });
- this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
- var value = self.editor.getValue();
- if (BI.isNotNull(value)) {
- self.editor.setValue(value);
- self.editor.setTitle(value);
- }
- self.fireEvent(BI.YearTrigger.EVENT_CONFIRM);
- });
- this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
- if (self.editor.isValid()) {
- self.editor.blur();
- }
- });
- this.editor.on(BI.SignEditor.EVENT_START, function () {
- self.fireEvent(BI.YearTrigger.EVENT_START);
- });
- this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
- self.fireEvent(BI.YearTrigger.EVENT_ERROR);
- });
- BI.createWidget({
- element: this,
- type: 'bi.htape',
- items: [
- {
- el: this.editor
- }, {
- el: {
- type: "bi.text_button",
- baseCls: "bi-trigger-year-text",
- text: BI.i18nText("BI-Multi_Date_Year"),
- width: c.triggerWidth
- },
- width: c.triggerWidth
- }, {
- el: {
- type: "bi.trigger_icon_button",
- width: c.triggerWidth
- },
- width: c.triggerWidth
- }
- ]
- });
- },
- setValue: function (v) {
- this.editor.setState(v);
- this.editor.setValue(v);
- this.editor.setTitle(v);
- },
- getKey: function () {
- return this.editor.getValue() | 0;
- }
-});
-BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS";
-BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR";
-BI.YearTrigger.EVENT_START = "EVENT_START";
-BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.YearTrigger.EVENT_STOP = "EVENT_STOP";
-BI.shortcut("bi.year_trigger", BI.YearTrigger);/**
- * 年份 + 月份下拉框
- *
- * @class BI.YearMonthCombo
- * @extends BI.Widget
- */
-BI.YearMonthCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-year-month-combo",
- yearBehaviors: {},
- monthBehaviors: {},
- height: 25
- });
- },
- _init: function () {
- BI.YearMonthCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.year = BI.createWidget({
- type: "bi.year_combo",
- behaviors: o.yearBehaviors
- });
-
- this.month = BI.createWidget({
- type: "bi.month_combo",
- behaviors: o.monthBehaviors
- });
-
- this.year.on(BI.YearCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
- });
- this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW);
- });
-
- this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
- });
- this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW);
- });
-
- BI.createWidget({
- type: "bi.center",
- element: this,
- hgap: 5,
- items: [this.year, this.month]
- });
-
- },
-
- setValue: function (v) {
- v = v || {};
- this.month.setValue(v.month);
- this.year.setValue(v.year);
- },
-
- getValue: function () {
- return {
- year: this.year.getValue(),
- month: this.month.getValue()
- };
- }
-});
-BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/**
- * 年份 + 月份下拉框
- *
- * @class BI.YearQuarterCombo
- * @extends BI.Widget
- */
-BI.YearQuarterCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function () {
- return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-year-quarter-combo",
- yearBehaviors: {},
- quarterBehaviors: {},
- height: 25
- });
- },
- _init: function () {
- BI.YearQuarterCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
-
- this.year = BI.createWidget({
- type: "bi.year_combo",
- behaviors: o.yearBehaviors
- });
-
- this.quarter = BI.createWidget({
- type: "bi.quarter_combo",
- behaviors: o.quarterBehaviors
- });
-
- this.year.on(BI.YearCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM);
- });
- this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
- });
-
- this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM);
- });
- this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
- });
-
- BI.createWidget({
- type: "bi.center",
- element: this,
- hgap: 5,
- items: [this.year, this.quarter]
- });
-
- },
-
- setValue: function (v) {
- v = v || {};
- this.quarter.setValue(v.quarter);
- this.year.setValue(v.year);
- },
-
- getValue: function () {
- return {
- year: this.year.getValue(),
- quarter: this.quarter.getValue()
- };
- }
-});
-BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/**
- * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AbstractAllValueChooser
- * @extends BI.Widget
- */
-BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
-
- _const: {
- perPage: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), {
- width: 200,
- height: 30,
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _valueFormatter: function (v) {
- var text = v;
- if (BI.isNotNull(this.items)) {
- BI.some(this.items, function (i, item) {
- if (item.value === v) {
- text = item.text;
- return true;
- }
- });
- }
- return text;
- },
-
- _itemsCreator: function (options, callback) {
- var self = this, o = this.options;
- if (!o.cache || !this.items) {
- o.itemsCreator({}, function (items) {
- self.items = items;
- call(items);
- });
- } else {
- call(this.items);
- }
- function call(items) {
- var keywords = (options.keywords || []).slice();
- if (options.keyword) {
- keywords.push(options.keyword);
- }
- BI.each(keywords, function (i, kw) {
- var search = BI.Func.getSearchResult(items, kw);
- items = search.matched.concat(search.finded);
- });
- if (options.selectedValues) {//过滤
- var filter = BI.makeObject(options.selectedValues, true);
- items = BI.filter(items, function (i, ob) {
- return !filter[ob.value];
- });
- }
- if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
- callback({
- items: items
- });
- return;
- }
- if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
- callback({count: items.length});
- return;
- }
- callback({
- items: items,
- hasNext: false
- });
- }
- }
-});/**
- * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AllValueChooserCombo
- * @extends BI.AbstractAllValueChooser
- */
-BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-all-value-chooser-combo",
- width: 200,
- height: 30,
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _init: function () {
- BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
- this.items = o.items;
- }
- this.combo = BI.createWidget({
- type: 'bi.multi_select_combo',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
- width: o.width,
- height: o.height
- });
-
- this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
- });
- },
-
- setValue: function (v) {
- this.combo.setValue({
- type: BI.Selection.Multi,
- value: v || []
- });
- },
-
- getValue: function () {
- var val = this.combo.getValue() || {};
- if (val.type === BI.Selection.All) {
- return val.assist;
- }
- return val.value || [];
- },
-
- populate: function () {
- this.combo.populate.apply(this, arguments);
- }
-});
-BI.AllValueChooserCombo.EVENT_CONFIRM = "AllValueChooserCombo.EVENT_CONFIRM";
-BI.shortcut('bi.all_value_chooser_combo', BI.AllValueChooserCombo);/**
- * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AllValueChooserPane
- * @extends BI.AbstractAllValueChooser
- */
-BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-all-value-chooser-pane",
- width: 200,
- height: 30,
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _init: function () {
- BI.AllValueChooserPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
- this.items = o.items;
- }
- this.list = BI.createWidget({
- type: 'bi.multi_select_list',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
- width: o.width,
- height: o.height
- });
-
- this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE);
- });
- },
-
- setValue: function (v) {
- this.list.setValue({
- type: BI.Selection.Multi,
- value: v || []
- });
- },
-
- getValue: function () {
- var val = this.list.getValue() || {};
- if (val.type === BI.Selection.All) {
- return val.assist;
- }
- return val.value || [];
- },
-
- populate: function () {
- this.list.populate.apply(this.list, arguments);
- }
-});
-BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE";
-BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
-
- _const: {
- perPage: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), {
- items: null,
- itemsCreator: BI.emptyFn
- });
- },
-
- _initData: function (items) {
- this.items = items;
- var nodes = BI.Tree.treeFormat(items);
- this.tree = new BI.Tree();
- this.tree.initTree(nodes);
- },
-
- _itemsCreator: function (options, callback) {
- var self = this, o = this.options;
- if (!this.items) {
- o.itemsCreator({}, function (items) {
- self._initData(items);
- call();
- });
- } else {
- call();
- }
- function call() {
- switch (options.type) {
- case BI.TreeView.REQ_TYPE_INIT_DATA:
- self._reqInitTreeNode(options, callback);
- break;
- case BI.TreeView.REQ_TYPE_ADJUST_DATA:
- self._reqAdjustTreeNode(options, callback);
- break;
- case BI.TreeView.REQ_TYPE_SELECT_DATA:
- self._reqSelectedTreeNode(options, callback);
- break;
- case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA:
- self._reqDisplayTreeNode(options, callback);
- break;
- default :
- self._reqTreeNode(options, callback);
- break;
- }
- }
- },
-
- _reqDisplayTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var selectedValues = op.selectedValues;
-
- if (selectedValues == null || BI.isEmpty(selectedValues)) {
- callback({});
- return;
- }
-
- doCheck([], this.tree.getRoot(), selectedValues);
-
- callback({
- items: result
- });
-
- function doCheck(parentValues, node, selected) {
- if (selected == null || BI.isEmpty(selected)) {
- BI.each(node.getChildren(), function (i, child) {
- var newParents = BI.clone(parentValues);
- newParents.push(child.value);
- var llen = self._getChildCount(newParents);
- createOneJson(child, node.id, llen);
- doCheck(newParents, child, {});
- });
- return;
- }
- BI.each(selected, function (k) {
- var node = self._getTreeNode(parentValues, k);
- var newParents = BI.clone(parentValues);
- newParents.push(node.value);
- createOneJson(node, node.parent && node.parent.id, getCount(selected[k], newParents));
- doCheck(newParents, node, selected[k]);
- })
- }
-
- function getCount(jo, parentValues) {
- if (jo == null) {
- return 0;
- }
- if (BI.isEmpty(jo)) {
- return self._getChildCount(parentValues);
- }
-
- return BI.size(jo);
- }
-
- function createOneJson(node, pId, llen) {
- result.push({
- id: node.id,
- pId: pId,
- text: node.text + (llen > 0 ? ("(" + BI.i18nText("BI-Basic_Altogether") + llen + BI.i18nText("BI-Basic_Count") + ")") : ""),
- value: node.value,
- open: true
- });
- }
- },
-
- _reqSelectedTreeNode: function (op, callback) {
- var self = this;
- var selectedValues = BI.deepClone(op.selectedValues);
- var notSelectedValue = op.notSelectedValue || {};
- var keyword = op.keyword || "";
- var parentValues = op.parentValues || [];
-
- if (selectedValues == null || BI.isEmpty(selectedValues)) {
- callback({});
- return;
- }
-
- dealWithSelectedValues(selectedValues);
- callback(selectedValues);
-
-
- function dealWithSelectedValues(selectedValues) {
- var p = parentValues.concat(notSelectedValue);
- //存储的值中存在这个值就把它删掉
- //例如选中了中国-江苏-南京, 取消中国或江苏或南京
- if (canFindKey(selectedValues, p)) {
- //如果搜索的值在父亲链中
- if (isSearchValueInParent(p)) {
- //例如选中了 中国-江苏, 搜索江苏, 取消江苏
- //例如选中了 中国-江苏, 搜索江苏, 取消中国
- self._deleteNode(selectedValues, p);
- } else {
- var searched = [];
- var finded = search(parentValues, notSelectedValue, [], searched);
- if (finded && BI.isNotEmptyArray(searched)) {
- BI.each(searched, function (i, arr) {
- var node = self._getNode(selectedValues, arr);
- if (node) {
- //例如选中了 中国-江苏-南京,搜索南京,取消中国
- self._deleteNode(selectedValues, arr);
- } else {
- //例如选中了 中国-江苏,搜索南京,取消中国
- expandSelectedValue(selectedValues, arr, BI.last(arr));
- }
- })
- }
- }
- }
-
- //存储的值中不存在这个值,但父亲节点是全选的情况
- //例如选中了中国-江苏,取消南京
- //important 选中了中国-江苏,取消了江苏,但是搜索的是南京
- if (isChild(selectedValues, p)) {
- var result = [], finded = false;
- //如果parentValues中有匹配的值,说明搜索结果不在当前值下
- if (isSearchValueInParent(p)) {
- finded = true;
- } else {
- //从当前值开始搜
- finded = search(parentValues, notSelectedValue, result);
- p = parentValues;
- }
-
- if (finded === true) {
- //去掉点击的节点之后的结果集
- expandSelectedValue(selectedValues, p, notSelectedValue);
- //添加去掉搜索的结果集
- if (result.length > 0) {
- BI.each(result, function (i, strs) {
- self._buildTree(selectedValues, strs);
- })
- }
- }
- }
-
- }
-
- function expandSelectedValue(selectedValues, parents, notSelectedValue) {
- var next = selectedValues;
- var childrenCount = [];
- var path = [];
- //去掉点击的节点之后的结果集
- BI.some(parents, function (i, v) {
- var t = next[v];
- if (t == null) {
- if (i === 0) {
- return true;
- }
- if (BI.isEmpty(next)) {
- var split = parents.slice(0, i);
- var expanded = self._getChildren(split);
- path.push(split);
- childrenCount.push(expanded.length);
- //如果只有一个值且取消的就是这个值
- if (i === parents.length - 1 && expanded.length === 1 && expanded[0] === notSelectedValue) {
- for (var j = childrenCount.length - 1; j >= 0; j--) {
- if (childrenCount[j] === 1) {
- self._deleteNode(selectedValues, path[j]);
- } else {
- break;
- }
- }
- } else {
- BI.each(expanded, function (m, child) {
- if (i === parents.length - 1 && child.value === notSelectedValue) {
- return true;
- }
- next[child.value] = {};
- });
- }
- next = next[v];
- } else {
- return true;
- // next = {};
- // next[v] = {};
- }
- } else {
- next = t;
- }
- });
- }
-
- function search(parents, current, result, searched) {
- var newParents = BI.clone(parents);
- newParents.push(current);
- if (self._isMatch(current, keyword)) {
- searched && searched.push(newParents);
- return true;
- }
-
- var children = self._getChildren(newParents);
-
- var notSearch = [];
- var can = false;
-
- BI.each(children, function (i, child) {
- if (search(newParents, child.value, result, searched)) {
- can = true;
- } else {
- notSearch.push(child.value);
- }
- });
- if (can === true) {
- BI.each(notSearch, function (i, v) {
- var next = BI.clone(newParents);
- next.push(v);
- result.push(next);
- });
- }
- return can;
- }
-
- function isSearchValueInParent(parentValues) {
- for (var i = 0, len = parentValues.length; i < len; i++) {
- if (self._isMatch(parentValues[i], keyword)) {
- return true;
- }
- }
- return false;
- }
-
- function canFindKey(selectedValues, parents) {
- var t = selectedValues;
- for (var i = 0; i < parents.length; i++) {
- var v = parents[i];
- t = t[v];
- if (t == null) {
- return false;
- }
- }
- return true;
- }
-
- function isChild(selectedValues, parents) {
- var t = selectedValues;
- for (var i = 0; i < parents.length; i++) {
- var v = parents[i];
- if (!BI.has(t, v)) {
- return false;
- }
- t = t[v];
- if (BI.isEmpty(t)) {
- return true;
- }
- }
- return false;
- }
- },
-
- _reqAdjustTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var selectedValues = op.selectedValues;
- if (selectedValues == null || BI.isEmpty(selectedValues)) {
- callback({});
- return;
- }
- BI.each(selectedValues, function (k, v) {
- result.push([k]);
- });
-
- dealWithSelectedValues(selectedValues, []);
-
- var jo = {};
- BI.each(result, function (i, strs) {
- self._buildTree(jo, strs);
- });
- callback(jo);
-
- function dealWithSelectedValues(selected, parents) {
- if (selected == null || BI.isEmpty(selected)) {
- return true;
- }
- var can = true;
- BI.each(selected, function (k, v) {
- var p = BI.clone(parents);
- p.push(k);
- if (!dealWithSelectedValues(selected[k], p)) {
- BI.each(selected[k], function (nk, nv) {
- var t = BI.clone(p);
- t.push(nk);
- result.push(t);
- });
- can = false;
- }
- });
- return can && isAllSelected(selected, parents);
- }
-
- function isAllSelected(selected, parents) {
- return BI.isEmpty(selected) || self._getChildCount(parents) === BI.size(selected);
- }
- },
-
- _reqInitTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var keyword = op.keyword || "";
- var selectedValues = op.selectedValues;
- var lastSearchValue = op.lastSearchValue || "";
- var output = search();
- BI.nextTick(function () {
- callback({
- hasNext: output.length > self._const.perPage,
- items: result,
- lastSearchValue: BI.last(output)
- })
- });
-
- function search() {
- var children = self._getChildren([]);
- var start = children.length;
- if (lastSearchValue !== "") {
- for (var j = 0, len = start; j < len; j++) {
- if (children[j].value === lastSearchValue) {
- start = j + 1;
- break;
- }
- }
- } else {
- start = 0;
- }
- var output = [];
- for (var i = start, len = children.length; i < len; i++) {
- if (output.length < self._const.perPage) {
- var find = nodeSearch(1, [], children[i].value, false, result);
- } else if (output.length === self._const.perPage) {
- var find = nodeSearch(1, [], children[i].value, false, []);
- }
- if (find[0] === true) {
- output.push(children[i].value);
- }
- if (output.length > self._const.perPage) {
- break;
- }
- }
- return output;
- }
-
- function nodeSearch(deep, parentValues, current, isAllSelect, result) {
- if (self._isMatch(current, keyword)) {
- var checked = isAllSelect || isSelected(parentValues, current);
- createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
- return [true, checked];
- }
- var newParents = BI.clone(parentValues);
- newParents.push(current);
- var children = self._getChildren(newParents);
-
- var can = false, checked = false;
-
- var isCurAllSelected = isAllSelect || isAllSelected(parentValues, current);
- BI.each(children, function (i, child) {
- var state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result);
- if (state[1] === true) {
- checked = true;
- }
- if (state[0] === true) {
- can = true;
- }
- });
- if (can === true) {
- checked = isCurAllSelected || (isSelected(parentValues, current) && checked);
- createOneJson(parentValues, current, true, checked, false, false, result);
- }
- return [can, checked];
- }
-
- function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
- var node = self._getTreeNode(parentValues, value)
- result.push({
- id: node.id,
- pId: node.pId,
- text: node.text,
- value: node.value,
- title: node.title,
- isParent: node.getChildrenLength() > 0,
- open: isOpen,
- checked: checked,
- halfCheck: half,
- flag: flag
- });
- }
-
- function isHalf(parentValues, value) {
- var find = findSelectedObj(parentValues);
- if (find == null) {
- return null;
- }
- return BI.any(find, function (v, ob) {
- if (v === value) {
- if (ob != null && !BI.isEmpty(ob)) {
- return true;
- }
- }
- });
- }
-
- function isAllSelected(parentValues, value) {
- var find = findSelectedObj(parentValues);
- if (find == null) {
- return null;
- }
- return BI.any(find, function (v, ob) {
- if (v === value) {
- if (ob != null && BI.isEmpty(ob)) {
- return true;
- }
- }
- });
- }
-
- function isSelected(parentValues, value) {
- var find = findSelectedObj(parentValues);
- if (find == null) {
- return false;
- }
- return BI.any(find, function (v) {
- if (v === value) {
- return true;
- }
- });
- }
-
- function findSelectedObj(parentValues) {
- var find = selectedValues;
- if (find == null) {
- return null;
- }
- BI.every(parentValues, function (i, v) {
- find = find[v];
- if (find == null) {
- return false;
- }
- return true;
- });
- return find;
- }
- },
-
- _reqTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var times = op.times;
- var checkState = op.checkState || {};
- var parentValues = op.parentValues || [];
- var selectedValues = op.selectedValues || {};
- var valueMap = {};
- // if (judgeState(parentValues, selectedValues, checkState)) {
- valueMap = dealWidthSelectedValue(parentValues, selectedValues);
- // }
- var nodes = this._getChildren(parentValues);
- for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) {
- var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState);
- result.push({
- id: nodes[i].id,
- pId: nodes[i].pId,
- value: nodes[i].value,
- text: nodes[i].text,
- times: 1,
- isParent: nodes[i].getChildrenLength() > 0,
- checked: state[0],
- halfCheck: state[1]
- })
- }
- BI.nextTick(function () {
- callback({
- items: result,
- hasNext: nodes.length > times * self._const.perPage
- });
- });
-
- function judgeState(parentValues, selected_value, checkState) {
- var checked = checkState.checked, half = checkState.half;
- if (parentValues.length > 0 && !checked) {
- return false;
- }
- return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value));
- }
-
- function dealWidthSelectedValue(parentValues, selectedValues) {
- var valueMap = {};
- BI.each(parentValues, function (i, v) {
- selectedValues = selectedValues[v] || {};
- });
- BI.each(selectedValues, function (value, obj) {
- if (BI.isNull(obj)) {
- valueMap[value] = [0, 0];
- return;
- }
- if (BI.isEmpty(obj)) {
- valueMap[value] = [2, 0];
- return;
- }
- var nextNames = {};
- BI.each(obj, function (t, o) {
- if (BI.isNull(o) || BI.isEmpty(o)) {
- nextNames[t] = true;
- }
- });
- valueMap[value] = [1, BI.size(nextNames)];
- });
- return valueMap;
- }
-
- function getCheckState(current, parentValues, valueMap, checkState) {
- var checked = checkState.checked, half = checkState.half;
- var tempCheck = false, halfCheck = false;
- if (BI.has(valueMap, current)) {
- //可能是半选
- if (valueMap[current][0] === 1) {
- var values = BI.clone(parentValues);
- values.push(current);
- var childCount = self._getChildCount(values);
- if (childCount > 0 && childCount !== valueMap[current][1]) {
- halfCheck = true;
- }
- } else if (valueMap[current][0] === 2) {
- tempCheck = true;
- }
- }
- var check;
- if (!checked && !halfCheck && !tempCheck) {
- check = BI.has(valueMap, current);
- } else {
- check = ((tempCheck || checked) && !half) || BI.has(valueMap, current);
- }
- return [check, halfCheck];
- }
- },
-
- _getNode: function (selectedValues, parentValues) {
- var pNode = selectedValues;
- for (var i = 0, len = parentValues.length; i < len; i++) {
- if (pNode == null) {
- return null;
- }
- pNode = pNode[parentValues[i]];
- }
- return pNode;
- },
-
- _deleteNode: function (selectedValues, values) {
- var name = values[values.length - 1];
- var p = values.slice(0, values.length - 1);
- var pNode = this._getNode(selectedValues, p);
- if (pNode != null && pNode[name]) {
- delete pNode[name];
- //递归删掉空父节点
- while (p.length > 0 && BI.isEmpty(pNode)) {
- name = p[p.length - 1];
- p = p.slice(0, p.length - 1);
- pNode = this._getNode(selectedValues, p);
- if (pNode != null) {
- delete pNode[name];
- }
- }
- }
- },
-
- _buildTree: function (jo, values) {
- var t = jo;
- BI.each(values, function (i, v) {
- if (!BI.has(t, v)) {
- t[v] = {};
- }
- t = t[v];
- });
- },
-
- _isMatch: function (value, keyword) {
- var finded = BI.Func.getSearchResult([value], keyword);
- return finded.finded.length > 0 || finded.matched.length > 0;
- },
-
- _getTreeNode: function (parentValues, v) {
- var self = this;
- var findedParentNode;
- var index = 0;
- this.tree.traverse(function (node) {
- if (self.tree.isRoot(node)) {
- return;
- }
- if (index > parentValues.length) {
- return false;
- }
- if (index === parentValues.length && node.value === v) {
- findedParentNode = node;
- return false;
- }
- if (node.value === parentValues[index]) {
- index++;
- return;
- }
- return true;
- });
- return findedParentNode;
- },
-
- _getChildren: function (parentValues) {
- if (parentValues.length > 0) {
- var value = BI.last(parentValues);
- var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value);
- } else {
- var parent = this.tree.getRoot();
- }
- return parent.getChildren();
- },
-
- _getChildCount: function (parentValues) {
- return this._getChildren(parentValues).length;
- }
-});/**
- * 简单的复选下拉树控件, 适用于数据量少的情况
- *
- * Created by GUY on 2015/10/29.
- * @class BI.TreeValueChooserCombo
- * @extends BI.Widget
- */
-BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-tree-value-chooser-combo",
- width: 200,
- height: 30,
- items: null,
- itemsCreator: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.TreeValueChooserCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
- this._initData(o.items);
- }
- this.combo = BI.createWidget({
- type: 'bi.multi_tree_combo',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- width: o.width,
- height: o.height
- });
-
- this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM);
- });
- },
-
- setValue: function (v) {
- this.combo.setValue(v);
- },
-
- getValue: function () {
- return this.combo.getValue();
- },
-
- populate: function () {
- this.combo.populate.apply(this.combo, arguments);
- }
-});
-BI.TreeValueChooserCombo.EVENT_CONFIRM = "TreeValueChooserCombo.EVENT_CONFIRM";
-BI.shortcut('bi.tree_value_chooser_combo', BI.TreeValueChooserCombo);/**
- * 简单的复选下拉树控件, 适用于数据量少的情况
- *
- * Created by GUY on 2015/10/29.
- * @class BI.TreeValueChooserPane
- * @extends BI.AbstractTreeValueChooser
- */
-BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-tree-value-chooser-pane",
- items: null,
- itemsCreator: BI.emptyFn
- });
- },
-
- _init: function () {
- BI.TreeValueChooserPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.pane = BI.createWidget({
- type: 'bi.multi_select_tree',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this)
- });
-
- this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE);
- });
- if (BI.isNotNull(o.items)) {
- this._initData(o.items);
- this.populate();
- }
- },
-
- setSelectedValue: function (v) {
- this.pane.setSelectedValue(v);
- },
-
- setValue: function (v) {
- this.pane.setValue(v);
- },
-
- getValue: function () {
- return this.pane.getValue();
- },
-
- populate: function () {
- this.pane.populate.apply(this.pane, arguments);
- }
-});
-BI.TreeValueChooserPane.EVENT_CHANGE = "TreeValueChooserPane.EVENT_CHANGE";
-BI.shortcut('bi.tree_value_chooser_pane', BI.TreeValueChooserPane);/**
- * 简单的复选下拉框控件, 适用于数据量少的情况
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AbstractValueChooser
- * @extends BI.Widget
- */
-BI.AbstractValueChooser = BI.inherit(BI.Widget, {
-
- _const: {
- perPage: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), {
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _valueFormatter: function (v) {
- var text = v;
- if (BI.isNotNull(this.items)) {
- BI.some(this.items, function (i, item) {
- if (item.value === v) {
- text = item.text;
- return true;
- }
- });
- }
- return text;
- },
-
- _getItemsByTimes: function (items, times) {
- var res = [];
- for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
- res.push(items[i]);
- }
- return res;
- },
-
- _hasNextByTimes: function (items, times) {
- return times * this._const.perPage < items.length;
- },
-
- _itemsCreator: function (options, callback) {
- var self = this, o = this.options;
- if (!o.cache || !this.items) {
- o.itemsCreator({}, function (items) {
- self.items = items;
- call(items);
- });
- } else {
- call(this.items);
- }
- function call(items) {
- var keywords = (options.keywords || []).slice();
- if (options.keyword) {
- keywords.push(options.keyword);
- }
- BI.each(keywords, function (i, kw) {
- var search = BI.Func.getSearchResult(items, kw);
- items = search.matched.concat(search.finded);
- });
- if (options.selectedValues) {//过滤
- var filter = BI.makeObject(options.selectedValues, true);
- items = BI.filter(items, function (i, ob) {
- return !filter[ob.value];
- });
- }
- if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
- callback({
- items: items
- });
- return;
- }
- if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
- callback({count: items.length});
- return;
- }
- callback({
- items: self._getItemsByTimes(items, options.times),
- hasNext: self._hasNextByTimes(items, options.times)
- });
- }
- }
-});/**
- * 简单的复选下拉框控件, 适用于数据量少的情况
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.ValueChooserCombo
- * @extends BI.Widget
- */
-BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-value-chooser-combo",
- width: 200,
- height: 30,
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _init: function () {
- BI.ValueChooserCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
- this.items = o.items;
- }
- this.combo = BI.createWidget({
- type: 'bi.multi_select_combo',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
- width: o.width,
- height: o.height
- });
-
- this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM);
- });
- },
-
- setValue: function (v) {
- this.combo.setValue(v);
- },
-
- getValue: function () {
- var val = this.combo.getValue() || {};
- return {
- type: val.type,
- value: val.value
- }
- },
-
- populate: function () {
- this.combo.populate.apply(this, arguments);
- }
-});
-BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM";
-BI.shortcut('bi.value_chooser_combo', BI.ValueChooserCombo);/**
- * 简单的复选下拉框控件, 适用于数据量少的情况
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.ValueChooserPane
- * @extends BI.Widget
- */
-BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
-
- _defaultConfig: function () {
- return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-value-chooser-pane",
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- });
- },
-
- _init: function () {
- BI.ValueChooserPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.list = BI.createWidget({
- type: 'bi.multi_select_list',
- element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this)
- });
-
- this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE);
- });
- if (BI.isNotNull(o.items)) {
- this.items = o.items;
- this.populate();
- }
- },
-
- setValue: function (v) {
- this.list.setValue(v);
- },
-
- getValue: function () {
- var val = this.list.getValue() || {};
- return {
- type: val.type,
- value: val.value
- }
- },
-
- populate: function () {
- this.list.populate.apply(this.list, arguments);
- }
-});
-BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
+/**
+ *
+ * Created by GUY on 2016/5/26.
+ * @class BI.SequenceTableTreeNumber
+ * @extends BI.Widget
+ */
+BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-sequence-table-tree-number",
+ isNeedFreeze: false,
+ startSequence: 1,//开始的序号
+ scrollTop: 0,
+ headerRowSize: 25,
+ rowSize: 25,
+
+ sequenceHeaderCreator: null,
+
+ header: [],
+ items: [], //二维数组
+
+ //交叉表头
+ crossHeader: [],
+ crossItems: []
+ });
+ },
+
+ _init: function () {
+ BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.vCurr = 1;
+ this.hCurr = 1;
+ this.tasks = [];
+ this.renderedCells = [];
+ this.renderedKeys = [];
+
+ this.container = BI.createWidget({
+ type: "bi.absolute",
+ width: 60,
+ scrollable: false
+ });
+
+ this.scrollContainer = BI.createWidget({
+ type: "bi.vertical",
+ scrollable: false,
+ scrolly: false,
+ items: [this.container]
+ });
+
+ this.headerContainer = BI.createWidget({
+ type: "bi.absolute",
+ cls: "bi-border",
+ width: 58,
+ scrollable: false
+ });
+
+ this.layout = BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.headerContainer,
+ height: this._getHeaderHeight() - 2
+ }, {el: {type: "bi.layout"}, height: 2}, {
+ el: this.scrollContainer
+ }]
+ });
+ //缓存第一行对应的序号
+ this.start = this.options.startSequence;
+ this.cache = {};
+ this._nextState();
+
+ this._populate();
+ },
+
+ _getNextSequence: function (nodes) {
+ var self = this;
+ var start = this.start;
+ var cnt = this.start;
+
+ function track(node) {
+ //如果已经有缓存了就不改计数了,复杂表会出现这种情况
+ self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt);
+ cnt++;
+ }
+
+ BI.each(nodes, function (i, node) {
+ if (BI.isNotEmptyArray(node.children)) {
+ BI.each(node.children, function (index, child) {
+ if (index === 0) {
+ if (self.cache[child.text || child.value]) {
+ start = cnt = self.cache[child.text || child.value];
+ }
+ }
+ track(child)
+ });
+ }
+ });
+ this.start = cnt;
+ return start;
+ },
+
+ _getStart: function (nodes) {
+ var self = this;
+ var start = this.start;
+ BI.some(nodes, function (i, node) {
+ if (BI.isNotEmptyArray(node.children)) {
+ return BI.some(node.children, function (index, child) {
+ if (index === 0) {
+ if (self.cache[child.text || child.value]) {
+ start = self.cache[child.text || child.value];
+ return true;
+ }
+ }
+ });
+ }
+ });
+ return start;
+ },
+
+ _formatNumber: function (nodes) {
+ var self = this, o = this.options;
+ var result = [];
+ var count = this._getStart(nodes);
+
+ function getLeafCount(node) {
+ var cnt = 0;
+ if (BI.isNotEmptyArray(node.children)) {
+ BI.each(node.children, function (index, child) {
+ cnt += getLeafCount(child);
+ });
+ if (/**node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) {
+ cnt++;
+ }
+ } else {
+ cnt++;
+ }
+ return cnt;
+ }
+
+ var start = 0, top = 0;
+ BI.each(nodes, function (i, node) {
+ if (BI.isArray(node.children)) {
+ BI.each(node.children, function (index, child) {
+ var cnt = getLeafCount(child);
+ result.push({
+ text: count++,
+ start: start,
+ top: top,
+ cnt: cnt,
+ index: index,
+ height: cnt * o.rowSize
+ });
+ start += cnt;
+ top += cnt * o.rowSize;
+ });
+ if (BI.isNotEmptyArray(node.values)) {
+ result.push({
+ text: BI.i18nText("BI-Summary_Values"),
+ start: start++,
+ top: top,
+ cnt: 1,
+ isSummary: true,
+ height: o.rowSize
+ });
+ top += o.rowSize;
+ }
+ }
+ });
+ return result;
+ },
+
+ _layout: function () {
+ var self = this, o = this.options;
+ var headerHeight = this._getHeaderHeight() - 2;
+ var items = this.layout.attr("items");
+ if (o.isNeedFreeze === false) {
+ items[0].height = 0;
+ items[1].height = 0;
+ } else if (o.isNeedFreeze === true) {
+ items[0].height = headerHeight;
+ items[1].height = 2;
+ }
+ this.layout.attr("items", items);
+ this.layout.resize();
+ try {
+ this.scrollContainer.element.scrollTop(o.scrollTop);
+ } catch (e) {
+
+ }
+ },
+
+ _getHeaderHeight: function () {
+ var o = this.options;
+ return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0));
+ },
+
+ _nextState: function () {
+ var o = this.options;
+ this._getNextSequence(o.items);
+ },
+
+ _prevState: function () {
+ var self = this, o = this.options;
+ var firstChild;
+ BI.some(o.items, function (i, node) {
+ if (BI.isNotEmptyArray(node.children)) {
+ return BI.some(node.children, function (j, child) {
+ firstChild = child;
+ return true;
+ });
+ }
+ });
+ if (firstChild && BI.isNotEmptyObject(this.cache)) {
+ this.start = this.cache[firstChild.text || firstChild.value];
+ } else {
+ this.start = 1;
+ }
+ this._nextState();
+ },
+
+ _getMaxScrollTop: function (numbers) {
+ var cnt = 0;
+ BI.each(numbers, function (i, number) {
+ cnt += number.cnt;
+ });
+ return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth());
+ },
+
+ _createHeader: function () {
+ var o = this.options;
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.headerContainer,
+ items: [{
+ el: o.sequenceHeaderCreator || {
+ type: "bi.table_style_cell",
+ cls: "sequence-table-title-cell",
+ styleGetter: o.headerCellStyleGetter,
+ text: BI.i18nText("BI-Number_Index")
+ },
+ left: 0,
+ top: 0,
+ right: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _calculateChildrenToRender: function () {
+ var self = this, o = this.options;
+
+ var renderedCells = [], renderedKeys = [];
+ var numbers = this._formatNumber(o.items);
+ var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0);
+ BI.each(numbers, function (i, number) {
+ intervalTree.set(i, number.height);
+ });
+ var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers));
+ var index = intervalTree.greatestLowerBound(scrollTop);
+ var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0));
+ var height = offsetTop;
+ var bodyHeight = o.height - this._getHeaderHeight();
+ while (height < bodyHeight && index < numbers.length) {
+ renderedKeys.push(index);
+ offsetTop += numbers[index].height;
+ height += numbers[index].height;
+ index++;
+ }
+
+ BI.each(renderedKeys, function (i, key) {
+ var index = BI.deepIndexOf(self.renderedKeys, key);
+ if (index > -1) {
+ if (numbers[key].height !== self.renderedCells[index]._height) {
+ self.renderedCells[index]._height = numbers[key].height;
+ self.renderedCells[index].el.setHeight(numbers[key].height);
+ }
+ if (numbers[key].top !== self.renderedCells[index].top) {
+ self.renderedCells[index].top = numbers[key].top;
+ self.renderedCells[index].el.element.css("top", numbers[key].top + "px");
+ }
+ renderedCells.push(self.renderedCells[index]);
+ } else {
+ var child = BI.createWidget(BI.extend({
+ type: "bi.table_style_cell",
+ cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",
+ width: 60,
+ styleGetter: numbers[key].isSummary === true ? function () {
+ return o.summaryCellStyleGetter(true);
+ } : function (key) {
+ return function () {
+ return o.sequenceCellStyleGetter(key);
+ }
+ }(numbers[key].index)
+ }, numbers[key]));
+ renderedCells.push({
+ el: child,
+ left: 0,
+ top: numbers[key].top,
+ _height: numbers[key].height
+ });
+ }
+ });
+
+ //已存在的, 需要添加的和需要删除的
+ var existSet = {}, addSet = {}, deleteArray = [];
+ BI.each(renderedKeys, function (i, key) {
+ if (BI.deepContains(self.renderedKeys, key)) {
+ existSet[i] = key;
+ } else {
+ addSet[i] = key;
+ }
+ });
+ BI.each(this.renderedKeys, function (i, key) {
+ if (BI.deepContains(existSet, key)) {
+ return;
+ }
+ if (BI.deepContains(addSet, key)) {
+ return;
+ }
+ deleteArray.push(i);
+ });
+ BI.each(deleteArray, function (i, index) {
+ self.renderedCells[index].el.destroy();
+ });
+ var addedItems = [];
+ BI.each(addSet, function (index) {
+ addedItems.push(renderedCells[index])
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: addedItems
+ });
+ this.renderedCells = renderedCells;
+ this.renderedKeys = renderedKeys;
+
+ this.container.setHeight(intervalTree.sumUntil(numbers.length));
+ },
+
+ _restore: function () {
+ BI.each(this.renderedCells, function (i, cell) {
+ cell.el.destroy();
+ });
+ this.renderedCells = [];
+ this.renderedKeys = [];
+ },
+
+ _populate: function () {
+ var self = this;
+ BI.each(this.tasks, function (i, task) {
+ task.apply(self);
+ });
+ this.tasks = [];
+ this.headerContainer.empty();
+ this._createHeader();
+ this._layout();
+ this._calculateChildrenToRender();
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ if (this.options.scrollTop !== scrollTop) {
+ this.options.scrollTop = scrollTop;
+ try {
+ this.scrollContainer.element.scrollTop(scrollTop);
+ } catch (e) {
+
+ }
+ }
+ },
+
+ getVerticalScroll: function () {
+ return this.options.scrollTop;
+ },
+
+ setVPage: function (v) {
+ if (v <= 1) {
+ this.cache = {};
+ this.start = this.options.startSequence;
+ this._restore();
+ this.tasks.push(this._nextState);
+ } else if (v === this.vCurr + 1) {
+ this.tasks.push(this._nextState);
+ } else if (v === this.vCurr - 1) {
+ this.tasks.push(this._prevState);
+ }
+ this.vCurr = v;
+ },
+
+ setHPage: function (v) {
+ if (v !== this.hCurr) {
+ this.tasks.push(this._prevState);
+ }
+ this.hCurr = v;
+ },
+
+ restore: function () {
+ this._restore();
+ },
+
+ populate: function (items, header, crossItems, crossHeader) {
+ var o = this.options;
+ if (items && items !== this.options.items) {
+ o.items = items;
+ this._restore();
+ this.tasks.push(this._prevState);
+ }
+ if (header && header !== this.options.header) {
+ o.header = header;
+ }
+ if (crossItems && crossItems !== this.options.crossItems) {
+ o.crossItems = crossItems;
+ }
+ if (crossHeader && crossHeader !== this.options.crossHeader) {
+ o.crossHeader = crossHeader;
+ }
+ this._populate();
+ }
+});
+BI.shortcut('bi.sequence_table_tree_number', BI.SequenceTableTreeNumber);/**
+ * 自适应布局
+ *
+ * 1、resize
+ * 2、吸附
+ * 3、当前组件在最上方
+ * 4、可以撤销
+ * 5、上下之间插入组件
+ *
+ * Created by GUY on 2016/2/23.
+ * @class BI.AdaptiveArrangement
+ * @extends BI.Widget
+ */
+BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-adaptive-arrangement",
+ resizable: true,
+ layoutType: BI.Arrangement.LAYOUT_TYPE.FREE,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.AdaptiveArrangement.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.arrangement = BI.createWidget({
+ type: "bi.arrangement",
+ element: this,
+ layoutType: o.layoutType,
+ items: o.items
+ });
+ this.arrangement.on(BI.Arrangement.EVENT_SCROLL, function () {
+ self.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL, arguments);
+ });
+ this.zIndex = 0;
+ BI.each(o.items, function (i, item) {
+ self._initResizable(item.el);
+ });
+
+ $(document).mousedown(function (e) {
+ BI.each(self.getAllRegions(), function (i, region) {
+ if (region.el.element.find(e.target).length === 0) {
+ region.el.element.removeClass("selected");
+ }
+ });
+ });
+ BI.ResizeDetector.addResizeListener(this, function () {
+ self.arrangement.resize();
+ self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
+ });
+ },
+
+ _isEqual: function () {
+ return this.arrangement._isEqual.apply(this.arrangement, arguments);
+ },
+
+ _setSelect: function (item) {
+ if (!item.element.hasClass("selected")) {
+ item.element.css("zIndex", ++this.zIndex);
+ BI.each(this.getAllRegions(), function (i, region) {
+ region.el.element.removeClass("selected");
+ });
+ item.element.addClass("selected");
+ }
+ },
+
+ _initResizable: function (item) {
+ var self = this, o = this.options;
+ item.element.css("zIndex", ++this.zIndex);
+ item.element.mousedown(function () {
+ self._setSelect(item)
+ });
+ // o.resizable && item.element.resizable({
+ // handles: "e, s, se",
+ // minWidth: 20,
+ // minHeight: 20,
+ // autoHide: true,
+ // helper: "bi-resizer",
+ // start: function () {
+ // item.element.css("zIndex", ++self.zIndex);
+ // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE);
+ // },
+ // resize: function (e, ui) {
+ // // self._resize(item.attr("id"), ui.size);
+ // self._resize(item.attr("id"), e, ui.size, ui.position);
+ // },
+ // stop: function (e, ui) {
+ // self._stopResize(item.attr("id"), ui.size);
+ // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size);
+ // self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
+ // }
+ // });
+ },
+
+ // _resize: function (name, e, size, position) {
+ // var self = this;
+ // this.scrollInterval(e, false, true, function (changedSize) {
+ // size.width += changedSize.offsetX;
+ // size.height += changedSize.offsetY;
+ // var containerWidth = self.arrangement.container.element.width();
+ // var containerHeight = self.arrangement.container.element.height();
+ // self.arrangement.container.element.width(containerWidth + changedSize.offsetX);
+ // self.arrangement.container.element.height(containerHeight + changedSize.offsetY);
+ // switch (self.getLayoutType()) {
+ // case BI.Arrangement.LAYOUT_TYPE.FREE:
+ // break;
+ // case BI.Arrangement.LAYOUT_TYPE.GRID:
+ // self.setRegionSize(name, size);
+ // break;
+ // }
+ // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size);
+ // });
+ // },
+ //
+ // _stopResize: function (name, size) {
+ // var self = this;
+ // this.scrollEnd();
+ // switch (this.getLayoutType()) {
+ // case BI.Arrangement.LAYOUT_TYPE.FREE:
+ // this.setRegionSize(name, size);
+ // break;
+ // case BI.Arrangement.LAYOUT_TYPE.GRID:
+ // this.setRegionSize(name, size);
+ // break;
+ // }
+ // },
+
+ _getScrollOffset: function () {
+ return this.arrangement._getScrollOffset();
+ },
+
+ getClientWidth: function () {
+ return this.arrangement.getClientWidth();
+ },
+
+ getClientHeight: function () {
+ return this.arrangement.getClientHeight();
+ },
+
+ addRegion: function (region, position) {
+ this._initResizable(region.el);
+ this._setSelect(region.el);
+ var self = this, flag;
+ var old = this.arrangement.getAllRegions();
+ if (flag = this.arrangement.addRegion(region, position)) {
+ this._old = old;
+ }
+ return flag;
+ },
+
+ deleteRegion: function (name) {
+ var flag;
+ var old = this.getAllRegions();
+ if (flag = this.arrangement.deleteRegion(name)) {
+ this._old = old;
+ } else {
+ this._old = this.getAllRegions();
+ this.relayout();
+ }
+ return flag;
+ },
+
+ setRegionSize: function (name, size) {
+ var flag;
+ var old = this.getAllRegions();
+ if (flag = this.arrangement.setRegionSize(name, size)) {
+ this._old = old;
+ }
+ return flag;
+ },
+
+ setPosition: function (position, size) {
+ var self = this;
+ return this.arrangement.setPosition(position, size);
+ },
+
+ setRegionPosition: function (name, position) {
+ var region = this.getRegionByName(name);
+ return this.arrangement.setRegionPosition(name, position);
+ },
+
+ setDropPosition: function (position, size) {
+ return this.arrangement.setDropPosition(position, size);
+ },
+
+ scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
+ var self = this;
+ var map = {
+ top: [-1, 0],
+ bottom: [1, 0],
+ left: [0, -1],
+ right: [0, 1]
+ };
+ var clientSize = this.element.bounds();
+
+ function scrollTo(direction, callback) {
+ if (direction === "") {
+ self.lastActiveRegion = "";
+ if (self._scrollInterval) {
+ clearInterval(self._scrollInterval);
+ self._scrollInterval = null;
+ }
+ return;
+ }
+ if (self.lastActiveRegion !== direction) {
+ self.lastActiveRegion = direction;
+ if (self._scrollInterval) {
+ clearInterval(self._scrollInterval);
+ self._scrollInterval = null;
+ }
+ self._scrollInterval = setInterval(function () {
+ var offset = self._getScrollOffset();
+ var t = offset.top + map[direction][0] * 40;
+ var l = offset.left + map[direction][1] * 40;
+ if (t < 0 || l < 0) {
+ return;
+ }
+ callback({
+ offsetX: map[direction][1] * 40,
+ offsetY: map[direction][0] * 40
+ });
+ self.scrollTo({
+ top: t,
+ left: l
+ });
+ }, 300);
+ }
+ }
+
+ cb({
+ offsetX: 0,
+ offsetY: 0
+ });
+ var offset = this.element.offset();
+ var p = {
+ left: e.pageX - offset.left,
+ top: e.pageY - offset.top
+ };
+ //向上滚
+ if (isBorderScroll && p.top >= 0 && p.top <= 30) {
+ scrollTo("top", cb)
+ }
+ //向下滚
+ else if (isBorderScroll && p.top >= clientSize.height - 30 && p.top <= clientSize.height) {
+ scrollTo("bottom", cb)
+ }
+ //向左滚
+ else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
+ scrollTo("left", cb)
+ }
+ //向右滚
+ else if (isBorderScroll && p.left >= clientSize.width - 30 && p.left <= clientSize.width) {
+ scrollTo("right", cb)
+ } else {
+ if (isOverflowScroll === true) {
+ if (p.top < 0) {
+ scrollTo("top", cb);
+ }
+ else if (p.top > clientSize.height) {
+ scrollTo("bottom", cb);
+ }
+ else if (p.left < 0) {
+ scrollTo("left", cb);
+ }
+ else if (p.left > clientSize.width) {
+ scrollTo("right", cb);
+ } else {
+ scrollTo("", cb);
+ }
+ } else {
+ scrollTo("", cb);
+ }
+ }
+ },
+
+ scrollEnd: function () {
+ this.lastActiveRegion = "";
+ if (this._scrollInterval) {
+ clearInterval(this._scrollInterval);
+ this._scrollInterval = null;
+ }
+ },
+
+ scrollTo: function (scroll) {
+ this.arrangement.scrollTo(scroll);
+ },
+
+ zoom: function (ratio) {
+ this.arrangement.zoom(ratio);
+ },
+
+ resize: function () {
+ this.arrangement.resize();
+ },
+
+ relayout: function () {
+ return this.arrangement.relayout();
+ },
+
+ setLayoutType: function (type) {
+ var self = this;
+ this.arrangement.setLayoutType(type);
+ },
+
+ getLayoutType: function () {
+ return this.arrangement.getLayoutType();
+ },
+
+ getLayoutRatio: function () {
+ return this.arrangement.getLayoutRatio();
+ },
+
+ getHelper: function () {
+ return this.arrangement.getHelper();
+ },
+
+ getRegionByName: function (name) {
+ return this.arrangement.getRegionByName(name);
+ },
+
+ getAllRegions: function () {
+ return this.arrangement.getAllRegions();
+ },
+
+ revoke: function () {
+ if (this._old) {
+ this.populate(BI.toArray(this._old));
+ }
+ },
+
+ populate: function (items) {
+ var self = this;
+ BI.each(items, function (i, item) {
+ self._initResizable(item.el);
+ });
+ this.arrangement.populate(items);
+ }
+});
+BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE";
+BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_RESIZE";
+BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE";
+BI.AdaptiveArrangement.EVENT_RESIZE = "AdaptiveArrangement.EVENT_RESIZE";
+BI.AdaptiveArrangement.EVENT_SCROLL = "AdaptiveArrangement.EVENT_SCROLL";
+BI.shortcut('bi.adaptive_arrangement', BI.AdaptiveArrangement);/**
+ * Arrangement的block面板
+ *
+ * Created by GUY on 2016/3/1.
+ * @class BI.ArrangementBlock
+ * @extends BI.Widget
+ */
+BI.ArrangementBlock = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-arrangement-block bi-mask"
+ });
+ }
+});
+BI.shortcut('bi.arrangement_block', BI.ArrangementBlock);/**
+ * Arrangement的drop面板
+ *
+ * Created by GUY on 2016/3/1.
+ * @class BI.ArrangementDroppable
+ * @extends BI.Widget
+ */
+BI.ArrangementDroppable = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-arrangement-droppable bi-resizer"
+ });
+ }
+});
+BI.shortcut('bi.arrangement_droppable', BI.ArrangementDroppable);/**
+ * 布局
+ *
+ * Created by GUY on 2016/2/23.
+ * @class BI.Arrangement
+ * @extends BI.Widget
+ */
+BI.Arrangement = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-arrangement",
+ layoutType: BI.Arrangement.LAYOUT_TYPE.GRID,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.Arrangement.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.arrangement = BI.createWidget({
+ type: "bi.arrangement_droppable",
+ cls: "arrangement-block",
+ invisible: true
+ });
+ this.block = BI.createWidget({
+ type: "bi.arrangement_block",
+ invisible: true
+ });
+ this.container = BI.createWidget({
+ type: "bi.absolute",
+ items: o.items.concat([this.block, this.arrangement])
+ });
+
+ this.scrollContainer = BI.createWidget({
+ type: "bi.adaptive",
+ width: "100%",
+ height: "100%",
+ scrollable: true,
+ items: [this.container]
+ });
+ this.scrollContainer.element.scroll(function () {
+ self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
+ scrollLeft: self.scrollContainer.element.scrollLeft(),
+ scrollTop: self.scrollContainer.element.scrollTop(),
+ clientWidth: self.scrollContainer.element[0].clientWidth,
+ clientHeight: self.scrollContainer.element[0].clientHeight
+ });
+ });
+
+ BI.createWidget({
+ type: "bi.adaptive",
+ element: this,
+ items: [this.scrollContainer]
+ });
+ this.regions = {};
+ if (o.items.length > 0) {
+ BI.nextTick(function () {
+ self.populate(o.items);
+ });
+ }
+ },
+
+ ////初始化操作////
+ _calculateRegions: function (items) {
+ var self = this, o = this.options;
+ this.regions = {};
+ BI.each(items, function (i, item) {
+ var region = self._createOneRegion(item);
+ self.regions[region.id] = region;
+ });
+ },
+
+ _isEqual: function (num1, num2) {
+ return Math.abs(num1 - num2) < 2;
+ },
+
+ _isLessThan: function (num1, num2) {
+ return num1 < num2 && !this._isEqual(num1, num2);
+ },
+
+ _isMoreThan: function (num1, num2) {
+ return num1 > num2 && !this._isEqual(num1, num2);
+ },
+
+ _isLessThanEqual: function (num1, num2) {
+ return num1 <= num2 || this._isEqual(num1, num2);
+ },
+
+ _isMoreThanEqual: function (num1, num2) {
+ return num1 >= num2 || this._isEqual(num1, num2);
+ },
+
+ //获取占有的最大Region
+ _getRegionOccupied: function (regions) {
+ var self = this, o = this.options;
+ if (BI.size(regions || this.regions) <= 0) {
+ return {
+ left: 0,
+ top: 0,
+ width: 0,
+ height: 0
+ }
+ }
+ var minLeft = BI.MAX, maxLeft = BI.MIN, minTop = BI.MAX, maxTop = BI.MIN;
+ BI.each(regions || this.regions, function (id, region) {
+ minLeft = Math.min(minLeft, region.left);
+ maxLeft = Math.max(maxLeft, region.left + region.width);
+ minTop = Math.min(minTop, region.top);
+ maxTop = Math.max(maxTop, region.top + region.height);
+ });
+ return {
+ left: minLeft,
+ top: minTop,
+ width: maxLeft - minLeft,
+ height: maxTop - minTop
+ }
+ },
+
+ //两个区域的交叉面积
+ _getCrossArea: function (region1, region2) {
+ if (region1.left <= region2.left) {
+ if (region1.top <= region2.top) {
+ if (region1.top + region1.height > region2.top && region1.left + region1.width > region2.left) {
+ if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region1.left + region1.width, region2.left)) {
+ return 0;
+ }
+ return (region1.top + region1.height - region2.top) * (region1.left + region1.width - region2.left);
+ }
+ } else {
+ if (region2.top + region2.height > region1.top && region1.left + region1.width > region2.left) {
+ if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region1.left + region1.width, region2.left)) {
+ return 0;
+ }
+ return (region2.top + region2.height - region1.top) * (region1.left + region1.width - region2.left);
+ }
+ }
+ } else {
+ if (region1.top <= region2.top) {
+ if (region1.top + region1.height > region2.top && region2.left + region2.width > region1.left) {
+ if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region2.left + region2.width, region1.left)) {
+ return 0;
+ }
+ return (region1.top + region1.height - region2.top) * (region2.left + region2.width - region1.left);
+ }
+ } else {
+ if (region2.top + region2.height > region1.top && region2.left + region2.width > region1.left) {
+ if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region2.left + region2.width, region1.left)) {
+ return 0;
+ }
+ return (region2.top + region2.height - region1.top) * (region2.left + region2.width - region1.left);
+ }
+ }
+ }
+ return 0;
+ },
+
+ //是否有覆盖的组件
+ _isRegionOverlay: function (regions) {
+ var reg = [];
+ BI.each(regions || this.regions, function (id, region) {
+ reg.push(new BI.Region(region.left, region.top, region.width, region.height));
+ });
+ for (var i = 0, len = reg.length; i < len; i++) {
+ for (var j = i + 1; j < len; j++) {
+ var area1 = {
+ left: reg[i].x,
+ top: reg[i].y,
+ width: reg[i].w,
+ height: reg[i].h
+ };
+ var area2 = {
+ left: reg[j].x,
+ top: reg[j].y,
+ width: reg[j].w,
+ height: reg[j].h
+ };
+ if (reg[i].isIntersects(reg[j]) && this._getCrossArea(area1, area2) > 1) {
+ return true;
+ }
+ }
+ }
+ return false;
+ },
+
+ //布局是否是优良的
+ _isArrangeFine: function (regions) {
+ switch (this.options.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ return true;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ // if (this._isRegionOverlay()) {
+ // return false;
+ // }
+ }
+ return true;
+ },
+
+ _getRegionNames: function (regions) {
+ var names = [];
+ BI.each(regions || this.regions, function (i, region) {
+ names.push(region.id || region.attr("id"));
+ });
+ return names;
+ },
+
+ _getRegionsByNames: function (names, regions) {
+ names = BI.isArray(names) ? names : [names];
+ regions = regions || this.regions;
+ if (BI.isArray(regions)) {
+ var result = [];
+ BI.each(regions, function (i, region) {
+ if (names.contains(region.id || region.attr("id"))) {
+ result.push(region);
+ }
+ });
+ } else {
+ var result = {};
+ BI.each(names, function (i, name) {
+ result[name] = regions[name];
+ });
+ }
+ return result;
+ },
+
+ _cloneRegion: function (regions) {
+ var clone = {};
+ BI.each(regions || this.regions, function (id, region) {
+ clone[id] = {};
+ clone[id].el = region.el;
+ clone[id].id = region.id;
+ clone[id].left = region.left;
+ clone[id].top = region.top;
+ clone[id].width = region.width;
+ clone[id].height = region.height;
+ });
+ return clone;
+ },
+
+ //测试合法性
+ _test: function (regions) {
+ var self = this;
+ return !BI.any(regions || this.regions, function (i, region) {
+ if (BI.isNaN(region.width) || BI.isNaN(region.height) || region.width <= 21 || region.height <= 21) {
+ return true;
+ }
+ })
+ },
+
+ _getScrollOffset: function () {
+ return {
+ left: this.scrollContainer.element[0].scrollLeft,
+ top: this.scrollContainer.element[0].scrollTop
+ }
+ },
+
+ ////操作////
+ _createOneRegion: function (item) {
+ var el = BI.createWidget(item.el);
+ el.setVisible(true);
+ return {
+ id: el.attr("id"),
+ left: item.left,
+ top: item.top,
+ width: item.width,
+ height: item.height,
+ el: el
+ }
+ },
+
+ _applyRegion: function (regions) {
+ var self = this, o = this.options;
+ BI.each(regions || this.regions, function (i, region) {
+ region.el.element.css({
+ left: region.left,
+ top: region.top,
+ width: region.width,
+ height: region.height
+ });
+ });
+ this._applyContainer();
+ this.ratio = this.getLayoutRatio();
+ },
+
+ _renderRegion: function () {
+ var self = this;
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: BI.toArray(this.regions)
+ });
+ },
+
+ getClientWidth: function () {
+ return this.scrollContainer.element[0].clientWidth;
+ },
+
+ getClientHeight: function () {
+ return this.scrollContainer.element[0].clientHeight;
+ },
+
+ _applyContainer: function () {
+ //先掩藏后显示能够明确滚动条是否出现
+ this.scrollContainer.element.css("overflow", "hidden");
+ var occupied = this._getRegionOccupied();
+ this.container.element.width(occupied.left + occupied.width).height(occupied.top + occupied.height);
+ this.scrollContainer.element.css("overflow", "auto");
+ return occupied;
+ },
+
+ _modifyRegion: function (regions) {
+ BI.each(this.regions, function (id, region) {
+ if (regions[id]) {
+ region.left = regions[id].left;
+ region.top = regions[id].top;
+ region.width = regions[id].width;
+ region.height = regions[id].height;
+ }
+ });
+ },
+
+ _addRegion: function (item) {
+ var region = this._createOneRegion(item);
+ this.regions[region.id] = region;
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: [region]
+ });
+ },
+
+ _deleteRegionByName: function (name) {
+ this.regions[name].el.setVisible(false);
+ delete this.regions[name];
+ },
+
+ _setArrangeSize: function (size) {
+ this.arrangement.element.css({
+ left: size.left,
+ top: size.top,
+ width: size.width,
+ height: size.height
+ })
+ },
+
+ //Grid
+ _getOneWidthPortion: function () {
+ return this.getClientWidth() / BI.Arrangement.PORTION;
+ },
+ _getOneHeightPortion: function () {
+ return this.getClientHeight() / BI.Arrangement.H_PORTION;
+ },
+
+ _getGridPositionAndSize: function (position) {
+ var perWidth = this._getOneWidthPortion();
+ var perHeight = this._getOneHeightPortion();
+ var widthPortion = Math.round(position.width / perWidth);
+ var leftPortion = Math.round(position.left / perWidth);
+ var topPortion = Math.round(position.top / perHeight);
+ var heightPortion = Math.round(position.height / perHeight);
+ // if (leftPortion > BI.Arrangement.PORTION) {
+ // leftPortion = BI.Arrangement.PORTION;
+ // }
+ // if (widthPortion > BI.Arrangement.PORTION) {
+ // widthPortion = BI.Arrangement.PORTION;
+ // }
+ // if (leftPortion + widthPortion > BI.Arrangement.PORTION) {
+ // leftPortion = BI.Arrangement.PORTION - widthPortion;
+ // }
+ if (widthPortion === 0) {
+ widthPortion = 1;
+ }
+ if (heightPortion === 0) {
+ heightPortion = 1;
+ }
+ return {
+ x: leftPortion,
+ y: topPortion,
+ w: widthPortion,
+ h: heightPortion
+ }
+ },
+
+ _getBlockPositionAndSize: function (position) {
+ var perWidth = this._getOneWidthPortion();
+ var perHeight = this._getOneHeightPortion();
+ return {
+ left: position.x * perWidth,
+ top: position.y * perHeight,
+ width: position.w * perWidth,
+ height: position.h * perHeight
+ };
+ },
+
+ _getLayoutsByRegions: function (regions) {
+ var self = this;
+ var result = [];
+ BI.each(regions || this.regions, function (id, region) {
+ result.push(BI.extend(self._getGridPositionAndSize(region), {
+ i: region.id
+ }))
+ });
+ return result;
+ },
+
+ _getLayoutIndexByName: function (layout, name) {
+ return BI.findIndex(layout, function (i, l) {
+ return l.i === name;
+ });
+ },
+
+ _setBlockPositionAndSize: function (size) {
+ this.block.element.css({
+ left: size.left,
+ top: size.top,
+ width: size.width,
+ height: size.height
+ });
+ },
+
+ _getRegionsByLayout: function (layout) {
+ var self = this;
+ var regions = {};
+ BI.each(layout, function (i, ly) {
+ regions[ly.i] = BI.extend(self._getBlockPositionAndSize(ly), {
+ id: ly.i
+ });
+ });
+ return regions;
+ },
+
+ _setRegionsByLayout: function (regions, layout) {
+ var self = this;
+ regions || (regions = this.regions);
+ BI.each(layout, function (i, ly) {
+ if (regions[ly.i]) {
+ BI.extend(regions[ly.i], self._getBlockPositionAndSize(ly));
+ }
+ });
+ return regions;
+ },
+
+ _moveElement: function (layout, l, x, y, isUserAction) {
+ var self = this;
+ if (l._static) {
+ return layout;
+ }
+
+ if (l.y === y && l.x === x) {
+ return layout;
+ }
+
+ var movingUp = y && l.y > y;
+ if (typeof x === 'number') {
+ l.x = x;
+ }
+ if (typeof y === 'number') {
+ l.y = y;
+ }
+ l.moved = true;
+
+ var sorted = this._sortLayoutItemsByRowCol(layout);
+ if (movingUp) {
+ sorted = sorted.reverse();
+ }
+ var collisions = getAllCollisions(sorted, l);
+
+ for (var i = 0, len = collisions.length; i < len; i++) {
+ var collision = collisions[i];
+ if (collision.moved) {
+ continue;
+ }
+
+ if (l.y > collision.y && l.y - collision.y > collision.h / 4) {
+ continue;
+ }
+
+ if (collision._static) {
+ layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction);
+ } else {
+ layout = this._moveElementAwayFromCollision(layout, l, collision, isUserAction);
+ }
+ }
+
+ return layout;
+
+ function getAllCollisions(layout, layoutItem) {
+ return BI.filter(layout, function (i, l) {
+ return self._collides(l, layoutItem);
+ });
+ }
+ },
+
+ _sortLayoutItemsByRowCol: function (layout) {
+ return [].concat(layout).sort(function (a, b) {
+ if (a.y > b.y || (a.y === b.y && a.x > b.x)) {
+ return 1;
+ }
+ return -1;
+ });
+ },
+
+ _collides: function (l1, l2) {
+ if (l1 === l2) {
+ return false;
+ } // same element
+ if (l1.x + l1.w <= l2.x) {
+ return false;
+ } // l1 is left of l2
+ if (l1.x >= l2.x + l2.w) {
+ return false;
+ } // l1 is right of l2
+ if (l1.y + l1.h <= l2.y) {
+ return false;
+ } // l1 is above l2
+ if (l1.y >= l2.y + l2.h) {
+ return false;
+ } // l1 is below l2
+ return true; // boxes overlap
+ },
+
+ _getFirstCollision: function (layout, layoutItem) {
+ for (var i = 0, len = layout.length; i < len; i++) {
+ if (this._collides(layout[i], layoutItem)) {
+ return layout[i];
+ }
+ }
+ },
+
+ _moveElementAwayFromCollision: function (layout, collidesWith,
+ itemToMove, isUserAction) {
+ if (isUserAction) {
+ var fakeItem = {
+ x: itemToMove.x,
+ y: itemToMove.y,
+ w: itemToMove.w,
+ h: itemToMove.h,
+ i: '-1'
+ };
+ fakeItem.y = Math.max(collidesWith.y - itemToMove.h, 0);
+ if (!this._getFirstCollision(layout, fakeItem)) {
+ return this._moveElement(layout, itemToMove, undefined, fakeItem.y);
+ }
+ }
+
+ return this._moveElement(layout, itemToMove, undefined, itemToMove.y + 1);
+ },
+
+ _compactItem: function (compareWith, l, verticalCompact) {
+ if (verticalCompact) {
+ while (l.y > 0 && !this._getFirstCollision(compareWith, l)) {
+ l.y--;
+ }
+ }
+
+ var collides;
+ while ((collides = this._getFirstCollision(compareWith, l))) {
+ l.y = collides.y + collides.h;
+ }
+ return l;
+ },
+
+ compact: function (layout, verticalCompact) {
+ var compareWith = getStatics(layout);
+ var sorted = this._sortLayoutItemsByRowCol(layout);
+ var out = [];
+
+ for (var i = 0, len = sorted.length; i < len; i++) {
+ var l = sorted[i];
+
+ if (!l._static) {
+ l = this._compactItem(compareWith, l, verticalCompact);
+
+ compareWith.push(l);
+ }
+
+ out[layout.indexOf(l)] = l;
+
+ l.moved = false;
+ }
+
+ return out;
+ function getStatics(layout) {
+ return BI.filter(layout, function (i, l) {
+ return l._static;
+ });
+ }
+ },
+
+ ////公有方法////
+ getRegionByName: function (name) {
+ var obj = {};
+ obj[name] = this.regions[name];
+ return this._cloneRegion(obj)[name];
+ },
+
+ getAllRegions: function () {
+ return BI.toArray(this._cloneRegion());
+ },
+
+ getHelper: function () {
+ var helper = BI.createWidget({
+ type: "bi.layout",
+ width: 18,
+ height: 18,
+ cls: "arrangement-helper bi-border"
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [helper]
+ });
+ return helper;
+ },
+
+ _start: function () {
+ if (this.options.layoutType === BI.Arrangement.LAYOUT_TYPE.GRID) {
+ this.block.setVisible(true);
+ } else {
+ this.arrangement.setVisible(true);
+ }
+ },
+
+ _stop: function () {
+ this.arrangement.setVisible(false);
+ this.block.setVisible(false);
+ },
+
+ ////公有操作////
+ setLayoutType: function (type) {
+ var self = this, o = this.options;
+ if (type !== o.layoutType) {
+ o.layoutType = type;
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ this.relayout();
+ break;
+ }
+ }
+ },
+
+ getLayoutType: function () {
+ return this.options.layoutType;
+ },
+
+ getLayoutRatio: function () {
+ var occupied = this._getRegionOccupied();
+ var width = this.getClientWidth(), height = this.getClientHeight();
+ return {
+ x: BI.parseFloat(BI.contentFormat((occupied.left + occupied.width) / width, "#.##;-#.##")),
+ y: BI.parseFloat(BI.contentFormat((occupied.top + occupied.height) / height, "#.##;-#.##"))
+ }
+ },
+
+ addRegion: function (region, position) {
+ if (position) {
+ this.setPosition(position, region);
+ }
+ var self = this, o = this.options;
+ if (!this.position) {
+ return false;
+ }
+ var test = this._cloneRegion();
+ BI.each(this.position.regions, function (i, region) {
+ test[region.id].left = region.left;
+ test[region.id].top = region.top;
+ test[region.id].width = region.width;
+ test[region.id].height = region.height;
+
+ });
+ var item = BI.extend({}, region, {
+ left: this.position.insert.left,
+ top: this.position.insert.top,
+ width: this.position.insert.width,
+ height: this.position.insert.height
+ });
+ var added = this._createOneRegion(item);
+ test[added.id] = added;
+ if (this._test(test)) {
+ delete test[added.id];
+ this._modifyRegion(test);
+ this._addRegion(item);
+ this._populate(this.getAllRegions());
+ return true;
+ }
+ return false;
+ },
+
+ deleteRegion: function (name) {
+ if (!this.regions[name]) {
+ return false;
+ }
+ var self = this, o = this.options;
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ this._deleteRegionByName(name);
+ this._populate(this.getAllRegions());
+ return true;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ this._deleteRegionByName(name);
+ this._populate(this.getAllRegions());
+ this.resize();
+ return true;
+ }
+ return false;
+ },
+
+ setRegionSize: function (name, size) {
+ var self = this, o = this.options;
+ var flag = false;
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ var clone = this._cloneRegion();
+ BI.extend(clone[name], {
+ width: size.width,
+ height: size.height
+ });
+ if (this._test(clone)) {
+ this._modifyRegion(clone);
+ flag = true;
+ }
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ var clone = this._cloneRegion();
+ BI.extend(clone[name], {
+ width: size.width,
+ height: size.height
+ });
+ if (this._test(clone)) {
+ var layout = this._getLayoutsByRegions(clone);
+ layout = this.compact(layout, true);
+ var regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ flag = true;
+ }
+ break;
+ }
+ this._applyRegion();
+ return flag;
+ },
+
+ setPosition: function (position, size) {
+ var self = this, o = this.options;
+ var insert, regions = [], cur;
+ if (position.left < 0 || position.top < 0) {
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ this.resize();
+ break;
+ }
+ this._stop();
+ this.position = null;
+ return null;
+ }
+ var offset = this._getScrollOffset();
+ position = {
+ left: position.left + offset.left,
+ top: position.top + offset.top
+ };
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ var insert = {
+ top: position.top < 0 ? 0 : position.top,
+ left: position.left < 0 ? 0 : position.left,
+ width: size.width,
+ height: size.height
+ };
+ this.position = {
+ insert: insert
+ };
+ this._setArrangeSize(insert);
+ this._start();
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ var p = {
+ top: position.top < 0 ? 0 : position.top,
+ left: position.left < 0 ? 0 : position.left,
+ width: size.width,
+ height: size.height
+ };
+ this._setArrangeSize(p);
+ var cur = this._getGridPositionAndSize(p);
+ var layout = [{
+ x: 0, y: BI.MAX, w: cur.w, h: cur.h, i: cur.i
+ }].concat(this._getLayoutsByRegions());
+ layout = this._moveElement(layout, layout[0], cur.x, cur.y, true);
+ layout = this.compact(layout, true);
+ var regions = this._setRegionsByLayout(this._cloneRegion(), layout);
+ var insert = this._getBlockPositionAndSize(layout[0]);
+ this.position = {
+ insert: insert,
+ regions: regions
+ };
+ this._applyRegion(regions);
+ this._setBlockPositionAndSize(insert);
+ this._start();
+ break;
+ }
+ return this.position;
+ },
+
+ setRegionPosition: function (name, position) {
+ var self = this, o = this.options;
+ var offset = this._getScrollOffset();
+ position = BI.extend(position, {
+ left: position.left + offset.left,
+ top: position.top + offset.top
+ });
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ BI.extend(this.regions[name], {
+ left: position.left < 0 ? 0 : position.left,
+ top: position.top < 0 ? 0 : position.top
+ });
+ this._applyRegion();
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ if (!position.stop) {
+ BI.extend(this.regions[name], {
+ left: position.left < 0 ? 0 : position.left,
+ top: position.top < 0 ? 0 : position.top
+ });
+ var cloned = this._cloneRegion();
+ var cur = this._getGridPositionAndSize(BI.extend(cloned[name], {
+ left: position.left < 0 ? 0 : position.left,
+ top: position.top < 0 ? 0 : position.top
+ }));
+ var x = cur.x, y = cur.y;
+ cur = BI.extend(cur, {
+ x: 0, y: BI.MAX, i: -1
+ });
+ delete cloned[name];
+ var layout = this._getLayoutsByRegions(cloned);
+ layout = this._moveElement([cur].concat(layout), cur, x, y, true);
+ layout = this.compact(layout, true);
+ var regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ this._applyRegion();
+
+ this._setBlockPositionAndSize(this._getBlockPositionAndSize(cur));
+ this.block.setVisible(true);
+ } else {
+ BI.extend(this.regions[name], {
+ left: position.left < 0 ? 0 : position.left,
+ top: position.top < 0 ? 0 : position.top
+ });
+ var cloned = this._cloneRegion();
+ var layout = this._getLayoutsByRegions(cloned);
+ layout = this.compact(layout, true);
+ var regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ this._applyRegion();
+ this.block.setVisible(false);
+ }
+ break;
+ }
+ },
+
+ setDropPosition: function (position, size) {
+ var self = this;
+ this.arrangement.setVisible(true);
+ var offset = this._getScrollOffset();
+ this._setArrangeSize(BI.extend({}, size, {
+ left: position.left + offset.left,
+ top: position.top + offset.top
+ }));
+ return function () {
+ self.arrangement.setVisible(false);
+ }
+ },
+
+ scrollTo: function (scroll) {
+ this.scrollContainer.element.scrollTop(scroll.top);
+ this.scrollContainer.element.scrollLeft(scroll.left);
+ },
+
+ zoom: function (ratio) {
+ var self = this, o = this.options;
+ if (!ratio) {
+ return;
+ }
+ var occupied = this._applyContainer();
+ switch (this.getLayoutType()) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ if (this._isArrangeFine()) {
+ var width = this.getClientWidth();
+ var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width);
+ //var yRatio = ratio.y * height / (occupied.top + occupied.height);
+ var regions = this._cloneRegion();
+ BI.each(regions, function (i, region) {
+ region.left = region.left * xRatio;
+ //region.top = region.top * yRatio;
+ region.width = region.width * xRatio;
+ //region.height = region.height * yRatio;
+ });
+ if (this._test(regions)) {
+ this._modifyRegion(regions);
+ this._applyRegion();
+ }
+ this.resize();
+ // } else {
+ this.relayout();
+ }
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ if (this._isArrangeFine()) {
+ var width = this.getClientWidth(), height = this.getClientHeight();
+ var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width);
+ var yRatio = (ratio.y || 1) * height / (occupied.top + occupied.height);
+ var regions = this._cloneRegion();
+ BI.each(regions, function (i, region) {
+ region.left = region.left * xRatio;
+ region.width = region.width * xRatio;
+ region.top = region.top * yRatio;
+ region.height = region.height * yRatio;
+ //做一下自适应布局到网格布局的兼容
+ var perWidth = self._getOneWidthPortion();
+ var widthPortion = Math.round(region.width / perWidth);
+ var leftPortion = Math.round(region.left / perWidth);
+ var comparePortion = Math.round((region.width + region.left) / perWidth);
+ if (leftPortion + widthPortion !== comparePortion) {
+ region.left = leftPortion * perWidth;
+ region.width = comparePortion * perWidth - region.left;
+ }
+ });
+ if (this._test(regions)) {
+ var layout = this._getLayoutsByRegions(regions);
+ layout = this.compact(layout, true);
+ regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ this._applyRegion();
+ }
+ } else {
+ this.relayout();
+ }
+ break;
+ }
+ },
+
+ resize: function () {
+ var self = this, o = this.options;
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ this.zoom(this.ratio);
+ var regions = this._cloneRegion();
+ var layout = this._getLayoutsByRegions(regions);
+ layout = this.compact(layout, true);
+ regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ this._applyRegion();
+ break;
+ }
+ },
+
+ relayout: function () {
+ var self = this, o = this.options;
+ switch (o.layoutType) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ if (!this._isArrangeFine()) {
+ var perHeight = this._getOneHeightPortion();
+ var width = this.getClientWidth(), height = this.getClientHeight();
+ var regions = this._cloneRegion();
+ var clone = BI.toArray(regions);
+ clone.sort(function (r1, r2) {
+ if (self._isEqual(r1.top, r2.top)) {
+ return r1.left - r2.left;
+ }
+ return r1.top - r2.top;
+ });
+ var count = clone.length;
+ var cols = 4, rows = Math.floor((count - 1) / 4 + 1);
+ var w = width / cols, h = height / rows;
+ var store = {};
+ BI.each(clone, function (i, region) {
+ var row = Math.floor(i / 4), col = i % 4;
+ BI.extend(region, {
+ top: row * perHeight * 6,
+ left: col * w,
+ width: w,
+ height: perHeight * 6
+ });
+ if (!store[row]) {
+ store[row] = {};
+ }
+ store[row][col] = region;
+ });
+ //非4的倍数
+ // if (count % 4 !== 0) {
+ // var lasts = store[rows - 1];
+ // var perWidth = width / (count % 4);
+ // BI.each(lasts, function (i, region) {
+ // BI.extend(region, {
+ // left: BI.parseInt(i) * perWidth,
+ // width: perWidth
+ // });
+ // });
+ // }
+ if (this._test(clone)) {
+ var layout = this._getLayoutsByRegions(regions);
+ layout = this.compact(layout, true);
+ regions = this._getRegionsByLayout(layout);
+ this._modifyRegion(regions);
+ this._populate(clone);
+ }
+ } else {
+ this.resize();
+ }
+ break;
+ }
+ },
+
+ _populate: function (items) {
+ this._stop();
+ this._calculateRegions(items);
+ this._applyRegion();
+ },
+
+ populate: function (items) {
+ var self = this;
+ BI.each(this.regions, function (name, region) {
+ self.regions[name].el.setVisible(false);
+ delete self.regions[name];
+ });
+ this._populate(items);
+ this._renderRegion();
+ }
+});
+BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL";
+BI.extend(BI.Arrangement, {
+ PORTION: 36,
+ H_PORTION: 18,
+ LAYOUT_TYPE: {
+ GRID: 0,
+ FREE: 1
+ }
+});
+BI.shortcut('bi.arrangement', BI.Arrangement);/**
+ * 表关联树
+ *
+ * Created by GUY on 2015/12/15.
+ * @class BI.BranchRelation
+ * @extends BI.Widget
+ */
+BI.BranchRelation = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.BranchRelation.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-branch-relation-tree",
+ items: [],
+
+ centerOffset: 0,//重心偏移量
+ direction: BI.Direction.Bottom,
+ align: BI.VerticalAlign.Top
+ })
+ },
+
+ _init: function () {
+ BI.BranchRelation.superclass._init.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ //树分层
+ _stratification: function () {
+ var levels = [];
+ this.tree.recursion(function (node, route) {
+ //node.isRoot = route.length <= 1;
+ node.leaf = node.isLeaf();
+ if (!levels[route.length - 1]) {
+ levels[route.length - 1] = [];
+ }
+ levels[route.length - 1].push(node);
+ });
+ return levels;
+ },
+
+ //计算所有节点的叶子结点个数
+ _calculateLeaves: function () {
+ var count = 0;
+
+ function track(node) {
+ var c = 0;
+ if (node.isLeaf()) {
+ return 1;
+ }
+ BI.each(node.getChildren(), function (i, child) {
+ c += track(child);
+ });
+ node.set("leaves", c);
+ return c;
+ }
+
+ count = track(this.tree.getRoot());
+ return count;
+ },
+
+ //树平移
+ _translate: function (levels) {
+ var adjust = [];
+ var maxLevel = levels.length;
+ BI.each(levels, function (i, nodes) {
+ if (!adjust[i]) {
+ adjust[i] = [];
+ }
+ BI.each(nodes, function (j, node) {
+ if (node.isLeaf() && i < maxLevel - 1) {
+ var newNode = new BI.Node(BI.UUID());
+ //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot;
+ newNode.isNew = true;
+ //把node向下一层移
+ var tar = 0;
+ if (j > 0) {
+ var c = nodes[j - 1].getLastChild();
+ tar = levels[i + 1].indexOf(c) + 1;
+ }
+ levels[i + 1].splice(tar, 0, node);
+ //新增一个临时树节点
+ var index = node.parent.getChildIndex(node.id);
+ node.parent.removeChildByIndex(index);
+ node.parent.addChild(newNode, index);
+ newNode.addChild(node);
+ adjust[i].push(newNode);
+ nodes[j] = newNode;
+ } else {
+ adjust[i].push(node);
+ }
+ })
+ });
+ return adjust;
+ },
+
+ //树补白
+ _fill: function (levels) {
+ var adjust = [];
+ var maxLevel = levels.length;
+ BI.each(levels, function (i, nodes) {
+ if (!adjust[i]) {
+ adjust[i] = [];
+ }
+ BI.each(nodes, function (j, node) {
+ if (node.isLeaf() && i < maxLevel - 1) {
+ var newNode = new BI.Node(BI.UUID());
+ newNode.leaf = true;
+ newNode.width = node.width;
+ newNode.height = node.height;
+ newNode.isNew = true;
+ //把node向下一层移
+ var tar = 0;
+ if (j > 0) {
+ var c = nodes[j - 1].getLastChild();
+ tar = levels[i + 1].indexOf(c) + 1;
+ }
+ levels[i + 1].splice(tar, 0, newNode);
+ //新增一个临时树节点
+ node.addChild(newNode);
+ }
+ adjust[i].push(node);
+ })
+ });
+ return adjust;
+ },
+
+ //树调整
+ _adjust: function (adjust) {
+ while (true) {
+ var isAllNeedAjust = false;
+ BI.backEach(adjust, function (i, nodes) {
+ BI.each(nodes, function (j, node) {
+ if (!node.isNew) {
+ var needAdjust = true;
+ BI.any(node.getChildren(), function (k, n) {
+ if (!n.isNew) {
+ needAdjust = false;
+ return true;
+ }
+ });
+ if (!node.isLeaf() && needAdjust === true) {
+ var allChilds = [];
+ BI.each(node.getChildren(), function (k, n) {
+ allChilds = allChilds.concat(n.getChildren());
+ });
+ node.removeAllChilds();
+ BI.each(allChilds, function (k, c) {
+ node.addChild(c);
+ });
+ var newNode = new BI.Node(BI.UUID());
+ //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot;
+ newNode.isNew = true;
+ var index = node.parent.getChildIndex(node.id);
+ node.parent.removeChildByIndex(index);
+ node.parent.addChild(newNode, index);
+ newNode.addChild(node);
+ isAllNeedAjust = true;
+ }
+ }
+ })
+ });
+ if (isAllNeedAjust === false) {
+ break;
+ } else {//树重构
+ adjust = this._stratification();
+ }
+ }
+ return adjust;
+ },
+
+ _calculateWidth: function () {
+ var o = this.options;
+ var width = 0;
+
+ function track1(node) {
+ var w = 0;
+ if (node.isLeaf()) {
+ return node.width;
+ }
+ BI.each(node.getChildren(), function (i, child) {
+ w += track1(child);
+ });
+ return w;
+ }
+
+ function track2(node) {
+ var w = 0;
+ if (node.isLeaf()) {
+ return node.height;
+ }
+ BI.each(node.getChildren(), function (i, child) {
+ w += track2(child);
+ });
+ return w;
+ }
+
+ if (this._isVertical()) {
+ width = track1(this.tree.getRoot());
+ } else {
+ width = track2(this.tree.getRoot());
+ }
+
+ return width;
+ },
+
+ _isVertical: function () {
+ var o = this.options;
+ return o.direction === BI.Direction.Top || o.direction === BI.Direction.Bottom;
+ },
+
+ _calculateHeight: function () {
+ var o = this.options;
+ var height = 0;
+
+ function track1(node) {
+ var h = 0;
+ BI.each(node.getChildren(), function (i, child) {
+ h = Math.max(h, track1(child));
+ });
+ return h + (node.height || 0);
+ }
+
+ function track2(node) {
+ var h = 0;
+ BI.each(node.getChildren(), function (i, child) {
+ h = Math.max(h, track2(child));
+ });
+ return h + (node.width || 0);
+ }
+
+ if (this._isVertical()) {
+ height = track1(this.tree.getRoot());
+ } else {
+ height = track2(this.tree.getRoot());
+ }
+ return height;
+ },
+
+ _calculateXY: function (levels) {
+ var o = this.options;
+ var width = this._calculateWidth();
+ var height = this._calculateHeight();
+ var levelCount = levels.length;
+ var allLeavesCount = this._calculateLeaves();
+ //计算坐标
+ var xy = {};
+ var levelHeight = height / levelCount;
+ BI.each(levels, function (i, nodes) {
+ //计算权重
+ var weights = [];
+ BI.each(nodes, function (j, node) {
+ weights[j] = (node.get("leaves") || 1) / allLeavesCount;
+ });
+ BI.each(nodes, function (j, node) {
+ //求前j个元素的权重
+ var weight = BI.sum(weights.slice(0, j));
+ //求坐标
+ var x = weight * width + weights[j] * width / 2;
+ var y = i * levelHeight + levelHeight / 2;
+ xy[node.id] = {x: x, y: y};
+ })
+ });
+ return xy;
+ },
+
+ _stroke: function (levels, xy) {
+ var height = this._calculateHeight();
+ var levelCount = levels.length;
+ var levelHeight = height / levelCount;
+ var self = this, o = this.options;
+ switch (o.direction) {
+ case BI.Direction.Top:
+ BI.each(levels, function (i, nodes) {
+ BI.each(nodes, function (j, node) {
+ if (node.getChildrenLength() > 0 && !node.leaf) {
+ var path = "";
+ var start = xy[node.id];
+ var split = start.y + levelHeight / 2;
+ path += "M" + start.x + "," + (start.y + o.centerOffset) + "L" + start.x + "," + split;
+ var end = [];
+ BI.each(node.getChildren(), function (t, c) {
+ var e = end[t] = xy[c.id];
+ path += "M" + e.x + "," + (e.y + o.centerOffset) + "L" + e.x + "," + split;
+ });
+ if (end.length > 0) {
+ path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split;
+ }
+ self.svg.path(path).attr("stroke", "#d4dadd");
+ }
+ })
+ });
+ break;
+ case BI.Direction.Bottom:
+ BI.each(levels, function (i, nodes) {
+ BI.each(nodes, function (j, node) {
+ if (node.getChildrenLength() > 0 && !node.leaf) {
+ var path = "";
+ var start = xy[node.id];
+ var split = start.y - levelHeight / 2;
+ path += "M" + start.x + "," + (start.y - o.centerOffset) + "L" + start.x + "," + split;
+ var end = [];
+ BI.each(node.getChildren(), function (t, c) {
+ var e = end[t] = xy[c.id];
+ path += "M" + e.x + "," + (e.y - o.centerOffset) + "L" + e.x + "," + split;
+ });
+ if (end.length > 0) {
+ path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split;
+ }
+ self.svg.path(path).attr("stroke", "#d4dadd");
+ }
+ })
+ });
+ break;
+ case BI.Direction.Left:
+ BI.each(levels, function (i, nodes) {
+ BI.each(nodes, function (j, node) {
+ if (node.getChildrenLength() > 0 && !node.leaf) {
+ var path = "";
+ var start = xy[node.id];
+ var split = start.y + levelHeight / 2;
+ path += "M" + (start.y + o.centerOffset) + "," + start.x + "L" + split + "," + start.x;
+ var end = [];
+ BI.each(node.getChildren(), function (t, c) {
+ var e = end[t] = xy[c.id];
+ path += "M" + (e.y + o.centerOffset) + "," + e.x + "L" + split + "," + e.x;
+ });
+ if (end.length > 0) {
+ path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x;
+ }
+ self.svg.path(path).attr("stroke", "#d4dadd");
+ }
+ })
+ });
+ break;
+ case BI.Direction.Right:
+ BI.each(levels, function (i, nodes) {
+ BI.each(nodes, function (j, node) {
+ if (node.getChildrenLength() > 0 && !node.leaf) {
+ var path = "";
+ var start = xy[node.id];
+ var split = start.y - levelHeight / 2;
+ path += "M" + (start.y - o.centerOffset) + "," + start.x + "L" + split + "," + start.x;
+ var end = [];
+ BI.each(node.getChildren(), function (t, c) {
+ var e = end[t] = xy[c.id];
+ path += "M" + (e.y - o.centerOffset) + "," + e.x + "L" + split + "," + e.x;
+ });
+ if (end.length > 0) {
+ path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x;
+ }
+ self.svg.path(path).attr("stroke", "#d4dadd");
+ }
+ })
+ });
+ break;
+ }
+ },
+
+ _createBranches: function (levels) {
+ var self = this, o = this.options;
+ if (o.direction === BI.Direction.Bottom || o.direction === BI.Direction.Right) {
+ levels = levels.reverse();
+ }
+ var xy = this._calculateXY(levels);
+ //画图
+ this._stroke(levels, xy);
+ },
+
+ _isNeedAdjust: function () {
+ var o = this.options;
+ return o.direction === BI.Direction.Top && o.align === BI.VerticalAlign.Bottom || o.direction === BI.Direction.Bottom && o.align === BI.VerticalAlign.Top
+ || o.direction === BI.Direction.Left && o.align === BI.HorizontalAlign.Right || o.direction === BI.Direction.Right && o.align === BI.HorizontalAlign.Left
+ },
+
+ setValue: function (value) {
+
+ },
+
+ getValue: function () {
+
+ },
+
+ _transformToTreeFormat: function (sNodes) {
+ var i, l;
+ if (!sNodes) {
+ return [];
+ }
+
+ if (BI.isArray(sNodes)) {
+ var r = [];
+ var tmpMap = [];
+ for (i = 0, l = sNodes.length; i < l; i++) {
+ tmpMap[sNodes[i].id] = sNodes[i];
+ }
+ for (i = 0, l = sNodes.length; i < l; i++) {
+ if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) {
+ if (!tmpMap[sNodes[i].pId].children) {
+ tmpMap[sNodes[i].pId].children = [];
+ }
+ tmpMap[sNodes[i].pId].children.push(sNodes[i]);
+ } else {
+ r.push(sNodes[i]);
+ }
+ }
+ return r;
+ } else {
+ return [sNodes];
+ }
+ },
+
+ populate: function (items) {
+ var self = this, o = this.options;
+ o.items = items || [];
+ this.empty();
+ items = this._transformToTreeFormat(o.items);
+ this.tree = new BI.Tree();
+ this.tree.initTree(items);
+
+ this.svg = BI.createWidget({
+ type: "bi.svg"
+ });
+
+ //树分层
+ var levels = this._stratification();
+
+ if (this._isNeedAdjust()) {
+ //树平移
+ var adjust = this._translate(levels);
+ //树调整
+ adjust = this._adjust(adjust);
+
+ this._createBranches(adjust);
+ } else {
+ var adjust = this._fill(levels);
+
+ this._createBranches(adjust);
+ }
+
+ var container = BI.createWidget({
+ type: "bi.layout",
+ width: this._isVertical() ? this._calculateWidth() : this._calculateHeight(),
+ height: this._isVertical() ? this._calculateHeight() : this._calculateWidth()
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: container,
+ items: [{
+ el: this.svg,
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }]
+ });
+ if (this._isVertical()) {
+ items = [{
+ type: "bi.handstand_branch_tree",
+ expander: {
+ direction: o.direction
+ },
+ el: {
+ layouts: [{
+ type: "bi.horizontal_adapt",
+ verticalAlign: o.align
+ }]
+ },
+ items: items
+ }]
+ } else {
+ items = [{
+ type: "bi.branch_tree",
+ expander: {
+ direction: o.direction
+ },
+ el: {
+ layouts: [{
+ type: "bi.vertical"
+ }, {
+ type: o.align === BI.HorizontalAlign.Left ? "bi.left" : "bi.right"
+ }]
+ },
+ items: items
+ }]
+ }
+ BI.createWidget({
+ type: "bi.adaptive",
+ element: container,
+ items: items
+ });
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: true,
+ element: this,
+ items: [container]
+ });
+ }
+});
+BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE";
+BI.shortcut("bi.branch_relation", BI.BranchRelation);/**
+ * 日期控件中的月份下拉框
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.MonthDateCombo
+ * @extends BI.Trigger
+ */
+BI.MonthDateCombo = BI.inherit(BI.Trigger, {
+ _defaultConfig: function() {
+ return BI.extend( BI.MonthDateCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-month-combo",
+ height: 25
+ });
+ },
+ _init: function() {
+ BI.MonthDateCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.date_triangle_trigger"
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.month_popup"
+ });
+
+ this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){
+ self.setValue(self.popup.getValue());
+ })
+
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ offsetStyle: "center",
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ stopPropagation: false,
+ el: this.popup
+ }
+ })
+ this.combo.on(BI.Combo.EVENT_CHANGE, function(){
+ self.combo.hideView();
+ self.fireEvent(BI.MonthDateCombo.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function(v){
+ this.trigger.setValue(v + 1);
+ this.popup.setValue(v);
+ },
+
+ getValue: function(){
+ return this.popup.getValue();
+ }
+});
+BI.MonthDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.month_date_combo', BI.MonthDateCombo);/**
+ * 年份下拉框
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.YearDateCombo
+ * @extends BI.Trigger
+ */
+BI.YearDateCombo = BI.inherit(BI.Trigger, {
+ _defaultConfig: function() {
+ return BI.extend( BI.YearDateCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-combo",
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ height: 25
+ });
+ },
+ _init: function() {
+ BI.YearDateCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.date_triangle_trigger"
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.year_popup",
+ min: o.min,
+ max: o.max
+ });
+
+ this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.YearDateCombo.EVENT_CHANGE);
+ })
+
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ offsetStyle: "center",
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ stopPropagation: false,
+ el: this.popup
+ }
+ })
+ this.combo.on(BI.Combo.EVENT_CHANGE, function(){
+ self.fireEvent(BI.YearDateCombo.EVENT_CHANGE);
+ })
+ },
+
+ setValue: function(v){
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function(){
+ return this.popup.getValue();
+ }
+});
+BI.YearDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.year_date_combo', BI.YearDateCombo);/**
+ * Created by GUY on 2015/9/7.
+ * @class BI.DatePicker
+ * @extends BI.Widget
+ */
+BI.DatePicker = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-date-picker bi-background",
+ height: 25,
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31' //最大日期
+ })
+ },
+
+ _init: function () {
+ BI.DatePicker.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this._year = new Date().getFullYear();
+ this._month = new Date().getMonth();
+ this.left = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "pre-page-h-font",
+ width: 25,
+ height: 25
+ });
+ this.left.on(BI.IconButton.EVENT_CHANGE, function () {
+ if (self._month === 0) {
+ self.setValue({
+ year: self.year.getValue() - 1,
+ month: 11
+ })
+ } else {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue() - 1
+ })
+ }
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ });
+
+ this.right = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "next-page-h-font",
+ width: 25,
+ height: 25
+ });
+
+ this.right.on(BI.IconButton.EVENT_CHANGE, function () {
+ if (self._month === 11) {
+ self.setValue({
+ year: self.year.getValue() + 1,
+ month: 0
+ })
+ } else {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue() + 1
+ })
+ }
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ });
+
+ this.year = BI.createWidget({
+ type: "bi.year_date_combo",
+ min: o.min,
+ max: o.max
+ });
+ this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue()
+ });
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ })
+ this.month = BI.createWidget({
+ type: "bi.month_date_combo"
+ });
+ this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue()
+ });
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: this.left,
+ width: 25
+ }, {
+ type: "bi.center_adapt",
+ items: [{
+ type: "bi.horizontal",
+ width: 100,
+ items: [this.year, this.month]
+ }]
+ }, {
+ el: this.right,
+ width: 25
+ }]
+ })
+ this.setValue({
+ year: this._year,
+ month: this._month
+ })
+ },
+
+ setValue: function (ob) {
+ this._year = ob.year;
+ this._month = ob.month;
+ this.year.setValue(ob.year);
+ this.month.setValue(ob.month);
+ },
+
+ getValue: function () {
+ return {
+ year: this.year.getValue(),
+ month: this.month.getValue()
+ }
+ }
+});
+BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE"
+BI.shortcut("bi.date_picker", BI.DatePicker);/**
+ * Created by GUY on 2015/9/7.
+ * @class BI.DateCalendarPopup
+ * @extends BI.Widget
+ */
+BI.DateCalendarPopup = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-date-calendar-popup",
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ selectedTime: null
+ })
+ },
+
+ _createNav: function (v) {
+ var date = BI.Calendar.getDateJSONByPage(v);
+ var calendar = BI.createWidget({
+ type: "bi.calendar",
+ logic: {
+ dynamic: true
+ },
+ min: this.options.min,
+ max: this.options.max,
+ year: date.year,
+ month: date.month,
+ day: this.selectedTime.day
+ });
+ return calendar;
+ },
+
+ _init: function () {
+ BI.DateCalendarPopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.today = new Date();
+ this._year = this.today.getFullYear();
+ this._month = this.today.getMonth();
+ this._day = this.today.getDate();
+
+ this.selectedTime = o.selectedTime || {
+ year: this._year,
+ month: this._month,
+ day: this._day
+ };
+ this.datePicker = BI.createWidget({
+ type: "bi.date_picker",
+ min: o.min,
+ max: o.max
+ });
+
+ this.calendar = BI.createWidget({
+ direction: "top",
+ element: this,
+ logic: {
+ dynamic: true
+ },
+ type: "bi.navigation",
+ tab: this.datePicker,
+ cardCreator: BI.bind(this._createNav, this),
+
+ afterCardCreated: function () {
+
+ },
+
+ afterCardShow: function () {
+ this.setValue(self.selectedTime);
+ }
+ });
+
+ this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
+ self.selectedTime = self.datePicker.getValue();
+ self.selectedTime.day = 1;
+ self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
+ });
+
+ this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedTime = self.calendar.getValue();
+ self.setValue(self.selectedTime);
+ self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (timeOb) {
+ this.datePicker.setValue(timeOb);
+ this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb));
+ this.calendar.setValue(timeOb);
+ this.selectedTime = timeOb;
+ },
+
+ getValue: function () {
+ return this.selectedTime;
+ }
+});
+BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);/**
+ * 日期控件中的年份或月份trigger
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.DateTriangleTrigger
+ * @extends BI.Trigger
+ */
+BI.DateTriangleTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ height: 25,
+ iconWidth: 16,
+ iconHeight: 13
+ },
+
+ _defaultConfig: function() {
+ return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer",
+ height: 25
+ });
+ },
+ _init: function() {
+ BI.DateTriangleTrigger.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "right",
+ text: o.text,
+ value: o.value,
+ height: c.height
+ })
+ this.icon = BI.createWidget({
+ type: "bi.icon",
+ width: c.iconWidth,
+ height: c.iconHeight
+ });
+
+ BI.createWidget({
+ type: "bi.center_adapt",
+ element: this,
+ items: [{
+ type: "bi.center_adapt",
+ width: 50,
+ height: c.height,
+ items: [this.text, this.icon]
+ }]
+ })
+ },
+
+ setValue: function(v){
+ this.text.setValue(v);
+ },
+
+ getValue: function(){
+ return this.text.getValue();
+ },
+
+ setText: function(v){
+ this.text.setText(v);
+ },
+
+ getText: function(){
+ return this.item.getText();
+ },
+
+ getKey: function(){
+
+ }
+});
+BI.shortcut('bi.date_triangle_trigger', BI.DateTriangleTrigger);/**
+ * 日期下拉框
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.DateCombo
+ * @extends BI.Widget
+ */
+BI.DateCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-date-combo bi-border",
+ height: 30
+ });
+ },
+ _init: function () {
+ BI.DateCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.date_trigger"
+ });
+
+ this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
+ self.combo.toggle();
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.date_calendar_popup"
+ });
+
+ this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ width: 270,
+ el: this.popup,
+ stopPropagation: false
+ }
+ })
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ triggerWidth: 30,
+ yearLength: 4,
+ yearMonthLength: 7
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-date-trigger",
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.DateTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ var date = v.match(/\d+/g);
+ self._autoAppend(v, date);
+ return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({
+ year: date[0],
+ month: date[1],
+ day: date[2]
+ });
+ },
+ quitChecker: function () {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ errorText: function () {
+ if (self.editor.isEditing()) {
+ return BI.i18nText("BI-Date_Trigger_Error_Text");
+ }
+ return BI.i18nText("BI-Year_Trigger_Invalid_Text");
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN)
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_STOP);
+ });
+ this.editor.on(BI.SignEditor.EVENT_VALID, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_VALID);
+ });
+ this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_ERROR);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setState(value);
+ }
+
+ if (BI.isNotEmptyString(value)) {
+ var date = value.split("-");
+ self.store_value = {
+ type: BI.DateTrigger.MULTI_DATE_CALENDAR,
+ value:{
+ year: date[0] | 0,
+ month: date[1] - 1,
+ day: date[2] | 0
+ }
+ };
+ }
+ self.fireEvent(BI.DateTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DateTrigger.EVENT_CHANGE);
+ });
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: BI.createWidget(),
+ width: 30
+ }, {
+ el: this.editor
+ }]
+ })
+ },
+ _dateCheck: function (date) {
+ return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date;
+ },
+ _checkVoid: function (obj) {
+ return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0];
+ },
+ _autoAppend: function (v, dateObj) {
+ var self = this;
+ var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d");
+ var yearCheck = function (v) {
+ return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max;
+ };
+ var monthCheck = function (v) {
+ return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max;
+ };
+ if (BI.isNotNull(dateObj) && Date.checkLegal(v)) {
+ switch (v.length) {
+ case this._const.yearLength:
+ if (yearCheck(v)) {
+ this.editor.setValue(v + "-");
+ }
+ break;
+ case this._const.yearMonthLength:
+ if (monthCheck(v)) {
+ this.editor.setValue(v + "-");
+ }
+ break;
+ }
+ }
+ },
+
+ setValue: function (v) {
+ var type, value, self = this;
+ var date = new Date();
+ this.store_value = v;
+ if (BI.isNotNull(v)) {
+ type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value;
+ if(BI.isNull(value)){
+ value = v;
+ }
+ }
+ var _setInnerValue = function (date, text) {
+ var dateStr = date.print("%Y-%x-%e");
+ self.editor.setState(dateStr);
+ self.editor.setValue(dateStr);
+ self.setTitle(text + ":" + dateStr);
+ };
+ switch (type) {
+ case BI.DateTrigger.MULTI_DATE_YEAR_PREV:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];
+ date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate());
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];
+ date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate());
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];
+ date = new Date(date.getFullYear(), 0, 1);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_YEAR_END:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];
+ date = new Date(date.getFullYear(), 11, 31);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];
+ date = new Date().getBeforeMulQuarter(value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];
+ date = new Date().getAfterMulQuarter(value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];
+ date = new Date().getQuarterStartDate();
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_QUARTER_END:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];
+ date = new Date().getQuarterEndDate();
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_MONTH_PREV:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];
+ date = new Date().getBeforeMultiMonth(value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];
+ date = new Date().getAfterMultiMonth(value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];
+ date = new Date(date.getFullYear(), date.getMonth(), 1);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_MONTH_END:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];
+ date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate());
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_WEEK_PREV:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];
+ date = date.getOffsetDate(-7 * value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];
+ date = date.getOffsetDate(7 * value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_DAY_PREV:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];
+ date = date.getOffsetDate(-1 * value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_DAY_AFTER:
+ var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];
+ date = date.getOffsetDate(1 * value);
+ _setInnerValue(date, text);
+ break;
+ case BI.DateTrigger.MULTI_DATE_DAY_TODAY:
+ var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];
+ date = new Date();
+ _setInnerValue(date, text);
+ break;
+ default:
+ if (BI.isNull(value) || BI.isNull(value.day)) {
+ this.editor.setState("");
+ this.editor.setValue("");
+ this.setTitle("");
+ } else {
+ var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day;
+ this.editor.setState(dateStr);
+ this.editor.setValue(dateStr);
+ this.setTitle(dateStr);
+ }
+ break;
+ }
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+ getValue: function () {
+ return this.store_value;
+ }
+
+});
+
+BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1;
+BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2;
+BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3;
+BI.DateTrigger.MULTI_DATE_YEAR_END = 4;
+
+BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5;
+BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6;
+BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7;
+BI.DateTrigger.MULTI_DATE_MONTH_END = 8;
+
+BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9;
+BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10;
+BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11;
+BI.DateTrigger.MULTI_DATE_QUARTER_END = 12;
+
+BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13;
+BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14;
+
+BI.DateTrigger.MULTI_DATE_DAY_PREV = 15;
+BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16;
+BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17;
+
+BI.DateTrigger.MULTI_DATE_PARAM = 18;
+BI.DateTrigger.MULTI_DATE_CALENDAR = 19;
+
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {};
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End");
+
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End");
+
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End");
+
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next");
+
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next");
+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today");
+
+BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.DateTrigger.EVENT_START = "EVENT_START";
+BI.DateTrigger.EVENT_STOP = "EVENT_STOP";
+BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DateTrigger.EVENT_VALID = "EVENT_VALID";
+BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR";
+BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.shortcut("bi.date_trigger", BI.DateTrigger);/**
+ * Created by zcf on 2017/2/20.
+ */
+BI.DatePaneWidget = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-date-pane-widget",
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ selectedTime: null
+ })
+ },
+ _init: function () {
+ BI.DatePaneWidget.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.today = new Date();
+ this._year = this.today.getFullYear();
+ this._month = this.today.getMonth();
+
+ this.selectedTime = o.selectedTime || {
+ year: this._year,
+ month: this._month
+ };
+
+ this.datePicker = BI.createWidget({
+ type: "bi.date_picker",
+ min: o.min,
+ max: o.max
+ });
+ this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
+ self.selectedTime = self.datePicker.getValue();
+ // self.selectedTime.day = 1;
+ self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
+ });
+
+ this.calendar = BI.createWidget({
+ direction: "top",
+ element: this,
+ logic: {
+ dynamic: false
+ },
+ type: "bi.navigation",
+ tab: this.datePicker,
+ cardCreator: BI.bind(this._createNav, this)
+
+ // afterCardCreated: function () {
+ //
+ // },
+ //
+ // afterCardShow: function () {
+ // // this.setValue(self.selectedTime);
+ // }
+ });
+ this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedTime = self.calendar.getValue();
+ self.calendar.empty();
+ self.setValue(self.selectedTime);
+ self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
+ });
+
+ },
+
+ _createNav: function (v) {
+ var date = BI.Calendar.getDateJSONByPage(v);
+ var calendar = BI.createWidget({
+ type: "bi.calendar",
+ logic: {
+ dynamic: false
+ },
+ min: this.options.min,
+ max: this.options.max,
+ year: date.year,
+ month: date.month,
+ day: this.selectedTime.day
+ });
+ return calendar;
+ },
+
+ _getNewCurrentDate: function () {
+ var today = new Date();
+ return {
+ year: today.getFullYear(),
+ month: today.getMonth()
+ }
+ },
+
+ _setCalenderValue: function (date) {
+ this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date));
+ this.calendar.setValue(date);
+ this.selectedTime = date;
+ },
+
+ _setDatePicker: function (timeOb) {
+ if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) {
+ this.datePicker.setValue(this._getNewCurrentDate());
+ } else {
+ this.datePicker.setValue(timeOb);
+ }
+ },
+
+ _setCalendar: function (timeOb) {
+ if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) {
+ this.calendar.empty();
+ this._setCalenderValue(this._getNewCurrentDate());
+ } else {
+ this._setCalenderValue(timeOb)
+ }
+ },
+
+ setValue: function (timeOb) {
+ this._setDatePicker(timeOb);
+ this._setCalendar(timeOb);
+ },
+
+ getValue: function () {
+ return this.selectedTime;
+ }
+
+});
+BI.shortcut("bi.date_pane_widget", BI.DatePaneWidget);/**
+ * 带有方向的pathchooser
+ *
+ * Created by GUY on 2016/4/21.
+ * @class BI.DirectionPathChooser
+ * @extends BI.Widget
+ */
+BI.DirectionPathChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ lineColor: "#808080",
+ selectLineColor: "#009de3"
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DirectionPathChooser.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-excel-table",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.DirectionPathChooser.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.pathChooser = BI.createWidget({
+ type: "bi.path_chooser",
+ element: this,
+ items: o.items
+ });
+ this.pathChooser.on(BI.PathChooser.EVENT_CHANGE, function (start, index) {
+ //self._unselectAllArrows();
+ self._setValue(start, index);
+ self.fireEvent(BI.DirectionPathChooser.EVENT_CHANGE);
+ });
+ this._drawArrows();
+
+ },
+
+ _unselectAllArrows: function () {
+ var self = this, lineColor = this._const.lineColor;
+ BI.each(this.arrows, function (region, rs) {
+ BI.each(rs, function (idx, arrows) {
+ BI.each(arrows, function (i, arrow) {
+ arrow.attr({fill: lineColor, stroke: lineColor});
+ });
+ });
+ });
+ },
+
+ _drawOneArrow: function (dot, direction) {
+ //0,1,2,3 上右下左
+ var lineColor = this._const.lineColor;
+ var selectLineColor = this._const.selectLineColor;
+ var svg = this.pathChooser.svg;
+ var path = "";
+ switch (direction) {
+ case 0:
+ path = "M" + dot.x + "," + dot.y
+ + "L" + (dot.x - 3) + "," + (dot.y + 5)
+ + "L" + (dot.x + 3) + "," + (dot.y + 5)
+ + "L" + dot.x + "," + dot.y;
+ break;
+ case 1:
+ path = "M" + dot.x + "," + dot.y
+ + "L" + (dot.x - 5) + "," + (dot.y - 3)
+ + "L" + (dot.x - 5) + "," + (dot.y + 3)
+ + "L" + dot.x + "," + dot.y;
+ break;
+ case 2:
+ path = "M" + dot.x + "," + dot.y
+ + "L" + (dot.x - 3) + "," + (dot.y - 5)
+ + "L" + (dot.x + 3) + "," + (dot.y - 5)
+ + "L" + dot.x + "," + dot.y;
+ break;
+ case 3:
+ path = "M" + dot.x + "," + dot.y
+ + "L" + (dot.x + 5) + "," + (dot.y - 3)
+ + "L" + (dot.x + 5) + "," + (dot.y + 3)
+ + "L" + dot.x + "," + dot.y;
+ break;
+ }
+ return svg.path(path).attr({fill: lineColor, stroke: lineColor});
+ },
+
+ _drawArrows: function () {
+ var self = this, o = this.options;
+ var routes = this.pathChooser.routes;
+ var pathes = this.pathChooser.pathes;
+ var store = this.pathChooser.store;
+ this.arrows = {};
+ BI.each(routes, function (region, ps) {
+ self.arrows[region] = [];
+ BI.each(ps, function (idx, path) {
+ self.arrows[region][idx] = [];
+ var dots = pathes[region][idx];
+ BI.each(dots, function (i, dot) {
+ if (i > 0 && i < dots.length - 1) {
+ var arrow;
+ if (dot.y === dots[i - 1].y) {
+ if (dots[i + 1].y != dot.y) {
+ if (store[path[path.length - 2]].direction === -1) {
+ if (i - 1 > 0) {
+ arrow = self._drawOneArrow(dots[i - 1], 3);
+ }
+ } else {
+ arrow = self._drawOneArrow(dots[i], 1);
+ }
+ }
+ } else if (dot.x === dots[i - 1].x) {
+ if (dot.y > dots[i - 1].y) {
+ if (store[BI.first(path)].direction === -1) {
+ arrow = self._drawOneArrow(dots[i - 1], 0);
+ } else {
+ arrow = self._drawOneArrow(dot, 2);
+ }
+ } else {
+ if (store[path[path.length - 2]].direction === -1) {
+ arrow = self._drawOneArrow(dots[i - 1], 2);
+ } else {
+ arrow = self._drawOneArrow(dot, 0);
+ }
+ }
+ }
+ if (arrow) {
+ self.arrows[region][idx].push(arrow);
+ }
+ }
+ });
+ BI.each(path, function (i, node) {
+ if (i !== 0) {
+ var arrow;
+ var from = path[i - 1];
+ if (store[from].direction === -1) {
+ var regionIndex = self.pathChooser.getRegionIndexById(from);
+ var x = getXoffsetByRegionIndex(regionIndex, -1);
+ var y = getYByXoffset(dots, x);
+ arrow = self._drawOneArrow({x: x, y: y}, 3);
+ } else {
+ var regionIndex = self.pathChooser.getRegionIndexById(node);
+ var x = getXoffsetByRegionIndex(regionIndex);
+ var y = getYByXoffset(dots, x);
+ arrow = self._drawOneArrow({x: x, y: y}, 1);
+ }
+ if (arrow) {
+ self.arrows[region][idx].push(arrow);
+ }
+ }
+ });
+ })
+ });
+
+ function getXoffsetByRegionIndex(regionIndex, diregion) {
+ if (diregion === -1) {
+ return 100 * (regionIndex + 1) - 20;
+ }
+ return 100 * regionIndex + 20;
+ }
+
+ function getYByXoffset(dots, xoffset) {
+ var finded = BI.find(dots, function (i, dot) {
+ if (i > 0) {
+ if (dots[i - 1].x < xoffset && dots[i].x > xoffset) {
+ return true;
+ }
+ }
+ });
+ return finded.y;
+ }
+ },
+
+ _setValue: function (start, index) {
+ var self = this;
+ var lineColor = this._const.lineColor;
+ var selectLineColor = this._const.selectLineColor;
+ var routes = this.pathChooser.routes;
+ var starts = this.pathChooser.start;
+ var each = [start];
+ if (starts.contains(start)) {
+ each = starts;
+ }
+ BI.each(each, function (i, s) {
+ BI.each(self.arrows[s], function (j, arrows) {
+ BI.each(arrows, function (k, arrow) {
+ arrow.attr({fill: lineColor, stroke: lineColor}).toFront();
+ });
+ });
+ });
+ BI.each(this.arrows[start][index], function (i, arrow) {
+ arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront();
+ });
+ var current = BI.last(routes[start][index]);
+ while (current && routes[current] && routes[current].length === 1) {
+ BI.each(self.arrows[current][0], function (i, arrow) {
+ arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront();
+ });
+ current = BI.last(routes[current][0]);
+ }
+ },
+
+ setValue: function (v) {
+ this.pathChooser.setValue(v);
+ this._unselectAllArrows();
+ var routes = this.pathChooser.routes;
+ var nodes = BI.keys(routes), self = this;
+ var result = [], array = [];
+ BI.each(v, function (i, val) {
+ if (BI.contains(nodes, val)) {
+ if (array.length > 0) {
+ array.push(val);
+ result.push(array);
+ array = [];
+ }
+ }
+ array.push(val);
+ });
+ if (array.length > 0) {
+ result.push(array);
+ }
+ //画这n条路径
+ BI.each(result, function (idx, path) {
+ var start = path[0];
+ var index = BI.findIndex(routes[start], function (idx, p) {
+ if (BI.isEqual(path, p)) {
+ return true;
+ }
+ });
+ if (index >= 0) {
+ self._setValue(start, index);
+ }
+ });
+ },
+
+ getValue: function () {
+ return this.pathChooser.getValue();
+ },
+
+ populate: function (items) {
+ this.pathChooser.populate(items);
+ this._drawArrows();
+ }
+});
+BI.DirectionPathChooser.EVENT_CHANGE = "DirectionPathChooser.EVENT_CHANGE";
+BI.shortcut('bi.direction_path_chooser', BI.DirectionPathChooser);/**
+ * Created by roy on 15/8/14.
+ */
+BI.DownListCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-down-list-combo",
+ invalid: false,
+ height: 25,
+ items: [],
+ adjustLength: 0,
+ direction: "bottom",
+ el: {}
+ })
+ },
+
+ _init: function () {
+ BI.DownListCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.popupview = BI.createWidget({
+ type: "bi.down_list_popup",
+ items: o.items,
+ chooseType: o.chooseType
+ });
+
+ this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) {
+ self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
+ self.downlistcombo.hideView();
+ });
+
+ this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
+ self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
+ self.downlistcombo.hideView();
+ });
+
+
+ this.downlistcombo = BI.createWidget({
+ element: this,
+ type: 'bi.combo',
+ isNeedAdjustWidth: false,
+ adjustLength: o.adjustLength,
+ direction: o.direction,
+ el: BI.createWidget(o.el, {
+ type: "bi.icon_trigger",
+ extraCls: o.iconCls ? o.iconCls : "pull-down-font",
+ width: o.width,
+ height: o.height
+ }),
+ popup: {
+ el: this.popupview,
+ stopPropagation: true,
+ maxHeight: 1000
+ }
+ });
+
+ this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ hideView: function () {
+ this.downlistcombo.hideView();
+ },
+
+ showView: function () {
+ this.downlistcombo.showView();
+ },
+
+ populate: function (items) {
+ this.popupview.populate(items);
+ },
+
+ setValue: function (v) {
+ this.popupview.setValue(v);
+ },
+ getValue: function () {
+ return this.popupview.getValue()
+ }
+});
+BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
+BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+
+BI.shortcut("bi.down_list_combo", BI.DownListCombo);/**
+ * Created by roy on 15/9/6.
+ */
+BI.DownListGroup = BI.inherit(BI.Widget, {
+ constants: {
+ iconCls: "check-mark-ha-font"
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.DownListGroup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-down-list-group",
+ items: [
+ {
+ el: {}
+ }
+ ]
+ })
+ },
+ _init: function () {
+ BI.DownListGroup.superclass._init.apply(this, arguments);
+ var o = this.options, self = this;
+
+ this.downlistgroup = BI.createWidget({
+ element: this,
+ type: "bi.button_tree",
+ items: o.items,
+ chooseType: 0,//0单选,1多选
+ layouts: [{
+ type: "bi.vertical",
+ hgap: 0,
+ vgap: 0
+ }]
+ });
+ this.downlistgroup.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if(type === BI.Events.CLICK) {
+ self.fireEvent(BI.DownListGroup.EVENT_CHANGE, arguments);
+ }
+ })
+ },
+ getValue:function(){
+ return this.downlistgroup.getValue();
+ },
+ setValue:function(v){
+ this.downlistgroup.setValue(v);
+ }
+
+
+})
+BI.DownListGroup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.down_list_group", BI.DownListGroup);BI.DownListItem = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.DownListItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-down-list-item bi-list-item-active",
+ cls: "",
+ height: 25,
+ logic: {
+ dynamic: true
+ },
+ selected: false,
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ })
+ },
+ _init: function () {
+ BI.DownListItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.text = BI.createWidget({
+ type: "bi.icon_text_item",
+ element: this,
+ height: o.height,
+ text: o.text,
+ value: o.value,
+ logic: o.logic,
+ selected: o.selected,
+ disabled: o.disabled,
+ iconHeight: o.iconHeight,
+ iconWidth: o.iconWidth,
+ textHgap: o.textHgap,
+ textVgap: o.textVgap,
+ textLgap: o.textLgap,
+ textRgap: o.textRgap,
+ father: o.father
+ });
+ this.text.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.text.on(BI.IconTextItem.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DownListItem.EVENT_CHANGE);
+ });
+ // this.setSelected(o.selected);
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ isSelected: function () {
+ return this.text.isSelected();
+ },
+
+ setSelected: function (b) {
+ this.text.setSelected(b);
+ // if (b === true) {
+ // this.element.addClass("dot-e-font");
+ // } else {
+ // this.element.removeClass("dot-e-font");
+ // }
+ },
+
+ setValue: function (v) {
+ this.text.setValue(v);
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ }
+});
+BI.DownListItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ var conf = BI.DownListGroupItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-down-list-group-item",
+ logic: {
+ dynamic: false
+ },
+ // invalid: true,
+ iconCls1: "dot-e-font",
+ iconCls2: "pull-right-e-font"
+ })
+ },
+ _init: function () {
+ BI.DownListGroupItem.superclass._init.apply(this, arguments);
+ var o = this.options;
+ var self = this;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-group-item-text",
+ textAlign: "left",
+ text: o.text,
+ value: o.value,
+ height: o.height
+ });
+
+ this.icon1 = BI.createWidget({
+ type: "bi.icon_button",
+ cls: o.iconCls1,
+ width: 25,
+ forceNotSelected: true
+ });
+
+ this.icon2 = BI.createWidget({
+ type: "bi.icon_button",
+ cls: o.iconCls2,
+ width: 25,
+ forceNotSelected: true
+ });
+
+ var blank = BI.createWidget({
+ type: "bi.layout",
+ width: 25
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.icon2,
+ top: 0,
+ bottom: 0,
+ right: 0
+ }]
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank)
+ }))));
+
+ this.element.hover(function () {
+ if (self.isEnabled()) {
+ self.hover();
+ }
+ }, function () {
+ if (self.isEnabled()) {
+ self.dishover()
+ }
+ });
+ },
+
+ hover: function () {
+ BI.DownListGroupItem.superclass.hover.apply(this, arguments);
+ this.icon1.element.addClass("hover");
+ this.icon2.element.addClass("hover");
+
+ },
+
+ dishover: function () {
+ BI.DownListGroupItem.superclass.dishover.apply(this, arguments);
+ this.icon1.element.removeClass("hover");
+ this.icon2.element.removeClass("hover");
+ },
+
+ doClick: function () {
+ BI.DownListGroupItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.DownListGroupItem.EVENT_CHANGE, this.getValue());
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ setValue: function (v) {
+ var self = this, o = this.options;
+ v = BI.isArray(v) ? v : [v];
+ BI.find(v, function (idx, value) {
+ if (BI.contains(o.childValues, value)) {
+ self.icon1.setSelected(true);
+ return true;
+ } else {
+ self.icon1.setSelected(false);
+ }
+ })
+ }
+});
+BI.DownListGroupItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem);/**
+ * Created by roy on 15/9/8.
+ * 处理popup中的item分组样式
+ * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项
+ */
+BI.DownListPopup = BI.inherit(BI.Pane, {
+ constants: {
+ nextIcon: "pull-right-e-font",
+ height: 25,
+ iconHeight: 12,
+ iconWidth: 12,
+ hgap: 0,
+ vgap: 0,
+ border: 1
+ },
+ _defaultConfig: function () {
+ var conf = BI.DownListPopup.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-down-list-popup",
+ items: [],
+ chooseType: BI.Selection.Multi
+ })
+ },
+ _init: function () {
+ BI.DownListPopup.superclass._init.apply(this, arguments);
+ this.singleValues = [];
+ this.childValueMap = {};
+ this.fatherValueMap = {};
+ var self = this, o = this.options, children = this._createChildren(o.items);
+ this.popup = BI.createWidget({
+ type: "bi.button_tree",
+ items: BI.createItems(children,
+ {}, {
+ adjustLength: -2
+ }
+ ),
+ layouts: [{
+ type: "bi.vertical",
+ hgap: this.constants.hgap,
+ vgap: this.constants.vgap
+ }],
+ chooseType: o.chooseType
+ });
+
+ this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) {
+ var changedValue = value;
+ if (BI.isNotNull(self.childValueMap[value])) {
+ changedValue = self.childValueMap[value];
+ self.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, self.fatherValueMap[value])
+ } else {
+ self.fireEvent(BI.DownListPopup.EVENT_CHANGE, changedValue, object);
+ }
+
+
+ if (!self.singleValues.contains(changedValue)) {
+ var item = self.getValue();
+ var result = [];
+ BI.each(item, function (i, valueObject) {
+ if (valueObject.value != changedValue) {
+ result.push(valueObject);
+ }
+ });
+ self.setValue(result);
+ }
+
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.popup]
+ });
+
+ },
+ _createChildren: function (items) {
+ var self = this, result = [];
+ BI.each(items, function (i, it) {
+ var item_done = {
+ type: "bi.down_list_group",
+ items: []
+ };
+
+ BI.each(it, function (i, item) {
+ if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) {
+ item.type = "bi.combo_group";
+ item.cls = "down-list-group";
+ item.trigger = "hover";
+ item.isNeedAdjustWidth = false;
+ item.el.title = item.el.title || item.el.text;
+ item.el.type = "bi.down_list_group_item";
+ item.el.logic = {
+ dynamic: true
+ };
+ item.el.height = self.constants.height;
+ item.el.iconCls2 = self.constants.nextIcon;
+ item.popup = {
+ lgap: 4,
+ el: {
+ type: "bi.button_tree",
+ chooseType: 0,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+
+ }
+ };
+ item.el.childValues = [];
+ BI.each(item.children, function (i, child) {
+ var fatherValue = BI.deepClone(item.el.value);
+ var childValue = BI.deepClone(child.value);
+ self.singleValues.push(child.value);
+ child.type = "bi.down_list_item";
+ child.extraCls = " child-down-list-item";
+ child.title = child.title || child.text;
+ child.textRgap = 10;
+ child.isNeedAdjustWidth = false;
+ child.logic = {
+ dynamic: true
+ };
+ child.father = fatherValue;
+ self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
+ self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
+ child.value = self._createChildValue(fatherValue, childValue);
+ item.el.childValues.push(child.value);
+ })
+ } else {
+ item.type = "bi.down_list_item";
+ item.title = item.title || item.text;
+ item.textRgap = 10;
+ item.isNeedAdjustWidth = false;
+ item.logic = {
+ dynamic: true
+ }
+ }
+ var el_done = {};
+ el_done.el = item;
+ item_done.items.push(el_done);
+ });
+ if (self._isGroup(item_done.items)) {
+ BI.each(item_done.items, function (i, item) {
+ self.singleValues.push(item.el.value);
+ })
+ }
+
+ result.push(item_done);
+ if (self._needSpliter(i, items.length)) {
+ var spliter_container = BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ el: {
+ type: "bi.layout",
+ cls: "bi-down-list-spliter bi-border-top cursor-pointer",
+ height: 0
+ }
+
+ }],
+ cls: "bi-down-list-spliter-container cursor-pointer",
+ lgap: 10,
+ rgap: 10
+ });
+ result.push(spliter_container);
+ }
+ });
+ return result;
+ },
+
+ _isGroup: function (i) {
+ return i.length > 1;
+ },
+
+ _needSpliter: function (i, itemLength) {
+ return i < itemLength - 1;
+ },
+
+ _createChildValue: function (fatherValue, childValue) {
+ return fatherValue + "_" + childValue
+ },
+
+ populate: function (items) {
+ BI.DownListPopup.superclass.populate.apply(this, arguments);
+ var self = this;
+ self.childValueMap = {};
+ self.fatherValueMap = {};
+ self.singleValues = [];
+ var children = self._createChildren(items);
+ var popupItem = BI.createItems(children,
+ {}, {
+ adjustLength: -2
+ }
+ );
+ self.popup.populate(popupItem);
+ },
+
+ setValue: function (valueItem) {
+ var self = this;
+ var valueArray = [];
+ BI.each(valueItem, function (i, item) {
+ var value;
+ if (BI.isNotNull(item.childValue)) {
+ value = self._createChildValue(item.value, item.childValue);
+ } else {
+ value = item.value;
+ }
+ valueArray.push(value);
+ }
+ );
+ this.popup.setValue(valueArray);
+ },
+
+ getValue: function () {
+ var self = this, result = [];
+ var values = this.popup.getValue();
+ BI.each(values, function (i, value) {
+ var valueItem = {};
+ if (BI.isNotNull(self.childValueMap[value])) {
+ var fartherValue = self.fatherValueMap[value];
+ valueItem.childValue = self.childValueMap[value];
+ valueItem.value = fartherValue;
+ } else {
+ valueItem.value = value;
+ }
+ result.push(valueItem);
+ });
+ return result;
+ }
+
+
+});
+
+BI.DownListPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
+BI.shortcut("bi.down_list_popup", BI.DownListPopup);/**
+ *
+ * Created by GUY on 2016/3/28.
+ * @class BI.ExcelTableCell
+ * @extends BI.Widget
+ */
+BI.ExcelTableCell = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ExcelTableCell.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-excel-table-cell",
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.ExcelTableCell.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: "left",
+ whiteSpace: "normal",
+ height: this.options.height,
+ text: this.options.text,
+ value: this.options.value
+ })
+ }
+});
+BI.shortcut('bi.excel_table_cell', BI.ExcelTableCell);/**
+ *
+ * Created by GUY on 2016/3/28.
+ * @class BI.ExcelTableHeaderCell
+ * @extends BI.Widget
+ */
+BI.ExcelTableHeaderCell = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ExcelTableHeaderCell.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-excel-table-header-cell bi-background",
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.ExcelTableHeaderCell.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: BI.HorizontalAlign.Center,
+ whiteSpace: "normal",
+ height: this.options.height,
+ text: this.options.text,
+ value: this.options.value
+ })
+ }
+});
+BI.shortcut('bi.excel_table_header_cell', BI.ExcelTableHeaderCell);/**
+ * Excel表格
+ *
+ * Created by GUY on 2016/3/28.
+ * @class BI.ExcelTable
+ * @extends BI.Widget
+ */
+BI.ExcelTable = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-excel-table",
+ el: {
+ type: "bi.responsive_table"
+ },
+
+ isNeedResize: false,
+ isResizeAdapt: true,
+
+ isNeedMerge: false,//是否需要合并单元格
+ mergeCols: [], //合并的单元格列号
+ mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
+ return BI.isEqual(row1, row2);
+ },
+
+ columnSize: [],
+ headerRowSize: 37,
+ footerRowSize: 37,
+ rowSize: 37,
+
+ regionColumnSize: false,
+
+ items: [] //二维数组
+ });
+ },
+
+ _init: function () {
+ BI.ExcelTable.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var mergeCols = [];
+ BI.each(o.mergeCols, function (i, col) {
+ mergeCols.push(col + 1);
+ });
+ this.table = BI.createWidget(o.el, {
+ type: "bi.table_view",
+ element: this,
+
+ isNeedFreeze: false,
+
+ isNeedMerge: o.isNeedMerge,
+ mergeCols: mergeCols,
+ mergeRule: o.mergeRule,
+
+ columnSize: [""].concat(o.columnSize),
+ headerRowSize: 18,
+ rowSize: o.rowSize,
+
+ regionColumnSize: o.regionColumnSize || [82, ""]
+ });
+
+ if (BI.isNotEmptyArray(o.items)) {
+ this.populate(o.items);
+ }
+ BI.nextTick(function () {
+ self.setRegionColumnSize(o.regionColumnSize || [82, ""]);
+ });
+ },
+
+ resize: function () {
+ this.table.resize();
+ },
+
+ setColumnSize: function (columnSize) {
+ this.table.setColumnSize(columnSize);
+ },
+
+ getColumnSize: function () {
+ return this.table.getColumnSize();
+ },
+
+ getCalculateColumnSize: function () {
+ return this.table.getCalculateColumnSize();
+ },
+
+ setHeaderColumnSize: function (columnSize) {
+ this.table.setHeaderColumnSize(columnSize);
+ },
+
+ setRegionColumnSize: function (columnSize) {
+ this.table.setRegionColumnSize(columnSize);
+ },
+
+ getRegionColumnSize: function () {
+ return this.table.getRegionColumnSize();
+ },
+
+ getCalculateRegionColumnSize: function () {
+ return this.table.getCalculateRegionColumnSize();
+ },
+
+ getCalculateRegionRowSize: function () {
+ return this.table.getCalculateRegionRowSize();
+ },
+
+ getClientRegionColumnSize: function () {
+ return this.table.getClientRegionColumnSize();
+ },
+
+ getScrollRegionColumnSize: function () {
+ return this.table.getScrollRegionColumnSize();
+ },
+
+ getScrollRegionRowSize: function () {
+ return this.table.getScrollRegionRowSize();
+ },
+
+ hasVerticalScroll: function () {
+ return this.table.hasVerticalScroll();
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ this.table.setVerticalScroll(scrollTop);
+ },
+
+ setLeftHorizontalScroll: function (scrollLeft) {
+ this.table.setLeftHorizontalScroll(scrollLeft);
+ },
+
+ setRightHorizontalScroll: function (scrollLeft) {
+ this.table.setRightHorizontalScroll(scrollLeft);
+ },
+
+ getVerticalScroll: function () {
+ return this.table.getVerticalScroll();
+ },
+
+ getLeftHorizontalScroll: function () {
+ return this.table.getLeftHorizontalScroll();
+ },
+
+ getRightHorizontalScroll: function () {
+ return this.table.getRightHorizontalScroll();
+ },
+
+ getColumns: function () {
+ return this.table.getColumns();
+ },
+
+ resizeHeader: function () {
+ this.table.resize();
+ this.table._resizeHeader && this.table._resizeHeader();
+ },
+
+ attr: function (key,value) {
+ var self = this;
+ if (BI.isObject(key)) {
+ BI.each(key, function (k, v) {
+ self.attr(k, v);
+ });
+ return;
+ }
+ BI.ExcelTable.superclass.attr.apply(this, arguments);
+ switch (key){
+ case "mergeCols":
+ var mCols = [];
+ BI.each(value, function (i, col) {
+ mCols.push(col + 1);
+ });
+ value=mCols;
+ break;
+ }
+ this.table.attr.apply(this.table, arguments);
+ },
+
+ populate: function (rows) {
+ var self = this;
+ var columnSize = this.getColumnSize();
+ var items = [];
+ var header = [{
+ type: "bi.excel_table_header_cell"
+ }];
+ if (BI.isNotNull(rows)) {
+ BI.each(columnSize, function (i, size) {
+ header.push({
+ type: "bi.excel_table_header_cell",
+ text: BI.int2Abc(i + 1)
+ });
+ });
+ BI.each(rows, function (i, row) {
+ items.push([{
+ type: "bi.excel_table_header_cell",
+ text: (i + 1)
+ }].concat(row));
+ });
+ }
+ this.table.populate(items, [header]);
+ },
+
+ destroy: function () {
+ this.table.destroy();
+ BI.ExcelTable.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.shortcut('bi.excel_table', BI.ExcelTable);/**
+ * 文件管理控件组
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerButtonGroup
+ * @extends BI.Widget
+ */
+BI.FileManagerButtonGroup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-button_group",
+ items: []
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerButtonGroup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.button_group = BI.createWidget({
+ type: "bi.button_tree",
+ element: this,
+ chooseType: BI.Selection.Multi,
+ items: this._formatItems(o.items),
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _formatItems: function (items) {
+ var self = this, o = this.options;
+ BI.each(items, function (i, item) {
+ if (item.children && item.children.length > 0) {
+ item.type = "bi.file_manager_folder_item";
+ } else {
+ item.type = "bi.file_manager_file_item";
+ }
+ });
+ return items;
+ },
+
+ setValue: function (v) {
+ this.button_group.setValue(v);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getNotSelectedValue: function () {
+ return this.button_group.getNotSelectedValue();
+ },
+
+ getAllLeaves: function () {
+ return this.button_group.getAllLeaves();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ getSelectedButtons: function () {
+ return this.button_group.getSelectedButtons();
+ },
+
+ getNotSelectedButtons: function () {
+ return this.button_group.getNotSelectedButtons();
+ },
+
+ populate: function (items) {
+ this.button_group.populate(this._formatItems(items));
+ }
+});
+BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/**
+ * 文件管理控件
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManager
+ * @extends BI.Widget
+ */
+BI.FileManager = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager",
+ el: {},
+ items: []
+ })
+ },
+
+ _init: function () {
+ BI.FileManager.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.tree = new BI.Tree();
+ var items = BI.Tree.transformToTreeFormat(o.items);
+ this.tree.initTree(items);
+ this.selectedValues = [];
+ this.nav = BI.createWidget({
+ type: "bi.file_manager_nav",
+ items: BI.deepClone(items)
+ });
+ this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) {
+ if (value == "-1") {//根节点
+ self.populate({children: self.tree.toJSON()});
+ } else {
+ var node = self.tree.search(obj.attr("id"));
+ self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)}));
+ }
+ self.setValue(self.selectedValues);
+ });
+ this.list = BI.createWidget(o.el, {
+ type: "bi.file_manager_list",
+ items: items
+ });
+ this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) {
+ if (type === BI.Events.CHANGE) {
+ var node = self.tree.search(obj.attr("id"));
+ self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)}));
+ } else if (type === BI.Events.CLICK) {
+ var values = [];
+ if (obj instanceof BI.MultiSelectBar) {
+ var t = self.list.getValue();
+ selected = t.type === BI.Selection.All;
+ values = BI.concat(t.assist, t.value);
+ } else {
+ values = obj.getAllLeaves();
+ }
+ BI.each(values, function (i, v) {
+ if (selected === true) {
+ self.selectedValues.pushDistinct(v);
+ } else {
+ self.selectedValues.remove(v);
+ }
+ });
+ }
+ self.setValue(self.selectedValues);
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.list,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 10
+ }, {
+ el: this.nav,
+ left: 40,
+ right: 100,
+ top: 0
+ }]
+ });
+ },
+
+ setValue: function (value) {
+ this.selectedValues = value || [];
+ this.list.setValue(this.selectedValues);
+ },
+
+ getValue: function () {
+ var obj = this.list.getValue();
+ var res = obj.type === BI.Selection.All ? obj.assist : obj.value;
+ res.pushDistinctArray(this.selectedValues);
+ return res;
+ },
+
+ _populate: function (items) {
+ this.list.populate(items);
+ },
+
+ getSelectedValue: function () {
+ return this.nav.getValue()[0];
+ },
+
+ getSelectedId: function () {
+ return this.nav.getId()[0];
+ },
+
+ populate: function (node) {
+ var clone = BI.deepClone(node);
+ this._populate(node.children);
+ this.nav.populate(clone);
+ }
+});
+BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE";
+BI.shortcut("bi.file_manager", BI.FileManager);/**
+ * 文件管理控件
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerFileItem
+ * @extends BI.Single
+ */
+BI.FileManagerFileItem = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom",
+ height: 30
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerFileItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checked = BI.createWidget({
+ type: "bi.multi_select_bar",
+ text: "",
+ width: 36,
+ height: o.height
+ });
+ this.checked.on(BI.Controller.EVENT_CHANGE, function () {
+ arguments[2] = self;
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: this.checked,
+ width: 36
+ }, {
+ el: {
+ type: "bi.icon_button",
+ cls: "create-by-me-file-font"
+ },
+ width: 20
+ }, {
+ el: {
+ type: "bi.label",
+ textAlign: "left",
+ height: o.height,
+ text: o.text,
+ value: o.value
+ }
+ }]
+ })
+ },
+
+ getAllLeaves: function(){
+ return [this.options.value];
+ },
+
+ isSelected: function () {
+ return this.checked.isSelected();
+ },
+
+ setSelected: function (v) {
+ this.checked.setSelected(v);
+ }
+});
+BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/**
+ * 文件管理控件
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerFolderItem
+ * @extends BI.Single
+ */
+BI.FileManagerFolderItem = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom",
+ height: 30
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerFolderItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checked = BI.createWidget({
+ type: "bi.multi_select_bar",
+ text: "",
+ width: 36,
+ height: o.height
+ });
+ this.checked.on(BI.Controller.EVENT_CHANGE, function () {
+ arguments[2] = self;
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button = BI.createWidget({
+ type: "bi.text_button",
+ textAlign: "left",
+ height: o.height,
+ text: o.text,
+ value: o.value
+ });
+ this.button.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self);
+ });
+
+ this.tree = new BI.Tree();
+ this.tree.initTree([{
+ id: o.id,
+ children: o.children
+ }]);
+ this.selectValue = [];
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: this.checked,
+ width: 36
+ }, {
+ el: {
+ type: "bi.icon_button",
+ cls: "create-by-me-folder-font"
+ },
+ width: 20
+ }, {
+ el: this.button
+ }]
+ })
+ },
+
+ setAllSelected: function (v) {
+ this.checked.setSelected(v);
+ this.selectValue = [];
+ },
+
+ setHalfSelected: function (v) {
+ this.checked.setHalfSelected(v);
+ if(!v){
+ this.selectValue = [];
+ }
+ },
+
+ setValue: function (v) {
+ var self = this, o = this.options;
+ var isHalf = false;
+ var selectValue = [];
+ this.tree.traverse(function (node) {
+ if (node.isLeaf()) {
+ if (BI.contains(v, node.get("data").value)) {
+ selectValue.push(node.get("data").value);
+ } else {
+ isHalf = true;
+ }
+ }
+ });
+ this.setAllSelected(selectValue.length > 0 && !isHalf);
+ this.setHalfSelected(selectValue.length > 0 && isHalf);
+ if (this.checked.isHalfSelected()) {
+ this.selectValue = selectValue;
+ }
+ },
+
+ getAllButtons: function () {
+ return [this];
+ },
+
+ getAllLeaves: function () {
+ var o = this.options;
+ var res = [];
+ this.tree.traverse(function (node) {
+ if (node.isLeaf()) {
+ res.push(node.get("data").value)
+ }
+ });
+ return res;
+ },
+
+ getNotSelectedValue: function () {
+ var self = this, o = this.options;
+ var res = [];
+ var isAllSelected = this.checked.isSelected();
+ if (isAllSelected === true) {
+ return res;
+ }
+ var isHalfSelected = this.checked.isHalfSelected();
+ this.tree.traverse(function (node) {
+ if (node.isLeaf()) {
+ var v = node.get("data").value;
+ if (isHalfSelected === true) {
+ if (!BI.contains(self.selectValue, node.get("data").value)) {
+ res.push(v);
+ }
+ } else {
+ res.push(v);
+ }
+ }
+ });
+ return res;
+ },
+
+ getValue: function () {
+ var res = [];
+ if (this.checked.isSelected()) {
+ this.tree.traverse(function (node) {
+ if (node.isLeaf()) {
+ res.push(node.get("data").value);
+ }
+ });
+ return res;
+ }
+ if (this.checked.isHalfSelected()) {
+ return this.selectValue;
+ }
+ return [];
+ }
+});
+BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/**
+ * 文件管理控件列表
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerList
+ * @extends BI.Widget
+ */
+BI.FileManagerList = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-list",
+ el: {},
+ items: []
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerList.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.list = BI.createWidget({
+ type: "bi.select_list",
+ element: this,
+ items: o.items,
+ toolbar: {
+ type: "bi.multi_select_bar",
+ height: 40,
+ text: ""
+ },
+ el: {
+ type: "bi.list_pane",
+ el: BI.isWidget(o.el) ? o.el : BI.extend({
+ type: "bi.file_manager_button_group"
+ }, o.el)
+ }
+ });
+ this.list.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ },
+
+ setValue: function (v) {
+ this.list.setValue({
+ value: v
+ });
+ },
+
+ getValue: function () {
+ return this.list.getValue();
+ },
+
+ populate: function (items) {
+ this.list.populate(items);
+ this.list.setToolBarVisible(true);
+ }
+});
+BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_list", BI.FileManagerList);/**
+ * 文件管理导航按钮
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerNavButton
+ * @extends BI.Widget
+ */
+BI.FileManagerNavButton = BI.inherit(BI.Widget, {
+
+ _const: {
+ normal_color: "#ffffff",
+ select_color: "#f4f4f4"
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-nav-button",
+ selected: false,
+ height: 40
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerNavButton.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.button = BI.createWidget({
+ type: "bi.text_button",
+ cls: "file-manager-nav-button-text bi-card",
+ once: true,
+ selected: o.selected,
+ text: o.text,
+ title: o.text,
+ value: o.value,
+ height: o.height,
+ lgap: 20,
+ rgap: 10
+ });
+ this.button.on(BI.Controller.EVENT_CHANGE, function () {
+ arguments[2] = self;
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ var svg = BI.createWidget({
+ type: "bi.svg",
+ cls: "file-manager-nav-button-triangle",
+ width: 15,
+ height: o.height
+ });
+ var path = svg.path("M0,0L15,20L0,40").attr({
+ "stroke": c.select_color,
+ "fill": o.selected ? c.select_color : c.normal_color
+ });
+ this.button.on(BI.TextButton.EVENT_CHANGE, function () {
+ if (this.isSelected()) {
+ path.attr("fill", c.select_color);
+ } else {
+ path.attr("fill", c.normal_color);
+ }
+ });
+ BI.createWidget({
+ type: "bi.default",
+ element: this,
+ items: [this.button]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: svg,
+ right: -15,
+ top: 0,
+ bottom: 0
+ }]
+ })
+ },
+
+ isSelected: function () {
+ return this.button.isSelected();
+ },
+
+ setValue: function (v) {
+ this.button.setValue(v);
+ },
+
+ getValue: function () {
+ return this.button.getValue();
+ },
+
+ populate: function (items) {
+
+ }
+});
+BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/**
+ * 文件管理导航
+ *
+ * Created by GUY on 2015/12/11.
+ * @class BI.FileManagerNav
+ * @extends BI.Widget
+ */
+BI.FileManagerNav = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-file-manager-nav bi-border-left",
+ height: 40,
+ items: []
+ })
+ },
+
+ _init: function () {
+ BI.FileManagerNav.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.tree = new BI.Tree();
+ this.refreshTreeData(o.items);
+ this.tree.getRoot().set("data", {
+ text: BI.i18nText("BI-Created_By_Me"),
+ value: BI.FileManagerNav.ROOT_CREATE_BY_ME,
+ id: BI.FileManagerNav.ROOT_CREATE_BY_ME
+ });
+ this.button_group = BI.createWidget({
+ type: "bi.button_group",
+ element: this,
+ items: [{
+ type: "bi.file_manager_nav_button",
+ text: BI.i18nText("BI-Created_By_Me"),
+ selected: true,
+ id: BI.FileManagerNav.ROOT_CREATE_BY_ME,
+ value: BI.FileManagerNav.ROOT_CREATE_BY_ME
+ }],
+ layouts: [{
+ type: "bi.horizontal"
+ }]
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) {
+ self.fireEvent(BI.FileManagerNav.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _getAllParents: function (id) {
+ var node, res = [];
+ if (!id) {
+ node = this.tree.getRoot();
+ } else {
+ node = this.tree.search(id);
+ }
+ while (node.parent) {
+ res.push(node);
+ node = node.parent;
+ }
+ res.push(node);
+ return res.reverse();
+ },
+
+ _formatNodes: function (nodes) {
+ var res = [];
+ BI.each(nodes, function (i, node) {
+ res.push(BI.extend({
+ type: "bi.file_manager_nav_button",
+ id: node.id
+ }, node.get("data")));
+ });
+ BI.last(res).selected = true;
+ return res;
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getId: function () {
+ var ids = [];
+ BI.each(this.button_group.getSelectedButtons(), function (i, btn) {
+ ids.push(btn.attr("id"));
+ });
+ return ids;
+ },
+
+ refreshTreeData: function(items){
+ this.tree.initTree(BI.Tree.transformToTreeFormat(items));
+ this.tree.getRoot().set("data", {
+ text: BI.i18nText("BI-Created_By_Me"),
+ value: BI.FileManagerNav.ROOT_CREATE_BY_ME,
+ id: BI.FileManagerNav.ROOT_CREATE_BY_ME
+ });
+ },
+
+ populate: function (node) {
+ var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id);
+ this.button_group.populate(this._formatNodes(parents));
+ }
+});
+BI.extend(BI.FileManagerNav, {
+ ROOT_CREATE_BY_ME: "-1"
+});
+BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE";
+BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/**
+ * Created by windy on 2017/3/13.
+ * 数值微调器
+ */
+BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-fine-tuning-number-editor bi-border",
+ value: -1
+ })
+ },
+
+ _init: function () {
+ BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ value: this._alertInEditorValue(o.value),
+ errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
+ validationChecker: function(v){
+ return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1;
+ }
+ });
+ this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
+ self._finetuning(0);
+ self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
+ });
+ this.topBtn = BI.createWidget({
+ type: "bi.icon_button",
+ trigger: "lclick,",
+ cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
+ });
+ this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
+ self._finetuning(1);
+ self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
+ });
+ this.bottomBtn = BI.createWidget({
+ type: "bi.icon_button",
+ trigger: "lclick,",
+ cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
+ });
+ this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
+ self._finetuning(-1);
+ self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
+ });
+ this._finetuning(0);
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [this.editor, {
+ el: {
+ type: "bi.grid",
+ columns: 1,
+ rows: 2,
+ items: [{
+ column: 0,
+ row: 0,
+ el: this.topBtn
+ }, {
+ column: 0,
+ row: 1,
+ el: this.bottomBtn
+ }]
+ },
+ width: 30
+ }]
+ });
+ },
+
+ _alertOutEditorValue: function(v){
+ return v === BI.i18nText("BI-Basic_Auto") ? -1 : v;
+ },
+
+ _alertInEditorValue: function(v){
+ return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v;
+ },
+
+ //微调
+ _finetuning: function(add){
+ var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
+ this.editor.setValue(this._alertInEditorValue(v + add));
+ this.bottomBtn.setEnable((v + add) > -1);
+ },
+
+ getValue: function () {
+ var v = this.editor.getValue();
+ return this._alertOutEditorValue(v);
+ },
+
+ setValue: function (v) {
+ this.editor.setValue(this._alertInEditorValue(v));
+ this._finetuning(0);
+ }
+
+});
+BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/**
+ * 交互行为布局
+ *
+ *
+ * Created by GUY on 2016/7/23.
+ * @class BI.InteractiveArrangement
+ * @extends BI.Widget
+ */
+BI.InteractiveArrangement = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-interactive-arrangement",
+ resizable: true,
+ layoutType: BI.Arrangement.LAYOUT_TYPE.GRID,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.InteractiveArrangement.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.arrangement = BI.createWidget({
+ type: "bi.adaptive_arrangement",
+ element: this,
+ resizable: o.resizable,
+ layoutType: o.layoutType,
+ items: o.items
+ });
+ this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL, function () {
+ self.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL, arguments);
+ });
+ this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE, function () {
+ self.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE, arguments);
+ });
+
+ this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, function (id, size) {
+ var p = self._getRegionClientPosition(id);
+ self.draw({
+ left: p.left,
+ top: p.top
+ }, size, id);
+ });
+ this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, function (id, size) {
+ self.stopDraw();
+ self.setRegionSize(id, size);
+ });
+
+ this.tags = [];
+
+ },
+
+ _isEqual: function (num1, num2) {
+ return this.arrangement._isEqual(num1, num2);
+ },
+
+ _getScrollOffset: function () {
+ return this.arrangement._getScrollOffset();
+ },
+
+ _positionAt: function (position, regions) {
+ var self = this;
+ regions = regions || this.getAllRegions();
+ var left = [], center = [], right = [], top = [], middle = [], bottom = [];
+ BI.each(regions, function (i, region) {
+ var client = self._getRegionClientPosition(region.id);
+ if (Math.abs(client.left - position.left) <= 3) {
+ left.push(region);
+ }
+ if (Math.abs(client.left + client.width / 2 - position.left) <= 3) {
+ center.push(region);
+ }
+ if (Math.abs(client.left + client.width - position.left) <= 3) {
+ right.push(region);
+ }
+ if (Math.abs(client.top - position.top) <= 3) {
+ top.push(region);
+ }
+ if (Math.abs(client.top + client.height / 2 - position.top) <= 3) {
+ middle.push(region);
+ }
+ if (Math.abs(client.top + client.height - position.top) <= 3) {
+ bottom.push(region);
+ }
+ });
+ return {
+ left: left,
+ center: center,
+ right: right,
+ top: top,
+ middle: middle,
+ bottom: bottom
+ }
+ },
+
+ _getRegionClientPosition: function (name) {
+ var region = this.getRegionByName(name);
+ var offset = this.arrangement._getScrollOffset();
+ return {
+ top: region.top - offset.top,
+ left: region.left - offset.left,
+ width: region.width,
+ height: region.height,
+ id: region.id
+ }
+ },
+
+ _vAlign: function (position, regions) {
+ var self = this;
+ var vs = this._positionAt(position, regions);
+ var positions = [];
+ var l;
+ if (vs.left.length > 0) {
+ l = this._getRegionClientPosition(vs.left[0].id).left;
+ } else if (vs.right.length > 0) {
+ var temp = this._getRegionClientPosition(vs.right[0].id);
+ l = temp.left + temp.width;
+ }
+ var rs = vs.left.concat(vs.right);
+ BI.each(rs, function (i, region) {
+ var p = self._getRegionClientPosition(region.id);
+ if (self._isEqual(p.left, l) || self._isEqual(p.left + p.width, l)) {
+ var topPoint = {
+ top: p.top + p.height / 2,
+ left: l
+ };
+ positions.push({
+ id: region.id,
+ start: topPoint,
+ end: {
+ left: l,
+ top: position.top
+ }
+ });
+ }
+ });
+ return positions;
+ },
+
+ _leftAlign: function (position, size, regions) {
+ var self = this;
+ return this._vAlign({
+ left: position.left,
+ top: position.top + size.height / 2
+ }, regions);
+ },
+
+ _rightAlign: function (position, size, regions) {
+ var self = this;
+ return this._vAlign({
+ left: position.left + size.width,
+ top: position.top + size.height / 2
+ }, regions);
+ },
+
+ _hAlign: function (position, regions) {
+ var self = this;
+ var hs = this._positionAt(position, regions);
+ var positions = [];
+ var t;
+ if (hs.top.length > 0) {
+ var temp = this._getRegionClientPosition(hs.top[0].id);
+ t = temp.top;
+ } else if (hs.bottom.length > 0) {
+ var temp = this._getRegionClientPosition(hs.bottom[0].id);
+ t = temp.top + temp.height;
+ }
+ var rs = hs.top.concat(hs.bottom);
+ BI.each(rs, function (i, region) {
+ var p = self._getRegionClientPosition(region.id);
+ if (self._isEqual(p.top, t) || self._isEqual(p.top + p.height, t)) {
+ var leftPoint = {
+ top: t,
+ left: p.left + p.width / 2
+ };
+ positions.push({
+ id: p.id,
+ start: leftPoint,
+ end: {
+ left: position.left,
+ top: t
+ }
+ });
+ }
+ });
+ return positions;
+ },
+
+ _topAlign: function (position, size, regions) {
+ var self = this;
+ return this._hAlign({
+ left: position.left + size.width / 2,
+ top: position.top
+ }, regions);
+ },
+
+ _bottomAlign: function (position, size, regions) {
+ var self = this;
+ return this._hAlign({
+ left: position.left + size.width / 2,
+ top: position.top + size.height
+ }, regions);
+ },
+
+ _centerAlign: function (position, size, regions) {
+ var self = this;
+ var cs = this._positionAt({
+ left: position.left + size.width / 2,
+ top: position.top + size.height / 2
+ }, regions);
+ var positions = [];
+ var l;
+ if (cs.center.length > 0) {
+ var temp = this._getRegionClientPosition(cs.center[0].id);
+ l = temp.left + temp.width / 2;
+ }
+ BI.each(cs.center, function (i, region) {
+ var p = self._getRegionClientPosition(region.id);
+ if (self._isEqual(p.left + p.width / 2, l)) {
+ var topPoint = {
+ top: p.top + p.height / 2,
+ left: p.left + p.width / 2
+ };
+ positions.push({
+ id: p.id,
+ start: topPoint,
+ end: {
+ left: l,
+ top: position.top + size.height / 2
+ }
+ });
+ }
+ });
+ return positions;
+ },
+
+ _middleAlign: function (position, size, regions) {
+ var self = this;
+ var cs = this._positionAt({
+ left: position.left + size.width / 2,
+ top: position.top + size.height / 2
+ }, regions);
+ var positions = [];
+ var t;
+ if (cs.middle.length > 0) {
+ var temp = this._getRegionClientPosition(cs.middle[0].id);
+ t = temp.top + temp.height / 2;
+ }
+ BI.each(cs.middle, function (i, region) {
+ var p = self._getRegionClientPosition(region.id);
+ if (self._isEqual(p.top + p.height / 2, t)) {
+ var topPoint = {
+ top: p.top + p.height / 2,
+ left: p.left + p.width / 2
+ };
+ positions.push({
+ id: p.id,
+ start: topPoint,
+ end: {
+ left: position.left + size.width / 2,
+ top: t
+ }
+ });
+ }
+ });
+ return positions;
+ },
+
+
+ _drawOneTag: function (start, end) {
+ var s = BI.createWidget({
+ type: "bi.icon_button",
+ //invisible: true,
+ width: 13,
+ height: 13,
+ cls: "drag-tag-font interactive-arrangement-dragtag-icon"
+ });
+ var e = BI.createWidget({
+ type: "bi.icon_button",
+ //invisible: true,
+ width: 13,
+ height: 13,
+ cls: "drag-tag-font interactive-arrangement-dragtag-icon"
+ });
+ if (this._isEqual(start.left, end.left)) {
+ var line = BI.createWidget({
+ type: "bi.layout",
+ //invisible: true,
+ cls: "interactive-arrangement-dragtag-line",
+ width: 1,
+ height: Math.abs(start.top - end.top)
+ });
+ } else {
+ var line = BI.createWidget({
+ type: "bi.layout",
+ //invisible: true,
+ cls: "interactive-arrangement-dragtag-line",
+ height: 1,
+ width: Math.abs(start.left - end.left)
+ });
+ }
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: s,
+ left: start.left - 6,
+ top: start.top - 7
+ }, {
+ el: e,
+ left: end.left - 6,
+ top: end.top - 7
+ }, {
+ el: line,
+ left: Math.min(start.left, end.left),
+ top: Math.min(start.top, end.top)
+ }]
+ });
+ this.tags.push(s);
+ this.tags.push(e);
+ this.tags.push(line);
+ },
+
+ stopDraw: function () {
+ BI.each(this.tags, function (i, w) {
+ w.destroy();
+ });
+ this.tags = [];
+ },
+
+ _getRegionExcept: function (name, regions) {
+ var other = [];
+ BI.each(regions || this.getAllRegions(), function (i, region) {
+ if (!(name && region.id === name)) {
+ other.push(region);
+ }
+ });
+ return other;
+ },
+
+ getClientWidth: function () {
+ return this.arrangement.getClientWidth();
+ },
+
+ getClientHeight: function () {
+ return this.arrangement.getClientHeight();
+ },
+
+ getPosition: function (name, position, size) {
+ var regions = this.getAllRegions();
+ var me;
+ if (name) {
+ me = this._getRegionClientPosition(name);
+ }
+ var other = this._getRegionExcept(name, regions);
+ position = position || {
+ left: me.left,
+ top: me.top
+ };
+ size = size || {
+ width: me.width,
+ height: me.height
+ };
+ var left = this._leftAlign(position, size, other);
+ var right = this._rightAlign(position, size, other);
+ var top = this._topAlign(position, size, other, other);
+ var bottom = this._bottomAlign(position, size, other);
+ var center = this._centerAlign(position, size, other);
+ var middle = this._middleAlign(position, size, other);
+
+ BI.each(center, function (i, pos) {
+ position.left = pos.end.left - size.width / 2;
+ });
+ BI.each(right, function (i, pos) {
+ position.left = pos.end.left - size.width;
+ });
+ BI.each(left, function (i, pos) {
+ position.left = pos.end.left;
+ });
+ BI.each(middle, function (i, pos) {
+ position.top = pos.end.top - size.height / 2;
+ });
+ BI.each(bottom, function (i, pos) {
+ position.top = pos.end.top - size.height;
+ });
+ BI.each(top, function (i, pos) {
+ position.top = pos.end.top;
+ });
+ return position;
+ },
+
+ //position不动 变size
+ getSize: function (name, position, size) {
+ var regions = this.getAllRegions();
+ var me;
+ if (name) {
+ me = this._getRegionClientPosition(name);
+ }
+ var other = this._getRegionExcept(name, regions);
+ position = position || {
+ left: me.left,
+ top: me.top
+ };
+ size = size || {
+ width: me.width,
+ height: me.height
+ };
+ var left = this._leftAlign(position, size, other);
+ var right = this._rightAlign(position, size, other);
+ var top = this._topAlign(position, size, other, other);
+ var bottom = this._bottomAlign(position, size, other);
+ var center = this._centerAlign(position, size, other);
+ var middle = this._middleAlign(position, size, other);
+
+ BI.each(center, function (i, pos) {
+ size.width = (pos.end.left - position.left) * 2;
+ });
+ BI.each(right, function (i, pos) {
+ size.width = pos.end.left - position.left;
+ });
+ BI.each(left, function (i, pos) {
+ });
+ BI.each(middle, function (i, pos) {
+ size.height = (pos.end.top - position.top) * 2;
+ });
+ BI.each(bottom, function (i, pos) {
+ size.height = pos.end.top - position.top;
+ });
+ BI.each(top, function (i, pos) {
+ });
+ return size;
+ },
+
+ draw: function (position, size, name) {
+ var self = this;
+ this.stopDraw();
+ switch (this.getLayoutType()) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ var other = this._getRegionExcept(name);
+ var left = this._leftAlign(position, size, other);
+ var right = this._rightAlign(position, size, other);
+ var top = this._topAlign(position, size, other);
+ var bottom = this._bottomAlign(position, size, other);
+ var center = this._centerAlign(position, size, other);
+ var middle = this._middleAlign(position, size, other);
+
+ BI.each(center, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ BI.each(right, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ BI.each(left, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ BI.each(middle, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ BI.each(bottom, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ BI.each(top, function (i, pos) {
+ self._drawOneTag(pos.start, pos.end);
+ });
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ break;
+ }
+ },
+
+ addRegion: function (region, position) {
+ this.stopDraw();
+ return this.arrangement.addRegion(region, position);
+ },
+
+ deleteRegion: function (name) {
+ return this.arrangement.deleteRegion(name);
+ },
+
+ setRegionSize: function (name, size) {
+ size = this.getSize(name, null, size);
+ return this.arrangement.setRegionSize(name, size);
+ },
+
+ setPosition: function (position, size) {
+ var self = this;
+ this.stopDraw();
+ if (position.left > 0 && position.top > 0) {
+ switch (this.getLayoutType()) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ position = this.getPosition(null, position, size);
+ this.draw(position, size);
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ break;
+ }
+ }
+ var at = this.arrangement.setPosition(position, size);
+ return at;
+ },
+
+ setRegionPosition: function (name, position) {
+ if (position.left > 0 && position.top > 0) {
+ switch (this.getLayoutType()) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ position = this.getPosition(name, position);
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ break;
+ }
+ }
+ return this.arrangement.setRegionPosition(name, position);
+ },
+
+ setDropPosition: function (position, size) {
+ var self = this;
+ this.stopDraw();
+ if (position.left > 0 && position.top > 0) {
+ switch (this.getLayoutType()) {
+ case BI.Arrangement.LAYOUT_TYPE.FREE:
+ position = this.getPosition(null, position, size);
+ this.draw(position, size);
+ break;
+ case BI.Arrangement.LAYOUT_TYPE.GRID:
+ break;
+ }
+ }
+ var callback = self.arrangement.setDropPosition(position, size);
+ return function () {
+ callback();
+ self.stopDraw();
+ }
+ },
+
+ scrollInterval: function () {
+ this.arrangement.scrollInterval.apply(this.arrangement, arguments);
+ },
+
+ scrollEnd: function () {
+ this.arrangement.scrollEnd.apply(this.arrangement, arguments);
+ },
+
+ scrollTo: function (scroll) {
+ this.arrangement.scrollTo(scroll);
+ },
+
+ zoom: function (ratio) {
+ this.arrangement.zoom(ratio);
+ },
+
+ resize: function () {
+ return this.arrangement.resize();
+ },
+
+ relayout: function () {
+ return this.arrangement.relayout();
+ },
+
+ setLayoutType: function (type) {
+ this.arrangement.setLayoutType(type);
+ },
+
+ getLayoutType: function () {
+ return this.arrangement.getLayoutType();
+ },
+
+ getLayoutRatio: function () {
+ return this.arrangement.getLayoutRatio();
+ },
+
+ getHelper: function () {
+ return this.arrangement.getHelper();
+ },
+
+ getRegionByName: function (name) {
+ return this.arrangement.getRegionByName(name);
+ },
+
+ getAllRegions: function () {
+ return this.arrangement.getAllRegions();
+ },
+
+ revoke: function () {
+ return this.arrangement.revoke();
+ },
+
+ populate: function (items) {
+ var self = this;
+ this.arrangement.populate(items);
+ }
+});
+BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE";
+BI.InteractiveArrangement.EVENT_SCROLL = "InteractiveArrangement.EVENT_SCROLL";
+BI.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/**
+ * Created by zcf on 2016/9/26.
+ * Make some change by dailer on 2017/7/17
+ */
+BI.IntervalSlider = BI.inherit(BI.Widget, {
+ _constant: {
+ EDITOR_WIDTH: 58,
+ EDITOR_R_GAP: 60,
+ EDITOR_HEIGHT: 30,
+ HEIGHT: 28,
+ SLIDER_WIDTH_HALF: 15,
+ SLIDER_WIDTH: 30,
+ SLIDER_HEIGHT: 30,
+ TRACK_HEIGHT: 24
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.IntervalSlider.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-slider bi-slider-track"
+ })
+ },
+
+ _init: function () {
+ BI.IntervalSlider.superclass._init.apply(this, arguments);
+
+ var self = this;
+ var c = this._constant;
+ this.enable = false;
+ this.valueOne = "";
+ this.valueTwo = "";
+ this.calculation = new BI.AccurateCalculationModel();
+
+ this.backgroundTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "background-track",
+ height: c.TRACK_HEIGHT
+ });
+ this.grayTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "gray-track",
+ height: 8
+ });
+ this.blueTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "blue-track bi-high-light-background",
+ height: 8
+ });
+ this.track = this._createTrackWrapper();
+
+ this.labelOne = BI.createWidget({
+ type: "bi.sign_editor",
+ cls: "slider-editor-button",
+ errorText: "",
+ allowBlank: false,
+ height: c.HEIGHT,
+ width: c.EDITOR_WIDTH,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () {
+ var v = BI.parseFloat(this.getValue());
+ self.valueOne = v;
+ var percent = self._getPercentByValue(v);
+ var significantPercent = BI.parseFloat(percent.toFixed(1)); //分成1000份
+ self._setLabelOnePosition(significantPercent);
+ self._setSliderOnePosition(significantPercent);
+ self._setBlueTrack();
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ });
+ this.labelOne.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.labelOne.element.addClass("bi-border");
+ });
+ this.labelOne.on(BI.SignEditor.EVENT_BLUR, function () {
+ self.labelOne.element.removeClass("bi-border");
+ });
+
+ this.labelTwo = BI.createWidget({
+ type: "bi.sign_editor",
+ cls: "slider-editor-button",
+ errorText: "",
+ allowBlank: false,
+ height: c.HEIGHT,
+ width: c.EDITOR_WIDTH,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () {
+ var v = BI.parseFloat(this.getValue());
+ self.valueTwo = v;
+ var percent = self._getPercentByValue(v);
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setLabelTwoPosition(significantPercent);
+ self._setSliderTwoPosition(significantPercent);
+ self._setBlueTrack();
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ });
+ this.labelTwo.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.labelTwo.element.addClass("bi-border");
+ });
+ this.labelTwo.on(BI.SignEditor.EVENT_BLUR, function () {
+ self.labelTwo.element.removeClass("bi-border");
+ });
+
+ this.sliderOne = BI.createWidget({
+ type: "bi.single_slider_slider"
+ });
+ this.sliderOne.element.draggable({
+ axis: "x",
+ containment: this.grayTrack.element,
+ scroll: false,
+ drag: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setLabelOnePosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.labelOne.setValue(v);
+ self.valueOne = v;
+ self._setBlueTrack();
+ },
+ stop: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderOnePosition(significantPercent);
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ }
+ });
+
+ this.sliderTwo = BI.createWidget({
+ type: "bi.single_slider_slider"
+ });
+ this.sliderTwo.element.draggable({
+ axis: "x",
+ containment: this.grayTrack.element,
+ scroll: false,
+ drag: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setLabelTwoPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.labelTwo.setValue(v);
+ self.valueTwo = v;
+ self._setBlueTrack();
+ },
+ stop: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderTwoPosition(significantPercent);
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ }
+ });
+ this._setVisible(false);
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.track,
+ width: "100%",
+ height: c.TRACK_HEIGHT
+ }]
+ }],
+ hgap: 7,
+ height: c.TRACK_HEIGHT
+ },
+ top: 33,
+ left: 0,
+ width: "100%"
+ },
+ this._createLabelWrapper(),
+ this._createSliderWrapper()
+ ]
+ })
+ },
+
+ _createLabelWrapper: function () {
+ var c = this._constant;
+ return {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.labelOne,
+ top: 0,
+ left: "0%"
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: this.labelTwo,
+ top: 0,
+ left: "100%"
+ }]
+ }],
+ rgap: c.EDITOR_R_GAP,
+ height: 90
+ },
+ top: 0,
+ left: 0,
+ width: "100%"
+ }
+ },
+
+ _createSliderWrapper: function () {
+ var c = this._constant;
+ return {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.sliderOne,
+ top: 0,
+ left: "0%"
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: this.sliderTwo,
+ top: 0,
+ left: "100%"
+ }]
+ }],
+ hgap: c.SLIDER_WIDTH_HALF,
+ height: c.SLIDER_HEIGHT
+ },
+ top: 30,
+ left: 0,
+ width: "100%"
+ }
+ },
+
+ _createTrackWrapper: function () {
+ return BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: this.backgroundTrack,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.grayTrack,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }, {
+ el: this.blueTrack,
+ top: 0,
+ left: 0,
+ width: "0%"
+ }]
+ }],
+ hgap: 8,
+ height: 8
+ },
+ top: 8,
+ left: 0,
+ width: "100%"
+ }]
+ })
+ },
+
+ _checkValidation: function (v) {
+ return BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)
+ },
+
+ _checkOverlap: function () {
+ var labelOneLeft = this.labelOne.element[0].offsetLeft;
+ var labelTwoLeft = this.labelTwo.element[0].offsetLeft;
+ if (labelOneLeft <= labelTwoLeft) {
+ if ((labelTwoLeft - labelOneLeft) < 90) {
+ this.labelTwo.element.css({
+ "top": 60
+ });
+ } else {
+ this.labelTwo.element.css({
+ "top": 0
+ });
+ }
+ } else {
+ if ((labelOneLeft - labelTwoLeft) < 90) {
+ this.labelTwo.element.css({
+ "top": 60
+ });
+ } else {
+ this.labelTwo.element.css({
+ "top": 0
+ });
+ }
+ }
+ },
+
+ _setLabelOnePosition: function (percent) {
+ this.labelOne.element.css({
+ "left": percent + "%"
+ });
+ this._checkOverlap();
+ },
+
+ _setLabelTwoPosition: function (percent) {
+ this.labelTwo.element.css({
+ "left": percent + "%"
+ });
+ this._checkOverlap();
+ },
+
+ _setSliderOnePosition: function (percent) {
+ this.sliderOne.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setSliderTwoPosition: function (percent) {
+ this.sliderTwo.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setBlueTrackLeft: function (percent) {
+ this.blueTrack.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setBlueTrackWidth: function (percent) {
+ this.blueTrack.element.css({
+ "width": percent + "%"
+ });
+ },
+
+ _setBlueTrack: function () {
+ var percentOne = this._getPercentByValue(this.labelOne.getValue());
+ var percentTwo = this._getPercentByValue(this.labelTwo.getValue());
+ if (percentOne <= percentTwo) {
+ this._setBlueTrackLeft(percentOne);
+ this._setBlueTrackWidth(percentTwo - percentOne);
+ } else {
+ this._setBlueTrackLeft(percentTwo);
+ this._setBlueTrackWidth(percentOne - percentTwo);
+ }
+ },
+
+ _setAllPosition: function (one, two) {
+ this._setSliderOnePosition(one);
+ this._setLabelOnePosition(one);
+ this._setSliderTwoPosition(two);
+ this._setLabelTwoPosition(two);
+ this._setBlueTrack();
+ },
+
+ _setVisible: function (visible) {
+ this.sliderOne.setVisible(visible);
+ this.sliderTwo.setVisible(visible);
+ this.labelOne.setVisible(visible);
+ this.labelTwo.setVisible(visible);
+ },
+
+ _setErrorText: function () {
+ var errorText = BI.i18nText("BI-Please_Enter") + this.min + "-" + this.max + BI.i18nText("BI-Basic_De") + BI.i18nText("BI-Basic_Number");
+ this.labelOne.setErrorText(errorText);
+ this.labelTwo.setErrorText(errorText);
+ },
+
+ _getGrayTrackLength: function () {
+ return this.grayTrack.element[0].scrollWidth
+ },
+
+ //其中取max-min后保留4为有效数字后的值的小数位数为最终value的精度
+ _getValueByPercent: function (percent) { //return (((max-min)*percent)/100+min)
+ var sub = this.calculation.accurateSubtraction(this.max, this.min);
+ var mul = this.calculation.accurateMultiplication(sub, percent);
+ var div = this.calculation.accurateDivisionTenExponent(mul, 2);
+ if (this.precision >= 0) {
+ return BI.parseFloat(this.calculation.accurateAddition(div, this.min).toFixed(this.precision));
+ } else {
+ return BI.parseFloat(this.calculation.accurateAddition(div, this.min) - this.calculation.accurateAddition(div, this.min) % (Math.pow(10, (-1) * this.precision)));
+ }
+ },
+
+ _getPercentByValue: function (v) {
+ return (v - this.min) * 100 / (this.max - this.min);
+ },
+
+ _setDraggableEnable: function (enable) {
+ if (enable) {
+ this.sliderOne.element.draggable("enable");
+ this.sliderTwo.element.draggable("enable")
+ } else {
+ this.sliderOne.element.draggable("disable");
+ this.sliderTwo.element.draggable("disable")
+ }
+ },
+
+
+ getValue: function () {
+ if (this.valueOne <= this.valueTwo) {
+ return {
+ min: this.valueOne,
+ max: this.valueTwo
+ }
+ } else {
+ return {
+ min: this.valueTwo,
+ max: this.valueOne
+ }
+ }
+ },
+
+ setMinAndMax: function (v) {
+ var minNumber = BI.parseFloat(v.min);
+ var maxNumber = BI.parseFloat(v.max);
+ if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber >= minNumber)) {
+ this.min = minNumber;
+ this.max = maxNumber;
+ this.valueOne = minNumber;
+ this.valueTwo = maxNumber;
+ //计算每一份值的精度(最大值和最小值的差值保留4为有效数字后的精度)
+ //如果差值的整数位数大于4,toPrecision得到的是科学计数法1234 => 1.2e+3
+ var sub = this.calculation.accurateSubtraction(this.max, this.min);
+ var pre = sub.toPrecision(4);
+ if(pre.indexOf("e") > -1 ){
+ this.precision = 3 - pre.charAt(pre.length - 1);
+ }else{
+ var arr = pre.split(".");
+ if(arr.length>1){
+ this.precision = arr[1].length;
+ }else{
+ this.precision=0;
+ }
+ }
+ this._setDraggableEnable(true);
+ }
+ if (maxNumber === minNumber) {
+ this._setDraggableEnable(false);
+ }
+ },
+
+ setValue: function (v) {
+ var valueOne = BI.parseFloat(v.min);
+ var valueTwo = BI.parseFloat(v.max);
+ if (!isNaN(valueOne) && !isNaN(valueTwo)) {
+ if (this._checkValidation(valueOne)) {
+ this.valueOne = valueOne;
+ }
+ if (this._checkValidation(valueTwo)) {
+ this.valueTwo = valueTwo;
+ }
+ if (valueOne < this.min) {
+ this.valueOne = this.min;
+ }
+ if (valueTwo > this.max) {
+ this.valueTwo = this.max;
+ }
+ }
+ },
+
+ reset: function () {
+ this._setVisible(false);
+ this.enable = false;
+ this.valueOne = "";
+ this.valueTwo = "";
+ this.min = NaN;
+ this.max = NaN;
+ this._setBlueTrackWidth(0);
+ },
+
+ populate: function () {
+ if (!isNaN(this.min) && !isNaN(this.max)) {
+ this.enable = true;
+ this._setVisible(true);
+ this._setErrorText();
+ if ((BI.isNumeric(this.valueOne) || BI.isNotEmptyString(this.valueOne)) && (BI.isNumeric(this.valueTwo) || BI.isNotEmptyString(this.valueTwo))) {
+ this.labelOne.setValue(this.valueOne);
+ this.labelTwo.setValue(this.valueTwo);
+ this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo));
+ } else {
+ this.labelOne.setValue(this.min);
+ this.labelTwo.setValue(this.max);
+ this._setAllPosition(0, 100)
+ }
+ }
+ }
+});
+BI.IntervalSlider.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.interval_slider", BI.IntervalSlider);/**
+ * Created by zcf on 2017/3/1.
+ * 万恶的IEEE-754
+ * 使用字符串精确计算含小数加法、减法、乘法和10的指数倍除法,支持负数
+ */
+BI.AccurateCalculationModel = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.AccurateCalculationModel.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: ""
+ })
+ },
+
+ _init: function () {
+ BI.AccurateCalculationModel.superclass._init.apply(this, arguments);
+ },
+
+ _getMagnitude: function (n) {
+ var magnitude = "1";
+ for (var i = 0; i < n; i++) {
+ magnitude += "0";
+ }
+ return BI.parseInt(magnitude);
+ },
+
+ _formatDecimal: function (stringNumber1, stringNumber2) {
+ if (stringNumber1.numDecimalLength === stringNumber2.numDecimalLength) {
+ return;
+ }
+ var magnitudeDiff = stringNumber1.numDecimalLength - stringNumber2.numDecimalLength;
+ if (magnitudeDiff > 0) {
+ var needAddZero = stringNumber2
+ } else {
+ var needAddZero = stringNumber1;
+ magnitudeDiff = (0 - magnitudeDiff);
+ }
+ for (var i = 0; i < magnitudeDiff; i++) {
+ if (needAddZero.numDecimal === "0" && i === 0) {
+ continue
+ }
+ needAddZero.numDecimal += "0"
+ }
+ },
+
+ _stringNumberFactory: function (num) {
+ var strNum = num.toString();
+ var numStrArray = strNum.split(".");
+ var numInteger = numStrArray[0];
+ if (numStrArray.length === 1) {
+ var numDecimal = "0";
+ var numDecimalLength = 0;
+ } else {
+ var numDecimal = numStrArray[1];
+ var numDecimalLength = numStrArray[1].length;
+ }
+ return {
+ "numInteger": numInteger,
+ "numDecimal": numDecimal,
+ "numDecimalLength": numDecimalLength
+ }
+ },
+
+ _accurateSubtraction: function (num1, num2) {//num1-num2 && num1>num2
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ //整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) - BI.parseInt(stringNumber2.numInteger);
+ //小数部分
+ this._formatDecimal(stringNumber1, stringNumber2);
+ var decimalMaxLength = getDecimalMaxLength(stringNumber1, stringNumber2);
+
+ if (BI.parseInt(stringNumber1.numDecimal) >= BI.parseInt(stringNumber2.numDecimal)) {
+ var decimalResultTemp = (BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
+ var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
+ } else {//否则借位
+ integerResult--;
+ var borrow = this._getMagnitude(decimalMaxLength);
+ var decimalResultTemp = (borrow + BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
+ var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
+ }
+ var result = integerResult + "." + decimalResult;
+ return BI.parseFloat(result);
+
+ function getDecimalMaxLength(num1, num2) {
+ if (num1.numDecimal.length >= num2.numDecimal.length) {
+ return num1.numDecimal.length
+ }
+ return num2.numDecimal.length
+ }
+
+ function addZero(resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp
+ }
+ },
+
+ _accurateAddition: function (num1, num2) {//加法结合律
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ //整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) + BI.parseInt(stringNumber2.numInteger);
+ //小数部分
+ this._formatDecimal(stringNumber1, stringNumber2);
+
+ var decimalResult = (BI.parseInt(stringNumber1.numDecimal) + BI.parseInt(stringNumber2.numDecimal)).toString();
+
+ if (decimalResult !== "0") {
+ if (decimalResult.length <= stringNumber1.numDecimal.length) {
+ decimalResult = addZero(decimalResult, stringNumber1.numDecimal.length)
+ } else {
+ integerResult++;//进一
+ decimalResult = decimalResult.slice(1);
+ }
+ }
+ var result = integerResult + "." + decimalResult;
+ return BI.parseFloat(result);
+
+ function addZero(resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp
+ }
+ },
+
+ _accurateMultiplication: function (num1, num2) {//乘法分配律
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ //整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numInteger);
+ //num1的小数和num2的整数
+ var dec1Int2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numInteger), stringNumber1.numDecimalLength);
+ //num1的整数和num2的小数
+ var int1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numDecimal), stringNumber2.numDecimalLength);
+ //小数*小数
+ var dec1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numDecimal), (stringNumber1.numDecimalLength + stringNumber2.numDecimalLength));
+
+ return this._accurateAddition(this._accurateAddition(this._accurateAddition(integerResult, dec1Int2), int1dec2), dec1dec2);
+ },
+
+ _accurateDivisionTenExponent: function (num, n) {// num/10^n && n>0
+ var stringNumber = this._stringNumberFactory(num);
+ if (stringNumber.numInteger.length > n) {
+ var integerResult = stringNumber.numInteger.slice(0, (stringNumber.numInteger.length - n));
+ var partDecimalResult = stringNumber.numInteger.slice(-n);
+ } else {
+ var integerResult = "0";
+ var partDecimalResult = addZero(stringNumber.numInteger, n);
+ }
+ var result = integerResult + "." + partDecimalResult + stringNumber.numDecimal;
+ return BI.parseFloat(result);
+
+ function addZero(resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp
+ }
+ },
+
+ accurateSubtraction: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ if (num1 >= num2) {
+ return this._accurateSubtraction(num1, num2)
+ }
+ return -this._accurateSubtraction(num2, num1)
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return this._accurateAddition(num1, -num2)
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return -this._accurateAddition(-num1, num2)
+ }
+ if (num1 < 0 && num2 < 0) {
+ if (num1 >= num2) {
+ return this._accurateSubtraction(-num2, -num1)
+ }
+ return this._accurateSubtraction(-num1, -num2)
+ }
+ },
+
+ accurateAddition: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ return this._accurateAddition(num1, num2)
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return this.accurateSubtraction(num1, -num2)
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return this.accurateSubtraction(num2, -num1)
+ }
+ if (num1 < 0 && num2 < 0) {
+ return -this._accurateAddition(-num1, -num2)
+ }
+ },
+
+ accurateMultiplication: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ return this._accurateMultiplication(num1, num2)
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return -this._accurateMultiplication(num1, -num2)
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return -this._accurateMultiplication(-num1, num2)
+ }
+ if (num1 < 0 && num2 < 0) {
+ return this._accurateMultiplication(-num1, -num2)
+ }
+ },
+
+ accurateDivisionTenExponent: function (num1, n) {
+ if (num1 >= 0) {
+ return this._accurateDivisionTenExponent(num1, n);
+ }
+ return -this._accurateDivisionTenExponent(-num1, n);
+ }
+});/**
+ * 月份下拉框
+ *
+ * Created by GUY on 2015/8/28.
+ * @class BI.MonthCombo
+ * @extends BI.Trigger
+ */
+BI.MonthCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-month-combo",
+ behaviors: {},
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.MonthCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.month_trigger"
+ });
+
+ this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) {
+ if (this.getKey() && this.getKey() !== self.storeValue) {
+ self.setValue(this.getValue());
+ } else if (!this.getKey()) {
+ self.setValue();
+ }
+ self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () {
+ self.storeValue = this.getKey();
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_START, function () {
+ self.combo.hideView();
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_CHANGE, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.month_popup",
+ behaviors: o.behaviors
+ });
+ this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ el: this.popup
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+
+BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.month_combo', BI.MonthCombo);/**
+ * 月份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.MonthPopup
+ * @extends BI.Trigger
+ */
+BI.MonthPopup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-month-popup",
+ behaviors: {}
+ });
+ },
+
+ _init: function () {
+ BI.MonthPopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ //纵向排列月
+ var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11];
+ var items = [];
+ items.push(month.slice(0, 2));
+ items.push(month.slice(2, 4));
+ items.push(month.slice(4, 6));
+ items.push(month.slice(6, 8));
+ items.push(month.slice(8, 10));
+ items.push(month.slice(10, 12));
+ items = BI.map(items, function (i, item) {
+ return BI.map(item, function (j, td) {
+ return {
+ type: "bi.text_item",
+ cls: "bi-list-item-active",
+ textAlign: "center",
+ whiteSpace: "nowrap",
+ once: false,
+ forceSelected: true,
+ height: 23,
+ width: 38,
+ value: td,
+ text: td + 1
+ };
+ });
+ });
+
+ this.month = BI.createWidget({
+ type: "bi.button_group",
+ element: this,
+ behaviors: o.behaviors,
+ items: BI.createItems(items, {}),
+ layouts: [BI.LogicFactory.createLogic("table", BI.extend({
+ dynamic: true
+ }, {
+ columns: 2,
+ rows: 6,
+ columnSize: [1 / 2, 1 / 2],
+ rowSize: 25
+ })), {
+ type: "bi.center_adapt",
+ vgap: 1,
+ hgap: 2
+ }]
+ });
+
+ this.month.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
+ }
+ })
+ },
+
+ getValue: function () {
+ return this.month.getValue()[0];
+ },
+
+ setValue: function (v) {
+ this.month.setValue([v]);
+ }
+});
+BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.month_popup", BI.MonthPopup);/**
+ * 月份trigger
+ *
+ * Created by GUY on 2015/8/21.
+ * @class BI.MonthTrigger
+ * @extends BI.Trigger
+ */
+BI.MonthTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ triggerWidth: 25,
+ errorText: BI.i18nText("BI-Month_Trigger_Error_Text")
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-month-trigger bi-border",
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.MonthTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 12);
+ },
+ quitChecker: function (v) {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ errorText: c.errorText
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_CHANGE);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setValue(value);
+ self.editor.setTitle(value);
+ }
+ self.fireEvent(BI.MonthTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_STOP);
+ });
+ BI.createWidget({
+ element: this,
+ type: 'bi.htape',
+ items: [
+ {
+ el: this.editor
+ }, {
+ el: {
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Multi_Date_Month"),
+ baseCls: "bi-trigger-month-text",
+ width: c.triggerWidth
+ },
+ width: c.triggerWidth
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: c.triggerWidth
+ },
+ width: c.triggerWidth
+ }
+ ]
+ });
+ },
+ setValue: function (v) {
+ if(BI.isNotNull(v)){
+ this.editor.setState(v + 1);
+ this.editor.setValue(v + 1);
+ this.editor.setTitle(v + 1);
+ return;
+ }
+ this.editor.setState();
+ this.editor.setValue();
+ this.editor.setTitle();
+ },
+ getKey: function () {
+ return this.editor.getValue() | 0;
+ },
+ getValue: function () {
+ return this.editor.getValue() - 1;
+ }
+});
+BI.MonthTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.MonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.MonthTrigger.EVENT_START = "EVENT_START";
+BI.MonthTrigger.EVENT_STOP = "EVENT_STOP";
+BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.month_trigger", BI.MonthTrigger);/**
+ * @class BI.MultiLayerSelectTreeCombo
+ * @extends BI.Widget
+ */
+BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSelectTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer_select_tree-combo",
+ isDefaultInit: false,
+ height: 30,
+ text: "",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.multilayer_select_tree_popup",
+ isDefaultInit: o.isDefaultInit,
+ items: o.items
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ }
+});
+BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
+ * guy
+ * 二级树
+ * @class BI.MultiLayerSelectLevelTree
+ * @extends BI.Select
+ */
+BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSelectLevelTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-select-level-tree",
+ isDefaultInit: false,
+ items: [],
+ itemsCreator: BI.emptyFn
+ })
+ },
+
+ _init: function () {
+ BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments);
+
+ this.initTree(this.options.items);
+ },
+
+ _formatItems: function (nodes, layer) {
+ var self = this;
+ BI.each(nodes, function (i, node) {
+ var extend = {};
+ node.layer = layer;
+ if (!BI.isKey(node.id)) {
+ node.id = BI.UUID();
+ }
+ if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
+ switch (i) {
+ case 0 :
+ extend.type = "bi.multilayer_select_tree_first_plus_group_node";
+ break;
+ case nodes.length - 1 :
+ extend.type = "bi.multilayer_select_tree_last_plus_group_node";
+ break;
+ default :
+ extend.type = "bi.multilayer_select_tree_mid_plus_group_node";
+ break;
+ }
+ BI.defaults(node, extend);
+
+ self._formatItems(node.children, layer + 1);
+ } else {
+ switch (i) {
+ case nodes.length - 1:
+ extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
+ break;
+ default :
+ extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
+ }
+ BI.defaults(node, extend);
+ }
+ });
+ return nodes;
+ },
+
+ _assertId: function (sNodes) {
+ BI.each(sNodes, function (i, node) {
+ node.id = node.id || BI.UUID();
+ });
+ },
+
+ //构造树结构,
+ initTree: function (nodes) {
+ var self = this, o = this.options;
+ this.empty();
+ this._assertId(nodes);
+ this.tree = BI.createWidget({
+ type: "bi.custom_tree",
+ element: this,
+ expander: {
+ type: "bi.select_tree_expander",
+ isDefaultInit: o.isDefaultInit,
+ el: {},
+ popup: {
+ type: "bi.custom_tree"
+ }
+ },
+
+ items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
+ itemsCreator: o.itemsCreator,
+
+ el: {
+ type: "bi.button_tree",
+ chooseType: BI.Selection.Single,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ });
+ this.tree.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, arguments);
+ }
+ })
+ },
+
+ populate: function (nodes) {
+ this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0));
+ },
+
+ setValue: function (v) {
+ this.tree.setValue(v);
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ getAllLeaves: function () {
+ return this.tree.getAllLeaves();
+ },
+
+ getNodeById: function (id) {
+ return this.tree.getNodeById(id);
+ },
+
+ getNodeByValue: function (id) {
+ return this.tree.getNodeByValue(id);
+ }
+});
+BI.MultiLayerSelectLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.multilayer_select_level_tree", BI.MultiLayerSelectLevelTree);/**
+ * Created by GUY on 2016/1/26.
+ *
+ * @class BI.MultiLayerSelectTreePopup
+ * @extends BI.Pane
+ */
+
+BI.MultiLayerSelectTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-select-tree-popup",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ isDefaultInit: false,
+ itemsCreator: BI.emptyFn,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSelectTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: 'bi.multilayer_select_level_tree',
+ isDefaultInit: o.isDefaultInit,
+ items: o.items,
+ itemsCreator: o.itemsCreator
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ scrollable: true,
+ element: this,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.MultiLayerSelectTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.MultiLayerSelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_select_tree_popup", BI.MultiLayerSelectTreePopup);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSelectTreeFirstPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.select_tree_first_plus_group_node",
+ cls: "bi-list-item-none",
+ stopPropagation: true,
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_select_tree_first_plus_group_node", BI.MultiLayerSelectTreeFirstPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSelectTreeLastPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-select-tree-last-plus-group-node bi-list-item-active",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.select_tree_last_plus_group_node",
+ cls: "bi-list-item-none",
+ stopPropagation: true,
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_select_tree_last_plus_group_node", BI.MultiLayerSelectTreeLastPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSelectTreeMidPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.select_tree_mid_plus_group_node",
+ cls: "bi-list-item-none",
+ stopPropagation: true,
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node", BI.MultiLayerSelectTreeMidPlusGroupNode);/**
+ * 多层级下拉单选树
+ * Created by GUY on 2016/1/26.
+ *
+ * @class BI.MultiLayerSingleTreeCombo
+ * @extends BI.Widget
+ */
+BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-singletree-combo",
+ isDefaultInit: false,
+ height: 30,
+ text: "",
+ itemsCreator: BI.emptyFn,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.multilayer_single_tree_popup",
+ isDefaultInit: o.isDefaultInit,
+ items: o.items
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ }
+});
+
+BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
+ * guy
+ * 二级树
+ * @class BI.MultiLayerSingleLevelTree
+ * @extends BI.Single
+ */
+BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleLevelTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-single-level-tree",
+ isDefaultInit: false,
+ items: [],
+ itemsCreator: BI.emptyFn
+ })
+ },
+
+ _init: function () {
+ BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments);
+
+ this.initTree(this.options.items);
+ },
+
+ _formatItems: function (nodes, layer) {
+ var self = this;
+ BI.each(nodes, function (i, node) {
+ var extend = {};
+ node.layer = layer;
+ if (!BI.isKey(node.id)) {
+ node.id = BI.UUID();
+ }
+ if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
+ switch (i) {
+ case 0 :
+ extend.type = "bi.multilayer_single_tree_first_plus_group_node";
+ break;
+ case nodes.length - 1 :
+ extend.type = "bi.multilayer_single_tree_last_plus_group_node";
+ break;
+ default :
+ extend.type = "bi.multilayer_single_tree_mid_plus_group_node";
+ break;
+ }
+ BI.defaults(node, extend);
+
+ self._formatItems(node.children, layer + 1);
+ } else {
+ switch (i) {
+ case nodes.length - 1:
+ extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
+ break;
+ default :
+ extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
+ }
+ BI.defaults(node, extend);
+ }
+ });
+ return nodes;
+ },
+
+ _assertId: function (sNodes) {
+ BI.each(sNodes, function (i, node) {
+ node.id = node.id || BI.UUID();
+ });
+ },
+
+ //构造树结构,
+ initTree: function (nodes) {
+ var self = this, o = this.options;
+ this.empty();
+ this._assertId(nodes);
+ this.tree = BI.createWidget({
+ type: "bi.custom_tree",
+ element: this,
+ expander: {
+ isDefaultInit: o.isDefaultInit,
+ el: {},
+ popup: {
+ type: "bi.custom_tree"
+ }
+ },
+
+ items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (items) {
+ callback(BI.Tree.transformToTreeFormat(items), 0)
+ })
+ },
+
+ el: {
+ type: "bi.button_tree",
+ chooseType: BI.Selection.Single,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ });
+ this.tree.on(BI.Controller.EVENT_CHANGE, function (type, v) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, v);
+ }
+ })
+ },
+
+ populate: function (nodes) {
+ this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0));
+ },
+
+ setValue: function (v) {
+ this.tree.setValue(v);
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ getAllLeaves: function () {
+ return this.tree.getAllLeaves();
+ },
+
+ getNodeById: function (id) {
+ return this.tree.getNodeById(id);
+ },
+
+ getNodeByValue: function (id) {
+ return this.tree.getNodeByValue(id);
+ }
+});
+BI.MultiLayerSingleLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.multilayer_single_level_tree", BI.MultiLayerSingleLevelTree);
+/**
+ * Created by GUY on 2016/1/26.
+ *
+ * @class BI.MultiLayerSingleTreePopup
+ * @extends BI.Pane
+ */
+
+BI.MultiLayerSingleTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-singletree-popup",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ isDefaultInit: false,
+ itemsCreator: BI.emptyFn,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSingleTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: 'bi.multilayer_single_level_tree',
+ isDefaultInit: o.isDefaultInit,
+ items: o.items,
+ itemsCreator: o.itemsCreator
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ scrollable: true,
+ element: this,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.MultiLayerSingleTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.MultiLayerSingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_single_tree_popup", BI.MultiLayerSingleTreePopup);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeFirstPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSingleTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-single-tree-first-plus-group-node bi-list-item",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.first_plus_group_node",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.node)) {
+ this.node.setOpened(v);
+ }
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_first_plus_group_node", BI.MultiLayerSingleTreeFirstPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeLastPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSingleTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-single-tree-last-plus-group-node bi-list-item",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.last_plus_group_node",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.node)) {
+ this.node.setOpened(v);
+ }
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_last_plus_group_node", BI.MultiLayerSingleTreeLastPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeMidPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSingleTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-single-tree-mid-plus-group-node bi-list-item",
+ layer: 0,//第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.mid_plus_group_node",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.node)) {
+ this.node.setOpened(v);
+ }
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/**
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeFirstTreeLeafItem
+ * @extends BI.BasicButton
+ */
+BI.MultiLayerSingleTreeFirstTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multilayer-single-tree-first-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ layer: 0,
+ id: "",
+ pId: "",
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.item = BI.createWidget({
+ type: "bi.first_tree_leaf_item",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.item);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.item.doRedMark.apply(this.item, arguments);
+ },
+
+ unRedMark: function () {
+ this.item.unRedMark.apply(this.item, arguments);
+ },
+
+ doHighLight: function () {
+ this.item.doHighLight.apply(this.item, arguments);
+ },
+
+ unHighLight: function () {
+ this.item.unHighLight.apply(this.item, arguments);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.item.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.item.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item", BI.MultiLayerSingleTreeFirstTreeLeafItem);/**
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeLastTreeLeafItem
+ * @extends BI.BasicButton
+ */
+BI.MultiLayerSingleTreeLastTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multilayer-single-tree-last-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ layer: 0,
+ id: "",
+ pId: "",
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.item = BI.createWidget({
+ type: "bi.last_tree_leaf_item",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.item);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.item.doRedMark.apply(this.item, arguments);
+ },
+
+ unRedMark: function () {
+ this.item.unRedMark.apply(this.item, arguments);
+ },
+
+ doHighLight: function () {
+ this.item.doHighLight.apply(this.item, arguments);
+ },
+
+ unHighLight: function () {
+ this.item.unHighLight.apply(this.item, arguments);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.item.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.item.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item", BI.MultiLayerSingleTreeLastTreeLeafItem);/**
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeMidTreeLeafItem
+ * @extends BI.BasicButton
+ */
+BI.MultiLayerSingleTreeMidTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multilayer-single-tree-mid-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ layer: 0,
+ id: "",
+ pId: "",
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.item = BI.createWidget({
+ type: "bi.mid_tree_leaf_item",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {//本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ cls: "base-line-conn-background",
+ width: 13,
+ height: o.height
+ })
+ });
+ items.push(this.item);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 13),
+ items: [items]
+ })
+ },
+
+ doRedMark: function () {
+ this.item.doRedMark.apply(this.item, arguments);
+ },
+
+ unRedMark: function () {
+ this.item.unRedMark.apply(this.item, arguments);
+ },
+
+ doHighLight: function () {
+ this.item.doHighLight.apply(this.item, arguments);
+ },
+
+ unHighLight: function () {
+ this.item.unHighLight.apply(this.item, arguments);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.item.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.item.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item", BI.MultiLayerSingleTreeMidTreeLeafItem);/**
+ *
+ * @class BI.MultiSelectCheckPane
+ * @extends BI.Widget
+ */
+BI.MultiSelectCheckPane = BI.inherit(BI.Widget, {
+
+ constants: {
+ height: 25,
+ lgap: 10,
+ tgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-check-pane bi-background",
+ items: [],
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ onClickContinueSelect: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCheckPane.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.storeValue = {};
+ this.display = BI.createWidget({
+ type: 'bi.display_selected_list',
+ items: opts.items,
+ itemsCreator: function (op, callback) {
+ op = BI.extend(op || {}, {
+ selectedValues: self.storeValue.value
+ });
+ if (self.storeValue.type === BI.Selection.Multi) {
+ callback({
+ items: BI.map(self.storeValue.value, function (i, v) {
+ var txt = opts.valueFormatter(v) || v;
+ return {
+ text: txt,
+ value: v,
+ title: txt
+ }
+ })
+ });
+ return;
+ }
+ opts.itemsCreator(op, callback);
+ }
+ });
+
+ this.continueSelect = BI.createWidget({
+ type: 'bi.text_button',
+ text: BI.i18nText('BI-Continue_Select'),
+ cls: 'multi-select-check-selected bi-high-light'
+ });
+
+ this.continueSelect.on(BI.TextButton.EVENT_CHANGE, function () {
+ opts.onClickContinueSelect();
+ });
+
+ BI.createWidget({
+ type: 'bi.vtape',
+ element: this,
+ items: [{
+ height: this.constants.height,
+ el: {
+ type: 'bi.left',
+ cls: 'multi-select-continue-select',
+ items: [
+ {
+ el: {
+ type: "bi.label",
+ text: BI.i18nText('BI-Selected_Data')
+ },
+ lgap: this.constants.lgap,
+ tgap: this.constants.tgap
+ },
+ {
+ el: this.continueSelect,
+ lgap: this.constants.lgap,
+ tgap: this.constants.tgap
+ }]
+ }
+ }, {
+ height: 'fill',
+ el: this.display
+ }]
+ });
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ },
+
+ empty: function () {
+ this.display.empty();
+ },
+
+ populate: function () {
+ this.display.populate.apply(this.display, arguments);
+ }
+});
+
+BI.shortcut("bi.multi_select_check_pane", BI.MultiSelectCheckPane);/**
+ *
+ *
+ * 查看已选弹出层的展示面板
+ * @class BI.DisplaySelectedList
+ * @extends BI.Widget
+ */
+BI.DisplaySelectedList = BI.inherit(BI.Pane, {
+
+ constants: {
+ height: 25,
+ lgap: 10
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-display-list",
+ itemsCreator: BI.emptyFn,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.DisplaySelectedList.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.hasNext = false;
+
+ this.button_group = BI.createWidget({
+ type: "bi.list_pane",
+ element: this,
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ items: this._createItems(opts.items),
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ layouts: [{
+ type: "bi.vertical",
+ lgap: 10
+ }]
+ },
+ itemsCreator: function (options, callback) {
+
+ opts.itemsCreator(options, function (ob) {
+ self.hasNext = !!ob.hasNext;
+ callback(self._createItems(ob.items));
+ })
+ },
+ hasNext: function () {
+ return self.hasNext;
+ }
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: 'bi.icon_text_item',
+ cls: 'cursor-default check-font display-list-item bi-tips',
+ once: true,
+ invalid: true,
+ selected: true,
+ height: this.constants.height,
+ logic: {
+ dynamic: true
+ }
+ });
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ if (arguments.length === 0) {
+ this.button_group.populate();
+ } else {
+ this.button_group.populate(this._createItems(items));
+ }
+ }
+});
+
+BI.shortcut('bi.display_selected_list', BI.DisplaySelectedList);/**
+ *
+ * @class BI.MultiSelectCombo
+ * @extends BI.Single
+ */
+BI.MultiSelectCombo = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-combo',
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ height: 28
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
+ self.trigger.getSearcher().setState(self.storeValue);
+ self.trigger.getCounter().setButtonChecked(self.storeValue);
+ };
+ this.storeValue = {};
+
+ this.trigger = BI.createWidget({
+ type: "bi.multi_select_trigger",
+ height: o.height,
+ // adapter: this.popup,
+ masker: {
+ offset: {
+ left: 1,
+ top: 1,
+ right: 2,
+ bottom: 33
+ }
+ },
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (res) {
+ if (op.times === 1 && BI.isNotNull(op.keywords)) {
+ //预防trigger内部把当前的storeValue改掉
+ self.trigger.setValue(BI.deepClone(self.getValue()));
+ }
+ callback.apply(self, arguments);
+ });
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
+ self._setStartValue("");
+ this.getSearcher().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
+ self._setStartValue("");
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
+ if (this.getSearcher().hasMatched()) {
+ var keyword = this.getSearcher().getKeyword();
+ self._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ self.combo.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.populate();
+ self._setStartValue("");
+ })
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ self.combo.populate();
+ self._setStartValue("");
+ } else {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ });
+ } else {
+ self._join(this.getValue(), function () {
+ assertShowValue();
+ });
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
+ this.getCounter().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ el: this.trigger,
+ adjustLength: 1,
+ popup: {
+ type: 'bi.multi_select_popup_view',
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
+ action: function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ });
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,
+ action: function () {
+ self._defaultState();
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,
+ action: function () {
+ self.setValue();
+ self._defaultState();
+ }
+ }],
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.combo.adjustWidth();
+ self.combo.adjustHeight();
+ self.trigger.getCounter().adjustView();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ }
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ this.setValue(self.storeValue);
+ BI.nextTick(function () {
+ self.populate();
+ });
+ });
+ this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ //important:关闭弹出时又可能没有退出编辑状态
+ self.trigger.stopEditing();
+ self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "multi-select-trigger-icon-button bi-border-left"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ self.trigger.getCounter().hideView();
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ })
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
+ keywords: keywords
+ }, function (ob) {
+ var values = BI.pluck(ob.items, "value");
+ digest(values);
+ });
+
+ function digest(items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
+ keywords: [this.trigger.getKey()]
+ }, function (ob) {
+ var items = BI.pluck(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ self._adjust(callback);
+ })
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ if (!this._count) {
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ self._count = res.count;
+ adjust();
+ callback();
+ });
+ } else {
+ adjust();
+ callback();
+ }
+ function adjust() {
+ if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.Multi,
+ value: []
+ }
+ } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.All,
+ value: []
+ }
+ }
+ }
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.popup.setStartValue(value);
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.combo.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ populate: function () {
+ this._count = null;
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+
+BI.extend(BI.MultiSelectCombo, {
+ REQ_GET_DATA_LENGTH: 0,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+
+BI.shortcut('bi.multi_select_combo', BI.MultiSelectCombo);/**
+ * 多选加载数据面板
+ * Created by guy on 15/11/2.
+ * @class BI.MultiSelectLoader
+ * @extends Widget
+ */
+BI.MultiSelectLoader = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-loader',
+ logic: {
+ dynamic: true
+ },
+ el: {
+ height: 400
+ },
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectLoader.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+ var hasNext = false;
+
+ this.button_group = BI.createWidget({
+ type: "bi.select_list",
+ element: this,
+ logic: opts.logic,
+ el: BI.extend({
+ onLoaded: opts.onLoaded,
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ el: {
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ }
+ }, opts.el),
+ itemsCreator: function (op, callback) {
+ var startValue = self._startValue;
+ self.storeValue && (op = BI.extend(op || {}, {
+ selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi
+ ? self.storeValue.value.concat(startValue) : self.storeValue.value
+ }));
+ opts.itemsCreator(op, function (ob) {
+ hasNext = ob.hasNext;
+ var firstItems = [];
+ if (op.times === 1 && self.storeValue) {
+ var json = BI.map(self.storeValue.value, function (i, v) {
+ var txt = opts.valueFormatter(v) || v;
+ return {
+ text: txt,
+ value: v,
+ title: txt,
+ selected: self.storeValue.type === BI.Selection.Multi
+ }
+ });
+ if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) {
+ var txt = opts.valueFormatter(startValue) || startValue;
+ json.unshift({
+ text: txt,
+ value: startValue,
+ title: txt,
+ selected: true
+ })
+ }
+ firstItems = self._createItems(json);
+ }
+ callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
+ if (op.times === 1 && self.storeValue) {
+ BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue);
+ self.setValue(self.storeValue);
+ }
+ (op.times === 1) && self._scrollToTop();
+ });
+ },
+ hasNext: function () {
+ return hasNext;
+ }
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: "bi.multi_select_item",
+ logic: this.options.logic,
+ height: 25,
+ selected: this.isAllSelected()
+ })
+ },
+
+ _scrollToTop: function () {
+ var self = this;
+ BI.delay(function () {
+ self.button_group.element.scrollTop(0);
+ }, 30);
+ },
+
+ isAllSelected: function () {
+ return this.button_group.isAllSelected();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ setStartValue: function (v) {
+ this._startValue = v;
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.button_group.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.button_group.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.button_group.resetWidth(w);
+ }
+});
+
+BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.multi_select_loader', BI.MultiSelectLoader);/**
+ * 带加载的多选下拉面板
+ * @class BI.MultiSelectPopupView
+ * @extends Widget
+ */
+BI.MultiSelectPopupView = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-popup-view',
+ maxWidth: 'auto',
+ minWidth: 135,
+ maxHeight: 400,
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectPopupView.superclass._init.apply(this, arguments);
+ var self = this, opts = this.options;
+
+ this.loader = BI.createWidget({
+ type: "bi.multi_select_loader",
+ itemsCreator: opts.itemsCreator,
+ valueFormatter: opts.valueFormatter,
+ onLoaded: opts.onLoaded
+ });
+
+ this.popupView = BI.createWidget({
+ type: "bi.multi_popup_view",
+ stopPropagation: false,
+ maxWidth: opts.maxWidth,
+ minWidth: opts.minWidth,
+ maxHeight: opts.maxHeight,
+ element: this,
+ buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')],
+ el: this.loader
+ });
+
+ this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE);
+ });
+ this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
+ switch (index) {
+ case 0:
+ self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM);
+ break;
+ }
+ });
+ },
+
+ isAllSelected: function () {
+ return this.loader.isAllSelected();
+ },
+
+ setStartValue: function (v) {
+ this.loader.setStartValue(v);
+ },
+
+ setValue: function (v) {
+ this.popupView.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popupView.getValue();
+ },
+
+ populate: function (items) {
+ this.popupView.populate.apply(this.popupView, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.popupView.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.popupView.resetWidth(w);
+ }
+});
+
+BI.MultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.MultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+
+
+BI.shortcut('bi.multi_select_popup_view', BI.MultiSelectPopupView);/**
+ *
+ * 复选下拉框
+ * @class BI.MultiSelectTrigger
+ * @extends BI.Trigger
+ */
+
+BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
+
+ constants: {
+ height: 14,
+ rgap: 4,
+ lgap: 4
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-trigger bi-border",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ searcher: {},
+ switcher: {},
+
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectTrigger.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ if (o.height) {
+ this.setHeight(o.height - 2);
+ }
+
+ this.searcher = BI.createWidget(o.searcher, {
+ type: "bi.multi_select_searcher",
+ height: o.height,
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ popup: {},
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_START);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING, arguments);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_STOP);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE, arguments);
+ });
+ this.numberCounter = BI.createWidget(o.switcher, {
+ type: 'bi.multi_select_check_selected_switcher',
+ valueFormatter: o.valueFormatter,
+ itemsCreator: o.itemsCreator,
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK);
+ });
+ this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
+ });
+
+ var wrapNumberCounter = BI.createWidget({
+ type: 'bi.right_vertical_adapt',
+ hgap: 4,
+ items: [{
+ el: this.numberCounter
+ }]
+ });
+
+ var wrapper = BI.createWidget({
+ type: 'bi.htape',
+ element: this,
+ items: [
+ {
+ el: this.searcher,
+ width: 'fill'
+ }, {
+ el: wrapNumberCounter,
+ width: 0
+ }, {
+ el: BI.createWidget(),
+ width: 30
+ }]
+ });
+
+ this.numberCounter.on(BI.Events.VIEW, function (b) {
+ BI.nextTick(function () {//自动调整宽度
+ wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
+ wrapper.resize();
+ });
+ });
+
+ this.element.click(function (e) {
+ if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) {
+ self.numberCounter.hideView();
+ }
+ });
+ },
+
+ getCounter: function () {
+ return this.numberCounter;
+ },
+
+ getSearcher: function () {
+ return this.searcher;
+ },
+
+ stopEditing: function () {
+ this.searcher.stopSearch();
+ this.numberCounter.hideView();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ this.numberCounter.setAdapter(adapter);
+ },
+
+ setValue: function (ob) {
+ this.searcher.setValue(ob);
+ this.numberCounter.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.searcher.getKey();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ }
+});
+
+BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+BI.MultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
+BI.MultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectTrigger.EVENT_START = "EVENT_START";
+BI.MultiSelectTrigger.EVENT_STOP = "EVENT_STOP";
+BI.MultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE";
+BI.MultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
+
+BI.shortcut('bi.multi_select_trigger', BI.MultiSelectTrigger);/**
+ * 多选加载数据搜索loader面板
+ * Created by guy on 15/11/4.
+ * @class BI.MultiSelectSearchLoader
+ * @extends Widget
+ */
+BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-search-loader',
+ itemsCreator: BI.emptyFn,
+ keywordGetter: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectSearchLoader.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+ var hasNext = false;
+
+ this.button_group = BI.createWidget({
+ type: "bi.select_list",
+ element: this,
+ logic: {
+ dynamic: false
+ },
+ el: {
+ tipText: BI.i18nText("BI-No_Select"),
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ el: {
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ }
+ },
+ itemsCreator: function (op, callback) {
+ self.storeValue && (op = BI.extend(op || {}, {
+ selectedValues: self.storeValue.value
+ }));
+ opts.itemsCreator(op, function (ob) {
+ var keyword = ob.keyword = opts.keywordGetter();
+ hasNext = ob.hasNext;
+ var firstItems = [];
+ if (op.times === 1 && self.storeValue) {
+ var json = self._filterValues(self.storeValue);
+ firstItems = self._createItems(json);
+ }
+ callback(firstItems.concat(self._createItems(ob.items)), keyword);
+ if (op.times === 1 && self.storeValue) {
+ self.setValue(self.storeValue);
+ }
+ });
+ },
+ hasNext: function () {
+ return hasNext;
+ }
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: "bi.multi_select_item",
+ logic: {
+ dynamic: false
+ },
+ height: 25,
+ selected: this.isAllSelected()
+ })
+ },
+
+ isAllSelected: function () {
+ return this.button_group.isAllSelected();
+ },
+
+ _filterValues: function (src) {
+ var o = this.options;
+ var keyword = o.keywordGetter();
+ var values = BI.deepClone(src.value) || [];
+ var newValues = BI.map(values, function (i, v) {
+ return {
+ text: o.valueFormatter(v) || v,
+ value: v
+ };
+ });
+ if (BI.isKey(keyword)) {
+ var search = BI.Func.getSearchResult(newValues, keyword);
+ values = search.matched.concat(search.finded);
+ }
+ return BI.map(values, function (i, v) {
+ return {
+ text: v.text,
+ title: v.text,
+ value: v.value,
+ selected: src.type === BI.Selection.All
+ }
+ })
+ },
+
+ setValue: function (v) {
+ //暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
+ this.storeValue = BI.deepClone(v);
+ this.button_group.setValue(v);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.button_group.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.button_group.resetWidth(w);
+ }
+});
+
+BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.multi_select_search_loader', BI.MultiSelectSearchLoader);/**
+ *
+ * 在搜索框中输入文本弹出的面板
+ * @class BI.MultiSelectSearchPane
+ * @extends Widget
+ */
+
+BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
+
+ constants: {
+ height: 25,
+ lgap: 10,
+ tgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-search-pane bi-card",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ keywordGetter: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectSearchPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.tooltipClick = BI.createWidget({
+ type: "bi.label",
+ invisible: true,
+ text: BI.i18nText('BI-Click_Blank_To_Select'),
+ cls: 'multi-select-toolbar',
+ height: this.constants.height
+ });
+
+ this.loader = BI.createWidget({
+ type: "bi.multi_select_search_loader",
+ keywordGetter: o.keywordGetter,
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator.apply(self, [op, function (res) {
+ callback(res);
+ self.setKeyword(o.keywordGetter());
+ }]);
+ }
+ });
+ this.loader.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.resizer = BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.tooltipClick,
+ height: 0
+ }, {
+ el: this.loader
+ }]
+ });
+ this.tooltipClick.setVisible(false);
+ },
+
+ setKeyword: function (keyword) {
+ var btn;
+ var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue());
+ if (isVisible !== this.tooltipClick.isVisible()) {
+ this.tooltipClick.setVisible(isVisible);
+ this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0);
+ this.resizer.resize();
+ }
+ },
+
+ isAllSelected: function () {
+ return this.loader.isAllSelected();
+ },
+
+ hasMatched: function () {
+ return this.tooltipClick.isVisible();
+ },
+
+ setValue: function (v) {
+ this.loader.setValue(v);
+ },
+
+ getValue: function () {
+ return this.loader.getValue();
+ },
+
+ empty: function () {
+ this.loader.empty();
+ },
+
+ populate: function (items) {
+ this.loader.populate.apply(this.loader, arguments);
+ }
+});
+
+BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);/**
+ * 查看已选按钮
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectCheckSelectedButton
+ * @extends BI.Single
+ */
+BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, {
+
+ _const: {
+ checkSelected: BI.i18nText('BI-Check_Selected')
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-check-selected-button bi-high-light',
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments);
+ var self = this;
+ this.numberCounter = BI.createWidget({
+ type: 'bi.text_button',
+ element: this,
+ hgap: 4,
+ text: "0",
+ textAlign: 'center',
+ textHeight: 15
+ });
+ this.numberCounter.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.numberCounter.on(BI.TextButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
+ });
+
+ this.numberCounter.element.hover(function () {
+ self.numberCounter.setTag(self.numberCounter.getText());
+ self.numberCounter.setText(self._const.checkSelected);
+ }, function () {
+ self.numberCounter.setText(self.numberCounter.getTag());
+ });
+ this.setVisible(false);
+ },
+
+ setValue: function (ob) {
+ var self = this, o = this.options;
+ ob || (ob = {});
+ ob.type || (ob.type = BI.Selection.Multi);
+ ob.value || (ob.value = []);
+ if (ob.type === BI.Selection.All) {
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ var length = res.count - ob.value.length;
+ BI.nextTick(function(){
+ self.numberCounter.setText(length);
+ self.setVisible(length > 0);
+ });
+ });
+ return;
+ }
+ BI.nextTick(function(){
+ self.numberCounter.setText(ob.value.length);
+ self.setVisible(ob.value.length > 0);
+ })
+ },
+
+ getValue: function () {
+
+ }
+});
+
+BI.MultiSelectCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.multi_select_check_selected_button', BI.MultiSelectCheckSelectedButton);/**
+ * 多选输入框
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectEditor
+ * @extends Widget
+ */
+BI.MultiSelectEditor = BI.inherit(BI.Widget, {
+
+ _const: {
+ checkSelected: BI.i18nText('BI-Check_Selected')
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectEditor.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-editor',
+ el: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.el, {
+ type: 'bi.state_editor',
+ element: this,
+ height: o.height,
+ watermark: BI.i18nText('BI-Basic_Search'),
+ allowBlank: true
+ });
+
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.editor.on(BI.StateEditor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.MultiSelectEditor.EVENT_PAUSE);
+ });
+ this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () {
+
+ });
+ },
+
+ focus: function () {
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ },
+
+ setState: function (state) {
+ this.editor.setState(state);
+ },
+
+ setValue: function (v) {
+ this.editor.setValue(v);
+ },
+
+ getValue: function () {
+ var v = this.editor.getState();
+ if (BI.isArray(v) && v.length > 0) {
+ return v[v.length - 1];
+ } else {
+ return "";
+ }
+ },
+
+ getKeywords: function () {
+ var val = this.editor.getLastValidValue();
+ var keywords = val.match(/[\S]+/g);
+ if (BI.isEndWithBlank(val)) {
+ return keywords.concat([' ']);
+ }
+ return keywords;
+ },
+
+ populate: function (items) {
+
+ }
+});
+BI.MultiSelectEditor.EVENT_PAUSE = "MultiSelectEditor.EVENT_PAUSE";
+BI.shortcut('bi.multi_select_editor', BI.MultiSelectEditor);/**
+ * searcher
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectSearcher
+ * @extends Widget
+ */
+BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-searcher',
+ itemsCreator: BI.emptyFn,
+ el: {},
+ popup: {},
+ valueFormatter: BI.emptyFn,
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectSearcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.el, {
+ type: 'bi.multi_select_editor',
+ height: o.height
+ });
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ element: this,
+ height: o.height,
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback();
+ },
+ el: this.editor,
+
+ popup: BI.extend({
+ type: "bi.multi_select_search_pane",
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.editor.getValue();
+ },
+ itemsCreator: function (op, callback) {
+ op.keyword = self.editor.getValue();
+ this.setKeyword(op.keyword);
+ o.itemsCreator(op, callback);
+ }
+ }, o.popup),
+
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.Searcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_START);
+ });
+ this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
+ if (this.hasMatched()) {
+
+ }
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.Searcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_STOP);
+ });
+ this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE, arguments);
+ });
+ this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
+ var keywords = this.getKeywords();
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING, keywords);
+ });
+ },
+
+ adjustView: function () {
+ this.searcher.adjustView();
+ },
+
+ isSearching: function () {
+ return this.searcher.isSearching();
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ getKeyword: function () {
+ return this.editor.getValue();
+ },
+
+ hasMatched: function () {
+ return this.searcher.hasMatched();
+ },
+
+ hasChecked: function () {
+ return this.searcher.getView() && this.searcher.getView().hasChecked();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ },
+
+ setState: function (ob) {
+ var o = this.options;
+ ob || (ob = {});
+ ob.value || (ob.value = []);
+ if (ob.type === BI.Selection.All) {
+ if (BI.size(ob.assist) === 1) {
+ this.editor.setState(o.valueFormatter(ob.assist[0] + "") || (ob.assist[0] + ""));
+ } else {
+ this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All);
+ }
+ } else {
+ if (BI.size(ob.value) === 1) {
+ this.editor.setState(o.valueFormatter(ob.value[0] + "") || (ob.value[0] + ""));
+ } else {
+ this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None);
+ }
+ }
+ },
+
+ setValue: function (ob) {
+ this.setState(ob);
+ this.searcher.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ },
+
+ populate: function (items) {
+ this.searcher.populate.apply(this.searcher, arguments);
+ }
+});
+
+BI.MultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.MultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectSearcher.EVENT_START = "EVENT_START";
+BI.MultiSelectSearcher.EVENT_STOP = "EVENT_STOP";
+BI.MultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE";
+BI.MultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.shortcut('bi.multi_select_searcher', BI.MultiSelectSearcher);/**
+ * 查看已选switcher
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectCheckSelectedSwitcher
+ * @extends Widget
+ */
+BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCheckSelectedSwitcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-check-selected-switcher',
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ el: {},
+ popup: {},
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCheckSelectedSwitcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.button = BI.createWidget(o.el, {
+ type: "bi.multi_select_check_selected_button",
+ itemsCreator: o.itemsCreator
+ });
+ this.button.on(BI.Events.VIEW, function () {
+ self.fireEvent(BI.Events.VIEW, arguments);
+ });
+ this.switcher = BI.createWidget({
+ type: "bi.switcher",
+ toggle: false,
+ element: this,
+ el: this.button,
+ popup: BI.extend({
+ type: "bi.multi_select_check_pane",
+ valueFormatter: o.valueFormatter,
+ itemsCreator: o.itemsCreator,
+ onClickContinueSelect: function () {
+ self.switcher.hideView();
+ }
+ }, o.popup),
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE);
+ });
+ this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW);
+ });
+ this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW, function () {
+ var me = this;
+ BI.nextTick(function () {
+ me.populate();
+ });
+ });
+
+ this.switcher.element.click(function (e) {
+ e.stopPropagation();
+ });
+ },
+
+ adjustView: function () {
+ this.switcher.adjustView();
+ },
+
+ hideView: function () {
+ this.switcher.empty();
+ this.switcher.hideView();
+ },
+
+ setAdapter: function (adapter) {
+ this.switcher.setAdapter(adapter);
+ },
+
+ setValue: function (v) {
+ this.switcher.setValue(v);
+ },
+
+ setButtonChecked: function (v) {
+ this.button.setValue(v)
+ },
+
+ getValue: function () {
+
+ },
+
+ populate: function (items) {
+ this.switcher.populate.apply(this.switcher, arguments);
+ }
+});
+
+BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE";
+BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/**
+ * Created by zcf_1 on 2017/5/2.
+ */
+BI.MultiSelectList = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-list',
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn
+ })
+ },
+ _init: function () {
+ BI.MultiSelectList.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ this.storeValue = {};
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
+ // self.trigger.setValue(self.storeValue);
+ };
+
+ this.adapter = BI.createWidget({
+ type: "bi.multi_select_loader",
+ cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom",
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ // onLoaded: o.onLoaded,
+ el: {
+ height: ""
+ }
+ });
+ this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
+ });
+ });
+
+ this.searcherPane = BI.createWidget({
+ type: "bi.multi_select_search_pane",
+ cls: "bi-border-left bi-border-right bi-border-bottom",
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.trigger.getKeyword();
+ },
+ itemsCreator: function (op, callback) {
+ op.keyword = self.trigger.getKeyword();
+ this.setKeyword(op.keyword);
+ o.itemsCreator(op, callback);
+ }
+ });
+ this.searcherPane.setVisible(false);
+
+ this.trigger = BI.createWidget({
+ type: "bi.searcher",
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback();
+ },
+ adapter: this.adapter,
+ popup: this.searcherPane,
+ height: 200,
+ masker: false,
+ listeners: [{
+ eventName: BI.Searcher.EVENT_START,
+ action: function () {
+ self._showSearcherPane();
+ self._setStartValue("");
+ this.setValue(BI.deepClone(self.storeValue));
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_STOP,
+ action: function () {
+ self._showAdapter();
+ self._setStartValue("");
+ self.adapter.setValue(self.storeValue);
+ //需要刷新回到初始界面,否则搜索的结果不能放在最前面
+ self.adapter.populate();
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_PAUSE,
+ action: function () {
+ if (this.hasMatched()) {
+ var keyword = this.getKeyword();
+ self._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ self._showAdapter();
+ self.adapter.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self._setStartValue("");
+ self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
+ })
+ } else {
+ self._showAdapter();
+ }
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_SEARCHING,
+ action: function () {
+ var keywords = this.getKeyword();
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.adapter.setValue(self.storeValue);
+ assertShowValue();
+ self.adapter.populate();
+ self._setStartValue("");
+ } else {
+ self.adapter.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_CHANGE,
+ action: function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ });
+ } else {
+ self._join(this.getValue(), function () {//安徽省 北京
+ assertShowValue();
+ });
+ }
+ }
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.trigger,
+ height: 30
+ }, {
+ el: this.adapter,
+ height: "fill"
+ }]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.searcherPane,
+ top: 30,
+ bottom: 0,
+ left: 0,
+ right: 0
+ }]
+ })
+ },
+
+ _showAdapter: function () {
+ this.adapter.setVisible(true);
+ this.searcherPane.setVisible(false);
+ },
+
+ _showSearcherPane: function () {
+ this.searcherPane.setVisible(true);
+ this.adapter.setVisible(false);
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ if (!this._allData) {
+ o.itemsCreator({
+ type: BI.MultiSelectList.REQ_GET_ALL_DATA
+ }, function (ob) {
+ self._allData = BI.pluck(ob.items, "value");
+ digest(self._allData);
+ })
+ } else {
+ digest(this._allData)
+ }
+
+ function digest(items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ o.itemsCreator({
+ type: BI.MultiSelectList.REQ_GET_ALL_DATA,
+ keyword: self.trigger.getKeyword()
+ }, function (ob) {
+ var items = BI.pluck(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ self._adjust(callback);
+ })
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ if (!this._count) {
+ o.itemsCreator({
+ type: BI.MultiSelectList.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ self._count = res.count;
+ adjust();
+ callback();
+ });
+ } else {
+ adjust();
+ callback();
+ }
+ function adjust() {
+ if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.Multi,
+ value: []
+ }
+ } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.All,
+ value: []
+ }
+ }
+ }
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.adapter.setStartValue(value);
+ },
+
+ isAllSelected: function () {
+ return this.adapter.isAllSelected();
+ },
+
+ resize: function () {
+ // this.trigger.getCounter().adjustView();
+ // this.trigger.adjustView();
+ },
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.adapter.setValue(this.storeValue);
+ this.trigger.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ populate: function () {
+ this._count = null;
+ this._allData = null;
+ this.adapter.populate.apply(this.adapter, arguments);
+ this.trigger.populate.apply(this.trigger, arguments);
+ }
+});
+
+BI.extend(BI.MultiSelectList, {
+ REQ_GET_DATA_LENGTH: 0,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.MultiSelectList.EVENT_CHANGE = "BI.MultiSelectList.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_list", BI.MultiSelectList);/**
+ * Created by zcf_1 on 2017/5/11.
+ */
+BI.MultiSelectTree = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-select-tree',
+ itemsCreator: BI.emptyFn
+ })
+ },
+
+ _init: function () {
+ BI.MultiSelectTree.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = {value: {}};
+
+ this.adapter = BI.createWidget({
+ type: "bi.multi_select_tree_popup",
+ itemsCreator: o.itemsCreator
+ });
+ this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
+ if (self.searcher.isSearching()) {
+ self.storeValue = {value: self.searcherPane.getValue()};
+ } else {
+ self.storeValue = {value: self.adapter.getValue()};
+ }
+ self.setSelectedValue(self.storeValue.value);
+ self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
+ });
+
+ //搜索中的时候用的是parttree,同adapter中的synctree不一样
+ this.searcherPane = BI.createWidget({
+ type: "bi.multi_tree_search_pane",
+ cls: "bi-border-left bi-border-right bi-border-bottom",
+ keywordGetter: function () {
+ return self.searcher.getKeyword();
+ },
+ itemsCreator: function (op, callback) {
+ op.keyword = self.searcher.getKeyword();
+ o.itemsCreator(op, callback);
+ }
+ });
+ this.searcherPane.setVisible(false);
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback({
+ keyword: self.searcher.getKeyword()
+ });
+ },
+ adapter: this.adapter,
+ popup: this.searcherPane,
+ masker: false,
+ listeners: [{
+ eventName: BI.Searcher.EVENT_START,
+ action: function () {
+ self._showSearcherPane();
+ // self.storeValue = {value: self.adapter.getValue()};
+ // self.searcherPane.setSelectedValue(self.storeValue.value);
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_STOP,
+ action: function () {
+ self._showAdapter();
+ // self.storeValue = {value: self.searcherPane.getValue()};
+ // self.adapter.setSelectedValue(self.storeValue.value);
+ BI.nextTick(function () {
+ self.adapter.populate();
+ });
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_CHANGE,
+ action: function () {
+ if (self.searcher.isSearching()) {
+ self.storeValue = {value: self.searcherPane.getValue()};
+ } else {
+ self.storeValue = {value: self.adapter.getValue()};
+ }
+ self.setSelectedValue(self.storeValue.value);
+ self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_PAUSE,
+ action: function () {
+ self._showAdapter();
+ }
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.searcher,
+ height: 30
+ }, {
+ el: this.adapter,
+ height: "fill"
+ }]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.searcherPane,
+ top: 30,
+ bottom: 0,
+ left: 0,
+ right: 0
+ }]
+ })
+
+ },
+
+ _showAdapter: function () {
+ this.adapter.setVisible(true);
+ this.searcherPane.setVisible(false);
+ },
+
+ _showSearcherPane: function () {
+ this.searcherPane.setVisible(true);
+ this.adapter.setVisible(false);
+ },
+
+ resize: function () {
+
+ },
+
+ setSelectedValue: function (v) {
+ this.storeValue.value = v || {};
+ this.adapter.setSelectedValue(v);
+ this.searcherPane.setSelectedValue(v);
+ this.searcher.setValue({
+ value: v || {}
+ });
+ },
+
+ setValue: function (v) {
+ this.adapter.setValue(v);
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ updateValue: function (v) {
+ this.adapter.updateValue(v);
+ },
+
+ getValue: function () {
+ return this.storeValue.value;
+ },
+
+ populate: function () {
+ this.searcher.populate.apply(this.searcher, arguments);
+ this.adapter.populate.apply(this.adapter, arguments);
+ }
+});
+BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
+ * Created by zcf on 2016/12/21.
+ */
+BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom",
+ itemsCreator: BI.emptyFn
+ });
+ },
+ _init: function () {
+ BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.popup = BI.createWidget({
+ type: "bi.async_tree",
+ element: this,
+ itemsCreator: o.itemsCreator
+ });
+ this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
+ self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)
+ });
+ this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)
+ });
+ },
+
+ hasChecked: function () {
+ return this.popup.hasChecked();
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.popup.setValue(v);
+ },
+
+ setSelectedValue: function (v) {
+ v || (v = {});
+ this.popup.setSelectedValue(v);
+ },
+
+ updateValue: function (v) {
+ this.popup.updateValue(v);
+ this.popup.refresh();
+ },
+
+ populate: function (config) {
+ this.popup.stroke(config);
+ }
+
+});
+BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
+BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);/**
+ *
+ * @class BI.MultiTreeCheckPane
+ * @extends BI.Pane
+ */
+BI.MultiTreeCheckPane = BI.inherit(BI.Pane, {
+
+ constants: {
+ height: 25,
+ lgap: 10,
+ tgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-tree-check-pane bi-background",
+ onClickContinueSelect: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeCheckPane.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.selectedValues = {};
+
+ var continueSelect = BI.createWidget({
+ type: 'bi.text_button',
+ text: BI.i18nText('BI-Continue_Select'),
+ cls: 'multi-tree-check-selected'
+ });
+ continueSelect.on(BI.TextButton.EVENT_CHANGE, function () {
+ opts.onClickContinueSelect();
+ BI.nextTick(function () {
+ self.empty();
+ });
+ });
+
+ var backToPopup = BI.createWidget({
+ type: 'bi.left',
+ cls: 'multi-tree-continue-select',
+ items: [
+ {
+ el: {
+ type: "bi.label",
+ text: BI.i18nText('BI-Selected_Data')
+ },
+ lgap: this.constants.lgap,
+ tgap: this.constants.tgap
+ },
+ {
+ el: continueSelect,
+ lgap: this.constants.lgap,
+ tgap: this.constants.tgap
+ }]
+ });
+
+ this.display = BI.createWidget({
+ type: "bi.display_tree",
+ cls: "bi-multi-tree-display",
+ itemsCreator: function (op, callback) {
+ op.type = BI.TreeView.REQ_TYPE_GET_SELECTED_DATA;
+ opts.itemsCreator(op, callback);
+ }
+ });
+
+ this.display.on(BI.Events.AFTERINIT, function () {
+ self.fireEvent(BI.Events.AFTERINIT);
+ });
+
+ this.display.on(BI.TreeView.EVENT_INIT, function () {
+ backToPopup.setVisible(false);
+ });
+
+ this.display.on(BI.TreeView.EVENT_AFTERINIT, function () {
+ backToPopup.setVisible(true);
+ });
+
+ BI.createWidget({
+ type: 'bi.vtape',
+ element: this,
+ items: [{
+ height: this.constants.height,
+ el: backToPopup
+ }, {
+ height: 'fill',
+ el: this.display
+ }]
+ });
+
+ },
+
+ empty: function () {
+ this.display.empty();
+ },
+
+ populate: function (configs) {
+ this.display.stroke(configs);
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.display.setSelectedValue(v.value);
+ },
+
+ getValue: function () {
+
+ }
+});
+
+BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK";
+
+
+BI.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/**
+ *
+ * @class BI.MultiTreeCombo
+ * @extends BI.Single
+ */
+
+BI.MultiTreeCombo = BI.inherit(BI.Single, {
+
+ constants: {
+ offset: {
+ top: 1,
+ left: 1,
+ right: 2,
+ bottom: 33
+ }
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-tree-combo',
+ itemsCreator: BI.emptyFn,
+ height: 25
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeCombo.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ var isInit = false;
+ var want2showCounter = false;
+
+ this.trigger = BI.createWidget({
+ type: "bi.multi_select_trigger",
+ height: o.height,
+ // adapter: this.popup,
+ masker: {
+ offset: this.constants.offset
+ },
+ searcher: {
+ type: "bi.multi_tree_searcher",
+ itemsCreator: o.itemsCreator
+ },
+ switcher: {
+ el: {
+ type: "bi.multi_tree_check_selected_button"
+ },
+ popup: {
+ type: "bi.multi_tree_check_pane",
+ itemsCreator: o.itemsCreator
+ }
+ }
+
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ el: this.trigger,
+ adjustLength: 1,
+ popup: {
+ type: 'bi.multi_tree_popup_view',
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.MultiTreePopup.EVENT_AFTERINIT,
+ action: function () {
+ self.trigger.getCounter().adjustView();
+ isInit = true;
+ if (want2showCounter === true) {
+ showCounter();
+ }
+ }
+ }, {
+ eventName: BI.MultiTreePopup.EVENT_CHANGE,
+ action: function () {
+ change = true;
+ var val = {
+ type: BI.Selection.Multi,
+ value: this.hasChecked() ? {1: 1} : {}
+ };
+ self.trigger.getSearcher().setState(val);
+ self.trigger.getCounter().setButtonChecked(val);
+ }
+ }, {
+ eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM,
+ action: function () {
+ self.combo.hideView();
+ }
+ }, {
+ eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR,
+ action: function () {
+ clear = true;
+ self.setValue();
+ self._defaultState();
+ }
+ }],
+ itemsCreator: o.itemsCreator,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.trigger.getCounter().adjustView();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ }
+ });
+
+ this.storeValue = {value: {}};
+ var change = false;
+ var clear = false; //标识当前是否点击了清空
+
+ var isSearching = function () {
+ return self.trigger.getSearcher().isSearching();
+ };
+
+ var isPopupView = function () {
+ return self.combo.isViewVisible();
+ };
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
+ self.storeValue = {value: self.combo.getValue()};
+ this.setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
+ self.storeValue = {value: this.getValue()};
+ self.combo.setValue(self.storeValue);
+ BI.nextTick(function () {
+ if (isPopupView()) {
+ self.combo.populate();
+ }
+ });
+ });
+ function showCounter() {
+ if (isSearching()) {
+ self.storeValue = {value: self.trigger.getValue()};
+ } else if (isPopupView()) {
+ self.storeValue = {value: self.combo.getValue()};
+ }
+ self.trigger.setValue(self.storeValue);
+ }
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
+ if (want2showCounter === false) {
+ want2showCounter = true;
+ }
+ if (isInit === true) {
+ want2showCounter = null;
+ showCounter();
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () {
+ self.combo.toggle();
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
+ var val = {
+ type: BI.Selection.Multi,
+ value: this.getSearcher().hasChecked() ? {1: 1} : {}
+ };
+ this.getSearcher().setState(val);
+ this.getCounter().setButtonChecked(val);
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ if (isSearching()) {
+ return;
+ }
+ if (change === true) {
+ self.storeValue = {value: self.combo.getValue()};
+ change = false;
+ }
+ self.combo.setValue(self.storeValue);
+ self.populate();
+
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () {
+ if (isSearching()) {
+ self.trigger.stopEditing();
+ self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
+ }else{
+ if (isPopupView()) {
+ self.trigger.stopEditing();
+ self.storeValue = {value: self.combo.getValue()};
+ if (clear === true) {
+ self.storeValue = {value: {}};
+ }
+ self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
+ }
+ }
+ clear = false;
+ change = false;
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "multi-select-trigger-icon-button bi-border-left"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ self.trigger.getCounter().hideView();
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ })
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ setValue: function (v) {
+ this.storeValue.value = v || {};
+ this.combo.setValue({
+ value: v || {}
+ });
+ },
+
+ getValue: function () {
+ return this.storeValue.value;
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+
+BI.MultiTreeCombo.EVENT_CONFIRM = "MultiTreeCombo.EVENT_CONFIRM";
+
+BI.shortcut('bi.multi_tree_combo', BI.MultiTreeCombo);/**
+ * 带加载的多选下拉面板
+ * @class BI.MultiTreePopup
+ * @extends BI.Pane
+ */
+BI.MultiTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-tree-popup',
+ maxWidth: 'auto',
+ minWidth: 100,
+ maxHeight: 400,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.selectedValues = {};
+
+ this.tree = BI.createWidget({
+ type: "bi.async_tree",
+ height: 400,
+ cls:"popup-view-tree",
+ itemsCreator: opts.itemsCreator,
+ onLoaded: opts.onLoaded
+ });
+
+ this.popupView = BI.createWidget({
+ type: "bi.multi_popup_view",
+ element: this,
+ stopPropagation: false,
+ maxWidth: opts.maxWidth,
+ minWidth: opts.minWidth,
+ maxHeight: opts.maxHeight,
+ buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')],
+ el: this.tree
+ });
+
+ this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
+ switch (index) {
+ case 0:
+ self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM);
+ break;
+ }
+ });
+
+ this.tree.on(BI.TreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiTreePopup.EVENT_CHANGE);
+ });
+
+ this.tree.on(BI.TreeView.EVENT_AFTERINIT, function () {
+ self.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT);
+ });
+
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.tree.setSelectedValue(v.value);
+ },
+
+ populate: function (config) {
+ this.tree.stroke(config);
+ },
+
+ hasChecked: function () {
+ return this.tree.hasChecked();
+ },
+
+ resetHeight: function (h) {
+ this.popupView.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.popupView.resetWidth(w);
+ }
+});
+
+BI.MultiTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiTreePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.MultiTreePopup.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+BI.MultiTreePopup.EVENT_AFTERINIT = "EVENT_AFTERINIT";
+
+
+BI.shortcut('bi.multi_tree_popup_view', BI.MultiTreePopup);/**
+ *
+ * 在搜索框中输入文本弹出的面板
+ * @class BI.MultiTreeSearchPane
+ * @extends BI.Pane
+ */
+
+BI.MultiTreeSearchPane = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-tree-search-pane bi-card",
+ itemsCreator: BI.emptyFn,
+ keywordGetter: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeSearchPane.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.partTree = BI.createWidget({
+ type: "bi.part_tree",
+ element: this,
+ tipText: BI.i18nText("BI-No_Select"),
+ itemsCreator: function (op, callback) {
+ op.keyword = opts.keywordGetter();
+ opts.itemsCreator(op, callback);
+ }
+ });
+
+ this.partTree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.partTree.on(BI.TreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE);
+ });
+ },
+
+ hasChecked: function () {
+ return this.partTree.hasChecked();
+ },
+
+ setValue: function (v) {
+ this.setSelectedValue(v.value);
+ },
+
+ setSelectedValue: function (v) {
+ v || (v = {});
+ this.partTree.setSelectedValue(v);
+ },
+
+ getValue: function () {
+ return this.partTree.getValue();
+ },
+
+ empty: function () {
+ this.partTree.empty();
+ },
+
+ populate: function (op) {
+ this.partTree.stroke.apply(this.partTree, arguments);
+ }
+});
+
+BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+
+BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane);/**
+ * 查看已选按钮
+ * Created by guy on 15/11/3.
+ * @class BI.MultiTreeCheckSelectedButton
+ * @extends BI.Single
+ */
+BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, {
+
+ _const: {
+ checkSelected: BI.i18nText('BI-Check_Selected')
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-tree-check-selected-button',
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeCheckSelectedButton.superclass._init.apply(this, arguments);
+ var self = this;
+ this.indicator = BI.createWidget({
+ type: 'bi.icon_button',
+ cls: 'check-font trigger-check-selected',
+ width: 15,
+ height: 15,
+ stopPropagation: true
+ });
+
+ this.checkSelected = BI.createWidget({
+ type: 'bi.text_button',
+ cls: "trigger-check-selected",
+ invisible: true,
+ hgap: 4,
+ text: this._const.checkSelected,
+ textAlign: 'center',
+ textHeight: 15
+ });
+ this.checkSelected.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.checkSelected.on(BI.TextButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
+ });
+
+ BI.createWidget({
+ type: "bi.horizontal",
+ element: this,
+ items: [this.indicator, this.checkSelected]
+ })
+
+ this.element.hover(function () {
+ self.indicator.setVisible(false);
+ self.checkSelected.setVisible(true);
+ }, function () {
+ self.indicator.setVisible(true);
+ self.checkSelected.setVisible(false);
+ });
+ this.setVisible(false);
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.setVisible(BI.size(v.value) > 0);
+ }
+});
+
+BI.MultiTreeCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut('bi.multi_tree_check_selected_button', BI.MultiTreeCheckSelectedButton);/**
+ * searcher
+ * Created by guy on 15/11/3.
+ * @class BI.MultiTreeSearcher
+ * @extends Widget
+ */
+BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: 'bi-multi-tree-searcher',
+ itemsCreator: BI.emptyFn,
+ popup: {},
+
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeSearcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: 'bi.multi_select_editor',
+ height: o.height,
+ el: {
+ type: "bi.simple_state_editor",
+ height: o.height
+ }
+ });
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ element: this,
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback({
+ keyword: self.editor.getValue()
+ });
+ },
+ el: this.editor,
+
+ popup: BI.extend({
+ type: "bi.multi_tree_search_pane",
+ keywordGetter: function () {
+ return self.editor.getValue();
+ },
+ itemsCreator: function (op, callback) {
+ op.keyword = self.editor.getValue();
+ o.itemsCreator(op, callback);
+ }
+ }, o.popup),
+
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.Searcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_START);
+ });
+ this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
+ if (this.hasMatched()) {
+
+ }
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.Searcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_STOP);
+ });
+ this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE, arguments);
+ });
+ },
+
+ adjustView: function () {
+ this.searcher.adjustView();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ },
+
+ isSearching: function () {
+ return this.searcher.isSearching();
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ getKeyword: function () {
+ return this.editor.getValue();
+ },
+
+ hasMatched: function () {
+ return this.searcher.hasMatched();
+ },
+
+ hasChecked: function () {
+ return this.searcher.getView() && this.searcher.getView().hasChecked();
+ },
+
+ setState: function (ob) {
+ ob || (ob = {});
+ ob.value || (ob.value = []);
+ if (ob.type === BI.Selection.All) {
+ this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All);
+ } else {
+ this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None);
+ }
+ },
+
+ setValue: function (ob) {
+ this.setState(ob);
+ this.searcher.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ },
+
+ populate: function (items) {
+ this.searcher.populate.apply(this.searcher, arguments);
+ }
+});
+
+BI.MultiTreeSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
+BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
+BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
+BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);//小于号的值为:0,小于等于号的值为:1
+//closeMIn:最小值的符号,closeMax:最大值的符号
+/**
+ * Created by roy on 15/9/17.
+ *
+ */
+BI.NumericalInterval = BI.inherit(BI.Single, {
+ constants: {
+ typeError: "typeBubble",
+ numberError: "numberBubble",
+ signalError: "signalBubble",
+ editorWidth: 114,
+ columns: 5,
+ width: 30,
+ rows: 1,
+ numberErrorCls: "number-error",
+ border: 1,
+ less: 0,
+ less_equal: 1,
+ numTip: ""
+ },
+ _defaultConfig: function () {
+ var conf = BI.NumericalInterval.superclass._defaultConfig.apply(this, arguments)
+ return BI.extend(conf, {
+ extraCls: "bi-numerical-interval",
+ height: 25,
+ validation: "valid"
+ })
+ },
+ _init: function () {
+ var self = this, c = this.constants, o = this.options;
+ BI.NumericalInterval.superclass._init.apply(this, arguments)
+ this.smallEditor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height - 2,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ allowBlank: true,
+ value: o.min,
+ level: "warning",
+ tipType: "warning",
+ quitChecker: function () {
+ return false;
+ },
+ validationChecker: function (v) {
+ if (!BI.isNumeric(v)) {
+ self.smallEditorBubbleType = c.typeError;
+ return false;
+ }
+ return true;
+ },
+ cls: "numerical-interval-small-editor bi-border-top bi-border-bottom bi-border-left"
+ });
+
+ this.smallTip = BI.createWidget({
+ type: "bi.label",
+ text: o.numTip,
+ height: o.height - 2,
+ invisible: true
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.smallEditor.element,
+ items: [{
+ el: this.smallTip,
+ top: 0,
+ right: 5
+ }]
+ });
+
+ this.bigEditor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height - 2,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ allowBlank: true,
+ value: o.max,
+ level: "warning",
+ tipType: "warning",
+ quitChecker: function () {
+ return false;
+ },
+ validationChecker: function (v) {
+ if (!BI.isNumeric(v)) {
+ self.bigEditorBubbleType = c.typeError;
+ return false;
+ }
+ return true;
+ },
+ cls: "numerical-interval-big-editor bi-border-top bi-border-bottom bi-border-right"
+ });
+
+ this.bigTip = BI.createWidget({
+ type: "bi.label",
+ text: o.numTip,
+ height: o.height - 2,
+ invisible: true
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.bigEditor.element,
+ items: [{
+ el: this.bigTip,
+ top: 0,
+ right: 5
+ }]
+ });
+
+ //this.smallCombo = BI.createWidget({
+ // type: "bi.numerical_interval_combo",
+ // cls: "numerical-interval-small-combo",
+ // height: o.height,
+ // value: o.closemin ? 1 : 0,
+ // offsetStyle: "left"
+ //});
+ //
+ //this.bigCombo = BI.createWidget({
+ // type: "bi.numerical_interval_combo",
+ // cls: "numerical-interval-big-combo",
+ // height: o.height,
+ // value: o.closemax ? 1 : 0,
+ // offsetStyle: "left"
+ //});
+ this.smallCombo = BI.createWidget({
+ type: "bi.icon_combo",
+ cls: "numerical-interval-small-combo bi-border",
+ height: o.height - 2,
+ items: [{
+ text: "(" + BI.i18nText("BI-Less_Than") + ")",
+ iconClass: "less-font",
+ value: 0
+ }, {
+ text: "(" + BI.i18nText("BI-Less_And_Equal") + ")",
+ value: 1,
+ iconClass: "less-equal-font"
+ }]
+ });
+ if (o.closemin === true) {
+ this.smallCombo.setValue(1);
+ } else {
+ this.smallCombo.setValue(0);
+ }
+ this.bigCombo = BI.createWidget({
+ type: "bi.icon_combo",
+ cls: "numerical-interval-big-combo bi-border",
+ height: o.height - 2,
+ items: [{
+ text: "(" + BI.i18nText("BI-Less_Than") + ")",
+ iconClass: "less-font",
+ value: 0
+ }, {
+ text: "(" + BI.i18nText("BI-Less_And_Equal") + ")",
+ value: 1,
+ iconClass: "less-equal-font"
+ }]
+ });
+ if (o.closemax === true) {
+ this.bigCombo.setValue(1);
+ } else {
+ this.bigCombo.setValue(0);
+ }
+ this.label = BI.createWidget({
+ type: "bi.label",
+ text: BI.i18nText("BI-Basic_Value"),
+ textHeight: o.height - c.border * 2,
+ width: c.width - c.border * 2,
+ height: o.height - c.border * 2,
+ level: "warning",
+ tipType: "warning"
+ });
+ this.left = BI.createWidget({
+ type: "bi.htape",
+ items: [{
+ el: self.smallEditor
+ }, {
+ el: self.smallCombo,
+ width: c.width - c.border * 2
+ }]
+
+ });
+ this.right = BI.createWidget({
+ type: "bi.htape",
+ items: [{
+ el: self.bigCombo,
+ width: c.width - c.border * 2
+ }, {
+ el: self.bigEditor
+ }]
+ });
+
+
+ BI.createWidget({
+ element: self,
+ type: "bi.center",
+ hgap: 15,
+ height: o.height,
+ items: [
+ {
+ type: "bi.absolute",
+ items: [{
+ el: self.left,
+ left: -15,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: self.right,
+ left: 0,
+ right: -15,
+ top: 0,
+ bottom: 0
+ }]
+ }
+ ]
+ });
+
+ BI.createWidget({
+ element: self,
+ type: "bi.horizontal_auto",
+ items: [
+ self.label
+ ]
+ });
+
+
+ self._setValidEvent(self.bigEditor, c.bigEditor);
+ self._setValidEvent(self.smallEditor, c.smallEditor);
+ self._setErrorEvent(self.bigEditor, c.bigEditor);
+ self._setErrorEvent(self.smallEditor, c.smallEditor);
+ self._setBlurEvent(self.bigEditor);
+ self._setBlurEvent(self.smallEditor);
+ self._setFocusEvent(self.bigEditor);
+ self._setFocusEvent(self.smallEditor);
+ self._setComboValueChangedEvent(self.bigCombo);
+ self._setComboValueChangedEvent(self.smallCombo);
+ self._setEditorValueChangedEvent(self.bigEditor);
+ self._setEditorValueChangedEvent(self.smallEditor);
+ },
+
+ _checkValidation: function () {
+ var self = this, c = this.constants, o = this.options;
+ self._setTitle("");
+ BI.Bubbles.hide(c.typeError);
+ BI.Bubbles.hide(c.numberError);
+ BI.Bubbles.hide(c.signalError);
+ if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) {
+ self.element.removeClass("number-error");
+ o.validation = "invalid";
+ return c.typeError;
+ } else {
+ if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) {
+ self.element.removeClass("number-error");
+ o.validation = "valid";
+ return "";
+ } else {
+ var smallValue = parseFloat(self.smallEditor.getValue()), bigValue = parseFloat(self.bigEditor.getValue()),
+ bigComboValue = self.bigCombo.getValue(), smallComboValue = self.smallCombo.getValue();
+ if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) {
+ if (smallValue > bigValue) {
+ self.element.addClass("number-error");
+ o.validation = "invalid";
+ return c.numberError;
+ } else {
+ self.element.removeClass("number-error");
+ o.validation = "valid";
+ return "";
+ }
+ } else {
+ if (smallValue > bigValue) {
+ self.element.addClass("number-error");
+ o.validation = "invalid";
+ return c.numberError;
+ } else if (smallValue === bigValue) {
+ self.element.addClass("number-error");
+ o.validation = "invalid";
+ return c.signalError;
+ } else {
+ self.element.removeClass("number-error");
+ o.validation = "valid";
+ return "";
+ }
+ }
+ }
+
+ }
+ },
+
+ _setTitle: function (v) {
+ var self = this;
+ self.bigEditor.setTitle(v);
+ self.smallEditor.setTitle(v);
+ self.label.setTitle(v);
+ },
+
+ _setFocusEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.Editor.EVENT_FOCUS, function () {
+ self._setTitle("");
+ switch (self._checkValidation()) {
+ case c.typeError:
+ BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ case c.numberError:
+ BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ case c.signalError:
+ BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ default :
+ return
+ }
+
+ })
+ },
+ _setBlurEvent: function (w) {
+ var c = this.constants, self = this;
+ w.on(BI.Editor.EVENT_BLUR, function () {
+ BI.Bubbles.hide(c.typeError);
+ BI.Bubbles.hide(c.numberError);
+ BI.Bubbles.hide(c.signalError);
+ switch (self._checkValidation()) {
+ case c.typeError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));
+ break;
+ case c.numberError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));
+ break;
+ case c.signalError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));
+ break;
+ default:
+ self._setTitle("");
+ }
+ })
+ },
+
+ _setErrorEvent: function (w) {
+ var c = this.constants, self = this
+ w.on(BI.Editor.EVENT_ERROR, function () {
+ self._checkValidation();
+ BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ })
+ },
+
+
+ _setValidEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.Editor.EVENT_VALID, function () {
+ switch (self._checkValidation()) {
+ case c.numberError:
+ BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ break;
+ case c.signalError:
+ BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ break;
+ default:
+ self.fireEvent(BI.NumericalInterval.EVENT_VALID);
+ }
+ })
+ },
+
+
+ _setEditorValueChangedEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.Editor.EVENT_CHANGE, function () {
+ switch (self._checkValidation()) {
+ case c.typeError:
+ BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ case c.numberError:
+ BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ case c.signalError:
+ BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "center"
+ });
+ break;
+ default :
+ break;
+ }
+ self.fireEvent(BI.NumericalInterval.EVENT_CHANGE);
+ });
+ },
+
+ _setComboValueChangedEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.IconCombo.EVENT_CHANGE, function () {
+ switch (self._checkValidation()) {
+ case c.typeError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ break;
+ case c.numberError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ break;
+ case c.signalError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));
+ self.fireEvent(BI.NumericalInterval.EVENT_ERROR);
+ break;
+ default :
+ self.fireEvent(BI.NumericalInterval.EVENT_CHANGE);
+ self.fireEvent(BI.NumericalInterval.EVENT_VALID);
+ }
+ })
+ },
+
+ isStateValid: function () {
+ return this.options.validation === "valid";
+ },
+
+ setMinEnable: function (b) {
+ this.smallEditor.setEnable(b);
+ },
+
+ setCloseMinEnable: function (b) {
+ this.smallCombo.setEnable(b);
+ },
+
+ setMaxEnable: function (b) {
+ this.bigEditor.setEnable(b);
+ },
+
+ setCloseMaxEnable: function (b) {
+ this.bigCombo.setEnable(b);
+ },
+
+ showNumTip: function () {
+ this.smallTip.setVisible(true);
+ this.bigTip.setVisible(true);
+ },
+
+ hideNumTip: function () {
+ this.smallTip.setVisible(false);
+ this.bigTip.setVisible(false);
+ },
+
+ setNumTip: function(numTip) {
+ this.smallTip.setText(numTip);
+ this.bigTip.setText(numTip);
+ },
+
+ getNumTip: function() {
+ return this.smallTip.getText();
+ },
+
+ setValue: function (data) {
+ data = data || {};
+ var self = this, combo_value;
+ if (BI.isNumeric(data.min) || BI.isEmptyString(data.min)) {
+ self.smallEditor.setValue(data.min);
+ }
+
+ if (!BI.isNotNull(data.min)) {
+ self.smallEditor.setValue("");
+ }
+
+ if (BI.isNumeric(data.max) || BI.isEmptyString(data.max)) {
+ self.bigEditor.setValue(data.max);
+ }
+
+ if (!BI.isNotNull(data.max)) {
+ self.bigEditor.setValue("");
+ }
+
+ if (!BI.isNull(data.closemin)) {
+ if (data.closemin === true) {
+ combo_value = 1
+ } else {
+ combo_value = 0
+ }
+ self.smallCombo.setValue(combo_value);
+ }
+
+ if (!BI.isNull(data.closemax)) {
+ if (data.closemax === true) {
+ combo_value = 1
+ } else {
+ combo_value = 0
+ }
+ self.bigCombo.setValue(combo_value);
+ }
+ },
+
+
+ getValue: function () {
+ var self = this, value = {}, minComboValue = self.smallCombo.getValue(), maxComboValue = self.bigCombo.getValue();
+ value.min = self.smallEditor.getValue();
+ value.max = self.bigEditor.getValue();
+ if (minComboValue[0] === 0) {
+ value.closemin = false
+ } else {
+ value.closemin = true
+ }
+
+ if (maxComboValue[0] === 0) {
+ value.closemax = false
+ } else {
+ value.closemax = true
+ }
+ return value;
+ }
+});
+BI.NumericalInterval.EVENT_CHANGE = "EVENT_CHANGE";
+BI.NumericalInterval.EVENT_VALID = "EVENT_VALID";
+BI.NumericalInterval.EVENT_ERROR = "EVENT_ERROR";
+BI.shortcut("bi.numerical_interval", BI.NumericalInterval);/**
+ *
+ * 表格
+ *
+ * Created by GUY on 2015/9/22.
+ * @class BI.PageTableCell
+ * @extends BI.Single
+ */
+BI.PageTableCell = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-page-table-cell",
+ text: "",
+ title: ""
+ })
+ },
+
+ _init: function () {
+ BI.PageTableCell.superclass._init.apply(this, arguments);
+ var label = BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ height: this.options.height,
+ text: this.options.text,
+ title: this.options.title,
+ value: this.options.value,
+ lgap: 5,
+ rgap: 5
+ });
+
+ if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) {
+ this.element.css(this.options.styles);
+ }
+ }
+});
+
+BI.shortcut("bi.page_table_cell", BI.PageTableCell);/**
+ * 分页表格
+ *
+ * Created by GUY on 2016/2/15.
+ * @class BI.PageTable
+ * @extends BI.Widget
+ */
+BI.PageTable = BI.inherit(BI.Widget, {
+
+ _const: {
+ scrollWidth: 18,
+ minScrollWidth: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-page-table",
+ el: {
+ type: "bi.sequence_table"
+ },
+ pager: {
+ horizontal: {
+ pages: false, //总页数
+ curr: 1, //初始化当前页, pages为数字时可用
+
+ hasPrev: BI.emptyFn,
+ hasNext: BI.emptyFn,
+ firstPage: 1,
+ lastPage: BI.emptyFn
+ },
+ vertical: {
+ pages: false, //总页数
+ curr: 1, //初始化当前页, pages为数字时可用
+
+ hasPrev: BI.emptyFn,
+ hasNext: BI.emptyFn,
+ firstPage: 1,
+ lastPage: BI.emptyFn
+ }
+ },
+
+ itemsCreator: BI.emptyFn,
+
+ isNeedFreeze: false,//是否需要冻结单元格
+ freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
+
+ isNeedMerge: false,//是否需要合并单元格
+ mergeCols: [], //合并的单元格列号
+ mergeRule: BI.emptyFn,
+
+ columnSize: [],
+ minColumnSize: [],
+ maxColumnSize: [],
+ headerRowSize: 25,
+ rowSize: 25,
+
+ regionColumnSize: [],
+
+ headerCellStyleGetter: BI.emptyFn,
+ summaryCellStyleGetter: BI.emptyFn,
+ sequenceCellStyleGetter: BI.emptyFn,
+
+ header: [],
+ items: [], //二维数组
+
+ //交叉表头
+ crossHeader: [],
+ crossItems: []
+ });
+ },
+
+ _init: function () {
+ BI.PageTable.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.hCurr = 1;
+ this.vCurr = 1;
+
+ this.table = BI.createWidget(o.el, {
+ type: "bi.sequence_table",
+ width: o.width,
+ height: o.height && o.height - 30,
+
+ isNeedResize: true,
+ isResizeAdapt: false,
+
+ isNeedFreeze: o.isNeedFreeze,
+ freezeCols: o.freezeCols,
+
+ isNeedMerge: o.isNeedMerge,
+ mergeCols: o.mergeCols,
+ mergeRule: o.mergeRule,
+
+ columnSize: o.columnSize,
+ minColumnSize: o.minColumnSize,
+ maxColumnSize: o.maxColumnSize,
+ headerRowSize: o.headerRowSize,
+ rowSize: o.rowSize,
+
+ regionColumnSize: o.regionColumnSize,
+
+ headerCellStyleGetter: o.headerCellStyleGetter,
+ summaryCellStyleGetter: o.summaryCellStyleGetter,
+ sequenceCellStyleGetter: o.sequenceCellStyleGetter,
+
+ header: o.header,
+ items: o.items,
+ //交叉表头
+ crossHeader: o.crossHeader,
+ crossItems: o.crossItems
+ });
+
+ this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
+ self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
+ o.regionColumnSize = this.getRegionColumnSize();
+ o.columnSize = this.getColumnSize();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
+ o.regionColumnSize = this.getRegionColumnSize();
+ o.columnSize = this.getColumnSize();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
+ });
+
+ this.pager = BI.createWidget(o.pager, {
+ type: "bi.direction_pager",
+ height: 30
+ });
+ this.pager.on(BI.Pager.EVENT_CHANGE, function () {
+ var vpage = this.getVPage && this.getVPage();
+ if (BI.isNull(vpage)) {
+ vpage = this.getCurrentPage();
+ }
+ var hpage = this.getHPage && this.getHPage();
+ o.itemsCreator({
+ vpage: vpage,
+ hpage: hpage
+ }, function (items, header, crossItems, crossHeader) {
+ self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage);
+ self.table.setHPage && self.table.setHPage(hpage);
+ self.populate.apply(self, arguments);
+ });
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.table,
+ left: 0,
+ top: 0
+ }, {
+ el: this.pager,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }]
+ })
+ },
+
+ setHPage: function (v) {
+ this.hCurr = v;
+ this.pager.setHPage && this.pager.setHPage(v);
+ this.table.setHPage && this.table.setHPage(v);
+ },
+
+ setVPage: function (v) {
+ this.vCurr = v;
+ this.pager.setVPage && this.pager.setVPage(v);
+ this.table.setVPage && this.table.setVPage(v);
+ },
+
+ getHPage: function () {
+ var hpage = this.pager.getHPage && this.pager.getHPage();
+ if (BI.isNotNull(hpage)) {
+ return hpage;
+ }
+ hpage = this.pager.getCurrentPage && this.pager.getCurrentPage();
+ if (BI.isNotNull(hpage)) {
+ return hpage;
+ }
+ return this.hpage;
+ },
+
+ getVPage: function () {
+ var vpage = this.pager.getVPage && this.pager.getVPage();
+ if (BI.isNotNull(vpage)) {
+ return vpage;
+ }
+ vpage = this.pager.getCurrentPage && this.pager.getCurrentPage();
+ if (BI.isNotNull(vpage)) {
+ return vpage;
+ }
+ return this.vpage;
+ },
+
+ setWidth: function (width) {
+ BI.PageTable.superclass.setWidth.apply(this, arguments);
+ this.table.setWidth(width);
+ },
+
+ setHeight: function (height) {
+ BI.PageTable.superclass.setHeight.apply(this, arguments);
+ var showPager = false;
+ if (this.pager.alwaysShowPager) {
+ showPager = true;
+ } else if (this.pager.hasHNext && this.pager.hasHNext()) {
+ showPager = true;
+ } else if (this.pager.hasHPrev && this.pager.hasHPrev()) {
+ showPager = true;
+ } else if (this.pager.hasVNext && this.pager.hasVNext()) {
+ showPager = true;
+ } else if (this.pager.hasVPrev && this.pager.hasVPrev()) {
+ showPager = true;
+ } else if (this.pager.hasNext && this.pager.hasNext()) {
+ showPager = true;
+ } else if (this.pager.hasPrev && this.pager.hasPrev()) {
+ showPager = true;
+ }
+ this.table.setHeight(height - (showPager ? 30 : 0));
+ },
+
+ setColumnSize: function (columnSize) {
+ this.options.columnSize = columnSize;
+ this.table.setColumnSize(columnSize);
+ },
+
+ getColumnSize: function () {
+ return this.table.getColumnSize();
+ },
+
+ setRegionColumnSize: function (columnSize) {
+ this.options.columnSize = columnSize;
+ this.table.setRegionColumnSize(columnSize);
+ },
+
+ getRegionColumnSize: function () {
+ return this.table.getRegionColumnSize();
+ },
+
+ getVerticalScroll: function () {
+ return this.table.getVerticalScroll();
+ },
+
+ setLeftHorizontalScroll: function (scrollLeft) {
+ this.table.setLeftHorizontalScroll(scrollLeft);
+ },
+
+ setRightHorizontalScroll: function (scrollLeft) {
+ this.table.setRightHorizontalScroll(scrollLeft);
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ this.table.setVerticalScroll(scrollTop);
+ },
+
+ restore: function () {
+ this.table.restore();
+ },
+
+ attr: function () {
+ BI.PageTable.superclass.attr.apply(this, arguments);
+ this.table.attr.apply(this.table, arguments);
+ },
+
+ populate: function () {
+ this.pager.populate();
+ this.table.populate.apply(this.table, arguments);
+ },
+
+ destroy: function () {
+ this.table.destroy();
+ this.pager && this.pager.destroy();
+ BI.PageTable.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.shortcut('bi.page_table', BI.PageTable);/**
+ * 路径选择
+ *
+ * Created by GUY on 2015/12/4.
+ * @class BI.PathChooser
+ * @extends BI.Widget
+ */
+BI.PathChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ lineColor: "#d4dadd",
+ selectLineColor: "#3f8ce8"
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-path-chooser",
+ items: []
+ })
+ },
+
+ _init: function () {
+ BI.PathChooser.superclass._init.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _createRegions: function (regions) {
+ var self = this;
+ this.regions = BI.createWidgets(BI.map(regions, function (i, region) {
+ return {
+ type: "bi.path_region",
+ title: self.texts[region] || region
+ }
+ }));
+ this.regionMap = {};
+ BI.each(regions, function (i, region) {
+ self.regionMap[region] = i;
+ });
+ this.container = BI.createWidget({
+ type: "bi.horizontal",
+ verticalAlign: "top",
+ scrollx: false,
+ scrolly: false,
+ hgap: 10,
+ items: this.regions
+ });
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ element: this,
+ scrollable: true,
+ hgap: 10,
+ items: [this.container]
+ });
+ },
+
+ getRegionIndexById: function (id) {
+ var node = this.store[id];
+ var regionType = node.get("region");
+ return this.regionMap[regionType];
+ },
+
+ _drawPath: function (start, offset, index) {
+ var self = this;
+ var starts = [];
+ if (BI.contains(this.start, start)) {
+ starts = this.start;
+ } else {
+ starts = [start];
+ }
+
+ BI.each(starts, function (i, s) {
+ BI.each(self.radios[s], function (i, rad) {
+ rad.setSelected(false);
+ });
+ BI.each(self.lines[s], function (i, line) {
+ line.attr("stroke", self._const.lineColor);
+ });
+ BI.each(self.regionIndexes[s], function (i, idx) {
+ self.regions[idx].reset();
+ });
+ });
+
+ BI.each(this.routes[start][index], function (i, id) {
+ var regionIndex = self.getRegionIndexById(id);
+ self.regions[regionIndex].setSelect(offset + index, id);
+ });
+ var current = BI.last(this.routes[start][index]);
+
+ while (current && this.routes[current] && this.routes[current].length === 1) {
+ BI.each(this.routes[current][0], function (i, id) {
+ var regionIndex = self.getRegionIndexById(id);
+ self.regions[regionIndex].setSelect(0, id);
+ });
+ this.lines[current][0].attr("stroke", self._const.selectLineColor).toFront();
+ current = BI.last(this.routes[current][0]);
+ }
+ this.lines[start][index].attr("stroke", self._const.selectLineColor).toFront();
+ this.radios[start] && this.radios[start][index] && this.radios[start][index].setSelected(true);
+ },
+
+ _drawRadio: function (start, offset, index, x, y) {
+ var self = this;
+ var radio = BI.createWidget({
+ type: "bi.radio",
+ cls: "path-chooser-radio",
+ selected: offset + index === 0,
+ start: start,
+ index: index
+ });
+ radio.on(BI.Radio.EVENT_CHANGE, function () {
+ self._drawPath(start, offset, index);
+ self.fireEvent(BI.PathChooser.EVENT_CHANGE, start, index);
+ });
+ if (!this.radios[start]) {
+ this.radios[start] = [];
+ }
+ this.radios[start].push(radio);
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: [{
+ el: radio,
+ left: x - 6.5,
+ top: y - 6.5
+ }]
+ })
+ },
+
+ _drawLine: function (start, lines) {
+ var self = this;
+ if (!this.lines[start]) {
+ this.lines[start] = [];
+ }
+ if (!this.pathes[start]) {
+ this.pathes[start] = [];
+ }
+ var startRegionIndex = this.getRegionIndexById(start);
+ //start所在的位置,然后接着往下画其他的路径
+ var offset = this.regions[startRegionIndex].getIndexByValue(start);
+ BI.each(lines, function (i, line) {
+ self.pathes[start][i] = [];
+ var idx = i + offset;
+ var path = "";
+ var stop = 47.5 + 29 * idx;
+ var sleft = 50 + 100 * startRegionIndex;
+ var radioStartX = sleft, radioStartY = stop;
+ var etop = stop;
+ var endRegionIndex = self.getRegionIndexById(BI.last(line));
+ var endOffset = self.regions[endRegionIndex].getIndexByValue(BI.last(line));
+ var eleft = 50 + 100 * endRegionIndex;
+ if (BI.contains(self.start, start)) {
+ radioStartX = sleft - 50;
+ path += "M" + (sleft - 50) + "," + stop;
+ self.pathes[start][i].push({
+ x: sleft - 50,
+ y: stop
+ })
+ } else if (idx === 0) {
+ radioStartX = sleft + 50;
+ path += "M" + sleft + "," + stop;
+ self.pathes[start][i].push({
+ x: sleft,
+ y: stop
+ })
+ } else {
+ radioStartX = sleft + 50;
+ path += "M" + sleft + "," + 47.5 + "L" + (sleft + 50) + "," + 47.5 + "L" + (sleft + 50) + "," + stop;
+ self.pathes[start][i].push({
+ x: sleft,
+ y: 47.5
+ });
+ self.pathes[start][i].push({
+ x: sleft + 50,
+ y: 47.5
+ });
+ self.pathes[start][i].push({
+ x: sleft + 50,
+ y: stop
+ });
+ }
+ if (idx > 0) {
+ var endY = endOffset * 29 + 47.5;
+ path += "L" + (eleft - 50) + "," + etop + "L" + (eleft - 50) + "," + endY + "L" + eleft + "," + endY;
+ self.pathes[start][i].push({
+ x: eleft - 50,
+ y: etop
+ });
+ self.pathes[start][i].push({
+ x: eleft - 50,
+ y: endY
+ });
+ self.pathes[start][i].push({
+ x: eleft,
+ y: endY
+ });
+ } else {
+ path += "L" + eleft + "," + etop;
+ self.pathes[start][i].push({
+ x: eleft,
+ y: etop
+ });
+ }
+
+ var graph = self.svg.path(path)
+ .attr({
+ stroke: idx === 0 ? self._const.selectLineColor : self._const.lineColor,
+ 'stroke-dasharray': '-'
+ });
+ self.lines[start].push(graph);
+ if (lines.length > 1) {
+ self.lines[start][0].toFront();
+ }
+ //第一个元素无论有多少个都要显示radio
+ if (BI.contains(self.start, start)) {
+ self.lines[self.regions[0].getValueByIndex(0)][0].toFront();
+ }
+ if (lines.length > 1 || BI.contains(self.start, start)) {
+ self._drawRadio(start, offset, i, radioStartX, radioStartY);
+ }
+ });
+ },
+
+ _drawLines: function (routes) {
+ var self = this;
+ this.lines = {};
+ this.pathes = {};
+ this.radios = {};
+ this.regionIndexes = {};
+ BI.each(routes, function (k, route) {
+ if (!self.regionIndexes[k]) {
+ self.regionIndexes[k] = [];
+ }
+ BI.each(route, function (i, rs) {
+ BI.each(rs, function (j, id) {
+ var regionIndex = self.getRegionIndexById(id);
+ if (!BI.contains(self.regionIndexes[k], regionIndex)) {
+ self.regionIndexes[k].push(regionIndex);
+ }
+ });
+ })
+ });
+ BI.each(routes, function (k, route) {
+ self._drawLine(k, route);
+ });
+ },
+
+ _pushNodes: function (nodes) {
+ var self = this;
+ var indexes = [];
+ for (var i = 0; i < nodes.length; i++) {
+ var id = nodes[i];
+ var index = self.getRegionIndexById(id);
+ indexes.push(index);
+ var region = self.regions[index];
+ if (i === nodes.length - 1) {
+ if (!region.hasItem(id)) {
+ region.addItem(id, self.texts[id]);
+ }
+ break;
+ }
+ if (i > 0 || BI.contains(self.start, id)) {
+ region.addItem(id, self.texts[id]);
+ }
+ }
+ for (var i = BI.first(indexes); i < BI.last(indexes); i++) {
+ if (!BI.contains(indexes, i)) {
+ self.regions[i].addItem("");
+ }
+ }
+ },
+
+ _createNodes: function () {
+ var self = this, o = this.options;
+ this.store = {};
+ this.texts = {};
+ this.start = [];
+ this.end = [];
+ BI.each(o.items, function (i, item) {
+ self.start.push(BI.first(item).value);
+ self.end.push(BI.last(item).value);
+ });
+ this.start = BI.uniq(this.start);
+ this.end = BI.uniq(this.end);
+ var regions = [];
+ var tree = new BI.Tree();
+ var branches = {}, max = 0;
+ BI.each(o.items, function (i, items) {
+ BI.each(items, function (j, item) {
+ if (!BI.has(branches, item.value)) {
+ branches[item.value] = 0;
+ }
+ branches[item.value]++;
+ max = Math.max(max, branches[item.value]);
+ var prev = {};
+ if (j > 0) {
+ prev = items[j - 1];
+ }
+ var parent = self.store[prev.value || ""];
+ var node = self.store[item.value] || new BI.Node(item.value);
+ node.set(item);
+ self.store[item.value] = node;
+ self.texts[item.value] = item.text;
+ self.texts[item.region] = item.regionText;
+ parent = BI.isNull(parent) ? tree.getRoot() : parent;
+ if (parent.getChildIndex(item.value) === -1) {
+ tree.addNode(parent, node);
+ }
+ })
+ });
+
+ //算出区域列表
+ tree.traverse(function (node) {
+ BI.each(node.getChildren(), function (i, child) {
+ if (BI.contains(regions, child.get("region"))) {
+ var index1 = BI.indexOf(regions, node.get("region"));
+ var index2 = BI.indexOf(regions, child.get("region"));
+ //交换区域
+ if (index1 > index2) {
+ var t = regions[index2];
+ for (var j = index2; j < index1; j++) {
+ regions[j] = regions[j + 1];
+ }
+ regions[index1] = t;
+ }
+ } else {
+ regions.push(child.get("region"));
+ }
+ });
+ });
+ this._createRegions(regions);
+
+ //算出节点
+ BI.each(branches, function (k, branch) {
+ if (branch < max) {
+ delete branches[k];
+ }
+ });
+
+ //过滤节点
+ var nodes = [];
+ var n = tree.getRoot();
+ while (n && n.getChildrenLength() === 1) {
+ if (BI.has(branches, n.getChildren()[0].id)) {
+ delete branches[n.getChildren()[0].id];
+ n = n.getChildren()[0];
+ } else {
+ n = null;
+ }
+ }
+ tree.traverse(function (node) {
+ if (BI.has(branches, node.id)) {
+ nodes.push(node.id);
+ delete branches[node.id];
+ }
+ });
+
+ //填充节点
+ var routes = {};
+ var s, e;
+ for (var i = 0, len = nodes.length; i < len + 1; i++) {
+ if (len === 0) {
+ s = [];
+ BI.each(this.start, function (i, id) {
+ s.push(tree.search(id));
+ });
+ e = [];
+ BI.each(this.end, function (i, id) {
+ e.push(tree.search(id));
+ });
+ } else if (i === len) {
+ s = e;
+ e = [];
+ BI.each(this.end, function (i, id) {
+ e.push(tree.search(id));
+ });
+ } else if (i === 0) {
+ s = [];
+ BI.each(this.start, function (i, id) {
+ s.push(tree.search(id));
+ });
+ e = [tree.search(nodes[i])];
+ } else {
+ s = [tree.search(e[0] || tree.getRoot(), nodes[i - 1])];
+ e = [tree.search(s[0], nodes[i])];
+ }
+ BI.each(s, function (i, n) {
+ tree._recursion(n, [n.id], function (node, route) {
+ if (BI.contains(e, node)) {
+ if (!routes[n.id]) {
+ routes[n.id] = [];
+ }
+ routes[n.id].push(route);
+ self._pushNodes(route);
+ if (e.length <= 1) {
+ return true;
+ }
+ }
+ })
+ });
+ }
+ this.routes = routes;
+ this._drawLines(routes);
+ },
+
+ _unselectAllPath: function () {
+ var self = this;
+ BI.each(this.radios, function (idx, rad) {
+ BI.each(rad, function (i, r) {
+ r.setSelected(false);
+ });
+ });
+ BI.each(this.lines, function (idx, line) {
+ BI.each(line, function (i, li) {
+ li.attr("stroke", self._const.lineColor);
+ });
+ });
+ BI.each(this.regions, function (idx, region) {
+ region.reset();
+ });
+ },
+
+ populate: function (items) {
+ this.options.items = items || [];
+ var self = this;
+ this.empty();
+ if (this.options.items.length <= 0) {
+ return;
+ }
+ this.svg = BI.createWidget({
+ type: "bi.svg"
+ });
+ this._createNodes();
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: [{
+ el: this.svg,
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ setValue: function (v) {
+ this._unselectAllPath();
+ var nodes = BI.keys(this.routes), self = this;
+ var result = [], array = [];
+ BI.each(v, function (i, val) {
+ if (BI.contains(nodes, val)) {
+ if (array.length > 0) {
+ array.push(val);
+ result.push(array);
+ array = [];
+ }
+ }
+ array.push(val);
+ });
+ if (array.length > 0) {
+ result.push(array);
+ }
+ //画这n条路径
+ BI.each(result, function (idx, path) {
+ var start = path[0];
+ var index = BI.findIndex(self.routes[start], function (idx, p) {
+ if (BI.isEqual(path, p)) {
+ return true;
+ }
+ });
+ if (index >= 0) {
+ var startRegionIndex = self.getRegionIndexById(start);
+ var offset = self.regions[startRegionIndex].getIndexByValue(start);
+ self._drawPath(start, offset, index);
+ }
+ });
+ },
+
+ getValue: function () {
+ var path = [];
+ BI.each(this.regions, function (i, region) {
+ var val = region.getValue();
+ if (BI.isKey(val)) {
+ path.push(val);
+ }
+ });
+ return path;
+ }
+});
+BI.PathChooser.EVENT_CHANGE = "PathChooser.EVENT_CHANGE";
+BI.shortcut("bi.path_chooser", BI.PathChooser);/**
+ * 路径选择区域
+ *
+ * Created by GUY on 2015/12/4.
+ * @class BI.PathRegion
+ * @extends BI.Widget
+ */
+BI.PathRegion = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-path-region bi-background",
+ width: 80,
+ title: ""
+ })
+ },
+
+ _init: function () {
+ BI.PathRegion.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.zIndex = 100;
+ var title = BI.createWidget({
+ type: "bi.label",
+ text: o.title,
+ title: o.title,
+ height: 30
+ });
+ title.element.css("zIndex", this.zIndex--);
+ this.items = [];
+ this.vertical = BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ bgap: 5,
+ hgap: 10,
+ items: [title]
+ })
+ },
+
+ hasItem: function (val) {
+ return BI.any(this.items, function (i, item) {
+ return val === item.getValue();
+ });
+ },
+
+ addItem: function (value, text) {
+ if (BI.isKey(value)) {
+ var label = BI.createWidget({
+ type: "bi.label",
+ cls: "path-region-label bi-card bi-border bi-list-item-select",
+ text: text,
+ value: value,
+ title: text || value,
+ height: 22
+ });
+ } else {
+ var label = BI.createWidget({
+ type: "bi.layout",
+ height: 24
+ });
+ }
+ label.element.css("zIndex", this.zIndex--);
+ this.items.push(label);
+ this.vertical.addItem(label);
+ if (this.items.length === 1) {
+ this.setSelect(0, value);
+ }
+ },
+
+ reset: function () {
+ BI.each(this.items, function (i, item) {
+ item.element.removeClass("active");
+ });
+ },
+
+ setSelect: function (index, value) {
+ this.reset();
+ if (this.items.length <= 0) {
+ return;
+ }
+ if (this.items.length === 1) {
+ this.items[0].element.addClass("active");
+ return;
+ }
+ if (this.items[index].attr("value") === value) {
+ this.items[index].element.addClass("active");
+ }
+ },
+
+ setValue: function (value) {
+ this.setSelect(this.getIndexByValue(value), value);
+ },
+
+ getValueByIndex: function (idx) {
+ return this.items[idx].attr("value");
+ },
+
+ getIndexByValue: function (value) {
+ return BI.findIndex(this.items, function (i, item) {
+ return item.attr("value") === value;
+ });
+ },
+
+ getValue: function () {
+ var res;
+ BI.any(this.items, function (i, item) {
+ if (item.element.hasClass("active")) {
+ res = item.getValue();
+ return true;
+ }
+ });
+ return res;
+ }
+});
+BI.PathRegion.EVENT_CHANGE = "PathRegion.EVENT_CHANGE";
+BI.shortcut("bi.path_region", BI.PathRegion);/**
+ * 预览表列
+ *
+ * Created by GUY on 2015/12/25.
+ * @class BI.PreviewTableCell
+ * @extends BI.Widget
+ */
+BI.PreviewTableCell = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-preview-table-cell",
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.PreviewTableCell.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: "left",
+ whiteSpace: "normal",
+ height: this.options.height,
+ text: this.options.text,
+ value: this.options.value
+ })
+ }
+});
+BI.shortcut('bi.preview_table_cell', BI.PreviewTableCell);/**
+ * 预览表
+ *
+ * Created by GUY on 2015/12/25.
+ * @class BI.PreviewTableHeaderCell
+ * @extends BI.Widget
+ */
+BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-preview-table-header-cell",
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: "left",
+ whiteSpace: "normal",
+ height: this.options.height,
+ text: this.options.text,
+ value: this.options.value
+ })
+ }
+});
+BI.shortcut('bi.preview_table_header_cell', BI.PreviewTableHeaderCell);/**
+ * 预览表
+ *
+ * Created by GUY on 2015/12/25.
+ * @class BI.PreviewTable
+ * @extends BI.Widget
+ */
+BI.PreviewTable = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-preview-table",
+ isNeedFreeze: false,
+ freezeCols: [],
+ rowSize: null,
+ columnSize: [],
+ headerRowSize: 30,
+ header: [],
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.PreviewTable.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.table = BI.createWidget({
+ type: "bi.table_view",
+ element: this,
+ isNeedResize: false,
+
+ isResizeAdapt: false,
+
+ isNeedFreeze: o.isNeedFreeze,
+ freezeCols: o.freezeCols,
+
+ rowSize: o.rowSize,
+ columnSize: o.columnSize,
+ headerRowSize: o.headerRowSize,
+
+ header: BI.map(o.header, function (i, items) {
+ return BI.map(items, function (j, item) {
+ return BI.extend({
+ type: "bi.preview_table_header_cell"
+ }, item);
+ });
+ }),
+ items: BI.map(o.items, function (i, items) {
+ return BI.map(items, function (j, item) {
+ return BI.extend({
+ type: "bi.preview_table_cell"
+ }, item);
+ });
+ })
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
+ self._adjustColumns();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
+ self._adjustColumns();
+ });
+ },
+
+ //是否有自适应调节的列,即列宽为""
+ _hasAdaptCol: function (columnSize) {
+ return BI.any(columnSize, function (i, size) {
+ return size === "";
+ })
+ },
+
+ _isPercentage: function (columnSize) {
+ return columnSize[0] <= 1;
+ },
+
+ _adjustColumns: function () {
+ var self = this, o = this.options;
+ if (o.isNeedFreeze === true) {
+ //如果存在百分比的情况
+ if (this._isPercentage(o.columnSize)) {
+ if (this._hasAdaptCol(o.columnSize)) {
+ var findCols = [], remain = 0;
+ BI.each(o.columnSize, function (i, size) {
+ if (size === "") {
+ findCols.push(i);
+ } else {
+ remain += size;
+ }
+ });
+ remain = 1 - remain;
+ var average = remain / findCols.length;
+ BI.each(findCols, function (i, col) {
+ o.columnSize[col] = average;
+ });
+ }
+ var isRight = BI.first(o.freezeCols) !== 0;
+ var freezeSize = [], notFreezeSize = [];
+ BI.each(o.columnSize, function (i, size) {
+ if (o.freezeCols.contains(i)) {
+ freezeSize.push(size);
+ } else {
+ notFreezeSize.push(size);
+ }
+ });
+ var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize);
+ BI.each(freezeSize, function (i, size) {
+ freezeSize[i] = size / sumFreezeSize;
+ });
+ BI.each(notFreezeSize, function (i, size) {
+ notFreezeSize[i] = size / sumNotFreezeSize;
+ });
+ this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]);
+ this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize)));
+ }
+ } else {
+ //如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100%
+ if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) {
+ this.table.setRegionColumnSize(["100%"]);
+ }
+ }
+ },
+
+ setColumnSize: function (columnSize) {
+ return this.table.setColumnSize(columnSize);
+ },
+
+ getColumnSize: function () {
+ return this.table.getColumnSize();
+ },
+
+ getCalculateColumnSize: function () {
+ return this.table.getCalculateColumnSize();
+ },
+
+ setHeaderColumnSize: function (columnSize) {
+ return this.table.setHeaderColumnSize(columnSize);
+ },
+
+ setRegionColumnSize: function (columnSize) {
+ return this.table.setRegionColumnSize(columnSize);
+ },
+
+ getRegionColumnSize: function () {
+ return this.table.getRegionColumnSize();
+ },
+
+ getCalculateRegionColumnSize: function () {
+ return this.table.getCalculateRegionColumnSize();
+ },
+
+ getCalculateRegionRowSize: function () {
+ return this.table.getCalculateRegionRowSize();
+ },
+
+ getClientRegionColumnSize: function () {
+ return this.table.getClientRegionColumnSize();
+ },
+
+ getScrollRegionColumnSize: function () {
+ return this.table.getScrollRegionColumnSize()
+ },
+
+ getScrollRegionRowSize: function () {
+ return this.table.getScrollRegionRowSize()
+ },
+
+ hasVerticalScroll: function () {
+ return this.table.hasVerticalScroll();
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ return this.table.setVerticalScroll(scrollTop);
+ },
+
+ setLeftHorizontalScroll: function (scrollLeft) {
+ return this.table.setLeftHorizontalScroll(scrollLeft)
+ },
+
+ setRightHorizontalScroll: function (scrollLeft) {
+ return this.table.setRightHorizontalScroll(scrollLeft);
+ },
+
+ getVerticalScroll: function () {
+ return this.table.getVerticalScroll();
+ },
+
+ getLeftHorizontalScroll: function () {
+ return this.table.getLeftHorizontalScroll();
+ },
+
+ getRightHorizontalScroll: function () {
+ return this.table.getRightHorizontalScroll();
+ },
+
+ getColumns: function () {
+ return this.table.getColumns();
+ },
+
+ populate: function (items, header) {
+ this.table.populate(items, header);
+ }
+});
+BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE";
+BI.shortcut('bi.preview_table', BI.PreviewTable);/**
+ * 季度下拉框
+ *
+ * Created by GUY on 2015/8/28.
+ * @class BI.QuarterCombo
+ * @extends BI.Widget
+ */
+BI.QuarterCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-quarter-combo",
+ behaviors: {},
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.QuarterCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = "";
+ this.trigger = BI.createWidget({
+ type: "bi.quarter_trigger"
+ });
+
+ this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS, function () {
+ self.storeValue = this.getKey();
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_CHANGE, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_START, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () {
+ if (self.combo.isViewVisible()) {
+ return;
+ }
+ if (this.getKey() && this.getKey() !== self.storeValue) {
+ self.setValue(this.getKey());
+ } else if (!this.getKey()) {
+ self.setValue();
+ }
+ self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
+ });
+ this.popup = BI.createWidget({
+ type: "bi.quarter_popup",
+ behaviors: o.behaviors
+ });
+
+ this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ el: this.popup
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue() || "";
+ }
+});
+
+BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.quarter_combo', BI.QuarterCombo);/**
+ * 季度展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.QuarterPopup
+ * @extends BI.Trigger
+ */
+BI.QuarterPopup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-quarter-popup",
+ behaviors: {}
+ });
+ },
+
+ _init: function () {
+ BI.QuarterPopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var items = [{
+ text: Date._QN[01],
+ value: 1
+ }, {
+ text: Date._QN[2],
+ value: 2
+ }, {
+ text: Date._QN[3],
+ value: 3
+ }, {
+ text: Date._QN[4],
+ value: 4
+ }];
+ items = BI.map(items, function (j, item) {
+ return BI.extend(item, {
+ type: "bi.text_item",
+ cls: "bi-list-item-active",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ once: false,
+ forceSelected: true,
+ height: 25
+ });
+ });
+
+ this.quarter = BI.createWidget({
+ type: "bi.button_group",
+ element: this,
+ behaviors: o.behaviors,
+ items: BI.createItems(items, {}),
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ });
+
+ this.quarter.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
+ }
+ })
+ },
+
+ getValue: function () {
+ return this.quarter.getValue()[0];
+ },
+
+ setValue: function (v) {
+ this.quarter.setValue([v]);
+ }
+});
+BI.QuarterPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.quarter_popup", BI.QuarterPopup);/**
+ * 季度trigger
+ *
+ * Created by GUY on 2015/8/21.
+ * @class BI.QuarterTrigger
+ * @extends BI.Trigger
+ */
+BI.QuarterTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ triggerWidth: 30,
+ textWidth: 40,
+ errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text")
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-quarter-trigger bi-border",
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.QuarterTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 4);
+ },
+ quitChecker: function (v) {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ errorText: c.errorText
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_CHANGE);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setValue(value);
+ self.editor.setTitle(value);
+ }
+ self.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_STOP);
+ });
+
+ BI.createWidget({
+ element: this,
+ type: 'bi.htape',
+ items: [
+ {
+ el: this.editor
+ }, {
+ el: {
+ type: "bi.text_button",
+ baseCls: "bi-trigger-quarter-text",
+ text: BI.i18nText("BI-Multi_Date_Quarter"),
+ width: c.textWidth
+ },
+ width: c.textWidth
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: c.triggerWidth
+ },
+ width: c.triggerWidth
+ }
+ ]
+ });
+ },
+
+ setValue: function (v) {
+ this.editor.setState(v);
+ this.editor.setValue(v);
+ this.editor.setTitle(v);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ }
+});
+BI.QuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.QuarterTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.QuarterTrigger.EVENT_START = "EVENT_START";
+BI.QuarterTrigger.EVENT_STOP = "EVENT_STOP";
+BI.QuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.shortcut("bi.quarter_trigger", BI.QuarterTrigger);/**
+ * 关联视图字段Item
+ *
+ * Created by GUY on 2015/12/23.
+ * @class BI.RelationViewItem
+ * @extends BI.Widget
+ */
+BI.RelationViewItem = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-relation-view-item bi-list-item-active",
+ height: 25,
+ hoverIn: BI.emptyFn,
+ hoverOut: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.RelationViewItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.element.hover(o.hoverIn, o.hoverOut);
+ var items = [];
+ if (o.isPrimary) {
+ items.push({
+ type: "bi.icon",
+ width: 16,
+ height: 16,
+ title: BI.i18nText("BI-Primary_Key")
+ });
+ }
+ items.push({
+ type: "bi.label",
+ text: o.text,
+ value: o.value,
+ height: o.height,
+ textAlign: "left",
+ width: o.isPrimary ? 70 : 90
+ });
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ element: this,
+ items: items,
+ cls: "primary-key-font",
+ lgap: 5
+ });
+ },
+
+ enableHover: function (opt) {
+ BI.RelationViewRegion.superclass.enableHover.apply(this, [{
+ container: "body"
+ }]);
+ },
+
+ setSelected: function (b) {
+ this.element[b ? "addClass" : "removeClass"]("active");
+ }
+});
+BI.shortcut('bi.relation_view_item', BI.RelationViewItem);/**
+ * 关联视图
+ *
+ * Created by GUY on 2015/12/22.
+ * @class BI.RelationView
+ * @extends BI.Widget
+ */
+BI.RelationView = BI.inherit(BI.Widget, {
+
+ _const: {
+ lineColor: "#c4c6c6",
+ selectLineColor: "#009de3"
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-relation-view",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.RelationView.superclass._init.apply(this, arguments);
+ this.populate(this.options.items);
+ },
+
+ _calculateWidths: function () {
+ var widths = [];
+ BI.each(this.views, function (i, items) {
+ BI.each(items, function (j, obj) {
+ if (!widths[j]) {
+ widths[j] = BI.MIN;
+ }
+ widths[j] = Math.max(widths[j], obj.getWidth());
+ })
+ });
+ return widths;
+ },
+
+ _calculateHeights: function () {
+ var heights = BI.makeArray(BI.size(this.views), BI.MIN);
+ BI.each(this.views, function (i, items) {
+ BI.each(items, function (j, obj) {
+ heights[i] = Math.max(heights[i], obj.getHeight());
+ })
+ });
+ return heights;
+ },
+
+ _hoverIn: function (target) {
+ var self = this, c = this._const;
+ BI.each(this.relations, function (start, rs) {
+ BI.each(rs, function (end, relation) {
+ if (relation[0].primary.value === target || relation[0].foreign.value === target) {
+ self.lines[start][end].attr("stroke", c.selectLineColor).toFront();
+ self.storeViews[start].setValue(relation[0].primary.value);
+ self.storeViews[end].setValue(relation[0].foreign.value);
+ }
+ });
+ });
+ },
+
+ _hoverOut: function (target) {
+ var self = this, c = this._const;
+ BI.each(this.relations, function (start, rs) {
+ BI.each(rs, function (end, relation) {
+ if (relation[0].primary.value === target || relation[0].foreign.value === target) {
+ self.lines[start][end].attr("stroke", c.lineColor);
+ self.storeViews[start].setValue([]);
+ self.storeViews[end].setValue([]);
+ }
+ });
+ });
+ },
+
+ previewRelationTables: function(relationTables, show) {
+ if (!show) {
+ BI.each(this.storeViews, function (i, view) {
+ view.toggleRegion(true);
+ view.setPreviewSelected(false);
+ });
+ BI.each(this.lines, function (i, lines) {
+ BI.each(lines, function (j, line) {
+ line.show();
+ });
+ });
+ return;
+ }
+ BI.each(this.storeViews, function (id, view) {
+ if (!relationTables.contains(id)) {
+ view.toggleRegion(false);
+ } else {
+ view.setPreviewSelected(true);
+ }
+ });
+ BI.each(this.lines, function (id, lines) {
+ BI.each(lines, function (cId, line) {
+ if (!relationTables.contains(id) || !relationTables.contains(cId)) {
+ line.hide();
+ }
+ });
+ });
+ },
+
+ populate: function (items) {
+ var self = this, o = this.options, c = this._const;
+ o.items = items || [];
+ this.empty();
+ this.svg = BI.createWidget({
+ type: "bi.svg"
+ });
+
+ //算出所有的区域和关联
+ var regions = this.regions = {}, relations = this.relations = {};
+ BI.each(items, function (i, item) {
+ var pr = item.primary.region, fr = item.foreign && item.foreign.region;
+ if (pr && !relations[pr]) {
+ relations[pr] = {};
+ }
+ if (pr && fr && !relations[pr][fr]) {
+ relations[pr][fr] = [];
+ }
+ if (pr && !regions[pr]) {
+ regions[pr] = [];
+ }
+ if (fr && !regions[fr]) {
+ regions[fr] = [];
+ }
+ if (pr && !BI.deepContains(regions[pr], item.primary)) {
+ regions[pr].push(item.primary);
+ }
+ if (fr && !BI.deepContains(regions[fr], item.foreign)) {
+ regions[fr].push(item.foreign);
+ }
+ pr && fr && relations[pr][fr].push(item);
+ });
+ //求拓扑
+ var topology = [];
+ var rs = BI.clone(regions), store = {};
+ while (!BI.isEmpty(rs)) {
+ var clone = BI.clone(rs);
+ BI.each(o.items, function (i, item) {
+ if (!store[item.primary.region]) {
+ delete clone[item.foreign && item.foreign.region];
+ }
+ });
+ topology.push(BI.keys(clone));
+ BI.extend(store, clone);
+ BI.each(clone, function (k, v) {
+ delete rs[k];
+ });
+ }
+ //构建视图
+ var views = this.views = {}, storeViews = this.storeViews = {}, indexes = this.indexes = {};
+ var verticals = [];
+ BI.each(topology, function (i, items) {
+ if (!views[i]) {
+ views[i] = {};
+ }
+ var horizontal = [];
+ BI.each(items, function (j, region) {
+ var items = regions[region];
+ views[i][j] = storeViews[region] = BI.createWidget({
+ type: "bi.relation_view_region_container",
+ value: region,
+ header: items[0].regionTitle,
+ text: items.length > 0 ? items[0].regionText : "",
+ handler: items.length > 0 ? items[0].regionHandler : BI.emptyFn,
+ items: items,
+ belongPackage: items.length > 0 ? items[0].belongPackage : true
+ });
+ if (BI.isNotNull(items[0]) && BI.isNotNull(items[0].keyword)) {
+ views[i][j].doRedMark(items[0].keyword);
+ }
+ views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN, function (v) {
+ self._hoverIn(v);
+ });
+ views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, function (v) {
+ self._hoverOut(v);
+ });
+ views[i][j].on(BI.RelationViewRegionContainer.EVENT_PREVIEW, function (v) {
+ self.fireEvent(BI.RelationView.EVENT_PREVIEW, region, v);
+ });
+ indexes[region] = {i: i, j: j};
+ horizontal.push(views[i][j]);
+ });
+ verticals.push({
+ type: "bi.horizontal",
+ items: horizontal
+ })
+ });
+
+ //求每一行的高度
+ var heights = this._calculateHeights();
+
+ //求每一列的宽度
+ var widths = this._calculateWidths();
+
+ //求相对宽度和高度
+ var offsetWidths = [0], offsetHeights = [0];
+ BI.each(heights, function (i, h) {
+ if (i === 0) {
+ return;
+ }
+ offsetHeights[i] = offsetHeights[i - 1] + heights[i - 1];
+ });
+ BI.each(widths, function (i, w) {
+ if (i === 0) {
+ return;
+ }
+ offsetWidths[i] = offsetWidths[i - 1] + widths[i - 1];
+ });
+
+ //画线
+ var lines = this.lines = {};//缓存所有的线
+ BI.each(relations, function (start, rs) {
+ BI.each(rs, function (end, relation) {
+ var startIndex = indexes[start], endIndex = indexes[end];
+ var top = 0, right = 1, bottom = 2, left = 3;
+ var startDirection = bottom, endDirection = top;
+ // if (startIndex.j > endIndex.j) {
+ // startDirection = left;
+ // endDirection = right;
+ // } else if (startIndex.j < endIndex.j) {
+ // startDirection = right;
+ // endDirection = left;
+ // } else if (startIndex.i < endIndex.i) {
+ // startDirection = bottom;
+ // endDirection = top;
+ // } else if (startIndex.i > endIndex.i) {
+ // startDirection = top;
+ // endDirection = bottom;
+ // }
+ var draw = function (i, j, direction, isForeign) {
+ var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2;
+ var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2;
+ var path = "", position;
+ switch (direction) {
+ case top:
+ position = isForeign ? views[i][j].getTopRightPosition() : views[i][j].getTopLeftPosition();
+ x += position.x;
+ y += position.y;
+ path = "M" + x + "," + y + "L" + x + "," + (y - 10);
+ y -= 10;
+ break;
+ case right:
+ position = views[i][j].getRightPosition();
+ x += position.x;
+ y += position.y;
+ path = "M" + x + "," + y + "L" + (x + 10) + "," + y;
+ x += 10;
+ break;
+ case bottom:
+ position = views[i][j].getBottomPosition();
+ x += position.x;
+ y += position.y;
+ path = "M" + x + "," + y + "L" + x + "," + (y + 10);
+ y += 10;
+ break;
+ case left:
+ position = views[i][j].getLeftPosition();
+ x += position.x;
+ y += position.y;
+ path = "M" + x + "," + y + "L" + (x - 10) + "," + y;
+ x -= 10;
+ break;
+ }
+ return {x: x, y: y, path: path};
+ };
+ var path = "";
+ var si = draw(startIndex.i, startIndex.j, startDirection);
+ var ei = draw(endIndex.i, endIndex.j, endDirection, true);
+ path += si.path + ei.path;
+ if (!lines[start]) {
+ lines[start] = {};
+ }
+ path += "M" + si.x + "," + si.y + "L" + ei.x + "," + ei.y;
+ var line = lines[start][end] = self.svg.path(path)
+ .attr({"stroke": c.lineColor, "stroke-width": "2"})
+ .hover(function () {
+ line.attr("stroke", c.selectLineColor).toFront();
+ storeViews[start].setValue(relation[0].primary.value);
+ storeViews[end].setValue(relation[0].foreign.value);
+ }, function () {
+ line.attr("stroke", c.lineColor);
+ storeViews[start].setValue([]);
+ storeViews[end].setValue([]);
+ });
+ });
+ });
+ var container = BI.createWidget();
+ BI.createWidget({
+ type: "bi.vertical",
+ element: container,
+ items: verticals
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: container,
+ items: [{
+ el: this.svg,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: true,
+ element: this,
+ items: [container]
+ });
+ }
+});
+BI.RelationView.EVENT_CHANGE = "RelationView.EVENT_CHANGE";
+BI.RelationView.EVENT_PREVIEW = "EVENT_PREVIEW";
+BI.shortcut('bi.relation_view', BI.RelationView);/**
+ * Created by Young's on 2017/3/10.
+ */
+BI.RelationViewRegionContainer = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-relation-view-region-container",
+ width: 150
+ });
+ },
+
+ _init: function () {
+ BI.RelationViewRegionContainer.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.region = BI.createWidget({
+ type: "bi.relation_view_region",
+ value: o.value,
+ header: o.header,
+ text: o.text,
+ handler: o.handler,
+ items: o.items,
+ belongPackage: o.belongPackage
+ });
+ this.region.on(BI.RelationViewRegion.EVENT_PREVIEW, function (v) {
+ self.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW, v);
+ });
+ this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN, function (v) {
+ self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN, v);
+ });
+ this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT, function (v) {
+ self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, v);
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.region],
+ width: this.region.getWidth(),
+ height: this.region.getHeight()
+ });
+ },
+
+ doRedMark: function () {
+ this.region.doRedMark.apply(this.region, arguments);
+ },
+
+ unRedMark: function () {
+ this.region.unRedMark.apply(this.region, arguments);
+ },
+
+ getWidth: function () {
+ return this.region.getWidth();
+ },
+
+ getHeight: function () {
+ return this.region.getHeight();
+ },
+
+ //获取上方开始划线的位置
+ getTopLeftPosition: function () {
+ return this.region.getTopLeftPosition();
+ },
+
+ getTopRightPosition: function () {
+ return this.region.getTopRightPosition();
+ },
+
+ getBottomPosition: function () {
+ return this.region.getBottomPosition();
+ },
+
+ getLeftPosition: function () {
+ return this.region.getLeftPosition();
+ },
+
+ getRightPosition: function () {
+ return this.region.getRightPosition();
+ },
+
+ setValue: function (v) {
+ this.region.setValue(v);
+ },
+
+ toggleRegion: function (v) {
+ v === true ? this.region.element.fadeIn() : this.region.element.fadeOut();
+ },
+
+ setPreviewSelected: function(v) {
+ this.region.setPreviewSelected(v);
+ }
+});
+BI.RelationViewRegionContainer.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN";
+BI.RelationViewRegionContainer.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT";
+BI.RelationViewRegionContainer.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW";
+BI.shortcut("bi.relation_view_region_container", BI.RelationViewRegionContainer);/**
+ * 关联视图
+ *
+ * Created by GUY on 2015/12/23.
+ * @class BI.RelationViewRegion
+ * @extends BI.BasicButton
+ */
+BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-relation-view-region cursor-pointer",
+ width: 150,
+ text: "",
+ value: "",
+ header: "",
+ items: [],
+ belongPackage: true
+ });
+ },
+
+ _init: function () {
+ BI.RelationViewRegion.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.preview = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "relation-table-preview-font",
+ width: 25,
+ height: 25,
+ stopPropagation: true
+ });
+ this.preview.on(BI.IconButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW, this.isSelected());
+ });
+
+ this.title = BI.createWidget({
+ type: "bi.label",
+ height: 25,
+ width: 70,
+ text: o.text,
+ value: o.value,
+ textAlign: "left"
+ });
+ //title放body上
+ if (BI.isKey(o.header)) {
+ this.title.setTitle(o.header, {
+ container: "body"
+ })
+ }
+
+ this.button_group = BI.createWidget({
+ type: "bi.button_group",
+ items: this._createItems(o.items),
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [{
+ type: "bi.vertical",
+ cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"),
+ items: [{
+ type: "bi.vertical_adapt",
+ cls: "relation-view-region-title bi-border-bottom",
+ items: [this.preview, this.title]
+ }, this.button_group]
+ }],
+ hgap: 25,
+ vgap: 20
+ })
+ },
+
+ _createItems: function (items) {
+ var self = this;
+ return BI.map(items, function (i, item) {
+ return BI.extend(item, {
+ type: "bi.relation_view_item",
+ hoverIn: function () {
+ self.setValue(item.value);
+ self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value);
+ },
+ hoverOut: function () {
+ self.setValue([]);
+ self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT, item.value);
+ }
+ })
+ });
+ },
+
+ doRedMark: function () {
+ this.title.doRedMark.apply(this.title, arguments);
+ },
+
+ unRedMark: function () {
+ this.title.unRedMark.apply(this.title, arguments);
+ },
+
+ getWidth: function () {
+ return this.options.width;
+ },
+
+ getHeight: function () {
+ return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3;
+ },
+
+ //获取上方开始划线的位置
+ getTopLeftPosition: function () {
+ return {
+ x: 25 + 10,
+ y: 20
+ }
+ },
+
+ getTopRightPosition: function () {
+ return {
+ x: this.getWidth() - 25 - 10,
+ y: 20
+ }
+ },
+
+ getBottomPosition: function () {
+ return {
+ x: 25 + 10,
+ y: this.getHeight() - 20
+ }
+ },
+
+ getLeftPosition: function () {
+ return {
+ x: 25,
+ y: 20 + 10
+ }
+ },
+
+ getRightPosition: function () {
+ return {
+ x: this.getWidth() - 25,
+ y: 20 + 10
+ }
+ },
+
+ setValue: function (v) {
+ this.button_group.setValue(v);
+ },
+
+ setPreviewSelected: function(v) {
+ this.preview.setSelected(v);
+ }
+});
+BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN";
+BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT";
+BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW";
+BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/**
+ * 自适应宽度的表格
+ *
+ * Created by GUY on 2016/2/3.
+ * @class BI.ResponisveTable
+ * @extends BI.Widget
+ */
+BI.ResponisveTable = BI.inherit(BI.Widget, {
+
+ _const: {
+ perColumnSize: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-responsive-table",
+ isNeedFreeze: false,//是否需要冻结单元格
+ freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
+
+ isNeedMerge: false,//是否需要合并单元格
+ mergeCols: [], //合并的单元格列号
+ mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
+ return BI.isEqual(row1, row2);
+ },
+
+ columnSize: [],
+ headerRowSize: 25,
+ footerRowSize: 25,
+ rowSize: 25,
+
+ regionColumnSize: false,
+
+ header: [],
+ footer: false,
+ items: [], //二维数组
+
+ //交叉表头
+ crossHeader: [],
+ crossItems: []
+ });
+ },
+
+ _init: function () {
+ BI.ResponisveTable.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.table = BI.createWidget({
+ type: "bi.table_view",
+ element: this,
+
+ isNeedFreeze: o.isNeedFreeze,
+ freezeCols: o.freezeCols,
+
+ isNeedMerge: o.isNeedMerge,
+ mergeCols: o.mergeCols,
+ mergeRule: o.mergeRule,
+
+ columnSize: o.columnSize,
+ headerRowSize: o.headerRowSize,
+ footerRowSize: o.footerRowSize,
+ rowSize: o.rowSize,
+
+ regionColumnSize: o.regionColumnSize,
+
+ header: o.header,
+ footer: o.footer,
+ items: o.items,
+ //交叉表头
+ crossHeader: o.crossHeader,
+ crossItems: o.crossItems
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
+ self._initRegionSize();
+ self.table.resize();
+ self._resizeHeader();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
+ self._resizeRegion();
+ self._resizeHeader();
+ self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
+ self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () {
+ self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () {
+ //important:在冻结并自适应列宽的情况下要随时变更表头宽度
+ if (o.isNeedResize === true && self._isAdaptiveColumn()) {
+ self._resizeHeader();
+ }
+ self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
+ self._resizeHeader();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
+ });
+
+ this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () {
+ self._resizeBody();
+ self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () {
+ self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
+ self._resizeRegion();
+ self._resizeHeader();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
+ });
+ },
+
+ _initRegionSize: function () {
+ var o = this.options;
+ if (o.isNeedFreeze === true) {
+ var regionColumnSize = this.table.getRegionColumnSize();
+ var maxWidth = this.table.element.width();
+ if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) {
+ var freezeCols = o.freezeCols;
+ if (freezeCols.length === 0) {
+ this.table.setRegionColumnSize([0, "fill"]);
+ } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) {
+ var size = maxWidth / 3;
+ if (freezeCols.length > o.columnSize.length / 2) {
+ size = maxWidth * 2 / 3;
+ }
+ this.table.setRegionColumnSize([size, "fill"]);
+ } else {
+ this.table.setRegionColumnSize(["fill", 0]);
+ }
+ }
+ }
+ },
+
+ _getBlockSize: function () {
+ var o = this.options;
+ var columnSize = this.table.getCalculateColumnSize();
+ if (o.isNeedFreeze === true) {
+ var columnSizeLeft = [], columnSizeRight = [];
+ BI.each(columnSize, function (i, size) {
+ if (o.freezeCols.contains(i)) {
+ columnSizeLeft.push(size);
+ } else {
+ columnSizeRight.push(size);
+ }
+ });
+ //因为有边框,所以加上数组长度的参数调整
+ var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length,
+ sumRight = BI.sum(columnSizeRight) + columnSizeRight.length;
+ return {
+ sumLeft: sumLeft,
+ sumRight: sumRight,
+ left: columnSizeLeft,
+ right: columnSizeRight
+ }
+ }
+ return {
+ size: columnSize,
+ sum: BI.sum(columnSize) + columnSize.length
+ };
+ },
+
+ _isAdaptiveColumn: function (columnSize) {
+ return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05);
+ },
+
+ _resizeHeader: function () {
+ var self = this, o = this.options;
+ if (o.isNeedFreeze === true) {
+ //若是当前处于自适应调节阶段
+ if (this._isAdaptiveColumn()) {
+ var columnSize = this.table.getCalculateColumnSize();
+ this.table.setHeaderColumnSize(columnSize);
+ } else {
+ var regionColumnSize = this.table.getClientRegionColumnSize();
+ var block = this._getBlockSize();
+ var sumLeft = block.sumLeft, sumRight = block.sumRight;
+ var columnSizeLeft = block.left, columnSizeRight = block.right;
+ columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft;
+ columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight;
+
+ var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight);
+ newLeft[newLeft.length - 1] = "";
+ newRight[newRight.length - 1] = "";
+ this.table.setColumnSize(newLeft.concat(newRight));
+
+ block = self._getBlockSize();
+ if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) {
+ columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1]
+ }
+ if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) {
+ columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1]
+ }
+
+ self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight));
+ }
+ } else {
+ if (!this._isAdaptiveColumn()) {
+ var regionColumnSize = this.table.getClientRegionColumnSize();
+ var block = this._getBlockSize();
+ var sum = block.sum;
+ var size = block.size;
+
+ size[size.length - 1] += regionColumnSize[0] - sum;
+
+ var newSize = BI.clone(size);
+ newSize[newSize.length - 1] = "";
+ this.table.setColumnSize(newSize);
+ block = this._getBlockSize();
+
+ if (size[size.length - 1] < block.size[block.size.length - 1]) {
+ size[size.length - 1] = block.size[block.size.length - 1]
+ }
+ this.table.setColumnSize(size);
+ }
+ }
+ },
+
+ _resizeBody: function () {
+ if (this._isAdaptiveColumn()) {
+ var columnSize = this.table.getCalculateColumnSize();
+ this.setColumnSize(columnSize);
+ }
+ },
+
+ _adjustRegion: function () {
+ var o = this.options;
+ var regionColumnSize = this.table.getCalculateRegionColumnSize();
+ if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
+ var block = this._getBlockSize();
+ var sumLeft = block.sumLeft, sumRight = block.sumRight;
+ if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) {
+ this.table.setRegionColumnSize([sumLeft, "fill"]);
+ }
+ this._resizeRegion();
+ }
+ },
+
+ _resizeRegion: function () {
+ var o = this.options;
+ var regionColumnSize = this.table.getCalculateRegionColumnSize();
+ if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
+ var maxWidth = this.table.element.width();
+ if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) {
+ var freezeCols = o.freezeCols;
+ var size = maxWidth / 3;
+ if (freezeCols.length > o.columnSize.length / 2) {
+ size = maxWidth * 2 / 3;
+ }
+ this.table.setRegionColumnSize([size, "fill"]);
+ }
+ }
+ },
+
+
+ resize: function () {
+ this.table.resize();
+ this._resizeRegion();
+ this._resizeHeader();
+ },
+
+ setColumnSize: function (columnSize) {
+ this.table.setColumnSize(columnSize);
+ this._adjustRegion();
+ this._resizeHeader();
+ },
+
+ getColumnSize: function () {
+ return this.table.getColumnSize();
+ },
+
+ getCalculateColumnSize: function () {
+ return this.table.getCalculateColumnSize();
+ },
+
+ setHeaderColumnSize: function (columnSize) {
+ this.table.setHeaderColumnSize(columnSize);
+ this._adjustRegion();
+ this._resizeHeader();
+ },
+
+ setRegionColumnSize: function (columnSize) {
+ this.table.setRegionColumnSize(columnSize);
+ this._resizeHeader();
+ },
+
+ getRegionColumnSize: function () {
+ return this.table.getRegionColumnSize();
+ },
+
+ getCalculateRegionColumnSize: function () {
+ return this.table.getCalculateRegionColumnSize();
+ },
+
+ getCalculateRegionRowSize: function () {
+ return this.table.getCalculateRegionRowSize();
+ },
+
+ getClientRegionColumnSize: function () {
+ return this.table.getClientRegionColumnSize();
+ },
+
+ getScrollRegionColumnSize: function () {
+ return this.table.getScrollRegionColumnSize();
+ },
+
+ getScrollRegionRowSize: function () {
+ return this.table.getScrollRegionRowSize();
+ },
+
+ hasVerticalScroll: function () {
+ return this.table.hasVerticalScroll();
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ this.table.setVerticalScroll(scrollTop);
+ },
+
+ setLeftHorizontalScroll: function (scrollLeft) {
+ this.table.setLeftHorizontalScroll(scrollLeft);
+ },
+
+ setRightHorizontalScroll: function (scrollLeft) {
+ this.table.setRightHorizontalScroll(scrollLeft);
+ },
+
+ getVerticalScroll: function () {
+ return this.table.getVerticalScroll();
+ },
+
+ getLeftHorizontalScroll: function () {
+ return this.table.getLeftHorizontalScroll();
+ },
+
+ getRightHorizontalScroll: function () {
+ return this.table.getRightHorizontalScroll();
+ },
+
+ getColumns: function () {
+ return this.table.getColumns();
+ },
+
+ attr: function () {
+ BI.ResponisveTable.superclass.attr.apply(this, arguments);
+ this.table.attr.apply(this.table, arguments);
+ },
+
+ populate: function (items) {
+ var self = this, o = this.options;
+ this.table.populate.apply(this.table, arguments);
+ if (o.isNeedFreeze === true) {
+ BI.nextTick(function () {
+ self._initRegionSize();
+ self.table.resize();
+ self._resizeHeader();
+ });
+ }
+ }
+});
+BI.shortcut('bi.responsive_table', BI.ResponisveTable);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.SelectTreeFirstPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-select-tree-first-plus-group-node bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.first_tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 25,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ },
+
+ setOpened: function (v) {
+ BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.select_tree_first_plus_group_node", BI.SelectTreeFirstPlusGroupNode);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.SelectTreeLastPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-select-tree-last-plus-group-node bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.last_tree_node_checkbox",
+ stopPropagation: true
+ })
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 25,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ },
+
+ setOpened: function (v) {
+ BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.select_tree_last_plus_group_node", BI.SelectTreeLastPlusGroupNode);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.SelectTreeMidPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-select-tree-mid-plus-group-node bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 25
+ })
+ },
+ _init: function () {
+ BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.mid_tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 25,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ },
+
+ setOpened: function (v) {
+ BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.select_tree_mid_plus_group_node", BI.SelectTreeMidPlusGroupNode);/**
+ * @class BI.SelectTreeCombo
+ * @extends BI.Widget
+ */
+BI.SelectTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-tree-combo",
+ height: 30,
+ text: "",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SelectTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.select_tree_popup",
+ items: o.items
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ }
+});
+
+
+BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo);/**
+ * @class BI.SelectTreeExpander
+ * @extends BI.Widget
+ */
+BI.SelectTreeExpander = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-tree-expander",
+ trigger: "click",
+ toggle: true,
+ direction: "bottom",
+ isDefaultInit: true,
+ el: {},
+ popup: {}
+ });
+ },
+
+ _init: function () {
+ BI.SelectTreeExpander.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget(BI.extend({stopPropagation: true}, o.el));
+ this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.expander.setValue([]);
+ }
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.expander = BI.createWidget({
+ type: "bi.expander",
+ element: this,
+ trigger: o.trigger,
+ toggle: o.toggle,
+ direction: o.direction,
+ isDefaultInit: o.isDefaultInit,
+ el: this.trigger,
+ popup: o.popup
+ });
+ this.expander.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self.trigger.setSelected(false);
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ },
+
+ setValue: function (v) {
+ if (BI.contains(v, this.trigger.getValue())) {
+ this.trigger.setSelected(true);
+ this.expander.setValue([]);
+ } else {
+ this.trigger.setSelected(false);
+ this.expander.setValue(v);
+ }
+ },
+
+ getValue: function () {
+ if (this.trigger.isSelected()) {
+ return [this.trigger.getValue()];
+ }
+ return this.expander.getValue();
+ },
+
+ populate: function (items) {
+ this.expander.populate(items);
+ }
+});
+
+BI.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);/**
+ * @class BI.SelectTreePopup
+ * @extends BI.Pane
+ */
+
+BI.SelectTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-tree-popup",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ items: []
+ });
+ },
+
+ _formatItems: function (nodes, layer) {
+ var self = this;
+ BI.each(nodes, function (i, node) {
+ var extend = {layer: layer};
+ node.id = node.id || BI.UUID();
+ if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
+ switch (i) {
+ case 0 :
+ extend.type = "bi.select_tree_first_plus_group_node";
+ break;
+ case nodes.length - 1 :
+ extend.type = "bi.select_tree_last_plus_group_node";
+ break;
+ default :
+ extend.type = "bi.select_tree_mid_plus_group_node";
+ break;
+ }
+ BI.defaults(node, extend);
+ self._formatItems(node.children);
+ } else {
+ switch (i) {
+ case nodes.length - 1:
+ extend.type = "bi.last_tree_leaf_item";
+ break;
+ default :
+ extend.type = "bi.mid_tree_leaf_item";
+ }
+ BI.defaults(node, extend);
+ }
+ });
+ return nodes;
+ },
+
+ _init: function () {
+ BI.SelectTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: 'bi.level_tree',
+ expander: {
+ type: "bi.select_tree_expander",
+ isDefaultInit: true
+ },
+ items: this._formatItems(BI.Tree.transformToTreeFormat(o.items)),
+ chooseType: BI.Selection.Single
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.LevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SelectTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.SelectTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.select_tree_popup", BI.SelectTreePopup);/**
+ *
+ * Created by GUY on 2016/8/10.
+ * @class BI.SequenceTableDynamicNumber
+ * @extends BI.SequenceTableTreeNumber
+ */
+BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-sequence-table-dynamic-number"
+ });
+ },
+
+ _init: function () {
+ BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments);
+ },
+
+ _formatNumber: function (nodes) {
+ var self = this, o = this.options;
+ var result = [];
+ var count = this._getStart(nodes);
+
+ function getLeafCount(node) {
+ var cnt = 0;
+ if (BI.isNotEmptyArray(node.children)) {
+ BI.each(node.children, function (index, child) {
+ cnt += getLeafCount(child);
+ });
+ if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) {
+ cnt++;
+ }
+ } else {
+ cnt++;
+ }
+ return cnt;
+ }
+
+ var start = 0, top = 0;
+ BI.each(nodes, function (i, node) {
+ if (BI.isArray(node.children)) {
+ BI.each(node.children, function (index, child) {
+ var cnt = getLeafCount(child);
+ result.push({
+ text: count++,
+ start: start,
+ top: top,
+ cnt: cnt,
+ index: index,
+ height: cnt * o.rowSize
+ });
+ start += cnt;
+ top += cnt * o.rowSize;
+ });
+ if (BI.isNotEmptyArray(node.values)) {
+ result.push({
+ text: BI.i18nText("BI-Summary_Values"),
+ start: start++,
+ top: top,
+ cnt: 1,
+ isSummary: true,
+ height: o.rowSize
+ });
+ top += o.rowSize;
+ }
+ }
+ });
+ return result;
+ }
+});
+BI.shortcut('bi.sequence_table_dynamic_number', BI.SequenceTableDynamicNumber);/**
+ *
+ * Created by GUY on 2016/5/26.
+ * @class BI.SequenceTableListNumber
+ * @extends BI.Widget
+ */
+BI.SequenceTableListNumber = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-sequence-table-list-number",
+ isNeedFreeze: false,
+ scrollTop: 0,
+ startSequence: 1,//开始的序号
+ headerRowSize: 25,
+ rowSize: 25,
+
+ sequenceHeaderCreator: null,
+
+ header: [],
+ items: [], //二维数组
+
+ //交叉表头
+ crossHeader: [],
+ crossItems: [],
+
+ pageSize: 20
+ });
+ },
+
+ _init: function () {
+ BI.SequenceTableListNumber.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.start = o.startSequence;
+ this.renderedCells = [];
+ this.renderedKeys = [];
+
+ this.container = BI.createWidget({
+ type: "bi.absolute",
+ width: 60,
+ scrollable: false
+ });
+
+ this.scrollContainer = BI.createWidget({
+ type: "bi.vertical",
+ scrollable: false,
+ scrolly: false,
+ items: [this.container]
+ });
+
+ this.headerContainer = BI.createWidget({
+ type: "bi.absolute",
+ cls: "bi-border",
+ width: 58,
+ scrollable: false
+ });
+
+ this.layout = BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.headerContainer,
+ height: o.headerRowSize * o.header.length - 2
+ }, {
+ el: {type: "bi.layout"},
+ height: 2
+ }, {
+ el: this.scrollContainer
+ }]
+ });
+ this._populate();
+ },
+
+ _layout: function () {
+ var self = this, o = this.options;
+ var headerHeight = o.headerRowSize * o.header.length - 2;
+ var items = this.layout.attr("items");
+ if (o.isNeedFreeze === false) {
+ items[0].height = 0;
+ items[1].height = 0;
+ } else if (o.isNeedFreeze === true) {
+ items[0].height = headerHeight;
+ items[1].height = 2;
+ }
+ this.layout.attr("items", items);
+ this.layout.resize();
+ this.container.setHeight(o.items.length * o.rowSize);
+ try {
+ this.scrollContainer.element.scrollTop(o.scrollTop);
+ } catch (e) {
+
+ }
+ },
+
+ _createHeader: function () {
+ var o = this.options;
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.headerContainer,
+ items: [{
+ el: o.sequenceHeaderCreator || {
+ type: "bi.table_style_cell",
+ cls: "sequence-table-title-cell",
+ styleGetter: o.headerCellStyleGetter,
+ text: BI.i18nText("BI-Number_Index")
+ },
+ left: 0,
+ top: 0,
+ right: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _calculateChildrenToRender: function () {
+ var self = this, o = this.options;
+ var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth());
+ var start = Math.floor(scrollTop / o.rowSize);
+ var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize);
+ var renderedCells = [], renderedKeys = [];
+ for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) {
+ var index = BI.deepIndexOf(this.renderedKeys, this.start + i);
+ var top = i * o.rowSize;
+ if (index > -1) {
+ if (o.rowSize !== this.renderedCells[index]._height) {
+ this.renderedCells[index]._height = o.rowSize;
+ this.renderedCells[index].el.setHeight(o.rowSize);
+ }
+ if (this.renderedCells[index].top !== top) {
+ this.renderedCells[index].top = top;
+ this.renderedCells[index].el.element.css("top", top + "px");
+ }
+ renderedCells.push(this.renderedCells[index]);
+ } else {
+ var child = BI.createWidget(BI.extend({
+ type: "bi.table_style_cell",
+ cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",
+ width: 60,
+ height: o.rowSize,
+ text: this.start + i,
+ styleGetter: function (index) {
+ return function () {
+ return o.sequenceCellStyleGetter(self.start + i - 1);
+ }
+ }(cnt)
+ }));
+ renderedCells.push({
+ el: child,
+ left: 0,
+ top: top,
+ _height: o.rowSize
+ });
+ }
+ renderedKeys.push(this.start + i);
+ }
+
+ //已存在的, 需要添加的和需要删除的
+ var existSet = {}, addSet = {}, deleteArray = [];
+ BI.each(renderedKeys, function (i, key) {
+ if (BI.deepContains(self.renderedKeys, key)) {
+ existSet[i] = key;
+ } else {
+ addSet[i] = key;
+ }
+ });
+ BI.each(this.renderedKeys, function (i, key) {
+ if (BI.deepContains(existSet, key)) {
+ return;
+ }
+ if (BI.deepContains(addSet, key)) {
+ return;
+ }
+ deleteArray.push(i);
+ });
+ BI.each(deleteArray, function (i, index) {
+ self.renderedCells[index].el.destroy();
+ });
+ var addedItems = [];
+ BI.each(addSet, function (index) {
+ addedItems.push(renderedCells[index])
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.container,
+ items: addedItems
+ });
+ this.renderedCells = renderedCells;
+ this.renderedKeys = renderedKeys;
+ },
+
+ _populate: function () {
+ this.headerContainer.empty();
+ this._createHeader();
+ this._layout();
+ this._calculateChildrenToRender();
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ if (this.options.scrollTop !== scrollTop) {
+ this.options.scrollTop = scrollTop;
+ try {
+ this.scrollContainer.element.scrollTop(scrollTop);
+ } catch (e) {
+
+ }
+ }
+ },
+
+ getVerticalScroll: function () {
+ return this.options.scrollTop;
+ },
+
+ setVPage: function (v) {
+ v = v < 1 ? 1 : v;
+ var o = this.options;
+ this.start = (v - 1) * o.pageSize + 1;
+ },
+
+ _restore: function () {
+ var o = this.options;
+ BI.each(this.renderedCells, function (i, cell) {
+ cell.el.destroy();
+ });
+ this.renderedCells = [];
+ this.renderedKeys = [];
+ },
+
+ restore: function () {
+ this._restore();
+ },
+
+ populate: function (items, header) {
+ var o = this.options;
+ if (items && items !== this.options.items) {
+ o.items = items;
+ this._restore();
+ }
+ if (header && header !== this.options.header) {
+ o.header = header;
+ }
+ this._populate();
+ }
+});
+BI.shortcut('bi.sequence_table_list_number', BI.SequenceTableListNumber);/**
+ * 带有序号的表格
+ *
+ * Created by GUY on 2016/5/26.
+ * @class BI.SequenceTable
+ * @extends BI.Widget
+ */
+BI.SequenceTable = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-sequence-table",
+ el: {
+ type: "bi.adaptive_table"
+ },
+
+ sequence: {},
+
+ isNeedResize: true,
+ isResizeAdapt: false,
+
+ isNeedFreeze: false,//是否需要冻结单元格
+ freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
+
+ isNeedMerge: false,//是否需要合并单元格
+ mergeCols: [], //合并的单元格列号
+ mergeRule: BI.emptyFn,
+
+ columnSize: [],
+ minColumnSize: [],
+ maxColumnSize: [],
+ headerRowSize: 25,
+ rowSize: 25,
+
+ regionColumnSize: [],
+
+ headerCellStyleGetter: BI.emptyFn,
+ summaryCellStyleGetter: BI.emptyFn,
+ sequenceCellStyleGetter: BI.emptyFn,
+
+ header: [],
+ items: [], //二维数组
+
+ //交叉表头
+ crossHeader: [],
+ crossItems: [],
+
+ showSequence: false,
+ startSequence: 1//开始的序号
+ });
+ },
+
+ _init: function () {
+ BI.SequenceTable.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.sequence = BI.createWidget(o.sequence, {
+ type: "bi.sequence_table_list_number",
+ invisible: o.showSequence === false,
+ startSequence: o.startSequence,
+ isNeedFreeze: o.isNeedFreeze,
+ header: o.header,
+ items: o.items,
+ crossHeader: o.crossHeader,
+ crossItems: o.crossItems,
+ headerRowSize: o.headerRowSize,
+ rowSize: o.rowSize,
+ width: 60,
+ height: o.height && o.height - BI.GridTableScrollbar.SIZE,
+
+ headerCellStyleGetter: o.headerCellStyleGetter,
+ summaryCellStyleGetter: o.summaryCellStyleGetter,
+ sequenceCellStyleGetter: o.sequenceCellStyleGetter
+ });
+ this.table = BI.createWidget(o.el, {
+ type: "bi.adaptive_table",
+ width: o.showSequence === true ? o.width - 60 : o.width,
+ height: o.height,
+ isNeedResize: o.isNeedResize,
+ isResizeAdapt: o.isResizeAdapt,
+
+ isNeedFreeze: o.isNeedFreeze,
+ freezeCols: o.freezeCols,
+
+ isNeedMerge: o.isNeedMerge,
+ mergeCols: o.mergeCols,
+ mergeRule: o.mergeRule,
+
+ columnSize: o.columnSize,
+ minColumnSize: o.minColumnSize,
+ maxColumnSize: o.maxColumnSize,
+ headerRowSize: o.headerRowSize,
+ rowSize: o.rowSize,
+
+ regionColumnSize: o.regionColumnSize,
+
+ headerCellStyleGetter: o.headerCellStyleGetter,
+ summaryCellStyleGetter: o.summaryCellStyleGetter,
+ sequenceCellStyleGetter: o.sequenceCellStyleGetter,
+
+ header: o.header,
+ items: o.items,
+ //交叉表头
+ crossHeader: o.crossHeader,
+ crossItems: o.crossItems
+ });
+
+ this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) {
+ if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) {
+ self.sequence.setVerticalScroll(this.getVerticalScroll());
+ self.sequence.populate();
+ }
+ self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
+ o.regionColumnSize = this.getRegionColumnSize();
+ o.columnSize = this.getColumnSize();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
+ });
+ this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
+ o.regionColumnSize = this.getRegionColumnSize();
+ o.columnSize = this.getColumnSize();
+ self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
+ });
+
+ this.htape = BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.sequence,
+ left: 0,
+ top: 0
+ }, {
+ el: this.table,
+ top: 0,
+ left: o.showSequence === true ? 60 : 0
+ }]
+ });
+ this._populate();
+ },
+
+ _populate: function () {
+ var o = this.options;
+ this.sequence.attr({
+ items: o.items,
+ header: o.header,
+ crossItems: o.crossItems,
+ crossHeader: o.crossHeader
+ });
+ if (o.showSequence === true) {
+ this.sequence.setVisible(true);
+ this.table.element.css("left", "60px");
+ this.table.setWidth(o.width - 60);
+ } else {
+ this.sequence.setVisible(false);
+ this.table.element.css("left", "0px");
+ this.table.setWidth(o.width);
+ }
+ },
+
+ setWidth: function (width) {
+ BI.PageTable.superclass.setWidth.apply(this, arguments);
+ this.table.setWidth(this.options.showSequence ? width - 60 : width);
+ },
+
+ setHeight: function (height) {
+ BI.PageTable.superclass.setHeight.apply(this, arguments);
+ this.table.setHeight(height);
+ this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE);
+ },
+
+ setColumnSize: function (columnSize) {
+ this.options.columnSize = columnSize;
+ this.table.setColumnSize(columnSize);
+ },
+
+ getColumnSize: function () {
+ return this.table.getColumnSize();
+ },
+
+ setRegionColumnSize: function (columnSize) {
+ this.options.columnSize = columnSize;
+ this.table.setRegionColumnSize(columnSize);
+ },
+
+ getRegionColumnSize: function () {
+ return this.table.getRegionColumnSize();
+ },
+
+ hasLeftHorizontalScroll: function () {
+ return this.table.hasLeftHorizontalScroll();
+ },
+
+ hasRightHorizontalScroll: function () {
+ return this.table.hasRightHorizontalScroll();
+ },
+
+ setLeftHorizontalScroll: function (scrollLeft) {
+ this.table.setLeftHorizontalScroll(scrollLeft);
+ },
+
+ setRightHorizontalScroll: function (scrollLeft) {
+ this.table.setRightHorizontalScroll(scrollLeft);
+ },
+
+ setVerticalScroll: function (scrollTop) {
+ this.table.setVerticalScroll(scrollTop);
+ this.sequence.setVerticalScroll(scrollTop);
+ },
+
+ getVerticalScroll: function () {
+ return this.table.getVerticalScroll();
+ },
+
+ setVPage: function (page) {
+ this.sequence.setVPage && this.sequence.setVPage(page);
+ },
+
+ setHPage: function (page) {
+ this.sequence.setHPage && this.sequence.setHPage(page);
+ },
+
+ attr: function () {
+ BI.SequenceTable.superclass.attr.apply(this, arguments);
+ this.table.attr.apply(this.table, arguments);
+ this.sequence.attr.apply(this.sequence, arguments);
+ },
+
+ restore: function () {
+ this.table.restore();
+ this.sequence.restore();
+ },
+
+ populate: function (items, header, crossItems, crossHeader) {
+ var o = this.options;
+ if (items) {
+ o.items = items;
+ }
+ if (header) {
+ o.header = header;
+ }
+ if (crossItems) {
+ o.crossItems = crossItems;
+ }
+ if (crossHeader) {
+ o.crossHeader = crossHeader;
+ }
+ this._populate();
+ this.table.populate.apply(this.table, arguments);
+ this.sequence.populate.apply(this.sequence, arguments);
+ this.sequence.setVerticalScroll(this.table.getVerticalScroll());
+ },
+
+ destroy: function () {
+ this.table.destroy();
+ BI.SequenceTable.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.shortcut('bi.sequence_table', BI.SequenceTable);/*! jQuery UI - v1.12.1 - 2017-07-14
+* http://jqueryui.com
+* Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/draggable.js, widgets/droppable.js, widgets/resizable.js, widgets/selectable.js, widgets/sortable.js, widgets/mouse.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js
+* Copyright jQuery Foundation and other contributors; Licensed MIT */
+
+(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)})(function(t){function e(t){for(var e=t.css("visibility");"inherit"===e;)t=t.parent(),e=t.css("visibility");return"hidden"!==e}t.ui=t.ui||{},t.ui.version="1.12.1";var i=0,s=Array.prototype.slice;t.cleanData=function(e){return function(i){var s,n,o;for(o=0;null!=(n=i[o]);o++)try{s=t._data(n,"events"),s&&s.remove&&t(n).triggerHandler("remove")}catch(a){}e(i)}}(t.cleanData),t.widget=function(e,i,s){var n,o,a,r={},l=e.split(".")[0];e=e.split(".")[1];var h=l+"-"+e;return s||(s=i,i=t.Widget),t.isArray(s)&&(s=t.extend.apply(null,[{}].concat(s))),t.expr[":"][h.toLowerCase()]=function(e){return!!t.data(e,h)},t[l]=t[l]||{},n=t[l][e],o=t[l][e]=function(t,e){return this._createWidget?(arguments.length&&this._createWidget(t,e),void 0):new o(t,e)},t.extend(o,n,{version:s.version,_proto:t.extend({},s),_childConstructors:[]}),a=new i,a.options=t.widget.extend({},a.options),t.each(s,function(e,s){return t.isFunction(s)?(r[e]=function(){function t(){return i.prototype[e].apply(this,arguments)}function n(t){return i.prototype[e].apply(this,t)}return function(){var e,i=this._super,o=this._superApply;return this._super=t,this._superApply=n,e=s.apply(this,arguments),this._super=i,this._superApply=o,e}}(),void 0):(r[e]=s,void 0)}),o.prototype=t.widget.extend(a,{widgetEventPrefix:n?a.widgetEventPrefix||e:e},r,{constructor:o,namespace:l,widgetName:e,widgetFullName:h}),n?(t.each(n._childConstructors,function(e,i){var s=i.prototype;t.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete n._childConstructors):i._childConstructors.push(o),t.widget.bridge(e,o),o},t.widget.extend=function(e){for(var i,n,o=s.call(arguments,1),a=0,r=o.length;r>a;a++)for(i in o[a])n=o[a][i],o[a].hasOwnProperty(i)&&void 0!==n&&(e[i]=t.isPlainObject(n)?t.isPlainObject(e[i])?t.widget.extend({},e[i],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,i){var n=i.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=s.call(arguments,1),l=this;return a?this.length||"instance"!==o?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(l=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(l=i&&i.jquery?l.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):l=void 0:(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new i(o,this))})),l}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"",options:{classes:{},disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),this._on(e.element,{remove:"_untrackClassesElement"}),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(e){var i=this;t.each(i.classesElementLookup,function(s,n){-1!==t.inArray(e.target,n)&&(i.classesElementLookup[s]=t(n.not(e.target).get()))})},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var l=s.match(/^([\w:-]*)\s*(.*)$/),h=l[1]+o.eventNamespace,c=l[2];c?n.on(h,c,r):i.on(h,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,function(){function e(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function i(e,i){return parseInt(t.css(e,i),10)||0}function s(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}var n,o=Math.max,a=Math.abs,r=/left|center|right/,l=/top|center|bottom/,h=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,d=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==n)return n;var e,i,s=t("
"),o=s.children()[0];return t("body").append(s),e=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),n=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.width
i?"left":e>0?"right":"center",vertical:0>r?"top":s>0?"bottom":"middle"};h>p&&p>a(e+i)&&(u.horizontal="center"),c>f&&f>a(s+r)&&(u.vertical="middle"),u.important=o(a(e),a(i))>o(a(s),a(r))?"horizontal":"vertical",n.using.call(this,t,u)}),l.offset(t.extend(D,{using:r}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,l=n-r,h=r+e.collisionWidth-a-n;e.collisionWidth>a?l>0&&0>=h?(i=t.left+l+e.collisionWidth-a-n,t.left+=l-i):t.left=h>0&&0>=l?n:l>h?n+a-e.collisionWidth:n:l>0?t.left+=l:h>0?t.left-=h:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,l=n-r,h=r+e.collisionHeight-a-n;e.collisionHeight>a?l>0&&0>=h?(i=t.top+l+e.collisionHeight-a-n,t.top+=l-i):t.top=h>0&&0>=l?n:l>h?n+a-e.collisionHeight:n:l>0?t.top+=l:h>0?t.top-=h:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,l=n.isWindow?n.scrollLeft:n.offset.left,h=t.left-e.collisionPosition.marginLeft,c=h-l,u=h+e.collisionWidth-r-l,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-r-o,(0>i||a(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-l,(s>0||u>a(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,o=n.offset.top+n.scrollTop,r=n.height,l=n.isWindow?n.scrollTop:n.offset.top,h=t.top-e.collisionPosition.marginTop,c=h-l,u=h+e.collisionHeight-r-l,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,g=-2*e.offset[1];0>c?(s=t.top+p+f+g+e.collisionHeight-r-o,(0>s||a(c)>s)&&(t.top+=p+f+g)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+g-l,(i>0||u>a(i))&&(t.top+=p+f+g))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}}}(),t.ui.position,t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])}}),t.fn.extend({disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.off(".ui-disableSelection")}}),t.ui.focusable=function(i,s){var n,o,a,r,l,h=i.nodeName.toLowerCase();return"area"===h?(n=i.parentNode,o=n.name,i.href&&o&&"map"===n.nodeName.toLowerCase()?(a=t("img[usemap='#"+o+"']"),a.length>0&&a.is(":visible")):!1):(/^(input|select|textarea|button|object)$/.test(h)?(r=!i.disabled,r&&(l=t(i).closest("fieldset")[0],l&&(r=!l.disabled))):r="a"===h?i.href||s:s,r&&t(i).is(":visible")&&e(t(i)))},t.extend(t.expr[":"],{focusable:function(e){return t.ui.focusable(e,null!=t.attr(e,"tabindex"))}}),t.ui.focusable,t.fn.form=function(){return"string"==typeof this[0].form?this.closest("form"):t(this[0].form)},t.ui.formResetMixin={_formResetHandler:function(){var e=t(this);setTimeout(function(){var i=e.data("ui-form-reset-instances");t.each(i,function(){this.refresh()})})},_bindFormResetHandler:function(){if(this.form=this.element.form(),this.form.length){var t=this.form.data("ui-form-reset-instances")||[];t.length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t)}},_unbindFormResetHandler:function(){if(this.form.length){var e=this.form.data("ui-form-reset-instances");e.splice(t.inArray(this,e),1),e.length?this.form.data("ui-form-reset-instances",e):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset")}}},"1.7"===t.fn.jquery.substring(0,3)&&(t.each(["Width","Height"],function(e,i){function s(e,i,s,o){return t.each(n,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(e){return void 0===e?a["inner"+i].call(this):this.each(function(){t(this).css(o,s(this,e)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?a["outer"+i].call(this,e):this.each(function(){t(this).css(o,s(this,e,!0,n)+"px")})}}),t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},t.ui.escapeSelector=function(){var t=/([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;return function(e){return e.replace(t,"\\$1")}}(),t.fn.labels=function(){var e,i,s,n,o;return this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(n=this.eq(0).parents("label"),s=this.attr("id"),s&&(e=this.eq(0).parents().last(),o=e.add(e.length?e.siblings():this.siblings()),i="label[for='"+t.ui.escapeSelector(s)+"']",n=n.add(o.find(i).addBack(i))),this.pushStack(n))},t.fn.scrollParent=function(e){var i=this.css("position"),s="absolute"===i,n=e?/(auto|scroll|hidden)/:/(auto|scroll)/,o=this.parents().filter(function(){var e=t(this);return s&&"static"===e.css("position")?!1:n.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==i&&o.length?o:t(this[0].ownerDocument||document)},t.extend(t.expr[":"],{tabbable:function(e){var i=t.attr(e,"tabindex"),s=null!=i;return(!s||i>=0)&&t.ui.focusable(e,s)}}),t.fn.extend({uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var n=!1;t(document).on("mouseup",function(){n=!1}),t.widget("ui.mouse",{version:"1.12.1",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!n){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,s=1===e.which,o="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return s&&!o&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),n=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,n=!1,e.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.ui.plugin={add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;o.length>n;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},t.ui.safeActiveElement=function(t){var e;try{e=t.activeElement}catch(i){e=t.body}return e||(e=t.body),e.nodeName||(e=t.body),e},t.ui.safeBlur=function(e){e&&"body"!==e.nodeName.toLowerCase()&&t(e).trigger("blur")},t.widget("ui.draggable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"===this.options.helper&&this._setPositionRelative(),this.options.addClasses&&this._addClass("ui-draggable"),this._setHandleClassName(),this._mouseInit()},_setOption:function(t,e){this._super(t,e),"handle"===t&&(this._removeHandleClassName(),this._setHandleClassName())},_destroy:function(){return(this.helper||this.element).is(".ui-draggable-dragging")?(this.destroyOnClear=!0,void 0):(this._removeHandleClassName(),this._mouseDestroy(),void 0)},_mouseCapture:function(e){var i=this.options;return this.helper||i.disabled||t(e.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(e),this.handle?(this._blurActiveElement(e),this._blockFrames(i.iframeFix===!0?"iframe":i.iframeFix),!0):!1)},_blockFrames:function(e){this.iframeBlocks=this.document.find(e).map(function(){var e=t(this);return t("").css("position","absolute").appendTo(e.parent()).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()).offset(e.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_blurActiveElement:function(e){var i=t.ui.safeActiveElement(this.document[0]),s=t(e.target);s.closest(i).length||t.ui.safeBlur(i)},_mouseStart:function(e){var i=this.options;return this.helper=this._createHelper(e),this._addClass(this.helper,"ui-draggable-dragging"),this._cacheHelperProportions(),t.ui.ddmanager&&(t.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.hasFixedAncestor=this.helper.parents().filter(function(){return"fixed"===t(this).css("position")}).length>0,this.positionAbs=this.element.offset(),this._refreshOffsets(e),this.originalPosition=this.position=this._generatePosition(e,!1),this.originalPageX=e.pageX,this.originalPageY=e.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",e)===!1?(this._clear(),!1):(this._cacheHelperProportions(),t.ui.ddmanager&&!i.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this._mouseDrag(e,!0),t.ui.ddmanager&&t.ui.ddmanager.dragStart(this,e),!0)},_refreshOffsets:function(t){this.offset={top:this.positionAbs.top-this.margins.top,left:this.positionAbs.left-this.margins.left,scroll:!1,parent:this._getParentOffset(),relative:this._getRelativeOffset()},this.offset.click={left:t.pageX-this.offset.left,top:t.pageY-this.offset.top}},_mouseDrag:function(e,i){if(this.hasFixedAncestor&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(e,!0),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",e,s)===!1)return this._mouseUp(new t.Event("mouseup",e)),!1;this.position=s.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),!1},_mouseStop:function(e){var i=this,s=!1;return t.ui.ddmanager&&!this.options.dropBehaviour&&(s=t.ui.ddmanager.drop(this,e)),this.dropped&&(s=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||t.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?t(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",e)!==!1&&i._clear()}):this._trigger("stop",e)!==!1&&this._clear(),!1},_mouseUp:function(e){return this._unblockFrames(),t.ui.ddmanager&&t.ui.ddmanager.dragStop(this,e),this.handleElement.is(e.target)&&this.element.trigger("focus"),t.ui.mouse.prototype._mouseUp.call(this,e)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp(new t.Event("mouseup",{target:this.element[0]})):this._clear(),this},_getHandle:function(e){return this.options.handle?!!t(e.target).closest(this.element.find(this.options.handle)).length:!0},_setHandleClassName:function(){this.handleElement=this.options.handle?this.element.find(this.options.handle):this.element,this._addClass(this.handleElement,"ui-draggable-handle")},_removeHandleClassName:function(){this._removeClass(this.handleElement,"ui-draggable-handle")},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper),n=s?t(i.helper.apply(this.element[0],[e])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return n.parents("body").length||n.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s&&n[0]===this.element[0]&&this._setPositionRelative(),n[0]===this.element[0]||/(fixed|absolute)/.test(n.css("position"))||n.css("position","absolute"),n},_setPositionRelative:function(){/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative")},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_isRootNode:function(t){return/(html|body)/i.test(t.tagName)||t===this.document[0]},_getParentOffset:function(){var e=this.offsetParent.offset(),i=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==i&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),this._isRootNode(this.offsetParent[0])&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var t=this.element.position(),e=this._isRootNode(this.scrollParent[0]);return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+(e?0:this.scrollParent.scrollTop()),left:t.left-(parseInt(this.helper.css("left"),10)||0)+(e?0:this.scrollParent.scrollLeft())}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options,o=this.document[0];return this.relativeContainer=null,n.containment?"window"===n.containment?(this.containment=[t(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,t(window).scrollLeft()+t(window).width()-this.helperProportions.width-this.margins.left,t(window).scrollTop()+(t(window).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):"document"===n.containment?(this.containment=[0,0,t(o).width()-this.helperProportions.width-this.margins.left,(t(o).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):n.containment.constructor===Array?(this.containment=n.containment,void 0):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=t(n.containment),s=i[0],s&&(e=/(scroll|auto)/.test(i.css("overflow")),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(e?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(e?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relativeContainer=i),void 0):(this.containment=null,void 0)},_convertPositionTo:function(t,e){e||(e=this.position);var i="absolute"===t?1:-1,s=this._isRootNode(this.scrollParent[0]);return{top:e.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:s?0:this.offset.scroll.top)*i,left:e.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:s?0:this.offset.scroll.left)*i}},_generatePosition:function(t,e){var i,s,n,o,a=this.options,r=this._isRootNode(this.scrollParent[0]),l=t.pageX,h=t.pageY;return r&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),e&&(this.containment&&(this.relativeContainer?(s=this.relativeContainer.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,t.pageX-this.offset.click.left
i[2]&&(l=i[2]+this.offset.click.left),t.pageY-this.offset.click.top>i[3]&&(h=i[3]+this.offset.click.top)),a.grid&&(n=a.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/a.grid[1])*a.grid[1]:this.originalPageY,h=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-a.grid[1]:n+a.grid[1]:n,o=a.grid[0]?this.originalPageX+Math.round((l-this.originalPageX)/a.grid[0])*a.grid[0]:this.originalPageX,l=i?o-this.offset.click.left>=i[0]||o-this.offset.click.left>i[2]?o:o-this.offset.click.left>=i[0]?o-a.grid[0]:o+a.grid[0]:o),"y"===a.axis&&(l=this.originalPageX),"x"===a.axis&&(h=this.originalPageY)),{top:h-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:r?0:this.offset.scroll.top),left:l-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:r?0:this.offset.scroll.left)}
+},_clear:function(){this._removeClass(this.helper,"ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_trigger:function(e,i,s){return s=s||this._uiHash(),t.ui.plugin.call(this,e,[i,s,this],!0),/^(drag|start|stop)/.test(e)&&(this.positionAbs=this._convertPositionTo("absolute"),s.offset=this.positionAbs),t.Widget.prototype._trigger.call(this,e,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),t.ui.plugin.add("draggable","connectToSortable",{start:function(e,i,s){var n=t.extend({},i,{item:s.element});s.sortables=[],t(s.options.connectToSortable).each(function(){var i=t(this).sortable("instance");i&&!i.options.disabled&&(s.sortables.push(i),i.refreshPositions(),i._trigger("activate",e,n))})},stop:function(e,i,s){var n=t.extend({},i,{item:s.element});s.cancelHelperRemoval=!1,t.each(s.sortables,function(){var t=this;t.isOver?(t.isOver=0,s.cancelHelperRemoval=!0,t.cancelHelperRemoval=!1,t._storedCSS={position:t.placeholder.css("position"),top:t.placeholder.css("top"),left:t.placeholder.css("left")},t._mouseStop(e),t.options.helper=t.options._helper):(t.cancelHelperRemoval=!0,t._trigger("deactivate",e,n))})},drag:function(e,i,s){t.each(s.sortables,function(){var n=!1,o=this;o.positionAbs=s.positionAbs,o.helperProportions=s.helperProportions,o.offset.click=s.offset.click,o._intersectsWith(o.containerCache)&&(n=!0,t.each(s.sortables,function(){return this.positionAbs=s.positionAbs,this.helperProportions=s.helperProportions,this.offset.click=s.offset.click,this!==o&&this._intersectsWith(this.containerCache)&&t.contains(o.element[0],this.element[0])&&(n=!1),n})),n?(o.isOver||(o.isOver=1,s._parent=i.helper.parent(),o.currentItem=i.helper.appendTo(o.element).data("ui-sortable-item",!0),o.options._helper=o.options.helper,o.options.helper=function(){return i.helper[0]},e.target=o.currentItem[0],o._mouseCapture(e,!0),o._mouseStart(e,!0,!0),o.offset.click.top=s.offset.click.top,o.offset.click.left=s.offset.click.left,o.offset.parent.left-=s.offset.parent.left-o.offset.parent.left,o.offset.parent.top-=s.offset.parent.top-o.offset.parent.top,s._trigger("toSortable",e),s.dropped=o.element,t.each(s.sortables,function(){this.refreshPositions()}),s.currentItem=s.element,o.fromOutside=s),o.currentItem&&(o._mouseDrag(e),i.position=o.position)):o.isOver&&(o.isOver=0,o.cancelHelperRemoval=!0,o.options._revert=o.options.revert,o.options.revert=!1,o._trigger("out",e,o._uiHash(o)),o._mouseStop(e,!0),o.options.revert=o.options._revert,o.options.helper=o.options._helper,o.placeholder&&o.placeholder.remove(),i.helper.appendTo(s._parent),s._refreshOffsets(e),i.position=s._generatePosition(e,!0),s._trigger("fromSortable",e),s.dropped=!1,t.each(s.sortables,function(){this.refreshPositions()}))})}}),t.ui.plugin.add("draggable","cursor",{start:function(e,i,s){var n=t("body"),o=s.options;n.css("cursor")&&(o._cursor=n.css("cursor")),n.css("cursor",o.cursor)},stop:function(e,i,s){var n=s.options;n._cursor&&t("body").css("cursor",n._cursor)}}),t.ui.plugin.add("draggable","opacity",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("opacity")&&(o._opacity=n.css("opacity")),n.css("opacity",o.opacity)},stop:function(e,i,s){var n=s.options;n._opacity&&t(i.helper).css("opacity",n._opacity)}}),t.ui.plugin.add("draggable","scroll",{start:function(t,e,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(e,i,s){var n=s.options,o=!1,a=s.scrollParentNotHidden[0],r=s.document[0];a!==r&&"HTML"!==a.tagName?(n.axis&&"x"===n.axis||(s.overflowOffset.top+a.offsetHeight-e.pageY=0;d--)l=s.snapElements[d].left-s.margins.left,h=l+s.snapElements[d].width,c=s.snapElements[d].top-s.margins.top,u=c+s.snapElements[d].height,l-g>_||m>h+g||c-g>b||v>u+g||!t.contains(s.snapElements[d].item.ownerDocument,s.snapElements[d].item)?(s.snapElements[d].snapping&&s.options.snap.release&&s.options.snap.release.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=!1):("inner"!==f.snapMode&&(n=g>=Math.abs(c-b),o=g>=Math.abs(u-v),a=g>=Math.abs(l-_),r=g>=Math.abs(h-m),n&&(i.position.top=s._convertPositionTo("relative",{top:c-s.helperProportions.height,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l-s.helperProportions.width}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h}).left)),p=n||o||a||r,"outer"!==f.snapMode&&(n=g>=Math.abs(c-v),o=g>=Math.abs(u-b),a=g>=Math.abs(l-m),r=g>=Math.abs(h-_),n&&(i.position.top=s._convertPositionTo("relative",{top:c,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u-s.helperProportions.height,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h-s.helperProportions.width}).left)),!s.snapElements[d].snapping&&(n||o||a||r||p)&&s.options.snap.snap&&s.options.snap.snap.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=n||o||a||r||p)}}),t.ui.plugin.add("draggable","stack",{start:function(e,i,s){var n,o=s.options,a=t.makeArray(t(o.stack)).sort(function(e,i){return(parseInt(t(e).css("zIndex"),10)||0)-(parseInt(t(i).css("zIndex"),10)||0)});a.length&&(n=parseInt(t(a[0]).css("zIndex"),10)||0,t(a).each(function(e){t(this).css("zIndex",n+e)}),this.css("zIndex",n+a.length))}}),t.ui.plugin.add("draggable","zIndex",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("zIndex")&&(o._zIndex=n.css("zIndex")),n.css("zIndex",o.zIndex)},stop:function(e,i,s){var n=s.options;n._zIndex&&t(i.helper).css("zIndex",n._zIndex)}}),t.ui.draggable,t.widget("ui.droppable",{version:"1.12.1",widgetEventPrefix:"drop",options:{accept:"*",addClasses:!0,greedy:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var e,i=this.options,s=i.accept;this.isover=!1,this.isout=!0,this.accept=t.isFunction(s)?s:function(t){return t.is(s)},this.proportions=function(){return arguments.length?(e=arguments[0],void 0):e?e:e={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}},this._addToManager(i.scope),i.addClasses&&this._addClass("ui-droppable")},_addToManager:function(e){t.ui.ddmanager.droppables[e]=t.ui.ddmanager.droppables[e]||[],t.ui.ddmanager.droppables[e].push(this)},_splice:function(t){for(var e=0;t.length>e;e++)t[e]===this&&t.splice(e,1)},_destroy:function(){var e=t.ui.ddmanager.droppables[this.options.scope];this._splice(e)},_setOption:function(e,i){if("accept"===e)this.accept=t.isFunction(i)?i:function(t){return t.is(i)};else if("scope"===e){var s=t.ui.ddmanager.droppables[this.options.scope];this._splice(s),this._addToManager(i)}this._super(e,i)},_activate:function(e){var i=t.ui.ddmanager.current;this._addActiveClass(),i&&this._trigger("activate",e,this.ui(i))},_deactivate:function(e){var i=t.ui.ddmanager.current;this._removeActiveClass(),i&&this._trigger("deactivate",e,this.ui(i))},_over:function(e){var i=t.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this._addHoverClass(),this._trigger("over",e,this.ui(i)))},_out:function(e){var i=t.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this._removeHoverClass(),this._trigger("out",e,this.ui(i)))},_drop:function(e,i){var s=i||t.ui.ddmanager.current,n=!1;return s&&(s.currentItem||s.element)[0]!==this.element[0]?(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var i=t(this).droppable("instance");return i.options.greedy&&!i.options.disabled&&i.options.scope===s.options.scope&&i.accept.call(i.element[0],s.currentItem||s.element)&&o(s,t.extend(i,{offset:i.element.offset()}),i.options.tolerance,e)?(n=!0,!1):void 0}),n?!1:this.accept.call(this.element[0],s.currentItem||s.element)?(this._removeActiveClass(),this._removeHoverClass(),this._trigger("drop",e,this.ui(s)),this.element):!1):!1},ui:function(t){return{draggable:t.currentItem||t.element,helper:t.helper,position:t.position,offset:t.positionAbs}},_addHoverClass:function(){this._addClass("ui-droppable-hover")},_removeHoverClass:function(){this._removeClass("ui-droppable-hover")},_addActiveClass:function(){this._addClass("ui-droppable-active")},_removeActiveClass:function(){this._removeClass("ui-droppable-active")}});var o=t.ui.intersect=function(){function t(t,e,i){return t>=e&&e+i>t}return function(e,i,s,n){if(!i.offset)return!1;var o=(e.positionAbs||e.position.absolute).left+e.margins.left,a=(e.positionAbs||e.position.absolute).top+e.margins.top,r=o+e.helperProportions.width,l=a+e.helperProportions.height,h=i.offset.left,c=i.offset.top,u=h+i.proportions().width,d=c+i.proportions().height;switch(s){case"fit":return o>=h&&u>=r&&a>=c&&d>=l;case"intersect":return o+e.helperProportions.width/2>h&&u>r-e.helperProportions.width/2&&a+e.helperProportions.height/2>c&&d>l-e.helperProportions.height/2;case"pointer":return t(n.pageY,c,i.proportions().height)&&t(n.pageX,h,i.proportions().width);case"touch":return(a>=c&&d>=a||l>=c&&d>=l||c>a&&l>d)&&(o>=h&&u>=o||r>=h&&u>=r||h>o&&r>u);default:return!1}}}();t.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(e,i){var s,n,o=t.ui.ddmanager.droppables[e.options.scope]||[],a=i?i.type:null,r=(e.currentItem||e.element).find(":data(ui-droppable)").addBack();t:for(s=0;o.length>s;s++)if(!(o[s].options.disabled||e&&!o[s].accept.call(o[s].element[0],e.currentItem||e.element))){for(n=0;r.length>n;n++)if(r[n]===o[s].element[0]){o[s].proportions().height=0;continue t}o[s].visible="none"!==o[s].element.css("display"),o[s].visible&&("mousedown"===a&&o[s]._activate.call(o[s],i),o[s].offset=o[s].element.offset(),o[s].proportions({width:o[s].element[0].offsetWidth,height:o[s].element[0].offsetHeight}))}},drop:function(e,i){var s=!1;return t.each((t.ui.ddmanager.droppables[e.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&o(e,this,this.options.tolerance,i)&&(s=this._drop.call(this,i)||s),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],e.currentItem||e.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,i)))}),s},dragStart:function(e,i){e.element.parentsUntil("body").on("scroll.droppable",function(){e.options.refreshPositions||t.ui.ddmanager.prepareOffsets(e,i)})},drag:function(e,i){e.options.refreshPositions&&t.ui.ddmanager.prepareOffsets(e,i),t.each(t.ui.ddmanager.droppables[e.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var s,n,a,r=o(e,this,this.options.tolerance,i),l=!r&&this.isover?"isout":r&&!this.isover?"isover":null;l&&(this.options.greedy&&(n=this.options.scope,a=this.element.parents(":data(ui-droppable)").filter(function(){return t(this).droppable("instance").options.scope===n}),a.length&&(s=t(a[0]).droppable("instance"),s.greedyChild="isover"===l)),s&&"isover"===l&&(s.isover=!1,s.isout=!0,s._out.call(s,i)),this[l]=!0,this["isout"===l?"isover":"isout"]=!1,this["isover"===l?"_over":"_out"].call(this,i),s&&"isout"===l&&(s.isout=!1,s.isover=!0,s._over.call(s,i)))}})},dragStop:function(e,i){e.element.parentsUntil("body").off("scroll.droppable"),e.options.refreshPositions||t.ui.ddmanager.prepareOffsets(e,i)}},t.uiBackCompat!==!1&&t.widget("ui.droppable",t.ui.droppable,{options:{hoverClass:!1,activeClass:!1},_addActiveClass:function(){this._super(),this.options.activeClass&&this.element.addClass(this.options.activeClass)},_removeActiveClass:function(){this._super(),this.options.activeClass&&this.element.removeClass(this.options.activeClass)},_addHoverClass:function(){this._super(),this.options.hoverClass&&this.element.addClass(this.options.hoverClass)},_removeHoverClass:function(){this._super(),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass)}}),t.ui.droppable,t.widget("ui.resizable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,classes:{"ui-resizable-se":"ui-icon ui-icon-gripsmall-diagonal-se"},containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseFloat(t)||0},_isNumber:function(t){return!isNaN(parseFloat(t))},_hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)},_create:function(){var e,i=this.options,s=this;this._addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(t("
").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,e={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(e),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(e),this._proportionallyResize()),this._setupHandles(),i.autoHide&&t(this.element).on("mouseenter",function(){i.disabled||(s._removeClass("ui-resizable-autohide"),s._handles.show())}).on("mouseleave",function(){i.disabled||s.resizing||(s._addClass("ui-resizable-autohide"),s._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeData("resizable").removeData("ui-resizable").off(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;default:}},_setupHandles:function(){var e,i,s,n,o,a=this.options,r=this;if(this.handles=a.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=t(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),s=this.handles.split(","),this.handles={},i=0;s.length>i;i++)e=t.trim(s[i]),n="ui-resizable-"+e,o=t(""),this._addClass(o,"ui-resizable-handle "+n),o.css({zIndex:a.zIndex}),this.handles[e]=".ui-resizable-"+e,this.element.append(o);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=t(this.handles[i]),this._on(this.handles[i],{mousedown:r._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){r.resizing||(this.className&&(o=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),r.axis=o&&o[1]?o[1]:"se")}),a.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._handles.remove()},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(e){var i,s,n,o=this.options,a=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),o.containment&&(i+=t(o.containment).scrollLeft()||0,s+=t(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:e.pageX,top:e.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===n?this.axis+"-resize":n),this._addClass("ui-resizable-resizing"),this._propagate("start",e),!0},_mouseDrag:function(e){var i,s,n=this.originalMousePosition,o=this.axis,a=e.pageX-n.left||0,r=e.pageY-n.top||0,l=this._change[o];return this._updatePrevProperties(),l?(i=l.apply(this,[e,a,r]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",e,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,l,h=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseFloat(c.element.css("left"))+(c.position.left-c.originalPosition.left)||null,l=parseFloat(c.element.css("top"))+(c.position.top-c.originalPosition.top)||null,h.animate||this.element.css(t.extend(a,{top:l,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!h.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s,n,o,a=this.options;o={minWidth:this._isNumber(a.minWidth)?a.minWidth:0,maxWidth:this._isNumber(a.maxWidth)?a.maxWidth:1/0,minHeight:this._isNumber(a.minHeight)?a.minHeight:0,maxHeight:this._isNumber(a.maxHeight)?a.maxHeight:1/0},(this._aspectRatio||t)&&(e=o.minHeight*this.aspectRatio,s=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,n=o.maxWidth/this.aspectRatio,e>o.minWidth&&(o.minWidth=e),s>o.minHeight&&(o.minHeight=s),o.maxWidth>i&&(o.maxWidth=i),o.maxHeight>n&&(o.maxHeight=n)),this._vBoundaries=o},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidth
t.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,l=this.originalPosition.top+this.originalSize.height,h=/sw|nw|w/.test(i),c=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&h&&(t.left=r-e.minWidth),s&&h&&(t.left=r-e.maxWidth),a&&c&&(t.top=l-e.minHeight),n&&c&&(t.top=l-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];4>e;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;this._proportionallyResizeElements.length>e;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
"),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,l={width:i.size.width-r,height:i.size.height-a},h=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,c=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(l,c&&h?{top:c,left:h}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var e,i,s,n,o,a,r,l=t(this).resizable("instance"),h=l.options,c=l.element,u=h.containment,d=u instanceof t?u.get(0):/parent/.test(u)?c.parent().get(0):u;d&&(l.containerElement=t(d),/document/.test(u)||u===document?(l.containerOffset={left:0,top:0},l.containerPosition={left:0,top:0},l.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(e=t(d),i=[],t(["Top","Right","Left","Bottom"]).each(function(t,s){i[t]=l._num(e.css("padding"+s))}),l.containerOffset=e.offset(),l.containerPosition=e.position(),l.containerSize={height:e.innerHeight()-i[3],width:e.innerWidth()-i[1]},s=l.containerOffset,n=l.containerSize.height,o=l.containerSize.width,a=l._hasScroll(d,"left")?d.scrollWidth:o,r=l._hasScroll(d)?d.scrollHeight:n,l.parentData={element:d,left:s.left,top:s.top,width:a,height:r}))},resize:function(e){var i,s,n,o,a=t(this).resizable("instance"),r=a.options,l=a.containerOffset,h=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(u=l),h.left<(a._helper?l.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-l.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio,p=!1),a.position.left=r.helper?l.left:0),h.top<(a._helper?l.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-l.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio,p=!1),a.position.top=a._helper?l.top:0),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o?(a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top):(a.offset.left=a.element.offset().left,a.offset.top=a.element.offset().top),i=Math.abs(a.sizeDiff.width+(a._helper?a.offset.left-u.left:a.offset.left-l.left)),s=Math.abs(a.sizeDiff.height+(a._helper?a.offset.top-u.top:a.offset.top-l.top)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio,p=!1)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio,p=!1)),p||(a.position.left=a.prevPosition.left,a.position.top=a.prevPosition.top,a.size.width=a.prevSize.width,a.size.height=a.prevSize.height)},stop:function(){var e=t(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),l=a.outerWidth()-e.sizeDiff.width,h=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:l,height:h}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:l,height:h})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).resizable("instance"),i=e.options;t(i.alsoResize).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseFloat(e.width()),height:parseFloat(e.height()),left:parseFloat(e.css("left")),top:parseFloat(e.css("top"))})})},resize:function(e,i){var s=t(this).resizable("instance"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0};t(n.alsoResize).each(function(){var e=t(this),s=t(this).data("ui-resizable-alsoresize"),n={},o=e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(o,function(t,e){var i=(s[e]||0)+(r[e]||0);i&&i>=0&&(n[e]=i||null)}),e.css(n)})},stop:function(){t(this).removeData("ui-resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).resizable("instance"),i=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:i.height,width:i.width,margin:0,left:0,top:0}),e._addClass(e.ghost,"ui-resizable-ghost"),t.uiBackCompat!==!1&&"string"==typeof e.options.ghost&&e.ghost.addClass(this.options.ghost),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).resizable("instance");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).resizable("instance");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e,i=t(this).resizable("instance"),s=i.options,n=i.size,o=i.originalSize,a=i.originalPosition,r=i.axis,l="number"==typeof s.grid?[s.grid,s.grid]:s.grid,h=l[0]||1,c=l[1]||1,u=Math.round((n.width-o.width)/h)*h,d=Math.round((n.height-o.height)/c)*c,p=o.width+u,f=o.height+d,g=s.maxWidth&&p>s.maxWidth,m=s.maxHeight&&f>s.maxHeight,_=s.minWidth&&s.minWidth>p,v=s.minHeight&&s.minHeight>f;s.grid=l,_&&(p+=h),v&&(f+=c),g&&(p-=h),m&&(f-=c),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=a.top-d):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=a.left-u):((0>=f-c||0>=p-h)&&(e=i._getPaddingPlusBorderDimensions(this)),f-c>0?(i.size.height=f,i.position.top=a.top-d):(f=c-e.height,i.size.height=f,i.position.top=a.top+o.height-f),p-h>0?(i.size.width=p,i.position.left=a.left-u):(p=h-e.width,i.size.width=p,i.position.left=a.left+o.width-p))
+}}),t.ui.resizable,t.widget("ui.selectable",t.ui.mouse,{version:"1.12.1",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var e=this;this._addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){e.elementPos=t(e.element[0]).offset(),e.selectees=t(e.options.filter,e.element[0]),e._addClass(e.selectees,"ui-selectee"),e.selectees.each(function(){var i=t(this),s=i.offset(),n={left:s.left-e.elementPos.left,top:s.top-e.elementPos.top};t.data(this,"selectable-item",{element:this,$element:i,left:n.left,top:n.top,right:n.left+i.outerWidth(),bottom:n.top+i.outerHeight(),startselected:!1,selected:i.hasClass("ui-selected"),selecting:i.hasClass("ui-selecting"),unselecting:i.hasClass("ui-unselecting")})})},this.refresh(),this._mouseInit(),this.helper=t(""),this._addClass(this.helper,"ui-selectable-helper")},_destroy:function(){this.selectees.removeData("selectable-item"),this._mouseDestroy()},_mouseStart:function(e){var i=this,s=this.options;this.opos=[e.pageX,e.pageY],this.elementPos=t(this.element[0]).offset(),this.options.disabled||(this.selectees=t(s.filter,this.element[0]),this._trigger("start",e),t(s.appendTo).append(this.helper),this.helper.css({left:e.pageX,top:e.pageY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=t.data(this,"selectable-item");s.startselected=!0,e.metaKey||e.ctrlKey||(i._removeClass(s.$element,"ui-selected"),s.selected=!1,i._addClass(s.$element,"ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",e,{unselecting:s.element}))}),t(e.target).parents().addBack().each(function(){var s,n=t.data(this,"selectable-item");return n?(s=!e.metaKey&&!e.ctrlKey||!n.$element.hasClass("ui-selected"),i._removeClass(n.$element,s?"ui-unselecting":"ui-selected")._addClass(n.$element,s?"ui-selecting":"ui-unselecting"),n.unselecting=!s,n.selecting=s,n.selected=s,s?i._trigger("selecting",e,{selecting:n.element}):i._trigger("unselecting",e,{unselecting:n.element}),!1):void 0}))},_mouseDrag:function(e){if(this.dragged=!0,!this.options.disabled){var i,s=this,n=this.options,o=this.opos[0],a=this.opos[1],r=e.pageX,l=e.pageY;return o>r&&(i=r,r=o,o=i),a>l&&(i=l,l=a,a=i),this.helper.css({left:o,top:a,width:r-o,height:l-a}),this.selectees.each(function(){var i=t.data(this,"selectable-item"),h=!1,c={};i&&i.element!==s.element[0]&&(c.left=i.left+s.elementPos.left,c.right=i.right+s.elementPos.left,c.top=i.top+s.elementPos.top,c.bottom=i.bottom+s.elementPos.top,"touch"===n.tolerance?h=!(c.left>r||o>c.right||c.top>l||a>c.bottom):"fit"===n.tolerance&&(h=c.left>o&&r>c.right&&c.top>a&&l>c.bottom),h?(i.selected&&(s._removeClass(i.$element,"ui-selected"),i.selected=!1),i.unselecting&&(s._removeClass(i.$element,"ui-unselecting"),i.unselecting=!1),i.selecting||(s._addClass(i.$element,"ui-selecting"),i.selecting=!0,s._trigger("selecting",e,{selecting:i.element}))):(i.selecting&&((e.metaKey||e.ctrlKey)&&i.startselected?(s._removeClass(i.$element,"ui-selecting"),i.selecting=!1,s._addClass(i.$element,"ui-selected"),i.selected=!0):(s._removeClass(i.$element,"ui-selecting"),i.selecting=!1,i.startselected&&(s._addClass(i.$element,"ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",e,{unselecting:i.element}))),i.selected&&(e.metaKey||e.ctrlKey||i.startselected||(s._removeClass(i.$element,"ui-selected"),i.selected=!1,s._addClass(i.$element,"ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",e,{unselecting:i.element})))))}),!1}},_mouseStop:function(e){var i=this;return this.dragged=!1,t(".ui-unselecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");i._removeClass(s.$element,"ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",e,{unselected:s.element})}),t(".ui-selecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");i._removeClass(s.$element,"ui-selecting")._addClass(s.$element,"ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",e,{selected:s.element})}),this._trigger("stop",e),this.helper.remove(),!1}}),t.widget("ui.sortable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(t,e,i){return t>=e&&e+i>t},_isFloating:function(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))},_create:function(){this.containerCache={},this._addClass("ui-sortable"),this.refresh(),this.offset=this.element.offset(),this._mouseInit(),this._setHandleClassName(),this.ready=!0},_setOption:function(t,e){this._super(t,e),"handle"===t&&this._setHandleClassName()},_setHandleClassName:function(){var e=this;this._removeClass(this.element.find(".ui-sortable-handle"),"ui-sortable-handle"),t.each(this.items,function(){e._addClass(this.instance.options.handle?this.item.find(this.instance.options.handle):this.item,"ui-sortable-handle")})},_destroy:function(){this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_mouseCapture:function(e,i){var s=null,n=!1,o=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(e),t(e.target).parents().each(function(){return t.data(this,o.widgetName+"-item")===o?(s=t(this),!1):void 0}),t.data(e.target,o.widgetName+"-item")===o&&(s=t(e.target)),s?!this.options.handle||i||(t(this.options.handle,s).find("*").addBack().each(function(){this===e.target&&(n=!0)}),n)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(e,i,s){var n,o,a=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,a.cursorAt&&this._adjustOffsetFromHelper(a.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),a.containment&&this._setContainment(),a.cursor&&"auto"!==a.cursor&&(o=this.document.find("body"),this.storedCursor=o.css("cursor"),o.css("cursor",a.cursor),this.storedStylesheet=t("").appendTo(o)),a.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",a.opacity)),a.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",a.zIndex)),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!a.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this._addClass(this.helper,"ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,s,n,o,a=this.options,r=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY
=0;i--)if(s=this.items[i],n=s.item[0],o=this._intersectsWithPointer(s),o&&s.instance===this.currentContainer&&n!==this.currentItem[0]&&this.placeholder[1===o?"next":"prev"]()[0]!==n&&!t.contains(this.placeholder[0],n)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],n):!0)){if(this.direction=1===o?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break;this._rearrange(e,s),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var s=this,n=this.placeholder.offset(),o=this.options.axis,a={};o&&"x"!==o||(a.left=n.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollLeft)),o&&"y"!==o||(a.top=n.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(a,parseInt(this.options.revert,10)||500,function(){s._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp(new t.Event("mouseup",{target:null})),"original"===this.options.helper?(this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&s.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!s.length&&e.key&&s.push(e.key+"="),s.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},i.each(function(){s.push(t(e.item||this).attr(e.attribute||"id")||"")}),s},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,o=t.left,a=o+t.width,r=t.top,l=r+t.height,h=this.offset.click.top,c=this.offset.click.left,u="x"===this.options.axis||s+h>r&&l>s+h,d="y"===this.options.axis||e+c>o&&a>e+c,p=u&&d;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?p:e+this.helperProportions.width/2>o&&a>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>r&&l>n-this.helperProportions.height/2},_intersectsWithPointer:function(t){var e,i,s="x"===this.options.axis||this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),n="y"===this.options.axis||this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width),o=s&&n;return o?(e=this._getDragVerticalDirection(),i=this._getDragHorizontalDirection(),this.floating?"right"===i||"down"===e?2:1:e&&("down"===e?2:1)):!1},_intersectsWithSides:function(t){var e=this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),i=this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),s=this._getDragVerticalDirection(),n=this._getDragHorizontalDirection();return this.floating&&n?"right"===n&&i||"left"===n&&!i:s&&("down"===s&&e||"up"===s&&!e)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!==t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this._setHandleClassName(),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){function i(){r.push(this)}var s,n,o,a,r=[],l=[],h=this._connectWith();if(h&&e)for(s=h.length-1;s>=0;s--)for(o=t(h[s],this.document[0]),n=o.length-1;n>=0;n--)a=t.data(o[n],this.widgetFullName),a&&a!==this&&!a.options.disabled&&l.push([t.isFunction(a.options.items)?a.options.items.call(a.element):t(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a]);for(l.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),s=l.length-1;s>=0;s--)l[s][0].each(i);return t(r)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;e.length>i;i++)if(e[i]===t.item[0])return!1;return!0})},_refreshItems:function(e){this.items=[],this.containers=[this];var i,s,n,o,a,r,l,h,c=this.items,u=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],d=this._connectWith();if(d&&this.ready)for(i=d.length-1;i>=0;i--)for(n=t(d[i],this.document[0]),s=n.length-1;s>=0;s--)o=t.data(n[s],this.widgetFullName),o&&o!==this&&!o.options.disabled&&(u.push([t.isFunction(o.options.items)?o.options.items.call(o.element[0],e,{item:this.currentItem}):t(o.options.items,o.element),o]),this.containers.push(o));for(i=u.length-1;i>=0;i--)for(a=u[i][1],r=u[i][0],s=0,h=r.length;h>s;s++)l=t(r[s]),l.data(this.widgetName+"-item",a),c.push({item:l,instance:a,width:0,height:0,left:0,top:0})},refreshPositions:function(e){this.floating=this.items.length?"x"===this.options.axis||this._isFloating(this.items[0].item):!1,this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,s,n,o;for(i=this.items.length-1;i>=0;i--)s=this.items[i],s.instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(n=this.options.toleranceElement?t(this.options.toleranceElement,s.item):s.item,e||(s.width=n.outerWidth(),s.height=n.outerHeight()),o=n.offset(),s.left=o.left,s.top=o.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)o=this.containers[i].element.offset(),this.containers[i].containerCache.left=o.left,this.containers[i].containerCache.top=o.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){e=e||this;var i,s=e.options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=e.currentItem[0].nodeName.toLowerCase(),n=t("<"+s+">",e.document[0]);return e._addClass(n,"ui-sortable-placeholder",i||e.currentItem[0].className)._removeClass(n,"ui-sortable-helper"),"tbody"===s?e._createTrPlaceholder(e.currentItem.find("tr").eq(0),t("",e.document[0]).appendTo(n)):"tr"===s?e._createTrPlaceholder(e.currentItem,n):"img"===s&&n.attr("src",e.currentItem.attr("src")),i||n.css("visibility","hidden"),n},update:function(t,n){(!i||s.forcePlaceholderSize)&&(n.height()||n.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),n.width()||n.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(s.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),s.placeholder.update(e,e.placeholder)},_createTrPlaceholder:function(e,i){var s=this;e.children().each(function(){t(" ",s.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(i)})},_contactContainers:function(e){var i,s,n,o,a,r,l,h,c,u,d=null,p=null;for(i=this.containers.length-1;i>=0;i--)if(!t.contains(this.currentItem[0],this.containers[i].element[0]))if(this._intersectsWith(this.containers[i].containerCache)){if(d&&t.contains(this.containers[i].element[0],d.element[0]))continue;d=this.containers[i],p=i}else this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",e,this._uiHash(this)),this.containers[i].containerCache.over=0);if(d)if(1===this.containers.length)this.containers[p].containerCache.over||(this.containers[p]._trigger("over",e,this._uiHash(this)),this.containers[p].containerCache.over=1);else{for(n=1e4,o=null,c=d.floating||this._isFloating(this.currentItem),a=c?"left":"top",r=c?"width":"height",u=c?"pageX":"pageY",s=this.items.length-1;s>=0;s--)t.contains(this.containers[p].element[0],this.items[s].item[0])&&this.items[s].item[0]!==this.currentItem[0]&&(l=this.items[s].item.offset()[a],h=!1,e[u]-l>this.items[s][r]/2&&(h=!0),n>Math.abs(e[u]-l)&&(n=Math.abs(e[u]-l),o=this.items[s],this.direction=h?"up":"down"));if(!o&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[p])return this.currentContainer.containerCache.over||(this.containers[p]._trigger("over",e,this._uiHash()),this.currentContainer.containerCache.over=1),void 0;o?this._rearrange(e,o,null,!0):this._rearrange(e,null,this.containers[p].element,!0),this._trigger("change",e,this._uiHash()),this.containers[p]._trigger("change",e,this._uiHash(this)),this.currentContainer=this.containers[p],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[p]._trigger("over",e,this._uiHash(this)),this.containers[p].containerCache.over=1}},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||t("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(!s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===this.document[0].body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options;"parent"===n.containment&&(n.containment=this.helper[0].parentNode),("document"===n.containment||"window"===n.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,"document"===n.containment?this.document.width():this.window.width()-this.helperProportions.width-this.margins.left,("document"===n.containment?this.document.height()||document.body.parentNode.scrollHeight:this.window.height()||this.document[0].body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(n.containment)||(e=t(n.containment)[0],i=t(n.containment).offset(),s="hidden"!==t(e).css("overflow"),this.containment=[i.left+(parseInt(t(e).css("borderLeftWidth"),10)||0)+(parseInt(t(e).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(t(e).css("borderTopWidth"),10)||0)+(parseInt(t(e).css("paddingTop"),10)||0)-this.margins.top,i.left+(s?Math.max(e.scrollWidth,e.offsetWidth):e.offsetWidth)-(parseInt(t(e).css("borderLeftWidth"),10)||0)-(parseInt(t(e).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(s?Math.max(e.scrollHeight,e.offsetHeight):e.offsetHeight)-(parseInt(t(e).css("borderTopWidth"),10)||0)-(parseInt(t(e).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(e,i){i||(i=this.position);var s="absolute"===e?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(n[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():o?0:n.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():o?0:n.scrollLeft())*s}},_generatePosition:function(e){var i,s,n=this.options,o=e.pageX,a=e.pageY,r="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,l=/(html|body)/i.test(r[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.leftthis.containment[2]&&(o=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(a=this.containment[3]+this.offset.click.top)),n.grid&&(i=this.originalPageY+Math.round((a-this.originalPageY)/n.grid[1])*n.grid[1],a=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-n.grid[1]:i+n.grid[1]:i,s=this.originalPageX+Math.round((o-this.originalPageX)/n.grid[0])*n.grid[0],o=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-n.grid[0]:s+n.grid[0]:s)),{top:a-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():l?0:r.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():l?0:r.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){function i(t,e,i){return function(s){i._trigger(t,s,e._uiHash(e))}}this.reverting=!1;var s,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(s in this._storedCSS)("auto"===this._storedCSS[s]||"static"===this._storedCSS[s])&&(this._storedCSS[s]="");this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&n.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||n.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(n.push(function(t){this._trigger("remove",t,this._uiHash())}),n.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),s=this.containers.length-1;s>=0;s--)e||n.push(i("deactivate",this,this.containers[s])),this.containers[s].containerCache.over&&(n.push(i("out",this,this.containers[s])),this.containers[s].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.cancelHelperRemoval||(this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null),!e){for(s=0;n.length>s;s++)n[s].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!this.cancelHelperRemoval},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}});var a="ui-effects-",r="ui-effects-style",l="ui-effects-animated",h=t;t.effects={effect:{}},function(t,e){function i(t,e,i){var s=u[e.type]||{};return null==t?i||!e.def?null:e.def:(t=s.floor?~~t:parseFloat(t),isNaN(t)?e.def:s.mod?(t+s.mod)%s.mod:0>t?0:t>s.max?s.max:t)}function s(i){var s=h(),n=s._rgba=[];return i=i.toLowerCase(),f(l,function(t,o){var a,r=o.re.exec(i),l=r&&o.parse(r),h=o.space||"rgba";return l?(a=s[h](l),s[c[h].cache]=a[c[h].cache],n=s._rgba=a._rgba,!1):e}),n.length?("0,0,0,0"===n.join()&&t.extend(n,o.transparent),s):o[i]}function n(t,e,i){return i=(i+1)%1,1>6*i?t+6*(e-t)*i:1>2*i?e:2>3*i?t+6*(e-t)*(2/3-i):t}var o,a="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",r=/^([\-+])=\s*(\d+\.?\d*)/,l=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[t[1],t[2],t[3],t[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[2.55*t[1],2.55*t[2],2.55*t[3],t[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(t){return[t[1],t[2]/100,t[3]/100,t[4]]}}],h=t.Color=function(e,i,s,n){return new t.Color.fn.parse(e,i,s,n)},c={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},u={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},d=h.support={},p=t("")[0],f=t.each;p.style.cssText="background-color:rgba(1,1,1,.5)",d.rgba=p.style.backgroundColor.indexOf("rgba")>-1,f(c,function(t,e){e.cache="_"+t,e.props.alpha={idx:3,type:"percent",def:1}}),h.fn=t.extend(h.prototype,{parse:function(n,a,r,l){if(n===e)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=t(n).css(a),a=e);var u=this,d=t.type(n),p=this._rgba=[];return a!==e&&(n=[n,a,r,l],d="array"),"string"===d?this.parse(s(n)||o._default):"array"===d?(f(c.rgba.props,function(t,e){p[e.idx]=i(n[e.idx],e)}),this):"object"===d?(n instanceof h?f(c,function(t,e){n[e.cache]&&(u[e.cache]=n[e.cache].slice())}):f(c,function(e,s){var o=s.cache;f(s.props,function(t,e){if(!u[o]&&s.to){if("alpha"===t||null==n[t])return;u[o]=s.to(u._rgba)}u[o][e.idx]=i(n[t],e,!0)}),u[o]&&0>t.inArray(null,u[o].slice(0,3))&&(u[o][3]=1,s.from&&(u._rgba=s.from(u[o])))}),this):e},is:function(t){var i=h(t),s=!0,n=this;return f(c,function(t,o){var a,r=i[o.cache];return r&&(a=n[o.cache]||o.to&&o.to(n._rgba)||[],f(o.props,function(t,i){return null!=r[i.idx]?s=r[i.idx]===a[i.idx]:e})),s}),s},_space:function(){var t=[],e=this;return f(c,function(i,s){e[s.cache]&&t.push(i)}),t.pop()},transition:function(t,e){var s=h(t),n=s._space(),o=c[n],a=0===this.alpha()?h("transparent"):this,r=a[o.cache]||o.to(a._rgba),l=r.slice();
+return s=s[o.cache],f(o.props,function(t,n){var o=n.idx,a=r[o],h=s[o],c=u[n.type]||{};null!==h&&(null===a?l[o]=h:(c.mod&&(h-a>c.mod/2?a+=c.mod:a-h>c.mod/2&&(a-=c.mod)),l[o]=i((h-a)*e+a,n)))}),this[n](l)},blend:function(e){if(1===this._rgba[3])return this;var i=this._rgba.slice(),s=i.pop(),n=h(e)._rgba;return h(t.map(i,function(t,e){return(1-s)*n[e]+s*t}))},toRgbaString:function(){var e="rgba(",i=t.map(this._rgba,function(t,e){return null==t?e>2?1:0:t});return 1===i[3]&&(i.pop(),e="rgb("),e+i.join()+")"},toHslaString:function(){var e="hsla(",i=t.map(this.hsla(),function(t,e){return null==t&&(t=e>2?1:0),e&&3>e&&(t=Math.round(100*t)+"%"),t});return 1===i[3]&&(i.pop(),e="hsl("),e+i.join()+")"},toHexString:function(e){var i=this._rgba.slice(),s=i.pop();return e&&i.push(~~(255*s)),"#"+t.map(i,function(t){return t=(t||0).toString(16),1===t.length?"0"+t:t}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),h.fn.parse.prototype=h.fn,c.hsla.to=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e,i,s=t[0]/255,n=t[1]/255,o=t[2]/255,a=t[3],r=Math.max(s,n,o),l=Math.min(s,n,o),h=r-l,c=r+l,u=.5*c;return e=l===r?0:s===r?60*(n-o)/h+360:n===r?60*(o-s)/h+120:60*(s-n)/h+240,i=0===h?0:.5>=u?h/c:h/(2-c),[Math.round(e)%360,i,u,null==a?1:a]},c.hsla.from=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/360,i=t[1],s=t[2],o=t[3],a=.5>=s?s*(1+i):s+i-s*i,r=2*s-a;return[Math.round(255*n(r,a,e+1/3)),Math.round(255*n(r,a,e)),Math.round(255*n(r,a,e-1/3)),o]},f(c,function(s,n){var o=n.props,a=n.cache,l=n.to,c=n.from;h.fn[s]=function(s){if(l&&!this[a]&&(this[a]=l(this._rgba)),s===e)return this[a].slice();var n,r=t.type(s),u="array"===r||"object"===r?s:arguments,d=this[a].slice();return f(o,function(t,e){var s=u["object"===r?t:e.idx];null==s&&(s=d[e.idx]),d[e.idx]=i(s,e)}),c?(n=h(c(d)),n[a]=d,n):h(d)},f(o,function(e,i){h.fn[e]||(h.fn[e]=function(n){var o,a=t.type(n),l="alpha"===e?this._hsla?"hsla":"rgba":s,h=this[l](),c=h[i.idx];return"undefined"===a?c:("function"===a&&(n=n.call(this,c),a=t.type(n)),null==n&&i.empty?this:("string"===a&&(o=r.exec(n),o&&(n=c+parseFloat(o[2])*("+"===o[1]?1:-1))),h[i.idx]=n,this[l](h)))})})}),h.hook=function(e){var i=e.split(" ");f(i,function(e,i){t.cssHooks[i]={set:function(e,n){var o,a,r="";if("transparent"!==n&&("string"!==t.type(n)||(o=s(n)))){if(n=h(o||n),!d.rgba&&1!==n._rgba[3]){for(a="backgroundColor"===i?e.parentNode:e;(""===r||"transparent"===r)&&a&&a.style;)try{r=t.css(a,"backgroundColor"),a=a.parentNode}catch(l){}n=n.blend(r&&"transparent"!==r?r:"_default")}n=n.toRgbaString()}try{e.style[i]=n}catch(l){}}},t.fx.step[i]=function(e){e.colorInit||(e.start=h(e.elem,i),e.end=h(e.end),e.colorInit=!0),t.cssHooks[i].set(e.elem,e.start.transition(e.end,e.pos))}})},h.hook(a),t.cssHooks.borderColor={expand:function(t){var e={};return f(["Top","Right","Bottom","Left"],function(i,s){e["border"+s+"Color"]=t}),e}},o=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(h),function(){function e(e){var i,s,n=e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,null):e.currentStyle,o={};if(n&&n.length&&n[0]&&n[n[0]])for(s=n.length;s--;)i=n[s],"string"==typeof n[i]&&(o[t.camelCase(i)]=n[i]);else for(i in n)"string"==typeof n[i]&&(o[i]=n[i]);return o}function i(e,i){var s,o,a={};for(s in i)o=i[s],e[s]!==o&&(n[s]||(t.fx.step[s]||!isNaN(parseFloat(o)))&&(a[s]=o));return a}var s=["add","remove","toggle"],n={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};t.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(e,i){t.fx.step[i]=function(t){("none"!==t.end&&!t.setAttr||1===t.pos&&!t.setAttr)&&(h.style(t.elem,i,t.end),t.setAttr=!0)}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.effects.animateClass=function(n,o,a,r){var l=t.speed(o,a,r);return this.queue(function(){var o,a=t(this),r=a.attr("class")||"",h=l.children?a.find("*").addBack():a;h=h.map(function(){var i=t(this);return{el:i,start:e(this)}}),o=function(){t.each(s,function(t,e){n[e]&&a[e+"Class"](n[e])})},o(),h=h.map(function(){return this.end=e(this.el[0]),this.diff=i(this.start,this.end),this}),a.attr("class",r),h=h.map(function(){var e=this,i=t.Deferred(),s=t.extend({},l,{queue:!1,complete:function(){i.resolve(e)}});return this.el.animate(this.diff,s),i.promise()}),t.when.apply(t,h.get()).done(function(){o(),t.each(arguments,function(){var e=this.el;t.each(this.diff,function(t){e.css(t,"")})}),l.complete.call(a[0])})})},t.fn.extend({addClass:function(e){return function(i,s,n,o){return s?t.effects.animateClass.call(this,{add:i},s,n,o):e.apply(this,arguments)}}(t.fn.addClass),removeClass:function(e){return function(i,s,n,o){return arguments.length>1?t.effects.animateClass.call(this,{remove:i},s,n,o):e.apply(this,arguments)}}(t.fn.removeClass),toggleClass:function(e){return function(i,s,n,o,a){return"boolean"==typeof s||void 0===s?n?t.effects.animateClass.call(this,s?{add:i}:{remove:i},n,o,a):e.apply(this,arguments):t.effects.animateClass.call(this,{toggle:i},s,n,o)}}(t.fn.toggleClass),switchClass:function(e,i,s,n,o){return t.effects.animateClass.call(this,{add:i,remove:e},s,n,o)}})}(),function(){function e(e,i,s,n){return t.isPlainObject(e)&&(i=e,e=e.effect),e={effect:e},null==i&&(i={}),t.isFunction(i)&&(n=i,s=null,i={}),("number"==typeof i||t.fx.speeds[i])&&(n=s,s=i,i={}),t.isFunction(s)&&(n=s,s=null),i&&t.extend(e,i),s=s||i.duration,e.duration=t.fx.off?0:"number"==typeof s?s:s in t.fx.speeds?t.fx.speeds[s]:t.fx.speeds._default,e.complete=n||i.complete,e}function i(e){return!e||"number"==typeof e||t.fx.speeds[e]?!0:"string"!=typeof e||t.effects.effect[e]?t.isFunction(e)?!0:"object"!=typeof e||e.effect?!1:!0:!0}function s(t,e){var i=e.outerWidth(),s=e.outerHeight(),n=/^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/,o=n.exec(t)||["",0,i,s,0];return{top:parseFloat(o[1])||0,right:"auto"===o[2]?i:parseFloat(o[2]),bottom:"auto"===o[3]?s:parseFloat(o[3]),left:parseFloat(o[4])||0}}t.expr&&t.expr.filters&&t.expr.filters.animated&&(t.expr.filters.animated=function(e){return function(i){return!!t(i).data(l)||e(i)}}(t.expr.filters.animated)),t.uiBackCompat!==!1&&t.extend(t.effects,{save:function(t,e){for(var i=0,s=e.length;s>i;i++)null!==e[i]&&t.data(a+e[i],t[0].style[e[i]])},restore:function(t,e){for(var i,s=0,n=e.length;n>s;s++)null!==e[s]&&(i=t.data(a+e[s]),t.css(e[s],i))},setMode:function(t,e){return"toggle"===e&&(e=t.is(":hidden")?"show":"hide"),e},createWrapper:function(e){if(e.parent().is(".ui-effects-wrapper"))return e.parent();var i={width:e.outerWidth(!0),height:e.outerHeight(!0),"float":e.css("float")},s=t("
").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),n={width:e.width(),height:e.height()},o=document.activeElement;try{o.id}catch(a){o=document.body}return e.wrap(s),(e[0]===o||t.contains(e[0],o))&&t(o).trigger("focus"),s=e.parent(),"static"===e.css("position")?(s.css({position:"relative"}),e.css({position:"relative"})):(t.extend(i,{position:e.css("position"),zIndex:e.css("z-index")}),t.each(["top","left","bottom","right"],function(t,s){i[s]=e.css(s),isNaN(parseInt(i[s],10))&&(i[s]="auto")}),e.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),e.css(n),s.css(i).show()},removeWrapper:function(e){var i=document.activeElement;return e.parent().is(".ui-effects-wrapper")&&(e.parent().replaceWith(e),(e[0]===i||t.contains(e[0],i))&&t(i).trigger("focus")),e}}),t.extend(t.effects,{version:"1.12.1",define:function(e,i,s){return s||(s=i,i="effect"),t.effects.effect[e]=s,t.effects.effect[e].mode=i,s},scaledDimensions:function(t,e,i){if(0===e)return{height:0,width:0,outerHeight:0,outerWidth:0};var s="horizontal"!==i?(e||100)/100:1,n="vertical"!==i?(e||100)/100:1;return{height:t.height()*n,width:t.width()*s,outerHeight:t.outerHeight()*n,outerWidth:t.outerWidth()*s}},clipToBox:function(t){return{width:t.clip.right-t.clip.left,height:t.clip.bottom-t.clip.top,left:t.clip.left,top:t.clip.top}},unshift:function(t,e,i){var s=t.queue();e>1&&s.splice.apply(s,[1,0].concat(s.splice(e,i))),t.dequeue()},saveStyle:function(t){t.data(r,t[0].style.cssText)},restoreStyle:function(t){t[0].style.cssText=t.data(r)||"",t.removeData(r)},mode:function(t,e){var i=t.is(":hidden");return"toggle"===e&&(e=i?"show":"hide"),(i?"hide"===e:"show"===e)&&(e="none"),e},getBaseline:function(t,e){var i,s;switch(t[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=t[0]/e.height}switch(t[1]){case"left":s=0;break;case"center":s=.5;break;case"right":s=1;break;default:s=t[1]/e.width}return{x:s,y:i}},createPlaceholder:function(e){var i,s=e.css("position"),n=e.position();return e.css({marginTop:e.css("marginTop"),marginBottom:e.css("marginBottom"),marginLeft:e.css("marginLeft"),marginRight:e.css("marginRight")}).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()),/^(static|relative)/.test(s)&&(s="absolute",i=t("<"+e[0].nodeName+">").insertAfter(e).css({display:/^(inline|ruby)/.test(e.css("display"))?"inline-block":"block",visibility:"hidden",marginTop:e.css("marginTop"),marginBottom:e.css("marginBottom"),marginLeft:e.css("marginLeft"),marginRight:e.css("marginRight"),"float":e.css("float")}).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()).addClass("ui-effects-placeholder"),e.data(a+"placeholder",i)),e.css({position:s,left:n.left,top:n.top}),i},removePlaceholder:function(t){var e=a+"placeholder",i=t.data(e);i&&(i.remove(),t.removeData(e))},cleanUp:function(e){t.effects.restoreStyle(e),t.effects.removePlaceholder(e)},setTransition:function(e,i,s,n){return n=n||{},t.each(i,function(t,i){var o=e.cssUnit(i);o[0]>0&&(n[i]=o[0]*s+o[1])}),n}}),t.fn.extend({effect:function(){function i(e){function i(){r.removeData(l),t.effects.cleanUp(r),"hide"===s.mode&&r.hide(),a()}function a(){t.isFunction(h)&&h.call(r[0]),t.isFunction(e)&&e()}var r=t(this);s.mode=u.shift(),t.uiBackCompat===!1||o?"none"===s.mode?(r[c](),a()):n.call(r[0],s,i):(r.is(":hidden")?"hide"===c:"show"===c)?(r[c](),a()):n.call(r[0],s,a)}var s=e.apply(this,arguments),n=t.effects.effect[s.effect],o=n.mode,a=s.queue,r=a||"fx",h=s.complete,c=s.mode,u=[],d=function(e){var i=t(this),s=t.effects.mode(i,c)||o;i.data(l,!0),u.push(s),o&&("show"===s||s===o&&"hide"===s)&&i.show(),o&&"none"===s||t.effects.saveStyle(i),t.isFunction(e)&&e()};return t.fx.off||!n?c?this[c](s.duration,h):this.each(function(){h&&h.call(this)}):a===!1?this.each(d).each(i):this.queue(r,d).queue(r,i)},show:function(t){return function(s){if(i(s))return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="show",this.effect.call(this,n)}}(t.fn.show),hide:function(t){return function(s){if(i(s))return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="hide",this.effect.call(this,n)}}(t.fn.hide),toggle:function(t){return function(s){if(i(s)||"boolean"==typeof s)return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="toggle",this.effect.call(this,n)}}(t.fn.toggle),cssUnit:function(e){var i=this.css(e),s=[];return t.each(["em","px","%","pt"],function(t,e){i.indexOf(e)>0&&(s=[parseFloat(i),e])}),s},cssClip:function(t){return t?this.css("clip","rect("+t.top+"px "+t.right+"px "+t.bottom+"px "+t.left+"px)"):s(this.css("clip"),this)},transfer:function(e,i){var s=t(this),n=t(e.to),o="fixed"===n.css("position"),a=t("body"),r=o?a.scrollTop():0,l=o?a.scrollLeft():0,h=n.offset(),c={top:h.top-r,left:h.left-l,height:n.innerHeight(),width:n.innerWidth()},u=s.offset(),d=t("
").appendTo("body").addClass(e.className).css({top:u.top-r,left:u.left-l,height:s.innerHeight(),width:s.innerWidth(),position:o?"fixed":"absolute"}).animate(c,e.duration,e.easing,function(){d.remove(),t.isFunction(i)&&i()})}}),t.fx.step.clip=function(e){e.clipInit||(e.start=t(e.elem).cssClip(),"string"==typeof e.end&&(e.end=s(e.end,e.elem)),e.clipInit=!0),t(e.elem).cssClip({top:e.pos*(e.end.top-e.start.top)+e.start.top,right:e.pos*(e.end.right-e.start.right)+e.start.right,bottom:e.pos*(e.end.bottom-e.start.bottom)+e.start.bottom,left:e.pos*(e.end.left-e.start.left)+e.start.left})}}(),function(){var e={};t.each(["Quad","Cubic","Quart","Quint","Expo"],function(t,i){e[i]=function(e){return Math.pow(e,t+2)}}),t.extend(e,{Sine:function(t){return 1-Math.cos(t*Math.PI/2)},Circ:function(t){return 1-Math.sqrt(1-t*t)},Elastic:function(t){return 0===t||1===t?t:-Math.pow(2,8*(t-1))*Math.sin((80*(t-1)-7.5)*Math.PI/15)},Back:function(t){return t*t*(3*t-2)},Bounce:function(t){for(var e,i=4;((e=Math.pow(2,--i))-1)/11>t;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*e-2)/22-t,2)}}),t.each(e,function(e,i){t.easing["easeIn"+e]=i,t.easing["easeOut"+e]=function(t){return 1-i(1-t)},t.easing["easeInOut"+e]=function(t){return.5>t?i(2*t)/2:1-i(-2*t+2)/2}})}();var c=t.effects;t.effects.define("blind","hide",function(e,i){var s={up:["bottom","top"],vertical:["bottom","top"],down:["top","bottom"],left:["right","left"],horizontal:["right","left"],right:["left","right"]},n=t(this),o=e.direction||"up",a=n.cssClip(),r={clip:t.extend({},a)},l=t.effects.createPlaceholder(n);r.clip[s[o][0]]=r.clip[s[o][1]],"show"===e.mode&&(n.cssClip(r.clip),l&&l.css(t.effects.clipToBox(r)),r.clip=a),l&&l.animate(t.effects.clipToBox(r),e.duration,e.easing),n.animate(r,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("bounce",function(e,i){var s,n,o,a=t(this),r=e.mode,l="hide"===r,h="show"===r,c=e.direction||"up",u=e.distance,d=e.times||5,p=2*d+(h||l?1:0),f=e.duration/p,g=e.easing,m="up"===c||"down"===c?"top":"left",_="up"===c||"left"===c,v=0,b=a.queue().length;for(t.effects.createPlaceholder(a),o=a.css(m),u||(u=a["top"===m?"outerHeight":"outerWidth"]()/3),h&&(n={opacity:1},n[m]=o,a.css("opacity",0).css(m,_?2*-u:2*u).animate(n,f,g)),l&&(u/=Math.pow(2,d-1)),n={},n[m]=o;d>v;v++)s={},s[m]=(_?"-=":"+=")+u,a.animate(s,f,g).animate(n,f,g),u=l?2*u:u/2;l&&(s={opacity:0},s[m]=(_?"-=":"+=")+u,a.animate(s,f,g)),a.queue(i),t.effects.unshift(a,b,p+1)}),t.effects.define("clip","hide",function(e,i){var s,n={},o=t(this),a=e.direction||"vertical",r="both"===a,l=r||"horizontal"===a,h=r||"vertical"===a;s=o.cssClip(),n.clip={top:h?(s.bottom-s.top)/2:s.top,right:l?(s.right-s.left)/2:s.right,bottom:h?(s.bottom-s.top)/2:s.bottom,left:l?(s.right-s.left)/2:s.left},t.effects.createPlaceholder(o),"show"===e.mode&&(o.cssClip(n.clip),n.clip=s),o.animate(n,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("drop","hide",function(e,i){var s,n=t(this),o=e.mode,a="show"===o,r=e.direction||"left",l="up"===r||"down"===r?"top":"left",h="up"===r||"left"===r?"-=":"+=",c="+="===h?"-=":"+=",u={opacity:0};t.effects.createPlaceholder(n),s=e.distance||n["top"===l?"outerHeight":"outerWidth"](!0)/2,u[l]=h+s,a&&(n.css(u),u[l]=c+s,u.opacity=1),n.animate(u,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("explode","hide",function(e,i){function s(){b.push(this),b.length===u*d&&n()}function n(){p.css({visibility:"visible"}),t(b).remove(),i()}var o,a,r,l,h,c,u=e.pieces?Math.round(Math.sqrt(e.pieces)):3,d=u,p=t(this),f=e.mode,g="show"===f,m=p.show().css("visibility","hidden").offset(),_=Math.ceil(p.outerWidth()/d),v=Math.ceil(p.outerHeight()/u),b=[];for(o=0;u>o;o++)for(l=m.top+o*v,c=o-(u-1)/2,a=0;d>a;a++)r=m.left+a*_,h=a-(d-1)/2,p.clone().appendTo("body").wrap("
").css({position:"absolute",visibility:"visible",left:-a*_,top:-o*v}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:_,height:v,left:r+(g?h*_:0),top:l+(g?c*v:0),opacity:g?0:1}).animate({left:r+(g?0:h*_),top:l+(g?0:c*v),opacity:g?1:0},e.duration||500,e.easing,s)}),t.effects.define("fade","toggle",function(e,i){var s="show"===e.mode;t(this).css("opacity",s?0:1).animate({opacity:s?1:0},{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("fold","hide",function(e,i){var s=t(this),n=e.mode,o="show"===n,a="hide"===n,r=e.size||15,l=/([0-9]+)%/.exec(r),h=!!e.horizFirst,c=h?["right","bottom"]:["bottom","right"],u=e.duration/2,d=t.effects.createPlaceholder(s),p=s.cssClip(),f={clip:t.extend({},p)},g={clip:t.extend({},p)},m=[p[c[0]],p[c[1]]],_=s.queue().length;l&&(r=parseInt(l[1],10)/100*m[a?0:1]),f.clip[c[0]]=r,g.clip[c[0]]=r,g.clip[c[1]]=0,o&&(s.cssClip(g.clip),d&&d.css(t.effects.clipToBox(g)),g.clip=p),s.queue(function(i){d&&d.animate(t.effects.clipToBox(f),u,e.easing).animate(t.effects.clipToBox(g),u,e.easing),i()}).animate(f,u,e.easing).animate(g,u,e.easing).queue(i),t.effects.unshift(s,_,4)}),t.effects.define("highlight","show",function(e,i){var s=t(this),n={backgroundColor:s.css("backgroundColor")};"hide"===e.mode&&(n.opacity=0),t.effects.saveStyle(s),s.css({backgroundImage:"none",backgroundColor:e.color||"#ffff99"}).animate(n,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("size",function(e,i){var s,n,o,a=t(this),r=["fontSize"],l=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],h=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],c=e.mode,u="effect"!==c,d=e.scale||"both",p=e.origin||["middle","center"],f=a.css("position"),g=a.position(),m=t.effects.scaledDimensions(a),_=e.from||m,v=e.to||t.effects.scaledDimensions(a,0);t.effects.createPlaceholder(a),"show"===c&&(o=_,_=v,v=o),n={from:{y:_.height/m.height,x:_.width/m.width},to:{y:v.height/m.height,x:v.width/m.width}},("box"===d||"both"===d)&&(n.from.y!==n.to.y&&(_=t.effects.setTransition(a,l,n.from.y,_),v=t.effects.setTransition(a,l,n.to.y,v)),n.from.x!==n.to.x&&(_=t.effects.setTransition(a,h,n.from.x,_),v=t.effects.setTransition(a,h,n.to.x,v))),("content"===d||"both"===d)&&n.from.y!==n.to.y&&(_=t.effects.setTransition(a,r,n.from.y,_),v=t.effects.setTransition(a,r,n.to.y,v)),p&&(s=t.effects.getBaseline(p,m),_.top=(m.outerHeight-_.outerHeight)*s.y+g.top,_.left=(m.outerWidth-_.outerWidth)*s.x+g.left,v.top=(m.outerHeight-v.outerHeight)*s.y+g.top,v.left=(m.outerWidth-v.outerWidth)*s.x+g.left),a.css(_),("content"===d||"both"===d)&&(l=l.concat(["marginTop","marginBottom"]).concat(r),h=h.concat(["marginLeft","marginRight"]),a.find("*[width]").each(function(){var i=t(this),s=t.effects.scaledDimensions(i),o={height:s.height*n.from.y,width:s.width*n.from.x,outerHeight:s.outerHeight*n.from.y,outerWidth:s.outerWidth*n.from.x},a={height:s.height*n.to.y,width:s.width*n.to.x,outerHeight:s.height*n.to.y,outerWidth:s.width*n.to.x};n.from.y!==n.to.y&&(o=t.effects.setTransition(i,l,n.from.y,o),a=t.effects.setTransition(i,l,n.to.y,a)),n.from.x!==n.to.x&&(o=t.effects.setTransition(i,h,n.from.x,o),a=t.effects.setTransition(i,h,n.to.x,a)),u&&t.effects.saveStyle(i),i.css(o),i.animate(a,e.duration,e.easing,function(){u&&t.effects.restoreStyle(i)})})),a.animate(v,{queue:!1,duration:e.duration,easing:e.easing,complete:function(){var e=a.offset();0===v.opacity&&a.css("opacity",_.opacity),u||(a.css("position","static"===f?"relative":f).offset(e),t.effects.saveStyle(a)),i()}})}),t.effects.define("scale",function(e,i){var s=t(this),n=e.mode,o=parseInt(e.percent,10)||(0===parseInt(e.percent,10)?0:"effect"!==n?0:100),a=t.extend(!0,{from:t.effects.scaledDimensions(s),to:t.effects.scaledDimensions(s,o,e.direction||"both"),origin:e.origin||["middle","center"]},e);e.fade&&(a.from.opacity=1,a.to.opacity=0),t.effects.effect.size.call(this,a,i)}),t.effects.define("puff","hide",function(e,i){var s=t.extend(!0,{},e,{fade:!0,percent:parseInt(e.percent,10)||150});t.effects.effect.scale.call(this,s,i)}),t.effects.define("pulsate","show",function(e,i){var s=t(this),n=e.mode,o="show"===n,a="hide"===n,r=o||a,l=2*(e.times||5)+(r?1:0),h=e.duration/l,c=0,u=1,d=s.queue().length;for((o||!s.is(":visible"))&&(s.css("opacity",0).show(),c=1);l>u;u++)s.animate({opacity:c},h,e.easing),c=1-c;s.animate({opacity:c},h,e.easing),s.queue(i),t.effects.unshift(s,d,l+1)}),t.effects.define("shake",function(e,i){var s=1,n=t(this),o=e.direction||"left",a=e.distance||20,r=e.times||3,l=2*r+1,h=Math.round(e.duration/l),c="up"===o||"down"===o?"top":"left",u="up"===o||"left"===o,d={},p={},f={},g=n.queue().length;for(t.effects.createPlaceholder(n),d[c]=(u?"-=":"+=")+a,p[c]=(u?"+=":"-=")+2*a,f[c]=(u?"-=":"+=")+2*a,n.animate(d,h,e.easing);r>s;s++)n.animate(p,h,e.easing).animate(f,h,e.easing);n.animate(p,h,e.easing).animate(d,h/2,e.easing).queue(i),t.effects.unshift(n,g,l+1)}),t.effects.define("slide","show",function(e,i){var s,n,o=t(this),a={up:["bottom","top"],down:["top","bottom"],left:["right","left"],right:["left","right"]},r=e.mode,l=e.direction||"left",h="up"===l||"down"===l?"top":"left",c="up"===l||"left"===l,u=e.distance||o["top"===h?"outerHeight":"outerWidth"](!0),d={};t.effects.createPlaceholder(o),s=o.cssClip(),n=o.position()[h],d[h]=(c?-1:1)*u+n,d.clip=o.cssClip(),d.clip[a[l][1]]=d.clip[a[l][0]],"show"===r&&(o.cssClip(d.clip),o.css(h,d[h]),d.clip=s,d[h]=n),o.animate(d,{queue:!1,duration:e.duration,easing:e.easing,complete:i})});var c;t.uiBackCompat!==!1&&(c=t.effects.define("transfer",function(e,i){t(this).transfer(e,i)}))});/**
+ * Created by zcf on 2016/9/22.
+ */
+BI.SingleSlider = BI.inherit(BI.Widget, {
+ _constant: {
+ EDITOR_WIDTH: 60,
+ EDITOR_HEIGHT: 30,
+ HEIGHT: 28,
+ SLIDER_WIDTH_HALF: 15,
+ SLIDER_WIDTH: 30,
+ SLIDER_HEIGHT: 30,
+ TRACK_HEIGHT: 24
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-slider bi-slider-track"
+ });
+ },
+ _init: function () {
+ BI.SingleSlider.superclass._init.apply(this, arguments);
+
+ var self = this;
+ var c = this._constant;
+ this.enable = false;
+ this.value = "";
+
+ this.backgroundTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "background-track bi-background",
+ height: c.TRACK_HEIGHT
+ });
+ this.grayTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "gray-track",
+ height: 8
+ });
+ this.blueTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "blue-track bi-high-light-background",
+ height: 8
+ });
+ this.track = this._createTrackWrapper();
+
+ this.slider = BI.createWidget({
+ type: "bi.single_slider_slider"
+ });
+ this.slider.element.draggable({
+ axis: "x",
+ containment: this.grayTrack.element,
+ scroll: false,
+ drag: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1)); //直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
+ self._setBlueTrack(significantPercent);
+ self._setLabelPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.label.setValue(v);
+ self.value = v;
+ },
+ stop: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderPosition(significantPercent);
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }
+ });
+ var sliderVertical = BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [this.slider]
+ }],
+ hgap: c.SLIDER_WIDTH_HALF,
+ height: c.SLIDER_HEIGHT
+ });
+ sliderVertical.element.click(function (e) {
+ if (self.enable) {
+ var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF;
+ var trackLength = self.track.element[0].scrollWidth;
+ var percent = 0;
+ if (offset < 0) {
+ percent = 0
+ }
+ if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) {
+ percent = offset * 100 / self._getGrayTrackLength();
+ }
+ if (offset > (trackLength - c.SLIDER_WIDTH)) {
+ percent = 100
+ }
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setAllPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.label.setValue(v);
+ self.value = v;
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }
+ });
+ this.label = BI.createWidget({
+ type: "bi.sign_editor",
+ cls: "slider-editor-button",
+ errorText: "",
+ height: c.HEIGHT,
+ width: c.EDITOR_WIDTH,
+ allowBlank: false,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ },
+ quitChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var percent = self._getPercentByValue(this.getValue());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setAllPosition(significantPercent);
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ });
+ this.label.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.label.element.addClass("bi-border");
+ });
+ this.label.on(BI.SignEditor.EVENT_BLUR, function () {
+ self.label.element.removeClass("bi-border");
+ });
+ this._setVisible(false);
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.track,
+ width: "100%",
+ height: c.TRACK_HEIGHT
+ }]
+ }],
+ hgap: 7,
+ height: c.TRACK_HEIGHT
+ },
+ top: 33,
+ left: 0,
+ width: "100%"
+ }, {
+ el: sliderVertical,
+ top: 30,
+ left: 0,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [this.label]
+ }],
+ rgap: c.EDITOR_WIDTH / 2,
+ height: c.EDITOR_HEIGHT
+ },
+ top: 0,
+ left: 0,
+ width: "100%"
+ }]
+ })
+ },
+
+ _createTrackWrapper: function () {
+ return BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: this.backgroundTrack,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.grayTrack,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }, {
+ el: this.blueTrack,
+ top: 0,
+ left: 0,
+ width: "0%"
+ }]
+ }],
+ hgap: 8,
+ height: 8
+ },
+ top: 8,
+ left: 0,
+ width: "100%"
+ }]
+ })
+ },
+
+ _checkValidation: function (v) {
+ return !(BI.isNull(v) || v < this.min || v > this.max)
+ },
+
+ _setBlueTrack: function (percent) {
+ this.blueTrack.element.css({
+ "width": percent + "%"
+ });
+ },
+
+ _setLabelPosition: function (percent) {
+ this.label.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setSliderPosition: function (percent) {
+ this.slider.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setAllPosition: function (percent) {
+ this._setSliderPosition(percent);
+ this._setLabelPosition(percent);
+ this._setBlueTrack(percent);
+ },
+
+ _setVisible: function (visible) {
+ this.slider.setVisible(visible);
+ this.label.setVisible(visible);
+ },
+
+ _getGrayTrackLength: function () {
+ return this.grayTrack.element[0].scrollWidth
+ },
+
+ _getValueByPercent: function (percent) {
+ var thousandth = BI.parseInt(percent * 10);
+ return (((this.max - this.min) * thousandth) / 1000 + this.min);
+ },
+
+ _getPercentByValue: function (v) {
+ return (v - this.min) * 100 / (this.max - this.min);
+ },
+
+ getValue: function () {
+ return this.value;
+ },
+
+ setValue: function (v) {
+ var value = BI.parseFloat(v);
+ if ((!isNaN(value))) {
+ if (this._checkValidation(value)) {
+ this.value = value;
+ }
+ if (value > this.max) {
+ this.value = this.max;
+ }
+ if (value < this.min) {
+ this.value = this.min;
+ }
+ }
+ },
+
+ setMinAndMax: function (v) {
+ var minNumber = BI.parseFloat(v.min);
+ var maxNumber = BI.parseFloat(v.max);
+ if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber)) {
+ this.min = minNumber;
+ this.max = maxNumber;
+ }
+ },
+
+ reset: function () {
+ this._setVisible(false);
+ this.enable = false;
+ this.value = "";
+ this.min = 0;
+ this.max = 0;
+ this._setBlueTrack(0);
+ },
+
+ populate: function () {
+ if (!isNaN(this.min) && !isNaN(this.max)) {
+ this._setVisible(true);
+ this.enable = true;
+ this.label.setErrorText(BI.i18nText("BI-Please_Enter") + this.min + "-" + this.max + BI.i18nText("BI-Basic_De") + BI.i18nText("BI-Basic_Number"));
+ if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
+ this.label.setValue(this.value);
+ this._setAllPosition(this._getPercentByValue(this.value));
+ } else {
+ this.label.setValue(this.max);
+ this._setAllPosition(100);
+ }
+ }
+ }
+});
+BI.SingleSlider.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_slider", BI.SingleSlider);/**
+ * Created by zcf on 2016/9/22.
+ */
+BI.Slider = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Slider.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-slider-slider"
+ });
+ },
+ _init: function () {
+ BI.extend(BI.Slider.superclass._init.apply(this, arguments));
+ this.slider = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "widget-slider-icon",
+ iconWidth: 30,
+ iconHeight: 30,
+ height: 30,
+ width: 30
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.slider,
+ top: 0,
+ left: -15
+ }],
+ width: 0,
+ height: 30
+ });
+ }
+});
+BI.shortcut("bi.single_slider_slider", BI.Slider);/**
+ * @class BI.SingleTreeCombo
+ * @extends BI.Widget
+ */
+BI.SingleTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-tree-combo",
+ trigger: {},
+ height: 30,
+ text: "",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SingleTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget(BI.extend({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items
+ }, o.trigger));
+
+ this.popup = BI.createWidget({
+ type: "bi.single_tree_popup",
+ items: o.items
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments);
+ });
+
+ this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE);
+ });
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+
+BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE";
+BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/**
+ * @class BI.SingleTreePopup
+ * @extends BI.Pane
+ */
+
+BI.SingleTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-tree-popup",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SingleTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: 'bi.level_tree',
+ expander: {
+ isDefaultInit: true
+ },
+ items: o.items,
+ chooseType: BI.Selection.Single
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.LevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SingleTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.SingleTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_tree_popup", BI.SingleTreePopup);/**
+ * @class BI.SingleTreeTrigger
+ * @extends BI.Trigger
+ */
+
+BI.SingleTreeTrigger = BI.inherit(BI.Trigger, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-tree-trigger",
+ height: 30,
+ text: "",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SingleTreeTrigger.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.select_text_trigger",
+ element: this,
+ text: o.text,
+ items: o.items,
+ height: o.height
+ });
+ },
+
+ _checkTitle: function () {
+ var self = this, val = this.getValue();
+ BI.any(this.options.items, function (i, item) {
+ if (val.contains(item.value)) {
+ self.trigger.setTitle(item.text || item.value);
+ return true;
+ }
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.options.value = v;
+ this.trigger.setValue(v);
+ this._checkTitle();
+ },
+
+ getValue: function () {
+ return this.options.value || [];
+ },
+
+ populate: function (items) {
+ BI.SingleTreeTrigger.superclass.populate.apply(this, arguments);
+ this.trigger.populate(items);
+ }
+
+});
+
+BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);/**
+ * 可以单选多选切换的树
+ *
+ * Created by GUY on 2015/12/21.
+ * @class BI.SwitchTree
+ * @extends BI.Widget
+ */
+BI.SwitchTree = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-switch-tree",
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SwitchTree.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.tab = BI.createWidget({
+ type: "bi.tab",
+ element: this,
+ tab: null,
+ defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect,
+ cardCreator: BI.bind(this._createTree, this)
+ });
+ },
+
+ _createTree: function (type) {
+ var self = this, o = this.options;
+ switch (type) {
+ case BI.SwitchTree.SelectType.SingleSelect:
+ this.levelTree = BI.createWidget({
+ type: "bi.multilayer_single_level_tree",
+ isDefaultInit: true,
+ items: BI.deepClone(o.items)
+ });
+ this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments);
+ });
+ return this.levelTree;
+ case BI.SwitchTree.SelectType.MultiSelect:
+ this.tree = BI.createWidget({
+ type: "bi.simple_tree",
+ items: this._removeIsParent(BI.deepClone(o.items))
+ });
+ this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments);
+ });
+ return this.tree;
+ }
+ },
+
+ _removeIsParent: function(items) {
+ BI.each(items, function(i, item) {
+ BI.isNotNull(item.isParent) && delete item.isParent;
+ });
+ return items;
+ },
+
+ switchSelect: function () {
+ switch (this.getSelect()) {
+ case BI.SwitchTree.SelectType.SingleSelect:
+ this.setSelect(BI.SwitchTree.SelectType.MultiSelect);
+ break;
+ case BI.SwitchTree.SelectType.MultiSelect:
+ this.setSelect(BI.SwitchTree.SelectType.SingleSelect);
+ break;
+ }
+ },
+
+ setSelect: function (v) {
+ this.tab.setSelect(v);
+ },
+
+ getSelect: function () {
+ return this.tab.getSelect();
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ switch (this.getSelect()) {
+ case BI.SwitchTree.SelectType.SingleSelect:
+ this.levelTree.setValue(v);
+ break;
+ case BI.SwitchTree.SelectType.MultiSelect:
+ this.tree.setValue(v);
+ break;
+ }
+ },
+
+ getValue: function () {
+ return this.tab.getValue();
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ if (BI.isNotNull(this.levelTree)) {
+ this.levelTree.populate(BI.deepClone(items));
+ }
+ if (BI.isNotNull(this.tree)) {
+ this.tree.populate(this._removeIsParent(BI.deepClone(items)));
+ }
+ }
+});
+BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE";
+BI.SwitchTree.SelectType = {
+ SingleSelect: BI.Selection.Single,
+ MultiSelect: BI.Selection.Multi
+};
+BI.shortcut('bi.switch_tree', BI.SwitchTree);
+/**
+ * 年份下拉框
+ *
+ * Created by GUY on 2015/8/28.
+ * @class BI.YearCombo
+ * @extends BI.Widget
+ */
+BI.YearCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-combo",
+ behaviors: {},
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.YearCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = "";
+ this.trigger = BI.createWidget({
+ type: "bi.year_trigger",
+ min: o.min,
+ max: o.max
+ });
+ this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () {
+ self.storeValue = this.getKey();
+ });
+ this.trigger.on(BI.YearTrigger.EVENT_START, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.YearTrigger.EVENT_STOP, function () {
+ self.combo.showView();
+ });
+ this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.YearTrigger.EVENT_CONFIRM, function () {
+ if (self.combo.isViewVisible()) {
+ return;
+ }
+ if (this.getKey() && this.getKey() !== self.storeValue) {
+ self.setValue(this.getKey());
+ } else if (!this.getKey()) {
+ self.setValue();
+ }
+ self.fireEvent(BI.YearCombo.EVENT_CONFIRM);
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ destroyWhenHide: true,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ stopPropagation: false,
+ el: {
+ type: "bi.year_popup",
+ ref: function () {
+ self.popup = this;
+ },
+ listeners: [{
+ eventName: BI.YearPopup.EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.YearCombo.EVENT_CONFIRM);
+ }
+ }],
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max
+ }
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ var value = self.trigger.getKey();
+ if (BI.isNotNull(value)) {
+ self.popup.setValue(value);
+ } else if (!value && value !== self.storeValue) {
+ self.popup.setValue(self.storeValue);
+ } else {
+ self.setValue();
+ }
+ self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.year_combo', BI.YearCombo);/**
+ * 年份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.YearPopup
+ * @extends BI.Trigger
+ */
+BI.YearPopup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-popup",
+ behaviors: {},
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31' //最大日期
+ });
+ },
+
+ _createYearCalendar: function (v) {
+ var o = this.options, y = this._year;
+
+ var calendar = BI.createWidget({
+ type: "bi.year_calendar",
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max,
+ logic: {
+ dynamic: true
+ },
+ year: y + v * 12
+ });
+ calendar.setValue(this._year);
+ return calendar;
+ },
+
+ _init: function () {
+ BI.YearPopup.superclass._init.apply(this, arguments);
+ var self = this;
+
+ this.selectedYear = this._year = new Date().getFullYear();
+
+ var backBtn = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "pre-page-h-font",
+ width: 25,
+ height: 25,
+ value: -1
+ });
+
+ var preBtn = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "next-page-h-font",
+ width: 25,
+ height: 25,
+ value: 1
+ });
+
+ this.navigation = BI.createWidget({
+ type: "bi.navigation",
+ element: this,
+ single: true,
+ logic: {
+ dynamic: true
+ },
+ tab: {
+ cls: "year-popup-navigation bi-high-light bi-border-top",
+ height: 25,
+ items: [backBtn, preBtn]
+ },
+ cardCreator: BI.bind(this._createYearCalendar, this),
+
+ afterCardShow: function () {
+ this.setValue(self.selectedYear);
+ var calendar = this.getSelectedCard();
+ backBtn.setEnable(!calendar.isFrontYear());
+ preBtn.setEnable(!calendar.isFinalYear());
+ }
+ });
+
+ this.navigation.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedYear = this.getValue();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear);
+ });
+ },
+
+ getValue: function () {
+ return this.selectedYear;
+ },
+
+ setValue: function (v) {
+ var o = this.options;
+ if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) {
+ v = new Date().getFullYear();
+ this.selectedYear = "";
+ this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
+ this.navigation.setValue("");
+ } else {
+ this.selectedYear = v;
+ this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
+ this.navigation.setValue(v);
+ }
+ }
+});
+BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.year_popup", BI.YearPopup);/**
+ * 年份trigger
+ *
+ * Created by GUY on 2015/8/21.
+ * @class BI.YearTrigger
+ * @extends BI.Trigger
+ */
+BI.YearTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ triggerWidth: 25,
+ errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
+ errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text")
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-year-trigger bi-border",
+ min: '1900-01-01', //最小日期
+ max: '2099-12-31', //最大日期
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.YearTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid);
+ return v === "" || (BI.isPositiveInteger(v) && !Date.checkVoid(v, 1, 1, o.min, o.max)[0]);
+ },
+ quitChecker: function (v) {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ errorText: c.errorText
+ })
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.YearTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.YearTrigger.EVENT_STOP);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setValue(value);
+ self.editor.setTitle(value);
+ }
+ self.fireEvent(BI.YearTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.YearTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
+ self.fireEvent(BI.YearTrigger.EVENT_ERROR);
+ });
+ BI.createWidget({
+ element: this,
+ type: 'bi.htape',
+ items: [
+ {
+ el: this.editor
+ }, {
+ el: {
+ type: "bi.text_button",
+ baseCls: "bi-trigger-year-text",
+ text: BI.i18nText("BI-Multi_Date_Year"),
+ width: c.triggerWidth
+ },
+ width: c.triggerWidth
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: c.triggerWidth
+ },
+ width: c.triggerWidth
+ }
+ ]
+ });
+ },
+ setValue: function (v) {
+ this.editor.setState(v);
+ this.editor.setValue(v);
+ this.editor.setTitle(v);
+ },
+ getKey: function () {
+ return this.editor.getValue() | 0;
+ }
+});
+BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR";
+BI.YearTrigger.EVENT_START = "EVENT_START";
+BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.YearTrigger.EVENT_STOP = "EVENT_STOP";
+BI.shortcut("bi.year_trigger", BI.YearTrigger);/**
+ * 年份 + 月份下拉框
+ *
+ * @class BI.YearMonthCombo
+ * @extends BI.Widget
+ */
+BI.YearMonthCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-month-combo",
+ yearBehaviors: {},
+ monthBehaviors: {},
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.YearMonthCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.year = BI.createWidget({
+ type: "bi.year_combo",
+ behaviors: o.yearBehaviors
+ });
+
+ this.month = BI.createWidget({
+ type: "bi.month_combo",
+ behaviors: o.monthBehaviors
+ });
+
+ this.year.on(BI.YearCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
+ });
+ this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
+ });
+ this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ BI.createWidget({
+ type: "bi.center",
+ element: this,
+ hgap: 5,
+ items: [this.year, this.month]
+ });
+
+ },
+
+ setValue: function (v) {
+ v = v || {};
+ this.month.setValue(v.month);
+ this.year.setValue(v.year);
+ },
+
+ getValue: function () {
+ return {
+ year: this.year.getValue(),
+ month: this.month.getValue()
+ };
+ }
+});
+BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/**
+ * 年份 + 月份下拉框
+ *
+ * @class BI.YearQuarterCombo
+ * @extends BI.Widget
+ */
+BI.YearQuarterCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-quarter-combo",
+ yearBehaviors: {},
+ quarterBehaviors: {},
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.YearQuarterCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.year = BI.createWidget({
+ type: "bi.year_combo",
+ behaviors: o.yearBehaviors
+ });
+
+ this.quarter = BI.createWidget({
+ type: "bi.quarter_combo",
+ behaviors: o.quarterBehaviors
+ });
+
+ this.year.on(BI.YearCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM);
+ });
+ this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM);
+ });
+ this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ BI.createWidget({
+ type: "bi.center",
+ element: this,
+ hgap: 5,
+ items: [this.year, this.quarter]
+ });
+
+ },
+
+ setValue: function (v) {
+ v = v || {};
+ this.quarter.setValue(v.quarter);
+ this.year.setValue(v.year);
+ },
+
+ getValue: function () {
+ return {
+ year: this.year.getValue(),
+ quarter: this.quarter.getValue()
+ };
+ }
+});
+BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AbstractAllValueChooser
+ * @extends BI.Widget
+ */
+BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ perPage: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _valueFormatter: function (v) {
+ var text = v;
+ if (BI.isNotNull(this.items)) {
+ BI.some(this.items, function (i, item) {
+ if (item.value === v) {
+ text = item.text;
+ return true;
+ }
+ });
+ }
+ return text;
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this, o = this.options;
+ if (!o.cache || !this.items) {
+ o.itemsCreator({}, function (items) {
+ self.items = items;
+ call(items);
+ });
+ } else {
+ call(this.items);
+ }
+ function call(items) {
+ var keywords = (options.keywords || []).slice();
+ if (options.keyword) {
+ keywords.push(options.keyword);
+ }
+ BI.each(keywords, function (i, kw) {
+ var search = BI.Func.getSearchResult(items, kw);
+ items = search.matched.concat(search.finded);
+ });
+ if (options.selectedValues) {//过滤
+ var filter = BI.makeObject(options.selectedValues, true);
+ items = BI.filter(items, function (i, ob) {
+ return !filter[ob.value];
+ });
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ callback({
+ items: items
+ });
+ return;
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ callback({count: items.length});
+ return;
+ }
+ callback({
+ items: items,
+ hasNext: false
+ });
+ }
+ }
+});/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AllValueChooserCombo
+ * @extends BI.AbstractAllValueChooser
+ */
+BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-all-value-chooser-combo",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ }
+ this.combo = BI.createWidget({
+ type: 'bi.multi_select_combo',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue({
+ type: BI.Selection.Multi,
+ value: v || []
+ });
+ },
+
+ getValue: function () {
+ var val = this.combo.getValue() || {};
+ if (val.type === BI.Selection.All) {
+ return val.assist;
+ }
+ return val.value || [];
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this, arguments);
+ }
+});
+BI.AllValueChooserCombo.EVENT_CONFIRM = "AllValueChooserCombo.EVENT_CONFIRM";
+BI.shortcut('bi.all_value_chooser_combo', BI.AllValueChooserCombo);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AllValueChooserPane
+ * @extends BI.AbstractAllValueChooser
+ */
+BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-all-value-chooser-pane",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.AllValueChooserPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ }
+ this.list = BI.createWidget({
+ type: 'bi.multi_select_list',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (v) {
+ this.list.setValue({
+ type: BI.Selection.Multi,
+ value: v || []
+ });
+ },
+
+ getValue: function () {
+ var val = this.list.getValue() || {};
+ if (val.type === BI.Selection.All) {
+ return val.assist;
+ }
+ return val.value || [];
+ },
+
+ populate: function () {
+ this.list.populate.apply(this.list, arguments);
+ }
+});
+BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE";
+BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ perPage: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ items: null,
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _initData: function (items) {
+ this.items = items;
+ var nodes = BI.Tree.treeFormat(items);
+ this.tree = new BI.Tree();
+ this.tree.initTree(nodes);
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this, o = this.options;
+ if (!this.items) {
+ o.itemsCreator({}, function (items) {
+ self._initData(items);
+ call();
+ });
+ } else {
+ call();
+ }
+ function call() {
+ switch (options.type) {
+ case BI.TreeView.REQ_TYPE_INIT_DATA:
+ self._reqInitTreeNode(options, callback);
+ break;
+ case BI.TreeView.REQ_TYPE_ADJUST_DATA:
+ self._reqAdjustTreeNode(options, callback);
+ break;
+ case BI.TreeView.REQ_TYPE_SELECT_DATA:
+ self._reqSelectedTreeNode(options, callback);
+ break;
+ case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA:
+ self._reqDisplayTreeNode(options, callback);
+ break;
+ default :
+ self._reqTreeNode(options, callback);
+ break;
+ }
+ }
+ },
+
+ _reqDisplayTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var selectedValues = op.selectedValues;
+
+ if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ callback({});
+ return;
+ }
+
+ doCheck([], this.tree.getRoot(), selectedValues);
+
+ callback({
+ items: result
+ });
+
+ function doCheck(parentValues, node, selected) {
+ if (selected == null || BI.isEmpty(selected)) {
+ BI.each(node.getChildren(), function (i, child) {
+ var newParents = BI.clone(parentValues);
+ newParents.push(child.value);
+ var llen = self._getChildCount(newParents);
+ createOneJson(child, node.id, llen);
+ doCheck(newParents, child, {});
+ });
+ return;
+ }
+ BI.each(selected, function (k) {
+ var node = self._getTreeNode(parentValues, k);
+ var newParents = BI.clone(parentValues);
+ newParents.push(node.value);
+ createOneJson(node, node.parent && node.parent.id, getCount(selected[k], newParents));
+ doCheck(newParents, node, selected[k]);
+ })
+ }
+
+ function getCount(jo, parentValues) {
+ if (jo == null) {
+ return 0;
+ }
+ if (BI.isEmpty(jo)) {
+ return self._getChildCount(parentValues);
+ }
+
+ return BI.size(jo);
+ }
+
+ function createOneJson(node, pId, llen) {
+ result.push({
+ id: node.id,
+ pId: pId,
+ text: node.text + (llen > 0 ? ("(" + BI.i18nText("BI-Basic_Altogether") + llen + BI.i18nText("BI-Basic_Count") + ")") : ""),
+ value: node.value,
+ open: true
+ });
+ }
+ },
+
+ _reqSelectedTreeNode: function (op, callback) {
+ var self = this;
+ var selectedValues = BI.deepClone(op.selectedValues);
+ var notSelectedValue = op.notSelectedValue || {};
+ var keyword = op.keyword || "";
+ var parentValues = op.parentValues || [];
+
+ if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ callback({});
+ return;
+ }
+
+ dealWithSelectedValues(selectedValues);
+ callback(selectedValues);
+
+
+ function dealWithSelectedValues(selectedValues) {
+ var p = parentValues.concat(notSelectedValue);
+ //存储的值中存在这个值就把它删掉
+ //例如选中了中国-江苏-南京, 取消中国或江苏或南京
+ if (canFindKey(selectedValues, p)) {
+ //如果搜索的值在父亲链中
+ if (isSearchValueInParent(p)) {
+ //例如选中了 中国-江苏, 搜索江苏, 取消江苏
+ //例如选中了 中国-江苏, 搜索江苏, 取消中国
+ self._deleteNode(selectedValues, p);
+ } else {
+ var searched = [];
+ var finded = search(parentValues, notSelectedValue, [], searched);
+ if (finded && BI.isNotEmptyArray(searched)) {
+ BI.each(searched, function (i, arr) {
+ var node = self._getNode(selectedValues, arr);
+ if (node) {
+ //例如选中了 中国-江苏-南京,搜索南京,取消中国
+ self._deleteNode(selectedValues, arr);
+ } else {
+ //例如选中了 中国-江苏,搜索南京,取消中国
+ expandSelectedValue(selectedValues, arr, BI.last(arr));
+ }
+ })
+ }
+ }
+ }
+
+ //存储的值中不存在这个值,但父亲节点是全选的情况
+ //例如选中了中国-江苏,取消南京
+ //important 选中了中国-江苏,取消了江苏,但是搜索的是南京
+ if (isChild(selectedValues, p)) {
+ var result = [], finded = false;
+ //如果parentValues中有匹配的值,说明搜索结果不在当前值下
+ if (isSearchValueInParent(p)) {
+ finded = true;
+ } else {
+ //从当前值开始搜
+ finded = search(parentValues, notSelectedValue, result);
+ p = parentValues;
+ }
+
+ if (finded === true) {
+ //去掉点击的节点之后的结果集
+ expandSelectedValue(selectedValues, p, notSelectedValue);
+ //添加去掉搜索的结果集
+ if (result.length > 0) {
+ BI.each(result, function (i, strs) {
+ self._buildTree(selectedValues, strs);
+ })
+ }
+ }
+ }
+
+ }
+
+ function expandSelectedValue(selectedValues, parents, notSelectedValue) {
+ var next = selectedValues;
+ var childrenCount = [];
+ var path = [];
+ //去掉点击的节点之后的结果集
+ BI.some(parents, function (i, v) {
+ var t = next[v];
+ if (t == null) {
+ if (i === 0) {
+ return true;
+ }
+ if (BI.isEmpty(next)) {
+ var split = parents.slice(0, i);
+ var expanded = self._getChildren(split);
+ path.push(split);
+ childrenCount.push(expanded.length);
+ //如果只有一个值且取消的就是这个值
+ if (i === parents.length - 1 && expanded.length === 1 && expanded[0] === notSelectedValue) {
+ for (var j = childrenCount.length - 1; j >= 0; j--) {
+ if (childrenCount[j] === 1) {
+ self._deleteNode(selectedValues, path[j]);
+ } else {
+ break;
+ }
+ }
+ } else {
+ BI.each(expanded, function (m, child) {
+ if (i === parents.length - 1 && child.value === notSelectedValue) {
+ return true;
+ }
+ next[child.value] = {};
+ });
+ }
+ next = next[v];
+ } else {
+ return true;
+ // next = {};
+ // next[v] = {};
+ }
+ } else {
+ next = t;
+ }
+ });
+ }
+
+ function search(parents, current, result, searched) {
+ var newParents = BI.clone(parents);
+ newParents.push(current);
+ if (self._isMatch(current, keyword)) {
+ searched && searched.push(newParents);
+ return true;
+ }
+
+ var children = self._getChildren(newParents);
+
+ var notSearch = [];
+ var can = false;
+
+ BI.each(children, function (i, child) {
+ if (search(newParents, child.value, result, searched)) {
+ can = true;
+ } else {
+ notSearch.push(child.value);
+ }
+ });
+ if (can === true) {
+ BI.each(notSearch, function (i, v) {
+ var next = BI.clone(newParents);
+ next.push(v);
+ result.push(next);
+ });
+ }
+ return can;
+ }
+
+ function isSearchValueInParent(parentValues) {
+ for (var i = 0, len = parentValues.length; i < len; i++) {
+ if (self._isMatch(parentValues[i], keyword)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function canFindKey(selectedValues, parents) {
+ var t = selectedValues;
+ for (var i = 0; i < parents.length; i++) {
+ var v = parents[i];
+ t = t[v];
+ if (t == null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ function isChild(selectedValues, parents) {
+ var t = selectedValues;
+ for (var i = 0; i < parents.length; i++) {
+ var v = parents[i];
+ if (!BI.has(t, v)) {
+ return false;
+ }
+ t = t[v];
+ if (BI.isEmpty(t)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ },
+
+ _reqAdjustTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var selectedValues = op.selectedValues;
+ if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ callback({});
+ return;
+ }
+ BI.each(selectedValues, function (k, v) {
+ result.push([k]);
+ });
+
+ dealWithSelectedValues(selectedValues, []);
+
+ var jo = {};
+ BI.each(result, function (i, strs) {
+ self._buildTree(jo, strs);
+ });
+ callback(jo);
+
+ function dealWithSelectedValues(selected, parents) {
+ if (selected == null || BI.isEmpty(selected)) {
+ return true;
+ }
+ var can = true;
+ BI.each(selected, function (k, v) {
+ var p = BI.clone(parents);
+ p.push(k);
+ if (!dealWithSelectedValues(selected[k], p)) {
+ BI.each(selected[k], function (nk, nv) {
+ var t = BI.clone(p);
+ t.push(nk);
+ result.push(t);
+ });
+ can = false;
+ }
+ });
+ return can && isAllSelected(selected, parents);
+ }
+
+ function isAllSelected(selected, parents) {
+ return BI.isEmpty(selected) || self._getChildCount(parents) === BI.size(selected);
+ }
+ },
+
+ _reqInitTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var keyword = op.keyword || "";
+ var selectedValues = op.selectedValues;
+ var lastSearchValue = op.lastSearchValue || "";
+ var output = search();
+ BI.nextTick(function () {
+ callback({
+ hasNext: output.length > self._const.perPage,
+ items: result,
+ lastSearchValue: BI.last(output)
+ })
+ });
+
+ function search() {
+ var children = self._getChildren([]);
+ var start = children.length;
+ if (lastSearchValue !== "") {
+ for (var j = 0, len = start; j < len; j++) {
+ if (children[j].value === lastSearchValue) {
+ start = j + 1;
+ break;
+ }
+ }
+ } else {
+ start = 0;
+ }
+ var output = [];
+ for (var i = start, len = children.length; i < len; i++) {
+ if (output.length < self._const.perPage) {
+ var find = nodeSearch(1, [], children[i].value, false, result);
+ } else if (output.length === self._const.perPage) {
+ var find = nodeSearch(1, [], children[i].value, false, []);
+ }
+ if (find[0] === true) {
+ output.push(children[i].value);
+ }
+ if (output.length > self._const.perPage) {
+ break;
+ }
+ }
+ return output;
+ }
+
+ function nodeSearch(deep, parentValues, current, isAllSelect, result) {
+ if (self._isMatch(current, keyword)) {
+ var checked = isAllSelect || isSelected(parentValues, current);
+ createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
+ return [true, checked];
+ }
+ var newParents = BI.clone(parentValues);
+ newParents.push(current);
+ var children = self._getChildren(newParents);
+
+ var can = false, checked = false;
+
+ var isCurAllSelected = isAllSelect || isAllSelected(parentValues, current);
+ BI.each(children, function (i, child) {
+ var state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result);
+ if (state[1] === true) {
+ checked = true;
+ }
+ if (state[0] === true) {
+ can = true;
+ }
+ });
+ if (can === true) {
+ checked = isCurAllSelected || (isSelected(parentValues, current) && checked);
+ createOneJson(parentValues, current, true, checked, false, false, result);
+ }
+ return [can, checked];
+ }
+
+ function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
+ var node = self._getTreeNode(parentValues, value)
+ result.push({
+ id: node.id,
+ pId: node.pId,
+ text: node.text,
+ value: node.value,
+ title: node.title,
+ isParent: node.getChildrenLength() > 0,
+ open: isOpen,
+ checked: checked,
+ halfCheck: half,
+ flag: flag
+ });
+ }
+
+ function isHalf(parentValues, value) {
+ var find = findSelectedObj(parentValues);
+ if (find == null) {
+ return null;
+ }
+ return BI.any(find, function (v, ob) {
+ if (v === value) {
+ if (ob != null && !BI.isEmpty(ob)) {
+ return true;
+ }
+ }
+ });
+ }
+
+ function isAllSelected(parentValues, value) {
+ var find = findSelectedObj(parentValues);
+ if (find == null) {
+ return null;
+ }
+ return BI.any(find, function (v, ob) {
+ if (v === value) {
+ if (ob != null && BI.isEmpty(ob)) {
+ return true;
+ }
+ }
+ });
+ }
+
+ function isSelected(parentValues, value) {
+ var find = findSelectedObj(parentValues);
+ if (find == null) {
+ return false;
+ }
+ return BI.any(find, function (v) {
+ if (v === value) {
+ return true;
+ }
+ });
+ }
+
+ function findSelectedObj(parentValues) {
+ var find = selectedValues;
+ if (find == null) {
+ return null;
+ }
+ BI.every(parentValues, function (i, v) {
+ find = find[v];
+ if (find == null) {
+ return false;
+ }
+ return true;
+ });
+ return find;
+ }
+ },
+
+ _reqTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var times = op.times;
+ var checkState = op.checkState || {};
+ var parentValues = op.parentValues || [];
+ var selectedValues = op.selectedValues || {};
+ var valueMap = {};
+ // if (judgeState(parentValues, selectedValues, checkState)) {
+ valueMap = dealWidthSelectedValue(parentValues, selectedValues);
+ // }
+ var nodes = this._getChildren(parentValues);
+ for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) {
+ var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState);
+ result.push({
+ id: nodes[i].id,
+ pId: nodes[i].pId,
+ value: nodes[i].value,
+ text: nodes[i].text,
+ times: 1,
+ isParent: nodes[i].getChildrenLength() > 0,
+ checked: state[0],
+ halfCheck: state[1]
+ })
+ }
+ BI.nextTick(function () {
+ callback({
+ items: result,
+ hasNext: nodes.length > times * self._const.perPage
+ });
+ });
+
+ function judgeState(parentValues, selected_value, checkState) {
+ var checked = checkState.checked, half = checkState.half;
+ if (parentValues.length > 0 && !checked) {
+ return false;
+ }
+ return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value));
+ }
+
+ function dealWidthSelectedValue(parentValues, selectedValues) {
+ var valueMap = {};
+ BI.each(parentValues, function (i, v) {
+ selectedValues = selectedValues[v] || {};
+ });
+ BI.each(selectedValues, function (value, obj) {
+ if (BI.isNull(obj)) {
+ valueMap[value] = [0, 0];
+ return;
+ }
+ if (BI.isEmpty(obj)) {
+ valueMap[value] = [2, 0];
+ return;
+ }
+ var nextNames = {};
+ BI.each(obj, function (t, o) {
+ if (BI.isNull(o) || BI.isEmpty(o)) {
+ nextNames[t] = true;
+ }
+ });
+ valueMap[value] = [1, BI.size(nextNames)];
+ });
+ return valueMap;
+ }
+
+ function getCheckState(current, parentValues, valueMap, checkState) {
+ var checked = checkState.checked, half = checkState.half;
+ var tempCheck = false, halfCheck = false;
+ if (BI.has(valueMap, current)) {
+ //可能是半选
+ if (valueMap[current][0] === 1) {
+ var values = BI.clone(parentValues);
+ values.push(current);
+ var childCount = self._getChildCount(values);
+ if (childCount > 0 && childCount !== valueMap[current][1]) {
+ halfCheck = true;
+ }
+ } else if (valueMap[current][0] === 2) {
+ tempCheck = true;
+ }
+ }
+ var check;
+ if (!checked && !halfCheck && !tempCheck) {
+ check = BI.has(valueMap, current);
+ } else {
+ check = ((tempCheck || checked) && !half) || BI.has(valueMap, current);
+ }
+ return [check, halfCheck];
+ }
+ },
+
+ _getNode: function (selectedValues, parentValues) {
+ var pNode = selectedValues;
+ for (var i = 0, len = parentValues.length; i < len; i++) {
+ if (pNode == null) {
+ return null;
+ }
+ pNode = pNode[parentValues[i]];
+ }
+ return pNode;
+ },
+
+ _deleteNode: function (selectedValues, values) {
+ var name = values[values.length - 1];
+ var p = values.slice(0, values.length - 1);
+ var pNode = this._getNode(selectedValues, p);
+ if (pNode != null && pNode[name]) {
+ delete pNode[name];
+ //递归删掉空父节点
+ while (p.length > 0 && BI.isEmpty(pNode)) {
+ name = p[p.length - 1];
+ p = p.slice(0, p.length - 1);
+ pNode = this._getNode(selectedValues, p);
+ if (pNode != null) {
+ delete pNode[name];
+ }
+ }
+ }
+ },
+
+ _buildTree: function (jo, values) {
+ var t = jo;
+ BI.each(values, function (i, v) {
+ if (!BI.has(t, v)) {
+ t[v] = {};
+ }
+ t = t[v];
+ });
+ },
+
+ _isMatch: function (value, keyword) {
+ var finded = BI.Func.getSearchResult([value], keyword);
+ return finded.finded.length > 0 || finded.matched.length > 0;
+ },
+
+ _getTreeNode: function (parentValues, v) {
+ var self = this;
+ var findedParentNode;
+ var index = 0;
+ this.tree.traverse(function (node) {
+ if (self.tree.isRoot(node)) {
+ return;
+ }
+ if (index > parentValues.length) {
+ return false;
+ }
+ if (index === parentValues.length && node.value === v) {
+ findedParentNode = node;
+ return false;
+ }
+ if (node.value === parentValues[index]) {
+ index++;
+ return;
+ }
+ return true;
+ });
+ return findedParentNode;
+ },
+
+ _getChildren: function (parentValues) {
+ if (parentValues.length > 0) {
+ var value = BI.last(parentValues);
+ var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value);
+ } else {
+ var parent = this.tree.getRoot();
+ }
+ return parent.getChildren();
+ },
+
+ _getChildCount: function (parentValues) {
+ return this._getChildren(parentValues).length;
+ }
+});/**
+ * 简单的复选下拉树控件, 适用于数据量少的情况
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.TreeValueChooserCombo
+ * @extends BI.Widget
+ */
+BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-tree-value-chooser-combo",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.TreeValueChooserCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this._initData(o.items);
+ }
+ this.combo = BI.createWidget({
+ type: 'bi.multi_tree_combo',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ },
+
+ getValue: function () {
+ return this.combo.getValue();
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+BI.TreeValueChooserCombo.EVENT_CONFIRM = "TreeValueChooserCombo.EVENT_CONFIRM";
+BI.shortcut('bi.tree_value_chooser_combo', BI.TreeValueChooserCombo);/**
+ * 简单的复选下拉树控件, 适用于数据量少的情况
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.TreeValueChooserPane
+ * @extends BI.AbstractTreeValueChooser
+ */
+BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-tree-value-chooser-pane",
+ items: null,
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.TreeValueChooserPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.pane = BI.createWidget({
+ type: 'bi.multi_select_tree',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this)
+ });
+
+ this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE);
+ });
+ if (BI.isNotNull(o.items)) {
+ this._initData(o.items);
+ this.populate();
+ }
+ },
+
+ setSelectedValue: function (v) {
+ this.pane.setSelectedValue(v);
+ },
+
+ setValue: function (v) {
+ this.pane.setValue(v);
+ },
+
+ getValue: function () {
+ return this.pane.getValue();
+ },
+
+ populate: function () {
+ this.pane.populate.apply(this.pane, arguments);
+ }
+});
+BI.TreeValueChooserPane.EVENT_CHANGE = "TreeValueChooserPane.EVENT_CHANGE";
+BI.shortcut('bi.tree_value_chooser_pane', BI.TreeValueChooserPane);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AbstractValueChooser
+ * @extends BI.Widget
+ */
+BI.AbstractValueChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ perPage: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _valueFormatter: function (v) {
+ var text = v;
+ if (BI.isNotNull(this.items)) {
+ BI.some(this.items, function (i, item) {
+ if (item.value === v) {
+ text = item.text;
+ return true;
+ }
+ });
+ }
+ return text;
+ },
+
+ _getItemsByTimes: function (items, times) {
+ var res = [];
+ for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
+ res.push(items[i]);
+ }
+ return res;
+ },
+
+ _hasNextByTimes: function (items, times) {
+ return times * this._const.perPage < items.length;
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this, o = this.options;
+ if (!o.cache || !this.items) {
+ o.itemsCreator({}, function (items) {
+ self.items = items;
+ call(items);
+ });
+ } else {
+ call(this.items);
+ }
+ function call(items) {
+ var keywords = (options.keywords || []).slice();
+ if (options.keyword) {
+ keywords.push(options.keyword);
+ }
+ BI.each(keywords, function (i, kw) {
+ var search = BI.Func.getSearchResult(items, kw);
+ items = search.matched.concat(search.finded);
+ });
+ if (options.selectedValues) {//过滤
+ var filter = BI.makeObject(options.selectedValues, true);
+ items = BI.filter(items, function (i, ob) {
+ return !filter[ob.value];
+ });
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ callback({
+ items: items
+ });
+ return;
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ callback({count: items.length});
+ return;
+ }
+ callback({
+ items: self._getItemsByTimes(items, options.times),
+ hasNext: self._hasNextByTimes(items, options.times)
+ });
+ }
+ }
+});/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.ValueChooserCombo
+ * @extends BI.Widget
+ */
+BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-value-chooser-combo",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.ValueChooserCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ }
+ this.combo = BI.createWidget({
+ type: 'bi.multi_select_combo',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ },
+
+ getValue: function () {
+ var val = this.combo.getValue() || {};
+ return {
+ type: val.type,
+ value: val.value
+ }
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this, arguments);
+ }
+});
+BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM";
+BI.shortcut('bi.value_chooser_combo', BI.ValueChooserCombo);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.ValueChooserPane
+ * @extends BI.Widget
+ */
+BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-value-chooser-pane",
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.ValueChooserPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.list = BI.createWidget({
+ type: 'bi.multi_select_list',
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this)
+ });
+
+ this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE);
+ });
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ this.populate();
+ }
+ },
+
+ setValue: function (v) {
+ this.list.setValue(v);
+ },
+
+ getValue: function () {
+ var val = this.list.getValue() || {};
+ return {
+ type: val.type,
+ value: val.value
+ }
+ },
+
+ populate: function () {
+ this.list.populate.apply(this.list, arguments);
+ }
+});
+BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.value_chooser_pane', BI.ValueChooserPane);
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 000000000..7653e6612
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,1776 @@
+{
+ "name": "fineui",
+ "version": "1.0.0",
+ "lockfileVersion": 1,
+ "dependencies": {
+ "abbrev": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz",
+ "integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=",
+ "dev": true
+ },
+ "accepts": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz",
+ "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=",
+ "dev": true
+ },
+ "ajv": {
+ "version": "4.11.8",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz",
+ "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=",
+ "dev": true,
+ "optional": true
+ },
+ "align-text": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz",
+ "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=",
+ "dev": true
+ },
+ "amdefine": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
+ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
+ "dev": true
+ },
+ "ansi-regex": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
+ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
+ "dev": true
+ },
+ "ansi-styles": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
+ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
+ "dev": true
+ },
+ "argparse": {
+ "version": "1.0.9",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz",
+ "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=",
+ "dev": true
+ },
+ "array-find-index": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz",
+ "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=",
+ "dev": true
+ },
+ "array-flatten": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
+ "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=",
+ "dev": true
+ },
+ "asap": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
+ "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=",
+ "dev": true,
+ "optional": true
+ },
+ "asn1": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
+ "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=",
+ "dev": true,
+ "optional": true
+ },
+ "assert-plus": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
+ "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=",
+ "dev": true,
+ "optional": true
+ },
+ "async": {
+ "version": "1.5.2",
+ "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
+ "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=",
+ "dev": true
+ },
+ "asynckit": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
+ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
+ "dev": true,
+ "optional": true
+ },
+ "aws-sign2": {
+ "version": "0.6.0",
+ "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz",
+ "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=",
+ "dev": true,
+ "optional": true
+ },
+ "aws4": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz",
+ "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=",
+ "dev": true,
+ "optional": true
+ },
+ "balanced-match": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+ "dev": true
+ },
+ "bcrypt-pbkdf": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz",
+ "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=",
+ "dev": true,
+ "optional": true
+ },
+ "body-parser": {
+ "version": "1.14.2",
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.14.2.tgz",
+ "integrity": "sha1-EBXLH+LEQ4WCWVgdtTMy+NDPUPk=",
+ "dev": true,
+ "dependencies": {
+ "debug": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
+ "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=",
+ "dev": true
+ },
+ "http-errors": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.3.1.tgz",
+ "integrity": "sha1-GX4izevUGYWF6GlO9nhhl7ke2UI=",
+ "dev": true
+ },
+ "iconv-lite": {
+ "version": "0.4.13",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz",
+ "integrity": "sha1-H4irpKsLFQjoMSrMOTRfNumS4vI=",
+ "dev": true
+ },
+ "ms": {
+ "version": "0.7.1",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz",
+ "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=",
+ "dev": true
+ },
+ "qs": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-5.2.0.tgz",
+ "integrity": "sha1-qfMRQq9GjLcrJbMBNrokVoNJFr4=",
+ "dev": true
+ }
+ }
+ },
+ "boom": {
+ "version": "2.10.1",
+ "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz",
+ "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=",
+ "dev": true
+ },
+ "brace-expansion": {
+ "version": "1.1.8",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
+ "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
+ "dev": true
+ },
+ "browserify-zlib": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz",
+ "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=",
+ "dev": true
+ },
+ "builtin-modules": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
+ "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
+ "dev": true
+ },
+ "bytes": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.2.0.tgz",
+ "integrity": "sha1-/TVGSkA/b5EXwt42Cez/nK4ABYg=",
+ "dev": true
+ },
+ "camelcase": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz",
+ "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=",
+ "dev": true
+ },
+ "camelcase-keys": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz",
+ "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=",
+ "dev": true
+ },
+ "caseless": {
+ "version": "0.12.0",
+ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
+ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=",
+ "dev": true,
+ "optional": true
+ },
+ "center-align": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz",
+ "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=",
+ "dev": true
+ },
+ "chalk": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
+ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
+ "dev": true
+ },
+ "clean-css": {
+ "version": "3.4.28",
+ "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.28.tgz",
+ "integrity": "sha1-vxlF6C/ICPVWlebd6uwBQA79A/8=",
+ "dev": true,
+ "dependencies": {
+ "source-map": {
+ "version": "0.4.4",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
+ "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=",
+ "dev": true
+ }
+ }
+ },
+ "cli": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz",
+ "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=",
+ "dev": true,
+ "dependencies": {
+ "glob": {
+ "version": "7.1.2",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
+ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
+ "dev": true
+ }
+ }
+ },
+ "cliui": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
+ "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=",
+ "dev": true
+ },
+ "co": {
+ "version": "4.6.0",
+ "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
+ "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
+ "dev": true,
+ "optional": true
+ },
+ "coffee-script": {
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.10.0.tgz",
+ "integrity": "sha1-EpOLz5vhlI+gBvkuDEyegXBRCMA=",
+ "dev": true
+ },
+ "colors": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz",
+ "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=",
+ "dev": true
+ },
+ "combined-stream": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz",
+ "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=",
+ "dev": true
+ },
+ "commander": {
+ "version": "2.8.1",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
+ "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=",
+ "dev": true
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+ "dev": true
+ },
+ "concat-stream": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz",
+ "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=",
+ "dev": true
+ },
+ "console-browserify": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz",
+ "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=",
+ "dev": true
+ },
+ "content-disposition": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
+ "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=",
+ "dev": true
+ },
+ "content-type": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz",
+ "integrity": "sha1-t9ETrueo3Se9IRM8TcJSnfFyHu0=",
+ "dev": true
+ },
+ "cookie": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
+ "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=",
+ "dev": true
+ },
+ "cookie-signature": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
+ "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=",
+ "dev": true
+ },
+ "core-util-is": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
+ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
+ "dev": true
+ },
+ "cryptiles": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz",
+ "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=",
+ "dev": true,
+ "optional": true
+ },
+ "currently-unhandled": {
+ "version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz",
+ "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=",
+ "dev": true
+ },
+ "dashdash": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
+ "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
+ "dev": true,
+ "optional": true,
+ "dependencies": {
+ "assert-plus": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
+ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "date-now": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
+ "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=",
+ "dev": true
+ },
+ "dateformat": {
+ "version": "1.0.12",
+ "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz",
+ "integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=",
+ "dev": true
+ },
+ "debug": {
+ "version": "2.6.7",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.7.tgz",
+ "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=",
+ "dev": true
+ },
+ "decamelize": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
+ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=",
+ "dev": true
+ },
+ "delayed-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
+ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
+ "dev": true
+ },
+ "depd": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz",
+ "integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=",
+ "dev": true
+ },
+ "destroy": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
+ "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=",
+ "dev": true
+ },
+ "dom-serializer": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz",
+ "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=",
+ "dev": true,
+ "dependencies": {
+ "domelementtype": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz",
+ "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=",
+ "dev": true
+ },
+ "entities": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz",
+ "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=",
+ "dev": true
+ }
+ }
+ },
+ "domelementtype": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz",
+ "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=",
+ "dev": true
+ },
+ "domhandler": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz",
+ "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=",
+ "dev": true
+ },
+ "domutils": {
+ "version": "1.5.1",
+ "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz",
+ "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=",
+ "dev": true
+ },
+ "ecc-jsbn": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
+ "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=",
+ "dev": true,
+ "optional": true
+ },
+ "ee-first": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
+ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=",
+ "dev": true
+ },
+ "encodeurl": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz",
+ "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=",
+ "dev": true
+ },
+ "entities": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz",
+ "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=",
+ "dev": true
+ },
+ "errno": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz",
+ "integrity": "sha1-uJbiOp5ei6M4cfyZar02NfyaHH0=",
+ "dev": true,
+ "optional": true
+ },
+ "error-ex": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz",
+ "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=",
+ "dev": true
+ },
+ "escape-html": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
+ "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=",
+ "dev": true
+ },
+ "escape-string-regexp": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
+ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
+ "dev": true
+ },
+ "esprima": {
+ "version": "2.7.3",
+ "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz",
+ "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=",
+ "dev": true
+ },
+ "etag": {
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.0.tgz",
+ "integrity": "sha1-b2Ma7zNtbEY2K1F2QETOIWvjwFE=",
+ "dev": true
+ },
+ "eventemitter2": {
+ "version": "0.4.14",
+ "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz",
+ "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=",
+ "dev": true
+ },
+ "exit": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz",
+ "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=",
+ "dev": true
+ },
+ "express": {
+ "version": "4.15.3",
+ "resolved": "https://registry.npmjs.org/express/-/express-4.15.3.tgz",
+ "integrity": "sha1-urZdDwOqgMNYQIly/HAPkWlEtmI=",
+ "dev": true
+ },
+ "extend": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz",
+ "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=",
+ "dev": true,
+ "optional": true
+ },
+ "extsprintf": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz",
+ "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=",
+ "dev": true
+ },
+ "faye-websocket": {
+ "version": "0.10.0",
+ "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.10.0.tgz",
+ "integrity": "sha1-TkkvjQTftviQA1B/btvy1QHnxvQ=",
+ "dev": true
+ },
+ "figures": {
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz",
+ "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=",
+ "dev": true
+ },
+ "finalhandler": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.0.3.tgz",
+ "integrity": "sha1-70fneVDpmXgOhgIqVg4yF+DQzIk=",
+ "dev": true
+ },
+ "find-up": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz",
+ "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=",
+ "dev": true
+ },
+ "findup-sync": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz",
+ "integrity": "sha1-N5MKpdgWt3fANEXhlmzGeQpMCxY=",
+ "dev": true,
+ "dependencies": {
+ "glob": {
+ "version": "5.0.15",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz",
+ "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=",
+ "dev": true
+ }
+ }
+ },
+ "forever-agent": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
+ "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=",
+ "dev": true,
+ "optional": true
+ },
+ "form-data": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz",
+ "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=",
+ "dev": true,
+ "optional": true
+ },
+ "forwarded": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz",
+ "integrity": "sha1-Ge+YdMSuHCl7zweP3mOgm2aoQ2M=",
+ "dev": true
+ },
+ "fresh": {
+ "version": "0.5.0",
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.0.tgz",
+ "integrity": "sha1-9HTKXmqSRtb9jglTz6m5yAWvp44=",
+ "dev": true
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
+ "dev": true
+ },
+ "gaze": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/gaze/-/gaze-1.1.2.tgz",
+ "integrity": "sha1-hHIkZ3rbiHDWeSV+0ziP22HkAQU=",
+ "dev": true
+ },
+ "get-stdin": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz",
+ "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=",
+ "dev": true
+ },
+ "getobject": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz",
+ "integrity": "sha1-BHpEl4n6Fg0Bj1SG7ZEyC27HiFw=",
+ "dev": true
+ },
+ "getpass": {
+ "version": "0.1.7",
+ "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
+ "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
+ "dev": true,
+ "optional": true,
+ "dependencies": {
+ "assert-plus": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
+ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "glob": {
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.6.tgz",
+ "integrity": "sha1-IRuvr0nlJbjNkyYNFKsTYVKz9Xo=",
+ "dev": true
+ },
+ "globule": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.0.tgz",
+ "integrity": "sha1-HcScaCLdnoovoAuiopUAboZkvQk=",
+ "dev": true,
+ "dependencies": {
+ "glob": {
+ "version": "7.1.2",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
+ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
+ "dev": true
+ },
+ "lodash": {
+ "version": "4.17.4",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
+ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=",
+ "dev": true
+ }
+ }
+ },
+ "graceful-fs": {
+ "version": "4.1.11",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
+ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
+ "dev": true
+ },
+ "graceful-readlink": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
+ "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=",
+ "dev": true
+ },
+ "grunt": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/grunt/-/grunt-1.0.1.tgz",
+ "integrity": "sha1-6HeHZOlEsY8yuw8QuQeEdcnftWs=",
+ "dev": true,
+ "dependencies": {
+ "grunt-cli": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/grunt-cli/-/grunt-cli-1.2.0.tgz",
+ "integrity": "sha1-VisRnrsGndtGSs4oRVAb6Xs1tqg=",
+ "dev": true
+ }
+ }
+ },
+ "grunt-contrib-concat": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/grunt-contrib-concat/-/grunt-contrib-concat-1.0.1.tgz",
+ "integrity": "sha1-YVCYYwhOhx1+ht5IwBUlntl3Rb0=",
+ "dev": true
+ },
+ "grunt-contrib-cssmin": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-1.0.2.tgz",
+ "integrity": "sha1-FzTL09hMpzZHWLflj/GOUqpgu3Y=",
+ "dev": true
+ },
+ "grunt-contrib-jshint": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/grunt-contrib-jshint/-/grunt-contrib-jshint-1.1.0.tgz",
+ "integrity": "sha1-Np2QmyWTxA6L55lAshNAhQx5Oaw=",
+ "dev": true
+ },
+ "grunt-contrib-less": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/grunt-contrib-less/-/grunt-contrib-less-1.4.1.tgz",
+ "integrity": "sha1-O73sC3XRLOqlXWKUNiXAsIYc328=",
+ "dev": true,
+ "dependencies": {
+ "async": {
+ "version": "2.5.0",
+ "resolved": "https://registry.npmjs.org/async/-/async-2.5.0.tgz",
+ "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==",
+ "dev": true
+ },
+ "lodash": {
+ "version": "4.17.4",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
+ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=",
+ "dev": true
+ }
+ }
+ },
+ "grunt-contrib-uglify": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-1.0.2.tgz",
+ "integrity": "sha1-rmekb5FT7dTLEYE6Vetpxw19svs=",
+ "dev": true,
+ "dependencies": {
+ "lodash": {
+ "version": "4.17.4",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
+ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=",
+ "dev": true
+ }
+ }
+ },
+ "grunt-contrib-watch": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/grunt-contrib-watch/-/grunt-contrib-watch-1.0.0.tgz",
+ "integrity": "sha1-hKGnodar0m7VaEE0lscxM+mQAY8=",
+ "dev": true
+ },
+ "grunt-known-options": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-1.1.0.tgz",
+ "integrity": "sha1-pCdO6zL6dl2lp6OxcSYXzjsUQUk=",
+ "dev": true
+ },
+ "grunt-legacy-log": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-1.0.0.tgz",
+ "integrity": "sha1-+4bxgJhHvAfcR4Q/ns1srLYt8tU=",
+ "dev": true
+ },
+ "grunt-legacy-log-utils": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-1.0.0.tgz",
+ "integrity": "sha1-p7ji0Ps1taUPSvmG/BEnSevJbz0=",
+ "dev": true,
+ "dependencies": {
+ "lodash": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.3.0.tgz",
+ "integrity": "sha1-79nEpuxT87BUEkKZFcPkgk5NJaQ=",
+ "dev": true
+ }
+ }
+ },
+ "grunt-legacy-util": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-1.0.0.tgz",
+ "integrity": "sha1-OGqnjcbtUJhsKxiVcmWxtIq7m4Y=",
+ "dev": true,
+ "dependencies": {
+ "lodash": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.3.0.tgz",
+ "integrity": "sha1-79nEpuxT87BUEkKZFcPkgk5NJaQ=",
+ "dev": true
+ }
+ }
+ },
+ "gzip-size": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-1.0.0.tgz",
+ "integrity": "sha1-Zs+LEBBHInuVus5uodoMF37Vwi8=",
+ "dev": true
+ },
+ "har-schema": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz",
+ "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=",
+ "dev": true,
+ "optional": true
+ },
+ "har-validator": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz",
+ "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=",
+ "dev": true,
+ "optional": true
+ },
+ "has-ansi": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
+ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
+ "dev": true
+ },
+ "hawk": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz",
+ "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=",
+ "dev": true,
+ "optional": true
+ },
+ "hoek": {
+ "version": "2.16.3",
+ "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz",
+ "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=",
+ "dev": true
+ },
+ "hooker": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz",
+ "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=",
+ "dev": true
+ },
+ "hosted-git-info": {
+ "version": "2.5.0",
+ "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz",
+ "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==",
+ "dev": true
+ },
+ "htmlparser2": {
+ "version": "3.8.3",
+ "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz",
+ "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=",
+ "dev": true,
+ "dependencies": {
+ "isarray": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
+ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
+ "dev": true
+ },
+ "readable-stream": {
+ "version": "1.1.14",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
+ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
+ "dev": true
+ },
+ "string_decoder": {
+ "version": "0.10.31",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
+ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
+ "dev": true
+ }
+ }
+ },
+ "http-errors": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.1.tgz",
+ "integrity": "sha1-X4uO2YrKVFZWv1cplzh/kEpyIlc=",
+ "dev": true
+ },
+ "http-signature": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz",
+ "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=",
+ "dev": true,
+ "optional": true
+ },
+ "iconv-lite": {
+ "version": "0.4.18",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.18.tgz",
+ "integrity": "sha512-sr1ZQph3UwHTR0XftSbK85OvBbxe/abLGzEnPENCQwmHf7sck8Oyu4ob3LgBxWWxRoM+QszeUyl7jbqapu2TqA==",
+ "dev": true
+ },
+ "image-size": {
+ "version": "0.5.5",
+ "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz",
+ "integrity": "sha1-Cd/Uq50g4p6xw+gLiZA3jfnjy5w=",
+ "dev": true,
+ "optional": true
+ },
+ "indent-string": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz",
+ "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=",
+ "dev": true
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+ "dev": true
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
+ "dev": true
+ },
+ "ipaddr.js": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.3.0.tgz",
+ "integrity": "sha1-HgOlL9rYOou7KyXL9JmLTP/NPew=",
+ "dev": true
+ },
+ "is-arrayish": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
+ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=",
+ "dev": true
+ },
+ "is-buffer": {
+ "version": "1.1.5",
+ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz",
+ "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=",
+ "dev": true
+ },
+ "is-builtin-module": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz",
+ "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=",
+ "dev": true
+ },
+ "is-finite": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz",
+ "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=",
+ "dev": true
+ },
+ "is-typedarray": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
+ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
+ "dev": true,
+ "optional": true
+ },
+ "is-utf8": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
+ "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
+ "dev": true
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
+ "dev": true
+ },
+ "isexe": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
+ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
+ "dev": true
+ },
+ "isstream": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
+ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
+ "dev": true,
+ "optional": true
+ },
+ "js-yaml": {
+ "version": "3.5.5",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.5.5.tgz",
+ "integrity": "sha1-A3fDgBfKvHMisNH7zSWkkWQfL74=",
+ "dev": true
+ },
+ "jsbn": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
+ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
+ "dev": true,
+ "optional": true
+ },
+ "jshint": {
+ "version": "2.9.5",
+ "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.5.tgz",
+ "integrity": "sha1-HnJSkVzmgbQIJ+4UJIxG006apiw=",
+ "dev": true,
+ "dependencies": {
+ "lodash": {
+ "version": "3.7.0",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.7.0.tgz",
+ "integrity": "sha1-Nni9irmVBXwHreg27S7wh9qBHUU=",
+ "dev": true
+ }
+ }
+ },
+ "json-schema": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
+ "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=",
+ "dev": true,
+ "optional": true
+ },
+ "json-stable-stringify": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz",
+ "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=",
+ "dev": true,
+ "optional": true
+ },
+ "json-stringify-safe": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
+ "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
+ "dev": true,
+ "optional": true
+ },
+ "jsonify": {
+ "version": "0.0.0",
+ "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
+ "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
+ "dev": true,
+ "optional": true
+ },
+ "jsprim": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz",
+ "integrity": "sha1-o7h+QCmNjDgFUtjMdiigu5WiKRg=",
+ "dev": true,
+ "optional": true,
+ "dependencies": {
+ "assert-plus": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
+ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "kind-of": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
+ "dev": true
+ },
+ "lazy-cache": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz",
+ "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=",
+ "dev": true
+ },
+ "less": {
+ "version": "2.7.2",
+ "resolved": "https://registry.npmjs.org/less/-/less-2.7.2.tgz",
+ "integrity": "sha1-No1sxz4fsDmBGDKAkYdDxdz5s98=",
+ "dev": true
+ },
+ "livereload-js": {
+ "version": "2.2.2",
+ "resolved": "https://registry.npmjs.org/livereload-js/-/livereload-js-2.2.2.tgz",
+ "integrity": "sha1-bIclfmSKtHW8JOoldFftzB+NC8I=",
+ "dev": true
+ },
+ "load-json-file": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
+ "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
+ "dev": true
+ },
+ "lodash": {
+ "version": "3.10.1",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz",
+ "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=",
+ "dev": true
+ },
+ "longest": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
+ "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=",
+ "dev": true
+ },
+ "loud-rejection": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz",
+ "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=",
+ "dev": true
+ },
+ "map-obj": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz",
+ "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=",
+ "dev": true
+ },
+ "maxmin": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/maxmin/-/maxmin-1.1.0.tgz",
+ "integrity": "sha1-cTZehKmd2Piz99X94vANHn9zvmE=",
+ "dev": true
+ },
+ "media-typer": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
+ "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
+ "dev": true
+ },
+ "meow": {
+ "version": "3.7.0",
+ "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz",
+ "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=",
+ "dev": true
+ },
+ "merge-descriptors": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
+ "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=",
+ "dev": true
+ },
+ "methods": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
+ "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=",
+ "dev": true
+ },
+ "mime": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz",
+ "integrity": "sha1-EV+eO2s9rylZmDyzjxSaLUDrXVM=",
+ "dev": true
+ },
+ "mime-db": {
+ "version": "1.27.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz",
+ "integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=",
+ "dev": true
+ },
+ "mime-types": {
+ "version": "2.1.15",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz",
+ "integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=",
+ "dev": true
+ },
+ "minimatch": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
+ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+ "dev": true
+ },
+ "minimist": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+ "dev": true
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
+ "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "dev": true,
+ "optional": true,
+ "dependencies": {
+ "minimist": {
+ "version": "0.0.8",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
+ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
+ "dev": true
+ },
+ "negotiator": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
+ "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=",
+ "dev": true
+ },
+ "nopt": {
+ "version": "3.0.6",
+ "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz",
+ "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=",
+ "dev": true
+ },
+ "normalize-package-data": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
+ "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==",
+ "dev": true
+ },
+ "number-is-nan": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
+ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
+ "dev": true
+ },
+ "oauth-sign": {
+ "version": "0.8.2",
+ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
+ "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=",
+ "dev": true,
+ "optional": true
+ },
+ "object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
+ "dev": true
+ },
+ "on-finished": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
+ "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
+ "dev": true
+ },
+ "once": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
+ "dev": true
+ },
+ "open": {
+ "version": "0.0.5",
+ "resolved": "https://registry.npmjs.org/open/-/open-0.0.5.tgz",
+ "integrity": "sha1-QsPhjslUZra/DcQvOilFw/DK2Pw=",
+ "dev": true
+ },
+ "pako": {
+ "version": "0.2.9",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
+ "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=",
+ "dev": true
+ },
+ "parse-json": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
+ "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
+ "dev": true
+ },
+ "parseurl": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz",
+ "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=",
+ "dev": true
+ },
+ "path-exists": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
+ "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=",
+ "dev": true
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
+ "dev": true
+ },
+ "path-to-regexp": {
+ "version": "0.1.7",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
+ "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=",
+ "dev": true
+ },
+ "path-type": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz",
+ "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=",
+ "dev": true
+ },
+ "performance-now": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz",
+ "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=",
+ "dev": true,
+ "optional": true
+ },
+ "pify": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
+ "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
+ "dev": true
+ },
+ "pinkie": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz",
+ "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=",
+ "dev": true
+ },
+ "pinkie-promise": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz",
+ "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=",
+ "dev": true
+ },
+ "pretty-bytes": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz",
+ "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=",
+ "dev": true
+ },
+ "process-nextick-args": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
+ "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=",
+ "dev": true
+ },
+ "promise": {
+ "version": "7.3.1",
+ "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
+ "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
+ "dev": true,
+ "optional": true
+ },
+ "proxy-addr": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.4.tgz",
+ "integrity": "sha1-J+VF9pYKRKYn2bREZ+NcG2tM4vM=",
+ "dev": true
+ },
+ "prr": {
+ "version": "0.0.0",
+ "resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz",
+ "integrity": "sha1-GoS4WQgyVQFBGFPQCB7j+obikmo=",
+ "dev": true,
+ "optional": true
+ },
+ "punycode": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
+ "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
+ "dev": true,
+ "optional": true
+ },
+ "qs": {
+ "version": "6.4.0",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz",
+ "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=",
+ "dev": true
+ },
+ "range-parser": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
+ "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=",
+ "dev": true
+ },
+ "raw-body": {
+ "version": "2.1.7",
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.1.7.tgz",
+ "integrity": "sha1-rf6s4uT7MJgFgBTQjActzFl1h3Q=",
+ "dev": true,
+ "dependencies": {
+ "bytes": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz",
+ "integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk=",
+ "dev": true
+ },
+ "iconv-lite": {
+ "version": "0.4.13",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz",
+ "integrity": "sha1-H4irpKsLFQjoMSrMOTRfNumS4vI=",
+ "dev": true
+ }
+ }
+ },
+ "read-pkg": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
+ "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=",
+ "dev": true
+ },
+ "read-pkg-up": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz",
+ "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=",
+ "dev": true
+ },
+ "readable-stream": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
+ "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
+ "dev": true
+ },
+ "redent": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz",
+ "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=",
+ "dev": true
+ },
+ "repeat-string": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
+ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=",
+ "dev": true
+ },
+ "repeating": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz",
+ "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=",
+ "dev": true
+ },
+ "request": {
+ "version": "2.81.0",
+ "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz",
+ "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=",
+ "dev": true,
+ "optional": true
+ },
+ "resolve": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz",
+ "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=",
+ "dev": true
+ },
+ "right-align": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz",
+ "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=",
+ "dev": true
+ },
+ "rimraf": {
+ "version": "2.2.8",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz",
+ "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=",
+ "dev": true
+ },
+ "safe-buffer": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
+ "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
+ "dev": true
+ },
+ "semver": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
+ "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=",
+ "dev": true
+ },
+ "send": {
+ "version": "0.15.3",
+ "resolved": "https://registry.npmjs.org/send/-/send-0.15.3.tgz",
+ "integrity": "sha1-UBP5+ZAj31DRvZiSwZ4979HVMwk=",
+ "dev": true
+ },
+ "serve-static": {
+ "version": "1.12.3",
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.12.3.tgz",
+ "integrity": "sha1-n0uhni8wMMVH+K+ZEHg47DjVseI=",
+ "dev": true
+ },
+ "setprototypeof": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz",
+ "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=",
+ "dev": true
+ },
+ "shelljs": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz",
+ "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=",
+ "dev": true
+ },
+ "signal-exit": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
+ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
+ "dev": true
+ },
+ "sntp": {
+ "version": "1.0.9",
+ "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz",
+ "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=",
+ "dev": true,
+ "optional": true
+ },
+ "source-map": {
+ "version": "0.5.6",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz",
+ "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=",
+ "dev": true
+ },
+ "spdx-correct": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz",
+ "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=",
+ "dev": true
+ },
+ "spdx-expression-parse": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz",
+ "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=",
+ "dev": true
+ },
+ "spdx-license-ids": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz",
+ "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=",
+ "dev": true
+ },
+ "sprintf-js": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
+ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
+ "dev": true
+ },
+ "sshpk": {
+ "version": "1.13.1",
+ "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz",
+ "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=",
+ "dev": true,
+ "optional": true,
+ "dependencies": {
+ "assert-plus": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
+ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "statuses": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz",
+ "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=",
+ "dev": true
+ },
+ "string_decoder": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
+ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
+ "dev": true
+ },
+ "stringstream": {
+ "version": "0.0.5",
+ "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
+ "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=",
+ "dev": true,
+ "optional": true
+ },
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "dev": true
+ },
+ "strip-bom": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
+ "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
+ "dev": true
+ },
+ "strip-indent": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz",
+ "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=",
+ "dev": true
+ },
+ "strip-json-comments": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz",
+ "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
+ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
+ "dev": true
+ },
+ "tiny-lr": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/tiny-lr/-/tiny-lr-0.2.1.tgz",
+ "integrity": "sha1-s/26gC5dVqM8L28QeUsy5Hescp0=",
+ "dev": true,
+ "dependencies": {
+ "debug": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
+ "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=",
+ "dev": true
+ },
+ "ms": {
+ "version": "0.7.1",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz",
+ "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=",
+ "dev": true
+ },
+ "qs": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-5.1.0.tgz",
+ "integrity": "sha1-TZMuXH6kEcynajEtOaYGIA/VDNk=",
+ "dev": true
+ }
+ }
+ },
+ "tough-cookie": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz",
+ "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=",
+ "dev": true,
+ "optional": true
+ },
+ "trim-newlines": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz",
+ "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=",
+ "dev": true
+ },
+ "tunnel-agent": {
+ "version": "0.6.0",
+ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
+ "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
+ "dev": true,
+ "optional": true
+ },
+ "tweetnacl": {
+ "version": "0.14.5",
+ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
+ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
+ "dev": true,
+ "optional": true
+ },
+ "type-is": {
+ "version": "1.6.15",
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz",
+ "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=",
+ "dev": true
+ },
+ "typedarray": {
+ "version": "0.0.6",
+ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
+ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
+ "dev": true
+ },
+ "uglify-js": {
+ "version": "2.6.4",
+ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.6.4.tgz",
+ "integrity": "sha1-ZeovswWck5RpLxX+2HwrNsFrmt8=",
+ "dev": true,
+ "dependencies": {
+ "async": {
+ "version": "0.2.10",
+ "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
+ "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=",
+ "dev": true
+ }
+ }
+ },
+ "uglify-to-browserify": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz",
+ "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=",
+ "dev": true
+ },
+ "underscore.string": {
+ "version": "3.2.3",
+ "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.2.3.tgz",
+ "integrity": "sha1-gGmSYzZl1eX8tNsfs6hi62jp5to=",
+ "dev": true
+ },
+ "unpipe": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
+ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=",
+ "dev": true
+ },
+ "uri-path": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/uri-path/-/uri-path-1.0.0.tgz",
+ "integrity": "sha1-l0fwGDWJM8Md4PzP2C0TjmcmLjI=",
+ "dev": true
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
+ "dev": true
+ },
+ "utils-merge": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz",
+ "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=",
+ "dev": true
+ },
+ "uuid": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz",
+ "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==",
+ "dev": true,
+ "optional": true
+ },
+ "validate-npm-package-license": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz",
+ "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=",
+ "dev": true
+ },
+ "vary": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz",
+ "integrity": "sha1-Z1Neu2lMHVIldFeYRmUyP1h+jTc=",
+ "dev": true
+ },
+ "verror": {
+ "version": "1.3.6",
+ "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz",
+ "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=",
+ "dev": true,
+ "optional": true
+ },
+ "websocket-driver": {
+ "version": "0.6.5",
+ "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.6.5.tgz",
+ "integrity": "sha1-XLJVbOuF9Dc8bYI4qmkchFThOjY=",
+ "dev": true
+ },
+ "websocket-extensions": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.1.tgz",
+ "integrity": "sha1-domUmcGEtu91Q3fC27DNbLVdKec=",
+ "dev": true
+ },
+ "which": {
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz",
+ "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=",
+ "dev": true
+ },
+ "window-size": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz",
+ "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=",
+ "dev": true
+ },
+ "wordwrap": {
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
+ "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=",
+ "dev": true
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
+ "dev": true
+ },
+ "yargs": {
+ "version": "3.10.0",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
+ "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=",
+ "dev": true,
+ "dependencies": {
+ "camelcase": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
+ "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
+ "dev": true
+ }
+ }
+ }
+ }
+}
diff --git a/src/less/resource/icon.less b/src/less/resource/icon.less
index b885ea16b..d2ce74bb8 100644
--- a/src/less/resource/icon.less
+++ b/src/less/resource/icon.less
@@ -55,3 +55,5 @@
//Half Select
.icon(check-half-select-icon, @icon-half-select);
+
+
diff --git a/src/less/widget/singleslider/singleslider.less b/src/less/widget/singleslider/singleslider.less
new file mode 100644
index 000000000..0f67e10ff
--- /dev/null
+++ b/src/less/widget/singleslider/singleslider.less
@@ -0,0 +1,6 @@
+@import "../../bibase";
+
+.bi-single-slider {
+ & .slider-editor-button {
+ }
+}
diff --git a/src/less/widget/singleslider/slider/widget.slider.less b/src/less/widget/singleslider/slider/widget.slider.less
new file mode 100644
index 000000000..297bd13f2
--- /dev/null
+++ b/src/less/widget/singleslider/slider/widget.slider.less
@@ -0,0 +1,4 @@
+@import "../../../bibase";
+.bi-single-slider-slider{
+ cursor: url('@{leftRightCursor}'), auto;
+}
\ No newline at end of file
diff --git a/src/less/widget/singleslider/track/widget.track.less b/src/less/widget/singleslider/track/widget.track.less
new file mode 100644
index 000000000..defc1b480
--- /dev/null
+++ b/src/less/widget/singleslider/track/widget.track.less
@@ -0,0 +1,15 @@
+@import "../../../bibase";
+
+.bi-slider-track {
+ .background-track {
+ .background-color(@color-bi-background-gray, 0);
+ .border-radius(12px);
+ }
+ .gray-track {
+ background: @color-bi-background-disabled;
+ .border-radius(4px);
+ }
+ .blue-track {
+ .border-radius(4px);
+ }
+}
\ No newline at end of file
diff --git a/src/widget/intervalslider/intervalslider.js b/src/widget/intervalslider/intervalslider.js
new file mode 100644
index 000000000..53f003487
--- /dev/null
+++ b/src/widget/intervalslider/intervalslider.js
@@ -0,0 +1,495 @@
+/**
+ * Created by zcf on 2016/9/26.
+ * Make some change by dailer on 2017/7/17
+ */
+BI.IntervalSlider = BI.inherit(BI.Widget, {
+ _constant: {
+ EDITOR_WIDTH: 58,
+ EDITOR_R_GAP: 60,
+ EDITOR_HEIGHT: 30,
+ HEIGHT: 28,
+ SLIDER_WIDTH_HALF: 15,
+ SLIDER_WIDTH: 30,
+ SLIDER_HEIGHT: 30,
+ TRACK_HEIGHT: 24
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.IntervalSlider.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-slider bi-slider-track"
+ })
+ },
+
+ _init: function () {
+ BI.IntervalSlider.superclass._init.apply(this, arguments);
+
+ var self = this;
+ var c = this._constant;
+ this.enable = false;
+ this.valueOne = "";
+ this.valueTwo = "";
+ this.calculation = new BI.AccurateCalculationModel();
+
+ this.backgroundTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "background-track",
+ height: c.TRACK_HEIGHT
+ });
+ this.grayTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "gray-track",
+ height: 8
+ });
+ this.blueTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "blue-track bi-high-light-background",
+ height: 8
+ });
+ this.track = this._createTrackWrapper();
+
+ this.labelOne = BI.createWidget({
+ type: "bi.sign_editor",
+ cls: "slider-editor-button",
+ errorText: "",
+ allowBlank: false,
+ height: c.HEIGHT,
+ width: c.EDITOR_WIDTH,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () {
+ var v = BI.parseFloat(this.getValue());
+ self.valueOne = v;
+ var percent = self._getPercentByValue(v);
+ var significantPercent = BI.parseFloat(percent.toFixed(1)); //分成1000份
+ self._setLabelOnePosition(significantPercent);
+ self._setSliderOnePosition(significantPercent);
+ self._setBlueTrack();
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ });
+ this.labelOne.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.labelOne.element.addClass("bi-border");
+ });
+ this.labelOne.on(BI.SignEditor.EVENT_BLUR, function () {
+ self.labelOne.element.removeClass("bi-border");
+ });
+
+ this.labelTwo = BI.createWidget({
+ type: "bi.sign_editor",
+ cls: "slider-editor-button",
+ errorText: "",
+ allowBlank: false,
+ height: c.HEIGHT,
+ width: c.EDITOR_WIDTH,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () {
+ var v = BI.parseFloat(this.getValue());
+ self.valueTwo = v;
+ var percent = self._getPercentByValue(v);
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setLabelTwoPosition(significantPercent);
+ self._setSliderTwoPosition(significantPercent);
+ self._setBlueTrack();
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ });
+ this.labelTwo.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.labelTwo.element.addClass("bi-border");
+ });
+ this.labelTwo.on(BI.SignEditor.EVENT_BLUR, function () {
+ self.labelTwo.element.removeClass("bi-border");
+ });
+
+ this.sliderOne = BI.createWidget({
+ type: "bi.single_slider_slider"
+ });
+ this.sliderOne.element.draggable({
+ axis: "x",
+ containment: this.grayTrack.element,
+ scroll: false,
+ drag: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setLabelOnePosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.labelOne.setValue(v);
+ self.valueOne = v;
+ self._setBlueTrack();
+ },
+ stop: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderOnePosition(significantPercent);
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ }
+ });
+
+ this.sliderTwo = BI.createWidget({
+ type: "bi.single_slider_slider"
+ });
+ this.sliderTwo.element.draggable({
+ axis: "x",
+ containment: this.grayTrack.element,
+ scroll: false,
+ drag: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setLabelTwoPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.labelTwo.setValue(v);
+ self.valueTwo = v;
+ self._setBlueTrack();
+ },
+ stop: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderTwoPosition(significantPercent);
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ }
+ });
+ this._setVisible(false);
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.track,
+ width: "100%",
+ height: c.TRACK_HEIGHT
+ }]
+ }],
+ hgap: 7,
+ height: c.TRACK_HEIGHT
+ },
+ top: 33,
+ left: 0,
+ width: "100%"
+ },
+ this._createLabelWrapper(),
+ this._createSliderWrapper()
+ ]
+ })
+ },
+
+ _createLabelWrapper: function () {
+ var c = this._constant;
+ return {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.labelOne,
+ top: 0,
+ left: "0%"
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: this.labelTwo,
+ top: 0,
+ left: "100%"
+ }]
+ }],
+ rgap: c.EDITOR_R_GAP,
+ height: 90
+ },
+ top: 0,
+ left: 0,
+ width: "100%"
+ }
+ },
+
+ _createSliderWrapper: function () {
+ var c = this._constant;
+ return {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.sliderOne,
+ top: 0,
+ left: "0%"
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: this.sliderTwo,
+ top: 0,
+ left: "100%"
+ }]
+ }],
+ hgap: c.SLIDER_WIDTH_HALF,
+ height: c.SLIDER_HEIGHT
+ },
+ top: 30,
+ left: 0,
+ width: "100%"
+ }
+ },
+
+ _createTrackWrapper: function () {
+ return BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: this.backgroundTrack,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.grayTrack,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }, {
+ el: this.blueTrack,
+ top: 0,
+ left: 0,
+ width: "0%"
+ }]
+ }],
+ hgap: 8,
+ height: 8
+ },
+ top: 8,
+ left: 0,
+ width: "100%"
+ }]
+ })
+ },
+
+ _checkValidation: function (v) {
+ return BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)
+ },
+
+ _checkOverlap: function () {
+ var labelOneLeft = this.labelOne.element[0].offsetLeft;
+ var labelTwoLeft = this.labelTwo.element[0].offsetLeft;
+ if (labelOneLeft <= labelTwoLeft) {
+ if ((labelTwoLeft - labelOneLeft) < 90) {
+ this.labelTwo.element.css({
+ "top": 60
+ });
+ } else {
+ this.labelTwo.element.css({
+ "top": 0
+ });
+ }
+ } else {
+ if ((labelOneLeft - labelTwoLeft) < 90) {
+ this.labelTwo.element.css({
+ "top": 60
+ });
+ } else {
+ this.labelTwo.element.css({
+ "top": 0
+ });
+ }
+ }
+ },
+
+ _setLabelOnePosition: function (percent) {
+ this.labelOne.element.css({
+ "left": percent + "%"
+ });
+ this._checkOverlap();
+ },
+
+ _setLabelTwoPosition: function (percent) {
+ this.labelTwo.element.css({
+ "left": percent + "%"
+ });
+ this._checkOverlap();
+ },
+
+ _setSliderOnePosition: function (percent) {
+ this.sliderOne.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setSliderTwoPosition: function (percent) {
+ this.sliderTwo.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setBlueTrackLeft: function (percent) {
+ this.blueTrack.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setBlueTrackWidth: function (percent) {
+ this.blueTrack.element.css({
+ "width": percent + "%"
+ });
+ },
+
+ _setBlueTrack: function () {
+ var percentOne = this._getPercentByValue(this.labelOne.getValue());
+ var percentTwo = this._getPercentByValue(this.labelTwo.getValue());
+ if (percentOne <= percentTwo) {
+ this._setBlueTrackLeft(percentOne);
+ this._setBlueTrackWidth(percentTwo - percentOne);
+ } else {
+ this._setBlueTrackLeft(percentTwo);
+ this._setBlueTrackWidth(percentOne - percentTwo);
+ }
+ },
+
+ _setAllPosition: function (one, two) {
+ this._setSliderOnePosition(one);
+ this._setLabelOnePosition(one);
+ this._setSliderTwoPosition(two);
+ this._setLabelTwoPosition(two);
+ this._setBlueTrack();
+ },
+
+ _setVisible: function (visible) {
+ this.sliderOne.setVisible(visible);
+ this.sliderTwo.setVisible(visible);
+ this.labelOne.setVisible(visible);
+ this.labelTwo.setVisible(visible);
+ },
+
+ _setErrorText: function () {
+ var errorText = BI.i18nText("BI-Please_Enter") + this.min + "-" + this.max + BI.i18nText("BI-Basic_De") + BI.i18nText("BI-Basic_Number");
+ this.labelOne.setErrorText(errorText);
+ this.labelTwo.setErrorText(errorText);
+ },
+
+ _getGrayTrackLength: function () {
+ return this.grayTrack.element[0].scrollWidth
+ },
+
+ //其中取max-min后保留4为有效数字后的值的小数位数为最终value的精度
+ _getValueByPercent: function (percent) { //return (((max-min)*percent)/100+min)
+ var sub = this.calculation.accurateSubtraction(this.max, this.min);
+ var mul = this.calculation.accurateMultiplication(sub, percent);
+ var div = this.calculation.accurateDivisionTenExponent(mul, 2);
+ if (this.precision >= 0) {
+ return BI.parseFloat(this.calculation.accurateAddition(div, this.min).toFixed(this.precision));
+ } else {
+ return BI.parseFloat(this.calculation.accurateAddition(div, this.min) - this.calculation.accurateAddition(div, this.min) % (Math.pow(10, (-1) * this.precision)));
+ }
+ },
+
+ _getPercentByValue: function (v) {
+ return (v - this.min) * 100 / (this.max - this.min);
+ },
+
+ _setDraggableEnable: function (enable) {
+ if (enable) {
+ this.sliderOne.element.draggable("enable");
+ this.sliderTwo.element.draggable("enable")
+ } else {
+ this.sliderOne.element.draggable("disable");
+ this.sliderTwo.element.draggable("disable")
+ }
+ },
+
+
+ getValue: function () {
+ if (this.valueOne <= this.valueTwo) {
+ return {
+ min: this.valueOne,
+ max: this.valueTwo
+ }
+ } else {
+ return {
+ min: this.valueTwo,
+ max: this.valueOne
+ }
+ }
+ },
+
+ setMinAndMax: function (v) {
+ var minNumber = BI.parseFloat(v.min);
+ var maxNumber = BI.parseFloat(v.max);
+ if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber >= minNumber)) {
+ this.min = minNumber;
+ this.max = maxNumber;
+ this.valueOne = minNumber;
+ this.valueTwo = maxNumber;
+ //计算每一份值的精度(最大值和最小值的差值保留4为有效数字后的精度)
+ //如果差值的整数位数大于4,toPrecision得到的是科学计数法1234 => 1.2e+3
+ var sub = this.calculation.accurateSubtraction(this.max, this.min);
+ var pre = sub.toPrecision(4);
+ if(pre.indexOf("e") > -1 ){
+ this.precision = 3 - pre.charAt(pre.length - 1);
+ }else{
+ var arr = pre.split(".");
+ if(arr.length>1){
+ this.precision = arr[1].length;
+ }else{
+ this.precision=0;
+ }
+ }
+ this._setDraggableEnable(true);
+ }
+ if (maxNumber === minNumber) {
+ this._setDraggableEnable(false);
+ }
+ },
+
+ setValue: function (v) {
+ var valueOne = BI.parseFloat(v.min);
+ var valueTwo = BI.parseFloat(v.max);
+ if (!isNaN(valueOne) && !isNaN(valueTwo)) {
+ if (this._checkValidation(valueOne)) {
+ this.valueOne = valueOne;
+ }
+ if (this._checkValidation(valueTwo)) {
+ this.valueTwo = valueTwo;
+ }
+ if (valueOne < this.min) {
+ this.valueOne = this.min;
+ }
+ if (valueTwo > this.max) {
+ this.valueTwo = this.max;
+ }
+ }
+ },
+
+ reset: function () {
+ this._setVisible(false);
+ this.enable = false;
+ this.valueOne = "";
+ this.valueTwo = "";
+ this.min = NaN;
+ this.max = NaN;
+ this._setBlueTrackWidth(0);
+ },
+
+ populate: function () {
+ if (!isNaN(this.min) && !isNaN(this.max)) {
+ this.enable = true;
+ this._setVisible(true);
+ this._setErrorText();
+ if ((BI.isNumeric(this.valueOne) || BI.isNotEmptyString(this.valueOne)) && (BI.isNumeric(this.valueTwo) || BI.isNotEmptyString(this.valueTwo))) {
+ this.labelOne.setValue(this.valueOne);
+ this.labelTwo.setValue(this.valueTwo);
+ this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo));
+ } else {
+ this.labelOne.setValue(this.min);
+ this.labelTwo.setValue(this.max);
+ this._setAllPosition(0, 100)
+ }
+ }
+ }
+});
+BI.IntervalSlider.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.interval_slider", BI.IntervalSlider);
\ No newline at end of file
diff --git a/src/widget/intervalslider/model.accuratecalculation.js b/src/widget/intervalslider/model.accuratecalculation.js
new file mode 100644
index 000000000..6d50ad5f3
--- /dev/null
+++ b/src/widget/intervalslider/model.accuratecalculation.js
@@ -0,0 +1,222 @@
+/**
+ * Created by zcf on 2017/3/1.
+ * 万恶的IEEE-754
+ * 使用字符串精确计算含小数加法、减法、乘法和10的指数倍除法,支持负数
+ */
+BI.AccurateCalculationModel = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.AccurateCalculationModel.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: ""
+ })
+ },
+
+ _init: function () {
+ BI.AccurateCalculationModel.superclass._init.apply(this, arguments);
+ },
+
+ _getMagnitude: function (n) {
+ var magnitude = "1";
+ for (var i = 0; i < n; i++) {
+ magnitude += "0";
+ }
+ return BI.parseInt(magnitude);
+ },
+
+ _formatDecimal: function (stringNumber1, stringNumber2) {
+ if (stringNumber1.numDecimalLength === stringNumber2.numDecimalLength) {
+ return;
+ }
+ var magnitudeDiff = stringNumber1.numDecimalLength - stringNumber2.numDecimalLength;
+ if (magnitudeDiff > 0) {
+ var needAddZero = stringNumber2
+ } else {
+ var needAddZero = stringNumber1;
+ magnitudeDiff = (0 - magnitudeDiff);
+ }
+ for (var i = 0; i < magnitudeDiff; i++) {
+ if (needAddZero.numDecimal === "0" && i === 0) {
+ continue
+ }
+ needAddZero.numDecimal += "0"
+ }
+ },
+
+ _stringNumberFactory: function (num) {
+ var strNum = num.toString();
+ var numStrArray = strNum.split(".");
+ var numInteger = numStrArray[0];
+ if (numStrArray.length === 1) {
+ var numDecimal = "0";
+ var numDecimalLength = 0;
+ } else {
+ var numDecimal = numStrArray[1];
+ var numDecimalLength = numStrArray[1].length;
+ }
+ return {
+ "numInteger": numInteger,
+ "numDecimal": numDecimal,
+ "numDecimalLength": numDecimalLength
+ }
+ },
+
+ _accurateSubtraction: function (num1, num2) {//num1-num2 && num1>num2
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ //整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) - BI.parseInt(stringNumber2.numInteger);
+ //小数部分
+ this._formatDecimal(stringNumber1, stringNumber2);
+ var decimalMaxLength = getDecimalMaxLength(stringNumber1, stringNumber2);
+
+ if (BI.parseInt(stringNumber1.numDecimal) >= BI.parseInt(stringNumber2.numDecimal)) {
+ var decimalResultTemp = (BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
+ var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
+ } else {//否则借位
+ integerResult--;
+ var borrow = this._getMagnitude(decimalMaxLength);
+ var decimalResultTemp = (borrow + BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
+ var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
+ }
+ var result = integerResult + "." + decimalResult;
+ return BI.parseFloat(result);
+
+ function getDecimalMaxLength(num1, num2) {
+ if (num1.numDecimal.length >= num2.numDecimal.length) {
+ return num1.numDecimal.length
+ }
+ return num2.numDecimal.length
+ }
+
+ function addZero(resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp
+ }
+ },
+
+ _accurateAddition: function (num1, num2) {//加法结合律
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ //整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) + BI.parseInt(stringNumber2.numInteger);
+ //小数部分
+ this._formatDecimal(stringNumber1, stringNumber2);
+
+ var decimalResult = (BI.parseInt(stringNumber1.numDecimal) + BI.parseInt(stringNumber2.numDecimal)).toString();
+
+ if (decimalResult !== "0") {
+ if (decimalResult.length <= stringNumber1.numDecimal.length) {
+ decimalResult = addZero(decimalResult, stringNumber1.numDecimal.length)
+ } else {
+ integerResult++;//进一
+ decimalResult = decimalResult.slice(1);
+ }
+ }
+ var result = integerResult + "." + decimalResult;
+ return BI.parseFloat(result);
+
+ function addZero(resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp
+ }
+ },
+
+ _accurateMultiplication: function (num1, num2) {//乘法分配律
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ //整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numInteger);
+ //num1的小数和num2的整数
+ var dec1Int2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numInteger), stringNumber1.numDecimalLength);
+ //num1的整数和num2的小数
+ var int1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numDecimal), stringNumber2.numDecimalLength);
+ //小数*小数
+ var dec1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numDecimal), (stringNumber1.numDecimalLength + stringNumber2.numDecimalLength));
+
+ return this._accurateAddition(this._accurateAddition(this._accurateAddition(integerResult, dec1Int2), int1dec2), dec1dec2);
+ },
+
+ _accurateDivisionTenExponent: function (num, n) {// num/10^n && n>0
+ var stringNumber = this._stringNumberFactory(num);
+ if (stringNumber.numInteger.length > n) {
+ var integerResult = stringNumber.numInteger.slice(0, (stringNumber.numInteger.length - n));
+ var partDecimalResult = stringNumber.numInteger.slice(-n);
+ } else {
+ var integerResult = "0";
+ var partDecimalResult = addZero(stringNumber.numInteger, n);
+ }
+ var result = integerResult + "." + partDecimalResult + stringNumber.numDecimal;
+ return BI.parseFloat(result);
+
+ function addZero(resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp
+ }
+ },
+
+ accurateSubtraction: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ if (num1 >= num2) {
+ return this._accurateSubtraction(num1, num2)
+ }
+ return -this._accurateSubtraction(num2, num1)
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return this._accurateAddition(num1, -num2)
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return -this._accurateAddition(-num1, num2)
+ }
+ if (num1 < 0 && num2 < 0) {
+ if (num1 >= num2) {
+ return this._accurateSubtraction(-num2, -num1)
+ }
+ return this._accurateSubtraction(-num1, -num2)
+ }
+ },
+
+ accurateAddition: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ return this._accurateAddition(num1, num2)
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return this.accurateSubtraction(num1, -num2)
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return this.accurateSubtraction(num2, -num1)
+ }
+ if (num1 < 0 && num2 < 0) {
+ return -this._accurateAddition(-num1, -num2)
+ }
+ },
+
+ accurateMultiplication: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ return this._accurateMultiplication(num1, num2)
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return -this._accurateMultiplication(num1, -num2)
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return -this._accurateMultiplication(-num1, num2)
+ }
+ if (num1 < 0 && num2 < 0) {
+ return this._accurateMultiplication(-num1, -num2)
+ }
+ },
+
+ accurateDivisionTenExponent: function (num1, n) {
+ if (num1 >= 0) {
+ return this._accurateDivisionTenExponent(num1, n);
+ }
+ return -this._accurateDivisionTenExponent(-num1, n);
+ }
+});
\ No newline at end of file
diff --git a/src/widget/singleslider/jquery-ui/jquery-ui.min.js b/src/widget/singleslider/jquery-ui/jquery-ui.min.js
new file mode 100644
index 000000000..957871790
--- /dev/null
+++ b/src/widget/singleslider/jquery-ui/jquery-ui.min.js
@@ -0,0 +1,9 @@
+/*! jQuery UI - v1.12.1 - 2017-07-14
+* http://jqueryui.com
+* Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/draggable.js, widgets/droppable.js, widgets/resizable.js, widgets/selectable.js, widgets/sortable.js, widgets/mouse.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js
+* Copyright jQuery Foundation and other contributors; Licensed MIT */
+
+(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)})(function(t){function e(t){for(var e=t.css("visibility");"inherit"===e;)t=t.parent(),e=t.css("visibility");return"hidden"!==e}t.ui=t.ui||{},t.ui.version="1.12.1";var i=0,s=Array.prototype.slice;t.cleanData=function(e){return function(i){var s,n,o;for(o=0;null!=(n=i[o]);o++)try{s=t._data(n,"events"),s&&s.remove&&t(n).triggerHandler("remove")}catch(a){}e(i)}}(t.cleanData),t.widget=function(e,i,s){var n,o,a,r={},l=e.split(".")[0];e=e.split(".")[1];var h=l+"-"+e;return s||(s=i,i=t.Widget),t.isArray(s)&&(s=t.extend.apply(null,[{}].concat(s))),t.expr[":"][h.toLowerCase()]=function(e){return!!t.data(e,h)},t[l]=t[l]||{},n=t[l][e],o=t[l][e]=function(t,e){return this._createWidget?(arguments.length&&this._createWidget(t,e),void 0):new o(t,e)},t.extend(o,n,{version:s.version,_proto:t.extend({},s),_childConstructors:[]}),a=new i,a.options=t.widget.extend({},a.options),t.each(s,function(e,s){return t.isFunction(s)?(r[e]=function(){function t(){return i.prototype[e].apply(this,arguments)}function n(t){return i.prototype[e].apply(this,t)}return function(){var e,i=this._super,o=this._superApply;return this._super=t,this._superApply=n,e=s.apply(this,arguments),this._super=i,this._superApply=o,e}}(),void 0):(r[e]=s,void 0)}),o.prototype=t.widget.extend(a,{widgetEventPrefix:n?a.widgetEventPrefix||e:e},r,{constructor:o,namespace:l,widgetName:e,widgetFullName:h}),n?(t.each(n._childConstructors,function(e,i){var s=i.prototype;t.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete n._childConstructors):i._childConstructors.push(o),t.widget.bridge(e,o),o},t.widget.extend=function(e){for(var i,n,o=s.call(arguments,1),a=0,r=o.length;r>a;a++)for(i in o[a])n=o[a][i],o[a].hasOwnProperty(i)&&void 0!==n&&(e[i]=t.isPlainObject(n)?t.isPlainObject(e[i])?t.widget.extend({},e[i],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,i){var n=i.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=s.call(arguments,1),l=this;return a?this.length||"instance"!==o?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(l=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(l=i&&i.jquery?l.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):l=void 0:(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new i(o,this))})),l}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"",options:{classes:{},disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),this._on(e.element,{remove:"_untrackClassesElement"}),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(e){var i=this;t.each(i.classesElementLookup,function(s,n){-1!==t.inArray(e.target,n)&&(i.classesElementLookup[s]=t(n.not(e.target).get()))})},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var l=s.match(/^([\w:-]*)\s*(.*)$/),h=l[1]+o.eventNamespace,c=l[2];c?n.on(h,c,r):i.on(h,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,function(){function e(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function i(e,i){return parseInt(t.css(e,i),10)||0}function s(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}var n,o=Math.max,a=Math.abs,r=/left|center|right/,l=/top|center|bottom/,h=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,d=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==n)return n;var e,i,s=t("
"),o=s.children()[0];return t("body").append(s),e=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),n=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.width
i?"left":e>0?"right":"center",vertical:0>r?"top":s>0?"bottom":"middle"};h>p&&p>a(e+i)&&(u.horizontal="center"),c>f&&f>a(s+r)&&(u.vertical="middle"),u.important=o(a(e),a(i))>o(a(s),a(r))?"horizontal":"vertical",n.using.call(this,t,u)}),l.offset(t.extend(D,{using:r}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,l=n-r,h=r+e.collisionWidth-a-n;e.collisionWidth>a?l>0&&0>=h?(i=t.left+l+e.collisionWidth-a-n,t.left+=l-i):t.left=h>0&&0>=l?n:l>h?n+a-e.collisionWidth:n:l>0?t.left+=l:h>0?t.left-=h:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,l=n-r,h=r+e.collisionHeight-a-n;e.collisionHeight>a?l>0&&0>=h?(i=t.top+l+e.collisionHeight-a-n,t.top+=l-i):t.top=h>0&&0>=l?n:l>h?n+a-e.collisionHeight:n:l>0?t.top+=l:h>0?t.top-=h:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,l=n.isWindow?n.scrollLeft:n.offset.left,h=t.left-e.collisionPosition.marginLeft,c=h-l,u=h+e.collisionWidth-r-l,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-r-o,(0>i||a(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-l,(s>0||u>a(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,o=n.offset.top+n.scrollTop,r=n.height,l=n.isWindow?n.scrollTop:n.offset.top,h=t.top-e.collisionPosition.marginTop,c=h-l,u=h+e.collisionHeight-r-l,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,g=-2*e.offset[1];0>c?(s=t.top+p+f+g+e.collisionHeight-r-o,(0>s||a(c)>s)&&(t.top+=p+f+g)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+g-l,(i>0||u>a(i))&&(t.top+=p+f+g))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}}}(),t.ui.position,t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])}}),t.fn.extend({disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.off(".ui-disableSelection")}}),t.ui.focusable=function(i,s){var n,o,a,r,l,h=i.nodeName.toLowerCase();return"area"===h?(n=i.parentNode,o=n.name,i.href&&o&&"map"===n.nodeName.toLowerCase()?(a=t("img[usemap='#"+o+"']"),a.length>0&&a.is(":visible")):!1):(/^(input|select|textarea|button|object)$/.test(h)?(r=!i.disabled,r&&(l=t(i).closest("fieldset")[0],l&&(r=!l.disabled))):r="a"===h?i.href||s:s,r&&t(i).is(":visible")&&e(t(i)))},t.extend(t.expr[":"],{focusable:function(e){return t.ui.focusable(e,null!=t.attr(e,"tabindex"))}}),t.ui.focusable,t.fn.form=function(){return"string"==typeof this[0].form?this.closest("form"):t(this[0].form)},t.ui.formResetMixin={_formResetHandler:function(){var e=t(this);setTimeout(function(){var i=e.data("ui-form-reset-instances");t.each(i,function(){this.refresh()})})},_bindFormResetHandler:function(){if(this.form=this.element.form(),this.form.length){var t=this.form.data("ui-form-reset-instances")||[];t.length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t)}},_unbindFormResetHandler:function(){if(this.form.length){var e=this.form.data("ui-form-reset-instances");e.splice(t.inArray(this,e),1),e.length?this.form.data("ui-form-reset-instances",e):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset")}}},"1.7"===t.fn.jquery.substring(0,3)&&(t.each(["Width","Height"],function(e,i){function s(e,i,s,o){return t.each(n,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(e){return void 0===e?a["inner"+i].call(this):this.each(function(){t(this).css(o,s(this,e)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?a["outer"+i].call(this,e):this.each(function(){t(this).css(o,s(this,e,!0,n)+"px")})}}),t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},t.ui.escapeSelector=function(){var t=/([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;return function(e){return e.replace(t,"\\$1")}}(),t.fn.labels=function(){var e,i,s,n,o;return this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(n=this.eq(0).parents("label"),s=this.attr("id"),s&&(e=this.eq(0).parents().last(),o=e.add(e.length?e.siblings():this.siblings()),i="label[for='"+t.ui.escapeSelector(s)+"']",n=n.add(o.find(i).addBack(i))),this.pushStack(n))},t.fn.scrollParent=function(e){var i=this.css("position"),s="absolute"===i,n=e?/(auto|scroll|hidden)/:/(auto|scroll)/,o=this.parents().filter(function(){var e=t(this);return s&&"static"===e.css("position")?!1:n.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==i&&o.length?o:t(this[0].ownerDocument||document)},t.extend(t.expr[":"],{tabbable:function(e){var i=t.attr(e,"tabindex"),s=null!=i;return(!s||i>=0)&&t.ui.focusable(e,s)}}),t.fn.extend({uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var n=!1;t(document).on("mouseup",function(){n=!1}),t.widget("ui.mouse",{version:"1.12.1",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!n){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,s=1===e.which,o="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return s&&!o&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),n=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,n=!1,e.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.ui.plugin={add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;o.length>n;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},t.ui.safeActiveElement=function(t){var e;try{e=t.activeElement}catch(i){e=t.body}return e||(e=t.body),e.nodeName||(e=t.body),e},t.ui.safeBlur=function(e){e&&"body"!==e.nodeName.toLowerCase()&&t(e).trigger("blur")},t.widget("ui.draggable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"===this.options.helper&&this._setPositionRelative(),this.options.addClasses&&this._addClass("ui-draggable"),this._setHandleClassName(),this._mouseInit()},_setOption:function(t,e){this._super(t,e),"handle"===t&&(this._removeHandleClassName(),this._setHandleClassName())},_destroy:function(){return(this.helper||this.element).is(".ui-draggable-dragging")?(this.destroyOnClear=!0,void 0):(this._removeHandleClassName(),this._mouseDestroy(),void 0)},_mouseCapture:function(e){var i=this.options;return this.helper||i.disabled||t(e.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(e),this.handle?(this._blurActiveElement(e),this._blockFrames(i.iframeFix===!0?"iframe":i.iframeFix),!0):!1)},_blockFrames:function(e){this.iframeBlocks=this.document.find(e).map(function(){var e=t(this);return t("").css("position","absolute").appendTo(e.parent()).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()).offset(e.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_blurActiveElement:function(e){var i=t.ui.safeActiveElement(this.document[0]),s=t(e.target);s.closest(i).length||t.ui.safeBlur(i)},_mouseStart:function(e){var i=this.options;return this.helper=this._createHelper(e),this._addClass(this.helper,"ui-draggable-dragging"),this._cacheHelperProportions(),t.ui.ddmanager&&(t.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.hasFixedAncestor=this.helper.parents().filter(function(){return"fixed"===t(this).css("position")}).length>0,this.positionAbs=this.element.offset(),this._refreshOffsets(e),this.originalPosition=this.position=this._generatePosition(e,!1),this.originalPageX=e.pageX,this.originalPageY=e.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",e)===!1?(this._clear(),!1):(this._cacheHelperProportions(),t.ui.ddmanager&&!i.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this._mouseDrag(e,!0),t.ui.ddmanager&&t.ui.ddmanager.dragStart(this,e),!0)},_refreshOffsets:function(t){this.offset={top:this.positionAbs.top-this.margins.top,left:this.positionAbs.left-this.margins.left,scroll:!1,parent:this._getParentOffset(),relative:this._getRelativeOffset()},this.offset.click={left:t.pageX-this.offset.left,top:t.pageY-this.offset.top}},_mouseDrag:function(e,i){if(this.hasFixedAncestor&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(e,!0),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",e,s)===!1)return this._mouseUp(new t.Event("mouseup",e)),!1;this.position=s.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),!1},_mouseStop:function(e){var i=this,s=!1;return t.ui.ddmanager&&!this.options.dropBehaviour&&(s=t.ui.ddmanager.drop(this,e)),this.dropped&&(s=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||t.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?t(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",e)!==!1&&i._clear()}):this._trigger("stop",e)!==!1&&this._clear(),!1},_mouseUp:function(e){return this._unblockFrames(),t.ui.ddmanager&&t.ui.ddmanager.dragStop(this,e),this.handleElement.is(e.target)&&this.element.trigger("focus"),t.ui.mouse.prototype._mouseUp.call(this,e)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp(new t.Event("mouseup",{target:this.element[0]})):this._clear(),this},_getHandle:function(e){return this.options.handle?!!t(e.target).closest(this.element.find(this.options.handle)).length:!0},_setHandleClassName:function(){this.handleElement=this.options.handle?this.element.find(this.options.handle):this.element,this._addClass(this.handleElement,"ui-draggable-handle")},_removeHandleClassName:function(){this._removeClass(this.handleElement,"ui-draggable-handle")},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper),n=s?t(i.helper.apply(this.element[0],[e])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return n.parents("body").length||n.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s&&n[0]===this.element[0]&&this._setPositionRelative(),n[0]===this.element[0]||/(fixed|absolute)/.test(n.css("position"))||n.css("position","absolute"),n},_setPositionRelative:function(){/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative")},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_isRootNode:function(t){return/(html|body)/i.test(t.tagName)||t===this.document[0]},_getParentOffset:function(){var e=this.offsetParent.offset(),i=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==i&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),this._isRootNode(this.offsetParent[0])&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var t=this.element.position(),e=this._isRootNode(this.scrollParent[0]);return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+(e?0:this.scrollParent.scrollTop()),left:t.left-(parseInt(this.helper.css("left"),10)||0)+(e?0:this.scrollParent.scrollLeft())}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options,o=this.document[0];return this.relativeContainer=null,n.containment?"window"===n.containment?(this.containment=[t(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,t(window).scrollLeft()+t(window).width()-this.helperProportions.width-this.margins.left,t(window).scrollTop()+(t(window).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):"document"===n.containment?(this.containment=[0,0,t(o).width()-this.helperProportions.width-this.margins.left,(t(o).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):n.containment.constructor===Array?(this.containment=n.containment,void 0):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=t(n.containment),s=i[0],s&&(e=/(scroll|auto)/.test(i.css("overflow")),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(e?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(e?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relativeContainer=i),void 0):(this.containment=null,void 0)},_convertPositionTo:function(t,e){e||(e=this.position);var i="absolute"===t?1:-1,s=this._isRootNode(this.scrollParent[0]);return{top:e.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:s?0:this.offset.scroll.top)*i,left:e.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:s?0:this.offset.scroll.left)*i}},_generatePosition:function(t,e){var i,s,n,o,a=this.options,r=this._isRootNode(this.scrollParent[0]),l=t.pageX,h=t.pageY;return r&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),e&&(this.containment&&(this.relativeContainer?(s=this.relativeContainer.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,t.pageX-this.offset.click.left
i[2]&&(l=i[2]+this.offset.click.left),t.pageY-this.offset.click.top>i[3]&&(h=i[3]+this.offset.click.top)),a.grid&&(n=a.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/a.grid[1])*a.grid[1]:this.originalPageY,h=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-a.grid[1]:n+a.grid[1]:n,o=a.grid[0]?this.originalPageX+Math.round((l-this.originalPageX)/a.grid[0])*a.grid[0]:this.originalPageX,l=i?o-this.offset.click.left>=i[0]||o-this.offset.click.left>i[2]?o:o-this.offset.click.left>=i[0]?o-a.grid[0]:o+a.grid[0]:o),"y"===a.axis&&(l=this.originalPageX),"x"===a.axis&&(h=this.originalPageY)),{top:h-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:r?0:this.offset.scroll.top),left:l-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:r?0:this.offset.scroll.left)}
+},_clear:function(){this._removeClass(this.helper,"ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_trigger:function(e,i,s){return s=s||this._uiHash(),t.ui.plugin.call(this,e,[i,s,this],!0),/^(drag|start|stop)/.test(e)&&(this.positionAbs=this._convertPositionTo("absolute"),s.offset=this.positionAbs),t.Widget.prototype._trigger.call(this,e,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),t.ui.plugin.add("draggable","connectToSortable",{start:function(e,i,s){var n=t.extend({},i,{item:s.element});s.sortables=[],t(s.options.connectToSortable).each(function(){var i=t(this).sortable("instance");i&&!i.options.disabled&&(s.sortables.push(i),i.refreshPositions(),i._trigger("activate",e,n))})},stop:function(e,i,s){var n=t.extend({},i,{item:s.element});s.cancelHelperRemoval=!1,t.each(s.sortables,function(){var t=this;t.isOver?(t.isOver=0,s.cancelHelperRemoval=!0,t.cancelHelperRemoval=!1,t._storedCSS={position:t.placeholder.css("position"),top:t.placeholder.css("top"),left:t.placeholder.css("left")},t._mouseStop(e),t.options.helper=t.options._helper):(t.cancelHelperRemoval=!0,t._trigger("deactivate",e,n))})},drag:function(e,i,s){t.each(s.sortables,function(){var n=!1,o=this;o.positionAbs=s.positionAbs,o.helperProportions=s.helperProportions,o.offset.click=s.offset.click,o._intersectsWith(o.containerCache)&&(n=!0,t.each(s.sortables,function(){return this.positionAbs=s.positionAbs,this.helperProportions=s.helperProportions,this.offset.click=s.offset.click,this!==o&&this._intersectsWith(this.containerCache)&&t.contains(o.element[0],this.element[0])&&(n=!1),n})),n?(o.isOver||(o.isOver=1,s._parent=i.helper.parent(),o.currentItem=i.helper.appendTo(o.element).data("ui-sortable-item",!0),o.options._helper=o.options.helper,o.options.helper=function(){return i.helper[0]},e.target=o.currentItem[0],o._mouseCapture(e,!0),o._mouseStart(e,!0,!0),o.offset.click.top=s.offset.click.top,o.offset.click.left=s.offset.click.left,o.offset.parent.left-=s.offset.parent.left-o.offset.parent.left,o.offset.parent.top-=s.offset.parent.top-o.offset.parent.top,s._trigger("toSortable",e),s.dropped=o.element,t.each(s.sortables,function(){this.refreshPositions()}),s.currentItem=s.element,o.fromOutside=s),o.currentItem&&(o._mouseDrag(e),i.position=o.position)):o.isOver&&(o.isOver=0,o.cancelHelperRemoval=!0,o.options._revert=o.options.revert,o.options.revert=!1,o._trigger("out",e,o._uiHash(o)),o._mouseStop(e,!0),o.options.revert=o.options._revert,o.options.helper=o.options._helper,o.placeholder&&o.placeholder.remove(),i.helper.appendTo(s._parent),s._refreshOffsets(e),i.position=s._generatePosition(e,!0),s._trigger("fromSortable",e),s.dropped=!1,t.each(s.sortables,function(){this.refreshPositions()}))})}}),t.ui.plugin.add("draggable","cursor",{start:function(e,i,s){var n=t("body"),o=s.options;n.css("cursor")&&(o._cursor=n.css("cursor")),n.css("cursor",o.cursor)},stop:function(e,i,s){var n=s.options;n._cursor&&t("body").css("cursor",n._cursor)}}),t.ui.plugin.add("draggable","opacity",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("opacity")&&(o._opacity=n.css("opacity")),n.css("opacity",o.opacity)},stop:function(e,i,s){var n=s.options;n._opacity&&t(i.helper).css("opacity",n._opacity)}}),t.ui.plugin.add("draggable","scroll",{start:function(t,e,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(e,i,s){var n=s.options,o=!1,a=s.scrollParentNotHidden[0],r=s.document[0];a!==r&&"HTML"!==a.tagName?(n.axis&&"x"===n.axis||(s.overflowOffset.top+a.offsetHeight-e.pageY=0;d--)l=s.snapElements[d].left-s.margins.left,h=l+s.snapElements[d].width,c=s.snapElements[d].top-s.margins.top,u=c+s.snapElements[d].height,l-g>_||m>h+g||c-g>b||v>u+g||!t.contains(s.snapElements[d].item.ownerDocument,s.snapElements[d].item)?(s.snapElements[d].snapping&&s.options.snap.release&&s.options.snap.release.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=!1):("inner"!==f.snapMode&&(n=g>=Math.abs(c-b),o=g>=Math.abs(u-v),a=g>=Math.abs(l-_),r=g>=Math.abs(h-m),n&&(i.position.top=s._convertPositionTo("relative",{top:c-s.helperProportions.height,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l-s.helperProportions.width}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h}).left)),p=n||o||a||r,"outer"!==f.snapMode&&(n=g>=Math.abs(c-v),o=g>=Math.abs(u-b),a=g>=Math.abs(l-m),r=g>=Math.abs(h-_),n&&(i.position.top=s._convertPositionTo("relative",{top:c,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u-s.helperProportions.height,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h-s.helperProportions.width}).left)),!s.snapElements[d].snapping&&(n||o||a||r||p)&&s.options.snap.snap&&s.options.snap.snap.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=n||o||a||r||p)}}),t.ui.plugin.add("draggable","stack",{start:function(e,i,s){var n,o=s.options,a=t.makeArray(t(o.stack)).sort(function(e,i){return(parseInt(t(e).css("zIndex"),10)||0)-(parseInt(t(i).css("zIndex"),10)||0)});a.length&&(n=parseInt(t(a[0]).css("zIndex"),10)||0,t(a).each(function(e){t(this).css("zIndex",n+e)}),this.css("zIndex",n+a.length))}}),t.ui.plugin.add("draggable","zIndex",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("zIndex")&&(o._zIndex=n.css("zIndex")),n.css("zIndex",o.zIndex)},stop:function(e,i,s){var n=s.options;n._zIndex&&t(i.helper).css("zIndex",n._zIndex)}}),t.ui.draggable,t.widget("ui.droppable",{version:"1.12.1",widgetEventPrefix:"drop",options:{accept:"*",addClasses:!0,greedy:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var e,i=this.options,s=i.accept;this.isover=!1,this.isout=!0,this.accept=t.isFunction(s)?s:function(t){return t.is(s)},this.proportions=function(){return arguments.length?(e=arguments[0],void 0):e?e:e={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}},this._addToManager(i.scope),i.addClasses&&this._addClass("ui-droppable")},_addToManager:function(e){t.ui.ddmanager.droppables[e]=t.ui.ddmanager.droppables[e]||[],t.ui.ddmanager.droppables[e].push(this)},_splice:function(t){for(var e=0;t.length>e;e++)t[e]===this&&t.splice(e,1)},_destroy:function(){var e=t.ui.ddmanager.droppables[this.options.scope];this._splice(e)},_setOption:function(e,i){if("accept"===e)this.accept=t.isFunction(i)?i:function(t){return t.is(i)};else if("scope"===e){var s=t.ui.ddmanager.droppables[this.options.scope];this._splice(s),this._addToManager(i)}this._super(e,i)},_activate:function(e){var i=t.ui.ddmanager.current;this._addActiveClass(),i&&this._trigger("activate",e,this.ui(i))},_deactivate:function(e){var i=t.ui.ddmanager.current;this._removeActiveClass(),i&&this._trigger("deactivate",e,this.ui(i))},_over:function(e){var i=t.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this._addHoverClass(),this._trigger("over",e,this.ui(i)))},_out:function(e){var i=t.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this._removeHoverClass(),this._trigger("out",e,this.ui(i)))},_drop:function(e,i){var s=i||t.ui.ddmanager.current,n=!1;return s&&(s.currentItem||s.element)[0]!==this.element[0]?(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var i=t(this).droppable("instance");return i.options.greedy&&!i.options.disabled&&i.options.scope===s.options.scope&&i.accept.call(i.element[0],s.currentItem||s.element)&&o(s,t.extend(i,{offset:i.element.offset()}),i.options.tolerance,e)?(n=!0,!1):void 0}),n?!1:this.accept.call(this.element[0],s.currentItem||s.element)?(this._removeActiveClass(),this._removeHoverClass(),this._trigger("drop",e,this.ui(s)),this.element):!1):!1},ui:function(t){return{draggable:t.currentItem||t.element,helper:t.helper,position:t.position,offset:t.positionAbs}},_addHoverClass:function(){this._addClass("ui-droppable-hover")},_removeHoverClass:function(){this._removeClass("ui-droppable-hover")},_addActiveClass:function(){this._addClass("ui-droppable-active")},_removeActiveClass:function(){this._removeClass("ui-droppable-active")}});var o=t.ui.intersect=function(){function t(t,e,i){return t>=e&&e+i>t}return function(e,i,s,n){if(!i.offset)return!1;var o=(e.positionAbs||e.position.absolute).left+e.margins.left,a=(e.positionAbs||e.position.absolute).top+e.margins.top,r=o+e.helperProportions.width,l=a+e.helperProportions.height,h=i.offset.left,c=i.offset.top,u=h+i.proportions().width,d=c+i.proportions().height;switch(s){case"fit":return o>=h&&u>=r&&a>=c&&d>=l;case"intersect":return o+e.helperProportions.width/2>h&&u>r-e.helperProportions.width/2&&a+e.helperProportions.height/2>c&&d>l-e.helperProportions.height/2;case"pointer":return t(n.pageY,c,i.proportions().height)&&t(n.pageX,h,i.proportions().width);case"touch":return(a>=c&&d>=a||l>=c&&d>=l||c>a&&l>d)&&(o>=h&&u>=o||r>=h&&u>=r||h>o&&r>u);default:return!1}}}();t.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(e,i){var s,n,o=t.ui.ddmanager.droppables[e.options.scope]||[],a=i?i.type:null,r=(e.currentItem||e.element).find(":data(ui-droppable)").addBack();t:for(s=0;o.length>s;s++)if(!(o[s].options.disabled||e&&!o[s].accept.call(o[s].element[0],e.currentItem||e.element))){for(n=0;r.length>n;n++)if(r[n]===o[s].element[0]){o[s].proportions().height=0;continue t}o[s].visible="none"!==o[s].element.css("display"),o[s].visible&&("mousedown"===a&&o[s]._activate.call(o[s],i),o[s].offset=o[s].element.offset(),o[s].proportions({width:o[s].element[0].offsetWidth,height:o[s].element[0].offsetHeight}))}},drop:function(e,i){var s=!1;return t.each((t.ui.ddmanager.droppables[e.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&o(e,this,this.options.tolerance,i)&&(s=this._drop.call(this,i)||s),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],e.currentItem||e.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,i)))}),s},dragStart:function(e,i){e.element.parentsUntil("body").on("scroll.droppable",function(){e.options.refreshPositions||t.ui.ddmanager.prepareOffsets(e,i)})},drag:function(e,i){e.options.refreshPositions&&t.ui.ddmanager.prepareOffsets(e,i),t.each(t.ui.ddmanager.droppables[e.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var s,n,a,r=o(e,this,this.options.tolerance,i),l=!r&&this.isover?"isout":r&&!this.isover?"isover":null;l&&(this.options.greedy&&(n=this.options.scope,a=this.element.parents(":data(ui-droppable)").filter(function(){return t(this).droppable("instance").options.scope===n}),a.length&&(s=t(a[0]).droppable("instance"),s.greedyChild="isover"===l)),s&&"isover"===l&&(s.isover=!1,s.isout=!0,s._out.call(s,i)),this[l]=!0,this["isout"===l?"isover":"isout"]=!1,this["isover"===l?"_over":"_out"].call(this,i),s&&"isout"===l&&(s.isout=!1,s.isover=!0,s._over.call(s,i)))}})},dragStop:function(e,i){e.element.parentsUntil("body").off("scroll.droppable"),e.options.refreshPositions||t.ui.ddmanager.prepareOffsets(e,i)}},t.uiBackCompat!==!1&&t.widget("ui.droppable",t.ui.droppable,{options:{hoverClass:!1,activeClass:!1},_addActiveClass:function(){this._super(),this.options.activeClass&&this.element.addClass(this.options.activeClass)},_removeActiveClass:function(){this._super(),this.options.activeClass&&this.element.removeClass(this.options.activeClass)},_addHoverClass:function(){this._super(),this.options.hoverClass&&this.element.addClass(this.options.hoverClass)},_removeHoverClass:function(){this._super(),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass)}}),t.ui.droppable,t.widget("ui.resizable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,classes:{"ui-resizable-se":"ui-icon ui-icon-gripsmall-diagonal-se"},containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseFloat(t)||0},_isNumber:function(t){return!isNaN(parseFloat(t))},_hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)},_create:function(){var e,i=this.options,s=this;this._addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(t("
").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,e={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(e),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(e),this._proportionallyResize()),this._setupHandles(),i.autoHide&&t(this.element).on("mouseenter",function(){i.disabled||(s._removeClass("ui-resizable-autohide"),s._handles.show())}).on("mouseleave",function(){i.disabled||s.resizing||(s._addClass("ui-resizable-autohide"),s._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeData("resizable").removeData("ui-resizable").off(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;default:}},_setupHandles:function(){var e,i,s,n,o,a=this.options,r=this;if(this.handles=a.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=t(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),s=this.handles.split(","),this.handles={},i=0;s.length>i;i++)e=t.trim(s[i]),n="ui-resizable-"+e,o=t(""),this._addClass(o,"ui-resizable-handle "+n),o.css({zIndex:a.zIndex}),this.handles[e]=".ui-resizable-"+e,this.element.append(o);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=t(this.handles[i]),this._on(this.handles[i],{mousedown:r._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){r.resizing||(this.className&&(o=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),r.axis=o&&o[1]?o[1]:"se")}),a.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._handles.remove()},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(e){var i,s,n,o=this.options,a=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),o.containment&&(i+=t(o.containment).scrollLeft()||0,s+=t(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:e.pageX,top:e.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===n?this.axis+"-resize":n),this._addClass("ui-resizable-resizing"),this._propagate("start",e),!0},_mouseDrag:function(e){var i,s,n=this.originalMousePosition,o=this.axis,a=e.pageX-n.left||0,r=e.pageY-n.top||0,l=this._change[o];return this._updatePrevProperties(),l?(i=l.apply(this,[e,a,r]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",e,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,l,h=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseFloat(c.element.css("left"))+(c.position.left-c.originalPosition.left)||null,l=parseFloat(c.element.css("top"))+(c.position.top-c.originalPosition.top)||null,h.animate||this.element.css(t.extend(a,{top:l,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!h.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s,n,o,a=this.options;o={minWidth:this._isNumber(a.minWidth)?a.minWidth:0,maxWidth:this._isNumber(a.maxWidth)?a.maxWidth:1/0,minHeight:this._isNumber(a.minHeight)?a.minHeight:0,maxHeight:this._isNumber(a.maxHeight)?a.maxHeight:1/0},(this._aspectRatio||t)&&(e=o.minHeight*this.aspectRatio,s=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,n=o.maxWidth/this.aspectRatio,e>o.minWidth&&(o.minWidth=e),s>o.minHeight&&(o.minHeight=s),o.maxWidth>i&&(o.maxWidth=i),o.maxHeight>n&&(o.maxHeight=n)),this._vBoundaries=o},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidth
t.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,l=this.originalPosition.top+this.originalSize.height,h=/sw|nw|w/.test(i),c=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&h&&(t.left=r-e.minWidth),s&&h&&(t.left=r-e.maxWidth),a&&c&&(t.top=l-e.minHeight),n&&c&&(t.top=l-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];4>e;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;this._proportionallyResizeElements.length>e;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
"),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,l={width:i.size.width-r,height:i.size.height-a},h=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,c=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(l,c&&h?{top:c,left:h}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var e,i,s,n,o,a,r,l=t(this).resizable("instance"),h=l.options,c=l.element,u=h.containment,d=u instanceof t?u.get(0):/parent/.test(u)?c.parent().get(0):u;d&&(l.containerElement=t(d),/document/.test(u)||u===document?(l.containerOffset={left:0,top:0},l.containerPosition={left:0,top:0},l.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(e=t(d),i=[],t(["Top","Right","Left","Bottom"]).each(function(t,s){i[t]=l._num(e.css("padding"+s))}),l.containerOffset=e.offset(),l.containerPosition=e.position(),l.containerSize={height:e.innerHeight()-i[3],width:e.innerWidth()-i[1]},s=l.containerOffset,n=l.containerSize.height,o=l.containerSize.width,a=l._hasScroll(d,"left")?d.scrollWidth:o,r=l._hasScroll(d)?d.scrollHeight:n,l.parentData={element:d,left:s.left,top:s.top,width:a,height:r}))},resize:function(e){var i,s,n,o,a=t(this).resizable("instance"),r=a.options,l=a.containerOffset,h=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(u=l),h.left<(a._helper?l.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-l.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio,p=!1),a.position.left=r.helper?l.left:0),h.top<(a._helper?l.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-l.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio,p=!1),a.position.top=a._helper?l.top:0),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o?(a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top):(a.offset.left=a.element.offset().left,a.offset.top=a.element.offset().top),i=Math.abs(a.sizeDiff.width+(a._helper?a.offset.left-u.left:a.offset.left-l.left)),s=Math.abs(a.sizeDiff.height+(a._helper?a.offset.top-u.top:a.offset.top-l.top)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio,p=!1)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio,p=!1)),p||(a.position.left=a.prevPosition.left,a.position.top=a.prevPosition.top,a.size.width=a.prevSize.width,a.size.height=a.prevSize.height)},stop:function(){var e=t(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),l=a.outerWidth()-e.sizeDiff.width,h=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:l,height:h}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:l,height:h})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).resizable("instance"),i=e.options;t(i.alsoResize).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseFloat(e.width()),height:parseFloat(e.height()),left:parseFloat(e.css("left")),top:parseFloat(e.css("top"))})})},resize:function(e,i){var s=t(this).resizable("instance"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0};t(n.alsoResize).each(function(){var e=t(this),s=t(this).data("ui-resizable-alsoresize"),n={},o=e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(o,function(t,e){var i=(s[e]||0)+(r[e]||0);i&&i>=0&&(n[e]=i||null)}),e.css(n)})},stop:function(){t(this).removeData("ui-resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).resizable("instance"),i=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:i.height,width:i.width,margin:0,left:0,top:0}),e._addClass(e.ghost,"ui-resizable-ghost"),t.uiBackCompat!==!1&&"string"==typeof e.options.ghost&&e.ghost.addClass(this.options.ghost),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).resizable("instance");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).resizable("instance");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e,i=t(this).resizable("instance"),s=i.options,n=i.size,o=i.originalSize,a=i.originalPosition,r=i.axis,l="number"==typeof s.grid?[s.grid,s.grid]:s.grid,h=l[0]||1,c=l[1]||1,u=Math.round((n.width-o.width)/h)*h,d=Math.round((n.height-o.height)/c)*c,p=o.width+u,f=o.height+d,g=s.maxWidth&&p>s.maxWidth,m=s.maxHeight&&f>s.maxHeight,_=s.minWidth&&s.minWidth>p,v=s.minHeight&&s.minHeight>f;s.grid=l,_&&(p+=h),v&&(f+=c),g&&(p-=h),m&&(f-=c),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=a.top-d):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=a.left-u):((0>=f-c||0>=p-h)&&(e=i._getPaddingPlusBorderDimensions(this)),f-c>0?(i.size.height=f,i.position.top=a.top-d):(f=c-e.height,i.size.height=f,i.position.top=a.top+o.height-f),p-h>0?(i.size.width=p,i.position.left=a.left-u):(p=h-e.width,i.size.width=p,i.position.left=a.left+o.width-p))
+}}),t.ui.resizable,t.widget("ui.selectable",t.ui.mouse,{version:"1.12.1",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var e=this;this._addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){e.elementPos=t(e.element[0]).offset(),e.selectees=t(e.options.filter,e.element[0]),e._addClass(e.selectees,"ui-selectee"),e.selectees.each(function(){var i=t(this),s=i.offset(),n={left:s.left-e.elementPos.left,top:s.top-e.elementPos.top};t.data(this,"selectable-item",{element:this,$element:i,left:n.left,top:n.top,right:n.left+i.outerWidth(),bottom:n.top+i.outerHeight(),startselected:!1,selected:i.hasClass("ui-selected"),selecting:i.hasClass("ui-selecting"),unselecting:i.hasClass("ui-unselecting")})})},this.refresh(),this._mouseInit(),this.helper=t(""),this._addClass(this.helper,"ui-selectable-helper")},_destroy:function(){this.selectees.removeData("selectable-item"),this._mouseDestroy()},_mouseStart:function(e){var i=this,s=this.options;this.opos=[e.pageX,e.pageY],this.elementPos=t(this.element[0]).offset(),this.options.disabled||(this.selectees=t(s.filter,this.element[0]),this._trigger("start",e),t(s.appendTo).append(this.helper),this.helper.css({left:e.pageX,top:e.pageY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=t.data(this,"selectable-item");s.startselected=!0,e.metaKey||e.ctrlKey||(i._removeClass(s.$element,"ui-selected"),s.selected=!1,i._addClass(s.$element,"ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",e,{unselecting:s.element}))}),t(e.target).parents().addBack().each(function(){var s,n=t.data(this,"selectable-item");return n?(s=!e.metaKey&&!e.ctrlKey||!n.$element.hasClass("ui-selected"),i._removeClass(n.$element,s?"ui-unselecting":"ui-selected")._addClass(n.$element,s?"ui-selecting":"ui-unselecting"),n.unselecting=!s,n.selecting=s,n.selected=s,s?i._trigger("selecting",e,{selecting:n.element}):i._trigger("unselecting",e,{unselecting:n.element}),!1):void 0}))},_mouseDrag:function(e){if(this.dragged=!0,!this.options.disabled){var i,s=this,n=this.options,o=this.opos[0],a=this.opos[1],r=e.pageX,l=e.pageY;return o>r&&(i=r,r=o,o=i),a>l&&(i=l,l=a,a=i),this.helper.css({left:o,top:a,width:r-o,height:l-a}),this.selectees.each(function(){var i=t.data(this,"selectable-item"),h=!1,c={};i&&i.element!==s.element[0]&&(c.left=i.left+s.elementPos.left,c.right=i.right+s.elementPos.left,c.top=i.top+s.elementPos.top,c.bottom=i.bottom+s.elementPos.top,"touch"===n.tolerance?h=!(c.left>r||o>c.right||c.top>l||a>c.bottom):"fit"===n.tolerance&&(h=c.left>o&&r>c.right&&c.top>a&&l>c.bottom),h?(i.selected&&(s._removeClass(i.$element,"ui-selected"),i.selected=!1),i.unselecting&&(s._removeClass(i.$element,"ui-unselecting"),i.unselecting=!1),i.selecting||(s._addClass(i.$element,"ui-selecting"),i.selecting=!0,s._trigger("selecting",e,{selecting:i.element}))):(i.selecting&&((e.metaKey||e.ctrlKey)&&i.startselected?(s._removeClass(i.$element,"ui-selecting"),i.selecting=!1,s._addClass(i.$element,"ui-selected"),i.selected=!0):(s._removeClass(i.$element,"ui-selecting"),i.selecting=!1,i.startselected&&(s._addClass(i.$element,"ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",e,{unselecting:i.element}))),i.selected&&(e.metaKey||e.ctrlKey||i.startselected||(s._removeClass(i.$element,"ui-selected"),i.selected=!1,s._addClass(i.$element,"ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",e,{unselecting:i.element})))))}),!1}},_mouseStop:function(e){var i=this;return this.dragged=!1,t(".ui-unselecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");i._removeClass(s.$element,"ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",e,{unselected:s.element})}),t(".ui-selecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");i._removeClass(s.$element,"ui-selecting")._addClass(s.$element,"ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",e,{selected:s.element})}),this._trigger("stop",e),this.helper.remove(),!1}}),t.widget("ui.sortable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(t,e,i){return t>=e&&e+i>t},_isFloating:function(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))},_create:function(){this.containerCache={},this._addClass("ui-sortable"),this.refresh(),this.offset=this.element.offset(),this._mouseInit(),this._setHandleClassName(),this.ready=!0},_setOption:function(t,e){this._super(t,e),"handle"===t&&this._setHandleClassName()},_setHandleClassName:function(){var e=this;this._removeClass(this.element.find(".ui-sortable-handle"),"ui-sortable-handle"),t.each(this.items,function(){e._addClass(this.instance.options.handle?this.item.find(this.instance.options.handle):this.item,"ui-sortable-handle")})},_destroy:function(){this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_mouseCapture:function(e,i){var s=null,n=!1,o=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(e),t(e.target).parents().each(function(){return t.data(this,o.widgetName+"-item")===o?(s=t(this),!1):void 0}),t.data(e.target,o.widgetName+"-item")===o&&(s=t(e.target)),s?!this.options.handle||i||(t(this.options.handle,s).find("*").addBack().each(function(){this===e.target&&(n=!0)}),n)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(e,i,s){var n,o,a=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,a.cursorAt&&this._adjustOffsetFromHelper(a.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),a.containment&&this._setContainment(),a.cursor&&"auto"!==a.cursor&&(o=this.document.find("body"),this.storedCursor=o.css("cursor"),o.css("cursor",a.cursor),this.storedStylesheet=t("").appendTo(o)),a.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",a.opacity)),a.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",a.zIndex)),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!a.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this._addClass(this.helper,"ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,s,n,o,a=this.options,r=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY
=0;i--)if(s=this.items[i],n=s.item[0],o=this._intersectsWithPointer(s),o&&s.instance===this.currentContainer&&n!==this.currentItem[0]&&this.placeholder[1===o?"next":"prev"]()[0]!==n&&!t.contains(this.placeholder[0],n)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],n):!0)){if(this.direction=1===o?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break;this._rearrange(e,s),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var s=this,n=this.placeholder.offset(),o=this.options.axis,a={};o&&"x"!==o||(a.left=n.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollLeft)),o&&"y"!==o||(a.top=n.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(a,parseInt(this.options.revert,10)||500,function(){s._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp(new t.Event("mouseup",{target:null})),"original"===this.options.helper?(this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&s.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!s.length&&e.key&&s.push(e.key+"="),s.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},i.each(function(){s.push(t(e.item||this).attr(e.attribute||"id")||"")}),s},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,o=t.left,a=o+t.width,r=t.top,l=r+t.height,h=this.offset.click.top,c=this.offset.click.left,u="x"===this.options.axis||s+h>r&&l>s+h,d="y"===this.options.axis||e+c>o&&a>e+c,p=u&&d;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?p:e+this.helperProportions.width/2>o&&a>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>r&&l>n-this.helperProportions.height/2},_intersectsWithPointer:function(t){var e,i,s="x"===this.options.axis||this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),n="y"===this.options.axis||this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width),o=s&&n;return o?(e=this._getDragVerticalDirection(),i=this._getDragHorizontalDirection(),this.floating?"right"===i||"down"===e?2:1:e&&("down"===e?2:1)):!1},_intersectsWithSides:function(t){var e=this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),i=this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),s=this._getDragVerticalDirection(),n=this._getDragHorizontalDirection();return this.floating&&n?"right"===n&&i||"left"===n&&!i:s&&("down"===s&&e||"up"===s&&!e)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!==t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this._setHandleClassName(),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){function i(){r.push(this)}var s,n,o,a,r=[],l=[],h=this._connectWith();if(h&&e)for(s=h.length-1;s>=0;s--)for(o=t(h[s],this.document[0]),n=o.length-1;n>=0;n--)a=t.data(o[n],this.widgetFullName),a&&a!==this&&!a.options.disabled&&l.push([t.isFunction(a.options.items)?a.options.items.call(a.element):t(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a]);for(l.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),s=l.length-1;s>=0;s--)l[s][0].each(i);return t(r)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;e.length>i;i++)if(e[i]===t.item[0])return!1;return!0})},_refreshItems:function(e){this.items=[],this.containers=[this];var i,s,n,o,a,r,l,h,c=this.items,u=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],d=this._connectWith();if(d&&this.ready)for(i=d.length-1;i>=0;i--)for(n=t(d[i],this.document[0]),s=n.length-1;s>=0;s--)o=t.data(n[s],this.widgetFullName),o&&o!==this&&!o.options.disabled&&(u.push([t.isFunction(o.options.items)?o.options.items.call(o.element[0],e,{item:this.currentItem}):t(o.options.items,o.element),o]),this.containers.push(o));for(i=u.length-1;i>=0;i--)for(a=u[i][1],r=u[i][0],s=0,h=r.length;h>s;s++)l=t(r[s]),l.data(this.widgetName+"-item",a),c.push({item:l,instance:a,width:0,height:0,left:0,top:0})},refreshPositions:function(e){this.floating=this.items.length?"x"===this.options.axis||this._isFloating(this.items[0].item):!1,this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,s,n,o;for(i=this.items.length-1;i>=0;i--)s=this.items[i],s.instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(n=this.options.toleranceElement?t(this.options.toleranceElement,s.item):s.item,e||(s.width=n.outerWidth(),s.height=n.outerHeight()),o=n.offset(),s.left=o.left,s.top=o.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)o=this.containers[i].element.offset(),this.containers[i].containerCache.left=o.left,this.containers[i].containerCache.top=o.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){e=e||this;var i,s=e.options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=e.currentItem[0].nodeName.toLowerCase(),n=t("<"+s+">",e.document[0]);return e._addClass(n,"ui-sortable-placeholder",i||e.currentItem[0].className)._removeClass(n,"ui-sortable-helper"),"tbody"===s?e._createTrPlaceholder(e.currentItem.find("tr").eq(0),t("",e.document[0]).appendTo(n)):"tr"===s?e._createTrPlaceholder(e.currentItem,n):"img"===s&&n.attr("src",e.currentItem.attr("src")),i||n.css("visibility","hidden"),n},update:function(t,n){(!i||s.forcePlaceholderSize)&&(n.height()||n.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),n.width()||n.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(s.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),s.placeholder.update(e,e.placeholder)},_createTrPlaceholder:function(e,i){var s=this;e.children().each(function(){t(" ",s.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(i)})},_contactContainers:function(e){var i,s,n,o,a,r,l,h,c,u,d=null,p=null;for(i=this.containers.length-1;i>=0;i--)if(!t.contains(this.currentItem[0],this.containers[i].element[0]))if(this._intersectsWith(this.containers[i].containerCache)){if(d&&t.contains(this.containers[i].element[0],d.element[0]))continue;d=this.containers[i],p=i}else this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",e,this._uiHash(this)),this.containers[i].containerCache.over=0);if(d)if(1===this.containers.length)this.containers[p].containerCache.over||(this.containers[p]._trigger("over",e,this._uiHash(this)),this.containers[p].containerCache.over=1);else{for(n=1e4,o=null,c=d.floating||this._isFloating(this.currentItem),a=c?"left":"top",r=c?"width":"height",u=c?"pageX":"pageY",s=this.items.length-1;s>=0;s--)t.contains(this.containers[p].element[0],this.items[s].item[0])&&this.items[s].item[0]!==this.currentItem[0]&&(l=this.items[s].item.offset()[a],h=!1,e[u]-l>this.items[s][r]/2&&(h=!0),n>Math.abs(e[u]-l)&&(n=Math.abs(e[u]-l),o=this.items[s],this.direction=h?"up":"down"));if(!o&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[p])return this.currentContainer.containerCache.over||(this.containers[p]._trigger("over",e,this._uiHash()),this.currentContainer.containerCache.over=1),void 0;o?this._rearrange(e,o,null,!0):this._rearrange(e,null,this.containers[p].element,!0),this._trigger("change",e,this._uiHash()),this.containers[p]._trigger("change",e,this._uiHash(this)),this.currentContainer=this.containers[p],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[p]._trigger("over",e,this._uiHash(this)),this.containers[p].containerCache.over=1}},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||t("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(!s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===this.document[0].body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options;"parent"===n.containment&&(n.containment=this.helper[0].parentNode),("document"===n.containment||"window"===n.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,"document"===n.containment?this.document.width():this.window.width()-this.helperProportions.width-this.margins.left,("document"===n.containment?this.document.height()||document.body.parentNode.scrollHeight:this.window.height()||this.document[0].body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(n.containment)||(e=t(n.containment)[0],i=t(n.containment).offset(),s="hidden"!==t(e).css("overflow"),this.containment=[i.left+(parseInt(t(e).css("borderLeftWidth"),10)||0)+(parseInt(t(e).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(t(e).css("borderTopWidth"),10)||0)+(parseInt(t(e).css("paddingTop"),10)||0)-this.margins.top,i.left+(s?Math.max(e.scrollWidth,e.offsetWidth):e.offsetWidth)-(parseInt(t(e).css("borderLeftWidth"),10)||0)-(parseInt(t(e).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(s?Math.max(e.scrollHeight,e.offsetHeight):e.offsetHeight)-(parseInt(t(e).css("borderTopWidth"),10)||0)-(parseInt(t(e).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(e,i){i||(i=this.position);var s="absolute"===e?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(n[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():o?0:n.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():o?0:n.scrollLeft())*s}},_generatePosition:function(e){var i,s,n=this.options,o=e.pageX,a=e.pageY,r="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,l=/(html|body)/i.test(r[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.leftthis.containment[2]&&(o=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(a=this.containment[3]+this.offset.click.top)),n.grid&&(i=this.originalPageY+Math.round((a-this.originalPageY)/n.grid[1])*n.grid[1],a=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-n.grid[1]:i+n.grid[1]:i,s=this.originalPageX+Math.round((o-this.originalPageX)/n.grid[0])*n.grid[0],o=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-n.grid[0]:s+n.grid[0]:s)),{top:a-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():l?0:r.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():l?0:r.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){function i(t,e,i){return function(s){i._trigger(t,s,e._uiHash(e))}}this.reverting=!1;var s,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(s in this._storedCSS)("auto"===this._storedCSS[s]||"static"===this._storedCSS[s])&&(this._storedCSS[s]="");this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&n.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||n.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(n.push(function(t){this._trigger("remove",t,this._uiHash())}),n.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),s=this.containers.length-1;s>=0;s--)e||n.push(i("deactivate",this,this.containers[s])),this.containers[s].containerCache.over&&(n.push(i("out",this,this.containers[s])),this.containers[s].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.cancelHelperRemoval||(this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null),!e){for(s=0;n.length>s;s++)n[s].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!this.cancelHelperRemoval},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}});var a="ui-effects-",r="ui-effects-style",l="ui-effects-animated",h=t;t.effects={effect:{}},function(t,e){function i(t,e,i){var s=u[e.type]||{};return null==t?i||!e.def?null:e.def:(t=s.floor?~~t:parseFloat(t),isNaN(t)?e.def:s.mod?(t+s.mod)%s.mod:0>t?0:t>s.max?s.max:t)}function s(i){var s=h(),n=s._rgba=[];return i=i.toLowerCase(),f(l,function(t,o){var a,r=o.re.exec(i),l=r&&o.parse(r),h=o.space||"rgba";return l?(a=s[h](l),s[c[h].cache]=a[c[h].cache],n=s._rgba=a._rgba,!1):e}),n.length?("0,0,0,0"===n.join()&&t.extend(n,o.transparent),s):o[i]}function n(t,e,i){return i=(i+1)%1,1>6*i?t+6*(e-t)*i:1>2*i?e:2>3*i?t+6*(e-t)*(2/3-i):t}var o,a="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",r=/^([\-+])=\s*(\d+\.?\d*)/,l=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[t[1],t[2],t[3],t[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[2.55*t[1],2.55*t[2],2.55*t[3],t[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(t){return[t[1],t[2]/100,t[3]/100,t[4]]}}],h=t.Color=function(e,i,s,n){return new t.Color.fn.parse(e,i,s,n)},c={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},u={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},d=h.support={},p=t("")[0],f=t.each;p.style.cssText="background-color:rgba(1,1,1,.5)",d.rgba=p.style.backgroundColor.indexOf("rgba")>-1,f(c,function(t,e){e.cache="_"+t,e.props.alpha={idx:3,type:"percent",def:1}}),h.fn=t.extend(h.prototype,{parse:function(n,a,r,l){if(n===e)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=t(n).css(a),a=e);var u=this,d=t.type(n),p=this._rgba=[];return a!==e&&(n=[n,a,r,l],d="array"),"string"===d?this.parse(s(n)||o._default):"array"===d?(f(c.rgba.props,function(t,e){p[e.idx]=i(n[e.idx],e)}),this):"object"===d?(n instanceof h?f(c,function(t,e){n[e.cache]&&(u[e.cache]=n[e.cache].slice())}):f(c,function(e,s){var o=s.cache;f(s.props,function(t,e){if(!u[o]&&s.to){if("alpha"===t||null==n[t])return;u[o]=s.to(u._rgba)}u[o][e.idx]=i(n[t],e,!0)}),u[o]&&0>t.inArray(null,u[o].slice(0,3))&&(u[o][3]=1,s.from&&(u._rgba=s.from(u[o])))}),this):e},is:function(t){var i=h(t),s=!0,n=this;return f(c,function(t,o){var a,r=i[o.cache];return r&&(a=n[o.cache]||o.to&&o.to(n._rgba)||[],f(o.props,function(t,i){return null!=r[i.idx]?s=r[i.idx]===a[i.idx]:e})),s}),s},_space:function(){var t=[],e=this;return f(c,function(i,s){e[s.cache]&&t.push(i)}),t.pop()},transition:function(t,e){var s=h(t),n=s._space(),o=c[n],a=0===this.alpha()?h("transparent"):this,r=a[o.cache]||o.to(a._rgba),l=r.slice();
+return s=s[o.cache],f(o.props,function(t,n){var o=n.idx,a=r[o],h=s[o],c=u[n.type]||{};null!==h&&(null===a?l[o]=h:(c.mod&&(h-a>c.mod/2?a+=c.mod:a-h>c.mod/2&&(a-=c.mod)),l[o]=i((h-a)*e+a,n)))}),this[n](l)},blend:function(e){if(1===this._rgba[3])return this;var i=this._rgba.slice(),s=i.pop(),n=h(e)._rgba;return h(t.map(i,function(t,e){return(1-s)*n[e]+s*t}))},toRgbaString:function(){var e="rgba(",i=t.map(this._rgba,function(t,e){return null==t?e>2?1:0:t});return 1===i[3]&&(i.pop(),e="rgb("),e+i.join()+")"},toHslaString:function(){var e="hsla(",i=t.map(this.hsla(),function(t,e){return null==t&&(t=e>2?1:0),e&&3>e&&(t=Math.round(100*t)+"%"),t});return 1===i[3]&&(i.pop(),e="hsl("),e+i.join()+")"},toHexString:function(e){var i=this._rgba.slice(),s=i.pop();return e&&i.push(~~(255*s)),"#"+t.map(i,function(t){return t=(t||0).toString(16),1===t.length?"0"+t:t}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),h.fn.parse.prototype=h.fn,c.hsla.to=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e,i,s=t[0]/255,n=t[1]/255,o=t[2]/255,a=t[3],r=Math.max(s,n,o),l=Math.min(s,n,o),h=r-l,c=r+l,u=.5*c;return e=l===r?0:s===r?60*(n-o)/h+360:n===r?60*(o-s)/h+120:60*(s-n)/h+240,i=0===h?0:.5>=u?h/c:h/(2-c),[Math.round(e)%360,i,u,null==a?1:a]},c.hsla.from=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/360,i=t[1],s=t[2],o=t[3],a=.5>=s?s*(1+i):s+i-s*i,r=2*s-a;return[Math.round(255*n(r,a,e+1/3)),Math.round(255*n(r,a,e)),Math.round(255*n(r,a,e-1/3)),o]},f(c,function(s,n){var o=n.props,a=n.cache,l=n.to,c=n.from;h.fn[s]=function(s){if(l&&!this[a]&&(this[a]=l(this._rgba)),s===e)return this[a].slice();var n,r=t.type(s),u="array"===r||"object"===r?s:arguments,d=this[a].slice();return f(o,function(t,e){var s=u["object"===r?t:e.idx];null==s&&(s=d[e.idx]),d[e.idx]=i(s,e)}),c?(n=h(c(d)),n[a]=d,n):h(d)},f(o,function(e,i){h.fn[e]||(h.fn[e]=function(n){var o,a=t.type(n),l="alpha"===e?this._hsla?"hsla":"rgba":s,h=this[l](),c=h[i.idx];return"undefined"===a?c:("function"===a&&(n=n.call(this,c),a=t.type(n)),null==n&&i.empty?this:("string"===a&&(o=r.exec(n),o&&(n=c+parseFloat(o[2])*("+"===o[1]?1:-1))),h[i.idx]=n,this[l](h)))})})}),h.hook=function(e){var i=e.split(" ");f(i,function(e,i){t.cssHooks[i]={set:function(e,n){var o,a,r="";if("transparent"!==n&&("string"!==t.type(n)||(o=s(n)))){if(n=h(o||n),!d.rgba&&1!==n._rgba[3]){for(a="backgroundColor"===i?e.parentNode:e;(""===r||"transparent"===r)&&a&&a.style;)try{r=t.css(a,"backgroundColor"),a=a.parentNode}catch(l){}n=n.blend(r&&"transparent"!==r?r:"_default")}n=n.toRgbaString()}try{e.style[i]=n}catch(l){}}},t.fx.step[i]=function(e){e.colorInit||(e.start=h(e.elem,i),e.end=h(e.end),e.colorInit=!0),t.cssHooks[i].set(e.elem,e.start.transition(e.end,e.pos))}})},h.hook(a),t.cssHooks.borderColor={expand:function(t){var e={};return f(["Top","Right","Bottom","Left"],function(i,s){e["border"+s+"Color"]=t}),e}},o=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(h),function(){function e(e){var i,s,n=e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,null):e.currentStyle,o={};if(n&&n.length&&n[0]&&n[n[0]])for(s=n.length;s--;)i=n[s],"string"==typeof n[i]&&(o[t.camelCase(i)]=n[i]);else for(i in n)"string"==typeof n[i]&&(o[i]=n[i]);return o}function i(e,i){var s,o,a={};for(s in i)o=i[s],e[s]!==o&&(n[s]||(t.fx.step[s]||!isNaN(parseFloat(o)))&&(a[s]=o));return a}var s=["add","remove","toggle"],n={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};t.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(e,i){t.fx.step[i]=function(t){("none"!==t.end&&!t.setAttr||1===t.pos&&!t.setAttr)&&(h.style(t.elem,i,t.end),t.setAttr=!0)}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.effects.animateClass=function(n,o,a,r){var l=t.speed(o,a,r);return this.queue(function(){var o,a=t(this),r=a.attr("class")||"",h=l.children?a.find("*").addBack():a;h=h.map(function(){var i=t(this);return{el:i,start:e(this)}}),o=function(){t.each(s,function(t,e){n[e]&&a[e+"Class"](n[e])})},o(),h=h.map(function(){return this.end=e(this.el[0]),this.diff=i(this.start,this.end),this}),a.attr("class",r),h=h.map(function(){var e=this,i=t.Deferred(),s=t.extend({},l,{queue:!1,complete:function(){i.resolve(e)}});return this.el.animate(this.diff,s),i.promise()}),t.when.apply(t,h.get()).done(function(){o(),t.each(arguments,function(){var e=this.el;t.each(this.diff,function(t){e.css(t,"")})}),l.complete.call(a[0])})})},t.fn.extend({addClass:function(e){return function(i,s,n,o){return s?t.effects.animateClass.call(this,{add:i},s,n,o):e.apply(this,arguments)}}(t.fn.addClass),removeClass:function(e){return function(i,s,n,o){return arguments.length>1?t.effects.animateClass.call(this,{remove:i},s,n,o):e.apply(this,arguments)}}(t.fn.removeClass),toggleClass:function(e){return function(i,s,n,o,a){return"boolean"==typeof s||void 0===s?n?t.effects.animateClass.call(this,s?{add:i}:{remove:i},n,o,a):e.apply(this,arguments):t.effects.animateClass.call(this,{toggle:i},s,n,o)}}(t.fn.toggleClass),switchClass:function(e,i,s,n,o){return t.effects.animateClass.call(this,{add:i,remove:e},s,n,o)}})}(),function(){function e(e,i,s,n){return t.isPlainObject(e)&&(i=e,e=e.effect),e={effect:e},null==i&&(i={}),t.isFunction(i)&&(n=i,s=null,i={}),("number"==typeof i||t.fx.speeds[i])&&(n=s,s=i,i={}),t.isFunction(s)&&(n=s,s=null),i&&t.extend(e,i),s=s||i.duration,e.duration=t.fx.off?0:"number"==typeof s?s:s in t.fx.speeds?t.fx.speeds[s]:t.fx.speeds._default,e.complete=n||i.complete,e}function i(e){return!e||"number"==typeof e||t.fx.speeds[e]?!0:"string"!=typeof e||t.effects.effect[e]?t.isFunction(e)?!0:"object"!=typeof e||e.effect?!1:!0:!0}function s(t,e){var i=e.outerWidth(),s=e.outerHeight(),n=/^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/,o=n.exec(t)||["",0,i,s,0];return{top:parseFloat(o[1])||0,right:"auto"===o[2]?i:parseFloat(o[2]),bottom:"auto"===o[3]?s:parseFloat(o[3]),left:parseFloat(o[4])||0}}t.expr&&t.expr.filters&&t.expr.filters.animated&&(t.expr.filters.animated=function(e){return function(i){return!!t(i).data(l)||e(i)}}(t.expr.filters.animated)),t.uiBackCompat!==!1&&t.extend(t.effects,{save:function(t,e){for(var i=0,s=e.length;s>i;i++)null!==e[i]&&t.data(a+e[i],t[0].style[e[i]])},restore:function(t,e){for(var i,s=0,n=e.length;n>s;s++)null!==e[s]&&(i=t.data(a+e[s]),t.css(e[s],i))},setMode:function(t,e){return"toggle"===e&&(e=t.is(":hidden")?"show":"hide"),e},createWrapper:function(e){if(e.parent().is(".ui-effects-wrapper"))return e.parent();var i={width:e.outerWidth(!0),height:e.outerHeight(!0),"float":e.css("float")},s=t("
").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),n={width:e.width(),height:e.height()},o=document.activeElement;try{o.id}catch(a){o=document.body}return e.wrap(s),(e[0]===o||t.contains(e[0],o))&&t(o).trigger("focus"),s=e.parent(),"static"===e.css("position")?(s.css({position:"relative"}),e.css({position:"relative"})):(t.extend(i,{position:e.css("position"),zIndex:e.css("z-index")}),t.each(["top","left","bottom","right"],function(t,s){i[s]=e.css(s),isNaN(parseInt(i[s],10))&&(i[s]="auto")}),e.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),e.css(n),s.css(i).show()},removeWrapper:function(e){var i=document.activeElement;return e.parent().is(".ui-effects-wrapper")&&(e.parent().replaceWith(e),(e[0]===i||t.contains(e[0],i))&&t(i).trigger("focus")),e}}),t.extend(t.effects,{version:"1.12.1",define:function(e,i,s){return s||(s=i,i="effect"),t.effects.effect[e]=s,t.effects.effect[e].mode=i,s},scaledDimensions:function(t,e,i){if(0===e)return{height:0,width:0,outerHeight:0,outerWidth:0};var s="horizontal"!==i?(e||100)/100:1,n="vertical"!==i?(e||100)/100:1;return{height:t.height()*n,width:t.width()*s,outerHeight:t.outerHeight()*n,outerWidth:t.outerWidth()*s}},clipToBox:function(t){return{width:t.clip.right-t.clip.left,height:t.clip.bottom-t.clip.top,left:t.clip.left,top:t.clip.top}},unshift:function(t,e,i){var s=t.queue();e>1&&s.splice.apply(s,[1,0].concat(s.splice(e,i))),t.dequeue()},saveStyle:function(t){t.data(r,t[0].style.cssText)},restoreStyle:function(t){t[0].style.cssText=t.data(r)||"",t.removeData(r)},mode:function(t,e){var i=t.is(":hidden");return"toggle"===e&&(e=i?"show":"hide"),(i?"hide"===e:"show"===e)&&(e="none"),e},getBaseline:function(t,e){var i,s;switch(t[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=t[0]/e.height}switch(t[1]){case"left":s=0;break;case"center":s=.5;break;case"right":s=1;break;default:s=t[1]/e.width}return{x:s,y:i}},createPlaceholder:function(e){var i,s=e.css("position"),n=e.position();return e.css({marginTop:e.css("marginTop"),marginBottom:e.css("marginBottom"),marginLeft:e.css("marginLeft"),marginRight:e.css("marginRight")}).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()),/^(static|relative)/.test(s)&&(s="absolute",i=t("<"+e[0].nodeName+">").insertAfter(e).css({display:/^(inline|ruby)/.test(e.css("display"))?"inline-block":"block",visibility:"hidden",marginTop:e.css("marginTop"),marginBottom:e.css("marginBottom"),marginLeft:e.css("marginLeft"),marginRight:e.css("marginRight"),"float":e.css("float")}).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()).addClass("ui-effects-placeholder"),e.data(a+"placeholder",i)),e.css({position:s,left:n.left,top:n.top}),i},removePlaceholder:function(t){var e=a+"placeholder",i=t.data(e);i&&(i.remove(),t.removeData(e))},cleanUp:function(e){t.effects.restoreStyle(e),t.effects.removePlaceholder(e)},setTransition:function(e,i,s,n){return n=n||{},t.each(i,function(t,i){var o=e.cssUnit(i);o[0]>0&&(n[i]=o[0]*s+o[1])}),n}}),t.fn.extend({effect:function(){function i(e){function i(){r.removeData(l),t.effects.cleanUp(r),"hide"===s.mode&&r.hide(),a()}function a(){t.isFunction(h)&&h.call(r[0]),t.isFunction(e)&&e()}var r=t(this);s.mode=u.shift(),t.uiBackCompat===!1||o?"none"===s.mode?(r[c](),a()):n.call(r[0],s,i):(r.is(":hidden")?"hide"===c:"show"===c)?(r[c](),a()):n.call(r[0],s,a)}var s=e.apply(this,arguments),n=t.effects.effect[s.effect],o=n.mode,a=s.queue,r=a||"fx",h=s.complete,c=s.mode,u=[],d=function(e){var i=t(this),s=t.effects.mode(i,c)||o;i.data(l,!0),u.push(s),o&&("show"===s||s===o&&"hide"===s)&&i.show(),o&&"none"===s||t.effects.saveStyle(i),t.isFunction(e)&&e()};return t.fx.off||!n?c?this[c](s.duration,h):this.each(function(){h&&h.call(this)}):a===!1?this.each(d).each(i):this.queue(r,d).queue(r,i)},show:function(t){return function(s){if(i(s))return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="show",this.effect.call(this,n)}}(t.fn.show),hide:function(t){return function(s){if(i(s))return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="hide",this.effect.call(this,n)}}(t.fn.hide),toggle:function(t){return function(s){if(i(s)||"boolean"==typeof s)return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="toggle",this.effect.call(this,n)}}(t.fn.toggle),cssUnit:function(e){var i=this.css(e),s=[];return t.each(["em","px","%","pt"],function(t,e){i.indexOf(e)>0&&(s=[parseFloat(i),e])}),s},cssClip:function(t){return t?this.css("clip","rect("+t.top+"px "+t.right+"px "+t.bottom+"px "+t.left+"px)"):s(this.css("clip"),this)},transfer:function(e,i){var s=t(this),n=t(e.to),o="fixed"===n.css("position"),a=t("body"),r=o?a.scrollTop():0,l=o?a.scrollLeft():0,h=n.offset(),c={top:h.top-r,left:h.left-l,height:n.innerHeight(),width:n.innerWidth()},u=s.offset(),d=t("
").appendTo("body").addClass(e.className).css({top:u.top-r,left:u.left-l,height:s.innerHeight(),width:s.innerWidth(),position:o?"fixed":"absolute"}).animate(c,e.duration,e.easing,function(){d.remove(),t.isFunction(i)&&i()})}}),t.fx.step.clip=function(e){e.clipInit||(e.start=t(e.elem).cssClip(),"string"==typeof e.end&&(e.end=s(e.end,e.elem)),e.clipInit=!0),t(e.elem).cssClip({top:e.pos*(e.end.top-e.start.top)+e.start.top,right:e.pos*(e.end.right-e.start.right)+e.start.right,bottom:e.pos*(e.end.bottom-e.start.bottom)+e.start.bottom,left:e.pos*(e.end.left-e.start.left)+e.start.left})}}(),function(){var e={};t.each(["Quad","Cubic","Quart","Quint","Expo"],function(t,i){e[i]=function(e){return Math.pow(e,t+2)}}),t.extend(e,{Sine:function(t){return 1-Math.cos(t*Math.PI/2)},Circ:function(t){return 1-Math.sqrt(1-t*t)},Elastic:function(t){return 0===t||1===t?t:-Math.pow(2,8*(t-1))*Math.sin((80*(t-1)-7.5)*Math.PI/15)},Back:function(t){return t*t*(3*t-2)},Bounce:function(t){for(var e,i=4;((e=Math.pow(2,--i))-1)/11>t;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*e-2)/22-t,2)}}),t.each(e,function(e,i){t.easing["easeIn"+e]=i,t.easing["easeOut"+e]=function(t){return 1-i(1-t)},t.easing["easeInOut"+e]=function(t){return.5>t?i(2*t)/2:1-i(-2*t+2)/2}})}();var c=t.effects;t.effects.define("blind","hide",function(e,i){var s={up:["bottom","top"],vertical:["bottom","top"],down:["top","bottom"],left:["right","left"],horizontal:["right","left"],right:["left","right"]},n=t(this),o=e.direction||"up",a=n.cssClip(),r={clip:t.extend({},a)},l=t.effects.createPlaceholder(n);r.clip[s[o][0]]=r.clip[s[o][1]],"show"===e.mode&&(n.cssClip(r.clip),l&&l.css(t.effects.clipToBox(r)),r.clip=a),l&&l.animate(t.effects.clipToBox(r),e.duration,e.easing),n.animate(r,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("bounce",function(e,i){var s,n,o,a=t(this),r=e.mode,l="hide"===r,h="show"===r,c=e.direction||"up",u=e.distance,d=e.times||5,p=2*d+(h||l?1:0),f=e.duration/p,g=e.easing,m="up"===c||"down"===c?"top":"left",_="up"===c||"left"===c,v=0,b=a.queue().length;for(t.effects.createPlaceholder(a),o=a.css(m),u||(u=a["top"===m?"outerHeight":"outerWidth"]()/3),h&&(n={opacity:1},n[m]=o,a.css("opacity",0).css(m,_?2*-u:2*u).animate(n,f,g)),l&&(u/=Math.pow(2,d-1)),n={},n[m]=o;d>v;v++)s={},s[m]=(_?"-=":"+=")+u,a.animate(s,f,g).animate(n,f,g),u=l?2*u:u/2;l&&(s={opacity:0},s[m]=(_?"-=":"+=")+u,a.animate(s,f,g)),a.queue(i),t.effects.unshift(a,b,p+1)}),t.effects.define("clip","hide",function(e,i){var s,n={},o=t(this),a=e.direction||"vertical",r="both"===a,l=r||"horizontal"===a,h=r||"vertical"===a;s=o.cssClip(),n.clip={top:h?(s.bottom-s.top)/2:s.top,right:l?(s.right-s.left)/2:s.right,bottom:h?(s.bottom-s.top)/2:s.bottom,left:l?(s.right-s.left)/2:s.left},t.effects.createPlaceholder(o),"show"===e.mode&&(o.cssClip(n.clip),n.clip=s),o.animate(n,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("drop","hide",function(e,i){var s,n=t(this),o=e.mode,a="show"===o,r=e.direction||"left",l="up"===r||"down"===r?"top":"left",h="up"===r||"left"===r?"-=":"+=",c="+="===h?"-=":"+=",u={opacity:0};t.effects.createPlaceholder(n),s=e.distance||n["top"===l?"outerHeight":"outerWidth"](!0)/2,u[l]=h+s,a&&(n.css(u),u[l]=c+s,u.opacity=1),n.animate(u,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("explode","hide",function(e,i){function s(){b.push(this),b.length===u*d&&n()}function n(){p.css({visibility:"visible"}),t(b).remove(),i()}var o,a,r,l,h,c,u=e.pieces?Math.round(Math.sqrt(e.pieces)):3,d=u,p=t(this),f=e.mode,g="show"===f,m=p.show().css("visibility","hidden").offset(),_=Math.ceil(p.outerWidth()/d),v=Math.ceil(p.outerHeight()/u),b=[];for(o=0;u>o;o++)for(l=m.top+o*v,c=o-(u-1)/2,a=0;d>a;a++)r=m.left+a*_,h=a-(d-1)/2,p.clone().appendTo("body").wrap("
").css({position:"absolute",visibility:"visible",left:-a*_,top:-o*v}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:_,height:v,left:r+(g?h*_:0),top:l+(g?c*v:0),opacity:g?0:1}).animate({left:r+(g?0:h*_),top:l+(g?0:c*v),opacity:g?1:0},e.duration||500,e.easing,s)}),t.effects.define("fade","toggle",function(e,i){var s="show"===e.mode;t(this).css("opacity",s?0:1).animate({opacity:s?1:0},{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("fold","hide",function(e,i){var s=t(this),n=e.mode,o="show"===n,a="hide"===n,r=e.size||15,l=/([0-9]+)%/.exec(r),h=!!e.horizFirst,c=h?["right","bottom"]:["bottom","right"],u=e.duration/2,d=t.effects.createPlaceholder(s),p=s.cssClip(),f={clip:t.extend({},p)},g={clip:t.extend({},p)},m=[p[c[0]],p[c[1]]],_=s.queue().length;l&&(r=parseInt(l[1],10)/100*m[a?0:1]),f.clip[c[0]]=r,g.clip[c[0]]=r,g.clip[c[1]]=0,o&&(s.cssClip(g.clip),d&&d.css(t.effects.clipToBox(g)),g.clip=p),s.queue(function(i){d&&d.animate(t.effects.clipToBox(f),u,e.easing).animate(t.effects.clipToBox(g),u,e.easing),i()}).animate(f,u,e.easing).animate(g,u,e.easing).queue(i),t.effects.unshift(s,_,4)}),t.effects.define("highlight","show",function(e,i){var s=t(this),n={backgroundColor:s.css("backgroundColor")};"hide"===e.mode&&(n.opacity=0),t.effects.saveStyle(s),s.css({backgroundImage:"none",backgroundColor:e.color||"#ffff99"}).animate(n,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("size",function(e,i){var s,n,o,a=t(this),r=["fontSize"],l=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],h=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],c=e.mode,u="effect"!==c,d=e.scale||"both",p=e.origin||["middle","center"],f=a.css("position"),g=a.position(),m=t.effects.scaledDimensions(a),_=e.from||m,v=e.to||t.effects.scaledDimensions(a,0);t.effects.createPlaceholder(a),"show"===c&&(o=_,_=v,v=o),n={from:{y:_.height/m.height,x:_.width/m.width},to:{y:v.height/m.height,x:v.width/m.width}},("box"===d||"both"===d)&&(n.from.y!==n.to.y&&(_=t.effects.setTransition(a,l,n.from.y,_),v=t.effects.setTransition(a,l,n.to.y,v)),n.from.x!==n.to.x&&(_=t.effects.setTransition(a,h,n.from.x,_),v=t.effects.setTransition(a,h,n.to.x,v))),("content"===d||"both"===d)&&n.from.y!==n.to.y&&(_=t.effects.setTransition(a,r,n.from.y,_),v=t.effects.setTransition(a,r,n.to.y,v)),p&&(s=t.effects.getBaseline(p,m),_.top=(m.outerHeight-_.outerHeight)*s.y+g.top,_.left=(m.outerWidth-_.outerWidth)*s.x+g.left,v.top=(m.outerHeight-v.outerHeight)*s.y+g.top,v.left=(m.outerWidth-v.outerWidth)*s.x+g.left),a.css(_),("content"===d||"both"===d)&&(l=l.concat(["marginTop","marginBottom"]).concat(r),h=h.concat(["marginLeft","marginRight"]),a.find("*[width]").each(function(){var i=t(this),s=t.effects.scaledDimensions(i),o={height:s.height*n.from.y,width:s.width*n.from.x,outerHeight:s.outerHeight*n.from.y,outerWidth:s.outerWidth*n.from.x},a={height:s.height*n.to.y,width:s.width*n.to.x,outerHeight:s.height*n.to.y,outerWidth:s.width*n.to.x};n.from.y!==n.to.y&&(o=t.effects.setTransition(i,l,n.from.y,o),a=t.effects.setTransition(i,l,n.to.y,a)),n.from.x!==n.to.x&&(o=t.effects.setTransition(i,h,n.from.x,o),a=t.effects.setTransition(i,h,n.to.x,a)),u&&t.effects.saveStyle(i),i.css(o),i.animate(a,e.duration,e.easing,function(){u&&t.effects.restoreStyle(i)})})),a.animate(v,{queue:!1,duration:e.duration,easing:e.easing,complete:function(){var e=a.offset();0===v.opacity&&a.css("opacity",_.opacity),u||(a.css("position","static"===f?"relative":f).offset(e),t.effects.saveStyle(a)),i()}})}),t.effects.define("scale",function(e,i){var s=t(this),n=e.mode,o=parseInt(e.percent,10)||(0===parseInt(e.percent,10)?0:"effect"!==n?0:100),a=t.extend(!0,{from:t.effects.scaledDimensions(s),to:t.effects.scaledDimensions(s,o,e.direction||"both"),origin:e.origin||["middle","center"]},e);e.fade&&(a.from.opacity=1,a.to.opacity=0),t.effects.effect.size.call(this,a,i)}),t.effects.define("puff","hide",function(e,i){var s=t.extend(!0,{},e,{fade:!0,percent:parseInt(e.percent,10)||150});t.effects.effect.scale.call(this,s,i)}),t.effects.define("pulsate","show",function(e,i){var s=t(this),n=e.mode,o="show"===n,a="hide"===n,r=o||a,l=2*(e.times||5)+(r?1:0),h=e.duration/l,c=0,u=1,d=s.queue().length;for((o||!s.is(":visible"))&&(s.css("opacity",0).show(),c=1);l>u;u++)s.animate({opacity:c},h,e.easing),c=1-c;s.animate({opacity:c},h,e.easing),s.queue(i),t.effects.unshift(s,d,l+1)}),t.effects.define("shake",function(e,i){var s=1,n=t(this),o=e.direction||"left",a=e.distance||20,r=e.times||3,l=2*r+1,h=Math.round(e.duration/l),c="up"===o||"down"===o?"top":"left",u="up"===o||"left"===o,d={},p={},f={},g=n.queue().length;for(t.effects.createPlaceholder(n),d[c]=(u?"-=":"+=")+a,p[c]=(u?"+=":"-=")+2*a,f[c]=(u?"-=":"+=")+2*a,n.animate(d,h,e.easing);r>s;s++)n.animate(p,h,e.easing).animate(f,h,e.easing);n.animate(p,h,e.easing).animate(d,h/2,e.easing).queue(i),t.effects.unshift(n,g,l+1)}),t.effects.define("slide","show",function(e,i){var s,n,o=t(this),a={up:["bottom","top"],down:["top","bottom"],left:["right","left"],right:["left","right"]},r=e.mode,l=e.direction||"left",h="up"===l||"down"===l?"top":"left",c="up"===l||"left"===l,u=e.distance||o["top"===h?"outerHeight":"outerWidth"](!0),d={};t.effects.createPlaceholder(o),s=o.cssClip(),n=o.position()[h],d[h]=(c?-1:1)*u+n,d.clip=o.cssClip(),d.clip[a[l][1]]=d.clip[a[l][0]],"show"===r&&(o.cssClip(d.clip),o.css(h,d[h]),d.clip=s,d[h]=n),o.animate(d,{queue:!1,duration:e.duration,easing:e.easing,complete:i})});var c;t.uiBackCompat!==!1&&(c=t.effects.define("transfer",function(e,i){t(this).transfer(e,i)}))});
\ No newline at end of file
diff --git a/src/widget/singleslider/singleslider.js b/src/widget/singleslider/singleslider.js
new file mode 100644
index 000000000..9662d5fdd
--- /dev/null
+++ b/src/widget/singleslider/singleslider.js
@@ -0,0 +1,299 @@
+/**
+ * Created by zcf on 2016/9/22.
+ */
+BI.SingleSlider = BI.inherit(BI.Widget, {
+ _constant: {
+ EDITOR_WIDTH: 60,
+ EDITOR_HEIGHT: 30,
+ HEIGHT: 28,
+ SLIDER_WIDTH_HALF: 15,
+ SLIDER_WIDTH: 30,
+ SLIDER_HEIGHT: 30,
+ TRACK_HEIGHT: 24
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-slider bi-slider-track"
+ });
+ },
+ _init: function () {
+ BI.SingleSlider.superclass._init.apply(this, arguments);
+
+ var self = this;
+ var c = this._constant;
+ this.enable = false;
+ this.value = "";
+
+ this.backgroundTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "background-track bi-background",
+ height: c.TRACK_HEIGHT
+ });
+ this.grayTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "gray-track",
+ height: 8
+ });
+ this.blueTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "blue-track bi-high-light-background",
+ height: 8
+ });
+ this.track = this._createTrackWrapper();
+
+ this.slider = BI.createWidget({
+ type: "bi.single_slider_slider"
+ });
+ this.slider.element.draggable({
+ axis: "x",
+ containment: this.grayTrack.element,
+ scroll: false,
+ drag: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1)); //直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
+ self._setBlueTrack(significantPercent);
+ self._setLabelPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.label.setValue(v);
+ self.value = v;
+ },
+ stop: function (e, ui) {
+ var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderPosition(significantPercent);
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }
+ });
+ var sliderVertical = BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [this.slider]
+ }],
+ hgap: c.SLIDER_WIDTH_HALF,
+ height: c.SLIDER_HEIGHT
+ });
+ sliderVertical.element.click(function (e) {
+ if (self.enable) {
+ var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF;
+ var trackLength = self.track.element[0].scrollWidth;
+ var percent = 0;
+ if (offset < 0) {
+ percent = 0
+ }
+ if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) {
+ percent = offset * 100 / self._getGrayTrackLength();
+ }
+ if (offset > (trackLength - c.SLIDER_WIDTH)) {
+ percent = 100
+ }
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setAllPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.label.setValue(v);
+ self.value = v;
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }
+ });
+ this.label = BI.createWidget({
+ type: "bi.sign_editor",
+ cls: "slider-editor-button",
+ errorText: "",
+ height: c.HEIGHT,
+ width: c.EDITOR_WIDTH,
+ allowBlank: false,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ },
+ quitChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var percent = self._getPercentByValue(this.getValue());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setAllPosition(significantPercent);
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ });
+ this.label.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.label.element.addClass("bi-border");
+ });
+ this.label.on(BI.SignEditor.EVENT_BLUR, function () {
+ self.label.element.removeClass("bi-border");
+ });
+ this._setVisible(false);
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.track,
+ width: "100%",
+ height: c.TRACK_HEIGHT
+ }]
+ }],
+ hgap: 7,
+ height: c.TRACK_HEIGHT
+ },
+ top: 33,
+ left: 0,
+ width: "100%"
+ }, {
+ el: sliderVertical,
+ top: 30,
+ left: 0,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [this.label]
+ }],
+ rgap: c.EDITOR_WIDTH / 2,
+ height: c.EDITOR_HEIGHT
+ },
+ top: 0,
+ left: 0,
+ width: "100%"
+ }]
+ })
+ },
+
+ _createTrackWrapper: function () {
+ return BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: this.backgroundTrack,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.grayTrack,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }, {
+ el: this.blueTrack,
+ top: 0,
+ left: 0,
+ width: "0%"
+ }]
+ }],
+ hgap: 8,
+ height: 8
+ },
+ top: 8,
+ left: 0,
+ width: "100%"
+ }]
+ })
+ },
+
+ _checkValidation: function (v) {
+ return !(BI.isNull(v) || v < this.min || v > this.max)
+ },
+
+ _setBlueTrack: function (percent) {
+ this.blueTrack.element.css({
+ "width": percent + "%"
+ });
+ },
+
+ _setLabelPosition: function (percent) {
+ this.label.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setSliderPosition: function (percent) {
+ this.slider.element.css({
+ "left": percent + "%"
+ });
+ },
+
+ _setAllPosition: function (percent) {
+ this._setSliderPosition(percent);
+ this._setLabelPosition(percent);
+ this._setBlueTrack(percent);
+ },
+
+ _setVisible: function (visible) {
+ this.slider.setVisible(visible);
+ this.label.setVisible(visible);
+ },
+
+ _getGrayTrackLength: function () {
+ return this.grayTrack.element[0].scrollWidth
+ },
+
+ _getValueByPercent: function (percent) {
+ var thousandth = BI.parseInt(percent * 10);
+ return (((this.max - this.min) * thousandth) / 1000 + this.min);
+ },
+
+ _getPercentByValue: function (v) {
+ return (v - this.min) * 100 / (this.max - this.min);
+ },
+
+ getValue: function () {
+ return this.value;
+ },
+
+ setValue: function (v) {
+ var value = BI.parseFloat(v);
+ if ((!isNaN(value))) {
+ if (this._checkValidation(value)) {
+ this.value = value;
+ }
+ if (value > this.max) {
+ this.value = this.max;
+ }
+ if (value < this.min) {
+ this.value = this.min;
+ }
+ }
+ },
+
+ setMinAndMax: function (v) {
+ var minNumber = BI.parseFloat(v.min);
+ var maxNumber = BI.parseFloat(v.max);
+ if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber)) {
+ this.min = minNumber;
+ this.max = maxNumber;
+ }
+ },
+
+ reset: function () {
+ this._setVisible(false);
+ this.enable = false;
+ this.value = "";
+ this.min = 0;
+ this.max = 0;
+ this._setBlueTrack(0);
+ },
+
+ populate: function () {
+ if (!isNaN(this.min) && !isNaN(this.max)) {
+ this._setVisible(true);
+ this.enable = true;
+ this.label.setErrorText(BI.i18nText("BI-Please_Enter") + this.min + "-" + this.max + BI.i18nText("BI-Basic_De") + BI.i18nText("BI-Basic_Number"));
+ if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
+ this.label.setValue(this.value);
+ this._setAllPosition(this._getPercentByValue(this.value));
+ } else {
+ this.label.setValue(this.max);
+ this._setAllPosition(100);
+ }
+ }
+ }
+});
+BI.SingleSlider.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_slider", BI.SingleSlider);
\ No newline at end of file
diff --git a/src/widget/singleslider/slider/widget.slider.js b/src/widget/singleslider/slider/widget.slider.js
new file mode 100644
index 000000000..1cf3462f9
--- /dev/null
+++ b/src/widget/singleslider/slider/widget.slider.js
@@ -0,0 +1,33 @@
+/**
+ * Created by zcf on 2016/9/22.
+ */
+BI.Slider = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Slider.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-slider-slider"
+ });
+ },
+ _init: function () {
+ BI.extend(BI.Slider.superclass._init.apply(this, arguments));
+ this.slider = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "widget-slider-icon",
+ iconWidth: 30,
+ iconHeight: 30,
+ height: 30,
+ width: 30
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.slider,
+ top: 0,
+ left: -15
+ }],
+ width: 0,
+ height: 30
+ });
+ }
+});
+BI.shortcut("bi.single_slider_slider", BI.Slider);
\ No newline at end of file