app/assets/javascripts/fae/form/fae_chosen.js in fae-rails-1.4.0 vs app/assets/javascripts/fae/form/fae_chosen.js in fae-rails-1.4.1
- old
+ new
@@ -19,9 +19,25 @@
if ($this.hasClass('select-search')) {
settings.disable_search_threshold = 0;
}
$this.chosen(settings);
+
+ // add handling for bottom of viewport / drop-up support
+ $this.on('chosen:showing_dropdown', function(event, params) {
+ var $chosen_container = $(event.target ).next('.chosen-container');
+ var $dropdown = $chosen_container.find('.chosen-drop');
+ var results_container_max_height = parseInt($dropdown.find('.chosen-results').css('max-height'));
+ var results_container_top_offset = 40; // to account for possibility of chosen search input
+ var dropdown_top = $dropdown.offset().top - FCH.$window.scrollTop();
+
+ if (dropdown_top + results_container_max_height + results_container_top_offset > FCH.dimensions.wh) {
+ $chosen_container.addClass('chosen-drop-up');
+ }
+ });
+ $this.on('chosen:hiding_dropdown', function(event, params) {
+ $(event.target).next('.chosen-container').removeClass('chosen-drop-up');
+ });
});
};
}( jQuery ));