"use strict";
(function ($) {
    $.field_duration = 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 $durationNumeric = $element.find('input[type="text"].duration');
            let $duration = $element.find(`input[name="${plugin.settings.input_name}"]`);
            $durationNumeric.autoNumeric('init', {
                mDec: '0'
            });
            $durationNumeric.on('keyup', function () {
                $duration.val($durationNumeric.autoNumeric('get'));
            })
        }
        plugin.example_function = function () {
        };
        plugin.init();
    }
    
    $.fn.field_duration = function (options) {
        
        return this.each(function () {
            
            if (undefined == $(this).data('field_duration')) {
                var plugin = new $.field_duration(this, options);
                $(this).data('field_duration', plugin);
            }
        });
    }
})(jQuery);
