Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I modified the show_dropdown function to automatically determine if it should display above or below:</p> <pre><code>function show_dropdown() { if (input_box.is(':focus')) { var windowHeight = $(window).height(); var docViewTop = $(window).scrollTop(); var dropdownPosition = $(token_list).offset().top + $(token_list).outerHeight(); var availableSpace = windowHeight - (dropdownPosition - docViewTop) var borderWidth = parseInt(dropdown.css('border-bottom-width')); if (availableSpace &gt;= (settings.maxHeight + 2 * borderWidth)) { dropdown.css('bottom', ''); $('body').css('position', ''); dropdown.css({ 'border-top-width': 0, left: $(token_list).offset().left, top: $(token_list).offset().top + $(token_list).outerHeight() }); } else { dropdown.css('top', ''); var bodyHeight = $('body').outerHeight(); var bodyTop = $('body').offset().top; var bottom; if ((bodyHeight + bodyTop) &lt; dropdownPosition) { bottom = dropdownPosition - (bodyTop + bodyHeight) ; } else { bottom = (bodyTop + bodyHeight) - ($(token_list).offset().top + borderWidth); } dropdown.css({ 'border-top-width': borderWidth, 'border-top-color': dropdown.css('border-bottom-color'), 'border-top-style': dropdown.css('border-bottom-style'), 'bottom': bottom, 'left': $(token_list).offset().left - parseInt($('body').css('margin-left')), 'position': 'absolute' }); $('body').css({ 'position': 'relative' }); } dropdown.css({ maxHeight: settings.maxHeight, overflow: 'auto', zIndex: settings.zIndex }).show(); } } </code></pre> <p>I've also added a <code>maxHeight</code> property to tokenInput and use it to both check for space and set the size of the dropdown.</p> <p>Try it out here: <a href="http://jsfiddle.net/colin_young/dvuHD/19/" rel="nofollow">http://jsfiddle.net/colin_young/dvuHD/19/</a> (note that my version has some significant modifications from the stock version, I just haven't had a chance to create pull-requests for them).</p> <p>No attempt is made to ensure there is space above however. The assumption is that if there is no space below and none above there isn't a lot you can do, although centering on the input element might be a good compromise.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload