(function ($) {
    $.field_rating = 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 $ratingNumeric = $element.find('input[type="text"].rating');
            let $rating = $element.find(`input[name="${plugin.settings.input_name}"]`);
            $ratingNumeric.autoNumeric('init', {
                aForm: true,
                vMax: '5.00',
            });
            $ratingNumeric.on('keyup', function () {
                $rating.val($ratingNumeric.autoNumeric('get'));
            })
        }
        plugin.example_function = function () {
        };
        plugin.init();
    }
    
    $.fn.field_rating = function (options) {
        
        return this.each(function () {
            
            if (undefined == $(this).data('field_rating')) {
                var plugin = new $.field_rating(this, options);
                $(this).data('field_rating', plugin);
            }
        });
    }
})(jQuery);
