"use strict";
(function ($) {
    $.field_price = function (element, options) {
        var defaults = {
            input_name: ""
        }
        var plugin = this;
        plugin.settings = {}
        var $element = $(element), 
            element = element;
        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            let $priceNumeric = $element.find('input[type="text"].price');
            let $price = $element.find(`input[name="${plugin.settings.input_name}"]`);
            $priceNumeric.autoNumeric('init');
            $priceNumeric.on('keyup', function () {
                $price.val($priceNumeric.autoNumeric('get'));
            })
        }
        plugin.example_function = function () {
        };
        plugin.init();
    }
    
    $.fn.field_price = function (options) {
        
        return this.each(function () {
            
            if (undefined == $(this).data('field_price')) {
                var plugin = new $.field_price(this, options);
                $(this).data('field_price', plugin);
            }
        });
    }
})(jQuery);
