Compare commits

...

53 Commits

Author SHA1 Message Date
fay e7f20f2ae1 Pull request #51: BI-69384 fix: 去除scale元素 4 years ago
fay 83a407309e BI-69384 fix: 去除scale元素 4 years ago
fay e1a31cab45 Pull request #50: BI-69245 fix: IE弹框 4 years ago
fay d6f3758f84 BI-69245 fix: IE弹框 4 years ago
fay 308bdd8384 Pull request #49: BI-68076B fix: 二级菜单 4 years ago
fay 2e47ce1515 BI-68076B fix: 二级菜单 4 years ago
fay 173c8ca273 Pull request #48: 修改版本号 4 years ago
fay 401fe1b4e9 修改版本号 4 years ago
fay 0fe1077483 Pull request #47: BI-67373 fix: 处理挂载时候的弹窗问题 4 years ago
fay d17f6afc05 BI-67373 fix: 处理挂载时候的弹窗问题 4 years ago
fay 8f9d649cc6 Pull request #46: 无JIRA任务 IEswitcher弹窗问题 5 years ago
fay b7262aa3a4 update 5 years ago
fay 746661ccd5 无JIRA任务 IE弹出框 5 years ago
fay e8d4f2c1db 无JIRA任务 IEswitcher弹窗问题 5 years ago
fay 228775b9df Pull request #45: 改下版本号 5 years ago
fay b790d56fcc 改下版本号 5 years ago
fay ad75bfb991 Pull request #44: BI-66270 fix: 傻叉IE 5 years ago
fay 72b886adfa BI-66270 fix: 傻叉IE 5 years ago
fay 4d973462c0 Pull request #43: BI-66198 fix: 不知道算是主线bug还是chrome的bug还是插件bug 5 years ago
fay a241a6b2df BI-66198 5 years ago
fay 68f5b25fa6 BI-66198 fix: 不知道算是主线bug还是chrome的bug还是插件bug 5 years ago
fay b009729159 Pull request #42: BI-66116 & BI-66032 & BI-66034 适配新功能后的弹窗问题 5 years ago
fay 542f81e5cb BI-66116 & BI-66032 & BI-66034 适配新功能后的弹窗问题 5 years ago
fay 640bb0744e Pull request #41: KERNEL-4159 修改名称 5 years ago
fay b3c5fd6c47 KERNEL-4159 修改名称 5 years ago
fay 23c2be82c0 Pull request #39: BI-65798 feat:新增自定义缩放比功能 5 years ago
fay 27d701e0c3 BI-65798 feat:新增自定义缩放比功能 5 years ago
fay ffb6cfef94 Pull request #38: 优化图表显示 5 years ago
fay 88047c885d 优化图表显示 5 years ago
fay cd3b2cd40e Pull request #36: 无JIRA任务 修改512插件名称 5 years ago
fay 2726e1c84b Update plugin.xml 5 years ago
fay bc2272cfe2 Pull request #35: BI-65346 fix: 处理scale元素的滚动问题 5 years ago
fay de685fa653 BI-65346 fix: 处理scale元素的滚动问题 5 years ago
fay e6b109f417 Pull request #33: BI-65305 fix: popup方向判断在scale影响下错误 5 years ago
fay 185913033b BI-65305 fix: popup方向判断在scale影响下错误 5 years ago
fay 8b494d3925 Pull request #30: BI-65018 & BI-65037 & BI-65031 5 years ago
fay 816a9f3903 BI-65018 & BI-65037 & BI-65031 5 years ago
fay fa742cb03a Merge pull request #26 in PG2/plugin-bi-screen-adaptive from ~FAY/plugin-bi-screen-adaptive:persist/10.0 to persist/10.0 5 years ago
fay 2efa9d5d7c fix IE 5 years ago
fay a24aba0d7c BI-61373 fix: 插件造成模板位置问题 5 years ago
fay 25bf5e40d2 Merge pull request #24 in PG2/plugin-bi-screen-adaptive from release/10.0 to persist/10.0 5 years ago
fay 6f5050f22f Merge pull request #22 in PG/plugin-bi-screen-adaptive from ~FAY/plugin-bi-screen-adaptive:release/10.0 to release/10.0 5 years ago
Fay 3a9ba96698 BI-56250 fix:缩小的情况有滚动条 5 years ago
fay 0ceb555238 Merge pull request #21 in PG/plugin-bi-screen-adaptive from ~FAY/plugin-bi-screen-adaptive:release/10.0 to release/10.0 5 years ago
Fay 7fbe0760fa BI-55967 & BI-55751 & BI-55749 计算popup位置时用wrapper代替 5 years ago
windy 4c6c991919 Merge pull request #20 in PG/plugin-bi-screen-adaptive from ~FAY/plugin-bi-screen-adaptive:release/10.0 to release/10.0 5 years ago
Fay 4412413bb3 BI-55726 fix:没有局中 5 years ago
richie 7d38d4dbf3 Merge remote-tracking branch 'origin/release/10.0' into persist/10.0 5 years ago
Fay d551d0aaeb Merge branch 'feature/10.0' into release/10.0 5 years ago
Fay 3342f437e6 修改plugin文件 5 years ago
Lanlan 3f50abeec2 Merge pull request #16 in PG/plugin-bi-screen-adaptive from release/10.0 to persist/10.0 5 years ago
Lanlan 01a9b4d66e Merge pull request #9 in PG/plugin-bi-screen-adaptive from release/10.0 to persist/10.0 5 years ago
fay 395d95679a build.xml edited online with Bitbucket 5 years ago
  1. 6
      plugin.xml
  2. 5
      src/main/java/com/finebi/plugin/ScreenAdaptiveComponent.java
  3. 3
      src/main/resources/com/finebi/plugin/web/css/plugin.screen_adaptive.css
  4. 511
      src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js
  5. 511
      src/main/resources/com/finebi/plugin/web/scripts/entry.js

