src/inputs/single.js
function SingleInput(options) {
    Selectivity.call(
        this,
        assign(
            {
                // Dropdowns for single-value inputs should open below the select box, unless there
                // is not enough space below, in which case the dropdown should be moved up just
                // enough so it fits in the window, but never so much that it reaches above the top.
                positionDropdown: function(el, selectEl) {
                    var rect = selectEl.getBoundingClientRect();
                    var dropdownTop = rect.bottom;

                    var deltaUp = Math.min(
                        Math.max(dropdownTop + el.clientHeight - window.innerHeight, 0),
                        rect.top + rect.height
                    );

                    assign(el.style, {
                        left: rect.left + 'px',
                        top: dropdownTop - deltaUp + 'px',
                        width: rect.width + 'px'
                    });
                }
            },
            options
        )
    );

    this.rerender();

    if (options.showSearchInputInDropdown === false) {
        this.initInput(this.$('.selectivity-single-select-input'), { search: false });
    }

    this.events.on({
        change: this.rerenderSelection,
        click: this._clicked,
        'click .selectivity-search-input': stopPropagation,
        'click .selectivity-single-selected-item-remove': this._itemRemoveClicked,
        'focus .selectivity-single-select-input': this._focused,
        'selectivity-selected': this._resultSelected
    });
}
function SingleInput(options) {
    Selectivity.call(
        this,
        assign(
            {
                // Dropdowns for single-value inputs should open below the select box, unless there
                // is not enough space below, in which case the dropdown should be moved up just
                // enough so it fits in the window, but never so much that it reaches above the top.
                positionDropdown: function(el, selectEl) {
                    var rect = selectEl.getBoundingClientRect();
                    var dropdownTop = rect.bottom;

                    var deltaUp = Math.min(
                        Math.max(dropdownTop + el.clientHeight - window.innerHeight, 0),
                        rect.top + rect.height
                    );

                    assign(el.style, {
                        left: rect.left + 'px',
                        top: dropdownTop - deltaUp + 'px',
                        width: rect.width + 'px'
                    });
                }
            },
            options
        )
    );

    this.rerender();

    if (options.showSearchInputInDropdown === false) {
        this.initInput(this.$('.selectivity-single-select-input'), { search: false });
    }

    this.events.on({
        change: this.rerenderSelection,
        click: this._clicked,
        'click .selectivity-search-input': stopPropagation,
        'click .selectivity-single-selected-item-remove': this._itemRemoveClicked,
        'focus .selectivity-single-select-input': this._focused,
        'selectivity-selected': this._resultSelected
    });
}
function SingleInput ( options ) { Selectivity . call ( this , assign ( { // Dropdowns for single-value inputs should open below the select box, unless there // is not enough space below, in which case the dropdown should be moved up just // enough so it fits in the window, but never so much that it reaches above the top. positionDropdown : function ( el , selectEl ) { var rect = selectEl . getBoundingClientRect ( ) ; var dropdownTop = rect . bottom ; var deltaUp = Math . min ( Math . max ( dropdownTop + el . clientHeight - window . innerHeight , 0 ) , rect . top + rect . height ) ; assign ( el . style , { left : rect . left + 'px' , top : dropdownTop - deltaUp + 'px' , width : rect . width + 'px' } ) ; } } , options ) ) ; this . rerender ( ) ; if ( options . showSearchInputInDropdown === false ) { this . initInput ( this . $ ( '.selectivity-single-select-input' ) , { search : false } ) ; } this . events . on ( { change : this . rerenderSelection , click : this . _clicked , 'click .selectivity-search-input' : stopPropagation , 'click .selectivity-single-selected-item-remove' : this . _itemRemoveClicked , 'focus .selectivity-single-select-input' : this . _focused , 'selectivity-selected' : this . _resultSelected } ) ; }
SingleInput Constructor.
SingleInput Constructor .