(function ($) {
    $.field_CustomAddress = 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('.list-address').select2();
            $element.find('.list-address').change(function (e) {
                let location_id = $(this).val();
                plugin.change_location(location_id);
            });
        }
        plugin.example_function = function () {
        };
        plugin.change_location = function (location_id) {
            if (location_id !== "") {
                $element.find('.wrapper-custom-address').hide();
            } else {
                $element.find('.wrapper-custom-address').show();
            }
        };
        plugin.init();
    }

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