6
plugin.xml

@ -3,12 +3,16 @@
<id>com.finebi.plugin.screenadaptive</id>
<name><![CDATA[BI模板屏幕自适应]]></name>
<active>yes</active>
<version>1.1.33</version>
<version>1.1.42</version>
<env-version>10.0</env-version>
<jartime>2019-08-16</jartime>
<vendor>fay</vendor>
<description><![CDATA[预览BI模板时,根据屏幕的宽度自适应显示模板]]></description>
<change-notes><![CDATA[
[2020-06-25]修复bug<br/>
[2020-05-25]支持自定义缩放比<br/>
[2020-05-21]解决部分情况下图表模糊的情况<br/>
[2020-05-09]修复IE中有空白部分的情况<br/>
[2019-10-24]修复IE中有空白部分的情况<br/>
[2019-08-28]为BI模板添加模板自适应功能。<br/>
]]></change-notes>

5
src/main/java/com/finebi/plugin/ScreenAdaptiveComponent.java

@ -16,4 +16,9 @@ public class ScreenAdaptiveComponent extends Component {
public ScriptPath script() {
return ScriptPath.build("com/finebi/plugin/web/plugin.screen_adaptive.js");
}
@Override
public StylePath style() {
return StylePath.build("/com/finebi/plugin/web/css/plugin.screen_adaptive.css");
}
}

3
src/main/resources/com/finebi/plugin/web/css/plugin.screen_adaptive.css

@ -0,0 +1,3 @@
.bi-show-widget-tool-factory {
z-index: 1;
}

511
src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js

