src/dropdown.js
function SelectivityDropdown(selectivity, options) {
    this.el = parseElement(
        selectivity.template('dropdown', {
            dropdownCssClass: selectivity.options.dropdownCssClass,
            searchInputPlaceholder: selectivity.options.searchInputPlaceholder,
            showSearchInput: options.showSearchInput
        })
    );

    /**
     * DOM element to add the results to.
     */
    this.resultsContainer = this.$('.selectivity-results-container');

    /**
     * Boolean indicating whether more results are available than currently displayed in the
     * dropdown.
     */
    this.hasMore = false;

    /**
     * The currently highlighted result item.
     */
    this.highlightedResult = null;

    /**
     * Boolean whether the load more link is currently highlighted.
     */
    this.loadMoreHighlighted = false;

    /**
     * Options passed to the dropdown constructor.
     */
    this.options = options;

    /**
     * The results displayed in the dropdown.
     */
    this.results = [];

    /**
     * Selectivity instance.
     */
    this.selectivity = selectivity;

    this._closed = false;
    this._lastMousePosition = {};

    this.close = this.close.bind(this);
    this.position = this.position.bind(this);

    if (selectivity.options.closeOnSelect !== false) {
        selectivity.events.on('selectivity-selecting', this.close);
    }

    this.addToDom();
    this.showLoading();

    if (options.showSearchInput) {
        selectivity.initInput(this.$('.selectivity-search-input'));
        selectivity.focus();
    }

    var events = {};
    events['click ' + LOAD_MORE_SELECTOR] = this._loadMoreClicked;
    events['click ' + RESULT_ITEM_SELECTOR] = this._resultClicked;
    events['mouseenter ' + LOAD_MORE_SELECTOR] = this._loadMoreHovered;
    events['mouseenter ' + RESULT_ITEM_SELECTOR] = this._resultHovered;

    this.events = new EventListener(this.el, this);
    this.events.on(events);

    this._attachScrollListeners();
    this._suppressWheel();

    setTimeout(this.triggerOpen.bind(this), 1);
}
function SelectivityDropdown(selectivity, options) {
    this.el = parseElement(
        selectivity.template('dropdown', {
            dropdownCssClass: selectivity.options.dropdownCssClass,
            searchInputPlaceholder: selectivity.options.searchInputPlaceholder,
            showSearchInput: options.showSearchInput
        })
    );

    /**
     * DOM element to add the results to.
     */
    this.resultsContainer = this.$('.selectivity-results-container');

    /**
     * Boolean indicating whether more results are available than currently displayed in the
     * dropdown.
     */
    this.hasMore = false;

    /**
     * The currently highlighted result item.
     */
    this.highlightedResult = null;

    /**
     * Boolean whether the load more link is currently highlighted.
     */
    this.loadMoreHighlighted = false;

    /**
     * Options passed to the dropdown constructor.
     */
    this.options = options;

    /**
     * The results displayed in the dropdown.
     */
    this.results = [];

    /**
     * Selectivity instance.
     */
    this.selectivity = selectivity;

    this._closed = false;
    this._lastMousePosition = {};

    this.close = this.close.bind(this);
    this.position = this.position.bind(this);

    if (selectivity.options.closeOnSelect !== false) {
        selectivity.events.on('selectivity-selecting', this.close);
    }

    this.addToDom();
    this.showLoading();

    if (options.showSearchInput) {
        selectivity.initInput(this.$('.selectivity-search-input'));
        selectivity.focus();
    }

    var events = {};
    events['click ' + LOAD_MORE_SELECTOR] = this._loadMoreClicked;
    events['click ' + RESULT_ITEM_SELECTOR] = this._resultClicked;
    events['mouseenter ' + LOAD_MORE_SELECTOR] = this._loadMoreHovered;
    events['mouseenter ' + RESULT_ITEM_SELECTOR] = this._resultHovered;

    this.events = new EventListener(this.el, this);
    this.events.on(events);

    this._attachScrollListeners();
    this._suppressWheel();

    setTimeout(this.triggerOpen.bind(this), 1);
}
function SelectivityDropdown ( selectivity , options ) { this . el = parseElement ( selectivity . template ( 'dropdown' , { dropdownCssClass : selectivity . options . dropdownCssClass , searchInputPlaceholder : selectivity . options . searchInputPlaceholder , showSearchInput : options . showSearchInput } ) ) ; /**
     * DOM element to add the results to.
     */ this . resultsContainer = this . $ ( '.selectivity-results-container' ) ; /**
     * Boolean indicating whether more results are available than currently displayed in the
     * dropdown.
     */ this . hasMore = false ; /**
     * The currently highlighted result item.
     */ this . highlightedResult = null ; /**
     * Boolean whether the load more link is currently highlighted.
     */ this . loadMoreHighlighted = false ; /**
     * Options passed to the dropdown constructor.
     */ this . options = options ; /**
     * The results displayed in the dropdown.
     */ this . results = [ ] ; /**
     * Selectivity instance.
     */ this . selectivity = selectivity ; this . _closed = false ; this . _lastMousePosition = { } ; this . close = this . close . bind ( this ) ; this . position = this . position . bind ( this ) ; if ( selectivity . options . closeOnSelect !== false ) { selectivity . events . on ( 'selectivity-selecting' , this . close ) ; } this . addToDom ( ) ; this . showLoading ( ) ; if ( options . showSearchInput ) { selectivity . initInput ( this . $ ( '.selectivity-search-input' ) ) ; selectivity . focus ( ) ; } var events = { } ; events [ 'click ' + LOAD_MORE_SELECTOR ] = this . _loadMoreClicked ; events [ 'click ' + RESULT_ITEM_SELECTOR ] = this . _resultClicked ; events [ 'mouseenter ' + LOAD_MORE_SELECTOR ] = this . _loadMoreHovered ; events [ 'mouseenter ' + RESULT_ITEM_SELECTOR ] = this . _resultHovered ; this . events = new EventListener ( this . el , this ) ; this . events . on ( events ) ; this . _attachScrollListeners ( ) ; this . _suppressWheel ( ) ; setTimeout ( this . triggerOpen . bind ( this ) , 1 ) ; }
Selectivity Dropdown Constructor.

@param selectivity Selectivity instance to which the dropdown belongs.
@param options Options object. Should have the following properties:
highlightFirstItem - Set to false if you don't want the first item to be
automatically highlighted (optional).
items - Array of items to display.
position - Callback for positioning the dropdown.
query - Callback to fetch the items to display.
showSearchInput - Boolean whether a search input should be shown.
Selectivity Dropdown Constructor .