Revision 07458256
Von Sven Schöling vor 4 Tagen hinzugefügt
- ID 07458256bbef0d3b6aae9918e61dba46c690e580
- Vorgänger 525f4f88
js/kivi.Part.js | ||
---|---|---|
363 | 363 |
this.last_real = $real.val(); |
364 | 364 |
this.$dummy = $($real.siblings()[0]); |
365 | 365 |
this.autocomplete_open = false; |
366 |
this.menu_above = false; |
|
366 | 367 |
this.state = this.STATES.PICKED; |
367 | 368 |
this.last_dummy = this.$dummy.val(); |
368 | 369 |
this.timer = undefined; |
... | ... | |
569 | 570 |
event.preventDefault(); |
570 | 571 |
}, |
571 | 572 |
open: function() { |
573 |
const $widget = self.$dummy.autocomplete('widget'); |
|
574 |
const input_bound = self.$dummy[0].getBoundingClientRect(); |
|
575 |
|
|
576 |
// safe inner viewport height without scrollbars |
|
577 |
const viewport_height = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0); |
|
578 |
|
|
579 |
// logic: |
|
580 |
// if the widget was already open, keep position |
|
581 |
// if fits above but not below: render above |
|
582 |
// else: render below |
|
583 |
if (!self.autocomplete_open) { |
|
584 |
if (input_bound.top > $widget.height() && input_bound.bottom + $widget.height() > viewport_height) { |
|
585 |
$widget.position({ my: "left bottom", at: "left top", of: self.$dummy }); |
|
586 |
self.menu_above = true; |
|
587 |
} else { |
|
588 |
$widget.position({ my: "left top", at: "left bottom", of: self.$dummy }); |
|
589 |
self.menu_above = false; |
|
590 |
} |
|
591 |
} else { |
|
592 |
if (self.menu_above) { |
|
593 |
$widget.position({ my: "left bottom", at: "left top", of: self.$dummy }); |
|
594 |
} else { |
|
595 |
$widget.position({ my: "left top", at: "left bottom", of: self.$dummy }); |
|
596 |
} |
|
597 |
} |
|
598 |
|
|
572 | 599 |
self.autocomplete_open = true; |
573 | 600 |
}, |
574 | 601 |
close: function() { |
Auch abrufbar als: Unified diff
Artikeleingabe unten: autocomplete Position dynamisch über dem input