| 1 |
(function ($, elementor) { |
| 2 |
("use strict"); |
| 3 |
var widgetProductQuickView = { |
| 4 |
loadQuickViewHtml: function (_this, $scope) { |
| 5 |
var product_id = $(_this).data("id"); |
| 6 |
$.ajax({ |
| 7 |
type: "POST", |
| 8 |
dataType: "json", |
| 9 |
url: ultimate_store_kit_ajax_config.ajaxurl, |
| 10 |
data: { |
| 11 |
action: "ultimate_store_kit_compare_products_quick_view_content", |
| 12 |
product_id: product_id, |
| 13 |
security: $scope.find("#usk-compare-products-modal-sc").val(), |
| 14 |
}, |
| 15 |
success: function (response) { |
| 16 |
$("#usk-grid-modal-response").html(response.data); |
| 17 |
}, |
| 18 |
}); |
| 19 |
}, |
| 20 |
}; |
| 21 |
var widgetWCQuickViewTrigger = function ($scope, $) { |
| 22 |
var $modalBody = '<div class="modal micromodal-slide" id="usk-grid-modal" aria-hidden="false"><div class="modal__overlay" tabindex="-1" data-custom-close=""><div id="usk-grid-modal-response" class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-btn-title"></div></div></div>'; |
| 23 |
$("body").append($modalBody); |
| 24 |
MicroModal.init({ |
| 25 |
openTrigger: "data-micromodal-trigger", |
| 26 |
closeTrigger: "data-micromodal-close", |
| 27 |
disableScroll: true, |
| 28 |
disableFocus: false, |
| 29 |
awaitOpenAnimation: false, |
| 30 |
awaitCloseAnimation: false, |
| 31 |
debugMode: true, |
| 32 |
}); |
| 33 |
$scope.on("click", ".usk-view-btn", function (e) { |
| 34 |
e.preventDefault(); |
| 35 |
widgetProductQuickView.loadQuickViewHtml(this, $scope); |
| 36 |
}); |
| 37 |
}; |
| 38 |
$(".ajax_remove_from_wishlist").on("click", function (e) { |
| 39 |
e.preventDefault(); |
| 40 |
var $this = $(this); |
| 41 |
var $product_id = $this.data("product_id"); |
| 42 |
$.ajax({ |
| 43 |
url: ultimate_store_kit_ajax_config.ajaxurl, |
| 44 |
data: { |
| 45 |
action: "usk_remove_wishlist", |
| 46 |
product_id: $product_id, |
| 47 |
nonce: ultimate_store_kit_ajax_config.nonce, |
| 48 |
}, |
| 49 |
type: "POST", |
| 50 |
dataType: "JSON", |
| 51 |
success: function (response) { |
| 52 |
if (response.action == "removed") { |
| 53 |
$this.closest("tr").remove(); |
| 54 |
} |
| 55 |
}, |
| 56 |
error: function (response) { |
| 57 |
console.log(response); |
| 58 |
}, |
| 59 |
}); |
| 60 |
}); |
| 61 |
jQuery(window).on("elementor/frontend/init", function () { |
| 62 |
elementorFrontend.hooks.addAction("frontend/element_ready/usk-compare-products.default", widgetWCQuickViewTrigger); |
| 63 |
}); |
| 64 |
})(jQuery, window.elementorFrontend); |