"use strict";
(function ($) {
    $.view_form_coupon = function (element, options) {
        let defaults = {
        };
        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_coupon = function (options) {
        return this.each(function () {
            if (undefined === $(this).data('view_form_coupon')) {
                let plugin = new $.view_form_coupon(this, options);
                $(this).data('view_form_coupon'
                    , plugin);
            }
        });
    }
})(jQuery);
