1 2var public_woo_amc_show; 3var public_woo_amc_get_cart; 4 5 6(function( $ ) { 7 8 var PerfectScrollbar_line = ''; 9 var nonce = wooAmcVars.nonce; 10 11 $(document).ready(function(){ 12 if (wooAmcVars.cart_type!='center') { 13 PerfectScrollbar_line = new PerfectScrollbar('.woo_amc_items_scroll'); 14 } 15 16 $('body').on('click','.woo_amc_close, .woo_amc_bg',function () { 17 woo_amc_hide(); 18 }); 19 $('body').on('click','.woo_amc_open_active',function () { 20 woo_amc_show(); 21 }); 22 23 $('body').on( 'added_to_cart', function(e, fragments, cart_hash, this_button){ 24 woo_amc_show(); 25 woo_amc_get_cart(); 26 }); 27 28 $('body').on('click','.woo_amc_item_delete',function () { 29 var key = $(this).data('key'); 30 var item = $(this).parents('.woo_amc_item_wrap'); 31 woo_amc_remove_item(key,item); 32 }); 33 34 $('body').on('click','.woo_amc_item_quanity_update',function () { 35 woo_amc_quanity_update_buttons($(this)); 36 }); 37 38 $('body').on('blur','.woo_amc_item_quanity',function () { 39 woo_amc_quanity_update($(this)); 40 }); 41 42 $(document).on('click', '.single_add_to_cart_button', function (e) { 43 e.preventDefault(); 44 var $button = $(this), 45 $form = $button.closest('form.cart'), 46 product_id = $form.find('input[name=add-to-cart]').val() || $button.val(); 47 48 if (!product_id) 49 return; 50 51 if ($button.is('.disabled')) 52 return; 53 54 var data = { 55 action: 'woo_amc_add_to_cart', 56 'add-to-cart': product_id, 57 }; 58 59 $form.serializeArray().forEach(function (element) { 60 data[element.name] = element.value; 61 }); 62 63 $(document.body).trigger('adding_to_cart', [$button, data]); 64 65 jQuery.ajax({ 66 type: 'post', 67 url: wooAmcVars.ajaxurl, 68 data: data, 69 beforeSend: function (response) { 70 $button.removeClass('added').addClass('loading'); 71 }, 72 complete: function (response) { 73 $button.addClass('added').removeClass('loading'); 74 }, 75 success: function (response) { 76 77 if (response.error & response.product_url) { 78 window.location = response.product_url; 79 return; 80 } else { 81 $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $button]); 82 83 $('.woocommerce-notices-wrapper').empty().append(response.notices); 84 85 } 86 }, 87 }); 88 89 return false; 90 91 }); 92 }); 93 94 function woo_amc_hide() { 95 if (wooAmcVars.cart_type=='center') { 96 $('.woo_amc_container_wrap_center').animate({opacity:'hide'},300); 97 } else { 98 $('.woo_amc_container_wrap').removeClass('woo_amc_show'); 99 $('.woo_amc_bg').removeClass('woo_amc_show'); 100 } 101 } 102 103 function woo_amc_show() { 104 if (wooAmcVars.cart_type=='center') { 105 $('.woo_amc_container_wrap_center').animate({opacity:'show'},300); 106 } else { 107 $('.woo_amc_container_wrap').addClass('woo_amc_show'); 108 $('.woo_amc_bg').addClass('woo_amc_show'); 109 } 110 111 } 112 113 function woo_amc_get_cart() { 114 $( '.woo_amc_items_wrap' ).addClass( 'woo_amc_items_wrap_loading' ); 115 var data = { 116 action: 'woo_amc_get_cart', 117 type: wooAmcVars.cart_type, 118 }; 119 $.post( wooAmcVars.ajaxurl, data, function( response ) { 120 var cart_response = JSON.parse( response ); 121 $( '.woo_amc_items' ).html( cart_response['html'] ); 122 woo_amc_perfect_scrollbar(); 123 $('.woo_amc_footer_products .woo_amc_value, .woo_amc_open_count').html(cart_response['count']); 124 $('.woo_amc_footer_total .woo_amc_value').html(cart_response['total']); 125 if (!$('.woo_amc_open').hasClass('woo_amc_open_active')){ 126 $('.woo_amc_open').addClass('woo_amc_open_active'); 127 } 128 $( '.woo_amc_items_wrap' ).removeClass( 'woo_amc_items_wrap_loading' ); 129 nonce = cart_response['nonce']; 130 } ); 131 } 132 133 var woo_amc_quanity_update_send = true; 134 function woo_amc_quanity_update_buttons( el ) { 135 if(woo_amc_quanity_update_send){ 136 $( '.woo_amc_items_wrap' ).addClass( 'woo_amc_items_wrap_loading' ); 137 woo_amc_quanity_update_send = false;
138 var wrap = $(el).parents('.woo_amc_item_wrap'); 139 var input = $(wrap).find('.woo_amc_item_quanity'); 140 var key = $(input).data('key'); 141 var number = parseInt($(input).val()); 142 var type = $(el).data('type'); 143 if(type=='minus'){ 144 number--; 145 } else { 146 number++; 147 } 148 if (number<1){ 149 number = 1; 150 } 151 $(input).val(number); 152 var data = { 153 action: 'woo_amc_quanity_update', 154 key: key, 155 number: number, 156 security: nonce 157 }; 158 $(wrap).addClass('loading'); 159 $.post( wooAmcVars.ajaxurl, data, function( response ) { 160 var cart_response = JSON.parse( response ); 161 $('.woo_amc_footer_products .woo_amc_value, .woo_amc_open_count').html(cart_response['count']); 162 $('.woo_amc_footer_total .woo_amc_value').html(cart_response['total']); 163 $(wrap).find('.woo_amc_item_total_price').html(cart_response['item_price']); 164 $(wrap).removeClass('loading'); 165 woo_amc_quanity_update_send = true; 166 $( '.woo_amc_items_wrap' ).removeClass( 'woo_amc_items_wrap_loading' ); 167 } ); 168 } 169 } 170 171 function woo_amc_quanity_update( input ) { 172 $( '.woo_amc_items_wrap' ).addClass( 'woo_amc_items_wrap_loading' ); 173 var wrap = $(input).parents('.woo_amc_item_wrap'); 174 var key = $(input).data('key'); 175 var number = parseInt($(input).val()); 176 if (!number || number<1){ 177 number = 1; 178 } 179 $(input).val(number); 180 var data = { 181 action: 'woo_amc_quanity_update', 182 key: key, 183 number: number, 184 security: nonce 185 }; 186 $(wrap).addClass('loading'); 187 $.post( wooAmcVars.ajaxurl, data, function( response ) { 188 var cart_response = JSON.parse( response ); 189 $('.woo_amc_footer_products .woo_amc_value, .woo_amc_open_count').html(cart_response['count']); 190 $('.woo_amc_footer_total .woo_amc_value').html(cart_response['total']); 191 $(wrap).find('.woo_amc_item_total_price').html(cart_response['item_price']); 192 $(wrap).removeClass('loading'); 193 woo_amc_quanity_update_send = true; 194 $( '.woo_amc_items_wrap' ).removeClass( 'woo_amc_items_wrap_loading' ); 195 } ); 196 } 197 198 function woo_amc_remove_item( key,item ) { 199 var data = { 200 action: 'woo_amc_delete_item', 201 key: key, 202 security: nonce 203 }; 204 if (wooAmcVars.cart_type=='left'){ 205 $(item).animate({right: '100%'}, 300, function () { 206 $(item).remove(); 207 woo_amc_perfect_scrollbar(); 208 }); 209 } else { 210 $(item).animate({left: '100%'}, 300, function () { 211 $(item).remove(); 212 woo_amc_perfect_scrollbar(); 213 }); 214 } 215 216 $.post( wooAmcVars.ajaxurl, data, function( response ) { 217 var cart_response = JSON.parse( response ); 218 $('.woo_amc_footer_products .woo_amc_value, .woo_amc_open_count').html(cart_response['count']); 219 $('.woo_amc_footer_total .woo_amc_value').html(cart_response['total']); 220 if(!parseInt(cart_response['count'])){ 221 $('.woo_amc_open').removeClass('woo_amc_open_active'); 222 woo_amc_hide(); 223 } 224 } ); 225 } 226 227 function woo_amc_perfect_scrollbar() { 228 if (wooAmcVars.cart_type!='center') { 229 PerfectScrollbar_line.update(); 230 } 231 } 232 233 public_woo_amc_show = woo_amc_show; 234 public_woo_amc_get_cart = woo_amc_get_cart; 235 236})( jQuery );
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.