@ -1,7 +1,22 @@
!(function () {
var scale = 1, transformY = 0, selected = true;
var wrapper = document.getElementById("wrapper");
var scale = 1, transformY = 0, selected = true, globalScaleRatio = parseFloat(BI.Cache.getItem('scaleRatio')) || null;
var html = document.getElementsByTagName('html')[0];
var wrapper = document.getElementById("wrapper");
var scrollContainer = document.createElement("div");
var fixedWrapper = document.createElement("div");
var fixedContainer = document.createElement('div'); // tooltip等fixed元素
scrollContainer.style.width = "100%";
scrollContainer.style.height = "100%";
fixedContainer.style.position = "absolute";
fixedContainer.style.top = "0";
fixedContainer.style.left = "0";
fixedContainer.style.width = "100%";
fixedContainer.style.height = "100%";
document.body.appendChild(scrollContainer);
scrollContainer.appendChild(fixedWrapper);
fixedWrapper.appendChild(wrapper);
wrapper.appendChild(fixedContainer);
var jQuery = $ || window.jQuery;
var injectOffset = jQuery.fn.offset;
@ -10,11 +25,50 @@
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 injectSearchSearchStop = BI.Searcher.prototype._stopSearch;
var injectTooltipsShow = BI.TooltipsController.prototype.show;
var injectSwitcherPopup = BI.Switcher.prototype.populate;
var injectSwitcherAdjustView = BI.Switcher.prototype.adjustView;
var injectCreate = BI.createWidget;
var callback = function () {};
BI.Searcher.prototype._search = function (result, searchResult, keyword) {
var self = this, o = this.options, keyword = o.allowSearchBlank ? this.editor.getValue() : this._getLastSearchKeyword();
if (keyword === "" || this._stop) {
return;
}
if (o.isAutoSearch) {
var items = (o.adapter && ((o.adapter.getItems && o.adapter.getItems()) || o.adapter.attr("items"))) || [];
var finding = BI.Func.getSearchResult(items, keyword);
var match = finding.match, find = finding.find;
this.popupView.populate(find, match, keyword);
o.isAutoSync && o.adapter && o.adapter.getValue && this.popupView.setValue(o.adapter.getValue());
self.fireEvent(BI.Searcher.EVENT_SEARCHING);
callback && callback.call(self, true);
return;
}
this.popupView.loading && this.popupView.loading();
o.onSearch({
times: 1,
keyword: keyword,
selectedValues: o.adapter && o.adapter.getValue()
}, function (searchResult, matchResult) {
if (!self._stop) {
var args = [].slice.call(arguments);
if (args.length > 0) {
args.push(keyword);
}
BI.Maskers.show(self.getName());
self.popupView.populate.apply(self.popupView, args);
o.isAutoSync && o.adapter && o.adapter.getValue && self.popupView.setValue(o.adapter.getValue());
self.popupView.loaded && self.popupView.loaded();
self.fireEvent(BI.Searcher.EVENT_SEARCHING);
callback && callback.call(self);
}
});
};
// 修正事件偏移
function correctEvent(e) {
@ -43,8 +97,8 @@
}
// 进行缩放
function transformScale() {
var bounds = getScaleBounds();
function transformScale(ratio) {
var bounds = getScaleBounds(ratio);
scale = bounds.scale;
wrapper.style.width = bounds.width + "px";
@ -53,21 +107,16 @@
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";
wrapper.style.overflow = "hidden";
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();
scrollContainer.style.overflowX = globalScaleRatio === null ? "hidden" : "auto";
scrollContainer.style.overflowY = "auto";
fixedWrapper.style.overflow = "hidden";
fixedWrapper.style.width = bounds.width * scale + "px";
fixedWrapper.style.height = bounds.height * scale + "px";
window.scale = Math.max(window.devicePixelRatio * scale, 1);
}
// 取消缩放
@ -78,22 +127,35 @@
wrapper.style.transformOrigin = "";
wrapper.style["-ms-transform"] = "";
wrapper.style["-ms-transform-origin"] = "";
wrapper.style.overflowY = "hidden";
wrapper.style.overflow = "hidden";
wrapper.style.top = "";
html.style.backgroundColor = "#ffffff";
scrollContainer.style.overflow = "hidden";
fixedWrapper.style.overflow = "hidden";
fixedWrapper.style.width = "100%";
fixedWrapper.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;
if (BI.isIE()) {
removeDomScale(document.body);
}
window.scale = window.devicePixelRatio;
}
// revertFixed();
function removeDomScale(dom) {
var style = dom.style;
if (style.transform.includes("scale") && (style.transformOrigin === "top left" || style.transformOrigin === "left top")) {
style.transform = "";
style.transformOrigin = "";
}
BI.each(dom.children, function (idx, child) {
removeDomScale(child);
})
}
// 获取缩放倍数,原模板宽高
function getScaleBounds() {
function getScaleBounds(ratio) {
var widgets = BI.designConfigure.widgets,
layoutRatio = BI.designConfigure.layoutRatio,
freeLayoutRatio = BI.designConfigure.freeLayoutRatio,
@ -126,12 +188,27 @@
var templateWidth = (Math.round((right / (layoutRatio.x || 1)) || (freeRight / (freeLayoutRatio.x || 1)))) + 60;
var templateHeight = (Math.round((bottom / (layoutRatio.y || 1)) || (freeBottom / (freeLayoutRatio.y || 1)))) + 30;
var scaleRatio = parseFloat((html.clientWidth / templateWidth).toFixed(1));
var bHeight = html.clientHeight / scaleRatio;
var resultWidth = 0;
var resultHeight = 0;
var bHeight = 0;
if (ratio) {
scaleRatio = ratio;
bHeight = html.clientHeight / scaleRatio;
resultWidth = templateWidth;
resultHeight = Math.max(bHeight, templateHeight);
} else {
bHeight = html.clientHeight / scaleRatio;
resultWidth = html.clientWidth / scaleRatio;
resultHeight = Math.max(bHeight, scaleRatio === 1 ? html.clientHeight : templateHeight);
}
return {
scale: scaleRatio,
width: html.clientWidth / scaleRatio,
height: Math.max(bHeight, scaleRatio === 1 ? html.clientHeight : templateHeight)
width: resultWidth,
height: resultHeight
};
}
@ -188,18 +265,20 @@
offsetTop = 0;
do{
offsetLeft += el.offsetLeft;
offsetTop += el.offsetTop;
offsetLeft += ( BI.isIE() ? window.getComputedStyle(el).position === "fixed" ? el.offsetLeft / scale : el.offsetLeft : el.offsetLeft );
offsetTop += ( BI.isIE() ? window.getComputedStyle(el).position === "fixed" ? el.offsetTop / scale : el.offsetTop : el.offsetTop );
el = el.offsetParent;
} 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;
elm = elm.offsetParent;
} while( elm );
}
win = getWindow( doc );
@ -212,74 +291,201 @@
jQuery.event.fix = function ( e ) {
return correctEvent(injectEventFix.call(this, e));
};
if (BI.isIE()) {
// Popovers
BI.Popovers = new BI.PopoverController({render: fixedContainer});
if (BI.isIE()) {
BI.Combo.prototype.adjustHeight = function (e) {
adjustHeight.call(this, e);
var transformX = scrollContainer.scrollLeft;
var transformY = scrollContainer.scrollTop;
if (this.popupView) {
if (!checkInPopupView(this.popupView.element[0])) {
this.popupView.element[0].style.left = parseInt(this.popupView.element[0].style.left) * scale + "px";
this.popupView.element[0].style.top = parseInt(this.popupView.element[0].style.top) * scale + transformY + "px";
this.popupView.element[0].style.left = parseInt(this.popupView.element[0].style.left) * scale - transformX + "px";
this.popupView.element[0].style.top = parseInt(this.popupView.element[0].style.top) * scale - transformY + "px";
} else {
var cBounds = BI.extend({}, this.popupView.element[0].getBoundingClientRect());
var pBounds = BI.extend({}, this.popupView.element[0].parentElement.getBoundingClientRect());
var hasScale = this.popupView.element[0].style.transform && this.popupView.element[0].style.transform.includes("scale");
var minWidth = parseInt(this.popupView.element[0].style.minWidth);
var minHeight = parseInt(this.popupView.element[0].style.minHeight);
cBounds.width = Math.max(cBounds.width, minWidth * scale);
cBounds.height = Math.max(cBounds.height, minHeight * scale);
if ((cBounds.left * scale + cBounds.width * (hasScale ? 1 : scale)) - transformX > body.clientWidth) {
this.popupView.element[0].style.top = parseInt(pBounds.bottom) + "px";
this.popupView.element[0].style.left = parseInt(this.popupView.element[0].style.left) * scale - transformX + "px";
} else if (this.options.direction === "right") {
this.popupView.element[0].style.top = parseInt(pBounds.top) + "px";
this.popupView.element[0].style.left = parseInt(pBounds.right) + "px";
} else if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) >= parseInt(pBounds.left)) {
this.popupView.element[0].style.top = parseInt(pBounds.bottom) + "px";
this.popupView.element[0].style.left = parseInt(pBounds.left) + "px";
}else if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) < parseInt(pBounds.left)) {
this.popupView.element[0].style.top = parseInt(pBounds.bottom) + "px";
this.popupView.element[0].style.left = parseInt(Math.min(pBounds.left, body.clientWidth - cBounds.width)) + "px";
} else {
this.popupView.element[0].style.top = parseInt(pBounds.bottom) + "px";
this.popupView.element[0].style.left = parseInt(cBounds.left) * scale + "px";
}
}
this.popupView.element[0].style.transform = "scale(" + scale+ ")";
this.popupView.element[0].style.transformOrigin = "top left";
}
};
BI.Tooltips.show = function (e, name, text, level, context, opt) {
injectToolTipShow.call(this, e, name, text, level, context, opt);
var tooltip = this.get(name);
tooltip.element[0].style.left = parseInt(tooltip.element[0].style.left) * scale + "px";
tooltip.element[0].style.top = parseInt(tooltip.element[0].style.top) * scale + transformY + "px";
tooltip.element[0].style.transform = "scale(" + scale+ ")";
tooltip.element[0].style.transformOrigin = "top left";
}
BI.Bubbles.show = function (name, text, context, opt) {
injectBubblesShow.call(this, name, text, context, opt);
var tooltip = this.get(name);
tooltip.element[0].style.left = parseInt(tooltip.element[0].style.left) * scale + "px";
tooltip.element[0].style.top = parseInt(tooltip.element[0].style.top) * scale + transformY + "px";
var transformX = scrollContainer.scrollLeft / scale, transformY = scrollContainer.scrollTop / scale;
tooltip.element[0].style.left = parseInt(tooltip.element[0].style.left) * scale - transformX + "px";
tooltip.element[0].style.top = parseInt(tooltip.element[0].style.top) * scale - transformY + "px";
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)
// };
// }
var tempAdd = BI.Popovers.add;
BI.Popovers.add = function (name, popover, options, context) {
tempAdd.call(this, name, popover, options, context);
if (this.floatContainer[name].options.cls && this.floatContainer[name].options.cls.includes("bi-popup-view")) {
this.floatContainer[name].element[0].style.setProperty("position", "absolute", "important");
}
}
// Searcher
callback = function (flag) {
var self = this;
BI.defer(function () {
if (self.popupView && self.popupView.element[0].parentElement) {
var skip = BI.isNotEmptyString(self.popupView.element[0].parentElement.style.transformOrigin) && flag;
if (!skip) {
self.popupView.element[0].parentElement.style.left = parseInt(self.popupView.element[0].parentElement.style.left) * scale + "px";
self.popupView.element[0].parentElement.style.top = parseInt(self.popupView.element[0].parentElement.style.top) * scale + "px";
self.popupView.element[0].parentElement.style.transform = "scale(" + scale + ")";
self.popupView.element[0].parentElement.style.transformOrigin = "left top";
}
}
})
}
BI.Searcher.prototype._stopSearch = function () {
injectSearchSearchStop.apply(this, arguments);
if (this.popupView && this.popupView.element[0].parentElement) {
this.popupView.element[0].parentElement.style.transform = "";
this.popupView.element[0].parentElement.style.transformOrigin = "";
}
}
// switcher
BI.Switcher.prototype.populate = function (items) {
injectSwitcherPopup.apply(this, arguments);
var self = this;
BI.defer(function () {
if (self.popupView) {
self.popupView.element[0].parentElement.style.left = parseInt(self.popupView.element[0].parentElement.style.left) * scale + "px";
self.popupView.element[0].parentElement.style.top = parseInt(self.popupView.element[0].parentElement.style.top) * scale + "px";
self.popupView.element[0].parentElement.style.transform = "scale(" + scale + ")";
self.popupView.element[0].parentElement.style.transformOrigin = "left top";
}
})
}
BI.Switcher.prototype.adjustView = function () {
injectSwitcherAdjustView.apply(this, arguments);
if (this.popupView) {
this.popupView.element[0].parentElement.style.left = parseInt(this.popupView.element[0].parentElement.style.left) * scale + "px";
this.popupView.element[0].parentElement.style.top = parseInt(this.popupView.element[0].parentElement.style.top) * scale + "px";
this.popupView.element[0].parentElement.style.transform = "scale(" + scale + ")";
this.popupView.element[0].parentElement.style.transformOrigin = "left top";
}
}
}
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;
BI.Widget.registerRenderEngine({
createElement: function (widget) {
if (widget === "body") {
return BI.$(wrapper);
}
return originalRender.createElement(widget);
},
createFragment: function () {
return originalRender.createFragment();
}
});
BI.TooltipsController.prototype.show = function (e, name, text, level, context, opt) {
opt || (opt = {});
var self = this;
BI.each(this.showingTips, function (i, tip) {
self.hide(i);
});
this.showingTips = {};
if (!this.has(name)) {
this.create(name, text, level, opt.container || "body");
}
if (!opt.belowMouse) {
var offset = context.element.offset();
var bounds = context.element.bounds();
if (bounds.height === 0 || bounds.width === 0) {
return;
}
var top = offset.top + bounds.height + 5;
}
var tooltip = this.get(name);
tooltip.setText(text);
tooltip.element.css({
left: "0px",
top: "0px"
});
tooltip.visible();
tooltip.element.height(tooltip.element[0].scrollHeight);
this.showingTips[name] = true;
// scale影响要计算在内
// var scale = context.element.offset().left / context.element.get(0).getBoundingClientRect().left;
// var x = (e.pageX || e.clientX) * scale + 15, y = (e.pageY || e.clientY) * scale + 15;
var x = (e.pageX || e.clientX) + 15, y = (e.pageY || e.clientY) + 15;
var originY = 0;
if (BI.isIE()) {
x = x * scale;
y = y * scale;
} else {
x = x + scrollContainer.scrollLeft / scale;
}
if (x + tooltip.element.outerWidth() > BI.Widget._renderEngine.createElement("body").outerWidth()) {
x -= tooltip.element.outerWidth() + 15;
}
var bodyHeight = BI.Widget._renderEngine.createElement("body").outerHeight();
if (y + tooltip.element.outerHeight() > bodyHeight || top + tooltip.element.outerHeight() > bodyHeight) {
y -= tooltip.element.outerHeight() + 15;
originY = y;
!opt.belowMouse && (y = Math.min(y, offset.top - tooltip.element.outerHeight() - 5));
} else {
originY = y;
!opt.belowMouse && (y = Math.max(y, top));
}
tooltip.element.css({
left: x < 0 ? 0 : x + "px",
top: y < 0 ? 0 : y + "px"
});
tooltip.element.hover(function () {
self.remove(name);
context.element.trigger("mouseleave.title" + context.getName());
});
if (BI.isIE()) {
tooltip.element[0].style.transform = "scale(" + scale+ ")";
tooltip.element[0].style.transformOrigin = "top left";
}
return this;
}
window.addEventListener('resize', updateScale);
window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)').
addListener(selectHandler);
@ -289,16 +495,22 @@
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);
callback = function () {}
BI.Switcher.prototype.populate = injectSwitcherPopup;
BI.Switcher.prototype.adjustView = injectSwitcherAdjustView;
BI.TooltipsController.prototype.show = injectTooltipsShow;
document.body.onmousedown = null;
window.removeEventListener('resize', updateScale);
window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)').
@ -307,7 +519,7 @@
var selectHandler = BI.debounce(function () {
selected && prepareEnv();
selected ? transformScale() : removeScale();
selected ? transformScale(globalScaleRatio) : removeScale();
!selected && restoreEnv();
}, 30);
@ -331,30 +543,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) {
@ -369,6 +557,119 @@
selectHandler();
}
}]
}, {
type: 'bi.text_value_combo',
text: '自定义缩放比例',
width: 120,
value: globalScaleRatio,
items: [
{
text: '自动',
value: null,
lgap: 10,
},
{
text: '50%',
value: 0.5,
lgap: 10,
},
{
text: '60%',
value: 0.6,
lgap: 10,
},
{
text: '70%',
value: 0.7,
lgap: 10,
},
{
lgap: 10,
text: '80%',
value: 0.8,
lgap: 10,
},
{
lgap: 10,
text: '90%',
value: 0.9,
lgap: 10,
},
{
lgap: 10,
text: '100%',
value: 1.0,
lgap: 10,
},
{
lgap: 10,
text: '110%',
value: 1.1,
lgap: 10,
},
{
lgap: 10,
text: '120%',
value: 1.2,
lgap: 10,
},
{
lgap: 10,
text: '130%',
value: 1.3,
lgap: 10,
},
{
lgap: 10,
text: '140%',
value: 1.4,
lgap: 10,
},
{
lgap: 10,
text: '150%',
value: 1.5,
lgap: 10,
},
{
lgap: 10,
text: '160%',
value: 1.6,
lgap: 10,
},
{
lgap: 10,
text: '170%',
value: 1.7,
lgap: 10,
},
{
lgap: 10,
text: '180%',
value: 1.8,
lgap: 10,
},
{
lgap: 10,
text: '190%',
value: 1.9,
lgap: 10,
},
{
lgap: 10,
text: '200%',
value: 2.0,
lgap: 10,
},
],
listeners: [{
eventName: "EVENT_CHANGE",
action: function (v) {
BI.Cache.setItem('scaleRatio', v);
globalScaleRatio = v;
selectHandler();
}
}],
}])
});
}());

