$(document).ready(function () {
    $("#btn-add-new-slider-title-desc").click(function (e) {
        e.preventDefault();
        $("#form-store-title-desc .itmes").append(
            `<div class="row parent-slider-title-desc-row"><div class="col-md-10"><div class="form-group"><input type="text" name="header_title[]" data-name="header_title" data-laravel-translatable="header_title--lara-trans-error" class="font-16" required="" placeholder="العنوان"></div><div class="form-group"><textarea name="header_desc[]" id="header_desc[]" data-name="header_desc" data-laravel-translatable="header_desc--lara-trans-error" class="font-16" required="" rows="4" placeholder="الوصف كل وصف سوف يظهر مع العنوان الخاص به"></textarea></div></div><div class="col-md-2"><button type="submit" class="btn-remove-slider-title-desc btn btn-soft-danger btn-block"><i class="fa fa-trash-alt"></i></button></div><div class="col-12 pb-3"><hr style="border-color:#ddd"></div></div>`
        );
        removeTitleDescSection();
    });

    function removeTitleDescSection() {
        $(".btn-remove-slider-title-desc").click(function (e) {
            e.preventDefault();
            let target = $(this);
            target.parents(".parent-slider-title-desc-row").slideUp(250);
            setTimeout(function () {
                target.parents(".parent-slider-title-desc-row").remove();
            }, 250);
        });
    }
    removeTitleDescSection();

    $("#btn-add-new-email").click(function (e) {
        e.preventDefault();
        $("#emails-box").append(
            `<div class="parent-email"><div class="row"><div class="col-2"><div class="btn-remove-email btn btn-soft-danger btn-block"><i class="fa fa-trash"></i></div></div><div class="col-10"><div class="form-group dir-ltr"><input type="email" name="email[]" value="" data-name="email" data-laravel-translatable="email--lara-trans-error" required="" placeholder="هذا البريد سوف يعرض في صفحات الموقع الرئيسة مثل ( اتصل بنا )"></div></div></div></div>`
        );
        removeEmail();
    });
    function removeEmail() {
        $(".btn-remove-email").click(function (e) {
            e.preventDefault();
            $(this).parents(".parent-email").remove();
        });
    }
    removeEmail();

    $("#btn-add-new-phone").click(function (e) {
        e.preventDefault();
        $("#phones-box").append(
            `<div class="parent-phone"><div class="row"><div class="col-2"><div class="btn-remove-phone btn btn-soft-danger btn-block"><i class="fa fa-trash"></i></div></div><div class="col-10"><div class="form-group dir-ltr"><input type="number" name="phone[]" data-name="phone" data-laravel-translatable="email--lara-trans-error" required="" placeholder="كود البلد يتبعه رقم الهاتف"></div></div></div></div>`
        );
        removePhone();
    });

    function removePhone() {
        $(".btn-remove-phone").click(function (e) {
            e.preventDefault();
            $(this).parents(".parent-phone").remove();
        });
    }
    removePhone();

    // //
    // $("#btn-add-new-receiving-email").click(function (e) {
    //     e.preventDefault();
    //     $("#receiving-emails-box").append(
    //         `<div class="parent-receiving-email"><div class="row"><div class="col-2"><div class="btn-remove-receiving-email btn btn-soft-danger btn-block"><i class="fa fa-trash"></i></div></div><div class="col-10"><div class="form-group dir-ltr"><input type="email" name="email[]" value="" data-name="email" data-laravel-translatable="email--lara-trans-error" required=""></div></div></div></div>`
    //     );
    //     removeReceivingEmail();
    // });
    // function removeReceivingEmail() {
    //     $(".btn-remove-receiving-email").click(function (e) {
    //         e.preventDefault();
    //         $(this).parents(".parent-receiving-email").remove();
    //     });
    // }
    // removeReceivingEmail();
});
