src/selectivity.js
function Selectivity(options) {
    /**
     * Reference to the currently open dropdown.
     */
    this.dropdown = null;

    /**
     * DOM element to which this instance is attached.
     */
    this.el = options.element;

    /**
     * Whether the input is enabled.
     *
     * This is false when the option readOnly is false or the option removeOnly is false.
     */
    this.enabled = !options.readOnly && !options.removeOnly;

    /**
     * DOM element for the input.
     *
     * May be null as long as there is no visible input. It is set by initInput().
     */
    this.input = null;

    /**
     * Array of items from which to select. If set, this will be an array of objects with 'id' and
     * 'text' properties.
     *
     * If given, all items are expected to be available locally and all selection operations operate
     * on this local array only. If null, items are not available locally, and a query function
     * should be provided to fetch remote data.
     */
    this.items = null;

    /**
     * Options passed to the Selectivity instance or set through setOptions().
     */
    this.options = {};

    /**
     * Mapping of templates.
     *
     * Custom templates can be specified in the options object.
     */
    this.templates = assign({}, Selectivity.Templates);

    /**
     * The last used search term.
     */
    this.term = '';

    this.setOptions(options);

    if (options.value) {
        this.setValue(options.value, { triggerChange: false });
    } else {
        this.setData(options.data || null, { triggerChange: false });
    }

    this.el.setAttribute('tabindex', options.tabIndex || 0);

    this.events = new EventListener(this.el, this);
    this.events.on({
        blur: this._blur,
        mouseenter: this._mouseenter,
        mouseleave: this._mouseleave,
        'selectivity-close': this._closed
    });
}
function Selectivity(options) {
    /**
     * Reference to the currently open dropdown.
     */
    this.dropdown = null;

    /**
     * DOM element to which this instance is attached.
     */
    this.el = options.element;

    /**
     * Whether the input is enabled.
     *
     * This is false when the option readOnly is false or the option removeOnly is false.
     */
    this.enabled = !options.readOnly && !options.removeOnly;

    /**
     * DOM element for the input.
     *
     * May be null as long as there is no visible input. It is set by initInput().
     */
    this.input = null;

    /**
     * Array of items from which to select. If set, this will be an array of objects with 'id' and
     * 'text' properties.
     *
     * If given, all items are expected to be available locally and all selection operations operate
     * on this local array only. If null, items are not available locally, and a query function
     * should be provided to fetch remote data.
     */
    this.items = null;

    /**
     * Options passed to the Selectivity instance or set through setOptions().
     */
    this.options = {};

    /**
     * Mapping of templates.
     *
     * Custom templates can be specified in the options object.
     */
    this.templates = assign({}, Selectivity.Templates);

    /**
     * The last used search term.
     */
    this.term = '';

    this.setOptions(options);

    if (options.value) {
        this.setValue(options.value, { triggerChange: false });
    } else {
        this.setData(options.data || null, { triggerChange: false });
    }

    this.el.setAttribute('tabindex', options.tabIndex || 0);

    this.events = new EventListener(this.el, this);
    this.events.on({
        blur: this._blur,
        mouseenter: this._mouseenter,
        mouseleave: this._mouseleave,
        'selectivity-close': this._closed
    });
}
function Selectivity ( options ) { /**
     * Reference to the currently open dropdown.
     */ this . dropdown = null ; /**
     * DOM element to which this instance is attached.
     */ this . el = options . element ; /**
     * Whether the input is enabled.
     *
     * This is false when the option readOnly is false or the option removeOnly is false.
     */ this . enabled = ! options . readOnly && ! options . removeOnly ; /**
     * DOM element for the input.
     *
     * May be null as long as there is no visible input. It is set by initInput().
     */ this . input = null ; /**
     * Array of items from which to select. If set, this will be an array of objects with 'id' and
     * 'text' properties.
     *
     * If given, all items are expected to be available locally and all selection operations operate
     * on this local array only. If null, items are not available locally, and a query function
     * should be provided to fetch remote data.
     */ this . items = null ; /**
     * Options passed to the Selectivity instance or set through setOptions().
     */ this . options = { } ; /**
     * Mapping of templates.
     *
     * Custom templates can be specified in the options object.
     */ this . templates = assign ( { } , Selectivity . Templates ) ; /**
     * The last used search term.
     */ this . term = '' ; this . setOptions ( options ) ; if ( options . value ) { this . setValue ( options . value , { triggerChange : false } ) ; } else { this . setData ( options . data || null , { triggerChange : false } ) ; } this . el . setAttribute ( 'tabindex' , options . tabIndex || 0 ) ; this . events = new EventListener ( this . el , this ) ; this . events . on ( { blur : this . _blur , mouseenter : this . _mouseenter , mouseleave : this . _mouseleave , 'selectivity-close' : this . _closed } ) ; }
Selectivity Base Constructor.

You will never use this constructor directly. Instead, you use $(selector).selectivity(options)
to create an instance of either MultipleSelectivity or SingleSelectivity. This class defines all
functionality that is common between both.

@param options Options object. Accepts the same options as the setOptions method(), in addition
to the following ones:
data - Initial selection data to set. This should be an array of objects with 'id'
and 'text' properties. This option is mutually exclusive with 'value'.
element - The DOM element to which to attach the Selectivity instance. This
property is set by the API wrapper.
value - Initial value to set. This should be an array of IDs. This property is
mutually exclusive with 'data'.
Selectivity Base Constructor .