511
src/main/resources/com/finebi/plugin/web/scripts/entry.js

@ -1,7 +1,22 @@
!(function () {
var scale = 1, transformY = 0, selected = true;
var wrapper = document.getElementById("wrapper");
var scale = 1, transformY = 0, selected = true, globalScaleRatio = parseFloat(BI.Cache.getItem('scaleRatio')) || null;
var html = document.getElementsByTagName('html')[0];
var wrapper = document.getElementById("wrapper");
var scrollContainer = document.createElement("div");
var fixedWrapper = document.createElement("div");
var fixedContainer = document.createElement('div'); // tooltip等fixed元素
scrollContainer.style.width = "100%";
scrollContainer.style.height = "100%";
fixedContainer.style.position = "absolute";
fixedContainer.style.top = "0";
fixedContainer.style.left = "0";
fixedContainer.style.width = "100%";
fixedContainer.style.height = "100%";
document.body.appendChild(scrollContainer);
scrollContainer.appendChild(fixedWrapper);
fixedWrapper.appendChild(wrapper);
wrapper.appendChild(fixedContainer);
var jQuery = $ || window.jQuery;
var injectOffset = jQuery.fn.offset;
@ -10,11 +25,50 @@
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 injectSearchSearchStop = BI.Searcher.prototype._stopSearch;
var injectTooltipsShow = BI.TooltipsController.prototype.show;
var injectSwitcherPopup = BI.Switcher.prototype.populate;
var injectSwitcherAdjustView = BI.Switcher.prototype.adjustView;
var injectCreate = BI.createWidget;
var callback = function () {};
BI.Searcher.prototype._search = function (result, searchResult, keyword) {
var self = this, o = this.options, keyword = o.allowSearchBlank ? this.editor.getValue() : this._getLastSearchKeyword();
if (keyword === "" || this._stop) {
return;
}
if (o.isAutoSearch) {
var items = (o.adapter && ((o.adapter.getItems && o.adapter.getItems()) || o.adapter.attr("items"))) || [];
var finding = BI.Func.getSearchResult(items, keyword);
var match = finding.match, find = finding.find;
this.popupView.populate(find, match, keyword);
o.isAutoSync && o.adapter && o.adapter.getValue && this.popupView.setValue(o.adapter.getValue());
self.fireEvent(BI.Searcher.EVENT_SEARCHING);
callback && callback.call(self, true);
return;
}
this.popupView.loading && this.popupView.loading();
o.onSearch({
times: 1,
keyword: keyword,
selectedValues: o.adapter && o.adapter.getValue()
}, function (searchResult, matchResult) {
if (!self._stop) {
var args = [].slice.call(arguments);
if (args.length > 0) {
args.push(keyword);
}
BI.Maskers.show(self.getName());
self.popupView.populate.apply(self.popupView, args);
o.isAutoSync && o.adapter && o.adapter.getValue && self.popupView.setValue(o.adapter.getValue());
self.popupView.loaded && self.popupView.loaded();
self.fireEvent(BI.Searcher.EVENT_SEARCHING);
callback && callback.call(self);
}
});
};
// 修正事件偏移
function correctEvent(e) {
@ -43,8 +97,8 @@
}
// 进行缩放
function transformScale() {
var bounds = getScaleBounds();
function transformScale(ratio) {
var bounds = getScaleBounds(ratio);
scale = bounds.scale;
wrapper.style.width = bounds.width + "px";
@ -53,21 +107,16 @@
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";
wrapper.style.overflow = "hidden";
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();
scrollContainer.style.overflowX = globalScaleRatio === null ? "hidden" : "auto";
scrollContainer.style.overflowY = "auto";
fixedWrapper.style.overflow = "hidden";
fixedWrapper.style.width = bounds.width * scale + "px";
fixedWrapper.style.height = bounds.height * scale + "px";
window.scale = Math.max(window.devicePixelRatio * scale, 1);
}
// 取消缩放
@ -78,22 +127,35 @@
wrapper.style.transformOrigin = "";
wrapper.style["-ms-transform"] = "";
wrapper.style["-ms-transform-origin"] = "";
wrapper.style.overflowY = "hidden";
wrapper.style.overflow = "hidden";
wrapper.style.top = "";
html.style.backgroundColor = "#ffffff";
scrollContainer.style.overflow = "hidden";
fixedWrapper.style.overflow = "hidden";
fixedWrapper.style.width = "100%";
fixedWrapper.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;
if (BI.isIE()) {
removeDomScale(document.body);
}
window.scale = window.devicePixelRatio;
}
// revertFixed();
function removeDomScale(dom) {
var style = dom.style;
if (style.transform.includes("scale") && (style.transformOrigin === "top left" || style.transformOrigin === "left top")) {
style.transform = "";
style.transformOrigin = "";
}
BI.each(dom.children, function (idx, child) {
removeDomScale(child);
})
}
// 获取缩放倍数,原模板宽高
function getScaleBounds() {
function getScaleBounds(ratio) {
var widgets = BI.designConfigure.widgets,
layoutRatio = BI.designConfigure.layoutRatio,
freeLayoutRatio = BI.designConfigure.freeLayoutRatio,
@ -126,12 +188,27 @@
var templateWidth = (Math.round((right / (layoutRatio.x || 1)) || (freeRight / (freeLayoutRatio.x || 1)))) + 60;
var templateHeight = (Math.round((bottom / (layoutRatio.y || 1)) || (freeBottom / (freeLayoutRatio.y || 1)))) + 30;
var scaleRatio = parseFloat((html.clientWidth / templateWidth).toFixed(1));
var bHeight = html.clientHeight / scaleRatio;
var resultWidth = 0;
var resultHeight = 0;
var bHeight = 0;
if (ratio) {
scaleRatio = ratio;
bHeight = html.clientHeight / scaleRatio;
resultWidth = templateWidth;
resultHeight = Math.max(bHeight, templateHeight);
} else {
bHeight = html.clientHeight / scaleRatio;
resultWidth = html.clientWidth / scaleRatio;
resultHeight = Math.max(bHeight, scaleRatio === 1 ? html.clientHeight : templateHeight);
}
return {
scale: scaleRatio,
width: html.clientWidth / scaleRatio,
height: Math.max(bHeight, scaleRatio === 1 ? html.clientHeight : templateHeight)
width: resultWidth,
height: resultHeight
};
}
@ -188,18 +265,20 @@
offsetTop = 0;
do{
offsetLeft += el.offsetLeft;
offsetTop += el.offsetTop;
offsetLeft += ( BI.isIE() ? window.getComputedStyle(el).position === "fixed" ? el.offsetLeft / scale : el.offsetLeft : el.offsetLeft );
offsetTop += ( BI.isIE() ? window.getComputedStyle(el).position === "fixed" ? el.offsetTop / scale : el.offsetTop : el.offsetTop );
el = el.offsetParent;
} 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;
elm = elm.offsetParent;
} while( elm );
}
win = getWindow( doc );
@ -212,74 +291,201 @@
jQuery.event.fix = function ( e ) {
return correctEvent(injectEventFix.call(this, e));
};
if (BI.isIE()) {
// Popovers
BI.Popovers = new BI.PopoverController({render: fixedContainer});
if (BI.isIE()) {
BI.Combo.prototype.adjustHeight = function (e) {
adjustHeight.call(this, e);
var transformX = scrollContainer.scrollLeft;
var transformY = scrollContainer.scrollTop;
if (this.popupView) {
if (!checkInPopupView(this.popupView.element[0])) {
this.popupView.element[0].style.left = parseInt(this.popupView.element[0].style.left) * scale + "px";
this.popupView.element[0].style.top = parseInt(this.popupView.element[0].style.top) * scale + transformY + "px";
this.popupView.element[0].style.left = parseInt(this.popupView.element[0].style.left) * scale - transformX + "px";
this.popupView.element[0].style.top = parseInt(this.popupView.element[0].style.top) * scale - transformY + "px";
} else {
var cBounds = BI.extend({}, this.popupView.element[0].getBoundingClientRect());
var pBounds = BI.extend({}, this.popupView.element[0].parentElement.getBoundingClientRect());
var hasScale = this.popupView.element[0].style.transform && this.popupView.element[0].style.transform.includes("scale");
var minWidth = parseInt(this.popupView.element[0].style.minWidth);
var minHeight = parseInt(this.popupView.element[0].style.minHeight);
cBounds.width = Math.max(cBounds.width, minWidth * scale);
cBounds.height = Math.max(cBounds.height, minHeight * scale);
if ((cBounds.left * scale + cBounds.width * (hasScale ? 1 : scale)) - transformX > body.clientWidth) {
this.popupView.element[0].style.top = parseInt(pBounds.bottom) + "px";
this.popupView.element[0].style.left = parseInt(this.popupView.element[0].style.left) * scale - transformX + "px";
} else if (this.options.direction === "right") {
this.popupView.element[0].style.top = parseInt(pBounds.top) + "px";
this.popupView.element[0].style.left = parseInt(pBounds.right) + "px";
} else if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) >= parseInt(pBounds.left)) {
this.popupView.element[0].style.top = parseInt(pBounds.bottom) + "px";
this.popupView.element[0].style.left = parseInt(pBounds.left) + "px";
}else if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) < parseInt(pBounds.left)) {
this.popupView.element[0].style.top = parseInt(pBounds.bottom) + "px";
this.popupView.element[0].style.left = parseInt(Math.min(pBounds.left, body.clientWidth - cBounds.width)) + "px";
} else {
this.popupView.element[0].style.top = parseInt(pBounds.bottom) + "px";
this.popupView.element[0].style.left = parseInt(cBounds.left) * scale + "px";
}
}
this.popupView.element[0].style.transform = "scale(" + scale+ ")";
this.popupView.element[0].style.transformOrigin = "top left";
}
};
BI.Tooltips.show = function (e, name, text, level, context, opt) {
injectToolTipShow.call(this, e, name, text, level, context, opt);
var tooltip = this.get(name);
tooltip.element[0].style.left = parseInt(tooltip.element[0].style.left) * scale + "px";
tooltip.element[0].style.top = parseInt(tooltip.element[0].style.top) * scale + transformY + "px";
tooltip.element[0].style.transform = "scale(" + scale+ ")";
tooltip.element[0].style.transformOrigin = "top left";
}
BI.Bubbles.show = function (name, text, context, opt) {
injectBubblesShow.call(this, name, text, context, opt);
var tooltip = this.get(name);
tooltip.element[0].style.left = parseInt(tooltip.element[0].style.left) * scale + "px";
tooltip.element[0].style.top = parseInt(tooltip.element[0].style.top) * scale + transformY + "px";
var transformX = scrollContainer.scrollLeft / scale, transformY = scrollContainer.scrollTop / scale;
tooltip.element[0].style.left = parseInt(tooltip.element[0].style.left) * scale - transformX + "px";
tooltip.element[0].style.top = parseInt(tooltip.element[0].style.top) * scale - transformY + "px";
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)
// };
// }
var tempAdd = BI.Popovers.add;
BI.Popovers.add = function (name, popover, options, context) {
tempAdd.call(this, name, popover, options, context);
if (this.floatContainer[name].options.cls && this.floatContainer[name].options.cls.includes("bi-popup-view")) {
this.floatContainer[name].element[0].style.setProperty("position", "absolute", "important");
}
}
// Searcher
callback = function (flag) {
var self = this;
BI.defer(function () {
if (self.popupView && self.popupView.element[0].parentElement) {
var skip = BI.isNotEmptyString(self.popupView.element[0].parentElement.style.transformOrigin) && flag;
if (!skip) {
self.popupView.element[0].parentElement.style.left = parseInt(self.popupView.element[0].parentElement.style.left) * scale + "px";
self.popupView.element[0].parentElement.style.top = parseInt(self.popupView.element[0].parentElement.style.top) * scale + "px";
self.popupView.element[0].parentElement.style.transform = "scale(" + scale + ")";
self.popupView.element[0].parentElement.style.transformOrigin = "left top";
}
}
})
}
BI.Searcher.prototype._stopSearch = function () {
injectSearchSearchStop.apply(this, arguments);
if (this.popupView && this.popupView.element[0].parentElement) {
this.popupView.element[0].parentElement.style.transform = "";
this.popupView.element[0].parentElement.style.transformOrigin = "";
}
}
// switcher
BI.Switcher.prototype.populate = function (items) {
injectSwitcherPopup.apply(this, arguments);
var self = this;
BI.defer(function () {
if (self.popupView) {
self.popupView.element[0].parentElement.style.left = parseInt(self.popupView.element[0].parentElement.style.left) * scale + "px";
self.popupView.element[0].parentElement.style.top = parseInt(self.popupView.element[0].parentElement.style.top) * scale + "px";
self.popupView.element[0].parentElement.style.transform = "scale(" + scale + ")";
self.popupView.element[0].parentElement.style.transformOrigin = "left top";
}
})
}
BI.Switcher.prototype.adjustView = function () {
injectSwitcherAdjustView.apply(this, arguments);
if (this.popupView) {
this.popupView.element[0].parentElement.style.left = parseInt(this.popupView.element[0].parentElement.style.left) * scale + "px";
this.popupView.element[0].parentElement.style.top = parseInt(this.popupView.element[0].parentElement.style.top) * scale + "px";
this.popupView.element[0].parentElement.style.transform = "scale(" + scale + ")";
this.popupView.element[0].parentElement.style.transformOrigin = "left top";
}
}
}
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;
BI.Widget.registerRenderEngine({
createElement: function (widget) {
if (widget === "body") {
return BI.$(wrapper);
}
return originalRender.createElement(widget);
},
createFragment: function () {
return originalRender.createFragment();
}
});
BI.TooltipsController.prototype.show = function (e, name, text, level, context, opt) {
opt || (opt = {});
var self = this;
BI.each(this.showingTips, function (i, tip) {
self.hide(i);
});
this.showingTips = {};
if (!this.has(name)) {
this.create(name, text, level, opt.container || "body");
}
if (!opt.belowMouse) {
var offset = context.element.offset();
var bounds = context.element.bounds();
if (bounds.height === 0 || bounds.width === 0) {
return;
}
var top = offset.top + bounds.height + 5;
}
var tooltip = this.get(name);
tooltip.setText(text);
tooltip.element.css({
left: "0px",
top: "0px"
});
tooltip.visible();
tooltip.element.height(tooltip.element[0].scrollHeight);
this.showingTips[name] = true;
// scale影响要计算在内
// var scale = context.element.offset().left / context.element.get(0).getBoundingClientRect().left;
// var x = (e.pageX || e.clientX) * scale + 15, y = (e.pageY || e.clientY) * scale + 15;
var x = (e.pageX || e.clientX) + 15, y = (e.pageY || e.clientY) + 15;
var originY = 0;
if (BI.isIE()) {
x = x * scale;
y = y * scale;
} else {
x = x + scrollContainer.scrollLeft / scale;
}
if (x + tooltip.element.outerWidth() > BI.Widget._renderEngine.createElement("body").outerWidth()) {
x -= tooltip.element.outerWidth() + 15;
}
var bodyHeight = BI.Widget._renderEngine.createElement("body").outerHeight();
if (y + tooltip.element.outerHeight() > bodyHeight || top + tooltip.element.outerHeight() > bodyHeight) {
y -= tooltip.element.outerHeight() + 15;
originY = y;
!opt.belowMouse && (y = Math.min(y, offset.top - tooltip.element.outerHeight() - 5));
} else {
originY = y;
!opt.belowMouse && (y = Math.max(y, top));
}
tooltip.element.css({
left: x < 0 ? 0 : x + "px",
top: y < 0 ? 0 : y + "px"
});
tooltip.element.hover(function () {
self.remove(name);
context.element.trigger("mouseleave.title" + context.getName());
});
if (BI.isIE()) {
tooltip.element[0].style.transform = "scale(" + scale+ ")";
tooltip.element[0].style.transformOrigin = "top left";
}
return this;
}
window.addEventListener('resize', updateScale);
window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)').
addListener(selectHandler);
@ -289,16 +495,22 @@
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);
callback = function () {}
BI.Switcher.prototype.populate = injectSwitcherPopup;
BI.Switcher.prototype.adjustView = injectSwitcherAdjustView;
BI.TooltipsController.prototype.show = injectTooltipsShow;
document.body.onmousedown = null;
window.removeEventListener('resize', updateScale);
window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)').
@ -307,7 +519,7 @@
var selectHandler = BI.debounce(function () {
selected && prepareEnv();
selected ? transformScale() : removeScale();
selected ? transformScale(globalScaleRatio) : removeScale();
!selected && restoreEnv();
}, 30);
@ -331,30 +543,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) {
@ -369,6 +557,119 @@
selectHandler();
}
}]
}, {
type: 'bi.text_value_combo',
text: '自定义缩放比例',
width: 120,
value: globalScaleRatio,
items: [
{
text: '自动',
value: null,
lgap: 10,
},
{
text: '50%',
value: 0.5,
lgap: 10,
},
{
text: '60%',
value: 0.6,
lgap: 10,
},
{
text: '70%',
value: 0.7,
lgap: 10,
},
{
lgap: 10,
text: '80%',
value: 0.8,
lgap: 10,
},
{
lgap: 10,
text: '90%',
value: 0.9,
lgap: 10,
},
{
lgap: 10,
text: '100%',
value: 1.0,
lgap: 10,
},
{
lgap: 10,
text: '110%',
value: 1.1,
lgap: 10,
},
{
lgap: 10,
text: '120%',
value: 1.2,
lgap: 10,
},
{
lgap: 10,
text: '130%',
value: 1.3,
lgap: 10,
},
{
lgap: 10,
text: '140%',
value: 1.4,
lgap: 10,
},
{
lgap: 10,
text: '150%',
value: 1.5,
lgap: 10,
},
{
lgap: 10,
text: '160%',
value: 1.6,
lgap: 10,
},
{
lgap: 10,
text: '170%',
value: 1.7,
lgap: 10,
},
{
lgap: 10,
text: '180%',
value: 1.8,
lgap: 10,
},
{
lgap: 10,
text: '190%',
value: 1.9,
lgap: 10,
},
{
lgap: 10,
text: '200%',
value: 2.0,
lgap: 10,
},
],
listeners: [{
eventName: "EVENT_CHANGE",
action: function (v) {
BI.Cache.setItem('scaleRatio', v);
globalScaleRatio = v;
selectHandler();
}
}],
}])
});
}());
Loading…
Cancel
Save