Initial commit
This commit is contained in:
@ -0,0 +1,285 @@
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
var throttle = function(fn, threshhold, scope) {
|
||||
threshhold || (threshhold = 250);
|
||||
var last,
|
||||
deferTimer;
|
||||
|
||||
return function () {
|
||||
var context = scope || this;
|
||||
|
||||
var now = +new Date,
|
||||
args = arguments;
|
||||
|
||||
if (last && now < last + threshhold) {
|
||||
// hold on to it
|
||||
clearTimeout(deferTimer);
|
||||
deferTimer = setTimeout(function () {
|
||||
last = now;
|
||||
fn.apply(context, args);
|
||||
}, threshhold);
|
||||
} else {
|
||||
last = now;
|
||||
fn.apply(context, args);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
$( '.wc-has-gallery .wc-product-image' ).hover(
|
||||
function() {
|
||||
$( this ).find( '.secondary-image' ).css( 'opacity','1' );
|
||||
}, function() {
|
||||
$( this ).find( '.secondary-image' ).css( 'opacity','0' );
|
||||
}
|
||||
);
|
||||
|
||||
$( 'body' ).on( 'added_to_cart', function() {
|
||||
if ( ! $( '.wc-menu-item' ).hasClass( 'has-items' ) ) {
|
||||
$( '.wc-menu-item' ).addClass( 'has-items' );
|
||||
}
|
||||
|
||||
if ( ! $( '.wc-mobile-cart-items' ).hasClass( 'has-items' ) ) {
|
||||
$( '.wc-mobile-cart-items' ).addClass( 'has-items' );
|
||||
}
|
||||
} );
|
||||
|
||||
$( 'body' ).on( 'removed_from_cart', function() {
|
||||
var numberOfItems = $( '.number-of-items' );
|
||||
|
||||
if ( numberOfItems.length ) {
|
||||
if ( numberOfItems.hasClass( 'no-items' ) ) {
|
||||
$( '.wc-menu-item' ).removeClass( 'has-items' );
|
||||
$( '.wc-mobile-cart-items' ).removeClass( 'has-items' );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
if ( generateWooCommerce.addToCartPanel ) {
|
||||
$( document.body ).on( "added_to_cart", function() {
|
||||
var adminBar = $( '#wpadminbar' ),
|
||||
stickyNav = $( '.navigation-stick' ),
|
||||
top = 0;
|
||||
|
||||
if ( adminBar.length ) {
|
||||
top = adminBar.outerHeight();
|
||||
}
|
||||
|
||||
if ( stickyNav.length && '0px' === stickyNav.css( 'top' ) ) {
|
||||
top = top + stickyNav.outerHeight();
|
||||
}
|
||||
|
||||
$( '.add-to-cart-panel' ).addClass( 'item-added' ).css( {
|
||||
'-webkit-transform': 'translateY(' + top + 'px)',
|
||||
'-ms-transform': 'translateY(' + top + 'px)',
|
||||
'transform': 'translateY(' + top + 'px)'
|
||||
} );
|
||||
} );
|
||||
|
||||
$( '.add-to-cart-panel .continue-shopping' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '.add-to-cart-panel' ).removeClass( 'item-added' ).css( {
|
||||
'-webkit-transform': 'translateY(-100%)',
|
||||
'-ms-transform': 'translateY(-100%)',
|
||||
'transform': 'translateY(-100%)'
|
||||
} );
|
||||
} );
|
||||
|
||||
$( window ).on( 'scroll', throttle( function() {
|
||||
var panel = $( '.add-to-cart-panel' );
|
||||
|
||||
if ( panel.hasClass( 'item-added' ) ) {
|
||||
panel.removeClass( 'item-added' ).css( {
|
||||
'-webkit-transform': 'translateY(-100%)',
|
||||
'-ms-transform': 'translateY(-100%)',
|
||||
'transform': 'translateY(-100%)'
|
||||
} );
|
||||
}
|
||||
}, 250 ) );
|
||||
}
|
||||
|
||||
if ( generateWooCommerce.stickyAddToCart ) {
|
||||
var lastScroll = 0;
|
||||
$( window ).on( 'scroll', throttle( function() {
|
||||
var adminBar = $( '#wpadminbar' ),
|
||||
stickyNav = $( '.navigation-stick' ),
|
||||
top = 0,
|
||||
scrollTop = $( window ).scrollTop(),
|
||||
panel = $( '.add-to-cart-panel' ),
|
||||
panelPosition = panel.offset().top + panel.outerHeight(),
|
||||
button = $( '.single_add_to_cart_button' ),
|
||||
buttonTop = button.offset().top,
|
||||
buttonHeight = button.outerHeight(),
|
||||
footerTop = $( '.site-footer' ).offset().top;
|
||||
|
||||
if ( adminBar.length ) {
|
||||
top = adminBar.outerHeight();
|
||||
}
|
||||
|
||||
if ( stickyNav.length ) {
|
||||
if ( stickyNav.hasClass( 'auto-hide-sticky' ) ) {
|
||||
if ( scrollTop < lastScroll && '0px' === stickyNav.css( 'top' ) ) {
|
||||
top = top + stickyNav.outerHeight();
|
||||
} else {
|
||||
top = top;
|
||||
}
|
||||
|
||||
lastScroll = scrollTop;
|
||||
} else {
|
||||
top = top + stickyNav.outerHeight();
|
||||
}
|
||||
}
|
||||
|
||||
if ( scrollTop > ( buttonTop + buttonHeight ) && panelPosition < footerTop ) {
|
||||
panel.addClass( 'show-sticky-add-to-cart' ).css( {
|
||||
'-webkit-transform': 'translateY(' + top + 'px)',
|
||||
'-ms-transform': 'translateY(' + top + 'px)',
|
||||
'transform': 'translateY(' + top + 'px)'
|
||||
} );
|
||||
} else {
|
||||
panel.removeClass( 'show-sticky-add-to-cart' ).css( {
|
||||
'-webkit-transform': '',
|
||||
'-ms-transform': '',
|
||||
'transform': ''
|
||||
} );
|
||||
}
|
||||
}, 250 ) );
|
||||
|
||||
$( '.go-to-variables' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var offset = 0,
|
||||
stickyNav = $( '.navigation-stick' ),
|
||||
adminBar = $( '#wpadminbar' );
|
||||
|
||||
if ( stickyNav.length ) {
|
||||
offset = stickyNav.outerHeight();
|
||||
}
|
||||
|
||||
if ( adminBar.length ) {
|
||||
offset = offset + adminBar.outerHeight();
|
||||
}
|
||||
|
||||
$( 'html, body' ).animate({
|
||||
scrollTop: $( '.variations' ).offset().top - offset
|
||||
}, 250 );
|
||||
} );
|
||||
}
|
||||
|
||||
$( document ).on( 'ready', function() {
|
||||
"use strict";
|
||||
|
||||
if ( generateWooCommerce.quantityButtons ) {
|
||||
generateQuantityButtons();
|
||||
}
|
||||
} );
|
||||
|
||||
$( document ).ajaxComplete( function() {
|
||||
"use strict";
|
||||
|
||||
if ( generateWooCommerce.quantityButtons ) {
|
||||
generateQuantityButtons();
|
||||
}
|
||||
} );
|
||||
|
||||
function generateQuantityButtons( quantitySelector ) {
|
||||
var quantityBoxes,
|
||||
cart = $( '.woocommerce div.product form.cart' );
|
||||
|
||||
if ( cart.closest( '.elementor-add-to-cart' ).length ) {
|
||||
$( '.elementor.product' ).removeClass( 'do-quantity-buttons' );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! quantitySelector ) {
|
||||
quantitySelector = '.qty';
|
||||
}
|
||||
|
||||
quantityBoxes = $( 'div.quantity:not(.buttons-added), td.quantity:not(.buttons-added)' ).find( quantitySelector );
|
||||
|
||||
if ( quantityBoxes && 'date' !== quantityBoxes.prop( 'type' ) && 'hidden' !== quantityBoxes.prop( 'type' ) ) {
|
||||
|
||||
// Add plus and minus icons
|
||||
quantityBoxes.parent().addClass( 'buttons-added' ).prepend('<a href="javascript:void(0)" class="minus">-</a>');
|
||||
quantityBoxes.after('<a href="javascript:void(0)" class="plus">+</a>');
|
||||
|
||||
// Target quantity inputs on product pages
|
||||
$( 'input' + quantitySelector + ':not(.product-quantity input' + quantitySelector + ')' ).each( function() {
|
||||
var min = parseFloat( $( this ).attr( 'min' ) );
|
||||
|
||||
if ( min && min > 0 && parseFloat( $( this ).val() ) < min ) {
|
||||
$( this ).val( min );
|
||||
}
|
||||
});
|
||||
|
||||
// Quantity input
|
||||
if ( $( 'body' ).hasClass( 'single-product' ) && ! cart.hasClass( 'grouped_form' ) ) {
|
||||
var quantityInput = $( '.woocommerce form input[type=number].qty' );
|
||||
quantityInput.on( 'keyup', function() {
|
||||
var qty_val = $( this ).val();
|
||||
quantityInput.val( qty_val );
|
||||
});
|
||||
}
|
||||
|
||||
$( '.plus, .minus' ).unbind( 'click' );
|
||||
|
||||
$( '.plus, .minus' ).on( 'click', function() {
|
||||
|
||||
// Quantity
|
||||
var quantityBox;
|
||||
|
||||
// If floating bar is enabled
|
||||
if ( $( 'body' ).hasClass( 'single-product' ) && ! cart.hasClass( 'grouped_form' ) && ! cart.hasClass( 'cart_group' ) ) {
|
||||
quantityBox = $( '.plus, .minus' ).closest( '.quantity' ).find( quantitySelector );
|
||||
} else {
|
||||
quantityBox = $( this ).closest( '.quantity' ).find( quantitySelector );
|
||||
}
|
||||
|
||||
// Get values
|
||||
var currentQuantity = parseFloat( quantityBox.val() ),
|
||||
maxQuantity = parseFloat( quantityBox.attr( 'max' ) ),
|
||||
minQuantity = parseFloat( quantityBox.attr( 'min' ) ),
|
||||
step = quantityBox.attr( 'step' );
|
||||
|
||||
// Fallback default values
|
||||
if ( ! currentQuantity || '' === currentQuantity || 'NaN' === currentQuantity ) {
|
||||
currentQuantity = 0;
|
||||
}
|
||||
|
||||
if ( '' === maxQuantity || 'NaN' === maxQuantity ) {
|
||||
maxQuantity = '';
|
||||
}
|
||||
|
||||
if ( '' === minQuantity || 'NaN' === minQuantity ) {
|
||||
minQuantity = 0;
|
||||
}
|
||||
|
||||
if ( 'any' === step || '' === step || undefined === step || 'NaN' === parseFloat( step ) ) {
|
||||
step = 1;
|
||||
}
|
||||
|
||||
// Change the value
|
||||
if ( $( this ).is( '.plus' ) ) {
|
||||
|
||||
if ( maxQuantity && ( maxQuantity == currentQuantity || currentQuantity > maxQuantity ) ) {
|
||||
quantityBox.val( maxQuantity );
|
||||
} else {
|
||||
quantityBox.val( currentQuantity + parseFloat( step ) );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ( minQuantity && ( minQuantity == currentQuantity || currentQuantity < minQuantity ) ) {
|
||||
quantityBox.val( minQuantity );
|
||||
} else if ( currentQuantity > 0 ) {
|
||||
quantityBox.val( currentQuantity - parseFloat( step ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Trigger change event
|
||||
quantityBox.trigger( 'change' );
|
||||
|
||||
} );
|
||||
}
|
||||
}
|
||||
});
|
1
wp-content/plugins/gp-premium/woocommerce/functions/js/woocommerce.min.js
vendored
Normal file
1
wp-content/plugins/gp-premium/woocommerce/functions/js/woocommerce.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
jQuery(document).ready(function(l){var t=function(s,o,n){var r,i;return o||(o=250),function(){var t=n||this,a=+new Date,e=arguments;r&&a<r+o?(clearTimeout(i),i=setTimeout(function(){r=a,s.apply(t,e)},o)):(r=a,s.apply(t,e))}};if(l(".wc-has-gallery .wc-product-image").hover(function(){l(this).find(".secondary-image").css("opacity","1")},function(){l(this).find(".secondary-image").css("opacity","0")}),l("body").on("added_to_cart",function(){l(".wc-menu-item").hasClass("has-items")||l(".wc-menu-item").addClass("has-items"),l(".wc-mobile-cart-items").hasClass("has-items")||l(".wc-mobile-cart-items").addClass("has-items")}),l("body").on("removed_from_cart",function(){var t=l(".number-of-items");t.length&&t.hasClass("no-items")&&(l(".wc-menu-item").removeClass("has-items"),l(".wc-mobile-cart-items").removeClass("has-items"))}),generateWooCommerce.addToCartPanel&&(l(document.body).on("added_to_cart",function(){var t=l("#wpadminbar"),a=l(".navigation-stick"),e=0;t.length&&(e=t.outerHeight()),a.length&&"0px"===a.css("top")&&(e+=a.outerHeight()),l(".add-to-cart-panel").addClass("item-added").css({"-webkit-transform":"translateY("+e+"px)","-ms-transform":"translateY("+e+"px)",transform:"translateY("+e+"px)"})}),l(".add-to-cart-panel .continue-shopping").on("click",function(t){t.preventDefault(),l(".add-to-cart-panel").removeClass("item-added").css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)"})}),l(window).on("scroll",t(function(){var t=l(".add-to-cart-panel");t.hasClass("item-added")&&t.removeClass("item-added").css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)"})},250))),generateWooCommerce.stickyAddToCart){var m=0;l(window).on("scroll",t(function(){var t=l("#wpadminbar"),a=l(".navigation-stick"),e=0,s=l(window).scrollTop(),o=l(".add-to-cart-panel"),n=o.offset().top+o.outerHeight(),r=l(".single_add_to_cart_button"),i=r.offset().top,c=r.outerHeight(),d=l(".site-footer").offset().top;t.length&&(e=t.outerHeight()),a.length&&(a.hasClass("auto-hide-sticky")?(s<m&&"0px"===a.css("top")?e+=a.outerHeight():e=e,m=s):e+=a.outerHeight()),i+c<s&&n<d?o.addClass("show-sticky-add-to-cart").css({"-webkit-transform":"translateY("+e+"px)","-ms-transform":"translateY("+e+"px)",transform:"translateY("+e+"px)"}):o.removeClass("show-sticky-add-to-cart").css({"-webkit-transform":"","-ms-transform":"",transform:""})},250)),l(".go-to-variables").on("click",function(t){t.preventDefault();var a=0,e=l(".navigation-stick"),s=l("#wpadminbar");e.length&&(a=e.outerHeight()),s.length&&(a+=s.outerHeight()),l("html, body").animate({scrollTop:l(".variations").offset().top-a},250)})}function a(n){var t,r=l(".woocommerce div.product form.cart");if(r.closest(".elementor-add-to-cart").length)l(".elementor.product").removeClass("do-quantity-buttons");else if(n||(n=".qty"),(t=l("div.quantity:not(.buttons-added), td.quantity:not(.buttons-added)").find(n))&&"date"!==t.prop("type")&&"hidden"!==t.prop("type")){if(t.parent().addClass("buttons-added").prepend('<a href="javascript:void(0)" class="minus">-</a>'),t.after('<a href="javascript:void(0)" class="plus">+</a>'),l("input"+n+":not(.product-quantity input"+n+")").each(function(){var t=parseFloat(l(this).attr("min"));t&&0<t&&parseFloat(l(this).val())<t&&l(this).val(t)}),l("body").hasClass("single-product")&&!r.hasClass("grouped_form")){var a=l(".woocommerce form input[type=number].qty");a.on("keyup",function(){var t=l(this).val();a.val(t)})}l(".plus, .minus").unbind("click"),l(".plus, .minus").on("click",function(){var t;t=!l("body").hasClass("single-product")||r.hasClass("grouped_form")||r.hasClass("cart_group")?l(this).closest(".quantity").find(n):l(".plus, .minus").closest(".quantity").find(n);var a=parseFloat(t.val()),e=parseFloat(t.attr("max")),s=parseFloat(t.attr("min")),o=t.attr("step");a&&""!==a&&"NaN"!==a||(a=0),""!==e&&"NaN"!==e||(e=""),""!==s&&"NaN"!==s||(s=0),"any"!==o&&""!==o&&void 0!==o&&"NaN"!==parseFloat(o)||(o=1),l(this).is(".plus")?e&&(e==a||e<a)?t.val(e):t.val(a+parseFloat(o)):s&&(s==a||a<s)?t.val(s):0<a&&t.val(a-parseFloat(o)),t.trigger("change")})}}l(document).on("ready",function(){"use strict";generateWooCommerce.quantityButtons&&a()}),l(document).ajaxComplete(function(){"use strict";generateWooCommerce.quantityButtons&&a()})});
|
Reference in New Issue
Block a user