"use strict";
(function ($) {
    $.view_form_discount = function (element, options) {
        let defaults = {
            row_state_template: ""
        };
        let plugin = this;
        plugin.settings = {};
        let $element = $(element);
        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            $element.find('input[name="amount"]').on('change', function () {
                if($(this).val() > 0) {
                    let $input_percent = $element.find('input[name="percent"]');
                    let $wrapper_duration1 = $input_percent.parent();
                    $element.find('input[name="percent"]').val(0);
                    $wrapper_duration1.find('input.duration1').val(0)
                }
            })
            $element.find('input[name="percent"]').on('change', function () {
                if($(this).val() > 0) {
                    let $input_percent = $element.find('input[name="amount"]');
                    let $wrapper_duration1 = $input_percent.parent();
                    $element.find('input[name="amount"]').val(0);
                    $wrapper_duration1.find('input.duration1').val(0)
                }
            })

        };
        plugin.example_function = function () {
        };
        plugin.init();
    }
    $.fn.view_form_discount = function (options) {
        return this.each(function () {
            if (undefined === $(this).data('view_form_discount')) {
                let plugin = new $.view_form_discount(this, options);
                $(this).data('view_form_discount'
                    , plugin);
            }
        });
    }
})(jQuery);
