diff --git a/bi/base.js b/bi/base.js index 41d9f2b6f..bd50dc576 100644 --- a/bi/base.js +++ b/bi/base.js @@ -42,9 +42,6 @@ } else { this.onmousewheel = handler; } - // Store the line height and page height for this particular element - $.data(this, 'mousewheel-line-height', special.getLineHeight(this)); - $.data(this, 'mousewheel-page-height', special.getPageHeight(this)); }, teardown: function() { @@ -55,22 +52,6 @@ } else { this.onmousewheel = null; } - // Clean up the data we added to the element - $.removeData(this, 'mousewheel-line-height'); - $.removeData(this, 'mousewheel-page-height'); - }, - - getLineHeight: function(elem) { - var $elem = $(elem), - $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent'](); - if (!$parent.length) { - $parent = $('body'); - } - return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16; - }, - - getPageHeight: function(elem) { - return $(elem).height(); }, settings: { @@ -136,12 +117,12 @@ // * deltaMode 1 is by lines // * deltaMode 2 is by pages if ( orgEvent.deltaMode === 1 ) { - var lineHeight = $.data(this, 'mousewheel-line-height'); + var lineHeight = 40; delta *= lineHeight; deltaY *= lineHeight; deltaX *= lineHeight; } else if ( orgEvent.deltaMode === 2 ) { - var pageHeight = $.data(this, 'mousewheel-page-height'); + var pageHeight = 800; delta *= pageHeight; deltaY *= pageHeight; deltaX *= pageHeight; @@ -1489,10 +1470,6 @@ BI.TreeView = BI.inherit(BI.Pane, { }, _init: function () { BI.TreeView.superclass._init.apply(this, arguments); - - - - this._stop = false; this.container = BI.createWidget(); @@ -1969,10 +1946,10 @@ BI.TreeView = BI.inherit(BI.Pane, { } }); BI.extend(BI.TreeView, { - REQ_TYPE_INIT_DATA: 1, - REQ_TYPE_ADJUST_DATA: 2, - REQ_TYPE_CALCULATE_SELECT_DATA: 3, - REQ_TYPE_SELECTED_DATA: 4 + REQ_TYPE_INIT_DATA: 0, + REQ_TYPE_ADJUST_DATA: 1, + REQ_TYPE_CALCULATE_SELECT_DATA: 2, + REQ_TYPE_SELECTED_DATA: 3 }); BI.TreeView.EVENT_CHANGE = "EVENT_CHANGE"; @@ -3920,12 +3897,9 @@ BI.Navigation = BI.inherit(BI.Widget, { logic: { dynamic: false }, - defaultShowIndex: 0, - tab: { - type: "bi.button_group", - items: [], - layouts: [] - }, + single: false, + defaultShowIndex: false, + tab: false, cardCreator: function (v) { return BI.createWidget(); }, @@ -3963,7 +3937,7 @@ BI.Navigation = BI.inherit(BI.Widget, { }, afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardShow: BI.bind(this.afterCardShow, this) - }) + }); }, mounted: function () { @@ -3973,6 +3947,18 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, + _deleteOtherCards: function (currCardName) { + var self = this, o = this.options; + if (o.single === true) { + BI.each(this.cardMap, function (name, card) { + if (name !== (currCardName + "")) { + self.layout.deleteCardByName(name); + delete self.cardMap[name]; + } + }); + } + }, + afterCardCreated: function (v) { var self = this; this.cardMap[v].on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { @@ -3980,12 +3966,13 @@ BI.Navigation = BI.inherit(BI.Widget, { if (type === BI.Events.CLICK) { self.fireEvent(BI.Navigation.EVENT_CHANGE, obj); } - }) + }); this.options.afterCardCreated.apply(this, arguments); }, afterCardShow: function (v) { this.showIndex = v; + this._deleteOtherCards(v); this.options.afterCardShow.apply(this, arguments); }, @@ -3996,16 +3983,23 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, - setSelect: function (v) { - this.showIndex = v; + _assertCard: function (v) { if (!this.layout.isCardExisted(v)) { var card = this.options.cardCreator(v); this.cardMap[v] = card; this.layout.addCardByName(v, card); this.afterCardCreated(v); } + }, + + setSelect: function (v) { + this._assertCard(); this.layout.showCardByName(v); - BI.nextTick(BI.bind(this.afterCardShow, this, v)); + this._deleteOtherCards(v); + if (this.showIndex !== v) { + this.showIndex = v; + BI.nextTick(BI.bind(this.afterCardShow, this, v)); + } }, getSelect: function () { @@ -4636,6 +4630,7 @@ BI.Tab = BI.inherit(BI.Widget, { return BI.extend(BI.Tab.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-tab", direction: "top",//top, bottom, left, right, custom + single: false, //是不是单页面 logic: { dynamic: false }, @@ -4675,6 +4670,7 @@ BI.Tab = BI.inherit(BI.Widget, { return card; }, afterCardShow: function (v) { + self._deleteOtherCards(v); self.curr = v; } }); @@ -4683,6 +4679,18 @@ BI.Tab = BI.inherit(BI.Widget, { }); }, + _deleteOtherCards: function (currCardName) { + var self = this, o = this.options; + if (o.single === true) { + BI.each(this.cardMap, function (name, card) { + if (name !== (currCardName + "")) { + self.layout.deleteCardByName(name); + delete self.cardMap[name]; + } + }); + } + }, + _assertCard: function (v) { if (!this.layout.isCardExisted(v)) { var card = this.options.cardCreator(v); @@ -4702,6 +4710,7 @@ BI.Tab = BI.inherit(BI.Widget, { this.tab && this.tab.setValue(v); this._assertCard(v); this.layout.showCardByName(v); + this._deleteOtherCards(v); if (this.curr !== v) { this.curr = v; } @@ -28297,8 +28306,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); }, - _init: function () { - BI.CollectionTable.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; this._width = 0; this._height = 0; @@ -28434,6 +28442,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); this._width = o.width - BI.GridTableScrollbar.SIZE; this._height = o.height - BI.GridTableScrollbar.SIZE; + }, + + mounted: function () { + var o = this.options; if (o.items.length > 0 || o.header.length < 0) { this._digest(); this._populate(); @@ -28832,8 +28844,8 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, { }); }, - _init: function () { - BI.QuickCollectionTable.superclass._init.apply(this, arguments); + render: function () { + BI.QuickCollectionTable.superclass.render.apply(this, arguments); var self = this, o = this.options; this.topLeftCollection.setOverflowX(false); this.topLeftCollection.setOverflowY(false); @@ -28843,6 +28855,11 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, { this.bottomLeftCollection.setOverflowY(false); this.bottomRightCollection.setOverflowX(false); this.bottomRightCollection.setOverflowY(false); + }, + + mounted: function () { + BI.QuickCollectionTable.superclass.mounted.apply(this, arguments); + var self = this; this._leftWheelHandler = new BI.WheelHandler( BI.bind(this._onWheelY, this), BI.bind(this._shouldHandleX, this), @@ -29037,8 +29054,7 @@ BI.GridTable = BI.inherit(BI.Widget, { }); }, - _init: function () { - BI.GridTable.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; this._width = 0; this._height = 0; @@ -29181,6 +29197,10 @@ BI.GridTable = BI.inherit(BI.Widget, { this._height = o.height - BI.GridTableScrollbar.SIZE; this.header = this._getHeader(); this.items = this._getItems(); + }, + + mounted: function () { + var o = this.options; if (o.items.length > 0) { this._populate(); } @@ -29499,8 +29519,8 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, { }); }, - _init: function () { - BI.QuickGridTable.superclass._init.apply(this, arguments); + render: function () { + BI.QuickGridTable.superclass.render.apply(this, arguments); var self = this, o = this.options; this.topLeftGrid.setOverflowX(false); this.topLeftGrid.setOverflowY(false); @@ -29510,6 +29530,11 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, { this.bottomLeftGrid.setOverflowY(false); this.bottomRightGrid.setOverflowX(false); this.bottomRightGrid.setOverflowY(false); + }, + + mounted: function () { + BI.QuickGridTable.superclass.mounted.apply(this, arguments); + var self = this; this._leftWheelHandler = new BI.WheelHandler( BI.bind(this._onWheelY, this), BI.bind(this._shouldHandleX, this), @@ -29679,8 +29704,7 @@ BI.GridTableScrollbar = BI.inherit(BI.Widget, { }) }, - _init: function () { - BI.GridTableScrollbar.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; this.focused = false; this.isDragging = false; @@ -29698,6 +29722,10 @@ BI.GridTableScrollbar = BI.inherit(BI.Widget, { top: 0 }] }); + }, + + mounted: function () { + var self = this, o = this.options; var onWheel = o.orientation === 'horizontal' ? this._onWheelX : this._onWheelY; this._wheelHandler = new BI.WheelHandler( BI.bind(onWheel, this), @@ -30052,6 +30080,12 @@ BI.GridTableHorizontalScrollbar = BI.inherit(BI.Widget, { populate: function () { this.scrollbar.populate(); + var o = this.options; + if (o.size < 1 || o.contentSize <= o.size) { + this.setVisible(false); + return; + } + this.setVisible(true); } }); BI.GridTableHorizontalScrollbar.EVENT_SCROLL = "EVENT_SCROLL"; @@ -30973,11 +31007,9 @@ BI.Table = BI.inherit(BI.Widget, { }; this._initNormalScroll(); - BI.Resizers.add(this.getName(), function (e) { - if (self.element.is(":visible") && BI.isWindow(e.target)) { - self._resize(); - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE); - } + BI.ResizeDetector.addResizeListener(this, function () { + self._resize(); + self.fireEvent(BI.Table.EVENT_TABLE_RESIZE); }); BI.nextTick(function () { if (self.element.is(":visible")) { @@ -32003,7 +32035,6 @@ BI.Table = BI.inherit(BI.Widget, { }, empty: function () { - BI.Resizers.remove(this.getName()); BI.Table.superclass.empty.apply(this, arguments); }, diff --git a/bi/case.js b/bi/case.js index 86cab3357..a17d8e33d 100644 --- a/bi/case.js +++ b/bi/case.js @@ -8614,6 +8614,8 @@ BI.AllCountPager = BI.inherit(BI.Widget, { }) }, + alwaysShowPager: true, + setAllPages: function (v) { this.allPages.setText("/" + v); this.allPages.setTitle(v); @@ -8648,10 +8650,6 @@ BI.AllCountPager = BI.inherit(BI.Widget, { this.pager.setVisible(b); }, - getAliasWidth: function () { - return this.options.width - 100; - }, - populate: function () { this.pager.populate(); } @@ -8908,6 +8906,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { this.setVPagerVisible(true); vShow = true; } + this.setVisible(hShow || vShow); var num = [74, 111, -9, 28]; var items = this.layout.attr("items"); diff --git a/bi/core.js b/bi/core.js index af139ef2a..a176df9ba 100644 --- a/bi/core.js +++ b/bi/core.js @@ -1904,9 +1904,6 @@ if (!window.BI) { } ; !(function ($, undefined) { - _.extend(BI, { - version: "2.0" - }); var traverse = function (func, context) { return function (value, key, obj) { return func.call(context, key, value, obj); @@ -4487,6 +4484,10 @@ BI.Widget = BI.inherit(BI.OB, { this.destroyed && this.destroyed(); }, + isMounted: function () { + return this._isMounted; + }, + setWidth: function (w) { this.options.width = w; this._initElementWidth(); @@ -13289,7 +13290,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { isCardExisted: function (cardName) { return BI.some(this.options.items, function (i, item) { - return item.cardName === cardName && item.el; + return item.cardName == cardName && item.el; }); }, @@ -16934,23 +16935,6 @@ $(function () { BI.Func = {}; var formulas = {}; BI.extend(BI.Func, { - /** - * 创建唯一的名字 - * @param array - * @param name - * @returns {*} - */ - createDistinctName: function (array, name) { - var src = name, idx = 1; - name = name || ""; - while (true) { - if (!ArrayUtils.getItemByName(array, name)) { - break; - } - name = src + (idx++); - } - return name; - }, /** * 获取搜索结果 @@ -16998,60 +16982,6 @@ $(function () { finded: finded } }, - - /** - * 公式合法性验证 - */ - checkFormulaValidation: function (str) { - if (!BI.isEmptyString(str)) { - if (BI.has(formulas, str)) { - return formulas[str]; - } - formulas[str] = false; - var response = BI.requestSync("fr_bi_base", "check_validation_of_expression", {expression: str}); - if (response.validation === "invalid") { - formulas[str] = false; - } else if (response.validation === "valid") { - formulas[str] = true; - } - return formulas[str]; - } else { - return true; - } - }, - - getFormulaStringFromFormulaValue: function (formulaValue) { - var formulaString = ""; - var regx = /\$[\{][^\}]*[\}]|\w*\w|\$\{[^\$\(\)\+\-\*\/)\$,]*\w\}|\$\{[^\$\(\)\+\-\*\/]*\w\}|\$\{[^\$\(\)\+\-\*\/]*[\u4e00-\u9fa5]\}|\w|(.)/g; - var result = formulaValue.match(regx); - BI.each(result, function (i, item) { - var fieldRegx = /\$[\{][^\}]*[\}]/; - var str = item.match(fieldRegx); - if (BI.isNotEmptyArray(str)) { - formulaString = formulaString + str[0].substring(2, item.length - 1); - } else { - formulaString = formulaString + item; - } - }); - return formulaString; - }, - - formatAddress: function (address) { - var temp = ''; - var url1 = /[a-zA-z]+:\/\/[^\s]*/; - var url2 = /\/[^\s]*/; - if (address.match(url1) || address.match(url2)) { - temp = address; - } else if (BI.isNotEmptyString(address)) { - temp = "http://" + address; - } - return temp; - }, - - getCompleteImageUrl: function (url) { - return BI.servletURL + "?op=fr_bi&cmd=get_uploaded_image&image_id=" + url; - } - }); /** @@ -17104,19 +17034,13 @@ $(function () { }); }, - getImageWidthAndHeight: function (src) { - return BI.requestSync("fr_bi_base", "get_image_size", { - src: src - }); - }, - isDarkColor: function (hex) { if (!hex) { return false; } var rgb = this.rgb2json(this.hex2rgb(hex)); - var grayLevel = (rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114); - if (grayLevel < 192) { + var grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114); + if (grayLevel < 140) { return true; } return false; diff --git a/bi/widget.js b/bi/widget.js index f3289fdcd..52b58fb3b 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -12846,7 +12846,7 @@ BI.PageTable = BI.inherit(BI.Widget, { this.table = BI.createWidget(o.el, { type: "bi.sequence_table", width: o.width, - height: o.height - 30, + height: o.height && o.height - 30, isNeedResize: true, isResizeAdapt: false, @@ -12970,7 +12970,23 @@ BI.PageTable = BI.inherit(BI.Widget, { setHeight: function (height) { BI.PageTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height - 30); + 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) { diff --git a/dist/base.js b/dist/base.js index 41d9f2b6f..bd50dc576 100644 --- a/dist/base.js +++ b/dist/base.js @@ -42,9 +42,6 @@ } else { this.onmousewheel = handler; } - // Store the line height and page height for this particular element - $.data(this, 'mousewheel-line-height', special.getLineHeight(this)); - $.data(this, 'mousewheel-page-height', special.getPageHeight(this)); }, teardown: function() { @@ -55,22 +52,6 @@ } else { this.onmousewheel = null; } - // Clean up the data we added to the element - $.removeData(this, 'mousewheel-line-height'); - $.removeData(this, 'mousewheel-page-height'); - }, - - getLineHeight: function(elem) { - var $elem = $(elem), - $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent'](); - if (!$parent.length) { - $parent = $('body'); - } - return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16; - }, - - getPageHeight: function(elem) { - return $(elem).height(); }, settings: { @@ -136,12 +117,12 @@ // * deltaMode 1 is by lines // * deltaMode 2 is by pages if ( orgEvent.deltaMode === 1 ) { - var lineHeight = $.data(this, 'mousewheel-line-height'); + var lineHeight = 40; delta *= lineHeight; deltaY *= lineHeight; deltaX *= lineHeight; } else if ( orgEvent.deltaMode === 2 ) { - var pageHeight = $.data(this, 'mousewheel-page-height'); + var pageHeight = 800; delta *= pageHeight; deltaY *= pageHeight; deltaX *= pageHeight; @@ -1489,10 +1470,6 @@ BI.TreeView = BI.inherit(BI.Pane, { }, _init: function () { BI.TreeView.superclass._init.apply(this, arguments); - - - - this._stop = false; this.container = BI.createWidget(); @@ -1969,10 +1946,10 @@ BI.TreeView = BI.inherit(BI.Pane, { } }); BI.extend(BI.TreeView, { - REQ_TYPE_INIT_DATA: 1, - REQ_TYPE_ADJUST_DATA: 2, - REQ_TYPE_CALCULATE_SELECT_DATA: 3, - REQ_TYPE_SELECTED_DATA: 4 + REQ_TYPE_INIT_DATA: 0, + REQ_TYPE_ADJUST_DATA: 1, + REQ_TYPE_CALCULATE_SELECT_DATA: 2, + REQ_TYPE_SELECTED_DATA: 3 }); BI.TreeView.EVENT_CHANGE = "EVENT_CHANGE"; @@ -3920,12 +3897,9 @@ BI.Navigation = BI.inherit(BI.Widget, { logic: { dynamic: false }, - defaultShowIndex: 0, - tab: { - type: "bi.button_group", - items: [], - layouts: [] - }, + single: false, + defaultShowIndex: false, + tab: false, cardCreator: function (v) { return BI.createWidget(); }, @@ -3963,7 +3937,7 @@ BI.Navigation = BI.inherit(BI.Widget, { }, afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardShow: BI.bind(this.afterCardShow, this) - }) + }); }, mounted: function () { @@ -3973,6 +3947,18 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, + _deleteOtherCards: function (currCardName) { + var self = this, o = this.options; + if (o.single === true) { + BI.each(this.cardMap, function (name, card) { + if (name !== (currCardName + "")) { + self.layout.deleteCardByName(name); + delete self.cardMap[name]; + } + }); + } + }, + afterCardCreated: function (v) { var self = this; this.cardMap[v].on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { @@ -3980,12 +3966,13 @@ BI.Navigation = BI.inherit(BI.Widget, { if (type === BI.Events.CLICK) { self.fireEvent(BI.Navigation.EVENT_CHANGE, obj); } - }) + }); this.options.afterCardCreated.apply(this, arguments); }, afterCardShow: function (v) { this.showIndex = v; + this._deleteOtherCards(v); this.options.afterCardShow.apply(this, arguments); }, @@ -3996,16 +3983,23 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, - setSelect: function (v) { - this.showIndex = v; + _assertCard: function (v) { if (!this.layout.isCardExisted(v)) { var card = this.options.cardCreator(v); this.cardMap[v] = card; this.layout.addCardByName(v, card); this.afterCardCreated(v); } + }, + + setSelect: function (v) { + this._assertCard(); this.layout.showCardByName(v); - BI.nextTick(BI.bind(this.afterCardShow, this, v)); + this._deleteOtherCards(v); + if (this.showIndex !== v) { + this.showIndex = v; + BI.nextTick(BI.bind(this.afterCardShow, this, v)); + } }, getSelect: function () { @@ -4636,6 +4630,7 @@ BI.Tab = BI.inherit(BI.Widget, { return BI.extend(BI.Tab.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-tab", direction: "top",//top, bottom, left, right, custom + single: false, //是不是单页面 logic: { dynamic: false }, @@ -4675,6 +4670,7 @@ BI.Tab = BI.inherit(BI.Widget, { return card; }, afterCardShow: function (v) { + self._deleteOtherCards(v); self.curr = v; } }); @@ -4683,6 +4679,18 @@ BI.Tab = BI.inherit(BI.Widget, { }); }, + _deleteOtherCards: function (currCardName) { + var self = this, o = this.options; + if (o.single === true) { + BI.each(this.cardMap, function (name, card) { + if (name !== (currCardName + "")) { + self.layout.deleteCardByName(name); + delete self.cardMap[name]; + } + }); + } + }, + _assertCard: function (v) { if (!this.layout.isCardExisted(v)) { var card = this.options.cardCreator(v); @@ -4702,6 +4710,7 @@ BI.Tab = BI.inherit(BI.Widget, { this.tab && this.tab.setValue(v); this._assertCard(v); this.layout.showCardByName(v); + this._deleteOtherCards(v); if (this.curr !== v) { this.curr = v; } @@ -28297,8 +28306,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); }, - _init: function () { - BI.CollectionTable.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; this._width = 0; this._height = 0; @@ -28434,6 +28442,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); this._width = o.width - BI.GridTableScrollbar.SIZE; this._height = o.height - BI.GridTableScrollbar.SIZE; + }, + + mounted: function () { + var o = this.options; if (o.items.length > 0 || o.header.length < 0) { this._digest(); this._populate(); @@ -28832,8 +28844,8 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, { }); }, - _init: function () { - BI.QuickCollectionTable.superclass._init.apply(this, arguments); + render: function () { + BI.QuickCollectionTable.superclass.render.apply(this, arguments); var self = this, o = this.options; this.topLeftCollection.setOverflowX(false); this.topLeftCollection.setOverflowY(false); @@ -28843,6 +28855,11 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, { this.bottomLeftCollection.setOverflowY(false); this.bottomRightCollection.setOverflowX(false); this.bottomRightCollection.setOverflowY(false); + }, + + mounted: function () { + BI.QuickCollectionTable.superclass.mounted.apply(this, arguments); + var self = this; this._leftWheelHandler = new BI.WheelHandler( BI.bind(this._onWheelY, this), BI.bind(this._shouldHandleX, this), @@ -29037,8 +29054,7 @@ BI.GridTable = BI.inherit(BI.Widget, { }); }, - _init: function () { - BI.GridTable.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; this._width = 0; this._height = 0; @@ -29181,6 +29197,10 @@ BI.GridTable = BI.inherit(BI.Widget, { this._height = o.height - BI.GridTableScrollbar.SIZE; this.header = this._getHeader(); this.items = this._getItems(); + }, + + mounted: function () { + var o = this.options; if (o.items.length > 0) { this._populate(); } @@ -29499,8 +29519,8 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, { }); }, - _init: function () { - BI.QuickGridTable.superclass._init.apply(this, arguments); + render: function () { + BI.QuickGridTable.superclass.render.apply(this, arguments); var self = this, o = this.options; this.topLeftGrid.setOverflowX(false); this.topLeftGrid.setOverflowY(false); @@ -29510,6 +29530,11 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, { this.bottomLeftGrid.setOverflowY(false); this.bottomRightGrid.setOverflowX(false); this.bottomRightGrid.setOverflowY(false); + }, + + mounted: function () { + BI.QuickGridTable.superclass.mounted.apply(this, arguments); + var self = this; this._leftWheelHandler = new BI.WheelHandler( BI.bind(this._onWheelY, this), BI.bind(this._shouldHandleX, this), @@ -29679,8 +29704,7 @@ BI.GridTableScrollbar = BI.inherit(BI.Widget, { }) }, - _init: function () { - BI.GridTableScrollbar.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; this.focused = false; this.isDragging = false; @@ -29698,6 +29722,10 @@ BI.GridTableScrollbar = BI.inherit(BI.Widget, { top: 0 }] }); + }, + + mounted: function () { + var self = this, o = this.options; var onWheel = o.orientation === 'horizontal' ? this._onWheelX : this._onWheelY; this._wheelHandler = new BI.WheelHandler( BI.bind(onWheel, this), @@ -30052,6 +30080,12 @@ BI.GridTableHorizontalScrollbar = BI.inherit(BI.Widget, { populate: function () { this.scrollbar.populate(); + var o = this.options; + if (o.size < 1 || o.contentSize <= o.size) { + this.setVisible(false); + return; + } + this.setVisible(true); } }); BI.GridTableHorizontalScrollbar.EVENT_SCROLL = "EVENT_SCROLL"; @@ -30973,11 +31007,9 @@ BI.Table = BI.inherit(BI.Widget, { }; this._initNormalScroll(); - BI.Resizers.add(this.getName(), function (e) { - if (self.element.is(":visible") && BI.isWindow(e.target)) { - self._resize(); - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE); - } + BI.ResizeDetector.addResizeListener(this, function () { + self._resize(); + self.fireEvent(BI.Table.EVENT_TABLE_RESIZE); }); BI.nextTick(function () { if (self.element.is(":visible")) { @@ -32003,7 +32035,6 @@ BI.Table = BI.inherit(BI.Widget, { }, empty: function () { - BI.Resizers.remove(this.getName()); BI.Table.superclass.empty.apply(this, arguments); }, diff --git a/dist/case.js b/dist/case.js index 86cab3357..a17d8e33d 100644 --- a/dist/case.js +++ b/dist/case.js @@ -8614,6 +8614,8 @@ BI.AllCountPager = BI.inherit(BI.Widget, { }) }, + alwaysShowPager: true, + setAllPages: function (v) { this.allPages.setText("/" + v); this.allPages.setTitle(v); @@ -8648,10 +8650,6 @@ BI.AllCountPager = BI.inherit(BI.Widget, { this.pager.setVisible(b); }, - getAliasWidth: function () { - return this.options.width - 100; - }, - populate: function () { this.pager.populate(); } @@ -8908,6 +8906,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { this.setVPagerVisible(true); vShow = true; } + this.setVisible(hShow || vShow); var num = [74, 111, -9, 28]; var items = this.layout.attr("items"); diff --git a/dist/core.js b/dist/core.js index fd8f0ca25..5c1b20386 100644 --- a/dist/core.js +++ b/dist/core.js @@ -13046,9 +13046,6 @@ if (!window.BI) { } ; !(function ($, undefined) { - _.extend(BI, { - version: "2.0" - }); var traverse = function (func, context) { return function (value, key, obj) { return func.call(context, key, value, obj); @@ -14482,6 +14479,10 @@ BI.Widget = BI.inherit(BI.OB, { this.destroyed && this.destroyed(); }, + isMounted: function () { + return this._isMounted; + }, + setWidth: function (w) { this.options.width = w; this._initElementWidth(); @@ -22558,23 +22559,6 @@ $(function () { BI.Func = {}; var formulas = {}; BI.extend(BI.Func, { - /** - * 创建唯一的名字 - * @param array - * @param name - * @returns {*} - */ - createDistinctName: function (array, name) { - var src = name, idx = 1; - name = name || ""; - while (true) { - if (!ArrayUtils.getItemByName(array, name)) { - break; - } - name = src + (idx++); - } - return name; - }, /** * 获取搜索结果 @@ -22622,60 +22606,6 @@ $(function () { finded: finded } }, - - /** - * 公式合法性验证 - */ - checkFormulaValidation: function (str) { - if (!BI.isEmptyString(str)) { - if (BI.has(formulas, str)) { - return formulas[str]; - } - formulas[str] = false; - var response = BI.requestSync("fr_bi_base", "check_validation_of_expression", {expression: str}); - if (response.validation === "invalid") { - formulas[str] = false; - } else if (response.validation === "valid") { - formulas[str] = true; - } - return formulas[str]; - } else { - return true; - } - }, - - getFormulaStringFromFormulaValue: function (formulaValue) { - var formulaString = ""; - var regx = /\$[\{][^\}]*[\}]|\w*\w|\$\{[^\$\(\)\+\-\*\/)\$,]*\w\}|\$\{[^\$\(\)\+\-\*\/]*\w\}|\$\{[^\$\(\)\+\-\*\/]*[\u4e00-\u9fa5]\}|\w|(.)/g; - var result = formulaValue.match(regx); - BI.each(result, function (i, item) { - var fieldRegx = /\$[\{][^\}]*[\}]/; - var str = item.match(fieldRegx); - if (BI.isNotEmptyArray(str)) { - formulaString = formulaString + str[0].substring(2, item.length - 1); - } else { - formulaString = formulaString + item; - } - }); - return formulaString; - }, - - formatAddress: function (address) { - var temp = ''; - var url1 = /[a-zA-z]+:\/\/[^\s]*/; - var url2 = /\/[^\s]*/; - if (address.match(url1) || address.match(url2)) { - temp = address; - } else if (BI.isNotEmptyString(address)) { - temp = "http://" + address; - } - return temp; - }, - - getCompleteImageUrl: function (url) { - return BI.servletURL + "?op=fr_bi&cmd=get_uploaded_image&image_id=" + url; - } - }); /** @@ -22728,19 +22658,13 @@ $(function () { }); }, - getImageWidthAndHeight: function (src) { - return BI.requestSync("fr_bi_base", "get_image_size", { - src: src - }); - }, - isDarkColor: function (hex) { if (!hex) { return false; } var rgb = this.rgb2json(this.hex2rgb(hex)); - var grayLevel = (rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114); - if (grayLevel < 192) { + var grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114); + if (grayLevel < 140) { return true; } return false; @@ -25033,7 +24957,7 @@ _.extend(BI, { Top: "top", Bottom: "bottom" } -});/** +});BI.version = "2.0";/** * absolute实现的居中布局 * @class BI.AbsoluteCenterLayout * @extends BI.Layout @@ -26842,7 +26766,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { isCardExisted: function (cardName) { return BI.some(this.options.items, function (i, item) { - return item.cardName === cardName && item.el; + return item.cardName == cardName && item.el; }); }, diff --git a/dist/widget.js b/dist/widget.js index f3289fdcd..52b58fb3b 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -12846,7 +12846,7 @@ BI.PageTable = BI.inherit(BI.Widget, { this.table = BI.createWidget(o.el, { type: "bi.sequence_table", width: o.width, - height: o.height - 30, + height: o.height && o.height - 30, isNeedResize: true, isResizeAdapt: false, @@ -12970,7 +12970,23 @@ BI.PageTable = BI.inherit(BI.Widget, { setHeight: function (height) { BI.PageTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height - 30); + 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) { diff --git a/src/base/combination/navigation.js b/src/base/combination/navigation.js index c119f92bb..1ce7d4342 100644 --- a/src/base/combination/navigation.js +++ b/src/base/combination/navigation.js @@ -9,12 +9,9 @@ BI.Navigation = BI.inherit(BI.Widget, { logic: { dynamic: false }, - defaultShowIndex: 0, - tab: { - type: "bi.button_group", - items: [], - layouts: [] - }, + single: false, + defaultShowIndex: false, + tab: false, cardCreator: function (v) { return BI.createWidget(); }, @@ -52,7 +49,7 @@ BI.Navigation = BI.inherit(BI.Widget, { }, afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardShow: BI.bind(this.afterCardShow, this) - }) + }); }, mounted: function () { @@ -62,6 +59,18 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, + _deleteOtherCards: function (currCardName) { + var self = this, o = this.options; + if (o.single === true) { + BI.each(this.cardMap, function (name, card) { + if (name !== (currCardName + "")) { + self.layout.deleteCardByName(name); + delete self.cardMap[name]; + } + }); + } + }, + afterCardCreated: function (v) { var self = this; this.cardMap[v].on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { @@ -69,12 +78,13 @@ BI.Navigation = BI.inherit(BI.Widget, { if (type === BI.Events.CLICK) { self.fireEvent(BI.Navigation.EVENT_CHANGE, obj); } - }) + }); this.options.afterCardCreated.apply(this, arguments); }, afterCardShow: function (v) { this.showIndex = v; + this._deleteOtherCards(v); this.options.afterCardShow.apply(this, arguments); }, @@ -85,16 +95,23 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, - setSelect: function (v) { - this.showIndex = v; + _assertCard: function (v) { if (!this.layout.isCardExisted(v)) { var card = this.options.cardCreator(v); this.cardMap[v] = card; this.layout.addCardByName(v, card); this.afterCardCreated(v); } + }, + + setSelect: function (v) { + this._assertCard(); this.layout.showCardByName(v); - BI.nextTick(BI.bind(this.afterCardShow, this, v)); + this._deleteOtherCards(v); + if (this.showIndex !== v) { + this.showIndex = v; + BI.nextTick(BI.bind(this.afterCardShow, this, v)); + } }, getSelect: function () { diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index 0c0b5e7fe..f3c1ea203 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -7,6 +7,7 @@ BI.Tab = BI.inherit(BI.Widget, { return BI.extend(BI.Tab.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-tab", direction: "top",//top, bottom, left, right, custom + single: false, //是不是单页面 logic: { dynamic: false }, @@ -46,6 +47,7 @@ BI.Tab = BI.inherit(BI.Widget, { return card; }, afterCardShow: function (v) { + self._deleteOtherCards(v); self.curr = v; } }); @@ -54,6 +56,18 @@ BI.Tab = BI.inherit(BI.Widget, { }); }, + _deleteOtherCards: function (currCardName) { + var self = this, o = this.options; + if (o.single === true) { + BI.each(this.cardMap, function (name, card) { + if (name !== (currCardName + "")) { + self.layout.deleteCardByName(name); + delete self.cardMap[name]; + } + }); + } + }, + _assertCard: function (v) { if (!this.layout.isCardExisted(v)) { var card = this.options.cardCreator(v); @@ -73,6 +87,7 @@ BI.Tab = BI.inherit(BI.Widget, { this.tab && this.tab.setValue(v); this._assertCard(v); this.layout.showCardByName(v); + this._deleteOtherCards(v); if (this.curr !== v) { this.curr = v; } diff --git a/src/base/single/editor/editor.textarea.js b/src/base/single/editor/editor.textarea.js index 23fb87664..1c0afb044 100644 --- a/src/base/single/editor/editor.textarea.js +++ b/src/base/single/editor/editor.textarea.js @@ -136,6 +136,7 @@ BI.TextAreaEditor = BI.inherit(BI.Single, { setValue: function (value) { this.content.element.val(value); + this._checkWaterMark(); }, setStyle: function (style) { diff --git a/src/base/table/table.collection.js b/src/base/table/table.collection.js index 65b56b954..59267c613 100644 --- a/src/base/table/table.collection.js +++ b/src/base/table/table.collection.js @@ -23,8 +23,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); }, - _init: function () { - BI.CollectionTable.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; this._width = 0; this._height = 0; @@ -160,6 +159,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); this._width = o.width - BI.GridTableScrollbar.SIZE; this._height = o.height - BI.GridTableScrollbar.SIZE; + }, + + mounted: function () { + var o = this.options; if (o.items.length > 0 || o.header.length < 0) { this._digest(); this._populate(); diff --git a/src/base/table/table.collection.quick.js b/src/base/table/table.collection.quick.js index 9cada8003..ab1cd926f 100644 --- a/src/base/table/table.collection.quick.js +++ b/src/base/table/table.collection.quick.js @@ -12,8 +12,8 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, { }); }, - _init: function () { - BI.QuickCollectionTable.superclass._init.apply(this, arguments); + render: function () { + BI.QuickCollectionTable.superclass.render.apply(this, arguments); var self = this, o = this.options; this.topLeftCollection.setOverflowX(false); this.topLeftCollection.setOverflowY(false); @@ -23,6 +23,11 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, { this.bottomLeftCollection.setOverflowY(false); this.bottomRightCollection.setOverflowX(false); this.bottomRightCollection.setOverflowY(false); + }, + + mounted: function () { + BI.QuickCollectionTable.superclass.mounted.apply(this, arguments); + var self = this; this._leftWheelHandler = new BI.WheelHandler( BI.bind(this._onWheelY, this), BI.bind(this._shouldHandleX, this), diff --git a/src/base/table/table.grid.js b/src/base/table/table.grid.js index 4c357ed38..73d42b385 100644 --- a/src/base/table/table.grid.js +++ b/src/base/table/table.grid.js @@ -20,8 +20,7 @@ BI.GridTable = BI.inherit(BI.Widget, { }); }, - _init: function () { - BI.GridTable.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; this._width = 0; this._height = 0; @@ -164,6 +163,10 @@ BI.GridTable = BI.inherit(BI.Widget, { this._height = o.height - BI.GridTableScrollbar.SIZE; this.header = this._getHeader(); this.items = this._getItems(); + }, + + mounted: function () { + var o = this.options; if (o.items.length > 0) { this._populate(); } diff --git a/src/base/table/table.grid.quick.js b/src/base/table/table.grid.quick.js index bfa5196b6..5ade73e43 100644 --- a/src/base/table/table.grid.quick.js +++ b/src/base/table/table.grid.quick.js @@ -12,8 +12,8 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, { }); }, - _init: function () { - BI.QuickGridTable.superclass._init.apply(this, arguments); + render: function () { + BI.QuickGridTable.superclass.render.apply(this, arguments); var self = this, o = this.options; this.topLeftGrid.setOverflowX(false); this.topLeftGrid.setOverflowY(false); @@ -23,6 +23,11 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, { this.bottomLeftGrid.setOverflowY(false); this.bottomRightGrid.setOverflowX(false); this.bottomRightGrid.setOverflowY(false); + }, + + mounted: function () { + BI.QuickGridTable.superclass.mounted.apply(this, arguments); + var self = this; this._leftWheelHandler = new BI.WheelHandler( BI.bind(this._onWheelY, this), BI.bind(this._shouldHandleX, this), diff --git a/src/base/table/table.grid.scrollbar.js b/src/base/table/table.grid.scrollbar.js index bf8364612..6faf27cc0 100644 --- a/src/base/table/table.grid.scrollbar.js +++ b/src/base/table/table.grid.scrollbar.js @@ -28,8 +28,7 @@ BI.GridTableScrollbar = BI.inherit(BI.Widget, { }) }, - _init: function () { - BI.GridTableScrollbar.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; this.focused = false; this.isDragging = false; @@ -47,6 +46,10 @@ BI.GridTableScrollbar = BI.inherit(BI.Widget, { top: 0 }] }); + }, + + mounted: function () { + var self = this, o = this.options; var onWheel = o.orientation === 'horizontal' ? this._onWheelX : this._onWheelY; this._wheelHandler = new BI.WheelHandler( BI.bind(onWheel, this), @@ -401,6 +404,12 @@ BI.GridTableHorizontalScrollbar = BI.inherit(BI.Widget, { populate: function () { this.scrollbar.populate(); + var o = this.options; + if (o.size < 1 || o.contentSize <= o.size) { + this.setVisible(false); + return; + } + this.setVisible(true); } }); BI.GridTableHorizontalScrollbar.EVENT_SCROLL = "EVENT_SCROLL"; diff --git a/src/base/table/table.js b/src/base/table/table.js index d37e894e6..8652d0543 100644 --- a/src/base/table/table.js +++ b/src/base/table/table.js @@ -887,11 +887,9 @@ BI.Table = BI.inherit(BI.Widget, { }; this._initNormalScroll(); - BI.Resizers.add(this.getName(), function (e) { - if (self.element.is(":visible") && BI.isWindow(e.target)) { - self._resize(); - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE); - } + BI.ResizeDetector.addResizeListener(this, function () { + self._resize(); + self.fireEvent(BI.Table.EVENT_TABLE_RESIZE); }); BI.nextTick(function () { if (self.element.is(":visible")) { @@ -1917,7 +1915,6 @@ BI.Table = BI.inherit(BI.Widget, { }, empty: function () { - BI.Resizers.remove(this.getName()); BI.Table.superclass.empty.apply(this, arguments); }, diff --git a/src/base/tree/treeview.js b/src/base/tree/treeview.js index 6e5de0e26..f7b149086 100644 --- a/src/base/tree/treeview.js +++ b/src/base/tree/treeview.js @@ -14,10 +14,6 @@ BI.TreeView = BI.inherit(BI.Pane, { }, _init: function () { BI.TreeView.superclass._init.apply(this, arguments); - - - - this._stop = false; this.container = BI.createWidget(); @@ -494,10 +490,10 @@ BI.TreeView = BI.inherit(BI.Pane, { } }); BI.extend(BI.TreeView, { - REQ_TYPE_INIT_DATA: 1, - REQ_TYPE_ADJUST_DATA: 2, - REQ_TYPE_CALCULATE_SELECT_DATA: 3, - REQ_TYPE_SELECTED_DATA: 4 + REQ_TYPE_INIT_DATA: 0, + REQ_TYPE_ADJUST_DATA: 1, + REQ_TYPE_CALCULATE_SELECT_DATA: 2, + REQ_TYPE_SELECTED_DATA: 3 }); BI.TreeView.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/case/pager/pager.all.count.js b/src/case/pager/pager.all.count.js index 432428f32..fee63982f 100644 --- a/src/case/pager/pager.all.count.js +++ b/src/case/pager/pager.all.count.js @@ -119,6 +119,8 @@ BI.AllCountPager = BI.inherit(BI.Widget, { }) }, + alwaysShowPager: true, + setAllPages: function (v) { this.allPages.setText("/" + v); this.allPages.setTitle(v); @@ -153,10 +155,6 @@ BI.AllCountPager = BI.inherit(BI.Widget, { this.pager.setVisible(b); }, - getAliasWidth: function () { - return this.options.width - 100; - }, - populate: function () { this.pager.populate(); } diff --git a/src/case/pager/pager.direction.js b/src/case/pager/pager.direction.js index 3ae115dd4..c946cf7f3 100644 --- a/src/case/pager/pager.direction.js +++ b/src/case/pager/pager.direction.js @@ -249,6 +249,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { this.setVPagerVisible(true); vShow = true; } + this.setVisible(hShow || vShow); var num = [74, 111, -9, 28]; var items = this.layout.attr("items"); diff --git a/src/core/base.js b/src/core/base.js index cdee5f2d5..9a39342cf 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -9,9 +9,6 @@ if (!window.BI) { } ; !(function ($, undefined) { - _.extend(BI, { - version: "2.0" - }); var traverse = function (func, context) { return function (value, key, obj) { return func.call(context, key, value, obj); diff --git a/src/core/func/function.js b/src/core/func/function.js index 9dc982554..aa594e3a8 100644 --- a/src/core/func/function.js +++ b/src/core/func/function.js @@ -6,23 +6,6 @@ $(function () { BI.Func = {}; var formulas = {}; BI.extend(BI.Func, { - /** - * 创建唯一的名字 - * @param array - * @param name - * @returns {*} - */ - createDistinctName: function (array, name) { - var src = name, idx = 1; - name = name || ""; - while (true) { - if (!ArrayUtils.getItemByName(array, name)) { - break; - } - name = src + (idx++); - } - return name; - }, /** * 获取搜索结果 @@ -70,60 +53,6 @@ $(function () { finded: finded } }, - - /** - * 公式合法性验证 - */ - checkFormulaValidation: function (str) { - if (!BI.isEmptyString(str)) { - if (BI.has(formulas, str)) { - return formulas[str]; - } - formulas[str] = false; - var response = BI.requestSync("fr_bi_base", "check_validation_of_expression", {expression: str}); - if (response.validation === "invalid") { - formulas[str] = false; - } else if (response.validation === "valid") { - formulas[str] = true; - } - return formulas[str]; - } else { - return true; - } - }, - - getFormulaStringFromFormulaValue: function (formulaValue) { - var formulaString = ""; - var regx = /\$[\{][^\}]*[\}]|\w*\w|\$\{[^\$\(\)\+\-\*\/)\$,]*\w\}|\$\{[^\$\(\)\+\-\*\/]*\w\}|\$\{[^\$\(\)\+\-\*\/]*[\u4e00-\u9fa5]\}|\w|(.)/g; - var result = formulaValue.match(regx); - BI.each(result, function (i, item) { - var fieldRegx = /\$[\{][^\}]*[\}]/; - var str = item.match(fieldRegx); - if (BI.isNotEmptyArray(str)) { - formulaString = formulaString + str[0].substring(2, item.length - 1); - } else { - formulaString = formulaString + item; - } - }); - return formulaString; - }, - - formatAddress: function (address) { - var temp = ''; - var url1 = /[a-zA-z]+:\/\/[^\s]*/; - var url2 = /\/[^\s]*/; - if (address.match(url1) || address.match(url2)) { - temp = address; - } else if (BI.isNotEmptyString(address)) { - temp = "http://" + address; - } - return temp; - }, - - getCompleteImageUrl: function (url) { - return BI.servletURL + "?op=fr_bi&cmd=get_uploaded_image&image_id=" + url; - } - }); /** @@ -176,19 +105,13 @@ $(function () { }); }, - getImageWidthAndHeight: function (src) { - return BI.requestSync("fr_bi_base", "get_image_size", { - src: src - }); - }, - isDarkColor: function (hex) { if (!hex) { return false; } var rgb = this.rgb2json(this.hex2rgb(hex)); - var grayLevel = (rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114); - if (grayLevel < 192) { + var grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114); + if (grayLevel < 140) { return true; } return false; diff --git a/src/core/version.js b/src/core/version.js new file mode 100644 index 000000000..a850da743 --- /dev/null +++ b/src/core/version.js @@ -0,0 +1 @@ +BI.version = "2.0"; \ No newline at end of file diff --git a/src/core/widget.js b/src/core/widget.js index 693734fc9..bd372a063 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -191,6 +191,10 @@ BI.Widget = BI.inherit(BI.OB, { this.destroyed && this.destroyed(); }, + isMounted: function () { + return this._isMounted; + }, + setWidth: function (w) { this.options.width = w; this._initElementWidth(); diff --git a/src/core/wrapper/layout/layout.card.js b/src/core/wrapper/layout/layout.card.js index aa0921291..201b3ccbf 100644 --- a/src/core/wrapper/layout/layout.card.js +++ b/src/core/wrapper/layout/layout.card.js @@ -63,7 +63,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { isCardExisted: function (cardName) { return BI.some(this.options.items, function (i, item) { - return item.cardName === cardName && item.el; + return item.cardName == cardName && item.el; }); }, diff --git a/src/third/jquery.mousewheel.js b/src/third/jquery.mousewheel.js index d53edb74e..597366353 100644 --- a/src/third/jquery.mousewheel.js +++ b/src/third/jquery.mousewheel.js @@ -42,9 +42,6 @@ } else { this.onmousewheel = handler; } - // Store the line height and page height for this particular element - $.data(this, 'mousewheel-line-height', special.getLineHeight(this)); - $.data(this, 'mousewheel-page-height', special.getPageHeight(this)); }, teardown: function() { @@ -55,22 +52,6 @@ } else { this.onmousewheel = null; } - // Clean up the data we added to the element - $.removeData(this, 'mousewheel-line-height'); - $.removeData(this, 'mousewheel-page-height'); - }, - - getLineHeight: function(elem) { - var $elem = $(elem), - $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent'](); - if (!$parent.length) { - $parent = $('body'); - } - return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16; - }, - - getPageHeight: function(elem) { - return $(elem).height(); }, settings: { @@ -136,12 +117,12 @@ // * deltaMode 1 is by lines // * deltaMode 2 is by pages if ( orgEvent.deltaMode === 1 ) { - var lineHeight = $.data(this, 'mousewheel-line-height'); + var lineHeight = 40; delta *= lineHeight; deltaY *= lineHeight; deltaX *= lineHeight; } else if ( orgEvent.deltaMode === 2 ) { - var pageHeight = $.data(this, 'mousewheel-page-height'); + var pageHeight = 800; delta *= pageHeight; deltaY *= pageHeight; deltaX *= pageHeight; diff --git a/src/widget/pagetable/pagetable.js b/src/widget/pagetable/pagetable.js index 03d884bae..a2f671eaa 100644 --- a/src/widget/pagetable/pagetable.js +++ b/src/widget/pagetable/pagetable.js @@ -78,7 +78,7 @@ BI.PageTable = BI.inherit(BI.Widget, { this.table = BI.createWidget(o.el, { type: "bi.sequence_table", width: o.width, - height: o.height - 30, + height: o.height && o.height - 30, isNeedResize: true, isResizeAdapt: false, @@ -202,7 +202,23 @@ BI.PageTable = BI.inherit(BI.Widget, { setHeight: function (height) { BI.PageTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height - 30); + 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) {