Skip to content
This repository was archived by the owner on Mar 6, 2020. It is now read-only.

Commit a52f73d

Browse files
author
René Kooi
committed
settings: expand dropdowns upward if there's not enough space below
1 parent 6fbc375 commit a52f73d

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/styles/settings-pane.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ define({
3535
'width': '50%',
3636
'top': '-5px',
3737
'margin-left': '50%'
38+
},
39+
'.extplug-dropdown-up': {
40+
'dd': {
41+
'position': 'absolute',
42+
'bottom': '39px',
43+
'width': '100%'
44+
}
3845
}
3946
},
4047

src/views/users/settings/DropdownView.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ define(function (require, exports, module) {
5353
return this;
5454
},
5555
close() {
56-
this.$dl.removeClass('open');
56+
this.$dl.removeClass('open extplug-dropdown-up');
5757
$(document).off('click', this.onDocumentClick);
5858
},
5959
remove() {
@@ -66,7 +66,12 @@ define(function (require, exports, module) {
6666
this.close();
6767
}
6868
else {
69-
this.$dl.addClass('open');
69+
if (this.canExpandDownward()) {
70+
this.$dl.addClass('open');
71+
}
72+
else {
73+
this.$dl.addClass('open extplug-dropdown-up');
74+
}
7075
_.defer(() => {
7176
$(document).on('click', this.onDocumentClick);
7277
});
@@ -82,6 +87,12 @@ define(function (require, exports, module) {
8287
},
8388
onDocumentClick(e) {
8489
_.defer(this.close.bind(this));
90+
},
91+
92+
canExpandDownward() {
93+
let top = this.$dl.offset().top;
94+
let bottom = top + this.$rows.height();
95+
return bottom < $(document).height();
8596
}
8697
});
8798

0 commit comments

Comments
 (0)