1074 lines
28 KiB
JavaScript
1074 lines
28 KiB
JavaScript
/*
|
|
* @Website: apollotheme.com - prestashop template provider
|
|
* @author Apollotheme <apollotheme@gmail.com>
|
|
* @copyright Apollotheme
|
|
* @description: ApPageBuilder is module help you can build content for your shop
|
|
*/
|
|
/*
|
|
* Custom code goes here.
|
|
* A template should always ship with an empty custom.js
|
|
*/
|
|
//DONGND:: create option for slick slider of modal popup at product page
|
|
var options_modal_product_page = {
|
|
speed: 300,
|
|
dots: false,
|
|
infinite: false,
|
|
slidesToShow: 4,
|
|
slidesToScroll: 1,
|
|
vertical: true,
|
|
verticalSwiping: true,
|
|
responsive: [
|
|
{
|
|
breakpoint: 1200,
|
|
settings: {
|
|
slidesToShow: 3,
|
|
slidesToScroll: 1,
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 992,
|
|
settings: {
|
|
slidesToShow: 2,
|
|
slidesToScroll: 1
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 768,
|
|
settings: {
|
|
slidesToShow: 2,
|
|
slidesToScroll: 1
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 576,
|
|
settings: {
|
|
slidesToShow: 1,
|
|
slidesToScroll: 1
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 480,
|
|
settings: {
|
|
slidesToShow: 2,
|
|
slidesToScroll: 1
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 400,
|
|
settings: {
|
|
slidesToShow: 1,
|
|
slidesToScroll: 1
|
|
}
|
|
}
|
|
]
|
|
};
|
|
|
|
//DONGND:: create option for slick slider of quickview
|
|
var options_quickview = {
|
|
speed: 300,
|
|
dots: false,
|
|
infinite: false,
|
|
slidesToShow: 4,
|
|
slidesToScroll: 1,
|
|
vertical: true,
|
|
verticalSwiping: true,
|
|
responsive: [
|
|
{
|
|
breakpoint: 1200,
|
|
settings: {
|
|
slidesToShow: 4,
|
|
slidesToScroll: 1,
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 992,
|
|
settings: {
|
|
slidesToShow: 3,
|
|
slidesToScroll: 1
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 768,
|
|
settings: {
|
|
slidesToShow: 4,
|
|
slidesToScroll: 1
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 576,
|
|
settings: {
|
|
slidesToShow: 3,
|
|
slidesToScroll: 1
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 480,
|
|
settings: {
|
|
slidesToShow: 2,
|
|
slidesToScroll: 1
|
|
}
|
|
}
|
|
]
|
|
};
|
|
|
|
$( window ).resize(function() {
|
|
//DONGND:: fix zoom, only work at product page
|
|
if (prestashop.page.page_name == 'product')
|
|
restartElevateZoom();
|
|
|
|
//DONGND:: fix lost slider of modal when resize
|
|
if ($('#product-modal .product-images').hasClass('slick-initialized') && $('#product-modal .product-images').height() == 0)
|
|
{
|
|
//DONGND:: setup slide for product thumb (modal)
|
|
$('#product-modal .product-images').slick('unslick');
|
|
$('#product-modal .product-images').hide();
|
|
initSlickProductModal();
|
|
}
|
|
});
|
|
|
|
$(document).ready(function(){
|
|
floatHeader();
|
|
backtotop()
|
|
//check page product only
|
|
if(prestashop.page.page_name == 'product'){
|
|
innitSlickandZoom();
|
|
}
|
|
if (prestashop.page.page_name == 'category'){
|
|
setDefaultListGrid();
|
|
}
|
|
|
|
if(typeof (products_list_functions) != 'undefined')
|
|
{
|
|
for (var i = 0; i < products_list_functions.length; i++) {
|
|
products_list_functions[i]();
|
|
}
|
|
}
|
|
|
|
//DONGND:: update for order page - tab adress, when change adress, block adress change class selected
|
|
$('.address-item .radio-block').click(function(){
|
|
if (!$(this).parents('.address-item').hasClass('selected'))
|
|
{
|
|
$('.address-item.selected').removeClass('selected');
|
|
$(this).parents('.address-item').addClass('selected');
|
|
}
|
|
})
|
|
|
|
//DONGND:: loading quickview
|
|
actionQuickViewLoading();
|
|
|
|
prestashop.on('updateProductList', function() {
|
|
actionQuickViewLoading();
|
|
});
|
|
|
|
prestashop.on('updatedProduct', function () {
|
|
|
|
if ($('.quickview.modal .product-thumb-images').length)
|
|
{
|
|
//DONGND:: run slick slider for product thumb - quickview
|
|
initSlickProductQuickView();
|
|
}
|
|
else if ($('.product-detail .product-thumb-images').length)
|
|
{
|
|
//DONGND:: re-call setup slick when change attribute at product page
|
|
innitSlickandZoom();
|
|
}
|
|
});
|
|
|
|
//DONGND:: display modal by config
|
|
if (typeof $("#content").data('templatemodal') != 'undefined')
|
|
{
|
|
if (!$("#content").data('templatemodal'))
|
|
{
|
|
$('div[data-target="#product-modal"]').hide();
|
|
}
|
|
}
|
|
|
|
//DONGND:: create demo product detail from megamenu
|
|
$('.demo-product-detail a').click(function(e){
|
|
if (!$(this).hasClass('updated'))
|
|
{
|
|
e.preventDefault();
|
|
var current_url = window.location.href;
|
|
if(prestashop.page.page_name == 'product' && current_url.indexOf('.html') >= 0){
|
|
var link_href = $(this).attr('href');
|
|
var layout_key_index = link_href.indexOf('?layout=');
|
|
var layout_key_value = link_href.substring(layout_key_index);
|
|
current_url = current_url.substring(0, current_url.indexOf('.html'));
|
|
var new_url = current_url+'.html'+layout_key_value;
|
|
window.location.href = new_url;
|
|
};
|
|
}
|
|
|
|
});
|
|
});
|
|
|
|
function innitSlickandZoom(){
|
|
if($("#main").hasClass('product-image-thumbs')){
|
|
|
|
//DONGND:: setup slide for product thumb (main)
|
|
$('.product-detail .product-thumb-images').imagesLoaded( function(){
|
|
|
|
if (typeof check_loaded_main_product != 'undefined')
|
|
{
|
|
clearInterval(check_loaded_main_product);
|
|
}
|
|
|
|
check_loaded_main_product = setInterval(function(){
|
|
if($('.product-detail .product-thumb-images').height() > 0)
|
|
{
|
|
|
|
$('.product-detail .product-thumb-images').fadeIn();
|
|
|
|
clearInterval(check_loaded_main_product);
|
|
postion = $("#content").data("templateview");
|
|
//DONGND:: add config for over 1200 extra large
|
|
numberimage = $("#content").data("numberimage");
|
|
numberimage1200 = $("#content").data("numberimage1200");
|
|
numberimage992 = $("#content").data("numberimage992");
|
|
numberimage768 = $("#content").data("numberimage768");
|
|
numberimage576 = $("#content").data("numberimage576");
|
|
numberimage480 = $("#content").data("numberimage480");
|
|
numberimage360 = $("#content").data("numberimage360");
|
|
|
|
if(postion !== 'undefined'){
|
|
initSlickProductThumb(postion, numberimage, numberimage1200, numberimage992, numberimage768, numberimage576, numberimage480, numberimage360);
|
|
}
|
|
|
|
}
|
|
}, 300);
|
|
});
|
|
|
|
//DONGND:: setup slide for product thumb (modal)
|
|
initSlickProductModal();
|
|
|
|
}
|
|
//call action zoom
|
|
applyElevateZoom();
|
|
}
|
|
|
|
function restartElevateZoom(){
|
|
$(".zoomContainer").remove();
|
|
applyElevateZoom();
|
|
}
|
|
|
|
function applyElevateZoom(){
|
|
if($(window).width() <= 991 || $("#content").data("templatezoomtype") == 'none')
|
|
{
|
|
//DONGND:: remove elevateZoom on mobile
|
|
if($('#main').hasClass('product-image-gallery'))
|
|
{
|
|
if ($('img.js-thumb').data('elevateZoom'))
|
|
{
|
|
var ezApi = $('img.js-thumb').data('elevateZoom');
|
|
ezApi.changeState('disable');
|
|
$('img.js-thumb').unbind("touchmove");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ($("#zoom_product").data('elevateZoom'))
|
|
{
|
|
var ezApi = $("#zoom_product").data('elevateZoom');
|
|
ezApi.changeState('disable');
|
|
$("#zoom_product").unbind("touchmove");
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//check if that is gallery, zoom all thumb
|
|
//DONGND:: fix zoom, create config
|
|
var zt = $("#content").data('templatezoomtype');
|
|
var zoom_cursor;
|
|
var zoom_type;
|
|
var scroll_zoom = false;
|
|
var lens_FadeIn = 200;
|
|
var lens_FadeOut = 200;
|
|
var zoomWindow_FadeIn = 200;
|
|
var zoomWindow_FadeOut = 200;
|
|
var zoom_tint = false;
|
|
var zoomWindow_Width = 400;
|
|
var zoomWindow_Height = 400;
|
|
var zoomWindow_Position = 1;
|
|
|
|
if (zt == 'in')
|
|
{
|
|
zoom_cursor = 'crosshair';
|
|
zoom_type = 'inner';
|
|
lens_FadeIn = false;
|
|
lens_FadeOut = false;
|
|
}
|
|
else
|
|
{
|
|
zoom_cursor = 'default';
|
|
zoom_type = 'window';
|
|
zoom_tint = true;
|
|
zoomWindow_Width = $("#content").data('zoomwindowwidth');
|
|
zoomWindow_Height = $("#content").data('zoomwindowheight');
|
|
|
|
if ($("#content").data('zoomposition') == 'right')
|
|
{
|
|
//DONGND:: update position of zoom window with ar language
|
|
if (prestashop.language.is_rtl == 1)
|
|
{
|
|
zoomWindow_Position = 11;
|
|
}
|
|
else
|
|
{
|
|
zoomWindow_Position = 1;
|
|
}
|
|
}
|
|
if ($("#content").data('zoomposition') == 'left')
|
|
{
|
|
//DONGND:: update position of zoom window with ar language
|
|
if (prestashop.language.is_rtl == 1)
|
|
{
|
|
zoomWindow_Position = 1;
|
|
}
|
|
else
|
|
{
|
|
zoomWindow_Position = 11;
|
|
}
|
|
}
|
|
if ($("#content").data('zoomposition') == 'top')
|
|
{
|
|
zoomWindow_Position = 13;
|
|
}
|
|
if ($("#content").data('zoomposition') == 'bottom')
|
|
{
|
|
zoomWindow_Position = 7;
|
|
}
|
|
|
|
if (zt == 'in_scrooll')
|
|
{
|
|
//DONGND:: scroll to zoom does not work on IE
|
|
var ua = window.navigator.userAgent;
|
|
var old_ie = ua.indexOf('MSIE ');
|
|
var new_ie = ua.indexOf('Trident/');
|
|
if (old_ie > 0 || new_ie > 0) // If Internet Explorer, return version number
|
|
{
|
|
scroll_zoom = false;
|
|
}
|
|
else // If another browser, return 0
|
|
{
|
|
scroll_zoom = true;
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
if($('#main').hasClass('product-image-gallery'))
|
|
{
|
|
lens_FadeIn = false;
|
|
lens_FadeOut = false;
|
|
zoomWindow_FadeIn = false;
|
|
zoomWindow_FadeOut = false;
|
|
}
|
|
|
|
var zoom_config = {
|
|
responsive : true,
|
|
cursor: zoom_cursor,
|
|
scrollZoom: scroll_zoom,
|
|
scrollZoomIncrement: 0.1,
|
|
zoomLevel: 1,
|
|
zoomType: zoom_type,
|
|
gallery: 'thumb-gallery',
|
|
lensFadeIn: lens_FadeIn,
|
|
lensFadeOut: lens_FadeOut,
|
|
zoomWindowFadeIn: zoomWindow_FadeIn,
|
|
zoomWindowFadeOut: zoomWindow_FadeOut,
|
|
zoomWindowWidth: zoomWindow_Width,
|
|
zoomWindowHeight: zoomWindow_Height,
|
|
borderColour: '#888',
|
|
borderSize: 2,
|
|
zoomWindowOffetx: 0,
|
|
zoomWindowOffety: 0,
|
|
zoomWindowPosition: zoomWindow_Position,
|
|
tint: zoom_tint,
|
|
};
|
|
|
|
if($('#main').hasClass('product-image-gallery'))
|
|
{
|
|
$('img.js-thumb').each(function(){
|
|
var parent_e = $(this).parent();
|
|
$(this).attr('src', parent_e.data('image'));
|
|
$(this).data('type-zoom', parent_e.data('zoom-image'));
|
|
});
|
|
|
|
if($.fn.elevateZoom !== undefined)
|
|
{
|
|
$('img.js-thumb').elevateZoom(zoom_config);
|
|
//DONGND:: fix click a thumb replace all image and add fancybox
|
|
$('img.js-thumb').bind("click", function(e) {
|
|
var ez = $(this).data('elevateZoom');
|
|
$.fancybox(ez.getGalleryList());
|
|
return false;
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if($.fn.elevateZoom !== undefined)
|
|
{
|
|
$("#zoom_product").elevateZoom(zoom_config);
|
|
|
|
//pass the images to Fancybox
|
|
$("#zoom_product").bind("click", function(e) {
|
|
var ez = $('#zoom_product').data('elevateZoom');
|
|
$.fancybox(ez.getGalleryList());
|
|
return false;
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
function initSlickProductThumb(postion, numberimage, numberimage1200, numberimage992, numberimage768, numberimage576, numberimage480 , numberimage360){
|
|
var vertical = true;
|
|
var verticalSwiping = true;
|
|
//DONGND:: update for rtl
|
|
var slick_rtl = false;
|
|
|
|
if(postion == "bottom"){
|
|
vertical = false;
|
|
verticalSwiping = false;
|
|
}
|
|
|
|
if(postion == 'none'){
|
|
vertical = false;
|
|
verticalSwiping = false;
|
|
numberimage = numberimage1200 = numberimage992 = numberimage768 = numberimage576 = numberimage480 = numberimage360 = 1;
|
|
}
|
|
|
|
//DONGND:: update for rtl
|
|
if (!vertical && prestashop.language.is_rtl == 1)
|
|
{
|
|
slick_rtl = true;
|
|
}
|
|
|
|
var slider = $('#thumb-gallery');
|
|
|
|
slider.slick({
|
|
speed: 300,
|
|
dots: false,
|
|
infinite: false,
|
|
slidesToShow: numberimage,
|
|
vertical: vertical,
|
|
verticalSwiping: verticalSwiping,
|
|
slidesToScroll: 1,
|
|
rtl: slick_rtl,
|
|
responsive: [
|
|
{
|
|
breakpoint: 1200,
|
|
settings: {
|
|
slidesToShow: numberimage1200,
|
|
slidesToScroll: 1,
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 992,
|
|
settings: {
|
|
slidesToShow: numberimage992,
|
|
slidesToScroll: 1,
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 768,
|
|
settings: {
|
|
slidesToShow: numberimage768,
|
|
slidesToScroll: 1
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 576,
|
|
settings: {
|
|
slidesToShow: numberimage576,
|
|
slidesToScroll: 1
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 480,
|
|
settings: {
|
|
slidesToShow: numberimage480,
|
|
slidesToScroll: 1
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 360,
|
|
settings: {
|
|
slidesToShow: numberimage360,
|
|
slidesToScroll: 1
|
|
}
|
|
}
|
|
]
|
|
});
|
|
$("#thumb-gallery").show();
|
|
|
|
if(postion == 'none')
|
|
{
|
|
var slickInstance = slider[0];
|
|
var slides = $(slickInstance.slick.$slides);
|
|
var positionStart = findPosition(slides);
|
|
var slideCount = slickInstance.slick.slideCount;
|
|
|
|
//DONGND:: update slick for case without thubms
|
|
if ((positionStart + 1) == slideCount){
|
|
$('.arrows-product-fake .slick-next').addClass('slick-disabled');
|
|
}else if(positionStart == 0){
|
|
$('.arrows-product-fake .slick-prev').addClass('slick-disabled');
|
|
}
|
|
|
|
// active image first load
|
|
slider.slick('slickGoTo', positionStart);
|
|
|
|
$('.arrows-product-fake .slick-next').on( "click", function() {
|
|
if (!$(this).hasClass('slick-disabled'))
|
|
{
|
|
$('.arrows-product-fake .slick-prev').removeClass('slick-disabled');
|
|
var positionCurrent = findPosition(slides);
|
|
if ((positionCurrent + 1) < slideCount) {
|
|
$(slides[positionCurrent]).removeClass('active');
|
|
$(slides[positionCurrent + 1]).addClass('active');
|
|
$(slides[positionCurrent + 1]).find('img').trigger("click");
|
|
slider.slick('slickNext');
|
|
if((positionCurrent + 1) == (slideCount - 1)){
|
|
$(this).addClass('slick-disabled');
|
|
}
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
$('.arrows-product-fake .slick-prev').on( "click", function() {
|
|
if (!$(this).hasClass('slick-disabled'))
|
|
{
|
|
$('.arrows-product-fake .slick-next').removeClass('slick-disabled');
|
|
var positionCurrent = findPosition(slides);
|
|
if ((positionCurrent) > 0) {
|
|
$(slides[positionCurrent]).removeClass('active');
|
|
$(slides[positionCurrent - 1]).addClass('active');
|
|
$(slides[positionCurrent - 1]).find('img').trigger("click");
|
|
slider.slick('slickPrev');
|
|
if((positionCurrent - 1) == 0){
|
|
$(this).addClass('slick-disabled');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function findPosition(slides){
|
|
var position;
|
|
for (var i = 0; i < slides.length; i++) {
|
|
if ($(slides[i]).hasClass('active')) {
|
|
position = $(slides[i]).data('slick-index');
|
|
return position;
|
|
}
|
|
}
|
|
}
|
|
|
|
//DONGND:: loading quickview
|
|
function actionQuickViewLoading()
|
|
{
|
|
$('.quick-view').click(function(){
|
|
if (!$(this).hasClass('active'))
|
|
{
|
|
$(this).addClass('active');
|
|
$(this).find('.leo-quickview-bt-loading').css({'display':'block'});
|
|
$(this).find('.leo-quickview-bt-content').hide();
|
|
if (typeof check_active_quickview != 'undefined')
|
|
{
|
|
clearInterval(check_active_quickview);
|
|
}
|
|
|
|
check_active_quickview = setInterval(function(){
|
|
if($('.quickview.modal').length)
|
|
{
|
|
$('.quickview.modal').on('hide.bs.modal', function (e) {
|
|
$('.quick-view.active').find('.leo-quickview-bt-loading').hide();
|
|
$('.quick-view.active').find('.leo-quickview-bt-content').show();
|
|
$('.quick-view.active').removeClass('active');
|
|
});
|
|
clearInterval(check_active_quickview);
|
|
|
|
//DONGND:: run slick for product thumb - quickview
|
|
initSlickProductQuickView();
|
|
}
|
|
|
|
}, 300);
|
|
|
|
}
|
|
})
|
|
}
|
|
|
|
$(document).on('click', '.leo_grid', function(e){
|
|
e.preventDefault();
|
|
$('#js-product-list .product_list').removeClass('list');
|
|
$('#js-product-list .product_list').addClass('grid');
|
|
|
|
$(this).parent().find('.leo_list').removeClass('selected');
|
|
$(this).addClass('selected');
|
|
|
|
var configName = LEO_COOKIE_THEME +'_grid_list';
|
|
$.cookie(configName, 'grid', {expires: 1, path: '/'});
|
|
});
|
|
|
|
$(document).on('click', '.leo_list', function(e){
|
|
e.preventDefault();
|
|
$('#js-product-list .product_list').removeClass('grid');
|
|
$('#js-product-list .product_list').addClass('list');
|
|
|
|
$(this).parent().find('.leo_grid').removeClass('selected');
|
|
$(this).addClass('selected');
|
|
|
|
var configName = LEO_COOKIE_THEME +'_grid_list';
|
|
$.cookie(configName, 'list', {expires: 1, path: '/'});
|
|
});
|
|
|
|
function setDefaultListGrid()
|
|
{
|
|
if ($.cookie(LEO_COOKIE_THEME +'_grid_list') == 'grid')
|
|
{
|
|
$('.leo_grid').trigger('click');
|
|
}
|
|
if ($.cookie(LEO_COOKIE_THEME +'_grid_list') == 'list')
|
|
{
|
|
$('.leo_list').trigger('click');
|
|
}
|
|
}
|
|
|
|
function processFloatHeader(headerAdd, scroolAction){
|
|
//DONGND:: hide search result when enable float header
|
|
if ($('.ac_results').length)
|
|
{
|
|
$('.ac_results').hide();
|
|
}
|
|
|
|
if(headerAdd){
|
|
$("#header").addClass( "navbar-fixed-top" );
|
|
var hideheight = $("#header").height()+120;
|
|
$("#page").css( "padding-top", $("#header").height() );
|
|
setTimeout(function(){
|
|
$("#page").css( "padding-top", $("#header").height() );
|
|
},200);
|
|
}else{
|
|
$("#header").removeClass( "navbar-fixed-top" );
|
|
$("#page").css( "padding-top", '');
|
|
}
|
|
|
|
var pos = $(window).scrollTop();
|
|
if( scroolAction && pos >= hideheight ){
|
|
$(".header-nav").addClass('hide-bar');
|
|
$(".hide-bar").css( "margin-top", - $(".header-nav").height() );
|
|
$("#header").addClass("mini-navbar");
|
|
}else {
|
|
$(".header-nav").removeClass('hide-bar');
|
|
$(".header-nav").css( "margin-top", 0 );
|
|
$("#header").removeClass("mini-navbar");
|
|
}
|
|
}
|
|
|
|
//Float Menu
|
|
function floatHeader(){
|
|
if (!$("body").hasClass("keep-header") || $(window).width() <= 990){
|
|
return;
|
|
}
|
|
|
|
$(window).resize(function(){
|
|
if ($(window).width() <= 990)
|
|
{
|
|
processFloatHeader(0,0);
|
|
}
|
|
else if ($(window).width() > 990)
|
|
{
|
|
if ($("body").hasClass("keep-header"))
|
|
processFloatHeader(1,1);
|
|
}
|
|
});
|
|
var headerScrollTimer;
|
|
|
|
$(window).scroll(function() {
|
|
if(headerScrollTimer) {
|
|
window.clearTimeout(headerScrollTimer);
|
|
}
|
|
|
|
headerScrollTimer = window.setTimeout(function() {
|
|
if (!$("body").hasClass("keep-header")) return;
|
|
if($(window).width() > 990){
|
|
processFloatHeader(1,1);
|
|
}
|
|
}, 100);
|
|
});
|
|
}
|
|
|
|
// Back to top
|
|
function backtotop(){
|
|
$("#back-top").hide();
|
|
$(window).scroll(function () {
|
|
if ($(this).scrollTop() > 100) {
|
|
$('#back-top').fadeIn();
|
|
} else {
|
|
$('#back-top').fadeOut();
|
|
}
|
|
});
|
|
|
|
// scroll body to 0px on click
|
|
$('#back-top a').click(function () {
|
|
$('body,html').animate({
|
|
scrollTop: 0
|
|
}, 800);
|
|
return false;
|
|
});
|
|
}
|
|
|
|
//DONGND:: build slick slider for quickview
|
|
function initSlickProductQuickView(){
|
|
$('.quickview.modal .product-thumb-images').imagesLoaded( function(){
|
|
if (typeof check_loaded_thumb_quickview != 'undefined')
|
|
{
|
|
clearInterval(check_loaded_thumb_quickview);
|
|
}
|
|
check_loaded_thumb_quickview = setInterval(function(){
|
|
if($('.quickview.modal .product-thumb-images').height() > 0)
|
|
{
|
|
$('.quickview.modal .product-thumb-images').fadeIn();
|
|
|
|
clearInterval(check_loaded_thumb_quickview);
|
|
$('.quickview.modal .product-thumb-images').slick(options_quickview);
|
|
}
|
|
}, 300);
|
|
});
|
|
|
|
}
|
|
|
|
//DONGND:: build slick slider for modal - product page
|
|
function initSlickProductModal(){
|
|
$('#product-modal .product-images').imagesLoaded( function(){
|
|
if (typeof check_loaded_thumb_modal != 'undefined')
|
|
{
|
|
clearInterval(check_loaded_thumb_modal);
|
|
}
|
|
check_loaded_thumb_modal = setInterval(function(){
|
|
if($('#product-modal .product-images').height() > 0)
|
|
{
|
|
$('#product-modal .product-images').fadeIn();
|
|
|
|
clearInterval(check_loaded_thumb_modal);
|
|
$('#product-modal .product-images').slick(options_modal_product_page);
|
|
}
|
|
}, 300);
|
|
});
|
|
}
|
|
|
|
|
|
//DONGND: fix base prestashop
|
|
$(document).ready(function(){
|
|
//DONGND: remove css inline of label
|
|
$('.product-flag').removeAttr('style');
|
|
prestashop.on('updateProductList', function() {
|
|
//DONGND: remove css inline of label
|
|
$('.product-flag').removeAttr('style');
|
|
});
|
|
})
|
|
//Fix translate button choose file to upload: change "Choose file" to choosefile_text
|
|
//Fix filter (category page) does not work on IE change dataset.searchUrl to getAttribute('data-search-url')
|
|
|
|
const menuElements = document.querySelectorAll('.nav.megamenu.horizontal li');
|
|
const bodyContainer = document.querySelector('body#index');
|
|
|
|
const removeActive = () => {
|
|
for(const menuElement of menuElements) {
|
|
menuElement.classList.remove('active');
|
|
}
|
|
}
|
|
|
|
window.addEventListener('DOMContentLoaded', (event) => {
|
|
if(bodyContainer != null) {
|
|
removeActive();
|
|
}
|
|
|
|
const labelNope = document.querySelector('.PM_ASBlockOutputVertical label[for="as4c_9_116"] a');
|
|
if(labelNope) {
|
|
labelNope.innerHTML = 'nie';
|
|
}
|
|
});
|
|
|
|
|
|
|
|
$(document).on('change', '.product-variants [data-product-attribute]', function (event) {
|
|
var query = $(event.target.form).serialize() + '&ajax=1&action=productrefresh';
|
|
var actionURL = $(event.target.form).attr('action');
|
|
$.post(actionURL, query, null, 'json').then(function (resp) {
|
|
var productUrl = resp.productUrl;
|
|
$.post(productUrl, {ajax: '1',action: 'refresh' }, null, 'json').then(function (resp) {
|
|
console.log('test');
|
|
window.location.href = productUrl;
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
|
|
// const rodzajLabel = document.querySelector('.category-id-45 .PM_ASBlockOutputVertical .PM_ASCriterionsGroup:first-child .PM_ASCriterionsGroupTitle span');
|
|
// if(rodzajLabel) {
|
|
// console.log(rodzajLabel);
|
|
// rodzajLabel.innerHTML = 'Producent';
|
|
// }
|
|
|
|
const aliorCalc = document.querySelector('#raty_alior');
|
|
if(aliorCalc) {
|
|
const productPrice = document.querySelector('.product-prices .current-price span[itemprop="price"]').getAttribute('content');
|
|
let aliorUrl = aliorCalc.getAttribute('href');
|
|
aliorUrl += '?cartValue=' + productPrice;
|
|
aliorCalc.setAttribute('href', aliorUrl);
|
|
}
|
|
|
|
// const scrollButton = document.querySelector('.js-scroll-trigger');
|
|
// if(scrollButton) {
|
|
// console.log('scroll');
|
|
// var scroll = new SmoothScroll('.js-scroll-trigger', {
|
|
// offset: 240,
|
|
// });
|
|
// }
|
|
|
|
// $(document).ready(function(){
|
|
// if($(".block-promo .cart-voucher").length) {
|
|
// $(".block-promo .cart-voucher .promo-code-button.display-promo .collapse-button").on("click", function(e){
|
|
// e.preventDefault();
|
|
// $("#promo-code").addClass('in')
|
|
// })
|
|
// }
|
|
// })
|
|
|
|
$(document).ready(function(){
|
|
if($("#buy-by-phone-popup").length) {
|
|
var buyByPhonePopup = $("#buy-by-phone-popup")
|
|
|
|
$('#buy_by_phone_btn').on('click', function(e){
|
|
$("#buy-by-phone-popup").find('input[name="buy-by-phone-name"]').val('');
|
|
$("#buy-by-phone-popup").find('input[name="buy-by-phone-phone"]').val('');
|
|
$("#buy-by-phone-popup").find('input[name="contact-time"]').val('');
|
|
$("#buy-by-phone-popup").find('input[name="product-name"]').val('');
|
|
$("#buy-by-phone-popup").find('input[name="shipping-address"]').val('');
|
|
$("#buy-by-phone-popup").find('input[name="phone-for-courier"]').val('');
|
|
$("#buy-by-phone-popup").find('input[name="email"]').val('');
|
|
$("#buy-by-phone-popup").find('input[name="comments-to-order"]').val('');
|
|
$("#buy-by-phone-popup .popup-footer").empty();
|
|
$("#buy-by-phone-popup").find('input[name="polityka"]').prop('checked', false);
|
|
|
|
buyByPhonePopup.addClass('active')
|
|
})
|
|
|
|
$(".close-popup", buyByPhonePopup).on('click', function(e){
|
|
e.preventDefault()
|
|
buyByPhonePopup.removeClass('active')
|
|
})
|
|
$(".close-popup-alert", buyByPhonePopup).on('click', function(e){
|
|
e.preventDefault()
|
|
$('.popup-alert', buyByPhonePopup).removeClass('active')
|
|
})
|
|
|
|
$("#buy-by-phone-form-btn").on('click', function(e){
|
|
e.preventDefault();
|
|
|
|
$("#buy-by-phone-popup .popup-footer").empty();
|
|
|
|
var name = $("#buy-by-phone-popup").find('input[name="buy-by-phone-name"]').val();
|
|
var phone = $("#buy-by-phone-popup").find('input[name="buy-by-phone-phone"]').val();
|
|
var contact_time = $("#buy-by-phone-popup").find('input[name="contact-time"]').val();
|
|
var politics = $("#buy-by-phone-popup").find('input[name="polityka"]').prop('checked');
|
|
|
|
if ( !phone)
|
|
{
|
|
popupAlert('<p>Proszę wypełnić wymagane pola formularza</p>')
|
|
return;
|
|
}
|
|
if ( !politics)
|
|
{
|
|
popupAlert('<p>Proszę wypełnić wymagane pola formularza</p>')
|
|
return;
|
|
}
|
|
|
|
$(this).prop('disabled', true);
|
|
|
|
var formData = $("#buy-by-phone-form").serialize();
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/buy-by-phone.php',
|
|
data: formData,
|
|
success: function(response) {
|
|
popupAlert(response)
|
|
$('#buy-by-phone-form-btn').prop('disabled', false);
|
|
setTimeout(function() {
|
|
buyByPhonePopup.removeClass('active')
|
|
},5000)
|
|
},
|
|
error: function() {
|
|
popupAlert('<p>Wystąpił błąd podczas wysyłania danych</p>')
|
|
$('#buy-by-phone-form-btn').prop('disabled', false);
|
|
}
|
|
});
|
|
})
|
|
|
|
function popupAlert(text) {
|
|
$('.popup-alert', buyByPhonePopup).addClass('active')
|
|
$('.popup-alert .popup-alert-data', buyByPhonePopup).empty();
|
|
$('.popup-alert .popup-alert-data', buyByPhonePopup).append(text);
|
|
setTimeout(function() {
|
|
$('.popup-alert', buyByPhonePopup).removeClass('active')
|
|
},3000)
|
|
}
|
|
}
|
|
})
|
|
|
|
$(document).ready(function(){
|
|
$('.acc_component li .acc_head').on('click', function(e){
|
|
var $currentItem = $(this).parent();
|
|
|
|
$('.acc_component li').not($currentItem).removeClass('active').find('.acc_body').slideUp(250);
|
|
|
|
$currentItem.toggleClass('active');
|
|
$currentItem.find('.acc_body').slideToggle(250);
|
|
})
|
|
})
|
|
|
|
|
|
$(document).ready(function(){
|
|
$('body').on('click', '#franczyza_form button.send-form', function(e){
|
|
e.preventDefault();
|
|
|
|
var form_name = $('#franczyza_form input[name="name"]').val();
|
|
var form_email = $('#franczyza_form input[name="email"]').val();
|
|
var form_phone = $('#franczyza_form input[name="phone"]').val();
|
|
var form_marketing = $('#franczyza_form input[name="marketing"]').is(':checked');
|
|
var form_location = $('#franczyza_form input[name="location"]').val();
|
|
|
|
if(form_name != '' && form_email != '' && form_phone != '' && form_marketing != ''){
|
|
$.ajax({
|
|
type: 'POST',
|
|
cache: false,
|
|
url: '/franczyza-contact.php',
|
|
data: {
|
|
form_name: form_name,
|
|
form_email: form_email,
|
|
form_phone: form_phone,
|
|
form_marketing: form_marketing,
|
|
form_location: form_location
|
|
},
|
|
beforeSend: function() {
|
|
$('#franczyza_form .form-info').empty()
|
|
$('#franczyza_form .loader').show();
|
|
$('#franczyza_form button.send-form').prop('disabled', true);
|
|
$('#franczyza_form button.send-form').hide();
|
|
},
|
|
|
|
success: function( data ) {
|
|
response = jQuery.parseJSON( data );
|
|
|
|
$('#franczyza_form button.send-form').prop('disabled', false);
|
|
$('#franczyza_form .loader').hide();
|
|
$('#franczyza_form button.send-form').show();
|
|
$('#franczyza_form .form-info').html(`<p class="${response.status}">${response.message}</p>`)
|
|
},
|
|
})
|
|
} else {
|
|
$('#franczyza_form .form-info').html(`<p class="error">Proszę wypełnić wszystkie wymagane pola w formularzu</p>`)
|
|
}
|
|
})
|
|
})
|
|
|
|
$(document).ready(function(){
|
|
if($("#box-accessories-slider").length){
|
|
var accessoriesSlider = $("#box-accessories-slider")
|
|
var accessoriesVisible = false;
|
|
|
|
$("#box-product-accessories .buy-protector-btn").on('click', function() {
|
|
if (!accessoriesVisible) {
|
|
$("#box-accessories-slider").slideDown();
|
|
accessoriesSlider.slick({
|
|
infinite: true,
|
|
slidesToShow: 2,
|
|
slidesToScroll: 1
|
|
});
|
|
accessoriesVisible = true;
|
|
} else {
|
|
$("#box-accessories-slider").slideUp();
|
|
accessoriesSlider.slick('unslick');
|
|
accessoriesVisible = false;
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
$(document).ready(function(){
|
|
if($("#featured-products-box").length){
|
|
var featuredSlider = $("#featured-products-box")
|
|
|
|
$('.featured-products-box-slider', featuredSlider).slick({
|
|
infinite: false,
|
|
slidesToShow: 4,
|
|
slidesToScroll: 4,
|
|
responsive: [
|
|
{
|
|
breakpoint: 992,
|
|
settings: {
|
|
slidesToShow: 3,
|
|
slidesToScroll: 3,
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 768,
|
|
settings: {
|
|
slidesToShow: 2,
|
|
slidesToScroll: 2,
|
|
}
|
|
},
|
|
{
|
|
breakpoint: 480,
|
|
settings: {
|
|
slidesToShow: 1,
|
|
slidesToScroll: 1,
|
|
}
|
|
},
|
|
]
|
|
})
|
|
}
|
|
})
|
|
|
|
$(document).ready(function(){
|
|
var scrollPosition = $(window).scrollTop()
|
|
var headerNav = $('#header');
|
|
|
|
$(window).scroll(function (event) {
|
|
scrollPosition = $(window).scrollTop();
|
|
|
|
if(scrollPosition > 0) {
|
|
$(headerNav).addClass('fixed');
|
|
} else {
|
|
$(headerNav).removeClass('fixed');
|
|
}
|
|
})
|
|
})
|
|
|
|
$(document).ready(function () {
|
|
$('.nav-item.parent.dropdown').on('mouseenter', function () {
|
|
var $submenu = $(this).find('.dropdown-menu');
|
|
|
|
if ($submenu.length) {
|
|
$submenu.css({ left: '', right: '', transform: '' });
|
|
|
|
var submenuRect = $submenu[0].getBoundingClientRect();
|
|
var windowWidth = $(window).width();
|
|
|
|
if (submenuRect.right > windowWidth) {
|
|
$submenu.attr('style', 'left: 50% !important; right: auto !important; transform: translateX(-50%) !important;');
|
|
} else if (submenuRect.left < 0) {
|
|
$submenu.attr('style', 'left: 50% !important; right: auto !important; transform: translateX(-50%) !important;');
|
|
} else {
|
|
$submenu.css({ left: '', right: '', transform: '' });
|
|
}
|
|
}
|
|
});
|
|
}); |