autofilter: don't allow to place outside screen

Change-Id: If4a0583e4160726bd0801a029161ba09442ab4f3
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
This commit is contained in:
Szymon Kłos 2021-01-06 13:08:24 +01:00 committed by Szymon Kłos
parent 1088e59a0c
commit 33ab7bdc6f

View file

@ -98,21 +98,35 @@ L.Control.AutofilterDropdown = L.Control.extend({
var innerContainer = L.DomUtil.create('div', 'autofilter-container', this.subMenu);
mainContainer = innerContainer;
L.DomUtil.setStyle(mainContainer, 'margin-left', this.position.x + this.container.offsetWidth - 30 + 'px');
L.DomUtil.setStyle(mainContainer, 'margin-top', this.position.y + 50 + 'px');
left = this.position.x + this.container.offsetWidth - 30;
top = this.position.y + 50;
} else {
this.container = L.DomUtil.create('div', 'autofilter-container', $('#document-container').get(0));
mainContainer = this.container;
L.DomUtil.setStyle(mainContainer, 'margin-left', left + 'px');
L.DomUtil.setStyle(mainContainer, 'margin-top', top + 'px');
this.position.x = left;
this.position.y = top;
}
L.DomUtil.setStyle(mainContainer, 'margin-left', left + 'px');
L.DomUtil.setStyle(mainContainer, 'margin-top', top + 'px');
var builder = new L.control.jsDialogBuilder({windowId: data.id, mobileWizard: this, map: this.map, cssClass: 'autofilter'});
builder.build(mainContainer, [data]);
var height = $(mainContainer).height();
if (top + height > $('#document-container').height()) {
var newTopPosition = top - height;
L.DomUtil.setStyle(mainContainer, 'margin-top', newTopPosition + 'px');
this.position.y = newTopPosition;
}
var width = $(mainContainer).width();
if (left + width > $('#document-container').width()) {
var newLeftPosition = left - width;
L.DomUtil.setStyle(mainContainer, 'margin-left', newLeftPosition + 'px');
this.position.x = newLeftPosition;
}
},
onJSUpdate: function (e) {