1(function ($) { 2 'use strict'; 3 4 function buyNow() { 5 if ( ! $('body').find('div.product').hasClass('has-buy-now') && ! $('body').find('div.product-quickview').hasClass('has-buy-now') ) { 6 return; 7 } 8 9 $('body').on('click', '.shopwell-buy-now-button', function (e) { 10 e.preventDefault(); 11 var $form = $('body').find('div.product form.cart'), 12 is_disabled = $(this).is(':disabled'); 13 14 if (is_disabled) { 15 jQuery('html, body').animate({ 16 scrollTop: $(this).offset().top - 200 17 }, 900 18 ); 19 } else { 20 $form.addClass('buy-now-clicked'); 21 $form.append('<input type="hidden" value="true" name="shopwell_buy_now" />'); 22 $form.find('.single_add_to_cart_button').trigger('click'); 23 } 24 }); 25 26 $( '.variations_form' ).each( function() { 27 $( this ).on('hide_variation', function (event) { 28 event.preventDefault(); 29 $( this ).find('.shopwell-buy-now-button').addClass('disabled wc-variation-selection-needed'); 30 }); 31 32 $( this ).on('show_variation', function (event, variation, purchasable) { 33 event.preventDefault(); 34 if (purchasable) { 35 $( this ).find('.shopwell-buy-now-button').removeClass('disabled wc-variation-selection-needed'); 36 } else { 37 $( this ).find('.shopwell-buy-now-button').addClass('disabled wc-variation-selection-needed'); 38 } 39 }); 40 }); 41 }; 42 43 /** 44 * Document ready 45 */ 46 $(function () { 47 buyNow(); 48 49 $('body').on('shopwell_product_quick_view_loaded', function () { 50 buyNow(); 51 }); 52 }); 53 54})(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.