From 3342f437e64cb6a0ebe0c69ea712f5f2fc662f07 Mon Sep 17 00:00:00 2001 From: Fay <lfhlifenghao@gmail.com> Date: Wed, 6 Nov 2019 15:32:08 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9plugin=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 192ad3a..1697bd8 100644 --- a/plugin.xml +++ b/plugin.xml @@ -12,7 +12,7 @@ [2019-08-28]为BI模板添加模板自适应功能。<br/> ]]></change-notes> <extra-decision> - <AbstractWebResourceProvider class="com.finebi.plugin.ScreenAdaptive"/> + <WebResourceProvider class="com.finebi.plugin.ScreenAdaptive"/> </extra-decision> <extra-core> <LocaleFinder class="com.finebi.plugin.ScreenAdaptiveLocaleFinder"/> From 4412413bb37a0fe8c42eb6fb2cac5c0205c54e87 Mon Sep 17 00:00:00 2001 From: Fay <lfhlifenghao@gmail.com> Date: Mon, 18 Nov 2019 15:41:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?BI-55726=20fix=EF=BC=9A=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=B1=80=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/web/plugin.screen_adaptive.js | 19 +++++++++++++++++-- .../com/finebi/plugin/web/scripts/entry.js | 19 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js b/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js index daea6ac..c63e581 100644 --- a/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js +++ b/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js @@ -1,7 +1,14 @@ !(function () { var scale = 1, transformY = 0, selected = true; - var wrapper = document.getElementById("wrapper"); var html = document.getElementsByTagName('html')[0]; + var wrapper = document.getElementById("wrapper"); + var fixedContainer = document.createElement('div'); + fixedContainer.style.position = "absolute"; + fixedContainer.style.top = "0"; + fixedContainer.style.left = "0"; + fixedContainer.style.width = "100%"; + + wrapper.appendChild(fixedContainer); var jQuery = $ || window.jQuery; var injectOffset = jQuery.fn.offset; @@ -53,6 +60,7 @@ wrapper.style.transformOrigin = "top left"; wrapper.style["-ms-transform"] = "scale(" + bounds.scale+ ")"; wrapper.style["-ms-transform-origin"] = "top left"; + fixedContainer.style.height = (document.body.clientHeight / scale) + "px"; // html.style.backgroundColor = document.getElementsByClassName('bi-theme-dark').length === 0 ? "#2c3d59" : "#ffffff"; html.style.backgroundColor = "#ffffff"; @@ -80,6 +88,7 @@ wrapper.style["-ms-transform-origin"] = ""; wrapper.style.overflowY = "hidden"; wrapper.style.top = ""; + fixedContainer.style.height = "0px"; html.style.backgroundColor = "#ffffff"; scale = 1; @@ -274,11 +283,14 @@ BI.createWidget = function () { if (arguments[0] && arguments[0].element === "body") { - arguments[0].element = wrapper; + arguments[0].element = fixedContainer; } return injectCreate.apply(this, arguments); }; + // Popovers + BI.Popovers = new BI.PopoverController({render: fixedContainer}); + // document.body.onmousedown = scaleFixed; window.addEventListener('resize', updateScale); window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)'). @@ -299,6 +311,9 @@ } BI.createWidget = injectCreate; + // Popovers + BI.Popovers = new BI.PopoverController(); + document.body.onmousedown = null; window.removeEventListener('resize', updateScale); window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)'). diff --git a/src/main/resources/com/finebi/plugin/web/scripts/entry.js b/src/main/resources/com/finebi/plugin/web/scripts/entry.js index daea6ac..c63e581 100644 --- a/src/main/resources/com/finebi/plugin/web/scripts/entry.js +++ b/src/main/resources/com/finebi/plugin/web/scripts/entry.js @@ -1,7 +1,14 @@ !(function () { var scale = 1, transformY = 0, selected = true; - var wrapper = document.getElementById("wrapper"); var html = document.getElementsByTagName('html')[0]; + var wrapper = document.getElementById("wrapper"); + var fixedContainer = document.createElement('div'); + fixedContainer.style.position = "absolute"; + fixedContainer.style.top = "0"; + fixedContainer.style.left = "0"; + fixedContainer.style.width = "100%"; + + wrapper.appendChild(fixedContainer); var jQuery = $ || window.jQuery; var injectOffset = jQuery.fn.offset; @@ -53,6 +60,7 @@ wrapper.style.transformOrigin = "top left"; wrapper.style["-ms-transform"] = "scale(" + bounds.scale+ ")"; wrapper.style["-ms-transform-origin"] = "top left"; + fixedContainer.style.height = (document.body.clientHeight / scale) + "px"; // html.style.backgroundColor = document.getElementsByClassName('bi-theme-dark').length === 0 ? "#2c3d59" : "#ffffff"; html.style.backgroundColor = "#ffffff"; @@ -80,6 +88,7 @@ wrapper.style["-ms-transform-origin"] = ""; wrapper.style.overflowY = "hidden"; wrapper.style.top = ""; + fixedContainer.style.height = "0px"; html.style.backgroundColor = "#ffffff"; scale = 1; @@ -274,11 +283,14 @@ BI.createWidget = function () { if (arguments[0] && arguments[0].element === "body") { - arguments[0].element = wrapper; + arguments[0].element = fixedContainer; } return injectCreate.apply(this, arguments); }; + // Popovers + BI.Popovers = new BI.PopoverController({render: fixedContainer}); + // document.body.onmousedown = scaleFixed; window.addEventListener('resize', updateScale); window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)'). @@ -299,6 +311,9 @@ } BI.createWidget = injectCreate; + // Popovers + BI.Popovers = new BI.PopoverController(); + document.body.onmousedown = null; window.removeEventListener('resize', updateScale); window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)'). From 7fbe0760fa0e6a5b999fd910b0ffac0f5fe9803b Mon Sep 17 00:00:00 2001 From: Fay <lfhlifenghao@gmail.com> Date: Tue, 19 Nov 2019 15:33:15 +0800 Subject: [PATCH 3/4] =?UTF-8?q?BI-55967=20&=20BI-55751=20&=20BI-55749=20?= =?UTF-8?q?=E8=AE=A1=E7=AE=97popup=E4=BD=8D=E7=BD=AE=E6=97=B6=E7=94=A8wrap?= =?UTF-8?q?per=E4=BB=A3=E6=9B=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/web/plugin.screen_adaptive.js | 101 ++++-------------- .../com/finebi/plugin/web/scripts/entry.js | 101 ++++-------------- 2 files changed, 46 insertions(+), 156 deletions(-) diff --git a/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js b/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js index c63e581..1eb30a4 100644 --- a/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js +++ b/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js @@ -17,9 +17,7 @@ var injectToolTipShow = null; var injectBubblesShow = null; var adjustHeight = BI.Combo.prototype.adjustHeight; - var injectOuterWidth = jQuery.fn.outerWidth; - var injectOuterHeight = jQuery.fn.outerHeight; - var injectBounds = jQuery.fn.bounds; + var originalRender = BI.Widget._renderEngine; var injectCreate = BI.createWidget; @@ -61,21 +59,12 @@ wrapper.style["-ms-transform"] = "scale(" + bounds.scale+ ")"; wrapper.style["-ms-transform-origin"] = "top left"; fixedContainer.style.height = (document.body.clientHeight / scale) + "px"; - // html.style.backgroundColor = document.getElementsByClassName('bi-theme-dark').length === 0 ? "#2c3d59" : "#ffffff"; + wrapper.style.overflowY = "hidden"; + document.body.style.overflowX = "hidden"; + document.body.style.overflowY = "auto"; html.style.backgroundColor = "#ffffff"; - // if (bounds.height * bounds.scale < html.clientHeight) { - // transformY = (html.clientHeight - bounds.height * bounds.scale) / 2; - // html.style.overflowY = "hidden"; - // } else { - // transformY = 0; - // } - - // document.body.style.height = (bounds.height * scale) + "px"; - // document.body.style.overflow = "hidden"; - // document.body.style.top = transformY + "px"; window.scale = window.devicePixelRatio * scale; - // scaleFixed(); } // 取消缩放 @@ -89,16 +78,12 @@ wrapper.style.overflowY = "hidden"; wrapper.style.top = ""; fixedContainer.style.height = "0px"; + document.body.style.overflowX = "hidden"; + document.body.style.overflowY = "hidden"; html.style.backgroundColor = "#ffffff"; scale = 1; - // document.body.style.top = "0px"; - // document.body.style.width = ""; - // document.body.style.height = ""; - // document.body.style.overflowY = ""; window.scale = window.devicePixelRatio / scale; - - // revertFixed(); } // 获取缩放倍数,原模板宽高 @@ -203,9 +188,11 @@ } while( el ); var elm = elem; - // 不知道该怎么写代码了,就这样了 if (!checkInPopupView(elm)) { do{ + if (elm === document.body) { + break; + } offsetLeft -= elm.scrollLeft || 0; offsetTop -= elm.scrollTop || 0; elm = elm.parentNode; @@ -222,8 +209,6 @@ return correctEvent(injectEventFix.call(this, e)); }; if (BI.isIE()) { - - BI.Combo.prototype.adjustHeight = function (e) { adjustHeight.call(this, e); if (this.popupView) { @@ -253,32 +238,6 @@ tooltip.element[0].style.transform = "scale(" + scale+ ")"; tooltip.element[0].style.transformOrigin = "top left"; } - // jQuery.fn.outerWidth = function () { - // var wdith = injectOuterWidth.apply(this, arguments); - // if (this[0] === document.body) { - // return wdith / scale; - // } - // return wdith; - // } - // jQuery.fn.outerHeight = function () { - // var height = injectOuterHeight.apply(this, arguments); - // if (this[0] === document.body) { - // return height / scale; - // } - // return height; - // } - // BI.DOM.getBottomPosition = function (combo, popup, extraHeight) { - // var el = combo.element; - // return { - // top: el.offset().top + el.outerHeight() * (1 - checkInPopupView(el[0]) ? scale : 0) + (extraHeight || 0) - // }; - // } - // BI.DOM.getRightPosition = function (combo, popup, extraWidth) { - // var el = combo.element; - // return { - // left: el.offset().left + el.outerWidth() * (1-checkInPopupView(el[0]) ? scale : 0) + (extraWidth || 0) - // }; - // } } BI.createWidget = function () { @@ -291,7 +250,19 @@ // Popovers BI.Popovers = new BI.PopoverController({render: fixedContainer}); - // document.body.onmousedown = scaleFixed; + // + BI.Widget.registerRenderEngine({ + createElement: function (widget) { + if (widget === "body") { + return BI.$(wrapper); + } + return originalRender.createElement(widget); + }, + createFragment: function () { + return originalRender.createFragment(); + } + }); + window.addEventListener('resize', updateScale); window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)'). addListener(selectHandler); @@ -301,18 +272,16 @@ jQuery.fn.__isMouseInBounds__ = injectMouseInBounds; jQuery.fn.offset = injectOffset; jQuery.event.fix = injectEventFix; - // jQuery.fn.bounds = injectBounds; if (BI.isIE()) { BI.Combo.prototype.adjustHeight = adjustHeight; BI.Tooltips.show = injectToolTipShow; BI.Bubbles.show = injectBubblesShow; - // jQuery.fn.outerWidth = injectOuterWidth; - // jQuery.fn.outerHeight = injectOuterHeight; } BI.createWidget = injectCreate; // Popovers BI.Popovers = new BI.PopoverController(); + BI.Widget.registerRenderEngine(originalRender); document.body.onmousedown = null; window.removeEventListener('resize', updateScale); @@ -346,30 +315,6 @@ } } injectMouseMoveTracker(); - // popupview - // function scaleFixed() { - // if (BI.isIE()) { - // var fixedList = document.getElementsByClassName("bi-popup-view"); - // BI.each(fixedList, function (i, el) { - // if (window.getComputedStyle(el).position === 'fixed') { - // el.style.transformOrigin = "top left"; - // el.style.transform = "scale(" + scale + ")"; - // } - // }) - // } - // } - // - // function revertFixed() { - // if (BI.isIE()) { - // var fixedList = document.getElementsByClassName("bi-popup-view"); - // BI.each(fixedList, function (i, el) { - // if (window.getComputedStyle(el).position === 'fixed') { - // el.style.transformOrigin = ""; - // el.style.transform = ""; - // } - // }) - // } - // } selectHandler(); BI.config("bi.constant.dashboard.toolbar.left.items", function (config) { diff --git a/src/main/resources/com/finebi/plugin/web/scripts/entry.js b/src/main/resources/com/finebi/plugin/web/scripts/entry.js index c63e581..1eb30a4 100644 --- a/src/main/resources/com/finebi/plugin/web/scripts/entry.js +++ b/src/main/resources/com/finebi/plugin/web/scripts/entry.js @@ -17,9 +17,7 @@ var injectToolTipShow = null; var injectBubblesShow = null; var adjustHeight = BI.Combo.prototype.adjustHeight; - var injectOuterWidth = jQuery.fn.outerWidth; - var injectOuterHeight = jQuery.fn.outerHeight; - var injectBounds = jQuery.fn.bounds; + var originalRender = BI.Widget._renderEngine; var injectCreate = BI.createWidget; @@ -61,21 +59,12 @@ wrapper.style["-ms-transform"] = "scale(" + bounds.scale+ ")"; wrapper.style["-ms-transform-origin"] = "top left"; fixedContainer.style.height = (document.body.clientHeight / scale) + "px"; - // html.style.backgroundColor = document.getElementsByClassName('bi-theme-dark').length === 0 ? "#2c3d59" : "#ffffff"; + wrapper.style.overflowY = "hidden"; + document.body.style.overflowX = "hidden"; + document.body.style.overflowY = "auto"; html.style.backgroundColor = "#ffffff"; - // if (bounds.height * bounds.scale < html.clientHeight) { - // transformY = (html.clientHeight - bounds.height * bounds.scale) / 2; - // html.style.overflowY = "hidden"; - // } else { - // transformY = 0; - // } - - // document.body.style.height = (bounds.height * scale) + "px"; - // document.body.style.overflow = "hidden"; - // document.body.style.top = transformY + "px"; window.scale = window.devicePixelRatio * scale; - // scaleFixed(); } // 取消缩放 @@ -89,16 +78,12 @@ wrapper.style.overflowY = "hidden"; wrapper.style.top = ""; fixedContainer.style.height = "0px"; + document.body.style.overflowX = "hidden"; + document.body.style.overflowY = "hidden"; html.style.backgroundColor = "#ffffff"; scale = 1; - // document.body.style.top = "0px"; - // document.body.style.width = ""; - // document.body.style.height = ""; - // document.body.style.overflowY = ""; window.scale = window.devicePixelRatio / scale; - - // revertFixed(); } // 获取缩放倍数,原模板宽高 @@ -203,9 +188,11 @@ } while( el ); var elm = elem; - // 不知道该怎么写代码了,就这样了 if (!checkInPopupView(elm)) { do{ + if (elm === document.body) { + break; + } offsetLeft -= elm.scrollLeft || 0; offsetTop -= elm.scrollTop || 0; elm = elm.parentNode; @@ -222,8 +209,6 @@ return correctEvent(injectEventFix.call(this, e)); }; if (BI.isIE()) { - - BI.Combo.prototype.adjustHeight = function (e) { adjustHeight.call(this, e); if (this.popupView) { @@ -253,32 +238,6 @@ tooltip.element[0].style.transform = "scale(" + scale+ ")"; tooltip.element[0].style.transformOrigin = "top left"; } - // jQuery.fn.outerWidth = function () { - // var wdith = injectOuterWidth.apply(this, arguments); - // if (this[0] === document.body) { - // return wdith / scale; - // } - // return wdith; - // } - // jQuery.fn.outerHeight = function () { - // var height = injectOuterHeight.apply(this, arguments); - // if (this[0] === document.body) { - // return height / scale; - // } - // return height; - // } - // BI.DOM.getBottomPosition = function (combo, popup, extraHeight) { - // var el = combo.element; - // return { - // top: el.offset().top + el.outerHeight() * (1 - checkInPopupView(el[0]) ? scale : 0) + (extraHeight || 0) - // }; - // } - // BI.DOM.getRightPosition = function (combo, popup, extraWidth) { - // var el = combo.element; - // return { - // left: el.offset().left + el.outerWidth() * (1-checkInPopupView(el[0]) ? scale : 0) + (extraWidth || 0) - // }; - // } } BI.createWidget = function () { @@ -291,7 +250,19 @@ // Popovers BI.Popovers = new BI.PopoverController({render: fixedContainer}); - // document.body.onmousedown = scaleFixed; + // + BI.Widget.registerRenderEngine({ + createElement: function (widget) { + if (widget === "body") { + return BI.$(wrapper); + } + return originalRender.createElement(widget); + }, + createFragment: function () { + return originalRender.createFragment(); + } + }); + window.addEventListener('resize', updateScale); window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)'). addListener(selectHandler); @@ -301,18 +272,16 @@ jQuery.fn.__isMouseInBounds__ = injectMouseInBounds; jQuery.fn.offset = injectOffset; jQuery.event.fix = injectEventFix; - // jQuery.fn.bounds = injectBounds; if (BI.isIE()) { BI.Combo.prototype.adjustHeight = adjustHeight; BI.Tooltips.show = injectToolTipShow; BI.Bubbles.show = injectBubblesShow; - // jQuery.fn.outerWidth = injectOuterWidth; - // jQuery.fn.outerHeight = injectOuterHeight; } BI.createWidget = injectCreate; // Popovers BI.Popovers = new BI.PopoverController(); + BI.Widget.registerRenderEngine(originalRender); document.body.onmousedown = null; window.removeEventListener('resize', updateScale); @@ -346,30 +315,6 @@ } } injectMouseMoveTracker(); - // popupview - // function scaleFixed() { - // if (BI.isIE()) { - // var fixedList = document.getElementsByClassName("bi-popup-view"); - // BI.each(fixedList, function (i, el) { - // if (window.getComputedStyle(el).position === 'fixed') { - // el.style.transformOrigin = "top left"; - // el.style.transform = "scale(" + scale + ")"; - // } - // }) - // } - // } - // - // function revertFixed() { - // if (BI.isIE()) { - // var fixedList = document.getElementsByClassName("bi-popup-view"); - // BI.each(fixedList, function (i, el) { - // if (window.getComputedStyle(el).position === 'fixed') { - // el.style.transformOrigin = ""; - // el.style.transform = ""; - // } - // }) - // } - // } selectHandler(); BI.config("bi.constant.dashboard.toolbar.left.items", function (config) { From 3a9ba966983648f3650747469213b384b5e06eef Mon Sep 17 00:00:00 2001 From: Fay <lfhlifenghao@gmail.com> Date: Tue, 26 Nov 2019 17:10:57 +0800 Subject: [PATCH 4/4] =?UTF-8?q?BI-56250=20fix=EF=BC=9A=E7=BC=A9=E5=B0=8F?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E6=9C=89=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/finebi/plugin/web/plugin.screen_adaptive.js | 8 ++++++++ src/main/resources/com/finebi/plugin/web/scripts/entry.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js b/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js index 1eb30a4..fc6f736 100644 --- a/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js +++ b/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js @@ -64,6 +64,11 @@ document.body.style.overflowY = "auto"; html.style.backgroundColor = "#ffffff"; + if (scale < 1) { + document.body.style.width = bounds.width + "px"; + document.body.style.height = bounds.height + "px"; + } + window.scale = window.devicePixelRatio * scale; } @@ -82,6 +87,9 @@ document.body.style.overflowY = "hidden"; html.style.backgroundColor = "#ffffff"; + document.body.style.width = "100%"; + document.body.style.height = "100%"; + scale = 1; window.scale = window.devicePixelRatio / scale; } diff --git a/src/main/resources/com/finebi/plugin/web/scripts/entry.js b/src/main/resources/com/finebi/plugin/web/scripts/entry.js index 1eb30a4..fc6f736 100644 --- a/src/main/resources/com/finebi/plugin/web/scripts/entry.js +++ b/src/main/resources/com/finebi/plugin/web/scripts/entry.js @@ -64,6 +64,11 @@ document.body.style.overflowY = "auto"; html.style.backgroundColor = "#ffffff"; + if (scale < 1) { + document.body.style.width = bounds.width + "px"; + document.body.style.height = bounds.height + "px"; + } + window.scale = window.devicePixelRatio * scale; } @@ -82,6 +87,9 @@ document.body.style.overflowY = "hidden"; html.style.backgroundColor = "#ffffff"; + document.body.style.width = "100%"; + document.body.style.height = "100%"; + scale = 1; window.scale = window.devicePixelRatio / scale; }