Browse Source

BI-66198 fix: 不知道算是主线bug还是chrome的bug还是插件bug

persist/10.0
fay 5 years ago
parent
commit
68f5b25fa6
  1. 5
      src/main/java/com/finebi/plugin/ScreenAdaptiveComponent.java
  2. 3
      src/main/resources/com/finebi/plugin/web/css/plugin.screen_adaptive.css
  3. 114
      src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js
  4. 114
      src/main/resources/com/finebi/plugin/web/scripts/entry.js

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;
}

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

@ -27,11 +27,57 @@
var adjustHeight = BI.Combo.prototype.adjustHeight;
var originalRender = BI.Widget._renderEngine;
var injectSearch = BI.Searcher.prototype._search;
var injectSearchView = BI.Searcher.prototype.setValue;
var injectSearchSetValue = BI.Searcher.prototype.setValue;
var injectSearchAdjustView = BI.Searcher.prototype._assertPopupView;
var injectTooltipsShow = BI.TooltipsController.prototype.show;
var injectSwitcherPopup = 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);
if (self.popupView) {
BI.defer(function () {
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";
})
}
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) {
@ -277,7 +323,7 @@
this.popupView.element[0].style.left = parseInt(Math.min(pBounds.left, body.clientWidth - cBounds.width)) - transformX + "px";
} else {
this.popupView.element[0].style.top = parseInt(pBounds.bottom) - transformY + "px";
this.popupView.element[0].style.left = parseInt(pBounds.left) - transformX + "px";
this.popupView.element[0].style.left = parseInt(cBounds.left) * scale - transformX + "px";
}
}
this.popupView.element[0].style.transform = "scale(" + scale+ ")";
@ -304,62 +350,26 @@
}
// Searcher
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);
if (self.popupView) {
BI.defer(function () {
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";
})
callback = function () {
var self = this;
BI.defer(function () {
if (self.popupView && self.popupView.element[0].parentElement) {
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";
}
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);
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.Searcher.prototype.setValue = function () {
injectSearchView.call(this, arguments);
injectSearchSetValue.call(this, arguments);
if (this.popupView && this.popupView.element[0].parentElement) {
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";
}
}
// switcher
@ -478,8 +488,8 @@
BI.Popovers = new BI.PopoverController();
BI.Widget.registerRenderEngine(originalRender);
BI.Searcher.prototype._search = injectSearch;
BI.Searcher.prototype.setValue = injectSearchView;
callback = function () {}
BI.Searcher.prototype.setValue = injectSearchSetValue;
BI.Switcher.prototype.adjustView = injectSwitcherPopup;
BI.TooltipsController.prototype.show = injectTooltipsShow;

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

@ -27,11 +27,57 @@
var adjustHeight = BI.Combo.prototype.adjustHeight;
var originalRender = BI.Widget._renderEngine;
var injectSearch = BI.Searcher.prototype._search;
var injectSearchView = BI.Searcher.prototype.setValue;
var injectSearchSetValue = BI.Searcher.prototype.setValue;
var injectSearchAdjustView = BI.Searcher.prototype._assertPopupView;
var injectTooltipsShow = BI.TooltipsController.prototype.show;
var injectSwitcherPopup = 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);
if (self.popupView) {
BI.defer(function () {
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";
})
}
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) {
@ -277,7 +323,7 @@
this.popupView.element[0].style.left = parseInt(Math.min(pBounds.left, body.clientWidth - cBounds.width)) - transformX + "px";
} else {
this.popupView.element[0].style.top = parseInt(pBounds.bottom) - transformY + "px";
this.popupView.element[0].style.left = parseInt(pBounds.left) - transformX + "px";
this.popupView.element[0].style.left = parseInt(cBounds.left) * scale - transformX + "px";
}
}
this.popupView.element[0].style.transform = "scale(" + scale+ ")";
@ -304,62 +350,26 @@
}
// Searcher
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);
if (self.popupView) {
BI.defer(function () {
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";
})
callback = function () {
var self = this;
BI.defer(function () {
if (self.popupView && self.popupView.element[0].parentElement) {
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";
}
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);
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.Searcher.prototype.setValue = function () {
injectSearchView.call(this, arguments);
injectSearchSetValue.call(this, arguments);
if (this.popupView && this.popupView.element[0].parentElement) {
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";
}
}
// switcher
@ -478,8 +488,8 @@
BI.Popovers = new BI.PopoverController();
BI.Widget.registerRenderEngine(originalRender);
BI.Searcher.prototype._search = injectSearch;
BI.Searcher.prototype.setValue = injectSearchView;
callback = function () {}
BI.Searcher.prototype.setValue = injectSearchSetValue;
BI.Switcher.prototype.adjustView = injectSwitcherPopup;
BI.TooltipsController.prototype.show = injectTooltipsShow;

Loading…
Cancel
Save