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:
parent
1088e59a0c
commit
33ab7bdc6f
1 changed files with 19 additions and 5 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue