Rev 30632 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(document).on('click', ".web-offers", function() {doAjaxRequestHandler(context + "/web-offers", "GET", function(response) {$('#main-content').html(response);});});$(document).on('click', "a.web-offer-details", function() {var webOfferId = $(this).data("id");doAjaxRequestHandler(`${context}/web-offer/${webOfferId}`, "GET", function(response) {$('.web-offer-products-container').html(response);});})$(document).on('click', ".web-offer-id", function() {var webOfferId = $(this).data("id");doAjaxRequestHandler(`${context}/getwebOffer/${webOfferId}`, "GET", function(response) {$('.web-offer-edit-container .modal-content').html(response);});});$(document).on('click', ".updateWebOfferDuration", function() {var webOfferId = $(this).data("id");console.log(webOfferId)webOfferTitle = $("#web-offer-update-title").val();detailedText = $("#detailed-update-text").val();largeBannerUrl = $("#offer-banner-update-large").val();console.log(largeBannerUrl)if (webOfferTitle === "") {alert("Title is required");return false;}var json = {id: webOfferId,title: webOfferTitle,detailedText: detailedText,largeBannerUrl: largeBannerUrl,startDate: getDatesFromPicker('input[name="offerUpdatedateRange"]').startDate,endDate: getDatesFromPicker('input[name="offerUpdatedateRange"]').endDate}startDate = getDatesFromPicker('input[name="offerUpdatedateRange"]').startDate,endDate = getDatesFromPicker('input[name="offerUpdatedateRange"]').endDateif (confirm("Are you sure you want to update offer!") == true) {doPostAjaxRequestWithJsonHandler(context + "/web-offer-duration/update", JSON.stringify(json), function(response) {$('#main-content').html(response);});return false;}});$(document).on('click', "#add-to-offer", function() {var webOfferId = $(this).data("id");var entityIds = [entityId];var entityIdTxt = $("#entityData").val();if (entityIdTxt.length > 0) {if (entityIdTxt.indexOf(",") > 0) {entityIds = entityIdTxt.split(",");}} else {alert("Please enter items");return;}json = [];for (var e of entityIds) {json.push({ webOfferId: webOfferId, entityId: e });}console.log(json);console.log(JSON.stringify(json))doPostAjaxRequestWithJsonHandler(`${context}/web-offer-product/add`, JSON.stringify(json), function(response) {$('.web-offer-products-container').html(response);});});$(document).on('click', "a.product-remove", function() {var webOfferProductId = $(this).closest('tr').data("id");if (confirm("Are you sure you want to remove the Item!") == true) {doDeleteAjaxRequestHandler(`${context}/web-offer-product/remove?webOfferProductId=${webOfferProductId}`, function(response) {alert("Product removed successfully");$('.web-offer-products-container').html(response);});}})function addWebOffer() {webOfferTitle = $("#web-offer-title").val();smallText = $("#small-text").val();largeText = $("#detailed-text").val();largeBannerUrl = $("#offer-banner-large").val();if (webOfferTitle === "") {alert("Title is required");return false;}var json = {id: 0,title: webOfferTitle,smallText: smallText,detailedText: largeText,largeBannerUrl: largeBannerUrl,startDate: getDatesFromPicker('input[name="offerdateRange"]').startDate,endDate: getDatesFromPicker('input[name="offerdateRange"]').endDate}if (confirm("Are you sure you want to add the offer!") == true) {doPostAjaxRequestWithJsonHandler(context + "/web-offer/add", JSON.stringify(json), function(response) {$('#main-content').html(response);});}}$(document).on('mousedown', ".grab", function(e) {var tr = $(e.target).closest("TR"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;b.addClass("grabCursor").css("userSelect", "none");tr.addClass("grabbed");function move(e) {console.log(Math.abs(e.pageY - sy));if (!drag && Math.abs(e.pageY - sy) < 10) return;drag = true;tr.siblings().each(function() {var s = $(this), i = s.index(), y = s.offset().top;if (e.pageY >= y && e.pageY < y + s.outerHeight()) {if (e.pageY <= y + (s.outerHeight() / 2))tr.insertBefore(s);elsetr.insertAfter(s);return false;}});}function up(e) {if (drag && si != tr.index()) {drag = false;$(".update-rank").prop('disabled', false);}$(document).unbind("mousemove", move).unbind("mouseup", up);b.removeClass("grabCursor").css("userSelect", "none");tr.removeClass("grabbed");}$(document).mousemove(move).mouseup(up);});$(document).on('click', ".update-rank", function() {if (confirm("Are you sure you want to update ranks?")) {var webListingId = $(this).data("id");var webProductIds = [];$("#web-product-listing-tbody").find("tr").each(function() {console.log(this);webProductIds.push($(this).data("id"));});doPostAjaxRequestWithJsonHandler(`${context}/web-offer/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {$('.web-offer-products-container').html(response);});}});