function() {
            var $dropdown = this.dropdown,
                offset = this.container.offset(),
                height = this.container.outerHeight(false),
                width = this.container.outerWidth(false),
                dropHeight = $dropdown.outerHeight(false),
                viewPortRight = $(window).scrollLeft() + $(window).width(),
                viewportBottom = $(window).scrollTop() + $(window).height(),
                dropTop = offset.top + height,
                dropLeft = offset.left,
                enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
                enoughRoomAbove = (offset.top - dropHeight) >= this.body().scrollTop(),
                dropWidth = $dropdown.outerWidth(false),
                enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight,
                aboveNow = $dropdown.hasClass("select2-drop-above"),
                bodyOffset,
                above,
                css,
                resultsListNode;

            if (this.opts.dropdownAutoWidth) {
                resultsListNode = $('.select2-results', $dropdown)[0];
                $dropdown.addClass('select2-drop-auto-width');
                $dropdown.css('width', '');
                // Add scrollbar width to dropdown if vertical scrollbar is present
                dropWidth = $dropdown.outerWidth(false) + (resultsListNode.scrollHeight === resultsListNode.clientHeight ? 0 : scrollBarDimensions.width);
                dropWidth > width ? width = dropWidth : dropWidth = width;
                enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight;
            }
            else {
                this.container.removeClass('select2-drop-auto-width');
            }

            //console.log("below/ droptop:", dropTop, "dropHeight", dropHeight, "sum", (dropTop+dropHeight)+" viewport bottom", viewportBottom, "enough?", enoughRoomBelow);
            //console.log("above/ offset.top", offset.top, "dropHeight", dropHeight, "top", (offset.top-dropHeight), "scrollTop", this.body().scrollTop(), "enough?", enoughRoomAbove);

            // fix positioning when body has an offset and is not position: static
            if (this.body().css('position') !== 'static') {
                bodyOffset = this.body().offset();
                dropTop -= bodyOffset.top;
                dropLeft -= bodyOffset.left;
            }

            // always prefer the current above/below alignment, unless there is not enough room
            if (aboveNow) {
                above = true;
                if (!enoughRoomAbove && enoughRoomBelow) above = false;
            } else {
                above = false;
                if (!enoughRoomBelow && enoughRoomAbove) above = true;
            }

            if (!enoughRoomOnRight) {
               dropLeft = offset.left + width - dropWidth;
            }

            if (above) {
                dropTop = offset.top - dropHeight;
                this.container.addClass("select2-drop-above");
                $dropdown.addClass("select2-drop-above");
            }
            else {
                this.container.removeClass("select2-drop-above");
                $dropdown.removeClass("select2-drop-above");
            }

            css = $.extend({
                top: dropTop,
                left: dropLeft,
                width: width
            }, evaluate(this.opts.dropdownCss));

            $dropdown.css(css);
        }
function() {
            var $dropdown = this.dropdown,
                offset = this.container.offset(),
                height = this.container.outerHeight(false),
                width = this.container.outerWidth(false),
                dropHeight = $dropdown.outerHeight(false),
                viewPortRight = $(window).scrollLeft() + $(window).width(),
                viewportBottom = $(window).scrollTop() + $(window).height(),
                dropTop = offset.top + height,
                dropLeft = offset.left,
                enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
                enoughRoomAbove = (offset.top - dropHeight) >= this.body().scrollTop(),
                dropWidth = $dropdown.outerWidth(false),
                enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight,
                aboveNow = $dropdown.hasClass("select2-drop-above"),
                bodyOffset,
                above,
                css,
                resultsListNode;

            if (this.opts.dropdownAutoWidth) {
                resultsListNode = $('.select2-results', $dropdown)[0];
                $dropdown.addClass('select2-drop-auto-width');
                $dropdown.css('width', '');
                
                dropWidth = $dropdown.outerWidth(false) + (resultsListNode.scrollHeight === resultsListNode.clientHeight ? 0 : scrollBarDimensions.width);
                dropWidth > width ? width = dropWidth : dropWidth = width;
                enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight;
            }
            else {
                this.container.removeClass('select2-drop-auto-width');
            }

            
            

            
            if (this.body().css('position') !== 'static') {
                bodyOffset = this.body().offset();
                dropTop -= bodyOffset.top;
                dropLeft -= bodyOffset.left;
            }

            
            if (aboveNow) {
                above = true;
                if (!enoughRoomAbove && enoughRoomBelow) above = false;
            } else {
                above = false;
                if (!enoughRoomBelow && enoughRoomAbove) above = true;
            }

            if (!enoughRoomOnRight) {
               dropLeft = offset.left + width - dropWidth;
            }

            if (above) {
                dropTop = offset.top - dropHeight;
                this.container.addClass("select2-drop-above");
                $dropdown.addClass("select2-drop-above");
            }
            else {
                this.container.removeClass("select2-drop-above");
                $dropdown.removeClass("select2-drop-above");
            }

            css = $.extend({
                top: dropTop,
                left: dropLeft,
                width: width
            }, evaluate(this.opts.dropdownCss));

            $dropdown.css(css);
        }
