1jQuery(document).ready(function($) { 2 3 $(".psfw-bxslider-pager").mCustomScrollbar(); 4 5 /* 6 * Add span to Read More/Add Cart etc woocommerce (When add to cart is replaced by read more when product is out of stock) 7 */ 8 $('.psfw-buton-one-wrapper').each(function() { 9 var text = $(this).children().html(); 10 $(this).children().html('<span class="psfw-span">' + text + '</span>'); 11 }); 12 $('.psfw-buton-two-wrapper').each(function() { 13 var text = $(this).children().html(); 14 $(this).children().html('<span class="psfw-span">' + text + '</span>'); 15 }); 16 17 //psfw-bxslider-pager 18 19 //Slider Layout 20 var psfw_slider = []; 21 22 $(".psfw-layout-slider-section").each(function() { 23 //alert('hey there'); 24 var id = $(this).data('id'); 25 var selector = $(this); 26 var a = 1; 27 //var psfw_thumb_slider = []; 28 var controls = $(this).data('controls'); 29 var auto = $(this).data('auto'); 30 var mode = $(this).data('orientation'); 31 var autoHover = $(this).data('autohover'); 32 var speed = $(this).data('speed'); 33 var pager = $(this).data('pager'); 34 var template = $(this).data('template'); 35 if (template=='template-10'){ 36 var next_text = '<span class="lnr lnr-arrow-right" aria-hidden="true"></span>'; 37 var pre_text = '<span class="lnr lnr-arrow-left" aria-hidden="true"></span>'; 38 }else{ 39 var next_text = '<span class="lnr lnr-chevron-right" aria-hidden="true"></span>'; 40 var pre_text = '<span class="lnr lnr-chevron-left" aria-hidden="true"></span>'; 41 } 42 43 if (template=='template-14'){ 44 custom_pager = ".psfw-bxslider-pager"; 45 } 46 else{ 47 custom_pager = ""; 48 } 49 psfw_slider[id] = $(this).bxSlider({ 50 auto: auto, 51 //autocontrols: controls, 52 controls: controls, 53 mode: mode, 54 autoHover: autoHover, //to stop on hover 55 pause: 3000, 56 speed: speed, 57 pager: pager, 58 infiniteLoop: true, 59 nextText: next_text, 60 prevText: pre_text, 61 adaptiveHeight: true, 62 useCSS: false, 63 pagerCustom: custom_pager, 64 onSliderLoad: function(currentSlideHtmlObject) { 65 if (template === 'template-1') { 66 setTimeout(function() { 67 selector.closest('.psfw-layout-slider-section').find('.psfw-circle-content').removeClass('psfw-hidden'); 68 selector.closest('.psfw-layout-slider-section').find('.psfw-circle-content').addClass('animated fadeIn'); 69 }, 500 70 ); 71 setTimeout(function() { 72 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('psfw-hidden'); 73 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated slideInUp'); 74 }, 700 75 ); 76 } else if (template === 'template-2') { 77 setTimeout(function() { 78 79 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-side-wrap').removeClass('psfw-hidden'); 80 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-side-wrap').addClass('animated slideInDown'); 81 }, 600 82 ); 83 setTimeout(function() { 84 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('psfw-hidden'); 85 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').addClass('animated slideInUp'); 86 }, 400 87 ); 88 } else if (template === 'template-3' || template === 'template-4') { 89 setTimeout(function() { 90 91 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('psfw-hidden'); 92 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').addClass('animated zoomIn'); 93 }, 400 94 ); 95 } else if (template === 'template-5') { 96 setTimeout(function() { 97 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('psfw-hidden'); 98 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated slideInLeft'); 99 }, 400 100 ); 101 setTimeout(function() { 102 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('psfw-hidden'); 103 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').addClass('animated slideInUp'); 104 }, 500 105 ); 106 setTimeout(function() { 107 selector.closest('.psfw-layout-slider-section').find('.psfw-below-wrap').removeClass('psfw-hidden'); 108 selector.closest('.psfw-layout-slider-section').find('.psfw-below-wrap').addClass('animated slideInRight'); 109 }, 400 110 ); 111 } else if (template === 'template-6') { 112 setTimeout(function() { 113 114 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('psfw-hidden'); 115 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').addClass('animated slideInLeft'); 116 }, 400 117 ); 118 setTimeout(function() { 119 120 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('psfw-hidden'); 121 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated slideInRight'); 122 }, 400 123 ); 124 } else if (template === 'template-7'){ 125 setTimeout(function() { 126 127 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('psfw-hidden'); 128 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated zoomIn'); 129 }, 400 130 ); 131 setTimeout(function() { 132 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('psfw-hidden'); 133 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').addClass('animated slideInUp'); 134 }, 500 135 ); 136 }else if (template === 'template-8'){ 137 138 } 139 }, 140 onSlideAfter: function(currentSlideNumber, totalSlideQty, currentSlideHtmlOb
140ject) { 141 var acurrent = currentSlideHtmlObject + 1; 142 if (template === 'template-1') { 143 setTimeout(function() { 144 145 selector.closest('.psfw-layout-slider-section').find('.psfw-circle-content').removeClass('psfw-hidden'); 146 selector.closest('.psfw-layout-slider-section').find('.psfw-circle-content').removeClass('animated fadeOut'); 147 selector.closest('.psfw-layout-slider-section').find('.psfw-circle-content').addClass('animated fadeIn'); 148 }, 500 149 ); 150 setTimeout(function() { 151 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('psfw-hidden'); 152 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('animated fadeOut'); 153 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated slideInUp'); 154 }, 700 155 ); 156 } else if (template === 'template-2') { 157 setTimeout(function() { 158 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-side-wrap').removeClass('psfw-hidden'); 159 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-side-wrap').removeClass('animated fadeOut'); 160 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-side-wrap').addClass('animated slideInDown'); 161 }, 600 162 ); 163 setTimeout(function() { 164 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('psfw-hidden'); 165 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('animated fadeOut'); 166 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').addClass('animated slideInUp'); 167 }, 400 168 ); 169 } else if (template === 'template-3' || template === 'template-4') { 170 setTimeout(function() { 171 172 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('psfw-hidden'); 173 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('animated fadeOut'); 174 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').addClass('animated zoomIn'); 175 }, 400 176 ); 177 } else if (template === 'template-5') { 178 setTimeout(function() { 179 180 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('psfw-hidden'); 181 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('animated fadeOut'); 182 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated slideInLeft'); 183 }, 400 184 ); 185 setTimeout(function() { 186 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('psfw-hidden'); 187 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('animated fadeOut'); 188 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').addClass('animated slideInUp'); 189 }, 500 190 ); 191 setTimeout(function() { 192 selector.closest('.psfw-layout-slider-section').find('.psfw-below-wrap').removeClass('psfw-hidden'); 193 selector.closest('.psfw-layout-slider-section').find('.psfw-below-wrap').removeClass('animated fadeOut'); 194 selector.closest('.psfw-layout-slider-section').find('.psfw-below-wrap').addClass('animated slideInRight'); 195 }, 400 196 ); 197 } else if (template === 'template-6') { 198 setTimeout(function() { 199 200 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('psfw-hidden'); 201 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('animated fadeOut'); 202 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').addClass('animated slideInLeft'); 203 }, 400 204 ); 205 setTimeout(function() { 206 207 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('psfw-hidden'); 208 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('animated fadeOut'); 209 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated slideInRight'); 210 }, 400 211 ); 212 } else if (template === 'template-7'){ 213 setTimeout(function() { 214 215 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('psfw-hidden'); 216 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('animated fadeOut'); 217 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated zoomIn'); 218 }, 400 219 ); 220 setTimeout(function() { 221 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('psfw-hidden'); 222 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('animated fadeOut'); 223 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').addClass('animated slideInUp'); 224 }, 500 225 ); 226 }else if (template === 'template-8'){ 227 setTimeout(function() { 228 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('psfw-hidden'); 229 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('animated fadeOut'); 230 }, 400 231 ); 232 setTimeout(function() { 233 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('psfw-hidden'); 234 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('animated fadeOut'); 235 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').addClass('animated slideInUp'); 236 }, 500 237 ); 238 } 239 },
240 onSlideBefore: function(currentSlideHtmlObject) { 241 if (template === 'template-1') { 242 selector.closest('.psfw-layout-slider-section').find('.psfw-circle-content').removeClass('animated fadeIn'); 243 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('animated slideInUp'); 244 selector.closest('.psfw-layout-slider-section').find('.psfw-circle-content').addClass('animated fadeOut'); 245 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated fadeOut'); 246 } else if (template === 'template-2') { 247 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-side-wrap').removeClass('animated slideInDown'); 248 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('animated slideInUp'); 249 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-side-wrap').addClass('animated fadeOut'); 250 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').addClass('animated fadeOut'); 251 } else if (template === 'template-3' || template === 'template-4') { 252 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('animated zoomIn'); 253 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').addClass('animated fadeOut'); 254 } else if (template === 'template-5') { 255 //alert('onSlideBefore'); 256 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('animated slideInLeft'); 257 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('animated slideInUp'); 258 selector.closest('.psfw-layout-slider-section').find('.psfw-below-wrap').removeClass('animated slideInRight'); 259 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated fadeOut'); 260 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').addClass('animated fadeOut'); 261 selector.closest('.psfw-layout-slider-section').find('.psfw-below-wrap').addClass('animated fadeOut'); 262 } else if (template === 'template-6') { 263 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').removeClass('animated slideInLeft'); 264 selector.closest('.psfw-layout-slider-section').find('.psfw-image-hover-wrap').addClass('animated fadeOut'); 265 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('animated slideInRight'); 266 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated fadeOut'); 267 } else if (template === 'template-7'){ 268 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('animated zoomIn'); 269 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('animated slideInUp'); 270 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').addClass('animated fadeOut'); 271 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').addClass('animated fadeOut'); 272 } else if (template === 'template-8'){ 273 selector.closest('.psfw-layout-slider-section').find('.psfw-top-wrap').removeClass('animated zoomIn'); 274 selector.closest('.psfw-layout-slider-section').find('.psfw-detail-inner-wrap').removeClass('animated slideInUp'); 275 } 276 } 277 }); 278 var clicks = 0; 279 280 //For Template 8 281 $('body').on('click', '.psfw-buttons-collection-secondary', function() { 282 $(this).closest('.psfw-content-container').find('.psfw-buttons-collection').toggleClass('psfw-display-buttons'); 283 if ($('.psfw-buttons-collection').hasClass('psfw-display-buttons')){ 284 var number_of_children = $(this).closest('.psfw-content-container').find('.psfw-buttons-collection-
284primary').children().length; 285 if(number_of_children == 4){ 286 var estimated_width = 190; 287 }else{ 288 var estimated_width = ((number_of_children * 25) + ((number_of_children + 1) * 15)); 289 } 290 $(this).closest('.psfw-content-container').find('.psfw-buttons-collection-primary').css("width",estimated_width); 291 } 292 else{ 293 $(this).closest('.psfw-content-container').find('.psfw-buttons-collection-primary').css('width', '0'); 294 } 295 }); 296 297 //For Template 9 298 $( ".psfw-social-share-secondary" ).on( "click", function() { 299 // alert('hey'); 300 $(this).parent().toggleClass("psfw-display-social-icons"); 301 }); 302 303 //For Template 13's Controls 304 if (template == 'template-13'){ 305 $(".bx-controls-direction").detach().appendTo('.psfw-slider-controls-wrap'); 306 } 307 }); 308 309 310 //Carousel layout 311 var psfw_carousel = []; 312 $(".psfw-layout-carousel-section").each(function() { 313 var id = $('.psfw-main-product-wrapper').data('id'); 314 var column = $(this).data('column'); 315 var controls = $(this).data('controls'); 316 var auto = $(this).data('auto'); 317 var mode = $(this).data('orientation'); 318 var autoHover = $(this).data('autohover'); 319 var speed = $(this).data('speed'); 320 var pager = $(this).data('pager'); 321 var width = $(this).data('width'); 322 var template = $(this).data('template'); 323 //alert(template); 324 var next_text = '<i class="fa fa-angle-right" aria-hidden="true"></i>'; 325 var pre_text = '<i class="fa fa-angle-left" aria-hidden="true"></i>'; 326 var margin = 15; 327 if (jQuery(window).width() >= 981) { 328 var itemcolumn = column; 329 var slidew = width; 330 var smargin = margin; 331 } else if (jQuery(window).width() <= 980 && jQuery(window).width() >= 801) { 332 var itemcolumn = 3; 333 var slidew = 300; 334 var smargin = margin; 335 } else if (jQuery(window).width() <= 800 && jQuery(window).width() >= 641) { 336 var itemcolumn = 2; 337 var slidew = 240; 338 var smargin = margin; 339 } else if (jQuery(window).width() <= 640 && jQuery(window).width() >= 320) { 340 var itemcolumn = 1; 341 var slidew = 350; 342 var smargin = 0; 343 } 344 345 psfw_carousel[id] = $(this).bxSlider({ 346 minSlides: 1, 347 maxSlides: itemcolumn, 348 moveSlides: 1, 349 pager: pager, 350 mode: mode, 351 autoHover: autoHover, //to stop on hover 352 slideWidth: slidew, 353 slideMargin: smargin, 354 auto: auto, 355 // controls: controls, 356 autoControls: controls, 357 speed: speed, 358 nextText: next_text, 359 prevText: pre_text, 360 touchEnabled: false 361 362 }); 363 364 //For Template 13 365 $( ".psfw-social-share-secondary" ).on( "click", function() { 366 // alert('hey'); 367 $(this).parent().toggleClass("psfw-display-social-icons"); 368 }); 369 370 //var template = $(this).data('template'); 371 if(template=="template-12"){ 372 $('.bx-pager').hide(); 373 } 374 }); 375 /* 376 * Wishlist Functionality 377 */ 378 $('body').on('click', '.add_to_wishlist', function() { 379 $(this).closest('.psfw-wishlist-wrap').find('.ajax-loading').removeAttr("style", "display: none !important"); 380 $(this).closest('.psfw-wishlist-wrap').find('.psfw-heart').removeClass("fa-heart-o"); 381 }); 382 /* 383 * Add span to View Cart woocommerce 384 */ 385 $('body').on('click', '.add_to_cart_button', function() { 386 $(document).ajaxComplete(function() { 387 $('.added_to_cart').each(function() { 388 $('.added_to_cart').html('<span class="psfw-span">View Cart</span>'); 389 }); 390 }); 391 }); 392 393 /* 394 * Lightbox function 395 */ 396 function psfw_slider_lightbox() { 397 $(".psfw-lightbox-image-wrapper").each(function() { 398 var selector = $(this); 399 var id = $(this).data('id'); 400 var next_text = '<i class="fa fa-angle-right" aria-hidden="true"></i>'; 401 var pre_text = '<i class="fa fa-angle-left" aria-hidden="true"></i>'; 402 psfw_lightbox_slider[id] = $(this).bxSlider({
403 auto: false, 404 control: true, 405 speed: 2000, 406 pager: true, 407 infiniteLoop: true, 408 nextText: next_text, 409 prevText: pre_text, 410 mode: 'horizontal', 411 pagerCustom: '#psfw-pager-' + id, 412 useCSS: false, 413 onSlideBefore: function($slideElement, oldIndex, newIndex) { 414 selector.closest('.psfw-each-thumb').find('.active').removeClass("active"); 415 selector.closest('.psfw-each-thumb').find('a[data-slide-index="' + newIndex + '"]').addClass("active"); 416 var slider = psfw_thumb_slider[id]; 417 if (slider.getSlideCount() - newIndex >= count) 418 slider.goToSlide(newIndex); 419 else 420 slider.goToSlide(slider.getSlideCount() - count); 421 } 422 }); 423 }); 424 var count = 0; 425 $(".psfw-thumbnail-slider").each(function() { 426 var id = $(this).data('id'); 427 var next_text = '<i class="fa fa-angle-right" aria-hidden="true"></i>'; 428 var pre_text = '<i class="fa fa-angle-left" aria-hidden="true"></i>'; 429 psfw_thumb_slider[id] = $(this).bxSlider({ 430 minSlides: 1, 431 maxSlides: 4, 432 slideWidth: 100, 433 slideMargin: 10, 434 moveSlides: 1, 435 auto: false, 436 pager: false, 437 infiniteLoop: true, 438 nextText: next_text, 439 prevText: pre_text 440 }); 441 }); 442 } 443 /* 444 * Popup Images Gallery 445 */ 446 $('body').on('click', '.psfw-content-lightbox', function() { 447 var layout = $(this).closest('.psfw-main-product-wrapper').data('layout'); 448 if (layout === 'carousel' || layout === 'slider') { 449 $(".psfw-display-popup").addClass('psfw-active'); 450 var selector = $(this); 451 if (layout === 'carousel') { 452 var post_id = selector.closest('.psfw-inner-wrap').data('post_id'); 453 var shortcode_id = selector.closest('.psfw-inner-wrap').data('shortcode_id'); 454 //alert(shortcode_id); 455 } else { 456 var post_id = selector.closest('.psfw-slider-inner-wrap').data('post_id'); 457 var shortcode_id = selector.closest('.psfw-slider-inner-wrap').data('shortcode_id'); 458 } 459 $.ajax({ 460 url: psfw_frontend_js_params.ajax_url, 461 data: { 462 post_id: post_id, 463 shortcode_id: shortcode_id, 464 _wpnonce: psfw_frontend_js_params.ajax_nonce, 465 action: 'psfw_view_lightbox', 466 beforeSend: function() { 467 $('.psfw-lightbox-loader').show(); 468 } 469 }, 470 type: "POST", 471 success: function(response) { 472 $('.psfw-lightbox-loader').hide(); 473 $(".psfw-display-popup").html(response); 474 var psfw_lightbox_slider = []; 475 var psfw_thumb_slider = []; 476 psfw_slider_lightbox(); 477 $('.psfw-lightbox-detail-wrap').mCustomScrollbar({ 478 theme: 'dark-3', 479 mouseWheel: {enable: true}, 480 axis: 'y' 481 }); 482 } 483 484 }); 485 } 486 }); 487 /* 488 * Popup close 489 * 490 */ 491 $('body').on('click', '.psfw-close-lightbox', function() { 492 var layout = $('.psfw-content-lightbox').closest('.psfw-main-product-wrapper').data('layout'); 493 if (layout === 'carousel' || layout === 'slider') { 494 $(".psfw-display-popup").removeClass('psfw-active'); 495 $(this).closest('.psfw-lightbox-detail-wrap').fadeOut(500); 496 } 497 }); 498 /* 499 * Lightbox Slider Images 500 */ 501 var psfw_lightbox_slider = []; 502 var psfw_thumb_slider = []; 503 $(".psfw-lightbox-image-wrapper").each(function() { 504 var selector = $(this); 505 var id = $(this).data('id'); 506 var next_text = '<i class="fa fa-angle-right" aria-hidden="true"></i>'; 507 var pre_text = '<i class="fa fa-angle-left" aria-hidden="true"></i>'; 508 psfw_lightbox_slider[id] = $(this).bxSlider({
509 auto: false, 510 control: true, 511 speed: 2000, 512 pager: true, 513 infiniteLoop: true, 514 nextText: next_text, 515 prevText: pre_text, 516 mode: 'horizontal', 517 pagerCustom: '#psfw-pager-' + id, 518 useCSS: false, 519 onSlideBefore: function($slideElement, oldIndex, newIndex) { 520 selector.closest('.psfw-each-thumb').find('.active').removeClass("active"); 521 selector.closest('.psfw-each-thumb').find('a[data-slide-index="' + newIndex + '"]').addClass("active"); 522 var slider = psfw_thumb_slider[id]; 523 if (slider.getSlideCount() - newIndex >= count) 524 slider.goToSlide(newIndex); 525 else 526 slider.goToSlide(slider.getSlideCount() - count); 527 } 528 }); 529 }); 530 var count = 0; 531 $(".psfw-thumbnail-slider").each(function() { 532 var id = $(this).data('id'); 533 var next_text = '<i class="fa fa-angle-right" aria-hidden="true"></i>'; 534 var pre_text = '<i class="fa fa-angle-left" aria-hidden="true"></i>'; 535 psfw_thumb_slider[id] = $(this).bxSlider({ 536 minSlides: 1, 537 maxSlides: 4, 538 slideWidth: 100, 539 slideMargin: 10, 540 moveSlides: 1, 541 auto: false, 542 pager: false, 543 infiniteLoop: true, 544 nextText: next_text, 545 prevText: pre_text 546 }); 547 }); 548 /* 549 * Scroll Configuration 550 */ 551 $('.psfw-lightbox-detail-wrap').mCustomScrollbar({ 552 theme: 'dark-3', 553 mouseWheel: {enable: true}, 554 axis: 'y' 555 }); 556 /* 557 * Swap effect on images 558 */ 559 $('body').on('hover', '.psfw-inner-wrap', function() { 560 var swap = $(this).find('.psfw-swap-image').data('swap'); 561 $(this).find('.psfw-swap-image').fadeIn(100).attr('src', swap).fadeIn(200); 562 }); 563 $('body').on('mouseleave', '.psfw-inner-wrap', function() { 564 var original = $(this).find('.psfw-swap-image').data('original'); 565 $(this).find('.psfw-swap-image').attr('src', original).fadeIn('slow'); 566 }); 567 $('body').on('hover', '.psfw-masonry-item-inner', function() { 568 var swap = $(this).find('.psfw-swap-image').data('swap'); 569 $(this).find('.psfw-swap-image').fadeIn(100).attr('src', swap).fadeIn(200); 570 }); 571 $('body').on('mouseleave', '.psfw-masonry-item-inner', function() { 572 var original = $(this).find('.psfw-swap-image').data('original'); 573 $(this).find('.psfw-swap-image').attr('src', original).fadeIn('slow'); 574 }); 575 /* 576 * WooCommerce Disable link for Variable Price functionality 577 * 578 */ 579 $('body').on('click', '.product_type_variable', function() { 580 event.preventDefault(); 581 var selector = $(this); 582 var post_id = selector.closest('.add_to_cart_button').data('product_id'); 583 $.ajax({ 584 url: psfw_frontend_js_params.ajax_url, 585 data: { 586 post_id: post_id, 587 _wpnonce: psfw_frontend_js_params.ajax_nonce, 588 action: 'psfw_variable_attribute', 589 beforeSend: function() { 590 $('.psfw-lightbox-loader').show(); 591 } 592 }, 593 type: "POST", 594 success: function(response) { 595 $('.psfw-lightbox-loader').hide(); 596 $(".psfw-attributes-container").html(response); 597 }, 598 complete: function() { 599 //alert('heeloo'); 600 loadVariationScript(); 601 } 602 }); 603 event.preventDefault(); 604 }); 605 606 $('body').on('click', '.product_type_variable', function() { 607 event.preventDefault(); 608 var selector = $(this); 609 var post_id = selector.closest('.product_type_variable').data('product_id'); 610 $.ajax({ 611 url: psfw_frontend_js_params.ajax_url, 612 data: { 613 post_id: post_id, 614 _wpnonce: psfw_frontend_js_params.ajax_nonce, 615 action: 'psfw_variable_attribute', 616 beforeSend: function() { 617 $('.psfw-lightbox-loader').show(); 618 } 619 }, 620 type: "POST", 621 success: function(response) { 622 $('.psfw-lightbox-loader').hide(); 623 $(".psfw-attributes-container").html(response); 624 }, 625 complete: function() { 626 //alert('heeloo'); 627 loadVariationScript(); 628 } 629 }); 630 event.preventDefault(); 631 }); 632 633 $('body').on('click', '.psfw-close-variation', function() { 634 $(this).closest('.psfw-attributes-container').find('.psfw-variation-container').fadeOut(); 635 }); 636 637 // Ajax add to cart 638 $(document).on('click', '.variations_form .single_add_to_cart_button', function(e) { 639 e.preventDefault(); 640 $variation_form = $(this).closest('.variations_form'); 641 var var_id = $variation_form.find('input[name=variation_id]').val(); 642 var product_id = $variation_form.find('input[name=product_id]').val(); 643 var quantity = $variation_form.find('input[name=quantity]').val(); 644 $('.ajaxerrors').remove(); 645 var item = {}, 646 check = true; 647 variations = $variation_form.find('select[name^=attribute]');
648 /* Updated code to work with radio button - mantish - WC Variations Radio Buttons - 8manos */ 649 if (!variations.length) { 650 variations = $variation_form.find('[name^=attribute]:checked'); 651 } 652 /* Backup Code for getting input variable */ 653 if (!variations.length) { 654 variations = $variation_form.find('input[name^=attribute]'); 655 } 656 variations.each(function() { 657 var $this = $(this), 658 attributeName = $this.attr('name'), 659 attributevalue = $this.val(), 660 index, 661 attributeTaxName; 662 $this.removeClass('error'); 663 if (attributevalue.length === 0) { 664 index = attributeName.lastIndexOf('_'); 665 attributeTaxName = attributeName.substring(index + 1); 666 $this.addClass('required error').before('<div class="ajaxerrors"><p>Please select ' + attributeTaxName + '</p></div>') 667 check = false; 668 } else { 669 item[attributeName] = attributevalue; 670 } 671 }); 672 if (!check) { 673 return false; 674 } 675 var $thisbutton = $(this); 676 if ($thisbutton.is('.variations_form .single_add_to_cart_button')) { 677 $thisbutton.removeClass('added'); 678 $thisbutton.addClass('loading'); 679 var data = { 680 action: 'woocommerce_add_to_cart_variable_rc', 681 product_id: product_id, 682 quantity: quantity, 683 variation_id: var_id, 684 variation: item 685 }; 686 687 // Trigger event 688 $('body').trigger('adding_to_cart', [$thisbutton, data]); 689 690 // Ajax action 691 $.post(wc_add_to_cart_params.ajax_url, data, function(response) { 692 693 if (!response) 694 return; 695 var this_page = window.location.toString(); 696 697 this_page = this_page.replace('add-to-cart', 'added-to-cart'); 698 699 if (response.error && response.product_url) { 700 window.location = response.product_url; 701 return; 702 } 703 704 if (wc_add_to_cart_params.cart_redirect_after_add === 'yes') { 705 window.location = wc_add_to_cart_params.cart_url; 706 return; 707 708 } else { 709 $thisbutton.removeClass('loading'); 710 var fragments = response.fragments; 711 var cart_hash = response.cart_hash; 712 713 // Block fragments class 714 if (fragments) { 715 $.each(fragments, function(key) { 716 $(key).addClass('updating'); 717 }); 718 } 719 720 // Block widgets and fragments 721 $('.shop_table.cart, .updating, .cart_totals').fadeTo('400', '0.6').block({ 722 message: null, 723 overlayCSS: { 724 opacity: 0.6 725 } 726 }); 727 728 // Changes button classes 729 $thisbutton.addClass('added'); 730 731 // View cart text 732 if (!wc_add_to_cart_params.is_cart && $thisbutton.parent().find('.added_to_cart').size() === 0) { 733 $thisbutton.after(' <a href="' + wc_add_to_cart_params.cart_url + '" class="added_to_cart wc-forward" title="' + 734 wc_add_to_cart_params.i18n_view_cart + '">' + wc_add_to_cart_params.i18n_view_cart + '</a>'); 735 } 736 737 // Replace fragments 738 if (fragments) { 739 $.each(fragments, function(key, value) { 740 $(key).replaceWith(value); 741 }); 742 } 743 744 // Unblock 745 $('.widget_shopping_cart, .updating').stop(true).css('opacity', '1').unblock(); 746 747 // Cart page elements 748 $('.shop_table.cart').load(this_page + ' .shop_table.cart:eq(0) > *', function() { 749 $('.shop_table.cart').stop(true).css('opacity', '1').unblock(); 750 $(document.body).trigger('cart_page_refreshed'); 751 }); 752 753 $('.cart_totals').load(this_page + ' .cart_totals:eq(0) > *', function() { 754 $('.cart_totals').stop(true).css('opacity', '1').unblock(); 755 }); 756 757 // Trigger event so themes can refresh other areas 758 $(document.body).trigger('added_to_cart', [fragments, cart_hash, $thisbutton]); 759 } 760 }); 761 return false;
762 } else { 763 return true; 764 } 765 }); 766 767 function loadVariationScript() { 768 var url = psfw_object_name.templateUrl; 769 $.getScript(url + '/assets/js/frontend/add-to-cart-variation.min.js'); 770 $.getScript(url + '/assets/js/frontend/add-to-cart-variation.js'); 771 } 772 773 774}); 775
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.