(function ($) {
    $.field_employeeimage = function (element, options) {
        var defaults = {
            field_name: 0
        }
        var plugin = this;
        plugin.settings = {}
        var $element = $(element),
            element = element;

        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            let field_name = plugin.settings.field_name;
            $element.find('.wrapper-employee').click(function (e) {
                let $self = $(this);
                $element.find('.wrapper-employee .selected').hide();
                let employee_id = $self.data('employee_id');
                $self.find('.selected').show();
                $element.find(`input[name="${field_name}"]`).val(employee_id);
            });
        };
        plugin.getValue = function () {
            let field_name = plugin.settings.field_name;
            return $element.find(`input[name="${field_name}"]`).val();
        };
        plugin.example_function = function () {
        };
        plugin.init();
    }

    $.fn.field_employeeimage = function (options) {

        return this.each(function () {

            if (undefined == $(this).data('field_employeeimage')) {
                var plugin = new $.field_employeeimage(this, options);
                $(this).data('field_employeeimage', plugin);
            }
        });
    }
})(jQuery);