function ( ) { var $dropdown = this . dropdown , offset = this . container . offset ( ) , height = this . container . outerHeight ( false ) , width = this . container . outerWidth ( false ) , dropHeight = $dropdown . outerHeight ( false ) , viewPortRight = $ ( window ) . scrollLeft ( ) + $ ( window ) . width ( ) , viewportBottom = $ ( window ) . scrollTop ( ) + $ ( window ) . height ( ) , dropTop = offset . top + height , dropLeft = offset . left , enoughRoomBelow = dropTop + dropHeight <= viewportBottom , enoughRoomAbove = ( offset . top - dropHeight ) >= this . body ( ) . scrollTop ( ) , dropWidth = $dropdown . outerWidth ( false ) , enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight , aboveNow = $dropdown . hasClass ( "select2-drop-above" ) , bodyOffset , above , css , resultsListNode ; if ( this . opts . dropdownAutoWidth ) { resultsListNode = $ ( '.select2-results' , $dropdown ) [ 0 ] ; $dropdown . addClass ( 'select2-drop-auto-width' ) ; $dropdown . css ( 'width' , '' ) ; // Add scrollbar width to dropdown if vertical scrollbar is present dropWidth = $dropdown . outerWidth ( false ) + ( resultsListNode . scrollHeight === resultsListNode . clientHeight ? 0 : scrollBarDimensions . width ) ; dropWidth > width ? width = dropWidth : dropWidth = width ; enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight ; } else { this . container . removeClass ( 'select2-drop-auto-width' ) ; } //console.log("below/ droptop:", dropTop, "dropHeight", dropHeight, "sum", (dropTop+dropHeight)+" viewport bottom", viewportBottom, "enough?", enoughRoomBelow); //console.log("above/ offset.top", offset.top, "dropHeight", dropHeight, "top", (offset.top-dropHeight), "scrollTop", this.body().scrollTop(), "enough?", enoughRoomAbove); // fix positioning when body has an offset and is not position: static if ( this . body ( ) . css ( 'position' ) !== 'static' ) { bodyOffset = this . body ( ) . offset ( ) ; dropTop -= bodyOffset . top ; dropLeft -= bodyOffset . left ; } // always prefer the current above/below alignment, unless there is not enough room if ( aboveNow ) { above = true ; if ( ! enoughRoomAbove && enoughRoomBelow ) above = false ; } else { above = false ; if ( ! enoughRoomBelow && enoughRoomAbove ) above = true ; } if ( ! enoughRoomOnRight ) { dropLeft = offset . left + width - dropWidth ; } if ( above ) { dropTop = offset . top - dropHeight ; this . container . addClass ( "select2-drop-above" ) ; $dropdown . addClass ( "select2-drop-above" ) ; } else { this . container . removeClass ( "select2-drop-above" ) ; $dropdown . removeClass ( "select2-drop-above" ) ; } css = $ . extend ( { top : dropTop , left : dropLeft , width : width } , evaluate ( this . opts . dropdownCss ) ) ; $dropdown . css ( css ) ; }
abstract
abstract