Current path: home/webdevt/www/wdp/wp-content/themes/quadric/assets/js/modules/
?? Go up: /home/webdevt/www/wdp/wp-content/themes/quadric/assets/js
(function($) {
'use strict';
$(document).ready(function () {
edgtfInitQuantityButtons();
edgtfInitSelect2();
edgtfAddedtoCartButton();
edgtfInitSingleProductLightbox();
});
function edgtfInitQuantityButtons() {
$(document).on( 'click', '.edgtf-quantity-minus, .edgtf-quantity-plus', function(e) {
e.stopPropagation();
var button = $(this),
inputField = button.siblings('.edgtf-quantity-input'),
step = parseFloat(inputField.attr('step')),
max = parseFloat(inputField.attr('max')),
minus = false,
inputValue = parseFloat(inputField.val()),
newInputValue;
if (button.hasClass('edgtf-quantity-minus')) {
minus = true;
}
if (minus) {
newInputValue = inputValue - step;
if (newInputValue >= 1) {
inputField.val(newInputValue);
} else {
inputField.val(1);
}
} else {
newInputValue = inputValue + step;
if ( max === undefined ) {
inputField.val(newInputValue);
} else {
if ( newInputValue >= max ) {
inputField.val(max);
} else {
inputField.val(newInputValue);
}
}
}
inputField.trigger( 'change' );
});
}
function edgtfInitSelect2() {
if ($('.woocommerce-ordering .orderby').length || $('#calc_shipping_country').length || $('.variations select').length ) {
$('.woocommerce-ordering .orderby').select2({
minimumResultsForSearch: Infinity
});
$('#calc_shipping_country').select2();
$('.variations select').select2();
}
}
function edgtfAddedtoCartButton(){
$('body').on("added_to_cart", function( data ) {
$('a.added_to_cart').addClass('edgtf-btn edgtf-btn-outline');
});
}
/*
** Init Product Single Pretty Photo attributes
*/
function edgtfInitSingleProductLightbox() {
var item = $('.edgtf-woocommerce-single-page .edgtf-single-product-images .images .woocommerce-product-gallery__image');
if(item.length) {
item.each(function() {
var thisItem = $(this).children('a');
thisItem.attr('data-rel', 'prettyPhoto[woo_single_pretty_photo]');
if (typeof edgtf.modules.common.edgtfPrettyPhoto === "function") {
edgtf.modules.common.edgtfPrettyPhoto();
}
});
}
}
})(jQuery);