HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_new/buyercall/buyercall/assets/scripts/mobile/contact_detail.js
$(() => {
    end_url = location.href.split('/')[5];
    $("#nav-notes").attr("href", "/mobile/contact_notes/" + end_url + location.search);
    $("#nav-timeline").attr("href", "/mobile/timeline/" + end_url + location.search);
    $("input[name=phonenumber_1]").mask("(000) 000-0000");
    $("input[name=phonenumber_2]").mask("(000) 000-0000");
    $("input[name=zip]").mask("00000");
    // $("#back-to-contact").attr("href", "/mobile/contact_leads/" + location.search);
})

$("#back-to-contact").on("click", () => {
    if ($(".save-btn").is(":hidden")){
        location.href = "/mobile/contact_leads/detail" + location.search;
    }
    else{
        $("#modal-ok-link").attr("href", "/mobile/contact_leads/detail" + location.search);
        $("#backToModal").modal('show');
    }
})

$("input[name=phonenumber_1]").click( function() {
    if ($(this).val() && $(this).is('[readonly]')){
        $("#numberModal1").modal("show");
    }    
})

$("input[name=phonenumber_2]").click( function() {
    if ($(this).val() && $(this).is('[readonly]')){
        $("#numberModal2").modal("show");
    }    
})

$('.edit-input').on("change", () => {
    $('.save-btn').attr("hidden", false);
})

$('.content-edit-btn').click(function () {
    $(this).closest(".contact-number-wrapper").find('.contact-block-sub input').addClass('active').attr("readonly", false);
    $("input[name=phonenumber_1]").removeClass('active').attr("readonly", true);
});

$('.address-edit-btn').click(function () {
    $(this).closest(".details-inp-wrapper").find('input').addClass('active').attr("readonly", false);
});

$('.inp-edit-btn').click(function () {
    $(this).closest(".details-inp-group").find('.details-input ').addClass('active').attr("readonly", false);
});
$('.save-btn').click(function () {
    $('.details-input').removeClass('active').attr("readonly", true);
    $('.contact-block-sub input').removeClass('active').attr("readonly", true);
})


$(".save-btn").on("click", () => {
    data = $("#contact-edit-form").serialize();
    $.ajax({
        type: "POST",
        url: location.href,
        data: data,
        success: function (result) {
            if(result.status){
                location.reload();
            }
            else{
                $("#error-msg").text(result.error);
                $("#validationError").modal('show');
            }
        }
    });
})