"use strict";
(function ($) {
    $.field_tags = function (element, options) {
        var defaults = {
            tags: [],
            tags_selected: []
        }
        var plugin = this;
        plugin.settings = {}
        var $element = $(element), 
            element = element;
        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            
            $element.find('select.list-tags').select2({tags:true});
            $element.find('select.list-tags').val(plugin.settings.tags_selected).trigger('change');

        };
        plugin.example_function = function () {
        };
        plugin.init();
    }
    
    $.fn.field_tags = function (options) {
        
        return this.each(function () {
            
            if (undefined == $(this).data('field_tags')) {
                var plugin = new $.field_tags(this, options);
                $(this).data('field_tags', plugin);
            }
        });
    }
})(jQuery);
