1// quick view 2// examples https://api.jquery.com/event.preventdefault/ 3// https://codex.wordpress.org/AJAX_in_Plugins 4 5jQuery(document).ready(function($) { 6"use strict"; 7$("a.creote_quick_view_btn").click(function(event) { 8 event.preventDefault(); 9 var data = { 10 action: 'creote_get_quick_view', 11 'id': $(this).attr('href'), 12 beforeSend: function() { 13 $('.quick_view_loading').addClass('loading'); 14 }, 15 }; 16 $.post(CreoteAjax.ajaxurl, data, function(response) { 17 $.magnificPopup.open({ 18 type: 'inline', 19 preloader: true, 20 // Delay in milliseconds before 21 // popup is removed 22 removalDelay: 50, 23 zoom: { 24 enabled: true, 25 duration: 50 // don't foget to change the duration also in CSS 26 }, 27 mainClass: 'mfp-fade' , 28 items: { 29 src: response 30 } 31 }) 32 $('.quick_view_loading').removeClass('loading'); 33 $('body').addClass('quickview_enable'); 34 35 var owl = $('.product-image-slider'); 36 owl.owlCarousel({ 37 autoplay: true, 38 autoplayTimeout: 4000, 39 loop: true, 40 dots: false, 41 items: 1, 42 center: true, 43 nav: true, 44 45 }); 46 $('.quick_view .mfp-close').on('click', function() { 47 $('.quick_view , .mfp-wrap').css('opacity', 0); 48 }); 49 50 $('.product:not(.product-type-external) form.cart').on('submit', function(e) { 51 e.preventDefault(); 52 var form = $(this); 53 var formData = new FormData(form[0]); 54 formData.append('add-to-cart', form.find('[name=add-to-cart]').val() ); 55 $.ajax({
56 url: wc_add_to_cart_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'ace_add_to_cart' ), 57 data: formData, 58 type: 'POST', 59 processData: false, 60 contentType: false, 61 complete: function( response ) { 62 response = response.responseJSON; 63 if(!response){ 64 return; 65 } 66 if(response.error && response.product_url){ 67 window.location = response.product_url; 68 return; 69 } 70 if (wc_add_to_cart_params.cart_redirect_after_add === 'yes'){ 71 window.location = wc_add_to_cart_params.cart_url; 72 return; 73 } 74 var $thisbutton = form.find('.single_add_to_cart_button'); // 75 //var $thisbutton = null; // uncomment this if you don't want the 'View cart' button 76 // Trigger event so themes can refresh other areas. 77 $( document.body ).trigger( 'added_to_cart', [ response.fragments, response.cart_hash, $thisbutton ] ); 78 // Remove existing notices 79 $( '.woocommerce-error, .woocommerce-message, .woocommerce-info' ).remove(); 80 // Add new notices 81 $(response.fragments.notices_html).appendTo('.cart_notice').delay(3000).fadeOut(300); 82 } 83 }); 84 }); 85 }); 86 }); 87});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.