"use strict";
(function ($) {
    $.field_uploadsystem = function (element, options) {
        var defaults = {
            input_name: "",
            value:''
        }
        var plugin = this;
        plugin.settings = {}
        var $element = $(element), 
            element = element;
        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            let input_name = plugin.settings.input_name;
            let value = plugin.settings.value;
            $element.find(`input[name="${input_name}"]`).val(value);
            $element.find('.upload-file').on('change', function (e) {
                let val = e.target.files[0].name;
                $element.find(`input[name="${input_name}"]`).val(val);
            });
        };
        plugin.example_function = function () {
        };
        plugin.init();
    };
    
    $.fn.field_uploadsystem = function (options) {
        return this.each(function () {
            if (undefined == $(this).data('field_uploadsystem')) {
                var plugin = new $.field_uploadsystem(this, options);
                $(this).data('field_uploadsystem', plugin);
            }
        });
    }
})(jQuery);