dist/toolkit.js
function(items) {
        if (!this.term.length || !items.length) {
            this.hide();
            return;
        }

        var options = this.options,
            term = this.term,
            categories = { _empty_: [] },
            item,
            list = $('<ul/>');

        // Reset
        this.items = [];
        this.index = -1;

        // Sort and match the list of items
        if ($.type(options.sorter) === 'function') {
            items = options.sorter(items);
        }

        if ($.type(options.matcher) === 'function') {
            items = items.filter(function(item) {
                return options.matcher(item, term);
            });
        }

        // Group the items into categories
        for (var i = 0; item = items[i]; i++) {
            if (item.category) {
                if (!categories[item.category]) {
                    categories[item.category] = [];
                }

                categories[item.category].push(item);
            } else {
                categories._empty_.push(item);
            }
        }

        // Loop through the items and build the markup
        var results = [],
            count = 0;

        $.each(categories, function(category, items) {
            var elements = [];

            if (category !== '_empty_') {
                results.push(null);

                elements.push(
                    this.render(options.headingTemplate).append( $('<span/>', { text: category }) )
                );
            }

            for (var i = 0, a; item = items[i]; i++) {
                if (count >= options.itemLimit) {
                    break;
                }

                a = options.builder(item);
                a.on({
                    mouseover: this.rewind.bind(this),
                    click: $.proxy(this.onSelect, this, results.length)
                });

                elements.push( $('<li/>').append(a) );
                results.push(item);
                count++;
            }

            list.append(elements);
        }.bind(this));

        // Append list
        this.element.empty().append(list);

        // Set the current result set to the items list
        // This will be used for index cycling
        this.items = results;

        // Cache the result set to the term
        // Filter out null categories so that we can re-use the cache
        this.cache[term.toLowerCase()] = results.filter(function(item) {
            return (item !== null);
        });

        this.fireEvent('load');

        // Apply the shadow text
        this._shadow();

        // Position the list
        this.position();
    }
function(items) {
        if (!this.term.length || !items.length) {
            this.hide();
            return;
        }

        var options = this.options,
            term = this.term,
            categories = { _empty_: [] },
            item,
            list = $('<ul/>');

        // Reset
        this.items = [];
        this.index = -1;

        // Sort and match the list of items
        if ($.type(options.sorter) === 'function') {
            items = options.sorter(items);
        }

        if ($.type(options.matcher) === 'function') {
            items = items.filter(function(item) {
                return options.matcher(item, term);
            });
        }

        // Group the items into categories
        for (var i = 0; item = items[i]; i++) {
            if (item.category) {
                if (!categories[item.category]) {
                    categories[item.category] = [];
                }

                categories[item.category].push(item);
            } else {
                categories._empty_.push(item);
            }
        }

        // Loop through the items and build the markup
        var results = [],
            count = 0;

        $.each(categories, function(category, items) {
            var elements = [];

            if (category !== '_empty_') {
                results.push(null);

                elements.push(
                    this.render(options.headingTemplate).append( $('<span/>', { text: category }) )
                );
            }

            for (var i = 0, a; item = items[i]; i++) {
                if (count >= options.itemLimit) {
                    break;
                }

                a = options.builder(item);
                a.on({
                    mouseover: this.rewind.bind(this),
                    click: $.proxy(this.onSelect, this, results.length)
                });

                elements.push( $('<li/>').append(a) );
                results.push(item);
                count++;
            }

            list.append(elements);
        }.bind(this));

        // Append list
        this.element.empty().append(list);

        // Set the current result set to the items list
        // This will be used for index cycling
        this.items = results;

        // Cache the result set to the term
        // Filter out null categories so that we can re-use the cache
        this.cache[term.toLowerCase()] = results.filter(function(item) {
            return (item !== null);
        });

        this.fireEvent('load');

        // Apply the shadow text
        this._shadow();

        // Position the list
        this.position();
    }
function ( items ) { if ( ! this . term . length || ! items . length ) { this . hide ( ) ; return ; } var options = this . options , term = this . term , categories = { _empty_ : [ ] } , item , list = $ ( '<ul/>' ) ; // Reset this . items = [ ] ; this . index = - 1 ; // Sort and match the list of items if ( $ . type ( options . sorter ) === 'function' ) { items = options . sorter ( items ) ; } if ( $ . type ( options . matcher ) === 'function' ) { items = items . filter ( function ( item ) { return options . matcher ( item , term ) ; } ) ; } // Group the items into categories for ( var i = 0 ; item = items [ i ] ; i ++ ) { if ( item . category ) { if ( ! categories [ item . category ] ) { categories [ item . category ] = [ ] ; } categories [ item . category ] . push ( item ) ; } else { categories . _empty_ . push ( item ) ; } } // Loop through the items and build the markup var results = [ ] , count = 0 ; $ . each ( categories , function ( category , items ) { var elements = [ ] ; if ( category !== '_empty_' ) { results . push ( null ) ; elements . push ( this . render ( options . headingTemplate ) . append ( $ ( '<span/>' , { text : category } ) ) ) ; } for ( var i = 0 , a ; item = items [ i ] ; i ++ ) { if ( count >= options . itemLimit ) { break ; } a = options . builder ( item ) ; a . on ( { mouseover : this . rewind . bind ( this ) , click : $ . proxy ( this . onSelect , this , results . length ) } ) ; elements . push ( $ ( '<li/>' ) . append ( a ) ) ; results . push ( item ) ; count ++ ; } list . append ( elements ) ; } . bind ( this ) ) ; // Append list this . element . empty ( ) . append ( list ) ; // Set the current result set to the items list // This will be used for index cycling this . items = results ; // Cache the result set to the term // Filter out null categories so that we can re-use the cache this . cache [ term . toLowerCase ( ) ] = results . filter ( function ( item ) { return ( item !== null ) ; } ) ; this . fireEvent ( 'load' ) ; // Apply the shadow text this . _shadow ( ) ; // Position the list this . position ( ) ; }
Process the list of items be generating new elements and positioning below the input.

@param {Array} items
Process the list of items be generating new elements and positioning below the input .