| @@ -1,140 +1,151 @@ | ||
| 1 | 1 | jQuery(document).ready(function ($) { |
| 2 | - if ($('.pcp-carousel-wrapper').length > 0) { | |
| 3 | - $('.pcp-carousel-wrapper').each(function () { | |
| 4 | - var pcp_container = $(this), | |
| 5 | - pcp_container_id = pcp_container.attr('id'), | |
| 6 | - pcpCarousel = $('#' + pcp_container_id + ' .sp-pcp-carousel'), | |
| 7 | - pcpCarouselData = pcpCarousel.data('carousel'); | |
| 8 | - if (pcpCarousel.length > 0) { | |
| 9 | - // Carousel Swiper for Standard mode. | |
| 10 | - var pcpSwiper = new Swiper('#' + pcp_container_id + ' .sp-pcp-carousel', { | |
| 11 | - speed: pcpCarouselData.speed, | |
| 12 | - slidesPerView: pcpCarouselData.slidesPerView.mobile, | |
| 13 | - spaceBetween: pcpCarouselData.spaceBetween, | |
| 14 | - loop: pcpCarouselData.loop, | |
| 15 | - loopFillGroupWithBlank: true, | |
| 16 | - autoHeight: pcpCarouselData.autoHeight, | |
| 17 | - simulateTouch: pcpCarouselData.simulateTouch, | |
| 18 | - freeMode: pcpCarouselData.freeMode, | |
| 19 | - allowTouchMove: pcpCarouselData.allowTouchMove, | |
| 20 | - centeredSlides: pcpCarouselData.center_mode, | |
| 21 | - mousewheel: pcpCarouselData.slider_mouse_wheel, | |
| 22 | - lazy: pcpCarouselData.lazy, | |
| 23 | - //grabCursor: true, | |
| 24 | - pagination: | |
| 25 | - pcpCarouselData.pagination == true | |
| 26 | - ? { | |
| 27 | - el: '.swiper-pagination', | |
| 28 | - clickable: true, | |
| 29 | - dynamicBullets: pcpCarouselData.dynamicBullets, | |
| 30 | - renderBullet: function (index, className) { | |
| 31 | - if (pcpCarouselData.bullet_types == 'number') { | |
| 32 | - return ( | |
| 33 | - '<span class="' + | |
| 34 | - className + | |
| 35 | - '">' + | |
| 36 | - (index + 1) + | |
| 37 | - '</span>' | |
| 38 | - ) | |
| 39 | - } else { | |
| 40 | - return '<span class="' + className + '"></span>' | |
| 41 | - } | |
| 42 | - } | |
| 43 | - } | |
| 44 | - : false, | |
| 45 | - autoplay: { | |
| 46 | - delay: pcpCarouselData.autoplay_speed | |
| 47 | - }, | |
| 48 | - navigation: | |
| 49 | - pcpCarouselData.navigation == true | |
| 50 | - ? { | |
| 51 | - nextEl: '.pcp-button-next', | |
| 52 | - prevEl: '.pcp-button-prev' | |
| 53 | - } | |
| 54 | - : false, | |
| 55 | - breakpoints: { | |
| 56 | - 576: { | |
| 57 | - slidesPerView: pcpCarouselData.slidesPerView.mobile_landscape, | |
| 58 | - navigation: | |
| 59 | - pcpCarouselData.navigation_mobile == true | |
| 60 | - ? { | |
| 61 | - nextEl: '.pcp-button-next', | |
| 62 | - prevEl: '.pcp-button-prev' | |
| 63 | - } | |
| 64 | - : false, | |
| 65 | - pagination: | |
| 66 | - pcpCarouselData.pagination_mobile == true | |
| 67 | - ? { | |
| 68 | - el: '.swiper-pagination', | |
| 69 | - clickable: true, | |
| 70 | - dynamicBullets: pcpCarouselData.dynamicBullets, | |
| 71 | - renderBullet: function (index, className) { | |
| 72 | - if (pcpCarouselData.bullet_types == 'number') { | |
| 73 | - return ( | |
| 74 | - '<span class="' + | |
| 75 | - className + | |
| 76 | - '">' + | |
| 77 | - (index + 1) + | |
| 78 | - '</span>' | |
| 79 | - ) | |
| 80 | - } else { | |
| 81 | - return '<span class="' + className + '"></span>' | |
| 82 | - } | |
| 83 | - } | |
| 84 | - } | |
| 85 | - : false | |
| 86 | - }, | |
| 87 | - 768: { | |
| 88 | - slidesPerView: pcpCarouselData.slidesPerView.tablet, | |
| 89 | - }, | |
| 90 | - 992: { | |
| 91 | - slidesPerView: pcpCarouselData.slidesPerView.desktop, | |
| 92 | - }, | |
| 93 | - 1200: { | |
| 94 | - slidesPerView: pcpCarouselData.slidesPerView.lg_desktop, | |
| 95 | - }, | |
| 96 | - }, | |
| 97 | - fadeEffect: { | |
| 98 | - crossFade: true | |
| 99 | - }, | |
| 100 | - ally: { | |
| 101 | - enabled: pcpCarouselData.enabled, | |
| 102 | - prevSlideMessage: pcpCarouselData.prevSlideMessage, | |
| 103 | - nextSlideMessage: pcpCarouselData.nextSlideMessage, | |
| 104 | - firstSlideMessage: pcpCarouselData.firstSlideMessage, | |
| 105 | - lastSlideMessage: pcpCarouselData.lastSlideMessage, | |
| 106 | - paginationBulletMessage: pcpCarouselData.paginationBulletMessage | |
| 107 | - }, | |
| 108 | - keyboard: { | |
| 109 | - enabled: true | |
| 110 | - } | |
| 111 | - }) | |
| 112 | - if (pcpCarouselData.autoplay === false) { | |
| 113 | - pcpSwiper.autoplay.stop() | |
| 114 | - } | |
| 115 | - if (pcpCarouselData.stop_onHover && pcpCarouselData.autoplay) { | |
| 116 | - $(pcpCarousel).on({ | |
| 117 | - mouseenter: function () { | |
| 118 | - pcpSwiper.autoplay.stop(); | |
| 119 | - }, | |
| 120 | - mouseleave: function () { | |
| 121 | - pcpSwiper.autoplay.start(); | |
| 122 | - } | |
| 123 | - }); | |
| 124 | - } | |
| 125 | - $(window).on('resize', function () { | |
| 126 | - pcpSwiper.update() | |
| 127 | - }) | |
| 128 | - $(window).trigger("resize") | |
| 129 | - } | |
| 130 | - }) | |
| 131 | - } | |
| 132 | - /* Preloader js */ | |
| 133 | - $(document).ready(function () { | |
| 134 | - $('.sp-pcp-section').each(function () { | |
| 135 | - var pcp_container = $(this).attr('id'); | |
| 136 | - var PCP_Wrapper_ID = '#' + pcp_container; | |
| 137 | - $(".pcp-preloader", PCP_Wrapper_ID).css({ "backgroundImage": "none", "visibility": "hidden" }); | |
| 138 | - }) | |
| 139 | - }); | |
| 2 | + if ($('.sp-pcp-container').length > 0) { | |
| 3 | + $('.sp-pcp-container').each(function () { | |
| 4 | + | |
| 5 | + var pcp_container = $(this), | |
| 6 | + pcp_container_id = pcp_container.attr('id'), | |
| 7 | + PCP_Wrapper_ID = '#' + pcp_container_id, | |
| 8 | + // pc_sid = $(PCP_Wrapper_ID).data('sid'), // The Shortcode ID. | |
| 9 | + pcpCarousel = $('#' + pcp_container_id + ' .sp-pcp-carousel'), | |
| 10 | + /* pcpfilter = $('#' + pcp_container_id + '.pcp-filter-wrapper'), | |
| 11 | + ajaxurl = sppcp.ajaxurl, | |
| 12 | + nonce = sppcp.nonce, */ | |
| 13 | + pcpCarouselData = pcpCarousel.data('carousel'); | |
| 14 | + if (pcpCarousel.length > 0) { | |
| 15 | + // Carousel Swiper for Standard mode. | |
| 16 | + var pcpSwiper = new Swiper('#' + pcp_container_id + ' .sp-pcp-carousel', { | |
| 17 | + speed: pcpCarouselData.speed, | |
| 18 | + slidesPerView: pcpCarouselData.slidesPerView.mobile, | |
| 19 | + spaceBetween: pcpCarouselData.spaceBetween, | |
| 20 | + loop: pcpCarouselData.loop, | |
| 21 | + loopFillGroupWithBlank: true, | |
| 22 | + autoHeight: pcpCarouselData.autoHeight, | |
| 23 | + simulateTouch: pcpCarouselData.simulateTouch, | |
| 24 | + allowTouchMove: pcpCarouselData.allowTouchMove, | |
| 25 | + centeredSlides: pcpCarouselData.center_mode, | |
| 26 | + mousewheel: pcpCarouselData.slider_mouse_wheel, | |
| 27 | + lazy: pcpCarouselData.lazy, | |
| 28 | + //grabCursor: true, | |
| 29 | + pagination: | |
| 30 | + pcpCarouselData.pagination == true | |
| 31 | + ? { | |
| 32 | + el: '.swiper-pagination', | |
| 33 | + clickable: true, | |
| 34 | + dynamicBullets: pcpCarouselData.dynamicBullets, | |
| 35 | + renderBullet: function (index, className) { | |
| 36 | + if (pcpCarouselData.bullet_types == 'number') { | |
| 37 | + return ( | |
| 38 | + '<span class="' + | |
| 39 | + className + | |
| 40 | + '">' + | |
| 41 | + (index + 1) + | |
| 42 | + '</span>' | |
| 43 | + ) | |
| 44 | + } else { | |
| 45 | + return '<span class="' + className + '"></span>' | |
| 46 | + } | |
| 47 | + } | |
| 48 | + } | |
| 49 | + : false, | |
| 50 | + autoplay: { | |
| 51 | + delay: pcpCarouselData.autoplay_speed | |
| 52 | + }, | |
| 53 | + navigation: | |
| 54 | + pcpCarouselData.navigation == true | |
| 55 | + ? { | |
| 56 | + nextEl: '.pcp-button-next', | |
| 57 | + prevEl: '.pcp-button-prev' | |
| 58 | + } | |
| 59 | + : false, | |
| 60 | + breakpoints: { | |
| 61 | + 576: { | |
| 62 | + slidesPerView: pcpCarouselData.slidesPerView.mobile_landscape, | |
| 63 | + navigation: | |
| 64 | + pcpCarouselData.navigation_mobile == true | |
| 65 | + ? { | |
| 66 | + nextEl: '.pcp-button-next', | |
| 67 | + prevEl: '.pcp-button-prev' | |
| 68 | + } | |
| 69 | + : false, | |
| 70 | + pagination: | |
| 71 | + pcpCarouselData.pagination_mobile == true | |
| 72 | + ? { | |
| 73 | + el: '.swiper-pagination', | |
| 74 | + clickable: true, | |
| 75 | + dynamicBullets: pcpCarouselData.dynamicBullets, | |
| 76 | + renderBullet: function (index, className) { | |
| 77 | + if (pcpCarouselData.bullet_types == 'number') { | |
| 78 | + return ( | |
| 79 | + '<span class="' + | |
| 80 | + className + | |
| 81 | + '">' + | |
| 82 | + (index + 1) + | |
| 83 | + '</span>' | |
| 84 | + ) | |
| 85 | + } else { | |
| 86 | + return '<span class="' + className + '"></span>' | |
| 87 | + } | |
| 88 | + } | |
| 89 | + } | |
| 90 | + : false | |
| 91 | + }, | |
| 92 | + 768: { | |
| 93 | + slidesPerView: pcpCarouselData.slidesPerView.tablet, | |
| 94 | + }, | |
| 95 | + 992: { | |
| 96 | + slidesPerView: pcpCarouselData.slidesPerView.desktop, | |
| 97 | + }, | |
| 98 | + 1200: { | |
| 99 | + slidesPerView: pcpCarouselData.slidesPerView.lg_desktop, | |
| 100 | + }, | |
| 101 | + }, | |
| 102 | + fadeEffect: { | |
| 103 | + crossFade: true | |
| 104 | + }, | |
| 105 | + ally: { | |
| 106 | + enabled: pcpCarouselData.enabled, | |
| 107 | + prevSlideMessage: pcpCarouselData.prevSlideMessage, | |
| 108 | + nextSlideMessage: pcpCarouselData.nextSlideMessage, | |
| 109 | + firstSlideMessage: pcpCarouselData.firstSlideMessage, | |
| 110 | + lastSlideMessage: pcpCarouselData.lastSlideMessage, | |
| 111 | + paginationBulletMessage: pcpCarouselData.paginationBulletMessage | |
| 112 | + }, | |
| 113 | + keyboard: { | |
| 114 | + enabled: true | |
| 115 | + } | |
| 116 | + }) | |
| 117 | + if (pcpCarouselData.autoplay === false) { | |
| 118 | + pcpSwiper.autoplay.stop() | |
| 119 | + } | |
| 120 | + if (pcpCarouselData.stop_onHover && pcpCarouselData.autoplay) { | |
| 121 | + $(pcpCarousel).hover( | |
| 122 | + function () { | |
| 123 | + pcpSwiper.autoplay.stop() | |
| 124 | + }, | |
| 125 | + function () { | |
| 126 | + pcpSwiper.autoplay.start() | |
| 127 | + } | |
| 128 | + ) | |
| 129 | + } | |
| 130 | + $(window).resize(function () { | |
| 131 | + pcpSwiper.update() | |
| 132 | + }) | |
| 133 | + $(window).trigger("resize") | |
| 134 | + } | |
| 135 | + | |
| 136 | + /** | |
| 137 | + * Grid masonry. | |
| 138 | + */ | |
| 139 | + if ($(PCP_Wrapper_ID).hasClass('pcp-masonry')) { | |
| 140 | + var $post_wrapper = $('.sp-pcp-row', PCP_Wrapper_ID) | |
| 141 | + $post_wrapper.imagesLoaded(function () { | |
| 142 | + $post_wrapper.masonry() | |
| 143 | + }) | |
| 144 | + } | |
| 145 | + /* Preloader js */ | |
| 146 | + $(document).ready(function() { | |
| 147 | + $(".pcp-preloader", PCP_Wrapper_ID).css({ "backgroundImage": "none", "visibility": "hidden" }); | |
| 148 | + }); | |
| 149 | + }) | |
| 150 | + } | |
| 140 | 151 | }) |