Browse Source

Merge pull request #24 in PG2/plugin-bi-screen-adaptive from release/10.0 to persist/10.0

* commit '6f5050f22f0d7802066c6d5ed9a70bd44d8c89ea':
  BI-56250 fix:缩小的情况有滚动条
  BI-55967 & BI-55751 & BI-55749 计算popup位置时用wrapper代替
  BI-55726 fix:没有局中
  修改plugin文件
persist/10.0
fay 5 years ago
parent
commit
25bf5e40d2
  1. 126
      src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js
  2. 126
      src/main/resources/com/finebi/plugin/web/scripts/entry.js

126
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;
@ -10,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;
@ -53,21 +58,18 @@
wrapper.style.transformOrigin = "top left";
wrapper.style["-ms-transform"] = "scale(" + bounds.scale+ ")";
wrapper.style["-ms-transform-origin"] = "top left";
// html.style.backgroundColor = document.getElementsByClassName('bi-theme-dark').length === 0 ? "#2c3d59" : "#ffffff";
fixedContainer.style.height = (document.body.clientHeight / scale) + "px";
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;
// }
if (scale < 1) {
document.body.style.width = bounds.width + "px";
document.body.style.height = bounds.height + "px";
}
// 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();
}
// 取消缩放
@ -80,16 +82,16 @@
wrapper.style["-ms-transform-origin"] = "";
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";
document.body.style.width = "100%";
document.body.style.height = "100%";
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();
}
// 获取缩放倍数,原模板宽高
@ -194,9 +196,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;
@ -213,8 +217,6 @@
return correctEvent(injectEventFix.call(this, e));
};
if (BI.isIE()) {
BI.Combo.prototype.adjustHeight = function (e) {
adjustHeight.call(this, e);
if (this.popupView) {
@ -244,42 +246,31 @@
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 () {
if (arguments[0] && arguments[0].element === "body") {
arguments[0].element = wrapper;
arguments[0].element = fixedContainer;
}
return injectCreate.apply(this, arguments);
};
// document.body.onmousedown = scaleFixed;
// Popovers
BI.Popovers = new BI.PopoverController({render: fixedContainer});
//
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);
@ -289,16 +280,17 @@
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);
window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)').
@ -331,30 +323,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) {

126
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;
@ -10,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;
@ -53,21 +58,18 @@
wrapper.style.transformOrigin = "top left";
wrapper.style["-ms-transform"] = "scale(" + bounds.scale+ ")";
wrapper.style["-ms-transform-origin"] = "top left";
// html.style.backgroundColor = document.getElementsByClassName('bi-theme-dark').length === 0 ? "#2c3d59" : "#ffffff";
fixedContainer.style.height = (document.body.clientHeight / scale) + "px";
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;
// }
if (scale < 1) {
document.body.style.width = bounds.width + "px";
document.body.style.height = bounds.height + "px";
}
// 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();
}
// 取消缩放
@ -80,16 +82,16 @@
wrapper.style["-ms-transform-origin"] = "";
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";
document.body.style.width = "100%";
document.body.style.height = "100%";
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();
}
// 获取缩放倍数,原模板宽高
@ -194,9 +196,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;
@ -213,8 +217,6 @@
return correctEvent(injectEventFix.call(this, e));
};
if (BI.isIE()) {
BI.Combo.prototype.adjustHeight = function (e) {
adjustHeight.call(this, e);
if (this.popupView) {
@ -244,42 +246,31 @@
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 () {
if (arguments[0] && arguments[0].element === "body") {
arguments[0].element = wrapper;
arguments[0].element = fixedContainer;
}
return injectCreate.apply(this, arguments);
};
// document.body.onmousedown = scaleFixed;
// Popovers
BI.Popovers = new BI.PopoverController({render: fixedContainer});
//
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);
@ -289,16 +280,17 @@
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);
window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)').
@ -331,30 +323,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) {

Loading…
Cancel
Save