harvesthq/chosen — pull request #1330 by MattDease (2013-07-04 21:26:50+00:00)
Title: Add viewport edge detection to results dropdown

Fixes harvesthq/chosen#155

Ensure dropdowns are always visible in the viewport by checking if they would drop below the window's bottom edge and positioning them above the input if that is the case.
This code is based off the snippets by @coreyworrell

This addition is especially important when a select input is positioned near the bottom of the page where the user can't scroll anymore - without this addition the list of options is nearly unusable as the list of options is cut off.