Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(function () {
    $(document).on('click', ".post-bulletin", function () {
        loadbulletinPage("main-content");
    });


    $(document).on('click', ".post-bulletin-button", function (event) {
        event.preventDefault();

        if (confirm("Are you sure?")) {

            let title = $("#btitle").val();
            let description = quill.root.innerHTML;
            let regionId = $("#bregionId").val();
            let documentIds = $("#bulletinDocumentIds").val();

            let param = {
                title: title,
                description: description,
                regionId: regionId,
                documentIds: documentIds
            }

            doPostAjaxRequestWithJsonHandler(context + "/bulletinPost", JSON.stringify(param), function (response) {
                if (response == 'true') {
                    bootbox.alert("Bulletin Post Successfully");
                    loadbulletinPage("main-content");
                }

            });
        }
    });

});


function loadbulletinPage(domId) {
    doGetAjaxRequestHandler(context + "/bulletin", function (response) {

        $('#' + domId).html(response);
    });
}


$(document).on('click', '.today-bulletin-offer', function () {
    let offerId = $(this).data("offerid");
    doGetAjaxRequestHandler(`${context}/getOfferMargins?offerId=${offerId}`, function (data) {
        $('#todayBulletinOfferDescription .modal-content').html(data);
        $("#todayBulletinOfferDescription").modal('show');
    });
});


document.querySelectorAll('.bulletin-tabs li').forEach(tab => {
    tab.addEventListener('click', function () {

        document.querySelectorAll('.bulletin-tabs li')
            .forEach(t => t.classList.remove('active'));

        document.querySelectorAll('.bulletin-tab-content')
            .forEach(c => c.style.display = 'none');

        this.classList.add('active');
        document.getElementById('tab-' + this.dataset.tab).style.display = 'block';
    });
});

/* Activate first tab by default */
document.querySelector('.bulletin-tabs li')?.click();