From 7e1b8c15143b5fa34d379e6357f51baa82369234 Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 1 Apr 2017 21:22:06 +0800 Subject: [PATCH 01/11] =?UTF-8?q?tab=E5=92=8Cnavigation=E5=8A=A0=E5=85=A5s?= =?UTF-8?q?ingle=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bi/base.js | 44 +++++++++++++++++++++++--- bi/core.js | 2 +- dist/base.js | 44 +++++++++++++++++++++++--- dist/core.js | 2 +- src/base/combination/navigation.js | 29 ++++++++++++++--- src/base/combination/tab.js | 15 +++++++++ src/core/wrapper/layout/layout.card.js | 2 +- 7 files changed, 123 insertions(+), 15 deletions(-) diff --git a/bi/base.js b/bi/base.js index 41d9f2b6f2..d8284b6a65 100644 --- a/bi/base.js +++ b/bi/base.js @@ -3920,6 +3920,7 @@ BI.Navigation = BI.inherit(BI.Widget, { logic: { dynamic: false }, + single: false, defaultShowIndex: 0, tab: { type: "bi.button_group", @@ -3973,6 +3974,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 +3993,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 +4010,23 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, - setSelect: function (v) { - this.showIndex = v; + _assertCard: function () { 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 +4657,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 +4697,7 @@ BI.Tab = BI.inherit(BI.Widget, { return card; }, afterCardShow: function (v) { + self._deleteOtherCards(v); self.curr = v; } }); @@ -4683,6 +4706,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 +4737,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/bi/core.js b/bi/core.js index af139ef2a8..b0b8f41bd8 100644 --- a/bi/core.js +++ b/bi/core.js @@ -13289,7 +13289,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/base.js b/dist/base.js index 41d9f2b6f2..d8284b6a65 100644 --- a/dist/base.js +++ b/dist/base.js @@ -3920,6 +3920,7 @@ BI.Navigation = BI.inherit(BI.Widget, { logic: { dynamic: false }, + single: false, defaultShowIndex: 0, tab: { type: "bi.button_group", @@ -3973,6 +3974,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 +3993,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 +4010,23 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, - setSelect: function (v) { - this.showIndex = v; + _assertCard: function () { 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 +4657,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 +4697,7 @@ BI.Tab = BI.inherit(BI.Widget, { return card; }, afterCardShow: function (v) { + self._deleteOtherCards(v); self.curr = v; } }); @@ -4683,6 +4706,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 +4737,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/dist/core.js b/dist/core.js index fd8f0ca254..bf97615c78 100644 --- a/dist/core.js +++ b/dist/core.js @@ -26842,7 +26842,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/base/combination/navigation.js b/src/base/combination/navigation.js index c119f92bbc..3ef882581d 100644 --- a/src/base/combination/navigation.js +++ b/src/base/combination/navigation.js @@ -9,6 +9,7 @@ BI.Navigation = BI.inherit(BI.Widget, { logic: { dynamic: false }, + single: false, defaultShowIndex: 0, tab: { type: "bi.button_group", @@ -62,6 +63,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 +82,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 +99,23 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, - setSelect: function (v) { - this.showIndex = v; + _assertCard: function () { 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 0c0b5e7fe0..f3c1ea2035 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/core/wrapper/layout/layout.card.js b/src/core/wrapper/layout/layout.card.js index aa0921291d..201b3ccbf6 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; }); }, From e32e8e094bf1d136c221f3a5ff4d71f6bf62a478 Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 1 Apr 2017 21:51:20 +0800 Subject: [PATCH 02/11] add --- bi/base.js | 4 ---- dist/base.js | 4 ---- src/base/tree/treeview.js | 4 ---- 3 files changed, 12 deletions(-) diff --git a/bi/base.js b/bi/base.js index d8284b6a65..86db12a7f3 100644 --- a/bi/base.js +++ b/bi/base.js @@ -1489,10 +1489,6 @@ BI.TreeView = BI.inherit(BI.Pane, { }, _init: function () { BI.TreeView.superclass._init.apply(this, arguments); - - - - this._stop = false; this.container = BI.createWidget(); diff --git a/dist/base.js b/dist/base.js index d8284b6a65..86db12a7f3 100644 --- a/dist/base.js +++ b/dist/base.js @@ -1489,10 +1489,6 @@ BI.TreeView = BI.inherit(BI.Pane, { }, _init: function () { BI.TreeView.superclass._init.apply(this, arguments); - - - - this._stop = false; this.container = BI.createWidget(); diff --git a/src/base/tree/treeview.js b/src/base/tree/treeview.js index 6e5de0e26e..9a0f89f059 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(); From c0f25fbd50df1c2d8a56981bce6a66fadef9291e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=B8=B0=E8=B1=AA?= Date: Sat, 1 Apr 2017 22:09:33 +0800 Subject: [PATCH 03/11] update --- src/base/tree/treeview.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/base/tree/treeview.js b/src/base/tree/treeview.js index 17e84d100e..25b436cafd 100644 --- a/src/base/tree/treeview.js +++ b/src/base/tree/treeview.js @@ -494,10 +494,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"; From 9485fa6b4644f806dd38731ab2b4e7d6a0858462 Mon Sep 17 00:00:00 2001 From: guy Date: Sun, 2 Apr 2017 15:52:50 +0800 Subject: [PATCH 04/11] version --- bi/base.js | 2 +- bi/core.js | 3 --- dist/base.js | 2 +- dist/core.js | 5 +---- src/base/combination/navigation.js | 2 +- src/core/base.js | 3 --- src/core/version.js | 1 + 7 files changed, 5 insertions(+), 13 deletions(-) create mode 100644 src/core/version.js diff --git a/bi/base.js b/bi/base.js index 86db12a7f3..02bbd5fbb5 100644 --- a/bi/base.js +++ b/bi/base.js @@ -4006,7 +4006,7 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, - _assertCard: function () { + _assertCard: function (v) { if (!this.layout.isCardExisted(v)) { var card = this.options.cardCreator(v); this.cardMap[v] = card; diff --git a/bi/core.js b/bi/core.js index b0b8f41bd8..14b93d785d 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); diff --git a/dist/base.js b/dist/base.js index 86db12a7f3..02bbd5fbb5 100644 --- a/dist/base.js +++ b/dist/base.js @@ -4006,7 +4006,7 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, - _assertCard: function () { + _assertCard: function (v) { if (!this.layout.isCardExisted(v)) { var card = this.options.cardCreator(v); this.cardMap[v] = card; diff --git a/dist/core.js b/dist/core.js index bf97615c78..ff5a7c5c54 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); @@ -25033,7 +25030,7 @@ _.extend(BI, { Top: "top", Bottom: "bottom" } -});/** +});BI.version = "2.0";/** * absolute实现的居中布局 * @class BI.AbsoluteCenterLayout * @extends BI.Layout diff --git a/src/base/combination/navigation.js b/src/base/combination/navigation.js index 3ef882581d..7f4cbf3eb3 100644 --- a/src/base/combination/navigation.js +++ b/src/base/combination/navigation.js @@ -99,7 +99,7 @@ BI.Navigation = BI.inherit(BI.Widget, { } }, - _assertCard: function () { + _assertCard: function (v) { if (!this.layout.isCardExisted(v)) { var card = this.options.cardCreator(v); this.cardMap[v] = card; diff --git a/src/core/base.js b/src/core/base.js index cdee5f2d50..9a39342cf1 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/version.js b/src/core/version.js new file mode 100644 index 0000000000..a850da7437 --- /dev/null +++ b/src/core/version.js @@ -0,0 +1 @@ +BI.version = "2.0"; \ No newline at end of file From f51e9935531633b6f9239ce2f974c6ef1e0bea28 Mon Sep 17 00:00:00 2001 From: guy Date: Sun, 2 Apr 2017 15:53:21 +0800 Subject: [PATCH 05/11] add --- bi/base.js | 8 ++++---- dist/base.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bi/base.js b/bi/base.js index 02bbd5fbb5..42fda510ef 100644 --- a/bi/base.js +++ b/bi/base.js @@ -1965,10 +1965,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/dist/base.js b/dist/base.js index 02bbd5fbb5..42fda510ef 100644 --- a/dist/base.js +++ b/dist/base.js @@ -1965,10 +1965,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"; From 26f98182c3e2480ecf68c31012c4b2e4c2b107f1 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 4 Apr 2017 17:02:04 +0800 Subject: [PATCH 06/11] add --- bi/core.js | 4 ++-- dist/core.js | 4 ++-- src/core/func/function.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bi/core.js b/bi/core.js index 14b93d785d..87caeb5115 100644 --- a/bi/core.js +++ b/bi/core.js @@ -17112,8 +17112,8 @@ $(function () { 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/dist/core.js b/dist/core.js index ff5a7c5c54..2c41386b7d 100644 --- a/dist/core.js +++ b/dist/core.js @@ -22736,8 +22736,8 @@ $(function () { 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/func/function.js b/src/core/func/function.js index 9dc982554d..8e2256a93b 100644 --- a/src/core/func/function.js +++ b/src/core/func/function.js @@ -187,8 +187,8 @@ $(function () { 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; From c032bed1faaac88013936e42715fa9fb0f75c577 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 5 Apr 2017 11:18:08 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bi/core.js | 77 --------------------------------------- dist/core.js | 77 --------------------------------------- src/core/func/function.js | 77 --------------------------------------- 3 files changed, 231 deletions(-) diff --git a/bi/core.js b/bi/core.js index 87caeb5115..34724f77bb 100644 --- a/bi/core.js +++ b/bi/core.js @@ -16931,23 +16931,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; - }, /** * 获取搜索结果 @@ -16995,60 +16978,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; - } - }); /** @@ -17101,12 +17030,6 @@ $(function () { }); }, - getImageWidthAndHeight: function (src) { - return BI.requestSync("fr_bi_base", "get_image_size", { - src: src - }); - }, - isDarkColor: function (hex) { if (!hex) { return false; diff --git a/dist/core.js b/dist/core.js index 2c41386b7d..de470e664f 100644 --- a/dist/core.js +++ b/dist/core.js @@ -22555,23 +22555,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; - }, /** * 获取搜索结果 @@ -22619,60 +22602,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; - } - }); /** @@ -22725,12 +22654,6 @@ $(function () { }); }, - getImageWidthAndHeight: function (src) { - return BI.requestSync("fr_bi_base", "get_image_size", { - src: src - }); - }, - isDarkColor: function (hex) { if (!hex) { return false; diff --git a/src/core/func/function.js b/src/core/func/function.js index 8e2256a93b..aa594e3a82 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,12 +105,6 @@ $(function () { }); }, - getImageWidthAndHeight: function (src) { - return BI.requestSync("fr_bi_base", "get_image_size", { - src: src - }); - }, - isDarkColor: function (hex) { if (!hex) { return false; From d36a84efeb125ee369790129960f5f33867b90c1 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 5 Apr 2017 16:01:28 +0800 Subject: [PATCH 08/11] =?UTF-8?q?IE8=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bi/base.js | 62 ++++++++++++------------ bi/core.js | 4 ++ dist/base.js | 62 ++++++++++++------------ dist/core.js | 4 ++ src/base/table/table.collection.js | 7 ++- src/base/table/table.collection.quick.js | 9 +++- src/base/table/table.grid.js | 7 ++- src/base/table/table.grid.quick.js | 9 +++- src/base/table/table.grid.scrollbar.js | 7 ++- src/core/widget.js | 4 ++ src/third/jquery.mousewheel.js | 23 +-------- 11 files changed, 105 insertions(+), 93 deletions(-) diff --git a/bi/base.js b/bi/base.js index 42fda510ef..24f6c82175 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; @@ -28329,8 +28310,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; @@ -28466,6 +28446,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(); @@ -28864,8 +28848,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); @@ -28875,6 +28859,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), @@ -29069,8 +29058,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; @@ -29213,6 +29201,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(); } @@ -29531,8 +29523,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); @@ -29542,6 +29534,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), @@ -29711,8 +29708,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; @@ -29730,6 +29726,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), diff --git a/bi/core.js b/bi/core.js index 34724f77bb..a176df9ba3 100644 --- a/bi/core.js +++ b/bi/core.js @@ -4484,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(); diff --git a/dist/base.js b/dist/base.js index 42fda510ef..24f6c82175 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; @@ -28329,8 +28310,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; @@ -28466,6 +28446,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(); @@ -28864,8 +28848,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); @@ -28875,6 +28859,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), @@ -29069,8 +29058,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; @@ -29213,6 +29201,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(); } @@ -29531,8 +29523,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); @@ -29542,6 +29534,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), @@ -29711,8 +29708,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; @@ -29730,6 +29726,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), diff --git a/dist/core.js b/dist/core.js index de470e664f..5c1b203864 100644 --- a/dist/core.js +++ b/dist/core.js @@ -14479,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(); diff --git a/src/base/table/table.collection.js b/src/base/table/table.collection.js index 65b56b9549..59267c6137 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 9cada80037..ab1cd926f2 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 4c357ed386..73d42b3856 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 bfa5196b61..5ade73e432 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 bf8364612a..32f9e71fe9 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), diff --git a/src/core/widget.js b/src/core/widget.js index 693734fc91..bd372a0639 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/third/jquery.mousewheel.js b/src/third/jquery.mousewheel.js index d53edb74ea..5973663539 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; From 78f30fe2f156e0250d7b7f64be53258503c6afa8 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 5 Apr 2017 16:03:16 +0800 Subject: [PATCH 09/11] add --- bi/base.js | 9 +++------ dist/base.js | 9 +++------ src/base/table/table.js | 9 +++------ 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/bi/base.js b/bi/base.js index 24f6c82175..efae354a2a 100644 --- a/bi/base.js +++ b/bi/base.js @@ -31005,11 +31005,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")) { @@ -32035,7 +32033,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/base.js b/dist/base.js index 24f6c82175..efae354a2a 100644 --- a/dist/base.js +++ b/dist/base.js @@ -31005,11 +31005,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")) { @@ -32035,7 +32033,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/table/table.js b/src/base/table/table.js index d37e894e63..8652d0543f 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); }, From 18b6904c52ecd0e513d55d8879a9b0f3a34b0edb Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 5 Apr 2017 20:59:07 +0800 Subject: [PATCH 10/11] add --- bi/base.js | 16 +++++++++------- bi/case.js | 7 +++---- bi/widget.js | 20 ++++++++++++++++++-- dist/base.js | 16 +++++++++------- dist/case.js | 7 +++---- dist/widget.js | 20 ++++++++++++++++++-- src/base/combination/navigation.js | 10 +++------- src/base/table/table.grid.scrollbar.js | 6 ++++++ src/case/pager/pager.all.count.js | 6 ++---- src/case/pager/pager.direction.js | 1 + src/widget/pagetable/pagetable.js | 20 ++++++++++++++++++-- 11 files changed, 90 insertions(+), 39 deletions(-) diff --git a/bi/base.js b/bi/base.js index efae354a2a..bd50dc576b 100644 --- a/bi/base.js +++ b/bi/base.js @@ -3898,12 +3898,8 @@ BI.Navigation = BI.inherit(BI.Widget, { dynamic: false }, single: false, - defaultShowIndex: 0, - tab: { - type: "bi.button_group", - items: [], - layouts: [] - }, + defaultShowIndex: false, + tab: false, cardCreator: function (v) { return BI.createWidget(); }, @@ -3941,7 +3937,7 @@ BI.Navigation = BI.inherit(BI.Widget, { }, afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardShow: BI.bind(this.afterCardShow, this) - }) + }); }, mounted: function () { @@ -30084,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"; diff --git a/bi/case.js b/bi/case.js index 86cab3357d..a17d8e33d6 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/widget.js b/bi/widget.js index f3289fdcd9..52b58fb3bf 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 efae354a2a..bd50dc576b 100644 --- a/dist/base.js +++ b/dist/base.js @@ -3898,12 +3898,8 @@ BI.Navigation = BI.inherit(BI.Widget, { dynamic: false }, single: false, - defaultShowIndex: 0, - tab: { - type: "bi.button_group", - items: [], - layouts: [] - }, + defaultShowIndex: false, + tab: false, cardCreator: function (v) { return BI.createWidget(); }, @@ -3941,7 +3937,7 @@ BI.Navigation = BI.inherit(BI.Widget, { }, afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardShow: BI.bind(this.afterCardShow, this) - }) + }); }, mounted: function () { @@ -30084,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"; diff --git a/dist/case.js b/dist/case.js index 86cab3357d..a17d8e33d6 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/widget.js b/dist/widget.js index f3289fdcd9..52b58fb3bf 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 7f4cbf3eb3..1ce7d4342b 100644 --- a/src/base/combination/navigation.js +++ b/src/base/combination/navigation.js @@ -10,12 +10,8 @@ BI.Navigation = BI.inherit(BI.Widget, { dynamic: false }, single: false, - defaultShowIndex: 0, - tab: { - type: "bi.button_group", - items: [], - layouts: [] - }, + defaultShowIndex: false, + tab: false, cardCreator: function (v) { return BI.createWidget(); }, @@ -53,7 +49,7 @@ BI.Navigation = BI.inherit(BI.Widget, { }, afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardShow: BI.bind(this.afterCardShow, this) - }) + }); }, mounted: function () { diff --git a/src/base/table/table.grid.scrollbar.js b/src/base/table/table.grid.scrollbar.js index 32f9e71fe9..6faf27cc0e 100644 --- a/src/base/table/table.grid.scrollbar.js +++ b/src/base/table/table.grid.scrollbar.js @@ -404,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/case/pager/pager.all.count.js b/src/case/pager/pager.all.count.js index 432428f32e..fee63982f9 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 3ae115dd41..c946cf7f36 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/widget/pagetable/pagetable.js b/src/widget/pagetable/pagetable.js index 03d884bae1..a2f671eaac 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) { From 317dbc24bede6df9d352fd4f04f49f8dd978b6e7 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 6 Apr 2017 09:19:33 +0800 Subject: [PATCH 11/11] checkwatermark --- src/base/single/editor/editor.textarea.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/base/single/editor/editor.textarea.js b/src/base/single/editor/editor.textarea.js index 23fb876648..1c0afb0448 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) {