/**
 * Handling of tags input fields.
 *
 * @mixin
 * @namespace Bolt.fields.tags
 *
 * @param {Object} bolt - The Bolt module.
 * @param {Object} $ - jQuery.
 */
(function (bolt, $) {

    /**
     * Bolt.fields.tags mixin container.
     *
     * @private
     * @type {Object}
     */
    var tags = {};

    /**
     * Bind tags field.
     *
     * @static
     * @function init
     * @memberof Bolt.fields.tags
     *
     * @param {Object} fieldset
     * @param {FieldConf} fconf
     */
    tags.init = function (fieldset, fconf) {
        var slug = fconf.slug,
            taxonomy = $(fieldset).find('select'),
            tagcloud = $(fieldset).find('div.tagcloud'),
            initSelect = function (tags) {
                taxonomy.select2({
                    width: '100%',
                    tags: tags,
                    minimumInputLength: 1,
                    tokenSeparators: [',', ' ']
                });
            };

        // Load all tags.
        $.ajax({
            url: bolt.conf('paths.root') + 'async/tags/' + slug,
            dataType: 'json',
            success: function (data) {
                var results = [];

                $.each(data, function (index, item) {
                    results.push( item.slug );
                });

                initSelect(results);
            },
            error: function () {
                initSelect([]);
            }
        });

        // Popular tags.
        if (tagcloud) {
            $.ajax({
                url: bolt.conf('paths.root') + 'async/populartags/' + slug,
                dataType: 'json',
                data : {
                    limit: 40
                },
                success: function(data) {
                    if (data.length > 0) {
                        $.each(data, function(index, item){
                            tagcloud.append('<a href="#" rel="' + item.count + '">' + item.slug + '</a>');
                        });

                        tagcloud.find('a').on('click', function (e) {
                            var data;

                            e.preventDefault();
                            data = taxonomy.select2('data');
                            data.push({
                                id: $(this).text(),
                                text: $(this).text()
                            });
                            taxonomy.select2('data', data);
                        });

                        $.fn.tagcloud.defaults = {
                            size: {
                                start: 12,
                                end: 22,
                                unit: 'px'
                            },
                            color: {
                                start: '#888',
                                end: '#194770'
                            }
                        };
                        tagcloud.find('a').tagcloud();
                    }
                }
            });
        }
    };

    // Apply mixin container
    bolt.fields.tags = tags;

})(Bolt || {}, jQuery);

@@ -819,16 +819,54 @@
 : tags,%0A
+                    allowClear: true,%0A
         

Add clear button