Sha256: 362e50e04800da5e74681e648292d2a394382c3b9edb39cca9603577eda67ee8

Contents?: true

Size: 1.33 KB

Versions: 63

Compression:

Stored size: 1.33 KB

Contents

/**
 * @external jQuery
 */

/**
 * @method
 * @name categorizedAutocomplete
 * @memberof external:jQuery
 */
$.widget('workarea.categorizedAutocomplete', $.ui.autocomplete, {
    _create: function () {
        'use strict';

        this._super();

        this.widget().menu(
            'option', 'items', '> :not(.ui-menu-heading)'
        );
    },

    _renderItem: function ($ul, item) {
        'use strict';

        var itemTemplate = JST['workarea/storefront/templates/ui_menu_item'];

        return $(itemTemplate({ label: item.label, image: item.image })).appendTo($ul);
    },

    _renderMenu: function ($ul, items) {
        'use strict';

        var widget = this,
            categories = _.uniq(_.map(items, 'type')),
            itemsByCategory = _.groupBy(items, 'type'),
            categoryHeaderTemplate = JST['workarea/storefront/templates/ui_menu_heading'],

            renderCategoryItem = function (item) {
                widget._renderItemData($ul, item);
            },

            renderCategory = function (category) {
                $ul.append(categoryHeaderTemplate({
                    categoryName: category
                }));

                _.forEach(
                    itemsByCategory[category], renderCategoryItem
                );
            };

        _.forEach(categories, renderCategory);
    }
});

Version data entries

63 entries across 63 versions & 2 rubygems

Version Path
workarea-storefront-3.5.27 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.5.26 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.4.45 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.5.25 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.5.23 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.4.44 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.5.22 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.4.43 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.5.21 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.4.42 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.5.20 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.4.41 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.5.19 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.4.40 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.5.18 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.4.39 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.5.17 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.4.38 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.5.16 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js
workarea-storefront-3.4.37 app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js