"use strict";
(function ($) {
    $.field_fullimage = function (element, options) {
        var defaults = {
        }
        var plugin = this;
        plugin.settings = {}
        var $element = $(element), 
            element = element;    
        
        plugin.init = function () {

            plugin.settings = $.extend({}, defaults, options);
            $element.find('.img-fullimage').on('click',function (e) {
                $element.find('input[type="file"].upload').click();
            });
            $element.find('input[type="file"].upload').on('change',function () {
                plugin.readURL(this);
            });
        };
        plugin.readURL = function (input) {
            if (input.files && input.files[0]) {
                let reader = new FileReader();
                reader.onload = function (e) {
                    $element.find('.img-fullimage').attr('src', e.target.result);
                }
                reader.readAsDataURL(input.files[0]);
            }
        }
        plugin.example_function = function () {
        };
        plugin.init();
    }
    
    $.fn.field_fullimage = function (options) {
        
        return this.each(function () {
            
            if (undefined == $(this).data('field_fullimage')) {
                var plugin = new $.field_fullimage(this, options);
                $(this).data('field_fullimage', plugin);
            }
        });
    }
})(jQuery);