// maximize-select2-height v1.0.2 // (c) Panorama Education 2015 // MIT License // https://github.com/panorama-ed/maximize-select2-height // This jQuery/Select2 plugin expands a Select2 dropdown to take up as much // height as possible given its position on the page and the current viewport // size. The plugin correctly handles: // - Dynamic window resizing. // - The effects of scroll bars on the viewport. // - Select2 rendering dropdowns both upwards and downwards. // NOTE: The original ) (function ($) { "use strict"; // We can find these elements now, since the properties we check on them are // all via methods that are recalculated each time. var $window = $(window); var $document = $(document); // @param {Object} options The options object passed in when this plugin is // initialized // @param {Boolean} dropdownDownwards True iff the dropdown is rendered // downwards (Select2 sometimes renders the options upwards to better fit on // a page) // @return {Object} The options passed in, combined with defaults. Keys are: // - cushion: The number of pixels between the edge of the dropdown and the // edge of the viewable window. [Default: 10, except when a // horizontal scroll bar would interfere, in which case it's 30.] // NOTE: If a value is passed in, no adjustments for possible // scroll bars are made. var settings = function (options, dropdownDownwards) { return $.extend({ cushion: ( dropdownDownwards && $document.width() > $window.width() ) ? 30 : 10 }, options); }; // @param {String} id The DOM element ID for the original