1// Check whether current page is inside (visual) builder or not 2var isBuilder = 'object' === typeof window.ET_Builder; 3Â 4/*! ET frontend-builder-scripts.js */ 5(function($){ 6 var $et_window = $(window); 7 var $et_top_window = isBuilder ? window.top.jQuery(window.top) : $(window); 8 var isBFB = $('body').hasClass('et-bfb'); 9 var isVB = isBuilder && !isBFB; 10 var isScrollOnAppWindow = function() { 11 return isVB && ($('html').is('.et-fb-preview--wireframe') || $('html').is('.et-fb-preview--desktop')); 12 }; 13 var isBuilderModeZoom = function() { 14 return isBuilder && $('html').is('.et-fb-preview--zoom'); 15 }; 16 17 window.et_load_event_fired = false; 18 window.et_is_transparent_nav = $( 'body' ).hasClass( 'et_transparent_nav' ); 19 window.et_is_vertical_nav = $( 'body' ).hasClass( 'et_vertical_nav' ); 20 window.et_is_fixed_nav = $( 'body' ).hasClass( 'et_fixed_nav' ); 21 window.et_is_minified_js = $( 'body' ).hasClass( 'et_minified_js' ); 22 window.et_is_minified_css = $( 'body' ).hasClass( 'et_minified_css' ); 23 window.et_force_width_container_change = false; 24 25 jQuery.fn.reverse = [].reverse; 26 27 jQuery.fn.closest_descendent = function( selector ) { 28 var $found, 29 $current_children = this.children(); 30 31 while ( $current_children.length ) { 32 $found = $current_children.filter( selector ); 33 if ( $found.length ) { 34 break; 35 } 36 $current_children = $current_children.children(); 37 } 38 39 return $found; 40 }; 41 42 /* 43 * Star-based rating UI. 44 * @see: WooCommerce's woocommerce/assets/js/frontend/single-product.js file 45 */ 46 window.et_pb_init_woo_star_rating = function($rating_selector) { 47 var $rating_parent = $rating_selector.closest('div'); 48 var $existing_stars = $rating_parent.find('p.stars'); 49 50 if ($existing_stars.length > 0) { 51 $existing_stars.remove(); 52 } 53 54 $rating_selector.hide().before( 55 '<p class="stars">\ 56 <span>\ 57 <a class="star-1" href="#">1</a>\ 58 <a class="star-2" href="#">2</a>\ 59 <a class="star-3" href="#">3</a>\ 60 <a class="star-4" href="#">4</a>\ 61 <a class="star-5" href="#">5</a>\ 62 </span>\ 63 </p>' 64 ); 65 }; 66 67 window.et_pb_init_modules = function() { 68 isBFB = $( 'body' ).hasClass( 'et-bfb' ); 69 isVB = isBuilder && !isBFB; 70 71 $.et_pb_simple_slider = function(el, options) { 72 var settings = $.extend( { 73 slide : '.et-slide', // slide class 74 arrows : '.et-pb-slider-arrows', // arrows container class 75 prev_arrow : '.et-pb-arrow-prev', // left arrow class 76 next_arrow : '.et-pb-arrow-next', // right arrow class 77 controls : '.et-pb-controllers a', // control selector 78 carousel_controls : '.et_pb_carousel_item', // carousel control selector 79 control_active_class : 'et-pb-active-control', // active control class name 80 previous_text : et_pb_custom.previous, // previous arrow text 81 next_text : et_pb_custom.next, // next arrow text 82 fade_speed : 500, // fade effect speed 83 use_arrows : true, // use arrows? 84 use_controls : true, // use controls? 85 manual_arrows : '', // html code for custom arrows 86 append_controls_to : '', // controls are appended to the slider element by default, here you can specify the element it should append to 87 controls_below : false, 88 controls_class : 'et-pb-controllers', // controls container class name 89 slideshow : false, // automattic animation? 90 slideshow_speed : 7000, // automattic animation speed 91 show_progress_bar : false, // show progress bar if automattic animation is active 92 tabs_animation : false, 93 use_carousel : false 94 }, options ); 95 96 var $et_slider = $(el), 97 $et_slide = $et_slider.closest_descendent( settings.slide ), 98 et_slides_number = $et_slide.length, 99 et_fade_speed = settings.fade_speed, 100 et_active_slide = 0, 101 $et_slider_arrows, 102 $et_slider_prev, 103 $et_slider_next, 104 $et_slider_controls, 105 $et_slider_carousel_controls, 106 et_slider_timer, 107 controls_html = '', 108 carousel_html = '', 109 $progress_bar = null,
110 progress_timer_count = 0, 111 $et_pb_container = $et_slider.find( '.et_pb_container' ), 112 et_pb_container_width = $et_pb_container.width(), 113 is_post_slider = $et_slider.hasClass( 'et_pb_post_slider' ), 114 et_slider_breakpoint = '', 115 stop_slider = false; 116 117 $et_slider.et_animation_running = false; 118 119 $.data(el, "et_pb_simple_slider", $et_slider); 120 121 $et_slide.eq(0).addClass( 'et-pb-active-slide' ); 122 123 $et_slider.attr('data-active-slide', $et_slide.data('slide-id')); 124 125 if ( ! settings.tabs_animation ) { 126 if ( !$et_slider.hasClass('et_pb_bg_layout_dark') && !$et_slider.hasClass('et_pb_bg_layout_light') ) { 127 $et_slider.addClass( et_get_bg_layout_color( $et_slide.eq(0) ) ); 128 } 129 } 130 131 if ( settings.use_arrows && et_slides_number > 1 ) { 132 if ( settings.manual_arrows == '' ) 133 $et_slider.append( '<div class="et-pb-slider-arrows"><a class="et-pb-arrow-prev" href="#">' + '<span>' +settings.previous_text + '</span>' + '</a><a class="et-pb-arrow-next" href="#">' + '<span>' + settings.next_text + '</span>' + '</a></div>' ); 134 else 135 $et_slider.append( settings.manual_arrows ); 136 137 $et_slider_arrows = $et_slider.find( settings.arrows ); 138 $et_slider_prev = $et_slider.find( settings.prev_arrow ); 139 $et_slider_next = $et_slider.find( settings.next_arrow ); 140 141 $et_slider.on( 'click.et_pb_simple_slider', settings.next_arrow, function() { 142 if ( $et_slider.et_animation_running ) return false; 143 144 $et_slider.et_slider_move_to( 'next' ); 145 146 return false; 147 } ); 148 149 $et_slider.on( 'click.et_pb_simple_slider', settings.prev_arrow, function() { 150 if ( $et_slider.et_animation_running ) return false; 151 152 $et_slider.et_slider_move_to( 'previous' ); 153 154 return false; 155 } ); 156 157 // swipe support requires et-jquery-touch-mobile 158 $et_slider.on( 'swipeleft.et_pb_simple_slider', settings.slide, function( event ) { 159 // do not switch slide on selecting text in VB 160 if ( $( event.target ).closest( '.et-fb-popover-tinymce' ).length || $( event.target ).closest( '.et-fb-editable-element' ).length ) { 161 return; 162 } 163 164 $et_slider.et_slider_move_to( 'next' ); 165 }); 166 $et_slider.on( 'swiperight.et_pb_simple_slider', settings.slide, function( event ) { 167 // do not switch slide on selecting text in VB 168 if ( $( event.target ).closest( '.et-fb-popover-tinymce' ).length || $( event.target ).closest( '.et-fb-editable-element' ).length ) { 169 return; 170 } 171 172 $et_slider.et_slider_move_to( 'previous' ); 173 }); 174 } 175 176 if ( settings.use_controls && et_slides_number > 1 ) { 177 for ( var i = 1; i <= et_slides_number; i++ ) { 178 controls_html += '<a href="#"' + ( i == 1 ? ' class="' + settings.control_active_class + '"' : '' ) + '>
178' + i + '</a>'; 179 } 180 181 if ($et_slider.find('video').length > 0) { 182 settings.controls_class += ' et-pb-controllers-has-video-tag'; 183 } 184 185 controls_html = 186 '<div class="' + settings.controls_class + '">' + 187 controls_html + 188 '</div>'; 189 190 if ( settings.append_controls_to == '' ) 191 $et_slider.append( controls_html ); 192 else 193 $( settings.append_controls_to ).append( controls_html ); 194 195 if ( settings.controls_below ) 196 $et_slider_controls = $et_slider.parent().find( settings.controls ); 197 else 198 $et_slider_controls = $et_slider.find( settings.controls ); 199 200 $et_slider_controls.on( 'click.et_pb_simple_slider', function () { 201 if ( $et_slider.et_animation_running ) return false; 202 203 $et_slider.et_slider_move_to( $(this).index() ); 204 205 return false; 206 } ); 207 } 208 209 if ( settings.use_carousel && et_slides_number > 1 ) { 210 for ( var i = 1; i <= et_slides_number; i++ ) { 211 slide_id = i - 1; 212 image_src = ( $et_slide.eq(slide_id).data('image') !== undefined ) ? 'url(' + $et_slide.eq(slide_id).data('image') + ')' : 'none'; 213 carousel_html += '<div class="et_pb_carousel_item ' + ( i == 1 ? settings.control_active_class : '' ) + '" data-slide-id="'+ slide_id +'">' + 214 '<div class="et_pb_video_overlay" href="#" style="background-image: ' + image_src + ';">' + 215 '<div class="et_pb_video_overlay_hover"><a href="#" class="et_pb_video_play"></a></div>' + 216 '</div>' + 217 '</div>'; 218 } 219 220 carousel_html = 221 '<div class="et_pb_carousel">' + 222 '<div class="et_pb_carousel_items">' + 223 carousel_html + 224 '</div>' + 225 '</div>'; 226 $et_slider.after( carousel_html ); 227 228 $et_slider_carousel_controls = $et_slider.siblings('.et_pb_carousel').find( settings.carousel_controls ); 229 $et_slider_carousel_controls.on( 'click.et_pb_simple_slider', function() { 230 if ( $et_slider.et_animation_running ) return false; 231 232 var $this = $(this); 233 $et_slider.et_slider_move_to( $this.data('slide-id') ); 234 235 return false; 236 } ); 237 } 238 239 if ( settings.slideshow && et_slides_number > 1 ) { 240 $et_slider.on( 'mouseenter.et_pb_simple_slider', function() { 241 if ( $et_slider.hasClass( 'et_slider_auto_ignore_hover' ) ) { 242 return; 243 } 244 245 $et_slider.addClass( 'et_slider_hovered' ); 246 247 if (typeof et_slider_timer !== 'undefined') { 248 clearTimeout(et_slider_timer); 249 } 250 }).on( 'mouseleave.et_pb_simple_slider', function() { 251 if ( $et_slider.hasClass( 'et_slider_auto_ignore_hover' ) ) { 252 return; 253 } 254 255 $et_slider.removeClass( 'et_slider_hovered' ); 256 257 et_slider_auto_rotate(); 258 } ); 259 } 260 261 et_slider_auto_rotate(); 262 263 function et_slider_auto_rotate() { 264 if (stop_slider) { 265 return; 266 } 267 268 // Slider animation can be dynamically paused with et_pb_pause_slider 269 // Make sure animation will start when class is removed by checking clas existence every 2 seconds. 270 if ($et_slider.hasClass('et_pb_pause_slider')) { 271 setTimeout(function() { 272 et_slider_auto_rotate(); 273 }, 2000); 274 275 return; 276 } 277 278 if ( settings.slideshow && et_slides_number > 1 && ! $et_slider.hasClass( 'et_slider_hovered' ) ) { 279 et_slider_timer = setTimeout( function() { 280 $et_slider.et_slider_move_to( 'next' ); 281 }, settings.slideshow_speed ); 282 } 283 } 284 285 $et_slider.et_slider_destroy = function() { 286 // Clear existing timer / auto rotate 287 if (typeof et_slider_timer !== 'undefined') { 288 clearTimeout(et_slider_timer); 289 } 290 291 stop_slider = true; 292 293 // Deregister all own existing events 294 $et_slider.off( '.et_pb_simple_slider' ); 295 296 // Removing existing style from slide(s) 297 $et_slider.find('.et_pb_slide').css({ 298 'z-index': '', 299 'display': '', 300 'opacity': '', 301 }); 302 303 // Removing existing classnames from slide(s) 304 $et_slider.find('.et-pb-active-slide').removeClass('et-pb-active-slide'); 305 $et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide'); 306 307 // Removing DOM that was added by slider 308 $et_slider.find('.et-pb-slider-arrows, .et-pb-controllers').remove(); 309 $et_slider.siblings('.et_pb_carousel, .et-pb-controllers').remove(); 310 311 // Remove references 312 $et_slider.removeData( 'et_pb_simple_slider' ); 313 }; 314 315 function et_stop_video( active_slide ) { 316 var $et_video, et_video_src; 317 318 // if there is a video in the slide, stop it when switching to another slide 319 if ( active_slide.has( 'iframe' ).length ) {
320 $et_video = active_slide.find( 'iframe' ); 321 et_video_src = $et_video.attr( 'src' ); 322 323 $et_video.attr( 'src', '' ); 324 $et_video.attr( 'src', et_video_src ); 325 326 } else if ( active_slide.has( 'video' ).length ) { 327 if ( !active_slide.find('.et_pb_section_video_bg').length ) { 328 $et_video = active_slide.find( 'video' ); 329 $et_video[0].pause(); 330 } 331 } 332 } 333 334 $et_slider.et_fix_slider_content_images = et_fix_slider_content_images; 335 336 function et_fix_slider_content_images() { 337 var $this_slider = $et_slider, 338 $slide_image_container = $this_slider.find( '.et-pb-active-slide .et_pb_slide_image' ), 339 $slide_video_container = $this_slider.find( '.et-pb-active-slide .et_pb_slide_video' ), 340 $slide = $slide_image_container.closest( '.et_pb_slide' ), 341 $slider = $slide.closest( '.et_pb_slider' ), 342 slide_height = parseFloat( $slider.innerHeight() ), 343 image_height = parseFloat( slide_height * 0.8 ), 344 slide_image_container_height = parseFloat( $slide_image_container.height() ), 345 slide_video_container_height = parseFloat( $slide_video_container.height() ); 346 347 if ( ! isNaN( image_height ) ) { 348 $slide_image_container.find( 'img' ).css( 'maxHeight', image_height + 'px' ); 349 350 slide_image_container_height = parseInt( $slide_image_container.height() ) 351 } 352 353 if ( ! isNaN( slide_image_container_height ) && $slide.hasClass( 'et_pb_media_alignment_center' ) ) { 354 $slide_image_container.css( 'marginTop', '-' + ( slide_image_container_height / 2 ) + 'px' ); 355 } 356 357 if ( ! isNaN( slide_video_container_height ) ) { 358 $slide_video_container.css( 'marginTop', '-' + ( slide_video_container_height / 2 ) + 'px' ); 359 } 360 } 361 362 function et_get_bg_layout_color( $slide ) { 363 if ( $slide.hasClass( 'et_pb_bg_layout_light' ) ) { 364 return 'et_pb_bg_layout_light'; 365 } 366 367 return 'et_pb_bg_layout_dark'; 368 } 369 370 // fix the appearance of some modules inside the post slider 371 function et_fix_builder_content() { 372 if ( is_post_slider ) { 373 setTimeout( function() { 374 var $et_pb_circle_counter = $( '.et_pb_circle_counter' ), 375 $et_pb_number_counter = $( '.et_pb_number_counter' ); 376 377 window.et_fix_testimonial_inner_width(); 378 379 if ( $et_pb_circle_counter.length ) { 380 window.et_pb_reinit_circle_counters( $et_pb_circle_counter ); 381 } 382 383 if ( $et_pb_number_counter.length ) { 384 window.et_pb_reinit_number_counters( $et_pb_number_counter ); 385 } 386 window.et_reinit_waypoint_modules(); 387 }, 1000 ); 388 } 389 } 390 391 function hex_to_rgba( color, alpha ) { 392 var color_16 = parseInt( color.replace( '#', '' ), 16 ), 393 red = ( color_16 >> 16 ) & 255, 394 green = ( color_16 >> 8 ) & 255, 395 blue = color_16 & 255, 396 alpha = alpha || 1, 397 rgba; 398 399 rgba = red + ',' + green + ',' + blue + ',' + alpha; 400 rgba = 'rgba(' + rgba + ')'; 401 402 return rgba; 403 } 404 405 if ( window.et_load_event_fired ) { 406 et_fix_slider_height( $et_slider ); 407 } else { 408 $et_window.on( 'load', function() { 409 et_fix_slider_height( $et_slider ); 410 } ); 411 } 412 413 $et_window.on( 'resize.et_simple_slider', function() { 414 et_fix_slider_height( $et_slider ); 415 } ); 416 417 $et_slider.et_slider_move_to = function (direction) { 418 $et_slide = $et_slider.closest_descendent(settings.slide); 419 var $active_slide = $et_slide.eq(et_active_slide); 420 421 $et_slider.et_animation_running = true; 422 423 $et_slider.removeClass('et_slide_transition_to_next et_slide_transition_to_previous').addClass('et_slide_transition_to_' + direction); 424 425 $et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide'); 426 427 if (direction === 'next' || direction === 'previous'){ 428 429 if (direction === 'next') { 430 et_active_slide = (et_active_slide + 1) < et_slides_number ? et_active_slide + 1 : 0; 431 } else { 432 et_active_slide = (et_active_slide - 1) >= 0 ? et_active_slide - 1 : et_slides_number - 1; 433 } 434 435 } else { 436 437 if (et_active_slide === direction) { 438 $et_slider.et_animation_running = false;
439 return; 440 } 441 442 et_active_slide = direction; 443 444 } 445 446 $et_slider.attr('data-active-slide', $et_slide.eq( et_active_slide ).data('slide-id')); 447 448 if (typeof et_slider_timer !== 'undefined') { 449 clearTimeout(et_slider_timer); 450 } 451 452 var $next_slide = $et_slide.eq(et_active_slide); 453 454 $et_slider.trigger('slide', {current: $active_slide, next: $next_slide}); 455 456 if ( typeof $active_slide.find('video')[0] !== 'undefined' && typeof $active_slide.find('video')[0]['player'] !== 'undefined' ) { 457 $active_slide.find('video')[0].player.pause(); 458 } 459 460 if ( typeof $next_slide.find('video')[0] !== 'undefined' && typeof $next_slide.find('video')[0]['player'] !== 'undefined' ) { 461 $next_slide.find('video')[0].player.play(); 462 } 463 464 var $active_slide_video = $active_slide.find('.et_pb_video_box iframe'); 465 466 if ( $active_slide_video.length ) { 467 var active_slide_video_src = $active_slide_video.attr('src'); 468 469 // Removes the "autoplay=1" parameter when switching slides 470 // by covering three possible cases: 471 472 // "?autoplay=1" at the end of the URL 473 active_slide_video_src = active_slide_video_src.replace(/\?autoplay=1$/, ''); 474 475 // "?autoplay=1" followed by another parameter 476 active_slide_video_src = active_slide_video_src.replace(/\?autoplay=1&(amp;)?/, '?'); 477 478 // "&autoplay=1" anywhere in the URL 479 active_slide_video_src = active_slide_video_src.replace(/&(amp;)?autoplay=1/, ''); 480 481 // Delays the URL update so that the cross-fade animation's smoothness is not affected 482 setTimeout(function() { 483 $active_slide_video.attr({ 484 'src': active_slide_video_src 485 }); 486 }, settings.fade_speed); 487 488 // Restores video overlay 489 $active_slide_video.parents('.et_pb_video_box').next('.et_pb_video_overlay').css({ 490 'display' : 'block', 491 'opacity' : 1 492 }); 493 } 494 495 $et_slider.trigger( 'simple_slider_before_move_to', { direction : direction, next_slide : $next_slide }); 496 497 $et_slide.each( function(){ 498 $(this).css( 'zIndex', 1 ); 499 } ); 500 // add 'slide-status' data attribute so it can be used to determine active slide in Visual Builder 501 $active_slide.css( 'zIndex', 2 ).removeClass( 'et-pb-active-slide' ).addClass('et-pb-moved-slide').data('slide-status', 'inactive'); 502 $next_slide.css( { 'display' : 'block', opacity : 0 } ).addClass( 'et-pb-active-slide' ).data('slide-status', 'active'); 503 504 et_fix_slider_content_images(); 505 506 et_fix_builder_content(); 507 508 if ( settings.use_controls ) 509 $et_slider_controls.removeClass( settings.control_active_class ).eq( et_active_slide ).addClass( settings.control_active_class ); 510 511 if ( settings.use_carousel && $et_slider_carousel_controls ) 512 $et_slider_carousel_controls.removeClass( settings.control_active_class ).eq( et_active_slide ).addClass( settings.control_active_class ); 513 514 if ( ! settings.tabs_animation ) { 515 $next_slide.animate( { opacity : 1 }, et_fade_speed ); 516 $active_slide.addClass( 'et_slide_transition' ).css( { 'display' : 'list-item', 'opacity' : 1 } ).animate( { opacity : 0 }, et_fade_speed, function(){ 517 var active_slide_layout_bg_color = et_get_bg_layout_color( $active_slide ), 518 next_slide_layout_bg_color = et_get_bg_layout_color( $next_slide ); 519 520 // Builder dynamically updates the slider options, so no need to set `display: none;` because it creates unwanted visual effects. 521 if (isBuilder) { 522 $(this).removeClass( 'et_slide_transition' ); 523 } else { 524 $(this).css('display', 'none').removeClass( 'et_slide_transition' ); 525 } 526 527 et_stop_video( $active_slide ); 528 529 $et_slider 530 .removeClass( active_slide_layout_bg_color ) 531 .addClass( next_slide_layout_bg_color ); 532 533 $et_slider.et_animation_running = false; 534 535 $et_slider.trigger( 'simple_slider_after_move_to', { next_slide : $next_slide } ); 536 } ); 537 } else { 538 $next_slide.css( { 'display' : 'none', opacity : 0 } ); 539 540 $active_slide.addClass( 'et_slide_transition' ).css( { 'display' : 'block', 'opacity' : 1 } ).animate( { opacity : 0 }, et_fade_speed, function(){ 541 $(this).css('display', 'none').removeClass( 'et_slide_transition' ); 542 543 $next_slide.css( { 'display' : 'block', 'opacity' : 0 } ).animate( { opacity : 1 }, et_fade_speed, function() { 544 $et_slider.et_animation_running = false;
545 546 $et_slider.trigger( 'simple_slider_after_move_to', { next_slide : $next_slide } ); 547 } ); 548 } ); 549 } 550 551 if ( $next_slide.find( '.et_parallax_bg' ).length ) { 552 // reinit parallax on slide change to make sure it displayed correctly 553 window.et_pb_parallax_init( $next_slide.find( '.et_parallax_bg' ) ); 554 } 555 556 et_slider_auto_rotate(); 557 } 558 559 /** 560 * Get current active device based on window width size. 561 * 562 * @return {String} View mode. 563 */ 564 function et_pb_get_current_window_mode() { 565 var window_width = $et_window.width(); 566 var current_mode = 'desktop'; 567 if ( window_width <= 980 && window_width > 479 ) { 568 current_mode = 'tablet'; 569 } else if ( window_width <= 479 ) { 570 current_mode = 'phone'; 571 } 572 573 return current_mode; 574 } 575 }; 576 577 $.fn.et_pb_simple_slider = function( options ) { 578 return this.each(function() { 579 var slider = $.data( this, 'et_pb_simple_slider' ); 580 return slider ? slider : new $.et_pb_simple_slider( this, options ); 581 }); 582 }; 583 584 var et_hash_module_seperator = '||', 585 et_hash_module_param_seperator = '|'; 586 587 function process_et_hashchange( hash ) { 588 // Bail early when hash is empty 589 if (! hash.length) { 590 return; 591 } 592 593 var modules; 594 var module_params; 595 var element; 596 597 if ((hash.indexOf(et_hash_module_seperator, 0)) !== - 1) { 598 modules = hash.split(et_hash_module_seperator); 599 for (var i = 0; i < modules.length; i ++) { 600 module_params = modules[i].split(et_hash_module_param_seperator); 601 element = module_params[0]; 602 module_params.shift(); 603 if (element.length && $('#' + element).length) { 604 $('#' + element).trigger({ 605 type: "et_hashchange", 606 params: module_params 607 }); 608 } 609 } 610 } else { 611 module_params = hash.split(et_hash_module_param_seperator); 612 element = module_params[0]; 613 module_params.shift(); 614 if (element.length && $('#' + element).length) { 615 $('#' + element).trigger({ 616 type: "et_hashchange", 617 params: module_params 618 }); 619 } 620 } 621 } 622 623 function et_set_hash( module_state_hash ) { 624 module_id = module_state_hash.split( et_hash_module_param_seperator )[0]; 625 if ( !$('#' + module_id ).length ) { 626 return; 627 } 628 629 if ( window.location.hash ) { 630 var hash = window.location.hash.substring(1), //Puts hash in variable, and removes the # character 631 new_hash = []; 632 633 if ( ( hash.indexOf( et_hash_module_seperator, 0 ) ) !== -1 ) { 634 modules = hash.split( et_hash_module_seperator ); 635 var in_hash = false; 636 for ( var i = 0; i < modules.length; i++ ) { 637 var element = modules[i].split( et_hash_module_param_seperator )[0]; 638 if ( element === module_id ) { 639 new_hash.push( module_state_hash ); 640 in_hash = true; 641 } else { 642 new_hash.push( modules[i] ); 643 } 644 } 645 if ( !in_hash ) { 646 new_hash.push( module_state_hash ); 647 } 648 } else { 649 module_params = hash.split( et_hash_module_param_seperator ); 650 var element = module_params[0]; 651 if ( element !== module_id ) { 652 new_hash.push( hash ); 653 } 654 new_hash.push( module_state_hash ); 655 } 656 657 hash = new_hash.join( et_hash_module_seperator ); 658 } else { 659 hash = module_state_hash; 660 } 661 662 var yScroll = document.body.scrollTop; 663 window.location.hash = hash; 664 document.body.scrollTop = yScroll; 665 } 666 667 $.et_pb_simple_carousel = function(el, options) { 668 var settings = $.extend( { 669 slide_duration : 500, 670 }, options ); 671 672 var $et_carousel = $(el), 673 $carousel_items = $et_carousel.find('.et_pb_carousel_items'), 674 $the_carousel_items = $carousel_items.find('.et_pb_carousel_item'); 675 676 $et_carousel.et_animation_running = false; 677 678 $et_carousel.addClass('container-width-change-notify').on('containerWidthChanged', function( event ){ 679 set_carousel_columns( $et_carousel ); 680 set_carousel_height( $et_carousel ); 681 }); 682 683 $carousel_items.data('items', $the_carousel_items.toArray() ); 684 $et_carousel.data('columns_setting_up', false ); 685 686 $carousel_items.prepend('<div class="et-pb-slider-arrows"><a class="et-pb-slider-arrow et-pb-arrow-prev" href="#">
686' + '<span>' + et_pb_custom.previous + '</span>' + '</a><a class="et-pb-slider-arrow et-pb-arrow-next" href="#">' + '<span>' + et_pb_custom.next + '</span>' + '</a></div>'); 687 688 set_carousel_columns( $et_carousel ); 689 set_carousel_height( $et_carousel ); 690 691 $et_carousel_next = $et_carousel.find( '.et-pb-arrow-next' ); 692 $et_carousel_prev = $et_carousel.find( '.et-pb-arrow-prev' ); 693 694 $et_carousel.on( 'click', '.et-pb-arrow-next', function(){ 695 if ( $et_carousel.et_animation_running ) return false; 696 697 $et_carousel.et_carousel_move_to( 'next' ); 698 699 return false; 700 } ); 701 702 $et_carousel.on( 'click', '.et-pb-arrow-prev', function(){ 703 if ( $et_carousel.et_animation_running ) return false; 704 705 $et_carousel.et_carousel_move_to( 'previous' ); 706 707 return false; 708 } ); 709 710 // swipe support requires et-jquery-touch-mobile 711 $et_carousel.on( 'swipeleft', function() { 712 $et_carousel.et_carousel_move_to( 'next' ); 713 }); 714 $et_carousel.on( 'swiperight', function() { 715 $et_carousel.et_carousel_move_to( 'previous' ); 716 }); 717 718 function set_carousel_height( $the_carousel ) { 719 var carousel_items_width = $the_carousel_items.width(), 720 carousel_items_height = $the_carousel_items.height(); 721 722 // Account for borders when needed 723 if ($the_carousel.parent().hasClass('et_pb_with_border')) { 724 carousel_items_height = $the_carousel_items.outerHeight(); 725 } 726 $carousel_items.css('height', carousel_items_height + 'px' ); 727 } 728 729 function set_carousel_columns( $the_carousel ) { 730 var columns = 3; 731 var $carousel_parent = $the_carousel.parents('.et_pb_column:not(".et_pb_specialty_column")'); 732 733 if ($carousel_parent.hasClass('et_pb_column_4_4') || $carousel_parent.hasClass('et_pb_column_3_4') || $carousel_parent.hasClass('et_pb_column_2_3')) { 734 if ($et_window.width() >= 768) { 735 columns = 4; 736 } 737 } else if ($carousel_parent.hasClass('et_pb_column_1_4')) { 738 if ($et_window.width() <= 480 && $et_window.width() >= 980) { 739 columns = 2; 740 } 741 } else if ($carousel_parent.hasClass('et_pb_column_3_5')) { 742 columns = 4; 743 } else if ($carousel_parent.hasClass('et_pb_column_1_5') || $carousel_parent.hasClass('et_pb_column_1_6')) { 744 columns = 2; 745 } 746 747 if ( columns === $carousel_items.data('portfolio-columns') ) { 748 return; 749 } 750 751 if ( $the_carousel.data('columns_setting_up') ) { 752 return; 753 } 754 755 $the_carousel.data('columns_setting_up', true ); 756 757 // store last setup column 758 $carousel_items.removeClass('columns-' + $carousel_items.data('portfolio-columns') ); 759 $carousel_items.addClass('columns-' + columns ); 760 $carousel_items.data('portfolio-columns', columns ); 761 762 // kill all previous groups to get ready to re-group 763 if ( $carousel_items.find('.et-carousel-group').length ) { 764 $the_carousel_items.appendTo( $carousel_items ); 765 $carousel_items.find('.et-carousel-group').remove(); 766 } 767 768 // setup the grouping 769 var the_carousel_items = $carousel_items.data('items'), 770 $carousel_group = $('<div class="et-carousel-group active">').appendTo( $carousel_items ); 771 772 $the_carousel_items.data('position', ''); 773 if ( the_carousel_items.length <= columns ) { 774 $carousel_items.find('.et-pb-slider-arrows').hide(); 775 } else { 776 $carousel_items.find('.et-pb-slider-arrows').show(); 777 } 778 779 for ( position = 1, x=0 ;x < the_carousel_items.length; x++, position++ ) { 780 if ( x < columns ) { 781 $( the_carousel_items[x] ).show(); 782 $( the_carousel_items[x] ).appendTo( $carousel_group ); 783 $( the_carousel_items[x] ).data('position', position ); 784 $( the_carousel_items[x] ).addClass('position_' + position ); 785 } else { 786 position = $( the_carousel_items[x] ).data('position'); 787 $( the_carousel_items[x] ).removeClass('position_' + position ); 788 $( the_carousel_items[x] ).data('position', '' ); 789 $( the_carousel_items[x] ).hide(); 790 } 791 } 792 793 $the_carousel.data('columns_setting_up', false ); 794 795 } /* end set_carousel_columns() */ 796 797 $et_carousel.et_carousel_move_to = function ( direction ) { 798 var $active_carousel_group = $carousel_items.find('.et-carousel-group.active'), 799 items = $carousel_items.data('items'), 800 columns = $carousel_items.data('portfolio-columns'); 801 802 $et_carousel.et_animation_running = true; 803 804 var left = 0; 805 $active_carousel_group.children().each(function(){ 806 $(this).css({'position':'absolute', 'left': left }); 807 left = left + $(this).outerWidth(true); 808 }); 809 810 // Avoid unwanted horizontal scroll on body when carousel is slided 811 $('body').addClass('et-pb-is-sliding-carousel'); 812 813 // Deterimine number of carousel group item 814 var carousel_group_item_size = $active_carousel_group.find('.et_pb_carousel_item').size(); 815 var carousel_group_item_progress = 0; 816 817 if ( direction == 'next' ) { 818 var $next_carousel_group, 819 current_position = 1, 820 next_position = 1, 821 active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ), 822 active_items_end = active_items_start + columns, 823 next_items_start = active_items_end, 824 next_items_end = next_items_start + columns; 825 826 $next_carousel_group = $('<div class="et-carousel-group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group ); 827 $next_carousel_group.css({ 'width': $active_carousel_group.innerWidth() }).show(); 828 829 // this is an endless loop, so it can decide internally when to break out, so that next_position 830 // can get filled up, even to the extent of an element having both and current_ and next_ position 831 for( x = 0, total = 0 ; ; x++, total++ ) { 832 if ( total >= active_items_start && total < active_items_end ) { 833 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 834 $( items[x] ).data('current_position', current_position ); 835 current_position++; 836 } 837 838 if ( total >= next_items_start && total < next_items_end ) { 839 $( items[x] ).data('next_position', next_position ); 840 $( items[x] ).addClass('changing_position next_position next_position_' + next_position ); 841 842 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 843 $( items[x] ).addClass('container_append'); 844 } else { 845 $( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 846 $( items[x] ).addClass('delayed_container_append'); 847 } 848 849 next_position++; 850 } 851 852 if ( next_position > columns ) { 853 break; 854 } 855 856 if ( x >= ( items.length -1 )) { 857 x = -1; 858 } 859 } 860 861 var sorted = $carousel_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 862 var el_a_position = parseInt( $(a).data('next_position') ); 863 var el_b_position = parseInt( $(b).data('next_position') ); 864 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 865 }); 866 867 $( sorted ).show().appendTo( $next_carousel_group ); 868 869 var left = 0; 870 $next_carousel_group.children().each(function(){ 871 $(this).css({'position':'absolute', 'left': left }); 872 left = left + $(this).outerWidth(true); 873 }); 874 875 $active_carousel_group.animate({ 876 left: '-100%' 877 }, {
878 duration: settings.slide_duration, 879 progress: function(animation, progress) { 880 if (progress > (carousel_group_item_progress/carousel_group_item_size)) { 881 carousel_group_item_progress++; 882 883 // Adding classnames on incoming/outcoming carousel item 884 $active_carousel_group.find('.et_pb_carousel_item:nth-child(' + carousel_group_item_progress + ')').addClass('item-fade-out'); 885 $next_carousel_group.find('.et_pb_carousel_item:nth-child(' + carousel_group_item_progress + ')').addClass('item-fade-in'); 886 } 887 }, 888 complete: function() { 889 $carousel_items.find('.delayed_container_append').each(function(){ 890 left = $( '#' + $(this).attr('id') + '-dup' ).css('left'); 891 $(this).css({'position':'absolute', 'left': left }); 892 $(this).appendTo( $next_carousel_group ); 893 }); 894 895 $active_carousel_group.removeClass('active'); 896 $active_carousel_group.children().each(function(){ 897 position = $(this).data('position'); 898 current_position = $(this).data('current_position'); 899 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 900 $(this).data('position', ''); 901 $(this).data('current_position', ''); 902 $(this).hide(); 903 $(this).css({'position': '', 'left': ''}); 904 $(this).appendTo( $carousel_items ); 905 }); 906 907 // Removing classnames on incoming/outcoming carousel item 908 $carousel_items.find('.item-fade-out').removeClass('item-fade-out'); 909 $next_carousel_group.find('.item-fade-in').removeClass('item-fade-in'); 910 911 // Remove horizontal scroll prevention class name on body 912 $('body').removeClass('et-pb-is-sliding-carousel'); 913 914 $active_carousel_group.remove(); 915 916 } 917 } ); 918 919 next_left = $active_carousel_group.width() + parseInt( $the_carousel_items.first().css('marginRight').slice(0, -2) ); 920 $next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: next_left }); 921 $next_carousel_group.animate({ 922 left: '0%' 923 }, { 924 duration: settings.slide_duration, 925 complete: function(){ 926 $next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''}); 927 928 $next_carousel_group.find('.changing_position').each(function( index ){ 929 position = $(this).data('position'); 930 current_position = $(this).data('current_position'); 931 next_position = $(this).data('next_position'); 932 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position ); 933 $(this).data('current_position', ''); 934 $(this).data('next_position', ''); 935 $(this).data('position', ( index + 1 ) ); 936 }); 937 938 $next_carousel_group.children().css({'position': '', 'left': ''}); 939 $next_carousel_group.find('.delayed_container_append_dup').remove(); 940 941 $et_carousel.et_animation_running = false; 942 } 943 } ); 944 945 } else if ( direction == 'previous' ) { 946 var $prev_carousel_group, 947 current_position = columns, 948 prev_position = columns, 949 columns_span = columns - 1, 950 active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ), 951 active_items_end = active_items_start - columns_span, 952 prev_items_start = active_items_end - 1, 953 prev_items_end = prev_items_start - columns_span; 954 955 $prev_carousel_group = $('<div class="et-carousel-group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group ); 956 $prev_carousel_group.css({ 'left': '-' + $active_carousel_group.innerWidth(), 'width': $active_carousel_group.innerWidth() }).show(); 957 958 // this is an endless loop, so it can decide internally when to break out, so that next_position 959 // can get filled up, even to the extent of an element having both and current_ and next_ position 960 for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) { 961 962 if ( total <= active_items_start && total >= active_items_end ) { 963 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 964 $( items[x] ).data('current_position', current_position ); 965 current_position--; 966 } 967 968 if ( total <= prev_items_start && total >= prev_items_end ) { 969 $( items[x] ).data('prev_position', prev_position ); 970 $( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position ); 971 972 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 973 $( items[x] ).addClass('container_append'); 974 } else { 975 $( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 976 $( items[x] ).addClass('delayed_container_append'); 977 } 978 979 prev_position--; 980 } 981 982 if ( prev_position <= 0 ) { 983 break; 984 } 985 986 if ( x == 0 ) { 987 x = items.length; 988 } 989 } 990 991 var sorted = $carousel_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 992 var el_a_position = parseInt( $(a).data('prev_position') ); 993 var el_b_position = parseInt( $(b).data('prev_position') ); 994 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 995 }); 996 997 $( sorted ).show().appendTo( $prev_carousel_group ); 998 999 var left = 0; 1000 $prev_carousel_group.children().each(function(){ 1001 $(this).css({'position':'absolute', 'left': left }); 1002 left = left + $(this).outerWidth(true); 1003 }); 1004 1005 $active_carousel_group.animate({ 1006 left: '100%' 1007 }, {
1008 duration: settings.slide_duration, 1009 progress: function(animation, progress) { 1010 if (progress > (carousel_group_item_progress/carousel_group_item_size)) { 1011 1012 var group_item_nth = carousel_group_item_size - carousel_group_item_progress; 1013 1014 // Add fadeIn / fadeOut className to incoming/outcoming carousel item 1015 $active_carousel_group.find('.et_pb_carousel_item:nth-child(' + group_item_nth + ')').addClass('item-fade-out'); 1016 $prev_carousel_group.find('.et_pb_carousel_item:nth-child(' + group_item_nth + ')').addClass('item-fade-in'); 1017 1018 carousel_group_item_progress++; 1019 } 1020 }, 1021 complete: function() { 1022 $carousel_items.find('.delayed_container_append').reverse().each(function(){ 1023 left = $( '#' + $(this).attr('id') + '-dup' ).css('left'); 1024 $(this).css({'position':'absolute', 'left': left }); 1025 $(this).prependTo( $prev_carousel_group ); 1026 }); 1027 1028 $active_carousel_group.removeClass('active'); 1029 $active_carousel_group.children().each(function(){ 1030 position = $(this).data('position'); 1031 current_position = $(this).data('current_position'); 1032 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 1033 $(this).data('position', ''); 1034 $(this).data('current_position', ''); 1035 $(this).hide(); 1036 $(this).css({'position': '', 'left': ''}); 1037 $(this).appendTo( $carousel_items ); 1038 }); 1039 1040 // Removing classnames on incoming/outcoming carousel item 1041 $carousel_items.find('.item-fade-out').removeClass('item-fade-out'); 1042 $prev_carousel_group.find('.item-fade-in').removeClass('item-fade-in'); 1043 1044 // Remove horizontal scroll prevention class name on body 1045 $('body').removeClass('et-pb-is-sliding-carousel'); 1046 1047 $active_carousel_group.remove(); 1048 } 1049 } ); 1050 1051 prev_left = (-1) * $active_carousel_group.width() - parseInt( $the_carousel_items.first().css('marginRight').slice(0, -2) ); 1052 $prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: prev_left }); 1053 $prev_carousel_group.animate({ 1054 left: '0%' 1055 }, { 1056 duration: settings.slide_duration, 1057 complete: function(){ 1058 $prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''}); 1059 1060 $prev_carousel_group.find('.delayed_container_append_dup').remove(); 1061 1062 $prev_carousel_group.find('.changing_position').each(function( index ){ 1063 position = $(this).data('position'); 1064 current_position = $(this).data('current_position'); 1065 prev_position = $(this).data('prev_position'); 1066 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position ); 1067 $(this).data('current_position', ''); 1068 $(this).data('prev_position', ''); 1069 position = index + 1; 1070 $(this).data('position', position ); 1071 $(this).addClass('position_' + position ); 1072 }); 1073 1074 $prev_carousel_group.children().css({'position': '', 'left': ''}); 1075 $et_carousel.et_animation_running = false; 1076 } 1077 } ); 1078 } 1079 } 1080 }; 1081 1082 $.fn.et_pb_simple_carousel = function( options ) { 1083 return this.each(function() { 1084 var carousel = $.data( this, 'et_pb_simple_carousel' ); 1085 return carousel ? carousel : new $.et_pb_simple_carousel( this, options ); 1086 }); 1087 }; 1088 1089 function et_init_audio_modules() { 1090 if (typeof jQuery.fn.mediaelementplayer === 'undefined' || isVB) { 1091 return; 1092 } 1093 1094 jQuery('.et_audio_container').each(function () { 1095 var $this = jQuery(this); 1096 1097 if ($this.find('.mejs-container:first').length > 0) { 1098 return; 1099 } 1100 1101 $this.find('audio').mediaelementplayer(window._wpmejsSettings); 1102 }); 1103 } 1104 1105 $(document).ready( function(){ 1106 /** 1107 * Provide event listener for plugins to hook up to 1108 */ 1109 $(window).trigger('et_pb_before_init_modules'); 1110 1111 var $et_pb_slider = $( '.et_pb_slider' ), 1112 $et_pb_tabs = $( '.et_pb_tabs' ), 1113 $et_pb_video_section = $('.et_pb_section_video_bg'), 1114 $et_pb_newsletter_button = $( '.et_pb_newsletter_button' ), 1115 $et_pb_filterable_portfolio = $( '.et_pb_filterable_portfolio' ), 1116 $et_pb_fullwidth_portfolio = $( '.et_pb_fullwidth_portfolio' ), 1117 $et_pb_gallery = $( '.et_pb_gallery' ), 1118 $et_pb_countdown_timer = $( '.et_pb_countdown_timer' ), 1119 $et_post_gallery = $( '.et_post_gallery' ), 1120 $et_lightbox_image = $( '.et_pb_lightbox_image'), 1121 $et_pb_map = $( '.et_pb_map_container' ), 1122 $et_pb_circle_counter = $( '.et_pb_circle_counter' ), 1123 $et_pb_number_counter = $( '.et_pb_number_counter' ), 1124 $et_pb_parallax = $( '.et_parallax_bg' ), 1125 $et_pb_shop = $( '.et_pb_shop' ), 1126 $et_pb_post_fullwidth = $( '.single.et_pb_pagebuilder_layout.et_full_width_page' ), 1127 $et_pb_background_layout_hoverable = $('[data-background-layout][data-background-layout-hover]'), 1128 et_is_mobile_device = navigator.userAgent.match( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/ ) !== null, 1129 et_is_ipad = navigator.userAgent.match( /iPad/ ), 1130 et_is_ie9 = navigator.userAgent.match( /MSIE 9.0/ ) !== null, 1131 et_all_rows = $('.et_pb_row'), 1132 $et_container = ! et_pb_custom.is_builder_plugin_used ? $( '.container' ) : et_all_rows, 1133 et_container_width = $et_container.width(), 1134 et_is_vertical_fixed_nav = $( 'body' ).hasClass( 'et_vertical_fixed' ), 1135 et_is_rtl = $( 'body' ).hasClass( 'rtl' ), 1136 et_hide_nav = $( 'body' ).hasClass( 'et_hide_nav' ), 1137 et_header_style_left = $( 'body' ).hasClass( 'et_header_style_left' ), 1138 $top_header = $('#top-header'), 1139 $main_header = $('#main-header'), 1140 $main_container_wrapper = $( '#page-container' ), 1141 $et_transparent_nav = $( '.et_transparent_nav' ), 1142 $et_pb_first_row = $( 'body.et_pb_pagebuilder_layout .et_pb_section:first-child' ), 1143 $et_main_content_first_row = $( '#main-content .container:first-child' ), 1144 $et_main_content_first_row_meta_wrapper = $et_main_content_first_row.find('.et_post_meta_wrapper:first'), 1145 $et_main_content_first_row_meta_wrapper_title = $et_main_content_first_row_meta_wrapper.find( 'h1' ), 1146 $et_main_content_first_row_content = $et_main_content_first_row.find('.entry-content:first'), 1147 $et_single_post = $( 'body.single-post' ), 1148 etRecalculateOffset = false, 1149 et_header_height, 1150 et_header_modifier, 1151 et_header_offset, 1152 et_primary_header_top, 1153 $et_header_style_split = $('.et_header_style_split'), 1154 $et_top_navigation = $('#et-top-navigation'), 1155 $logo = $('#logo'), 1156 $et_sticky_image = $('.et_pb_image_sticky'), 1157 $et_pb_counter_amount = $('.et_pb_counter_amount'), 1158 $et_pb_carousel = $( '.et_pb_carousel' ), 1159 $et_menu_selector = et_pb_custom.is_divi_theme_used ? $( 'ul.nav' ) : $( '.et_pb_fullwidth_menu ul.nav' ), 1160 et_pb_ab_bounce_rate = et_pb_custom.ab_bounce_rate * 1000, 1161 et_pb_ab_logged_status = { 1162 read_page: false, 1163 read_goal: false, 1164 view_goal: false, 1165 click_goal: false, 1166 con_goal: false, 1167 con_short: false, 1168 }, 1169 et_animation_breakpoint = ''; 1170 1171 var grid_containers = $('.et_pb_grid_item').parent().get(); 1172 var $hover_gutter_modules = $('.et_pb_gutter_hover'); 1173 1174 window.et_pb_slider_init = function( $this_slider ) { 1175 var et_slider_settings = { 1176 fade_speed : 700, 1177 slide : ! $this_slider.hasClass( 'et_pb_gallery' ) ? '.et_pb_slide' : '.et_pb_gallery_item' 1178 }; 1179 1180 if ( $this_slider.hasClass('et_pb_slider_no_arrows') ) 1181 et_slider_settings.use_arrows = false;
1182 1183 if ( $this_slider.hasClass('et_pb_slider_no_pagination') ) 1184 et_slider_settings.use_controls = false; 1185 1186 if ( $this_slider.hasClass('et_slider_auto') ) { 1187 var et_slider_autospeed_class_value = /et_slider_speed_(\d+)/g; 1188 1189 et_slider_settings.slideshow = true; 1190 1191 var et_slider_autospeed = et_slider_autospeed_class_value.exec( $this_slider.attr('class') ); 1192 1193 et_slider_settings.slideshow_speed = et_slider_autospeed === null ? 10 : et_slider_autospeed[1]; 1194 } 1195 1196 if ( $this_slider.parent().hasClass('et_pb_video_slider') ) { 1197 et_slider_settings.controls_below = true; 1198 et_slider_settings.append_controls_to = $this_slider.parent(); 1199 1200 setTimeout( function() { 1201 $( '.et_pb_preload' ).removeClass( 'et_pb_preload' ); 1202 }, 500 ); 1203 } 1204 1205 if ( $this_slider.hasClass('et_pb_slider_carousel') ) 1206 et_slider_settings.use_carousel = true; 1207 1208 $this_slider.et_pb_simple_slider( et_slider_settings ); 1209 }; 1210 1211 var $et_top_menu = $et_menu_selector, 1212 et_parent_menu_longpress_limit = 300, 1213 et_parent_menu_longpress_start, 1214 et_parent_menu_click = true, 1215 is_frontend_builder = isBuilder, 1216 et_menu_hover_triggered = false; 1217 1218 // log the conversion if visitor is on Thank You page and comes from the Shop module which is the Goal 1219 if ( $( '.et_pb_ab_shop_conversion' ).length && typeof et_pb_get_cookie_value( 'et_pb_ab_shop_log' ) !== 'undefined' && '' !== et_pb_get_cookie_value( 'et_pb_ab_shop_log' ) ) { 1220 var shop_log_data = et_pb_get_cookie_value( 'et_pb_ab_shop_log' ).split( '_' ); 1221 page_id = shop_log_data[0], 1222 subject_id = shop_log_data[1], 1223 test_id = shop_log_data[2]; 1224 1225 et_pb_ab_update_stats( 'con_goal', page_id, subject_id, test_id ); 1226 1227 // remove the cookie after conversion is logged 1228 et_pb_set_cookie( 0, 'et_pb_ab_shop_log=true' ); 1229 } 1230 1231 // log the conversion if visitor is on page with tracking shortcode 1232 if ( $( '.et_pb_ab_split_track' ).length ) { 1233 $( '.et_pb_ab_split_track' ).each( function() { 1234 var tracking_test = $( this ).data( 'test_id' ), 1235 cookies_name = 'et_pb_ab_shortcode_track_' + tracking_test; 1236 1237 if ( typeof et_pb_get_cookie_value( cookies_name ) !== 'undefined' && '' !== et_pb_get_cookie_value( cookies_name ) ) { 1238 var track_data = et_pb_get_cookie_value( cookies_name ).split( '_' ); 1239 page_id = track_data[0], 1240 subject_id = track_data[1], 1241 test_id = track_data[2]; 1242 1243 et_pb_ab_update_stats( 'con_short', page_id, subject_id, test_id ); 1244 1245 // remove the cookie after conversion is logged 1246 et_pb_set_cookie( 0, cookies_name + '=true' ); 1247 } 1248 }); 1249 } 1250 1251 // Handle gutter hover options 1252 if ($hover_gutter_modules.length > 0) { 1253 $hover_gutter_modules.each(function() { 1254 var $thisEl = $(this); 1255 var originalGutter = $thisEl.data('original_gutter'); 1256 var hoverGutter = $thisEl.data('hover_gutter'); 1257 1258 $thisEl.hover( 1259 function() { 1260 $thisEl.removeClass('et_pb_gutters' + originalGutter); 1261 $thisEl.addClass('et_pb_gutters' + hoverGutter); 1262 }, 1263 function() { 1264 $thisEl.removeClass('et_pb_gutters' + hoverGutter); 1265 $thisEl.addClass('et_pb_gutters' + originalGutter); 1266 } 1267 ); 1268 }); 1269 } 1270 1271 // init AB Testing if enabled 1272 if ( et_pb_custom.is_ab_testing_active ) { 1273 et_pb_init_ab_test(); 1274 } 1275 1276 if (et_all_rows.length) { 1277 et_all_rows.each(function () { 1278 var $this_row = $(this), 1279 row_class = ''; 1280 1281 row_class = et_get_column_types($this_row.find('>.et_pb_column')); 1282 1283 if ('' !== row_class) { 1284 $this_row.addClass(row_class); 1285 } 1286 1287 if ($this_row.find('.et_pb_row_inner').length) { 1288 $this_row.find('.et_pb_row_inner').each(function () { 1289 var $this_row_inner = $(this); 1290 row_class = et_get_column_types($this_row_inner.find('.et_pb_column')); 1291 1292 if ('' !== row_class) { 1293 $this_row_inner.addClass(row_class); 1294 } 1295 }); 1296 } 1297 }); 1298 } 1299 1300 function et_get_column_types($columns) { 1301 var row_class = ''; 1302 1303 if ($columns.length) { 1304 $columns.each(function () { 1305 var $column = $(this); 1306 var column_type = $column.attr('class').split('et_pb_column_')[1]; 1307 var column_type_clean = typeof column_type !== 'undefined' ? column_type.split(' ', 1)[0] : '4_4'; 1308 var column_type_updated = column_type_clean.replace('_', '-').trim(); 1309 1310 row_class += '_' + column_type_updated; 1311 }); 1312 1313 if ((row_class.indexOf('1-4') !== -1) 1314 || (row_class.indexOf('1-5_1-5') !== -1) 1315 || (row_class.indexOf('1-6_1-6') !== -1)) { 1316 switch (row_class) { 1317 case '_1-4_1-4_1-4_1-4': 1318 row_class = 'et_pb_row_4col'; 1319 break; 1320 case '_1-5_1-5_1-5_1-5_1-5': 1321 row_class = 'et_pb_row_5col'; 1322 break; 1323 case '_1-6_1-6_1-6_1-6_1-6_1-6': 1324 row_class = 'et_pb_row_6col'; 1325 break; 1326 default: 1327 row_class = 'et_pb_row' + row_class; 1328 } 1329 } else { 1330 row_class = ''; 1331 } 1332 } 1333 return row_class; 1334 } 1335 1336 window.et_pb_init_nav_menu( $et_top_menu ); 1337 1338 $et_sticky_image.each( function() { 1339 window.et_pb_apply_sticky_image_effect($(this)); 1340 } ); 1341 1342 if ( et_is_mobile_device ) { 1343 $( '.et_pb_section_video_bg' ).each( function() { 1344 var $this_el = $(this); 1345 1346 $this_el.closest( '.et_pb_preload' ).removeClass( 'et_pb_preload' ); 1347 1348 // Only remove when it has opened class. 1349 if ($this_el.hasClass("opened")) { 1350 $this_el.remove(); 1351 } 1352 } ); 1353 1354 $( 'body' ).addClass( 'et_mobile_device' ); 1355 1356 if ( ! et_is_ipad ) { 1357 $( 'body' ).addClass( 'et_mobile_device_not_ipad' ); 1358 } 1359 } 1360 1361 if ( et_is_ie9 ) { 1362 $( 'body' ).addClass( 'et_ie9' ); 1363 } 1364 1365 if ( $et_pb_video_section.length || is_frontend_builder ) { 1366 window.et_pb_video_section_init = function( $et_pb_video_section ) { 1367 $et_pb_video_section.find( 'video' ).mediaelementplayer( { 1368 pauseOtherPlayers: false, 1369 success : function( mediaElement, domObject ) { 1370 mediaElement.addEventListener( 'loadeddata', function() { 1371 et_pb_resize_section_video_bg( $(domObject) );
1372 et_pb_center_video( $(domObject).closest( '.mejs-video' ) ); 1373 }, false ); 1374 1375 mediaElement.addEventListener( 'canplay', function() { 1376 $(domObject).closest( '.et_pb_preload' ).removeClass( 'et_pb_preload' ); 1377 }, false ); 1378 } 1379 } ); 1380 }; 1381 et_pb_video_section_init( $et_pb_video_section ); 1382 } 1383 1384 et_init_audio_modules(); 1385 1386 if ( $et_post_gallery.length ) { 1387 // swipe support in magnific popup only if gallery exists 1388 var magnificPopup = $.magnificPopup.instance; 1389 1390 $( 'body' ).on( 'swiperight', '.mfp-container', function() { 1391 magnificPopup.prev(); 1392 } ); 1393 $( 'body' ).on( 'swipeleft', '.mfp-container', function() { 1394 magnificPopup.next(); 1395 } ); 1396 1397 $et_post_gallery.each(function() { 1398 $(this).magnificPopup( { 1399 delegate: '.et_pb_gallery_image a', 1400 type: 'image', 1401 removalDelay: 500, 1402 gallery: { 1403 enabled: true, 1404 navigateByImgClick: true 1405 }, 1406 mainClass: 'mfp-fade', 1407 zoom: { 1408 enabled: ! et_pb_custom.is_builder_plugin_used, 1409 duration: 500, 1410 opener: function(element) { 1411 return element.find('img'); 1412 } 1413 }, 1414 autoFocusLast: false 1415 } ); 1416 } ); 1417 // prevent attaching of any further actions on click 1418 $et_post_gallery.find( 'a' ).unbind( 'click' ); 1419 } 1420 1421 if ( $et_lightbox_image.length || is_frontend_builder ) { 1422 // prevent attaching of any further actions on click 1423 $et_lightbox_image.unbind( 'click' ); 1424 $et_lightbox_image.bind( 'click' ); 1425 1426 window.et_pb_image_lightbox_init = function( $et_lightbox_image ) { 1427 // Delay the initialization if magnificPopup hasn't finished loading yet. 1428 if (!$et_lightbox_image.magnificPopup) { 1429 return jQuery(window).on('load', function() {window.et_pb_image_lightbox_init($et_lightbox_image);}); 1430 } 1431 $et_lightbox_image.magnificPopup( { 1432 type: 'image', 1433 removalDelay: 500, 1434 mainClass: 'mfp-fade', 1435 zoom: { 1436 enabled: ! et_pb_custom.is_builder_plugin_used, 1437 duration: 500, 1438 opener: function(element) { 1439 return element.find('img'); 1440 } 1441 }, 1442 autoFocusLast: false 1443 } ); 1444 }; 1445 1446 et_pb_image_lightbox_init( $et_lightbox_image ); 1447 } 1448 1449 if ( $et_pb_slider.length || is_frontend_builder ) { 1450 $et_pb_slider.each( function() { 1451 $this_slider = $(this); 1452 1453 et_pb_slider_init( $this_slider ); 1454 } ); 1455 } 1456 1457 $et_pb_carousel = $( '.et_pb_carousel' ); 1458 if ( $et_pb_carousel.length || is_frontend_builder ) { 1459 $et_pb_carousel.each( function() { 1460 var $this_carousel = $(this), 1461 et_carousel_settings = { 1462 slide_duration: 1000 1463 }; 1464 1465 $this_carousel.et_pb_simple_carousel( et_carousel_settings ); 1466 } ); 1467 } 1468 1469 if (grid_containers.length || is_frontend_builder) { 1470 $(grid_containers).each(function () { 1471 window.et_pb_set_responsive_grid($(this), '.et_pb_grid_item'); 1472 }); 1473 } 1474 1475 if ( $et_pb_fullwidth_portfolio.length || is_frontend_builder ) { 1476 1477 window.et_fullwidth_portfolio_init = function( $the_portfolio ) { 1478 var $portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'); 1479 1480 $portfolio_items.data('items', $portfolio_items.find('.et_pb_portfolio_item').toArray() ); 1481 $the_portfolio.data('columns_setting_up', false ); 1482 1483 if ( $the_portfolio.hasClass('et_pb_fullwidth_portfolio_carousel') ) { 1484 // add left and right arrows 1485 $portfolio_items.prepend('<div class="et-pb-slider-arrows"><a class="et-pb-arrow-prev" href="#">' + '<span>' + et_pb_custom.previous + '</span>' + '</a><a class="et-pb-arrow-next" href="#">' + '<span>' + et_pb_custom.next + '</span>' + '</a></div>'); 1486 1487 set_fullwidth_portfolio_columns( $the_portfolio, true ); 1488 1489 et_carousel_auto_rotate( $the_portfolio ); 1490 1491 // swipe support 1492 $the_portfolio.on( 'swiperight', function() { 1493 $( this ).find( '.et-pb-arrow-prev' ).click(); 1494 }); 1495 $the_portfolio.on( 'swipeleft', function() { 1496 $( this ).find( '.et-pb-arrow-next' ).click(); 1497 }); 1498 1499 $the_portfolio.hover( 1500 function(){ 1501 $(this).addClass('et_carousel_hovered'); 1502 if ( typeof $(this).data('et_carousel_timer') != 'undefined' ) { 1503 clearInterval( $(this).data('et_carousel_timer') ); 1504 } 1505 }, 1506 function(){ 1507 $(this).removeClass('et_carousel_hovered'); 1508 et_carousel_auto_rotate( $(this) ); 1509 } 1510 ); 1511 1512 $the_portfolio.data('carouseling', false ); 1513 1514 $the_portfolio.on('click', '.et-pb-slider-arrows a', function(e){ 1515 fullwidth_portfolio_carousel_slide( $( this) ); 1516 e.preventDefault(); 1517 return false;
1518 }); 1519 1520 } else { 1521 // setup fullwidth portfolio grid 1522 set_fullwidth_portfolio_columns( $the_portfolio, false ); 1523 } 1524 }; 1525 1526 function fullwidth_portfolio_carousel_slide( $arrow ) { 1527 var $the_portfolio = $arrow.parents('.et_pb_fullwidth_portfolio'), 1528 $portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'), 1529 $the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'), 1530 $active_carousel_group = $portfolio_items.find('.et_pb_carousel_group.active'), 1531 slide_duration = 700, 1532 items = $portfolio_items.data('items'), 1533 columns = $portfolio_items.data('portfolio-columns'), 1534 item_width = $active_carousel_group.innerWidth() / columns, 1535 original_item_width = ( 100 / columns ) + '%'; 1536 1537 if ( 'undefined' == typeof items ) { 1538 return; 1539 } 1540 1541 if ( $the_portfolio.data('carouseling') ) { 1542 return; 1543 } 1544 1545 $the_portfolio.data('carouseling', true); 1546 1547 $active_carousel_group.children().each(function(){ 1548 $(this).css({'width': item_width + 1, 'max-width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('position') - 1 ) ) }); 1549 }); 1550 1551 if ( $arrow.hasClass('et-pb-arrow-next') ) { 1552 var $next_carousel_group, 1553 current_position = 1, 1554 next_position = 1, 1555 active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ), 1556 active_items_end = active_items_start + columns, 1557 next_items_start = active_items_end, 1558 next_items_end = next_items_start + columns, 1559 active_carousel_width = $active_carousel_group.innerWidth(); 1560 1561 $next_carousel_group = $('<div class="et_pb_carousel_group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group ); 1562 $next_carousel_group.css({ 'width': active_carousel_width, 'max-width': active_carousel_width }).show(); 1563 1564 // this is an endless loop, so it can decide internally when to break out, so that next_position 1565 // can get filled up, even to the extent of an element having both and current_ and next_ position 1566 for( x = 0, total = 0 ; ; x++, total++ ) { 1567 if ( total >= active_items_start && total < active_items_end ) { 1568 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 1569 $( items[x] ).data('current_position', current_position ); 1570 current_position++; 1571 } 1572 1573 if ( total >= next_items_start && total < next_items_end ) { 1574 $( items[x] ).data('next_position', next_position ); 1575 $( items[x] ).addClass('changing_position next_position next_position_' + next_position ); 1576 1577 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 1578 $( items[x] ).addClass('container_append'); 1579 } else { 1580 $( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 1581 $( items[x] ).addClass('delayed_container_append'); 1582 } 1583 1584 next_position++; 1585 } 1586 1587 if ( next_position > columns ) { 1588 break; 1589 } 1590 1591 if ( x >= ( items.length -1 )) { 1592 x = -1; 1593 } 1594 } 1595 1596 sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 1597 var el_a_position = parseInt( $(a).data('next_position') ); 1598 var el_b_position = parseInt( $(b).data('next_position') ); 1599 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 1600 }); 1601 1602 $( sorted ).show().appendTo( $next_carousel_group ); 1603 1604 $next_carousel_group.children().each(function(){ 1605 $(this).css({'width': item_width, 'max-width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) }); 1606 }); 1607 1608 $active_carousel_group.animate({ 1609 left: '-100%' 1610 }, { 1611 duration: slide_duration, 1612 complete: function() { 1613 $portfolio_items.find('.delayed_container_append').each(function(){ 1614 $(this).css({'width': item_width, 'max-width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) }); 1615 $(this).appendTo( $next_carousel_group ); 1616 }); 1617 1618 $active_carousel_group.removeClass('active'); 1619 $active_carousel_group.children().each(function(){ 1620 position = $(this).data('position'); 1621 current_position = $(this).data('current_position'); 1622 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 1623 $(this).data('position', ''); 1624 $(this).data('current_position', ''); 1625 $(this).hide(); 1626 $(this).css({'position': '', 'width': '', 'max-width': '', 'left': ''}); 1627 $(this).appendTo( $portfolio_items ); 1628 }); 1629 1630 $active_carousel_group.remove(); 1631 1632 et_carousel_auto_rotate( $the_portfolio ); 1633 1634 } 1635 } ); 1636 1637 $next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '100%'}); 1638 $next_carousel_group.animate({ 1639 left: '0%' 1640 }, {
1641 duration: slide_duration, 1642 complete: function(){ 1643 setTimeout(function(){ 1644 $next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'max-width':'', 'top':'', 'left': ''}); 1645 1646 $next_carousel_group.find('.delayed_container_append_dup').remove(); 1647 1648 $next_carousel_group.find('.changing_position').each(function( index ){ 1649 position = $(this).data('position'); 1650 current_position = $(this).data('current_position'); 1651 next_position = $(this).data('next_position'); 1652 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position ); 1653 $(this).data('current_position', ''); 1654 $(this).data('next_position', ''); 1655 $(this).data('position', ( index + 1 ) ); 1656 }); 1657 1658 $next_carousel_group.children().css({'position': '', 'width': original_item_width, 'max-width': original_item_width, 'left': ''}); 1659 1660 $the_portfolio.data('carouseling', false); 1661 }, 100 ); 1662 } 1663 } ); 1664 1665 } else { 1666 var $prev_carousel_group, 1667 current_position = columns, 1668 prev_position = columns, 1669 columns_span = columns - 1, 1670 active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ), 1671 active_items_end = active_items_start - columns_span, 1672 prev_items_start = active_items_end - 1, 1673 prev_items_end = prev_items_start - columns_span, 1674 active_carousel_width = $active_carousel_group.innerWidth(); 1675 1676 $prev_carousel_group = $('<div class="et_pb_carousel_group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group ); 1677 $prev_carousel_group.css({ 'left': '-' + active_carousel_width, 'width': active_carousel_width, 'max-width': active_carousel_width }).show(); 1678 1679 // this is an endless loop, so it can decide internally when to break out, so that next_position 1680 // can get filled up, even to the extent of an element having both and current_ and next_ position 1681 for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) { 1682 1683 if ( total <= active_items_start && total >= active_items_end ) { 1684 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 1685 $( items[x] ).data('current_position', current_position ); 1686 current_position--; 1687 } 1688 1689 if ( total <= prev_items_start && total >= prev_items_end ) { 1690 $( items[x] ).data('prev_position', prev_position ); 1691 $( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position ); 1692 1693 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 1694 $( items[x] ).addClass('container_append'); 1695 } else { 1696 $( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 1697 $( items[x] ).addClass('delayed_container_append'); 1698 } 1699 1700 prev_position--; 1701 } 1702 1703 if ( prev_position <= 0 ) { 1704 break; 1705 } 1706 1707 if ( x == 0 ) { 1708 x = items.length; 1709 } 1710 } 1711 1712 sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 1713 var el_a_position = parseInt( $(a).data('prev_position') ); 1714 var el_b_position = parseInt( $(b).data('prev_position') ); 1715 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 1716 }); 1717 1718 $( sorted ).show().appendTo( $prev_carousel_group ); 1719 1720 $prev_carousel_group.children().each(function(){ 1721 $(this).css({'width': item_width, 'max-width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) }); 1722 }); 1723 1724 $active_carousel_group.animate({ 1725 left: '100%' 1726 }, { 1727 duration: slide_duration, 1728 complete: function() { 1729 $portfolio_items.find('.delayed_container_append').reverse().each(function(){ 1730 $(this).css({'width': item_width, 'max-width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) }); 1731 $(this).prependTo( $prev_carousel_group ); 1732 }); 1733 1734 $active_carousel_group.removeClass('active'); 1735 $active_carousel_group.children().each(function(){ 1736 position = $(this).data('position'); 1737 current_position = $(this).data('current_position'); 1738 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 1739 $(this).data('position', ''); 1740 $(this).data('current_position', ''); 1741 $(this).hide(); 1742 $(this).css({'position': '', 'width': '', 'max-width': '', 'left': ''}); 1743 $(this).appendTo( $portfolio_items ); 1744 }); 1745 1746 $active_carousel_group.remove(); 1747 } 1748 } ); 1749 1750 $prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '-100%'}); 1751 $prev_carousel_group.animate({ 1752 left: '0%' 1753 }, {
1754 duration: slide_duration, 1755 complete: function(){ 1756 setTimeout(function(){ 1757 $prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'max-width':'', 'top':'', 'left': ''}); 1758 1759 $prev_carousel_group.find('.delayed_container_append_dup').remove(); 1760 1761 $prev_carousel_group.find('.changing_position').each(function( index ){ 1762 position = $(this).data('position'); 1763 current_position = $(this).data('current_position'); 1764 prev_position = $(this).data('prev_position'); 1765 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position ); 1766 $(this).data('current_position', ''); 1767 $(this).data('prev_position', ''); 1768 position = index + 1; 1769 $(this).data('position', position ); 1770 $(this).addClass('position_' + position ); 1771 }); 1772 1773 $prev_carousel_group.children().css({'position': '', 'width': original_item_width, 'max-width': original_item_width, 'left': ''}); 1774 $the_portfolio.data('carouseling', false); 1775 }, 100 ); 1776 } 1777 } ); 1778 } 1779 } 1780 1781 function set_fullwidth_portfolio_columns( $the_portfolio, carousel_mode ) { 1782 var columns, 1783 $portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'), 1784 portfolio_items_width = $portfolio_items.width(), 1785 $the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'), 1786 portfolio_item_count = $the_portfolio_items.length; 1787 1788 if ('undefined' === typeof $the_portfolio_items) { 1789 return; 1790 } 1791 1792 // calculate column breakpoints 1793 if ( portfolio_items_width >= 1600 ) { 1794 columns = 5; 1795 } else if ( portfolio_items_width >= 1024 ) { 1796 columns = 4; 1797 } else if ( portfolio_items_width >= 768 ) { 1798 columns = 3; 1799 } else if ( portfolio_items_width >= 480 ) { 1800 columns = 2; 1801 } else { 1802 columns = 1; 1803 } 1804 1805 // set height of items 1806 portfolio_item_width = portfolio_items_width / columns;
1807 portfolio_item_height = portfolio_item_width * .75; 1808 1809 if ( carousel_mode ) { 1810 $portfolio_items.css({ 'height' : portfolio_item_height }); 1811 } 1812 1813 $the_portfolio_items.css({ 'height' : portfolio_item_height }); 1814 1815 if ( columns === $portfolio_items.data('portfolio-columns') ) { 1816 return; 1817 } 1818 1819 if ( $the_portfolio.data('columns_setting_up') ) { 1820 return; 1821 } 1822 1823 $the_portfolio.data('columns_setting_up', true ); 1824 1825 var portfolio_item_width_percentage = ( 100 / columns ) + '%'; 1826 $the_portfolio_items.css({ 'width' : portfolio_item_width_percentage, 'max-width' : portfolio_item_width_percentage }); 1827 1828 // store last setup column 1829 $portfolio_items.removeClass('columns-' + $portfolio_items.data('portfolio-columns') ); 1830 $portfolio_items.addClass('columns-' + columns ); 1831 $portfolio_items.data('portfolio-columns', columns ); 1832 1833 if ( !carousel_mode ) { 1834 return $the_portfolio.data('columns_setting_up', false ); 1835 } 1836 1837 // kill all previous groups to get ready to re-group 1838 if ( $portfolio_items.find('.et_pb_carousel_group').length ) { 1839 $the_portfolio_items.appendTo( $portfolio_items ); 1840 $portfolio_items.find('.et_pb_carousel_group').remove(); 1841 } 1842 1843 // setup the grouping 1844 var the_portfolio_items = $portfolio_items.data('items' ), 1845 $carousel_group = $('<div class="et_pb_carousel_group active">').appendTo( $portfolio_items ); 1846 1847 if ('undefined' === typeof the_portfolio_items) { 1848 return; 1849 } 1850 1851 $the_portfolio_items.data('position', ''); 1852 if ( the_portfolio_items.length <= columns ) { 1853 $portfolio_items.find('.et-pb-slider-arrows').hide(); 1854 } else { 1855 $portfolio_items.find('.et-pb-slider-arrows').show(); 1856 } 1857 1858 for ( position = 1, x=0 ;x < the_portfolio_items.length; x++, position++ ) { 1859 if ( x < columns ) { 1860 $( the_portfolio_items[x] ).show(); 1861 $( the_portfolio_items[x] ).appendTo( $carousel_group ); 1862 $( the_portfolio_items[x] ).data('position', position ); 1863 $( the_portfolio_items[x] ).addClass('position_' + position ); 1864 } else { 1865 position = $( the_portfolio_items[x] ).data('position'); 1866 $( the_portfolio_items[x] ).removeClass('position_' + position ); 1867 $( the_portfolio_items[x] ).data('position', '' ); 1868 $( the_portfolio_items[x] ).hide(); 1869 } 1870 } 1871 1872 $the_portfolio.data('columns_setting_up', false ); 1873 1874 } 1875 1876 function et_carousel_auto_rotate( $carousel ) { 1877 if ( 'on' === $carousel.data('auto-rotate') && $carousel.find('.et_pb_portfolio_item').length > $carousel.find('.et_pb_carousel_group .et_pb_portfolio_item').length && ! $carousel.hasClass( 'et_carousel_hovered' ) ) { 1878 1879 et_carousel_timer = setTimeout( function() { 1880 fullwidth_portfolio_carousel_slide( $carousel.find('.et-pb-arrow-next') ); 1881 }, $carousel.data('auto-rotate-speed') ); 1882 1883 $carousel.data('et_carousel_timer', et_carousel_timer); 1884 } 1885 } 1886 1887 $et_pb_fullwidth_portfolio.each(function(){ 1888 et_fullwidth_portfolio_init( $(this) ); 1889 }); 1890 } 1891 1892 if ( $('.et_pb_section_video').length ) { 1893 window._wpmejsSettings.pauseOtherPlayers = false; 1894 } 1895 1896 if ( $et_pb_filterable_portfolio.length || is_frontend_builder ) { 1897 1898 window.et_pb_filterable_portfolio_init = function( $selector ) { 1899 if ( typeof $selector !== 'undefined' ){ 1900 set_filterable_portfolio_init( $selector ); 1901 } else { 1902 $et_pb_filterable_portfolio.each(function(){ 1903 set_filterable_portfolio_init( $(this) ) 1904 }); 1905 } 1906 }; 1907 1908 window.set_filterable_portfolio_init = function( $the_portfolio ) { 1909 var $the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'), 1910 $left_orientatation = true == $the_portfolio.data( 'rtl' ) ? false : true, 1911 all_portfolio_items = $the_portfolio_items.clone(); // cache for all the portfolio items 1912 1913 $the_portfolio.show(); 1914 $the_portfolio.find('.et_pb_portfolio_item').addClass('active'); 1915 $the_portfolio.css('display', 'block'); 1916 1917 set_filterable_grid_items( $the_portfolio ); 1918 1919 $the_portfolio.on('click', '.et_pb_portfolio_filter a', function(e){ 1920 e.preventDefault(); 1921 var category_slug = $(this).data('category-slug'); 1922 var $the_portfolio = $(this).parents('.et_pb_filterable_portfolio'); 1923 var $the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'); 1924 1925 if ( 'all' == category_slug ) { 1926 $the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active'); 1927 $the_portfolio.find('.et_pb_portfolio_filter_all a').addClass('active'); 1928 1929 // remove all items from the portfolio items container 1930 $the_portfolio_items.empty(); 1931 1932 // fill the portfolio items container with cached items from memory 1933 $the_portfolio_items.append( all_portfolio_items.find( '.et_pb_portfolio_item' ).clone() ); 1934 $the_portfolio.find('.et_pb_portfolio_item').addClass('active'); 1935 } else { 1936 $the_portfolio.find('.et_pb_portfolio_filter_all').removeClass('active'); 1937 $the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active'); 1938 $the_portfolio.find('.et_pb_portfolio_filter_all a').removeClass('active'); 1939 $(this).addClass('active'); 1940 1941 // remove all items from the portfolio items container 1942 $the_portfolio_items.empty(); 1943 1944 // fill the portfolio items container with cached items from memory 1945 $the_portfolio_items.append( all_portfolio_items.find( '.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).clone() ); 1946 1947 $the_portfolio_items.find('.et_pb_portfolio_item').removeClass('active'); 1948 $the_portfolio_items.find('.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).addClass('active').removeClass( 'inactive' ); 1949 } 1950 1951 set_filterable_grid_items( $the_portfolio ); 1952 setTimeout(function(){ 1953 set_filterable_portfolio_hash( $the_portfolio ); 1954 }, 500 ); 1955 1956 $the_portfolio.find('.et_pb_portfolio_item').removeClass( 'first_in_row last_in_row' ); 1957 et_pb_set_responsive_grid( $the_portfolio, '.et_pb_portfolio_item:visible' ); 1958 }); 1959 1960 $the_portfolio.on('click', '.et_pb_portofolio_pagination a', function(e){ 1961 e.preventDefault(); 1962 1963 var to_page = $(this).data('page'); 1964 var $the_portfolio = $(this).parents('.et_pb_filterable_portfolio'); 1965 var $the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'); 1966 1967 et_pb_smooth_scroll( $the_portfolio, false, 800 ); 1968 1969 if ( $(this).hasClass('page-prev') ) { 1970 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1; 1971 } else if ( $(this).hasClass('page-next') ) { 1972 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1; 1973 } 1974 1975 $(this).parents('ul').find('a').removeClass('active'); 1976 $(this).parents('ul').find('a.page-' + to_page ).addClass('active'); 1977 1978 var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(), 1979 total_pages = $(this).parents('ul').find('li.page').length; 1980 1981 $(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show(); 1982 $(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show(); 1983 1984 $(this).parents('ul').find('li.page').each(function(i){ 1985 if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) { 1986 if ( i < ( current_index - 3 ) ) { 1987 $(this).hide(); 1988 } else if ( i > ( current_index + 1 ) ) { 1989 $(this).hide(); 1990 } else { 1991 $(this).show(); 1992 } 1993 1994 if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) { 1995 $(this).show(); 1996 } else if ( current_index <= 3 && i <= 4 ) { 1997 $(this).show(); 1998 } 1999 2000 } 2001 }); 2002 2003 if ( to_page > 1 ) { 2004 $(this).parents('ul').find('li.prev').show(); 2005 } else { 2006 $(this).parents('ul').find('li.prev').hide(); 2007 } 2008 2009 if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) { 2010 $(this).parents('ul').find('li.next').hide(); 2011 } else { 2012 $(this).parents('ul').find('li.next').show(); 2013 } 2014 2015 $the_portfolio.find('.et_pb_portfolio_item').hide(); 2016 $the_portfolio.find('.et_pb_portfolio_item').filter(function( index ) { 2017 return $(this).data('page') === to_page; 2018 }).show(); 2019 2020 window.et_pb_set_responsive_grid( $the_portfolio.find( '.et_pb_portfolio_items' ), '.et_pb_portfolio_item' ); 2021 2022 setTimeout(function(){ 2023 set_filterable_portfolio_hash( $the_portfolio ); 2024 }, 500 ); 2025 2026 $the_portfolio.find('.et_pb_portfolio_item').removeClass( 'first_in_row last_in_row' ); 2027 et_pb_set_responsive_grid( $the_portfolio, '.et_pb_portfolio_item:visible' ); 2028 }); 2029 2030 $(this).on('et_hashchange', function( event ){ 2031 var params = event.params; 2032 $the_portfolio = $( '#' + event.target.id ); 2033 2034 if ( !$the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').hasClass('active') ) { 2035 $the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').click(); 2036 } 2037 2038 if ( params[1] ) { 2039 setTimeout(function(){ 2040 if ( !$the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).hasClass('active') ) { 2041 $the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).addClass('active').click(); 2042 } 2043 }, 300 ); 2044 } 2045 }); 2046 }; 2047 2048 // init portfolio if .load event was fired already, wait for the window load otherwise. 2049 if ( window.et_load_event_fired ) { 2050 et_pb_filterable_portfolio_init(); 2051 } else { 2052 $(window).load(function(){ 2053 et_pb_filterable_portfolio_init(); 2054 }); // End $(window).load() 2055 } 2056 2057 function set_filterable_grid_items( $the_portfolio ) { 2058 var active_category = $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug'); 2059 2060 window.et_pb_set_responsive_grid( $the_portfolio.find( '.et_pb_portfolio_items' ), '.et_pb_portfolio_item' ); 2061 2062 if ( 'all' === active_category ) { 2063 $the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item'); 2064 } else { 2065 $the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item.project_category_' + active_category); 2066 } 2067 2068 var visible_grid_items = $the_portfolio_visible_items.length, 2069 posts_number = $the_portfolio.data('posts-number'), 2070 pages = 0 === posts_number ? 1 : Math.ceil( visible_grid_items / posts_number ); 2071 2072 set_filterable_grid_pages( $the_portfolio, pages ); 2073 2074 var visible_grid_items = 0; 2075 var _page = 1; 2076 $the_portfolio.find('.et_pb_portfolio_item').data('page', ''); 2077 $the_portfolio_visible_items.each(function(i){ 2078 visible_grid_items++; 2079 if ( 0 === parseInt( visible_grid_items % posts_number ) ) { 2080 $(this).data('page', _page); 2081 _page++; 2082 } else { 2083 $(this).data('page', _page); 2084 } 2085 }); 2086 2087 $the_portfolio_visible_items.filter(function() { 2088 return $(this).data('page') == 1; 2089 }).show(); 2090 2091 $the_portfolio_visible_items.filter(function() { 2092 return $(this).data('page') != 1; 2093 }).hide(); 2094 } 2095 2096 function set_filterable_grid_pages( $the_portfolio, pages ) { 2097 $pagination = $the_portfolio.find('.et_pb_portofolio_pagination'); 2098 2099 if ( !$pagination.length ) { 2100 return; 2101 } 2102 2103 $pagination.html('<ul></ul>'); 2104 if ( pages <= 1 ) { 2105 return; 2106 } 2107 2108 $pagination_list = $pagination.children('ul'); 2109 $pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + et_pb_custom.prev + '</a></li>'); 2110 for( var page = 1; page <= pages; page++ ) { 2111 var first_page_class = page === 1 ? ' active' : '', 2112 last_page_class = page === pages ? ' last-page' : '', 2113 hidden_page_class = page >= 5 ? ' style="display:none;"' : ''; 2114 $pagination_list.append('<li' + hidden_page_class + ' class="page page-' + page + '"><a href="#" data-page="' + page + '" class="page-' + page + first_page_class + last_page_class + '">' + page + '</a></li>'); 2115 } 2116 $pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + et_pb_custom.next + '</a></li>'); 2117 } 2118 2119 function set_filterable_portfolio_hash( $the_portfolio ) { 2120 2121 if ( !$the_portfolio.attr('id') ) { 2122 return; 2123 } 2124 2125 var this_portfolio_state = []; 2126 this_portfolio_state.push( $the_portfolio.attr('id') ); 2127 this_portfolio_state.push( $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug') ); 2128 2129 if ( $the_portfolio.find('.et_pb_portofolio_pagination a.active').length ) { 2130 this_portfolio_state.push( $the_portfolio.find('.et_pb_portofolio_pagination a.active').data('page') ); 2131 } else { 2132 this_portfolio_state.push( 1 ); 2133 } 2134 2135 this_portfolio_state = this_portfolio_state.join( et_hash_module_param_seperator ); 2136 2137 et_set_hash( this_portfolio_state ); 2138 } 2139 } /* end if ( $et_pb_filterable_portfolio.length ) */ 2140 2141 if ( $et_pb_gallery.length || is_frontend_builder ) { 2142 2143 window.set_gallery_grid_items = function( $the_gallery ) { 2144 var $the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'), 2145 $the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item'); 2146 2147 var total_grid_items = $the_gallery_items.length, 2148 posts_number_original = parseInt( $the_gallery_items_container.attr('data-per_page') ), 2149 posts_number = isNaN( posts_number_original ) || 0 === posts_number_original ? 4 : posts_number_original, 2150 pages = Math.ceil( total_grid_items / posts_number ); 2151 2152 window.et_pb_set_responsive_grid($the_gallery_items_container, '.et_pb_gallery_item'); 2153 2154 set_gallery_grid_pages( $the_gallery, pages ); 2155 2156 var total_grid_items = 0; 2157 var _page = 1; 2158 2159 $the_gallery_items.data('page', ''); 2160 $the_gallery_items.each(function(i){ 2161 total_grid_items++; 2162 // Do some caching 2163 var $this = $(this); 2164 if ( 0 === parseInt( total_grid_items % posts_number ) ) { 2165 $this.data('page', _page); 2166 _page++; 2167 } else { 2168 $this.data('page', _page); 2169 } 2170 2171 }); 2172 2173 var visible_items = $the_gallery_items.filter(function() { 2174 return $(this).data('page') == 1; 2175 }).show(); 2176 2177 $the_gallery_items.filter(function() { 2178 return $(this).data('page') != 1; 2179 }).hide(); 2180 }; 2181 2182 window.set_gallery_grid_pages = function( $the_gallery, pages ) { 2183 $pagination = $the_gallery.find('.et_pb_gallery_pagination'); 2184 2185 if ( !$pagination.length ) { 2186 return; 2187 } 2188 2189 $pagination.html('<ul></ul>'); 2190 if ( pages <= 1 ) { 2191 $pagination.hide(); 2192 return; 2193 } 2194 2195 $pagination_list = $pagination.children('ul'); 2196 $pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + et_pb_custom.prev + '</a></li>'); 2197 for( var page = 1; page <= pages; page++ ) { 2198 var first_page_class = page === 1 ? ' active' : '', 2199 last_page_class = page === pages ? ' last-page' : '', 2200 hidden_page_class = page >= 5 ? ' style="display:none;"' : ''; 2201 $pagination_list.append('<li' + hidden_page_class + ' class="page page-' + page + '"><a href="#" data-page="' + page + '" class="page-' + page + first_page_class + last_page_class + '">' + page + '</a></li>'); 2202 } 2203 $pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + et_pb_custom.next + '</a></li>'); 2204 }; 2205 2206 window.set_gallery_hash = function( $the_gallery ) { 2207 2208 if ( !$the_gallery.attr('id') ) { 2209 return; 2210 } 2211 2212 var this_gallery_state = []; 2213 this_gallery_state.push( $the_gallery.attr('id') ); 2214 2215 if ( $the_gallery.find('.et_pb_gallery_pagination a.active').length ) { 2216 this_gallery_state.push( $the_gallery.find('.et_pb_gallery_pagination a.active').data('page') ); 2217 } else { 2218 this_gallery_state.push( 1 ); 2219 } 2220 2221 this_gallery_state = this_gallery_state.join( et_hash_module_param_seperator ); 2222 2223 et_set_hash( this_gallery_state ); 2224 }; 2225 2226 window.et_pb_gallery_init = function( $the_gallery ) { 2227 if ( $the_gallery.hasClass( 'et_pb_gallery_grid' ) ) { 2228 2229 $the_gallery.show(); 2230 set_gallery_grid_items( $the_gallery ); 2231 2232 $the_gallery.on('et_hashchange', function( event ){ 2233
2233 var params = event.params; 2234 $the_gallery = $( '#' + event.target.id ); 2235 2236 if ( page_to = params[0] ) { 2237 if ( !$the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).hasClass('active') ) { 2238 $the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).addClass('active').click(); 2239 } 2240 } 2241 }); 2242 } 2243 }; 2244 2245 $et_pb_gallery.each(function(){ 2246 var $the_gallery = $(this); 2247 2248 et_pb_gallery_init( $the_gallery ); 2249 }); 2250 2251 $et_pb_gallery.data('paginating', false ); 2252 2253 window.et_pb_gallery_pagination_nav = function( $the_gallery ) { 2254 $the_gallery.on('click', '.et_pb_gallery_pagination a', function(e){ 2255 e.preventDefault(); 2256 2257 var to_page = $(this).data('page'), 2258 $the_gallery = $(this).parents('.et_pb_gallery'), 2259 $the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'), 2260 $the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item'); 2261 2262 if ( $the_gallery.data('paginating') ) { 2263 return; 2264 } 2265 2266 $the_gallery.data('paginating', true ); 2267 2268 if ( $(this).hasClass('page-prev') ) { 2269 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1; 2270 } else if ( $(this).hasClass('page-next') ) { 2271 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1; 2272 } 2273 2274 $(this).parents('ul').find('a').removeClass('active'); 2275 $(this).parents('ul').find('a.page-' + to_page ).addClass('active'); 2276 2277 var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(), 2278 total_pages = $(this).parents('ul').find('li.page').length; 2279 2280 $(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show(); 2281 $(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show(); 2282 2283 $(this).parents('ul').find('li.page').each(function(i){ 2284 if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) { 2285 if ( i < ( current_index - 3 ) ) { 2286 $(this).hide(); 2287 } else if ( i > ( current_index + 1 ) ) { 2288 $(this).hide(); 2289 } else { 2290 $(this).show(); 2291 } 2292 2293 if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) { 2294 $(this).show(); 2295 } else if ( current_index <= 3 && i <= 4 ) { 2296 $(this).show(); 2297 } 2298 2299 } 2300 }); 2301 2302 if ( to_page > 1 ) { 2303 $(this).parents('ul').find('li.prev').show(); 2304 } else { 2305 $(this).parents('ul').find('li.prev').hide(); 2306 } 2307 2308 if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) { 2309 $(this).parents('ul').find('li.next').hide(); 2310 } else { 2311 $(this).parents('ul').find('li.next').show(); 2312 } 2313 2314 $the_gallery_items.hide(); 2315 var visible_items = $the_gallery_items.filter(function( index ) { 2316 return $(this).data('page') === to_page; 2317 }).show(); 2318 2319 $the_gallery.data('paginating', false ); 2320 2321 window.et_pb_set_responsive_grid( $the_gallery_items_container, '.et_pb_gallery_item' ); 2322 2323 setTimeout(function(){ 2324 set_gallery_hash( $the_gallery ); 2325 }, 100 ); 2326 2327 $( 'html, body' ).animate( { scrollTop : $the_gallery.offset().top - 200 }, 200 ); 2328 }); 2329 }; 2330 et_pb_gallery_pagination_nav( $et_pb_gallery ); 2331 2332 // Frontend builder's interface wouldn't be able to use $et_pb_gallery as selector 2333 // due to its react component's nature. Using more global selector works. 2334 if ( is_frontend_builder ) { 2335 et_pb_gallery_pagination_nav( $('#et-fb-app') ); 2336 } 2337 2338 } /* end if ( $et_pb_gallery.length ) */ 2339 2340 if ( $et_pb_counter_amount.length ) { 2341 $et_pb_counter_amount.each(function(){ 2342 window.et_bar_counters_init( $( this ) ); 2343 }); 2344 } /* $et_pb_counter_amount.length */ 2345 2346 window.et_countdown_timer = function( timer ) { 2347 var end_date = parseInt( timer.attr( 'data-end-timestamp') ), 2348 current_date = new Date().getTime() / 1000, 2349 seconds_left = ( end_date - current_date ); 2350 2351 days = parseInt(seconds_left / 86400); 2352 days = days > 0 ? days : 0; 2353 seconds_left = seconds_left % 86400; 2354 2355 hours = parseInt(seconds_left / 3600); 2356 hours = hours > 0 ? hours : 0; 2357 2358 seconds_left = seconds_left % 3600; 2359 2360 minutes = parseInt(seconds_left / 60); 2361 minutes = minutes > 0 ? minutes : 0; 2362 2363 seconds = parseInt(seconds_left % 60); 2364 seconds = seconds > 0 ? seconds : 0; 2365
2366 var $days_section = timer.find('.days > .value').parent('.section'), 2367 $hours_section = timer.find('.hours > .value').parent('.section'), 2368 $minutes_section = timer.find('.minutes > .value').parent('.section'), 2369 $seconds_section = timer.find('.seconds > .value').parent('.section'); 2370 2371 2372 if ( days == 0 ) { 2373 if ( ! $days_section.hasClass('zero') ) { 2374 timer.find('.days > .value').html( '000' ).parent('.section').addClass('zero').next().addClass('zero'); 2375 } 2376 } else { 2377 days_slice = days.toString().length >= 3 ? days.toString().length : 3; 2378 timer.find('.days > .value').html( ('000' + days).slice(-days_slice) ); 2379 2380 if ( $days_section.hasClass('zero') ) { 2381 $days_section.removeClass('zero').next().removeClass('zero'); 2382 } 2383 } 2384 2385 if ( days == 0 && hours == 0 ) { 2386 if ( ! $hours_section.hasClass('zero') ) { 2387 timer.find('.hours > .value').html('00').parent('.section').addClass('zero').next().addClass('zero'); 2388 } 2389 } else { 2390 timer.find('.hours > .value').html( ( '0' + hours ).slice(-2) ); 2391 2392 if ( $hours_section.hasClass('zero') ) { 2393 $hours_section.removeClass('zero').next().removeClass('zero'); 2394 } 2395 } 2396 2397 if ( days == 0 && hours == 0 && minutes == 0 ) { 2398 if ( ! $minutes_section.hasClass('zero') ) { 2399 timer.find('.minutes > .value').html('00').parent('.section').addClass('zero').next().addClass('zero'); 2400 } 2401 } else { 2402 timer.find('.minutes > .value').html( ( '0' + minutes ).slice(-2) ); 2403 2404 if ( $minutes_section.hasClass('zero') ) { 2405 $minutes_section.removeClass('zero').next().removeClass('zero'); 2406 } 2407 } 2408 2409 if ( days == 0 && hours == 0 && minutes == 0 && seconds == 0 ) { 2410 if ( ! $seconds_section.hasClass('zero') ) { 2411 timer.find('.seconds > .value').html('00').parent('.section').addClass('zero'); 2412 } 2413 } else { 2414 timer.find('.seconds > .value').html( ( '0' + seconds ).slice(-2) ); 2415 2416 if ( $seconds_section.hasClass('zero') ) { 2417 $seconds_section.removeClass('zero').next().removeClass('zero'); 2418 } 2419 } 2420 }; 2421 2422 window.et_countdown_timer_labels = function( timer ) { 2423 if ( timer.closest( '.et_pb_column_3_8' ).length || timer.closest( '.et_pb_column_1_4' ).length || timer.children('.et_pb_countdown_timer_container').width() <= 400 ) {
2424 timer.find('.days .label').html( timer.find('.days').data('short') ); 2425 timer.find('.hours .label').html( timer.find('.hours').data('short') ); 2426 timer.find('.minutes .label').html( timer.find('.minutes').data('short') ); 2427 timer.find('.seconds .label').html( timer.find('.seconds').data('short') ); 2428 } else { 2429 timer.find('.days .label').html( timer.find('.days').data('full') ); 2430 timer.find('.hours .label').html( timer.find('.hours').data('full') ); 2431 timer.find('.minutes .label').html( timer.find('.minutes').data('full') ); 2432 timer.find('.seconds .label').html( timer.find('.seconds').data('full') ); 2433 } 2434 }; 2435 2436 if ( $et_pb_countdown_timer.length || is_frontend_builder ) { 2437 window.et_pb_countdown_timer_init = function( $et_pb_countdown_timer ) { 2438 $et_pb_countdown_timer.each(function(){ 2439 var timer = $(this); 2440 et_countdown_timer_labels( timer ); 2441 et_countdown_timer( timer ); 2442 setInterval(function(){ 2443 et_countdown_timer( timer ); 2444 }, 1000); 2445 }); 2446 }; 2447 et_pb_countdown_timer_init( $et_pb_countdown_timer ); 2448 } 2449 2450 if ($et_pb_tabs.length || is_frontend_builder) { 2451 window.et_pb_tabs_init = function ($et_pb_tabs) { 2452 var $et_pb_tabs_li = $et_pb_tabs.find('.et_pb_tabs_controls li'); 2453 2454 $et_pb_tabs.et_pb_simple_slider({ 2455 use_controls: false, 2456 use_arrows: false, 2457 slide: '.et_pb_all_tabs > div', 2458 tabs_animation: true 2459 }).on('et_hashchange', function (event) { 2460 var params = event.params; 2461 var $the_tabs = $('#' + event.target.id); 2462 var active_tab = params[0]; 2463 if (!$the_tabs.find('.et_pb_tabs_controls li').eq(active_tab).hasClass('et_pb_tab_active')) { 2464 $the_tabs.find('.et_pb_tabs_controls li').eq(active_tab).click(); 2465 } 2466 }); 2467 2468 $et_pb_tabs_li.click(function () { 2469 var $this_el = $(this), 2470 $tabs_container = $this_el.closest('.et_pb_tabs').data('et_pb_simple_slider'); 2471 2472 if ($tabs_container.et_animation_running) return false; 2473 2474 $this_el.addClass('et_pb_tab_active').siblings().removeClass('et_pb_tab_active'); 2475 2476 $tabs_container.data('et_pb_simple_slider').et_slider_move_to($this_el.index()); 2477 2478 if ($this_el.closest('.et_pb_tabs').attr('id')) { 2479 var tab_state = []; 2480 tab_state.push($this_el.closest('.et_pb_tabs').attr('id')); 2481 tab_state.push($this_el.index()); 2482 tab_state = tab_state.join(et_hash_module_param_seperator); 2483 et_set_hash(tab_state); 2484 } 2485 2486 return false; 2487 }); 2488 2489 window.et_pb_set_tabs_height(); 2490 }; 2491 window.et_pb_tabs_init($et_pb_tabs); 2492 } 2493 2494 if ( $et_pb_map.length || is_frontend_builder ) { 2495 function et_pb_init_maps() { 2496 $et_pb_map.each(function(){ 2497 et_pb_map_init( $(this) ); 2498 }); 2499 } 2500 2501 window.et_pb_map_init = function( $this_map_container ) { 2502 if ( typeof google === 'undefined' || typeof google.maps === 'undefined' ) { 2503 return; 2504 } 2505 2506 var current_mode = et_pb_get_current_window_mode(); 2507 et_animation_breakpoint = current_mode; 2508 var suffix = current_mode !== 'desktop' ? '-' + current_mode : ''; 2509 var prev_suffix = current_mode === 'phone' ? '-tablet' : ''; 2510 var grayscale_value = $this_map_container.attr( 'data-grayscale' + suffix ) || 0; 2511 if ( ! grayscale_value ) { 2512 grayscale_value = $this_map_container.attr( 'data-grayscale' + prev_suffix ) || $this_map_container.attr( 'data-grayscale' ) || 0; 2513 } 2514 2515 var $this_map = $this_map_container.children('.et_pb_map'), 2516 this_map_grayscale = grayscale_value, 2517 is_draggable = ( et_is_mobile_device && $this_map.data('mobile-dragging') !== 'off' ) || ! et_is_mobile_device, 2518 infowindow_active; 2519 2520 if ( this_map_grayscale !== 0 ) { 2521 this_map_grayscale = '-' + this_map_grayscale.toString(); 2522 } 2523 2524 // Being saved to pass lat and lang of center location. 2525 var data_center_lat = parseFloat($this_map.attr('data-center-lat')) || 0; 2526 var data_center_lng = parseFloat($this_map.attr('data-center-lng')) || 0; 2527 2528 $this_map_container.data('map', new google.maps.Map( $this_map[0], { 2529 zoom: parseInt( $this_map.attr('data-zoom') ), 2530 center: new google.maps.LatLng(data_center_lat, data_center_lng), 2531 mapTypeId: google.maps.MapTypeId.ROADMAP, 2532 scrollwheel: $this_map.attr('data-mouse-wheel') == 'on' ? true : false, 2533 draggable: is_draggable, 2534 panControlOptions: { 2535 position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP 2536 }, 2537 zoomControlOptions: { 2538 position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP 2539 }, 2540 styles: [ { 2541 stylers: [ 2542 { saturation: parseInt( this_map_grayscale ) } 2543 ] 2544 } ] 2545 })); 2546 2547 $this_map_container.find('.et_pb_map_pin').each(function(){ 2548 var $this_marker = $(this); 2549 2550 var marker = new google.maps.Marker({ 2551 position: new google.maps.LatLng( parseFloat( $this_marker.attr('data-lat') ) , parseFloat( $this_marker.attr('data-lng') ) ), 2552 map: $this_map_container.data('map'), 2553 title: $this_marker.attr('data-title'), 2554 icon: { url: et_pb_custom.builder_images_uri + '/marker.png', size: new google.maps.Size( 46, 43 ), anchor: new google.maps.Point( 16, 43 ) }, 2555 shape: { coord: [1, 1, 46, 43], type: 'rect' }, 2556 anchorPoint: new google.maps.Point(0, -45) 2557 }); 2558 2559 if ( $this_marker.find('.infowindow').length ) { 2560 var infowindow = new google.maps.InfoWindow({ 2561 content: $this_marker.html() 2562 }); 2563 2564 google.maps.event.addListener( $this_map_container.data('map'), 'click', function() { 2565 infowindow.close(); 2566 }); 2567 2568 google.maps.event.addListener(marker, 'click', function() { 2569 if( infowindow_active ) { 2570 infowindow_active.close(); 2571 } 2572 infowindow_active = infowindow; 2573 2574 infowindow.open( $this_map_container.data('map'), marker ); 2575 2576 // Trigger mouse hover event for responsive content swap. 2577 $this_marker.closest('.et_pb_module').trigger('mouseleave'); 2578 setTimeout(function (){ 2579 $this_marker.closest('.et_pb_module').trigger('mouseenter'); 2580 }, 1); 2581 }); 2582 } 2583 }); 2584 }; 2585 2586 if ( window.et_load_event_fired ) { 2587 et_pb_init_maps(); 2588 } else { 2589 if ( typeof google !== 'undefined' && typeof google.maps !== 'undefined' ) { 2590 google.maps.event.addDomListener(window, 'load', function() { 2591 et_pb_init_maps(); 2592 } ); 2593 } 2594 } 2595 } 2596 2597 $('.et_pb_shop, .et_pb_wc_upsells, .et_pb_wc_related_products').each(function() { 2598 var $this_el = $(this); 2599 var icon = $this_el.data('icon') || ''; 2600 var icon_tablet = $this_el.data('icon-tablet') || ''; 2601 var icon_phone = $this_el.data('icon-phone') || ''; 2602 var $overlay = $this_el.find('.et_overlay'); 2603 2604 // Set data icon and inline icon class. 2605 if (icon !== '') { 2606 $overlay.attr('data-icon', icon).addClass('et_pb_inline_icon'); 2607 } 2608 2609 if (icon_tablet !== '') { 2610 $overlay.attr('data-icon-tablet', icon_tablet).addClass('et_pb_inline_icon_tablet'); 2611 } 2612 2613 if (icon_phone !== '') { 2614 $overlay.attr('data-icon-phone', icon_phone).addClass('et_pb_inline_icon_phone'); 2615 } 2616 }); 2617 2618 $et_pb_background_layout_hoverable.each(function() { 2619 var $this_el = $(this); 2620 var background_layout = $this_el.data('background-layout'); 2621 var background_layout_hover = $this_el.data('background-layout-hover'); 2622 2623 // Switch the target element for the button module 2624 if ($this_el.hasClass('et_pb_button_module_wrapper')) { 2625 $this_el = $this_el.find('> .et_pb_button'); 2626 } 2627 2628 $this_el.on('mouseenter', function() { 2629 $this_el.removeClass('et_pb_bg_layout_light et_pb_bg_layout_dark et_pb_text_color_dark'); 2630 2631 $this_el.addClass('et_pb_bg_layout_' + background_layout_hover); 2632 2633 if ($this_el.hasClass('et_pb_audio_module') && 'light' === background_layout_hover) { 2634 $this_el.addClass('et_pb_text_color_dark'); 2635 } 2636 }); 2637 2638 $this_el.on('mouseleave', function() { 2639 $this_el.removeClass('et_pb_bg_layout_light et_pb_bg_layout_dark et_pb_text_color_dark'); 2640 2641 $this_el.addClass('et_pb_bg_layout_' + background_layout); 2642 2643 if ($this_el.hasClass('et_pb_audio_module') && 'light' === background_layout) { 2644 $this_el.addClass('et_pb_text_color_dark'); 2645 } 2646 }); 2647 }); 2648 2649 if ( $et_pb_circle_counter.length || is_frontend_builder || $( '.et_pb_ajax_pagination_container' ).length > 0 ) { 2650 window.et_pb_circle_counter_init = function($the_counter, animate, custom_mode) { 2651 if ( $the_counter.width() <= 0 ) { 2652 return; 2653 } 2654 2655 // Update animation breakpoint variable and generate suffix. 2656 var current_mode = et_pb_get_current_window_mode(); 2657 et_animation_breakpoint = current_mode; 2658 2659 // Custom Mode is used to pass custom preview mode such as hover. Current mode is 2660 // actual preview mode based on current window size. 2661 var suffix = ''; 2662 if ('undefined' !== typeof custom_mode && '' !== custom_mode) { 2663 suffix = '-' + custom_mode; 2664 } else if (current_mode !== 'desktop') { 2665 suffix = '-' + current_mode; 2666 } 2667 2668 // Update bar background color based on active mode.
2669 var bar_color = $the_counter.data( 'bar-bg-color' ); 2670 var mode_bar_color = $the_counter.data( 'bar-bg-color' + suffix ); 2671 if ( typeof mode_bar_color !== 'undefined' && mode_bar_color !== '' ) { 2672 bar_color = mode_bar_color; 2673 } 2674 2675 // Update bar track color based on active mode. 2676 var track_color = $the_counter.data( 'color' ) || '#000000'; 2677 var mode_track_color = $the_counter.data( 'color' + suffix ); 2678 if ( typeof mode_track_color !== 'undefined' && mode_track_color !== '' ) { 2679 track_color = mode_track_color; 2680 } 2681 2682 // Update bar track color alpha based on active mode. 2683 var track_color_alpha = $the_counter.data( 'alpha' ) || '0.1'; 2684 var mode_track_color_alpha = $the_counter.data( 'alpha' + suffix ); 2685 if ('undefined' !== typeof mode_track_color_alpha && '' !== mode_track_color_alpha && !isNaN(mode_track_color_alpha)) { 2686 track_color_alpha = mode_track_color_alpha; 2687 } 2688 2689 $the_counter.easyPieChart({ 2690 animate: { 2691 duration: 1800, 2692 enabled: true 2693 }, 2694 size: 0 !== $the_counter.width() ? $the_counter.width() : 10, // set the width to 10 if actual width is 0 to avoid js errors 2695 barColor: bar_color, 2696 trackColor: track_color, 2697 trackAlpha: track_color_alpha, 2698 scaleColor: false, 2699 lineWidth: 5, 2700 onStart: function() { 2701 $(this.el).find('.percent p').css({ 'visibility' : 'visible' }); 2702 }, 2703 onStep: function(from, to, percent) { 2704 $(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) ); 2705 }, 2706 onStop: function(from, to) { 2707 $(this.el).find('.percent-value').text( $(this.el).data('number-value') ); 2708 } 2709 }); 2710 }; 2711 2712 window.et_pb_reinit_circle_counters = function( $et_pb_circle_counter ) { 2713 $et_pb_circle_counter.each(function(){ 2714 var $the_counter = $(this).find('.et_pb_circle_counter_inner'); 2715 window.et_pb_circle_counter_init($the_counter, false); 2716 2717 // Circle Counter on Hover. 2718 $the_counter.on('mouseover', function(event){ 2719 window.et_pb_circle_counter_update($the_counter, event, 'hover'); 2720 }); 2721 2722 // Circle Counter on "Unhover" as reset of Hover effect. 2723 $the_counter.on('mouseleave', function(event){ 2724 window.et_pb_circle_counter_update($the_counter, event); 2725 }); 2726 2727 $the_counter.on('containerWidthChanged', function(event, custom_mode){ 2728 $the_counter = $( event.target ); 2729 $the_counter.find('canvas').remove(); 2730 $the_counter.removeData('easyPieChart' ); 2731 window.et_pb_circle_counter_init($the_counter, true, custom_mode); 2732 }); 2733 2734 }); 2735 }; 2736 window.et_pb_reinit_circle_counters( $et_pb_circle_counter ); 2737 } 2738 2739 /** 2740 * Update circle counter easyPieChart data on custom mode. 2741 * 2742 * @since 3.25.3 2743 * 2744 * @param {jQuery} $this_counter Circle counter jQuery element. 2745 * @param {Object} event Event object 2746 * @param {String} custom_mode Custom view mode such as hover/desktop/tablet/phone. 2747 */ 2748 window.et_pb_circle_counter_update = function($this_counter, event, custom_mode) { 2749 if (!$this_counter.is(':visible') || typeof $this_counter.data('easyPieChart') === 'undefined') { 2750 return; 2751 } 2752 2753 // Check circle attributes value for current event type. 2754 if ($(event.target).length > 0) { 2755 if ('mouseover' === event.type || 'mouseleave' === event.type) { 2756 has_field_value = false; 2757 2758 // Check if one of those field value exist. 2759 var mode_bar_color = $this_counter.data('bar-bg-color-hover'); 2760 var mode_track_color = $this_counter.data('color-hover'); 2761 var mode_track_color_alpha = $this_counter.data('alpha-hover'); 2762 2763 if (typeof mode_bar_color !== 'undefined' && mode_bar_color !== '') { 2764 has_field_value = true; 2765 } else if (typeof mode_track_color !== 'undefined' && mode_track_color !== '') { 2766 has_field_value = true; 2767 } else if (typeof mode_track_color_alpha !== 'undefined' && mode_track_color_alpha !== '') { 2768 has_field_value = true; 2769 } 2770 2771 if (!has_field_value) { 2772 return; 2773 } 2774 } 2775 } 2776 2777 // Reinit circle counter for current event. 2778 var container_param = []; 2779 if ('undefined' !== typeof custom_mode && '' !== custom_mode) { 2780 container_param = [custom_mode]; 2781 } 2782 $this_counter.trigger('containerWidthChanged', container_param); 2783 2784 // Animation should be disabled here. 2785 $this_counter.data('easyPieChart').disableAnimation(); 2786 $this_counter.data('easyPieChart').update($this_counter.data('number-value')); 2787 }; 2788 2789 if ( $et_pb_number_counter.length || is_frontend_builder || $( '.et_pb_ajax_pagination_container' ).length > 0 ) { 2790 window.et_pb_reinit_number_counters = function( $et_pb_number_counter ) { 2791 2792 var is_firefox = $('body').hasClass('gecko'); 2793 2794 function et_format_number( number_value, separator ) { 2795 return number_value.toString().replace( /\B(?=(\d{3})+(?!\d))/g, separator ); 2796 } 2797 2798 if ( $.fn.fitText ) { 2799 $et_pb_number_counter.find( '.percent p' ).fitText( 0.3 ); 2800 } 2801 2802 $et_pb_number_counter.each(function(){ 2803 var $this_counter = $(this); 2804 var separator = $this_counter.data('number-separator'); 2805 2806 $this_counter.easyPieChart({ 2807 animate: { 2808 duration: 1800, 2809 enabled: true 2810 }, 2811 size: is_firefox ? 1 : 0, // firefox can't print page when it contains 0 sized canvas elements. 2812 trackColor: false, 2813 scaleColor: false, 2814 lineWidth: 0, 2815 onStart: function () { 2816 $(this.el).addClass('active'); 2817 }, 2818 onStep: function(from, to, percent) { 2819 if ( percent != to ) 2820 $(this.el).find('.percent-value').text( et_format_number( Math.round( parseInt( percent ) ), separator ) ); 2821 }, 2822 onStop: function(from, to) { 2823 $(this.el).find('.percent-value').text( et_format_number( $(this.el).data('number-value'), separator ) ); 2824 } 2825 }); 2826 }); 2827 }; 2828 window.et_pb_reinit_number_counters( $et_pb_number_counter ); 2829 } 2830 2831 window.et_apply_parallax = function() { 2832 if ( ! $(this).length || typeof $(this) === 'undefined' || typeof $(this).offset() === 'undefined') { 2833 return; 2834 } 2835 2836 var $parallaxWindow = isScrollOnAppWindow() ? $(window) : $et_top_window; 2837 var $this = $(this); 2838 var element_top = isBuilderModeZoom() ? $this.offset().top / 2 : $this.offset().top; 2839 var window_top = $parallaxWindow.scrollTop(); 2840 var y_pos = ( ( ( window_top + $et_top_window.height() ) - element_top ) * 0.3 ); 2841 var main_position; 2842 2843 main_position = 'translate(0, ' + y_pos + 'px)'; 2844 2845 $this.children('.et_parallax_bg').css( { 2846 '-webkit-transform' : main_position, 2847 '-moz-transform' : main_position, 2848 '-ms-transform' : main_position, 2849 'transform' : main_position 2850 } ); 2851 }; 2852 2853 window.et_parallax_set_height = function() { 2854 var $this = $(this); 2855 var isFullscreen = isBuilder && $this.parent('.et_pb_fullscreen').length; 2856 var parallaxHeight = isFullscreen && $et_top_window.height() > $this.innerHeight() ? $et_top_window.height() : $this.innerHeight(); 2857 var bg_height = ( $et_top_window.height() * 0.3 + parallaxHeight ); 2858 2859 // Add BFB metabox to top window offset on parallax image height to avoid parallax displays its 2860 // background while scrolling because the image height is too short. This is required since BFB 2861 // tracks parent window scroll event and BFB metabox has offset top to the top window 2862 if (isBFB) { 2863 bg_height += window.top.jQuery('#et_pb_layout .inside').offset().top; 2864 } 2865 2866 $this.find('.et_parallax_bg').css( { 'height' : bg_height } ); 2867 }; 2868 2869 // Emulate CSS Parallax (background-attachment: fixed) effect via absolute image positioning 2870 window.et_apply_builder_css_parallax = function() { 2871 // This callback is for builder only 2872 if (!isBuilder) { 2873 return; 2874 } 2875 2876 var $this_parent = $(this); 2877 var $this_parallax = $this_parent.children('.et_parallax_bg'); 2878 2879 // Remove inline styling to avoid unwanted result first 2880 $this_parallax.css({ 2881 width: '', 2882 height: '', 2883 top: '', 2884 left: '', 2885 backgroundAttachment: '' 2886 }); 2887 2888 // Bail if window scroll happens on app window (visual builder desktop mode) 2889 if (isScrollOnAppWindow()) { 2890 return; 2891 } 2892 2893 var topWindow = isBuilder ? window.top : window; 2894 var backgroundOffset = isBFB ? topWindow.jQuery('#et_pb_layout .inside').offset().top : 0; 2895 var heightMultiplier = isBuilderModeZoom() ? 2 : 1; 2896 var parentOffset = $this_parent.offset(); 2897 var parentOffsetTop = isBuilderModeZoom() ? parentOffset.top / 2 : parentOffset.top; 2898 2899 $this_parallax.css({ 2900 width: $(window).width(), 2901 height: $et_top_window.innerHeight() * heightMultiplier, 2902 top: ($et_top_window.scrollTop() - backgroundOffset) - parentOffsetTop, 2903 left: 0 - parentOffset.left, 2904 backgroundAttachment: 'scroll' 2905 }); 2906 }; 2907 2908 function et_toggle_animation_callback( initial_toggle_state, $module, $section ) { 2909 if ( 'closed' === initial_toggle_state ) { 2910 $module.removeClass('et_pb_toggle_close').addClass('et_pb_toggle_open'); 2911 } else { 2912 $module.removeClass('et_pb_toggle_open').addClass('et_pb_toggle_close'); 2913 } 2914 2915 if ( $section.hasClass( 'et_pb_section_parallax' ) && !$section.children().hasClass( 'et_pb_parallax_css') ) { 2916 $.proxy( et_parallax_set_height, $section )(); 2917 } 2918 } 2919 2920 $( 'body' ).on( 'click', '.et_pb_toggle_title, .et_fb_toggle_overlay', function() { 2921 var $this_heading = $(this), 2922 $module = $this_heading.closest('.et_pb_toggle'), 2923 $section = $module.parents( '.et_pb_section' ), 2924 $content = $module.find('.et_pb_toggle_content'), 2925 $accordion = $module.closest( '.et_pb_accordion' ), 2926 is_accordion = $accordion.length, 2927 is_accordion_toggling = $accordion.hasClass( 'et_pb_accordion_toggling' ), 2928 window_offset_top = $(window).scrollTop(), 2929 fixed_header_height = 0, 2930 initial_toggle_state = $module.hasClass( 'et_pb_toggle_close' ) ? 'closed' : 'opened', 2931 $accordion_active_toggle, 2932 module_offset; 2933 2934 if ( is_accordion ) { 2935 if ( $module.hasClass('et_pb_toggle_open') || is_accordion_toggling ) { 2936 return false;
2937 } 2938 2939 $accordion.addClass( 'et_pb_accordion_toggling' ); 2940 $accordion_active_toggle = $module.siblings('.et_pb_toggle_open'); 2941 } 2942 2943 if ( $content.is( ':animated' ) ) { 2944 return; 2945 } 2946 2947 $content.slideToggle(700, function () { 2948 et_toggle_animation_callback(initial_toggle_state, $module, $section); 2949 }); 2950 2951 if ( is_accordion ) { 2952 $accordion_active_toggle.find('.et_pb_toggle_content').slideToggle( 700, function() { 2953 $accordion_active_toggle.removeClass( 'et_pb_toggle_open' ).addClass('et_pb_toggle_close'); 2954 $accordion.removeClass( 'et_pb_accordion_toggling' ); 2955 2956 module_offset = $module.offset(); 2957 2958 // Calculate height of fixed nav 2959 if ( $('#wpadminbar').length ) { 2960 fixed_header_height += $('#wpadminbar').height(); 2961 } 2962 2963 if ( $('#top-header').length ) { 2964 fixed_header_height += $('#top-header').height(); 2965 } 2966 2967 if ( $('#main-header').length && ! window.et_is_vertical_nav ) { 2968 fixed_header_height += $('#main-header').height(); 2969 } 2970 2971 // Compare accordion offset against window's offset and adjust accordingly 2972 if ( ( window_offset_top + fixed_header_height ) > module_offset.top ) { 2973 $('html, body').animate({ scrollTop : ( module_offset.top - fixed_header_height - 50 ) }); 2974 } 2975 } ); 2976 } 2977 } ); 2978 2979 // Email Validation 2980 // Use the regex defined in the HTML5 spec for input[type=email] validation 2981 // (see https://www.w3.org/TR/2016/REC-html51-20161101/sec-forms.html#email-state-typeemail) 2982 var et_email_reg_html5 = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 2983 2984 var $et_contact_container = $('.et_pb_contact_form_container'); 2985 2986 if ($et_contact_container.length) { 2987 $et_contact_container.each(function() { 2988 var $this_contact_container = $(this); 2989 var $et_contact_form = $this_contact_container.find('form'); 2990 var redirect_url = typeof $this_contact_container.data('redirect_url') !== 'undefined' ? $this_contact_container.data('redirect_url') : ''; 2991 2992 $et_contact_form.find('input[type=checkbox]').on('change', function() { 2993 var $checkbox = $(this); 2994 var $checkbox_field = $checkbox.siblings('input[type=text]:first'); 2995 var is_checked = $checkbox.prop('checked'); 2996 2997 $checkbox_field.val(is_checked ? $checkbox_field.data('checked') : $checkbox_field.data('unchecked')); 2998 }); 2999 3000 $et_contact_form.submit(function(event) { 3001 event.preventDefault(); 3002 3003 var $this_contact_form = $(this); 3004 3005 if (true === $this_contact_form.data('submitted')) { 3006 // Previously submitted, do not submit again 3007 return; 3008 } 3009 3010 var $this_inputs = $this_contact_form.find('input[type=text], .et_pb_checkbox_handle, .et_pb_contact_field[data-type="radio"], textarea, select'); 3011 var $captcha_field = $this_contact_form.find('.et_pb_contact_captcha'); 3012 var $et_contact_message = $this_contact_container.find('.et-pb-contact-message'); 3013 var form_unique_id = typeof $this_contact_container.data('form_unique_num') !== 'undefined' ? $this_contact_container.data('form_unique_num') : 0; 3014 var this_et_contact_error = false; 3015 var et_message = ''; 3016 var et_fields_message = ''; 3017 var inputs_list = []; 3018 var hidden_fields = []; 3019 3020 et_message = '<ul>'; 3021 3022 $this_inputs.removeClass('et_contact_error'); 3023 3024 $this_inputs.each(function() { 3025 var $this_el = $(this); 3026 var $this_wrapper = false;
3027 3028 if ('checkbox' === $this_el.data('field_type')) { 3029 $this_wrapper = $this_el.parents('.et_pb_contact_field'); 3030 $this_wrapper.removeClass('et_contact_error'); 3031 } 3032 3033 if ('radio' === $this_el.data('type')) { 3034 $this_el = $this_el.find('input[type="radio"]'); 3035 $this_wrapper = $this_el.parents('.et_pb_contact_field'); 3036 } 3037 3038 var this_id = $this_el.attr('id'); 3039 var this_val = $this_el.val(); 3040 var this_label = $this_el.siblings('label:first').text(); 3041 var field_type = typeof $this_el.data('field_type') !== 'undefined' ? $this_el.data('field_type') : 'text'; 3042 var required_mark = typeof $this_el.data('required_mark') !== 'undefined' ? $this_el.data('required_mark') : 'not_required'; 3043 var original_id = typeof $this_el.data('original_id') !== 'undefined' ? $this_el.data('original_id') : ''; 3044 var unchecked = false; 3045 var default_value; 3046 3047 // radio field properties adjustment 3048 if ('radio' === field_type) { 3049 if (0 !== $this_wrapper.find('input[type="radio"]').length) { 3050 field_type = 'radio'; 3051 3052 var $firstRadio = $this_wrapper.find('input[type="radio"]:first'); 3053 3054 required_mark = typeof $firstRadio.data('required_mark') !== 'undefined' ? $firstRadio.data('required_mark') : 'not_required'; 3055 3056 this_val = ''; 3057 if ($this_wrapper.find('input[type="radio"]:checked')) { 3058 this_val = $this_wrapper.find('input[type="radio"]:checked').val(); 3059 } 3060 } 3061 3062 this_label = $this_wrapper.find('.et_pb_contact_form_label').text(); 3063 this_id = $this_wrapper.find('input[type="radio"]:first').attr('name'); 3064 original_id = $this_wrapper.attr('data-id'); 3065 3066 if (0 === $this_wrapper.find('input[type="radio"]:checked').length) { 3067 unchecked = true; 3068 } 3069 } 3070 3071 // radio field properties adjustment 3072 if ('checkbox' === field_type) { 3073 this_val = ''; 3074 3075 if (0 !== $this_wrapper.find('input[type="checkbox"]').length) { 3076 field_type = 'checkbox'; 3077 3078 var $checkboxHandle = $this_wrapper.find('.et_pb_checkbox_handle'); 3079 3080 required_mark = typeof $checkboxHandle.data('required_mark') !== 'undefined' ? $checkboxHandle.data('required_mark') : 'not_required'; 3081 3082 if ($this_wrapper.find('input[type="checked"]:checked')) { 3083 this_val = []; 3084 $this_wrapper.find('input[type="checkbox"]:checked').each(function() { 3085 this_val.push($(this).val()); 3086 }); 3087 3088 this_val = this_val.join(', '); 3089 } 3090 } 3091 3092 $this_wrapper.find('.et_pb_checkbox_handle').val(this_val); 3093 3094 this_label = $this_wrapper.find('.et_pb_contact_form_label').text(); 3095 this_id = $this_wrapper.find('.et_pb_checkbox_handle').attr('name'); 3096 original_id = $this_wrapper.attr('data-id'); 3097 3098 if (0 === $this_wrapper.find('input[type="checkbox"]:checked').length) { 3099 unchecked = true; 3100 } 3101 } 3102 3103 // Escape double quotes in label 3104 this_label = this_label.replace(/"/g, """); 3105 3106 // Store the labels of the conditionally hidden fields so that they can be 3107 // removed later if a custom message pattern is enabled 3108 if (! $this_el.is(':visible') && 'hidden' !== $this_el.attr('type') && 'radio' !== $this_el.attr('type')) { 3109 hidden_fields.push(original_id); 3110 return; 3111 } 3112 3113 if (('hidden' === $this_el.attr('type') || 'radio' === $this_el.attr('type')) && ! $this_el.parents('.et_pb_contact_field').is(':visible')) { 3114 hidden_fields.push(original_id); 3115 return; 3116 } 3117 3118 // add current field data into array of inputs 3119 if (typeof this_id !== 'undefined') { 3120 inputs_list.push({ 3121 'field_id': this_id, 3122 'original_id': original_id, 3123 'required_mark': required_mark, 3124 'field_type': field_type, 3125 'field_label': this_label 3126 }); 3127 } 3128 3129 // add error message for the field if it is required and empty 3130 if ('required' === required_mark && ('' === this_val || true === unchecked) && ! $this_el.is('[id^="et_pb_contact_et_number_"]')) { 3131 3132 if (false === $this_wrapper) { 3133 $this_el.addClass('et_contact_error'); 3134 } else { 3135 $this_wrapper.addClass('et_contact_error'); 3136 } 3137 3138 this_et_contact_error = true; 3139 3140 default_value = this_label; 3141 3142 if ('' === default_value) { 3143 default_value = et_pb_custom.captcha; 3144 } 3145 3146 et_fields_message += '<li>' + default_value + '</li>'; 3147 } 3148 3149 // add error message if email field is not empty and fails the email validation 3150 if ('email' === field_type) {
3151 // remove trailing/leading spaces and convert email to lowercase 3152 var processed_email = this_val.trim().toLowerCase(); 3153 var is_valid_email = et_email_reg_html5.test(processed_email); 3154 3155 if ('' !== processed_email && this_label !== processed_email && ! is_valid_email) { 3156 $this_el.addClass('et_contact_error'); 3157 this_et_contact_error = true; 3158 3159 if (! is_valid_email) { 3160 et_message += '<li>' + et_pb_custom.invalid + '</li>'; 3161 } 3162 } 3163 } 3164 }); 3165 3166 // check the captcha value if required for current form 3167 if ($captcha_field.length && '' !== $captcha_field.val()) { 3168 var first_digit = parseInt($captcha_field.data('first_digit')); 3169 var second_digit = parseInt($captcha_field.data('second_digit')); 3170 3171 if (parseInt($captcha_field.val()) !== first_digit + second_digit) { 3172 3173 et_message += '<li>' + et_pb_custom.wrong_captcha + '</li>'; 3174 this_et_contact_error = true; 3175 3176 // generate new digits for captcha 3177 first_digit = Math.floor((Math.random() * 15) + 1); 3178 second_digit = Math.floor((Math.random() * 15) + 1); 3179 3180 // set new digits for captcha 3181 $captcha_field.data('first_digit', first_digit); 3182 $captcha_field.data('second_digit', second_digit); 3183 3184 // regenerate captcha on page 3185 $this_contact_form.find('.et_pb_contact_captcha_question').empty().append(first_digit + ' + ' + second_digit); 3186 } 3187 3188 } 3189 3190 if (! this_et_contact_error) { 3191 // Mark this form as `submitted` to prevent repeated processing. 3192 $this_contact_form.data('submitted', true); 3193 3194 var $href = $(this).attr('action'); 3195 var form_data = $(this).serializeArray(); 3196 3197 form_data.push({ 3198 'name': 'et_pb_contact_email_fields_' + form_unique_id, 3199 'value': JSON.stringify(inputs_list) 3200 }); 3201 3202 if (hidden_fields.length > 0) { 3203 form_data.push({ 3204 'name': 'et_pb_contact_email_hidden_fields_' + form_unique_id, 3205 'value': JSON.stringify(hidden_fields) 3206 }); 3207 } 3208 3209 $this_contact_container.removeClass('et_animated').removeAttr('style').fadeTo('fast', 0.2, function() { 3210 $this_contact_container.load($href + ' #' + $this_contact_container.attr('id') + '> *', form_data, function(responseText) { 3211 if (! $(responseText).find('.et_pb_contact_error_text').length) { 3212 3213 et_pb_maybe_log_event($this_contact_container, 'con_goal'); 3214 3215 // redirect if redirect URL is not empty and no errors in contact form 3216 if ('' !== redirect_url) { 3217 window.location.href = redirect_url; 3218 } 3219 } 3220 3221 $this_contact_container.fadeTo('fast', 1); 3222 }); 3223 }); 3224 } 3225 3226 et_message += '</ul>'; 3227 3228 if ('' !== et_fields_message) { 3229 if (et_message !== '<ul></ul>') { 3230 et_message = '<p class="et_normal_padding">' + et_pb_custom.contact_error_message + '</p>' + et_message; 3231 } 3232 3233 et_fields_message = '<ul>' + et_fields_message + '</ul>'; 3234 3235 et_fields_message = '<p>' + et_pb_custom.fill_message + '</p>' + et_fields_message; 3236 3237 et_message = et_fields_message + et_message; 3238 } 3239 3240 if (et_message !== '<ul></ul>') { 3241 $et_contact_message.html(et_message); 3242 3243 // If parent of this contact form uses parallax 3244 if ($this_contact_container.parents('.et_pb_section_parallax').length) { 3245 $this_contact_container.parents('.et_pb_section_parallax').each(function() { 3246 var $parallax_element = $(this); 3247 var $parallax = $parallax_element.children('.et_parallax_bg'); 3248 var is_true_parallax = (! $parallax.hasClass('et_pb_parallax_css')); 3249 3250 if (is_true_parallax) { 3251 $et_window.trigger('resize'); 3252 } 3253 }); 3254 } 3255 } 3256 }); 3257 }); 3258 } 3259 3260 window.et_pb_play_overlayed_video = function( $play_video ) { 3261 var $this = $play_video; 3262 var $video_image = $this.closest('.et_pb_video_overlay'); 3263 var $wrapper = $this.closest('.et_pb_video, .et_main_video_container, .et_pb_video_wrap'); 3264 var $video_iframe = $wrapper.find('iframe'); 3265 var is_embedded = $video_iframe.length > 0; 3266 var is_fb_video = $wrapper.find('.fb-video').length; 3267 var video_iframe_src; 3268 var video_iframe_src_splitted; 3269 var video_iframe_src_autoplay; 3270 3271 if (is_embedded) { 3272 if (is_fb_video && 'undefined' !== typeof $video_iframe[2]) { 3273 // Facebook uses three http/https/iframe 3274 $video_iframe = $($video_iframe[2]); 3275 } 3276 3277 // Add autoplay parameter to automatically play embedded content when overlay is clicked 3278 video_iframe_src = $video_iframe.attr('src'); 3279 video_iframe_src_splitted = video_iframe_src.split("?"); 3280 3281 if (video_iframe_src.indexOf('autoplay=') !== -1) { 3282 return; 3283 } 3284 3285 if (typeof video_iframe_src_splitted[1] !== 'undefined') { 3286 video_iframe_src_autoplay = video_iframe_src_splitted[0] + "?autoplay=1&" + video_iframe_src_splitted[1]; 3287 } else { 3288 video_iframe_src_autoplay = video_iframe_src_splitted[0] + "?autoplay=1"; 3289 } 3290 3291 $video_iframe.attr({ 3292 'src': video_iframe_src_autoplay 3293 }); 3294 } else { 3295 $wrapper.find('video').get(0).play(); 3296 } 3297 3298 3299 $video_image.fadeTo( 500, 0, function() { 3300 var $image = $(this); 3301 3302 $image.css( 'display', 'none' ); 3303 } ); 3304 }; 3305 3306 $( '.et_pb_post .et_pb_video_overlay, .et_pb_video .et_pb_video_overlay, .et_pb_video_wrap .et_pb_video_overlay' ).click( function() { 3307 var $this = $(this); 3308 3309 et_pb_play_overlayed_video( $this ); 3310 3311 return false;
3312 } ); 3313 3314 window.et_pb_resize_section_video_bg = function( $video ) { 3315 $element = typeof $video !== 'undefined' ? $video.closest( '.et_pb_section_video_bg' ) : $( '.et_pb_section_video_bg' ); 3316 3317 $element.each( function() { 3318 var $this_el = $(this); 3319 3320 if ( is_frontend_builder ) { 3321 $this_el.removeAttr('data-ratio'); 3322 $this_el.find('video').removeAttr('style'); 3323 } 3324 3325 var $video = $this_el.find('video'); 3326 var el_width = ($video.prop('videoWidth')) || parseInt($video.width()); 3327 var el_height = ($video.prop('videoHeight')) || parseInt($video.height()); 3328 3329 var ratio = el_width / el_height; 3330 3331 var $video_elements = $this_el.find( '.mejs-video, video, object' ).css( 'margin', 0 ); 3332 3333 var $container = $this_el.closest( '.et_pb_section_video' ).length 3334 ? $this_el.closest( '.et_pb_section_video' ) 3335 : $this_el.closest( '.et_pb_slides' ); 3336 3337 var body_width = $container.innerWidth(); 3338 3339 var container_height = $container.innerHeight(); 3340 3341 var width, height; 3342 3343 if ( typeof $this_el.attr( 'data-ratio' ) == 'undefined' && !isNaN(ratio) ) { 3344 $this_el.attr( 'data-ratio', ratio ); 3345 } 3346 3347 if ( body_width / container_height < ratio ) { 3348 width = container_height * ratio; 3349 height = container_height; 3350 } else { 3351 width = body_width; 3352 height = body_width / ratio; 3353 } 3354 3355 $video_elements.width( width ).height( height ); 3356 3357 // need to re-set the values to make it work correctly in Frontend builder 3358 if ( is_frontend_builder ) { 3359 setTimeout( function() { 3360 $video_elements.width( width ).height( height ); 3361 }, 0 ); 3362 } 3363 } ); 3364 }; 3365 3366 window.et_pb_center_video = function( $video ) { 3367 $element = typeof $video !== 'undefined' ? $video : $( '.et_pb_section_video_bg .mejs-video' ); 3368 3369 if ( ! $element.length ) { 3370 return; 3371 } 3372 3373 $element.each( function() { 3374 var $this_el = $(this); 3375 3376 et_pb_adjust_video_margin( $this_el ); 3377 3378 // need to re-calculate the values in Frontend builder 3379 if ( is_frontend_builder ) { 3380 setTimeout( function() { 3381 et_pb_adjust_video_margin( $this_el ); 3382 }, 0 ); 3383 } 3384 3385 if ( typeof $video !== 'undefined' ) { 3386 if ( $video.closest( '.et_pb_slider' ).length && ! $video.closest( '.et_pb_first_video' ).length ) { 3387 return false; 3388 } 3389 } 3390 } ); 3391 }; 3392 3393 window.et_pb_adjust_video_margin = function( $el ) { 3394 var $video_width = $el.width() / 2; 3395 var $video_width_negative = 0 - $video_width; 3396 3397 $el.css("margin-left", $video_width_negative ); 3398 }; 3399 3400 function et_fix_slider_height( $slider ) { 3401 var $this_slider = $slider || $et_pb_slider; 3402 3403 if ( ! $this_slider || ! $this_slider.length ) { 3404 return; 3405 } 3406 3407 $this_slider.each( function() { 3408 var $slide_section = $(this).parent( '.et_pb_section' ), 3409 $slides = $(this).find( '.et_pb_slide' ), 3410 $slide_containers = $slides.find( '.et_pb_container' ), 3411 max_height = 0, 3412 image_margin = 0, 3413 need_image_margin_top = $(this).hasClass( 'et_pb_post_slider_image_top' ), 3414 need_image_margin_bottom = $(this).hasClass( 'et_pb_post_slider_image_bottom' ); 3415 3416 // If this is appears at the first section beneath transparent nav, skip it 3417 // leave it to et_fix_page_container_position() 3418 if ( $slide_section.is( '.et_pb_section_first' ) ){ 3419 return true; 3420 } 3421 3422 $slide_containers.css( 'height', '' ); 3423 3424 // make slides visible to calculate the height correctly 3425 $slides.addClass( 'et_pb_temp_slide' ); 3426 3427 if ( typeof $(this).data('et_pb_simple_slider') === 'object' ) { 3428 $(this).data('et_pb_simple_slider').et_fix_slider_content_images(); 3429 } 3430 3431 $slides.each( function() { 3432 var height = parseFloat( $(this).innerHeight() ), 3433 $slide_image = $(this).find( '.et_pb_slide_image' ), 3434 adjustedHeight = parseFloat( $(this).data( 'adjustedHeight' ) ), 3435 autoTopPadding = isNaN( adjustedHeight ) ? 0 : adjustedHeight; 3436 3437 // reduce the height by autopadding value if slider height was adjusted. This is required in VB. 3438 height = ( autoTopPadding && autoTopPadding < height ) ? ( height - autoTopPadding ) : height; 3439 3440 if ( need_image_margin_top || need_image_margin_bottom ) { 3441 if ( $slide_image.length ) { 3442 // get the margin from slides with image 3443 image_margin = need_image_margin_top ? parseFloat( $slide_image.css( 'margin-top' ) ) : parseFloat( $slide_image.css( 'margin-bottom' ) ); 3444 image_margin += 10; 3445 } else { 3446 // add class to slides without image to adjust their height accordingly 3447 $(this).find( '.et_pb_container' ).addClass( 'et_pb_no_image' ); 3448 } 3449 } 3450 3451 // mark the slides without content 3452 if ( 0 === Math.abs( parseInt( $(this).find( '.et_pb_slide_description' ).height() ) ) ) { 3453 $(this).find( '.et_pb_container' ).addClass( 'et_pb_empty_slide' ); 3454 } 3455 3456 if ( max_height < height ) { 3457 max_height = height; 3458 } 3459 } ); 3460 3461 if ( ( max_height + image_margin ) < 1 ) { 3462 // No slides have any content. It's probably being used with background images only. 3463 // Reset the height so that it falls back to the default padding for the content. 3464 $slide_containers.css( 'height', '' ); 3465 3466 } else { 3467 $slide_containers.css( 'height', max_height + image_margin ); 3468 } 3469 3470 // remove temp class after getting the slider height 3471 $slides.removeClass( 'et_pb_temp_slide' ); 3472 3473 // Show the active slide's image (if exists) 3474 $slides.filter('.et-pb-active-slide') 3475 .find( '.et_pb_slide_image' ) 3476 .children( 'img' ) 3477 .addClass( 'active' ); 3478 } ); 3479 } 3480 var debounced_et_fix_slider_height = {}; 3481 3482 // This function can end up being called a lot of times and it's quite expensive in terms of cpu due to 3483 // recalculating styles. Debouncing it (VB only) for performances reasons. 3484 window.et_fix_slider_height = !is_frontend_builder ? et_fix_slider_height : function($slider) { 3485 var $this_slider = $slider || $et_pb_slider; 3486 3487 if ( ! $this_slider || ! $this_slider.length ) { 3488 return; 3489 } 3490 3491 // Create a debounced function per slider 3492 var address = $this_slider.data('address'); 3493 if (!debounced_et_fix_slider_height[address]) { 3494 debounced_et_fix_slider_height[address] = window.et_pb_debounce(et_fix_slider_height, 100); 3495 } 3496 debounced_et_fix_slider_height[address]($slider); 3497 }; 3498 3499 /** 3500 * Add conditional class to prevent unwanted dropdown nav 3501 */ 3502 function et_fix_nav_direction() { 3503 window_width = $(window).width(); 3504 $('.nav li.et-reverse-direction-nav').removeClass( 'et-reverse-direction-nav' ); 3505 $('.nav li li ul').each(function(){ 3506 var $dropdown = $(this), 3507 dropdown_width = $dropdown.width(), 3508 dropdown_offset = $dropdown.offset(), 3509 $parents = $dropdown.parents('.nav > li'); 3510 3511 if ( dropdown_offset.left > ( window_width - dropdown_width ) ) { 3512 $parents.addClass( 'et-reverse-direction-nav' ); 3513 } 3514 }); 3515 } 3516 et_fix_nav_direction(); 3517 3518 et_pb_form_placeholders_init( $( '.et_pb_comments_module #commentform' ) ); 3519 3520 $('.et_pb_fullwidth_menu ul.nav').each(function(i) { 3521 i++; 3522 et_duplicate_menu( $(this), $(this).parents('.et_pb_row').find('div .mobile_nav'), 'mobile_menu' + i, 'et_mobile_menu' ); 3523 }); 3524 3525 $('.et_pb_fullwidth_menu').each(function() { 3526 var this_menu = $( this ), 3527 bg_color = this_menu.data( 'bg_color' ); 3528 if ( bg_color ) { 3529 this_menu.find( 'ul' ).css( { 'background-color' : bg_color } ); 3530 } 3531 }); 3532 3533 $et_pb_newsletter_button.click( function( event ) { 3534 et_pb_submit_newsletter( $(this), event ); 3535 } ); 3536 3537 $et_pb_newsletter_button 3538 .closest('.et_pb_newsletter') 3539 .find('input[type=checkbox]') 3540 .on('change', function() { 3541 var $checkbox = $(this); 3542 var $checkbox_field = $checkbox.siblings('input[type=text]:first'); 3543 var is_checked = $checkbox.prop('checked'); 3544 3545 $checkbox_field.val(is_checked ? $checkbox_field.data('checked') : $checkbox_field.data('unchecked')); 3546 }); 3547 3548 window.et_pb_submit_newsletter = function( $submit, event ) { 3549 if ($submit.closest('.et_pb_login_form').length) { 3550 et_pb_maybe_log_event($submit.closest('.et_pb_newsletter'), 'con_goal'); 3551 return; 3552 } 3553 3554 if ( typeof event !== 'undefined' ) { 3555 event.preventDefault(); 3556 } 3557
3558 // check if it is a feedburner feed subscription 3559 if ($('.et_pb_feedburner_form').length > 0) { 3560 $feed_name = $('.et_pb_feedburner_form input[name=uri]').val(); 3561 window.open('https://feedburner.google.com/fb/a/mailverify?uri=' + $feed_name, 'et-feedburner-subscribe', 'scrollbars=yes,width=550,height=520'); 3562 return true; 3563 } // otherwise keep things moving 3564 3565 var $newsletter_container = $submit.closest('.et_pb_newsletter'); 3566 var $name = $newsletter_container.find('input[name="et_pb_signup_firstname"]'); 3567 var $lastname = $newsletter_container.find('input[name="et_pb_signup_lastname"]'); 3568 var $email = $newsletter_container.find('input[name="et_pb_signup_email"]'); 3569 var list_id = $newsletter_container.find('input[name="et_pb_signup_list_id"]').val(); 3570 var $error_message = $newsletter_container.find('.et_pb_newsletter_error').hide(); 3571 var provider = $newsletter_container.find('input[name="et_pb_signup_provider"]').val(); 3572 var account = $newsletter_container.find('input[name="et_pb_signup_account_name"]').val(); 3573 var ip_address = $newsletter_container.find('input[name="et_pb_signup_ip_address"]').val(); 3574 3575 var $fields_container = $newsletter_container.find('.et_pb_newsletter_fields'); 3576 3577 var $success_message = $newsletter_container.find( '.et_pb_newsletter_success' ); 3578 var redirect_url = $newsletter_container.data( 'redirect_url' ); 3579 var redirect_query = $newsletter_container.data( 'redirect_query' ); 3580 var custom_fields = {}; 3581 var hidden_fields = []; 3582 var et_message = '<ul>'; 3583 var et_fields_message = ''; 3584 3585 var $custom_fields = $fields_container 3586 .find('input[type=text], .et_pb_checkbox_handle, .et_pb_contact_field[data-type="radio"], textarea, select') 3587 .filter('.et_pb_signup_custom_field, .et_pb_signup_custom_field *'); 3588 3589 3590 $name.removeClass( 'et_pb_signup_error' ); 3591 $lastname.removeClass( 'et_pb_signup_error' ); 3592 $email.removeClass( 'et_pb_signup_error' ); 3593 $custom_fields.removeClass('et_contact_error'); 3594 $error_message.html(''); 3595 3596 // Validate user input 3597 var is_valid = true; 3598 var form = $submit.closest('.et_pb_newsletter_form form'); 3599 if (form.length > 0 && typeof form[0].reportValidity === 'function') { 3600 // Checks HTML5 validation constraints 3601 is_valid = form[0].reportValidity(); 3602 } 3603 3604 if ( $name.length > 0 && ! $name.val() ) { 3605 $name.addClass( 'et_pb_signup_error' ); 3606 is_valid = false; 3607 } 3608 3609 if ( $lastname.length > 0 && ! $lastname.val() ) { 3610 $lastname.addClass( 'et_pb_signup_error' ); 3611 is_valid = false; 3612 } 3613 3614 if ( ! et_email_reg_html5.test( $email.val() ) ) { 3615 $email.addClass( 'et_pb_signup_error' ); 3616 is_valid = false; 3617 } 3618 3619 if ( ! is_valid ) { 3620 return; 3621 } 3622 3623 $custom_fields.each(function() { 3624 var $this_el = $(this); 3625 var $this_wrapper = false;
3626 3627 if ('checkbox' === $this_el.data('field_type')) { 3628 $this_wrapper = $this_el.parents('.et_pb_contact_field'); 3629 $this_wrapper.removeClass('et_contact_error'); 3630 } 3631 3632 if ('radio' === $this_el.data('type')) { 3633 $this_el = $this_el.find('input[type="radio"]'); 3634 $this_wrapper = $this_el.parents('.et_pb_contact_field'); 3635 } 3636 3637 var this_id = $this_el.data('id'); 3638 var this_val = $this_el.val(); 3639 var this_label = $this_el.siblings('label:first').text(); 3640 var field_type = typeof $this_el.data('field_type') !== 'undefined' ? $this_el.data('field_type') : 'text'; 3641 var required_mark = typeof $this_el.data('required_mark') !== 'undefined' ? $this_el.data('required_mark') : 'not_required'; 3642 var original_id = typeof $this_el.data('original_id') !== 'undefined' ? $this_el.data('original_id') : ''; 3643 var unchecked = false; 3644 var default_value; 3645 3646 if (! this_id) { 3647 this_id = $this_el.data('original_id'); 3648 } 3649 3650 // radio field properties adjustment 3651 if ('radio' === field_type) { 3652 if (0 !== $this_wrapper.find('input[type="radio"]').length) { 3653 var $firstRadio = $this_wrapper.find('input[type="radio"]:first'); 3654 3655 required_mark = typeof $firstRadio.data('required_mark') !== 'undefined' ? $firstRadio.data('required_mark') : 'not_required'; 3656 3657 this_val = ''; 3658 3659 if ($this_wrapper.find('input[type="radio"]:checked')) { 3660 this_val = $this_wrapper.find('input[type="radio"]:checked').val(); 3661 } 3662 } 3663 3664 this_label = $this_wrapper.find('.et_pb_contact_form_label').text(); 3665 this_id = $this_el.data('original_id'); 3666 3667 if (! $.isEmptyObject(this_val)) { 3668 custom_fields[this_id] = this_val; 3669 } 3670 3671 if (0 === $this_wrapper.find('input[type="radio"]:checked').length) { 3672 unchecked = true; 3673 } 3674 3675 if (this_val) { 3676 custom_fields[this_id] = this_val; 3677 } 3678 3679 } else if ('checkbox' === field_type) { 3680 this_val = {}; 3681 3682 if (0 !== $this_wrapper.find('input[type="checkbox"]').length) { 3683 var $checkboxHandle = $this_wrapper.find('.et_pb_checkbox_handle'); 3684 3685 required_mark = typeof $checkboxHandle.data('required_mark') !== 'undefined' ? $checkboxHandle.data('required_mark') : 'not_required'; 3686 3687 if ($this_wrapper.find('input[type="checked"]:checked')) { 3688 $this_wrapper.find('input[type="checkbox"]:checked').each(function() { 3689 var field_id = $(this).data('id'); 3690 this_val[field_id] = $(this).val(); 3691 }); 3692 } 3693 } 3694 3695 this_label = $this_wrapper.find('.et_pb_contact_form_label').text(); 3696 this_id = $this_wrapper.attr('data-id'); 3697 3698 if (! $.isEmptyObject(this_val)) { 3699 custom_fields[this_id] = this_val; 3700 } 3701 3702 if (0 === $this_wrapper.find('input[type="checkbox"]:checked').length) { 3703 unchecked = true; 3704 } 3705 } else if ('ontraport' === provider && 'select' === field_type) { 3706 // Need to pass option ID as a value for dropdown menu in Ontraport 3707 var $selected_option = $this_el.find(':selected'); 3708 custom_fields[this_id] = $selected_option.length > 0 ? $selected_option.data('id') : this_val; 3709 } else { 3710 custom_fields[this_id] = this_val; 3711 } 3712 3713 // Escape double quotes in label 3714 this_label = this_label.replace(/"/g, """); 3715 3716 // Store the labels of the conditionally hidden fields so that they can be 3717 // removed later if a custom message pattern is enabled 3718 if (! $this_el.is(':visible') && 'hidden' !== $this_el.attr('type') && 'radio' !== $this_el.attr('type')) { 3719 hidden_fields.push(original_id); 3720 return; 3721 } 3722 3723 if (('hidden' === $this_el.attr('type') || 'radio' === $this_el.attr('type')) && ! $this_el.parents('.et_pb_contact_field').is(':visible')) { 3724 hidden_fields.push(this_id); 3725 return; 3726 } 3727 3728 // add error message for the field if it is required and empty 3729 if ('required' === required_mark && ('' === this_val || true === unchecked)) { 3730 3731 if (false === $this_wrapper) { 3732 $this_el.addClass('et_contact_error'); 3733 } else { 3734 $this_wrapper.addClass('et_contact_error'); 3735 } 3736 3737 is_valid = false;
3738 3739 default_value = this_label; 3740 3741 if ('' === default_value) { 3742 default_value = et_pb_custom.captcha; 3743 } 3744 3745 et_fields_message += '<li>' + default_value + '</li>'; 3746 } 3747 3748 // add error message if email field is not empty and fails the email validation 3749 if ('email' === field_type) { 3750 // remove trailing/leading spaces and convert email to lowercase 3751 var processed_email = this_val.trim().toLowerCase(); 3752 var is_valid_email = et_email_reg_html5.test(processed_email); 3753 3754 if ('' !== processed_email && this_label !== processed_email && ! is_valid_email) { 3755 $this_el.addClass('et_contact_error'); 3756 is_valid = false; 3757 3758 if (! is_valid_email) { 3759 et_message += '<li>' + et_pb_custom.invalid + '</li>'; 3760 } 3761 } 3762 } 3763 }); 3764 3765 et_message += '</ul>'; 3766 3767 if ('' !== et_fields_message) { 3768 if (et_message !== '<ul></ul>') { 3769 et_message = '<p class="et_normal_padding">' + et_pb_custom.contact_error_message + '</p>' + et_message; 3770 } 3771 3772 et_fields_message = '<ul>' + et_fields_message + '</ul>'; 3773 3774 et_fields_message = '<p>' + et_pb_custom.fill_message + '</p>' + et_fields_message; 3775 3776 et_message = et_fields_message + et_message; 3777 } 3778 3779 if (et_message !== '<ul></ul>') { 3780 $error_message.html(et_message).show(); 3781 3782 // If parent of this contact form uses parallax 3783 if ($newsletter_container.parents('.et_pb_section_parallax').length) { 3784 $newsletter_container.parents('.et_pb_section_parallax').each(function() { 3785 var $parallax_element = $(this), 3786 $parallax = $parallax_element.children('.et_parallax_bg'), 3787 is_true_parallax = (! $parallax.hasClass('et_pb_parallax_css')); 3788 3789 if (is_true_parallax) { 3790 $et_window.trigger('resize'); 3791 } 3792 }); 3793 } 3794 3795 return; 3796 } 3797 3798 function get_redirect_query() { 3799 var query = {}; 3800 3801 if ( ! redirect_query ) { 3802 return ''; 3803 } 3804 3805 if ( $name.length > 0 && redirect_query.indexOf( 'name' ) > -1 ) { 3806 query.first_name = $name.val(); 3807 } 3808 3809 if ( $lastname.length > 0 && redirect_query.indexOf( 'last_name' ) > -1 ) { 3810 query.last_name = $lastname.val(); 3811 } 3812 3813 if ( redirect_query.indexOf( 'email' ) > -1 ) { 3814 query.email = $email.val(); 3815 } 3816 3817 if ( redirect_query.indexOf( 'ip_address' ) > -1 ) { 3818 query.ip_address = $newsletter_container.data( 'ip_address' ); 3819 } 3820 3821 if ( redirect_query.indexOf( 'css_id' ) > -1 ) { 3822 query.form_id = $newsletter_container.attr( 'id' ); 3823 } 3824 3825 return decodeURIComponent( $.param( query ) ); 3826 } 3827 3828 $.ajax( { 3829 type: "POST", 3830 url: et_pb_custom.ajaxurl, 3831 dataType: "json", 3832 data: { 3833 action : 'et_pb_submit_subscribe_form', 3834 et_frontend_nonce : et_pb_custom.et_frontend_nonce, 3835 et_list_id : list_id, 3836 et_firstname : $name.val(), 3837 et_lastname : $lastname.val(), 3838 et_email : $email.val(), 3839 et_provider : provider, 3840 et_account: account, 3841 et_ip_address: ip_address, 3842 et_custom_fields: custom_fields, 3843 et_hidden_fields: hidden_fields 3844 }, 3845 beforeSend: function() { 3846 $newsletter_container 3847 .find( '.et_pb_newsletter_button' ) 3848 .addClass( 'et_pb_button_text_loading' ) 3849 .find('.et_subscribe_loader') 3850 .show(); 3851 }, 3852 complete: function() { 3853 $newsletter_container 3854 .find( '.et_pb_newsletter_button' ) 3855 .removeClass( 'et_pb_button_text_loading' ) 3856 .find('.et_subscribe_loader') 3857 .hide(); 3858 }, 3859 success: function( data ) { 3860 if ( ! data ) { 3861 $error_message.html( et_pb_custom.subscription_failed ).show(); 3862 return; 3863 } 3864 3865 if ( data.error ) { 3866 $error_message.show().append('<h2>').text( data.error ); 3867 } 3868 3869 if ( data.success ) { 3870 if (redirect_url) { 3871 et_pb_maybe_log_event($newsletter_container, 'con_goal', function() { 3872 var query = get_redirect_query(); 3873 3874 if (query.length) { 3875 if (redirect_url.indexOf('?') > - 1) { 3876 redirect_url += '&'; 3877 } else { 3878 redirect_url += '?'; 3879 } 3880 } 3881 3882 window.location = redirect_url + query; 3883 }); 3884 } else { 3885 et_pb_maybe_log_event($newsletter_container, 'con_goal'); 3886 $newsletter_container.find('.et_pb_newsletter_fields').hide(); 3887 $success_message.show(); 3888 } 3889 } 3890 } 3891 } ); 3892 }; 3893 3894 window.et_fix_testimonial_inner_width = function() { 3895 var window_width = $( window ).width(); 3896 3897 if ( window_width > 959 ) { 3898 $('.et_pb_testimonial').each(function () { 3899 if (! $(this).is(':visible')) { 3900 return; 3901 } 3902 3903 var $testimonial = $(this); 3904 var $portrait = $testimonial.find('.et_pb_testimonial_portrait'); 3905 var portrait_width = $portrait.outerWidth(true); 3906 var $testimonial_descr = $testimonial.find('.et_pb_testimonial_description'); 3907 var $outer_column = $testimonial.closest('.et_pb_column'); 3908 3909 if (portrait_width > 90) { 3910 $portrait.css('padding-bottom', '0'); 3911 $portrait.width('90px'); 3912 $portrait.height('90px'); 3913 } 3914 3915 var testimonial_indent = ! ($outer_column.hasClass('et_pb_column_1_3') 3916 || $outer_column.hasClass('et_pb_column_1_4') 3917 || $outer_column.hasClass('et_pb_column_1_5') 3918 || $outer_column.hasClass('et_pb_column_1_6') 3919 || $outer_column.hasClass('et_pb_column_2_5') 3920 || $outer_column.hasClass('et_pb_column_3_8')) ? portrait_width : 0; 3921 3922 $testimonial_descr.css('margin-left', testimonial_indent); 3923 }); 3924 } else if ( window_width > 767 ) { 3925 $( '.et_pb_testimonial' ).each( function() { 3926 if ( ! $(this).is( ':visible' ) ) { 3927 return; 3928 } 3929 3930 var $testimonial = $(this); 3931 var $portrait = $testimonial.find('.et_pb_testimonial_portrait'); 3932 var portrait_width = $portrait.outerWidth(true); 3933 var $testimonial_descr = $testimonial.find('.et_pb_testimonial_description'); 3934 var $outer_column = $testimonial.closest('.et_pb_column'); 3935 var testimonial_indent = ! ($outer_column.hasClass('et_pb_column_1_4') 3936 || $outer_column.hasClass('et_pb_column_1_5') 3937 || $outer_column.hasClass('et_pb_column_1_6') 3938 || $outer_column.hasClass('et_pb_column_2_5') 3939 || $outer_column.hasClass('et_pb_column_3_8')) ? portrait_width : 0; 3940 3941 $testimonial_descr.css( 'margin-left', testimonial_indent ); 3942 } ); 3943 } else { 3944 $( '.et_pb_testimonial_description' ).removeAttr( 'style' ); 3945 } 3946 }; 3947 window.et_fix_testimonial_inner_width(); 3948 3949 window.et_pb_video_background_init = function( $this_video_background, this_video_background ) { 3950 var $video_background_wrapper = $this_video_background.closest( '.et_pb_section_video_bg' ); 3951 3952 // Initializing video values 3953 var onplaying = false;
3954 var onpause = true; 3955 3956 // On video playing toggle values 3957 this_video_background.onplaying = function() { 3958 onplaying = true; 3959 onpause = false; 3960 }; 3961 3962 // On video pause toggle values 3963 this_video_background.onpause = function() { 3964 onplaying = false; 3965 onpause = true; 3966 }; 3967 3968 // Entering video's top viewport 3969 et_waypoint( $video_background_wrapper, { 3970 offset: '100%', 3971 handler : function( direction ) { 3972 // This has to be placed inside handler to make it works with changing class name in VB 3973 var is_play_outside_viewport = $video_background_wrapper.hasClass( 'et_pb_video_play_outside_viewport' ); 3974 3975 if ( $this_video_background.is(':visible') && direction === 'down' ) { 3976 if ( this_video_background.paused && ! onplaying ) { 3977 this_video_background.play(); 3978 } 3979 } else if ( $this_video_background.is(':visible') && direction === 'up' ) { 3980 if ( ! this_video_background.paused && ! onpause && ! is_play_outside_viewport ) { 3981 this_video_background.pause(); 3982 } 3983 } 3984 } 3985 }, 2 ); 3986 3987 // Entering video's bottom viewport 3988 et_waypoint( $video_background_wrapper, { 3989 offset: function() { 3990 var video_height = this.element.clientHeight, 3991 toggle_offset = Math.ceil( window.innerHeight / 2); 3992 3993 if ( video_height > toggle_offset ) { 3994 toggle_offset = video_height; 3995 } 3996 3997 return toggle_offset * (-1); 3998 }, 3999 handler : function( direction ) { 4000 // This has to be placed inside handler to make it works with changing class name in VB 4001 var is_play_outside_viewport = $video_background_wrapper.hasClass( 'et_pb_video_play_outside_viewport' ); 4002 4003 if ( $this_video_background.is(':visible') && direction === 'up' ) { 4004 if ( this_video_background.paused && ! onplaying ) { 4005 this_video_background.play(); 4006 } 4007 } else if ( $this_video_background.is(':visible') && direction === 'down' ) { 4008 if ( ! this_video_background.paused && ! onpause && ! is_play_outside_viewport ) { 4009 this_video_background.pause(); 4010 } 4011 } 4012 } 4013 }, 2 ); 4014 }; 4015 4016 function et_waypoint( $element, options, max_instances ) { 4017 max_instances = max_instances || $element.data( 'et_waypoint_max_instances' ) || 1; 4018 var current_instances = $element.data( 'et_waypoint' ) || []; 4019 4020 if ( current_instances.length < max_instances ) { 4021 var new_instances = $element.waypoint( options ); 4022 4023 if ( new_instances && new_instances.length > 0 ) { 4024 current_instances.push( new_instances[0] ); 4025 $element.data( 'et_waypoint', current_instances ); 4026 } 4027 } else { 4028 // Reinit existing 4029 for ( var i = 0; i < current_instances.length; i++ ) { 4030 current_instances[i].context.refresh(); 4031 } 4032 } 4033 } 4034 4035 /** 4036 * Returns an offset to be used for waypoints. 4037 * @param {element} element The element being passed. 4038 * @param {string} fallback String of either pixels or percent. 4039 * @return {string} Returns either the fallback or 'bottom-in-view' 4040 */ 4041 function et_get_offset( element, fallback ) { 4042 // cache things so we can test. 4043 var section_index = element.parents('.et_pb_section').index(), 4044 section_length = $('.et_pb_section').length - 1, 4045 row_index = element.parents('.et_pb_row').index(), 4046 row_length = element.parents('.et_pb_section').children().length - 1; 4047 4048 // return bottom-in-view if it is the last element otherwise return the user defined fallback 4049 if ( section_index === section_length && row_index === row_length ) { 4050 return 'bottom-in-view'; 4051 } 4052 return fallback; 4053 } 4054 4055 /** 4056 * Reinit animation styles on window resize. 4057 * 4058 * It will check current window mode then compare it with the breakpoint of last rendered 4059 * animation styles. If it's different, it will recall et_process_animation_data(). 4060 * 4061 * @since 3.23 4062 */ 4063 function et_pb_reinit_animation() { 4064 // If mode is changed, reinit animation data. 4065 if ( et_pb_get_current_window_mode() !== et_animation_breakpoint ) { 4066 et_process_animation_data( false ); 4067 } 4068 } 4069 4070 /** 4071 * Update map filters. 4072 * 4073 * @since 3.23 4074 * @since 3.24.1 Prevent reinit maps to update map filters. 4075 * 4076 * @param {jQuery} $et_pb_map 4077 */ 4078 function et_pb_update_maps_filters($et_pb_map) { 4079 // Ensure to update map filters only on preview mode changes. 4080 if (et_pb_get_current_window_mode() === et_animation_breakpoint) { 4081 return false;
4082 } 4083 4084 $et_pb_map.each(function(){ 4085 var $this_map = $(this); 4086 var this_map = $this_map.data('map'); 4087 4088 // Ensure the map exist. 4089 if ('undefined' === typeof this_map) { 4090 return; 4091 } 4092 4093 var current_mode = et_pb_get_current_window_mode(); 4094 et_animation_breakpoint = current_mode; 4095 var suffix = current_mode !== 'desktop' ? '-' + current_mode : ''; 4096 var prev_suffix = current_mode === 'phone' ? '-tablet' : ''; 4097 var grayscale_value = $this_map.attr('data-grayscale' + suffix) || 0; 4098 if (!grayscale_value) { 4099 grayscale_value = $this_map.attr('data-grayscale' + prev_suffix) || $this_map.attr('data-grayscale') || 0; 4100 } 4101 4102 // Convert it to negative value as string. 4103 if (grayscale_value !== 0) { 4104 grayscale_value = '-' + grayscale_value.toString(); 4105 } 4106 4107 // Apply grayscale value on the saturation. 4108 this_map.setOptions({ 4109 styles: [{ 4110 stylers: [ 4111 { saturation: parseInt(grayscale_value) } 4112 ] 4113 }] 4114 }); 4115 }); 4116 } 4117 4118 function et_animate_element($elementOriginal) { 4119 var $element = $elementOriginal; 4120 if ($element.hasClass('et_had_animation')) { 4121 return; 4122 } 4123 4124 var animation_style = $element.attr('data-animation-style'); 4125 var animation_repeat = $element.attr('data-animation-repeat'); 4126 var animation_duration = $element.attr('data-animation-duration'); 4127 var animation_delay = $element.attr('data-animation-delay'); 4128 var animation_intensity = $element.attr('data-animation-intensity'); 4129 var animation_starting_opacity = $element.attr('data-animation-starting-opacity'); 4130 var animation_speed_curve = $element.attr('data-animation-speed-curve'); 4131 var $buttonWrapper = $element.parent('.et_pb_button_module_wrapper'); 4132 4133 // Avoid horizontal scroll bar when section is rolled 4134 if ($element.is('.et_pb_section') && 'roll' === animation_style) { 4135 $('#et-boc').css('overflow-x', 'hidden'); 4136 } 4137 4138 // Remove all the animation data attributes once the variables have been set 4139 et_remove_animation_data( $element ); 4140 4141 // Opacity can be 0 to 1 so the starting opacity is equal to the percentage number multiplied by 0.01 4142 var starting_opacity = isNaN( parseInt( animation_starting_opacity ) ) ? 0 : parseInt( animation_starting_opacity ) * 0.01; 4143 4144 // Check if the animation speed curve is one of the allowed ones and set it to the default one if it is not 4145 if ( $.inArray( animation_speed_curve, ['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out'] ) === -1 ) { 4146 animation_speed_curve = 'ease-in-out'; 4147 } 4148 4149 if ($buttonWrapper.length > 0) { 4150 $element.removeClass('et_animated'); 4151 $element = $buttonWrapper; 4152 $element.addClass('et_animated'); 4153 } 4154 4155 $element.css({ 4156 'animation-duration' : animation_duration, 4157 'animation-delay' : animation_delay, 4158 'opacity' : starting_opacity, 4159 'animation-timing-function' : animation_speed_curve 4160 }); 4161 4162 var intensity_css = {}; 4163 var intensity_percentage = isNaN( parseInt( animation_intensity ) ) ? 50 : parseInt( animation_intensity ); 4164 4165 // All the animations that can have intensity 4166 var intensity_animations = ['slide', 'zoom', 'flip', 'fold', 'roll']; 4167 4168 var original_animation = false; 4169 var original_direction = false; 4170 4171 // Check if current animation can have intensity 4172 for ( var i = 0; i < intensity_animations.length; i++ ) { 4173 var animation = intensity_animations[i]; 4174 4175 // As the animation style is a combination of type and direction check if 4176 // the current animation contains any of the allowed animation types 4177 if ( ! animation_style || animation_style.substr( 0, animation.length ) !== animation ) { 4178 continue; 4179 } 4180 4181 // If it does set the original animation to the base animation type 4182 original_animation = animation; 4183 4184 // Get the remainder of the animation style and set it as the direction 4185 original_direction = animation_style.substr(animation.length, animation_style.length); 4186 4187 // If that is not empty convert it to lower case for better readability's sake
4188 if ( '' !== original_direction ) { 4189 original_direction = original_direction.toLowerCase(); 4190 } 4191 4192 break; 4193 } 4194 4195 if ( original_animation !== false && original_direction !== false ) { 4196 intensity_css = et_process_animation_intensity( original_animation, original_direction, intensity_percentage ); 4197 } 4198 4199 if ( ! $.isEmptyObject( intensity_css ) ) { 4200 $element.css( intensity_css ); 4201 } 4202 4203 $element.addClass( 'et_animated' ); 4204 $element.addClass( animation_style ); 4205 $element.addClass( animation_repeat ); 4206 4207 // Remove the animation after it completes if it is not an infinite one 4208 if ( ! animation_repeat ) { 4209 var animation_duration_ms = parseInt( animation_duration ); 4210 var animation_delay_ms = parseInt( animation_delay ); 4211 4212 setTimeout( function() { 4213 et_remove_animation( $element ); 4214 }, animation_duration_ms + animation_delay_ms ); 4215 } 4216 } 4217 4218 function et_process_animation_data( waypoints_enabled ) { 4219 if ( 'undefined' !== typeof et_animation_data && et_animation_data.length > 0 ) { 4220 $('body').css('overflow-x', 'hidden'); 4221 $('#page-container').css('overflow-y', 'hidden'); 4222 4223 for ( var i = 0; i < et_animation_data.length; i++ ) { 4224 var animation_entry = et_animation_data[i]; 4225 4226 if ( 4227 ! animation_entry.class || 4228 ! animation_entry.style || 4229 ! animation_entry.repeat || 4230 ! animation_entry.duration || 4231 ! animation_entry.delay || 4232 ! animation_entry.intensity || 4233 ! animation_entry.starting_opacity || 4234 ! animation_entry.speed_curve 4235 ) { 4236 continue; 4237 } 4238 4239 var $animated = $('.' + animation_entry.class); 4240 4241 // Get current active device. 4242 var current_mode = et_pb_get_current_window_mode(); 4243 var is_desktop_view = current_mode === 'desktop'; 4244 4245 // Update animation breakpoint variable. 4246 et_animation_breakpoint = current_mode; 4247 4248 // Generate suffix. 4249 var suffix = ''; 4250 if ( ! is_desktop_view ) { 4251 suffix += '_' + current_mode; 4252 } 4253 4254 // Being save and prepare the value. 4255 var data_style = ! is_desktop_view && typeof animation_entry['style' + suffix] !== 'undefined' ? animation_entry['style' + suffix] : animation_entry.style; 4256 var data_repeat = ! is_desktop_view && typeof animation_entry['repeat' + suffix] !== 'undefined' ? animation_entry['repeat' + suffix] : animation_entry.repeat; 4257 var data_duration = ! is_desktop_view && typeof animation_entry['duration' + suffix] !== 'undefined' ? animation_entry['duration' + suffix] : animation_entry.duration; 4258 var data_delay = ! is_desktop_view && typeof animation_entry['delay' + suffix] !== 'undefined' ? animation_entry['delay' + suffix] : animation_entry.delay; 4259 var data_intensity = ! is_desktop_view && typeof animation_entry['intensity' + suffix] !== 'undefined' ? animation_entry['intensity' + suffix] : animation_entry.intensity; 4260 var data_starting_opacity = ! is_desktop_view && typeof animation_entry['starting_opacity' + suffix] !== 'undefined' ? animation_entry['starting_opacity' + suffix] : animation_entry.starting_opacity; 4261 var data_speed_curve = ! is_desktop_view && typeof animation_entry['speed_curve' + suffix] !== 'undefined' ? animation_entry['speed_curve' + suffix] : animation_entry.speed_curve; 4262 4263 $animated.attr({ 4264 'data-animation-style' : data_style, 4265 'data-animation-repeat' : 'once' === data_repeat ? '' : 'infinite', 4266 'data-animation-duration' : data_duration, 4267 'data-animation-delay' : data_delay, 4268 'data-animation-intensity' : data_intensity, 4269 'data-animation-starting-opacity': data_starting_opacity, 4270 'data-animation-speed-curve' : data_speed_curve 4271 }); 4272 4273 // Process the waypoints logic if the waypoints are not ignored 4274 // Otherwise add the animation to the element right away 4275 if ( true === waypoints_enabled ) { 4276 if ( $animated.hasClass('et_pb_circle_counter') ) { 4277 et_waypoint( $animated, { 4278 offset: '100%', 4279 handler: function() { 4280 var $this_counter = $(this.element).find('.et_pb_circle_counter_inner'); 4281 4282 if ( $this_counter.data( 'PieChartHasLoaded' ) || typeof $this_counter.data('easyPieChart')
4282=== 'undefined' ) { 4283 return; 4284 } 4285 4286 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4287 4288 $this_counter.data( 'PieChartHasLoaded', true ); 4289 4290 et_animate_element( $(this.element) ); 4291 } 4292 }); 4293 4294 // fallback to 'bottom-in-view' offset, to make sure animation applied when element is on the bottom of page and other offsets are not triggered 4295 et_waypoint( $animated, { 4296 offset: 'bottom-in-view', 4297 handler: function() { 4298 var $this_counter = $(this.element).find('.et_pb_circle_counter_inner'); 4299 4300 if ( $this_counter.data( 'PieChartHasLoaded' ) || typeof $this_counter.data('easyPieChart') === 'undefined' ) { 4301 return; 4302 } 4303 4304 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4305 4306 $this_counter.data( 'PieChartHasLoaded', true ); 4307 4308 et_animate_element( $(this.element) ); 4309 } 4310 }); 4311 } else if ( $animated.hasClass('et_pb_number_counter') ) { 4312 et_waypoint( $animated, { 4313 offset: '100%', 4314 handler: function() { 4315 $(this.element).data('easyPieChart').update( $(this.element).data('number-value') ); 4316 et_animate_element( $(this.element) ); 4317 } 4318 }); 4319 4320 // fallback to 'bottom-in-view' offset, to make sure animation applied when element is on the bottom of page and other offsets are not triggered 4321 et_waypoint( $animated, { 4322 offset: 'bottom-in-view', 4323 handler: function() { 4324 $(this.element).data('easyPieChart').update( $(this.element).data('number-value') ); 4325 et_animate_element( $(this.element) ); 4326 } 4327 }); 4328 } else { 4329 et_waypoint( $animated, { 4330 offset: '100%', 4331 handler: function() { 4332 et_animate_element( $(this.element) ); 4333 } 4334 } ); 4335 } 4336 } else { 4337 et_animate_element( $animated ); 4338 } 4339 } 4340 } 4341 } 4342 4343 function et_process_animation_intensity( animation, direction, intensity ) { 4344 var intensity_css = {}; 4345 4346 switch( animation ) { 4347 case 'slide': 4348 switch( direction ) { 4349 case 'top': 4350 var percentage = intensity * -2; 4351 4352 intensity_css = { 4353 transform: 'translate3d(0, ' + percentage + '%, 0)' 4354 }; 4355 4356 break; 4357 4358 case 'right': 4359 var percentage = intensity * 2; 4360 4361 intensity_css = { 4362 transform: 'translate3d(' + percentage + '%, 0, 0)' 4363 }; 4364 4365 break; 4366 4367 case 'bottom': 4368 var percentage = intensity * 2; 4369 4370 intensity_css = { 4371 transform: 'translate3d(0, ' + percentage + '%, 0)' 4372 }; 4373 4374 break; 4375 4376 case 'left': 4377 var percentage = intensity * -2; 4378 4379 intensity_css = { 4380 transform: 'translate3d(' + percentage + '%, 0, 0)' 4381 }; 4382 4383 break; 4384 4385 default: 4386 var scale = ( 100 - intensity ) * 0.01; 4387 4388 intensity_css = { 4389 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4390 }; 4391 break; 4392 } 4393 break; 4394 4395 case 'zoom': 4396 var scale = ( 100 - intensity ) * 0.01; 4397 4398 switch( direction ) { 4399 case 'top': 4400 intensity_css = { 4401 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4402 }; 4403 4404 break; 4405 4406 case 'right': 4407 intensity_css = { 4408 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4409 }; 4410 4411 break; 4412 4413 case 'bottom': 4414 intensity_css = { 4415 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4416 }; 4417 4418 break; 4419 4420 case 'left': 4421 intensity_css = { 4422 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4423 }; 4424 4425 break; 4426 4427 default: 4428 intensity_css = { 4429 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4430 }; 4431 break; 4432 } 4433 4434 break; 4435 4436 case 'flip': 4437 switch ( direction ) { 4438 case 'right': 4439 var degree = Math.ceil( ( 90 / 100 ) * intensity ); 4440 4441 intensity_css = { 4442 transform: 'perspective(2000px) rotateY(' + degree+ 'deg)' 4443 }; 4444 break; 4445 4446 case 'left':
4447 var degree = Math.ceil( ( 90 / 100 ) * intensity ) * -1; 4448 4449 intensity_css = { 4450 transform: 'perspective(2000px) rotateY(' + degree+ 'deg)' 4451 }; 4452 break; 4453 4454 case 'top': 4455 default: 4456 var degree = Math.ceil( ( 90 / 100 ) * intensity ); 4457 4458 intensity_css = { 4459 transform: 'perspective(2000px) rotateX(' + degree+ 'deg)' 4460 }; 4461 break; 4462 4463 case 'bottom': 4464 var degree = Math.ceil( ( 90 / 100 ) * intensity ) * -1; 4465 4466 intensity_css = { 4467 transform: 'perspective(2000px) rotateX(' + degree+ 'deg)' 4468 }; 4469 break; 4470 } 4471 4472 break; 4473 4474 case 'fold': 4475 switch( direction ) { 4476 case 'top': 4477 var degree = Math.ceil( ( 90 / 100 ) * intensity ) * -1; 4478 4479 intensity_css = { 4480 transform: 'perspective(2000px) rotateX(' + degree + 'deg)' 4481 }; 4482 4483 break; 4484 case 'bottom': 4485 var degree = Math.ceil( ( 90 / 100 ) * intensity ); 4486 4487 intensity_css = { 4488 transform: 'perspective(2000px) rotateX(' + degree + 'deg)' 4489 }; 4490 4491 break; 4492 4493 case 'left': 4494 var degree = Math.ceil( ( 90 / 100 ) * intensity ); 4495 4496 intensity_css = { 4497 transform: 'perspective(2000px) rotateY(' + degree + 'deg)' 4498 }; 4499 4500 break; 4501 case 'right': 4502 default: 4503 var degree = Math.ceil( ( 90 / 100 ) * intensity ) * -1; 4504 4505 intensity_css = { 4506 transform: 'perspective(2000px) rotateY(' + degree + 'deg)' 4507 }; 4508 4509 break; 4510 } 4511 4512 break; 4513 4514 case 'roll': 4515 switch( direction ) { 4516 case 'right': 4517 case 'bottom': 4518 var degree = Math.ceil( ( 360 / 100 ) * intensity ) * -1; 4519 4520 intensity_css = { 4521 transform: 'rotateZ(' + degree + 'deg)' 4522 }; 4523 4524 break; 4525 case 'top': 4526 case 'left': 4527 var degree = Math.ceil( ( 360 / 100 ) * intensity ); 4528 4529 intensity_css = { 4530 transform: 'rotateZ(' + degree + 'deg)' 4531 }; 4532 4533 break; 4534 default: 4535 var degree = Math.ceil( ( 360 / 100 ) * intensity ); 4536 4537 intensity_css = { 4538 transform: 'rotateZ(' + degree + 'deg)' 4539 }; 4540 4541 break; 4542 } 4543 4544 break; 4545 } 4546 4547 return intensity_css; 4548 } 4549 4550 function et_has_animation_data( $element ) { 4551 var has_animation = false; 4552 4553 if ( 'undefined' !== typeof et_animation_data && et_animation_data.length > 0 ) { 4554 for ( var i = 0; i < et_animation_data.length; i++ ) { 4555 var animation_entry = et_animation_data[i]; 4556 4557 if ( ! animation_entry.class ) { 4558 continue; 4559 } 4560 4561 if ( $element.hasClass( animation_entry.class ) ) { 4562 has_animation = true; 4563 break; 4564 } 4565 } 4566 } 4567 4568 return has_animation; 4569 } 4570 4571 function et_get_animation_classes() { 4572 return [ 4573 'et_animated', 'infinite', 'et-waypoint', 4574 'fade', 'fadeTop', 'fadeRight', 'fadeBottom', 'fadeLeft', 4575 'slide', 'slideTop', 'slideRight', 'slideBottom', 'slideLeft', 4576 'bounce', 'bounceTop', 'bounceRight', 'bounceBottom', 'bounceLeft', 4577 'zoom', 'zoomTop', 'zoomRight', 'zoomBottom', 'zoomLeft', 4578 'flip', 'flipTop', 'flipRight', 'flipBottom', 'flipLeft', 4579 'fold', 'foldTop', 'foldRight', 'foldBottom', 'foldLeft', 4580 'roll', 'rollTop', 'rollRight', 'rollBottom', 'rollLeft', 'transformAnim', 4581 ]; 4582 } 4583 4584 function et_remove_animation( $element ) { 4585 var animation_classes = et_get_animation_classes(); 4586 4587 // Remove attributes which avoid horizontal scroll to appear when section is rolled 4588 if ($element.is('.et_pb_section') && $element.is('.roll')) { 4589 $('#et-boc').css('overflow-x', ''); 4590 } 4591 4592 $element.removeClass( animation_classes.join(' ') ); 4593 $element.css({ 4594 'animation-delay' : '', 4595 'animation-duration' : '', 4596 'animation-timing-function' : '', 4597 'opacity' : '', 4598 'transform' : '' 4599 }); 4600 4601 // Prevent animation module with no explicit position property to be incorrectly positioned 4602 // after animation is clomplete and animation classname is removed because animation classname has 4603 // animation-name property which gives pseudo correct z-index. This class also works as a marker to prevent animating already animated objects. 4604 $element.addClass('et_had_animation'); 4605 } 4606 4607 function et_remove_animation_data( $element ) { 4608 var attr_name; 4609 var data_attrs_to_remove = []; 4610 var data_attrs = $element.get(0).attributes; 4611 4612 for ( var i = 0; i < data_attrs.length; i++ ) { 4613 if ( 'data-animation-' === data_attrs[i].name.substring( 0, 15 ) ) { 4614 data_attrs_to_remove.push( data_attrs[i].name ); 4615 } 4616 } 4617 4618 $.each( data_attrs_to_remove, function( index, attr_name ) { 4619 $element.removeAttr( attr_name ); 4620 } ); 4621 } 4622 4623 window.et_reinit_waypoint_modules = et_pb_debounce( function() { 4624 var $et_pb_circle_counter = $( '.et_pb_circle_counter' ), 4625 $et_pb_number_counter = $( '.et_pb_number_counter' ), 4626 $et_pb_video_background = $( '.et_pb_section_video_bg video' ); 4627
4628 // if waypoint is available and we are not ignoring them. 4629 if ( $.fn.waypoint && 'yes' !== et_pb_custom.ignore_waypoints && !is_frontend_builder ) { 4630 et_process_animation_data( true ); 4631 4632 // get all of our waypoint things. 4633 var modules = $( '.et-waypoint' ); 4634 modules.each(function(){ 4635 et_waypoint( $(this), { 4636 offset: et_get_offset( $(this), '100%' ), 4637 handler: function() { 4638 // what actually triggers the animation. 4639 $(this.element).addClass( 'et-animated' ); 4640 } 4641 }, 2 ); 4642 }); 4643 4644 // Set waypoint for circle counter module. 4645 if ( $et_pb_circle_counter.length ) { 4646 // iterate over each. 4647 $et_pb_circle_counter.each(function(){ 4648 var $this_counter = $(this).find('.et_pb_circle_counter_inner'); 4649 if ( ! $this_counter.is( ':visible' ) || et_has_animation_data( $this_counter ) ) { 4650 return; 4651 } 4652 4653 et_waypoint( $this_counter, { 4654 offset: et_get_offset( $(this), '100%'), 4655 handler: function() { 4656 if ( $this_counter.data( 'PieChartHasLoaded' ) || typeof $this_counter.data('easyPieChart') === 'undefined' ) { 4657 return; 4658 } 4659 4660 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4661 4662 $this_counter.data( 'PieChartHasLoaded', true ); 4663 } 4664 }, 2 ); 4665 }); 4666 } 4667 4668 // Set waypoint for number counter module. 4669 if ( $et_pb_number_counter.length ) { 4670 $et_pb_number_counter.each(function(){ 4671 var $this_counter = $(this); 4672 4673 if ( et_has_animation_data( $this_counter ) ) { 4674 return; 4675 } 4676 4677 et_waypoint( $this_counter, { 4678 offset: et_get_offset( $(this), '100%' ), 4679 handler: function() { 4680 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4681 } 4682 }); 4683 }); 4684 } 4685 4686 // Set waypoint for goal module. 4687 if ($('.et_pb_ab_goal').length && ! is_frontend_builder) { 4688 var $et_pb_ab_goal = $( '.et_pb_ab_goal' ); 4689 4690 et_waypoint( $et_pb_ab_goal, { 4691 offset: et_get_offset( $(this), '80%'), 4692 handler: function() { 4693 if ( et_pb_ab_logged_status['read_goal'] || ! $et_pb_ab_goal.length || ! $et_pb_ab_goal.visible( true ) ) { 4694 return; 4695 } 4696 4697 // log the goal_read if goal is still visible after 3 seconds. 4698 setTimeout( function() { 4699 if ( $et_pb_ab_goal.length && $et_pb_ab_goal.visible( true ) && ! et_pb_ab_logged_status['read_goal'] ) { 4700 et_pb_ab_update_stats( 'read_goal' ); 4701 } 4702 }, 3000 ); 4703 4704 et_pb_maybe_log_event( $et_pb_ab_goal, 'view_goal' ); 4705 } 4706 }); 4707 } 4708 } else { 4709 // if no waypoints supported then apply all the animations right away 4710 et_process_animation_data( false ); 4711 4712 var animated_class = is_frontend_builder ? 'et-animated--vb' : 'et-animated'; 4713 4714 $('.et-waypoint').addClass(animated_class); 4715 4716 if ( $et_pb_circle_counter.length ) { 4717 $et_pb_circle_counter.each(function() { 4718 var $this_counter = $(this).find('.et_pb_circle_counter_inner'); 4719 4720 if ( ! $this_counter.is( ':visible' ) ) { 4721 return; 4722 } 4723 4724 if ($this_counter.data('PieChartHasLoaded') || typeof $this_counter.data('easyPieChart') === 'undefined') { 4725 return; 4726 } 4727 4728 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4729 4730 $this_counter.data( 'PieChartHasLoaded', true ); 4731 } ); 4732 } 4733 4734 if ( $et_pb_number_counter.length ) { 4735 $et_pb_number_counter.each(function(){ 4736 var $this_counter = $(this); 4737 4738 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4739 }); 4740 } 4741 4742 // log the stats without waypoints 4743 if ( $( '.et_pb_ab_goal' ).length ) { 4744 var $et_pb_ab_goal = $( '.et_pb_ab_goal' ); 4745 4746 if ( et_pb_ab_logged_status['read_goal'] || ! $et_pb_ab_goal.length || ! $et_pb_ab_goal.visible( true ) ) { 4747 return; 4748 } 4749 4750 // log the goal_read if goal is still visible after 3 seconds. 4751 setTimeout( function() { 4752 if ( $et_pb_ab_goal.length && $et_pb_ab_goal.visible( true ) && ! et_pb_ab_logged_status['read_goal'] ) { 4753 et_pb_ab_update_stats( 'read_goal' ); 4754 } 4755 }, 3000 ); 4756 4757 et_pb_maybe_log_event( $et_pb_ab_goal, 'view_goal' ); 4758 } 4759 } // End checking of waypoints. 4760 4761 if ( $et_pb_video_background.length ) { 4762 $et_pb_video_background.each( function(){ 4763 var $this_video_background = $(this); 4764 4765 et_pb_video_background_init( $this_video_background, this ); 4766 }); 4767 } // End of et_pb_debounce(). 4768 }, 100 ); 4769 4770 4771 function et_process_link_options_data() { 4772 if ('undefined' !== typeof et_link_options_data && et_link_options_data.length > 0) { 4773 4774 // $.each needs to be used so that the proper values are bound 4775 // when there are multiple elements with link options enabled 4776 $.each(et_link_options_data, function(index, link_option_entry) { 4777 if ( 4778 ! link_option_entry.class || 4779 ! link_option_entry.url || 4780 ! link_option_entry.target 4781 ) { 4782 return; 4783 } 4784 4785 var $clickable = $('.' + link_option_entry.class); 4786 4787 $clickable.on('click', function(event) { 4788 // If the event target is different from current target a check for elements that should not trigger module link is performed 4789 if ( ( event.target !== event.currentTarget && ! et_is_click_exception($(event.target)) ) || event.target === event.currentTarget ) { 4790 event.stopPropagation(); 4791 4792 if ('_blank' === link_option_entry.target) { 4793 window.open( link_option_entry.url ); 4794 4795 return; 4796 } 4797 4798 var url = link_option_entry.url; 4799 4800 if (url && '#' === url[0] && $(url).length) { 4801 et_pb_smooth_scroll($(url), undefined, 800); 4802 history.pushState(null, "", url); 4803 } else { 4804 window.location = url; 4805 } 4806 } 4807 }); 4808 4809 // Prevent any links inside the element from triggering its (parent) link 4810 $clickable.on('click', 'a, button', function(event) { 4811 if (! et_is_click_exception( $(this))) { 4812 event.stopPropagation(); 4813 } 4814 }); 4815 }); 4816 } 4817 } 4818 4819 // There are some classes that have other click handlers attached to them 4820 // Link options should not be triggered by/or prevent them from working 4821 function et_is_click_exception($element) { 4822 var is_exception = false;
4823 4824 // List of elements that already have click handlers 4825 var click_exceptions = [ 4826 // Accordion/Toggle 4827 '.et_pb_toggle_title', 4828 4829 // Audio Module 4830 '.mejs-container *', 4831 4832 // Contact Form Fields 4833 '.et_pb_contact_field input', 4834 '.et_pb_contact_field textarea', 4835 '.et_pb_contact_field_checkbox *', 4836 '.et_pb_contact_field_radio *', 4837 '.et_pb_contact_captcha', 4838 4839 // Tabs 4840 '.et_pb_tabs_controls a', 4841 4842 // Woo Image 4843 '.flex-control-nav *' 4844 ]; 4845 4846 for (var i = 0; i < click_exceptions.length; i++) { 4847 if ($element.is(click_exceptions[i])) { 4848 is_exception = true; 4849 break; 4850 } 4851 } 4852 4853 return is_exception; 4854 } 4855 4856 et_process_link_options_data(); 4857 4858 function et_pb_init_ab_test() { 4859 // Disable AB Testing tracking on VB 4860 // AB Testing should not record anything on AB Testing 4861 if (is_frontend_builder) { 4862 return; 4863 } 4864 4865 var $et_pb_ab_goal = $('.et_pb_ab_goal'); 4866 var et_ab_subject_id = et_pb_get_subject_id(); 4867 4868 $.each( et_pb_ab_logged_status, function( key, value ) { 4869 var cookie_subject = 'click_goal' === key || 'con_short' === key ? '' : et_ab_subject_id; 4870 4871 et_pb_ab_logged_status[key] = et_pb_check_cookie_value( 'et_pb_ab_' + key + '_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + cookie_subject, 'true' ); 4872 4873 }); 4874 4875 // log the page read event if user stays on page long enough and if not logged for current subject 4876 if ( ! et_pb_ab_logged_status['read_page'] ) { 4877 setTimeout( function() { 4878 et_pb_ab_update_stats( 'read_page' ); 4879 }, et_pb_ab_bounce_rate ); 4880 } 4881 4882 // add the cookies for shortcode tracking, if enabled 4883 if ( 'on' === et_pb_custom.is_shortcode_tracking && ! et_pb_ab_logged_status['con_short'] ) { 4884 et_pb_set_cookie( 365, 'et_pb_ab_shortcode_track_' + et_pb_custom.page_id + '=' + et_pb_custom.page_id + '_' + et_pb_get_subject_id() + '_' + et_pb_custom.unique_test_id ); 4885 } 4886 4887 if ( $et_pb_ab_goal.length ) { 4888 // if goal is a module and has a button then track the conversions, otherwise track clicks 4889 if ( $et_pb_ab_goal.hasClass( 'et_pb_module' ) && ( $et_pb_ab_goal.hasClass( 'et_pb_button' ) || $et_pb_ab_goal.find( '.et_pb_button' ).length ) ) { 4890 // Log con_goal if current goal doesn't require any specific conversion calculation 4891 if ( ! $et_pb_ab_goal.hasClass( 'et_pb_contact_form_container' ) && ! $et_pb_ab_goal.hasClass( 'et_pb_newsletter' ) ) { 4892 var $goal_button = $et_pb_ab_goal.hasClass( 'et_pb_button' ) ? $et_pb_ab_goal : $et_pb_ab_goal.find( '.et_pb_button' ); 4893 4894 if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) ) { 4895 var page_url = window.location.href, 4896 comment_submitted = -1 !== page_url.indexOf( '#comment-' ) ? true : false, 4897 log_conversion = et_pb_check_cookie_value( 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id, 'true' ); 4898 4899 if ( comment_submitted && log_conversion ) { 4900 et_pb_ab_update_stats( 'con_goal' ); 4901 et_pb_set_cookie( 0, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' ); 4902 } 4903 } 4904 4905 $goal_button.click( function(){ 4906 if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) && ! et_pb_ab_logged_status['con_goal'] ) { 4907 et_pb_set_cookie( 365, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' ); 4908 return; 4909 } 4910 4911 et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' ); 4912 }); 4913 } 4914 } else { 4915 $et_pb_ab_goal.click( function() { 4916 if ( $et_pb_ab_goal.hasClass( 'et_pb_shop' ) && ! et_pb_ab_logged_status['con_goal'] ) { 4917 et_pb_set_cookie( 365, 'et_pb_ab_shop_log=' + et_pb_custom.page_id + '_' + et_pb_get_subject_id() + '_' + et_pb_custom.unique_test_id ); 4918 } 4919 4920 et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' ); 4921 }); 4922 } 4923 } 4924 } 4925 4926 function et_pb_maybe_log_event( $goal_container, event, callback ) { 4927 // Disable AB Testing tracking on VB 4928 // AB Testing should not record anything on AB Testing 4929 if (is_frontend_builder) { 4930 return; 4931 } 4932 4933 var log_event = typeof event === 'undefined' ? 'con_goal' : event; 4934 4935 if ( ! $goal_container.hasClass( 'et_pb_ab_goal' ) || et_pb_ab_logged_status[ log_event ] ) { 4936 if ( 'undefined' !== typeof callback ) { 4937 callback(); 4938 } 4939 4940 return; 4941 } 4942 4943 // log the event if it's not logged for current user 4944 et_pb_ab_update_stats( log_event, callback ); 4945 } 4946 4947 function et_pb_ab_update_stats( record_type, set_page_id, set_subject_id, set_test_id, callback ) { 4948 var subject_id = typeof set_subject_id === 'undefined' ? et_pb_get_subject_id() : set_subject_id, 4949 page_id = typeof set_page_id === 'undefined' ? et_pb_custom.page_id : set_page_id, 4950 test_id = typeof set_test_id === 'undefined' ? et_pb_custom.unique_test_id : set_test_id, 4951 stats_data = JSON.stringify({ 'test_id' : page_id, 'subject_id' : subject_id, 'record_type' : record_type }),
4952 cookie_subject = 'click_goal' === record_type || 'con_short' === record_type ? '' : subject_id; 4953 4954 et_pb_set_cookie( 365, 'et_pb_ab_' + record_type + '_' + page_id + test_id + cookie_subject + '=true' ); 4955 4956 et_pb_ab_logged_status[record_type] = true; 4957 4958 $.ajax({ 4959 type: 'POST', 4960 url: et_pb_custom.ajaxurl, 4961 data: { 4962 action : 'et_pb_update_stats_table', 4963 stats_data_array : stats_data, 4964 et_ab_log_nonce : et_pb_custom.et_ab_log_nonce 4965 } 4966 }).always( function() { 4967 if ( 'undefined' !== typeof callback ) { 4968 callback(); 4969 } 4970 } ); 4971 } 4972 4973 function et_pb_get_subject_id() { 4974 var $subject = $( '.et_pb_ab_subject' ); 4975 4976 // In case no subject found 4977 if ( $subject.length <= 0 || $('html').is('.et_fb_preview_active--wireframe_preview') ) { 4978 return false; 4979 } 4980 4981 var subject_classname = $subject.attr( 'class' ), 4982 subject_id_raw = subject_classname.split( 'et_pb_ab_subject_id-' )[1], 4983 subject_id_clean = subject_id_raw.split( ' ' )[0], 4984 subject_id_separated = subject_id_clean.split( '_' ), 4985 subject_id = subject_id_separated[1]; 4986 4987 return subject_id; 4988 } 4989 4990 /** 4991 * Get current active device based on window width size. 4992 * 4993 * @return {String} View mode. 4994 */ 4995 function et_pb_get_current_window_mode() { 4996 var window_width = $et_window.width(); 4997 var current_mode = 'desktop'; 4998 if ( window_width <= 980 && window_width > 479 ) { 4999 current_mode = 'tablet'; 5000 } else if ( window_width <= 479 ) { 5001 current_mode = 'phone'; 5002 } 5003 5004 return current_mode; 5005 } 5006 5007 function et_pb_set_cookie_expire( days ) { 5008 var ms = days*24*60*60*1000; 5009 5010 var date = new Date(); 5011 date.setTime( date.getTime() + ms ); 5012 5013 return "; expires=" + date.toUTCString(); 5014 } 5015 5016 function et_pb_check_cookie_value( cookie_name, value ) { 5017 return et_pb_get_cookie_value( cookie_name ) == value; 5018 } 5019 5020 function et_pb_get_cookie_value( cookie_name ) { 5021 return et_pb_parse_cookies()[cookie_name]; 5022 } 5023 5024 function et_pb_parse_cookies() { 5025 var cookies = document.cookie.split( '; ' ); 5026 5027 var ret = {}; 5028 for ( var i = cookies.length - 1; i >= 0; i-- ) { 5029 var el = cookies[i].split( '=' ); 5030 ret[el[0]] = el[1]; 5031 } 5032 return ret; 5033 } 5034 5035 function et_pb_set_cookie( expire, cookie_content ) { 5036 cookie_expire = et_pb_set_cookie_expire( expire ); 5037 document.cookie = cookie_content + cookie_expire + "; path=/"; 5038 } 5039 5040 function et_pb_get_fixed_main_header_height() { 5041 if ( ! window.et_is_fixed_nav ) { 5042 return 0; 5043 } 5044 5045 var fixed_height_onload = typeof $('#main-header').attr('data-fixed-height-onload') === 'undefined' ? 0 : $('#main-header').attr('data-fixed-height-onload'); 5046 5047 return ! window.et_is_fixed_nav ? 0 : parseFloat( fixed_height_onload ); 5048 } 5049 5050 var fullscreen_section_width = {}; 5051 var fullscreen_section_timeout = {}; 5052 5053 window.et_calc_fullscreen_section = function(event, section) { 5054 var isResizing = typeof event === 'object' && event.type === 'resize', 5055 topWindow = isBuilder ? window.top : window, 5056 $et_window = $(topWindow), 5057 $appWindow = $(window), 5058 $this_section = section || $(this), 5059 section_index = $this_section.index('.et_pb_fullscreen'), 5060 timeout = isResizing && typeof fullscreen_section_width[section_index] !== 'undefined' && event.target.window_width > fullscreen_section_width[section_index] ? 800 : 0; 5061 5062 fullscreen_section_width[section_index] = $et_window.width(); 5063 5064 if ( typeof fullscreen_section_timeout[section_index] !== 'undefined' ) { 5065 clearTimeout( fullscreen_section_timeout[section_index] ); 5066 } 5067 5068 fullscreen_section_timeout[section_index] = setTimeout( function() { 5069 var $body = $( 'body' ), 5070 has_section = $this_section.length, 5071 this_section_index = $this_section.index('.et_pb_fullwidth_header'), 5072 this_section_offset = has_section ? $this_section.offset() : {}, 5073 $header = $this_section.children('.et_pb_fullwidth_header_container'), 5074 $header_content = $header.children('.header-content-container'), 5075 $header_image = $header.children('.header-image-container'), 5076 sectionHeight = topWindow.innerHeight || $et_window.height(), 5077 $wpadminbar = topWindow.jQuery('#wpadminbar'), 5078 has_wpadminbar = $wpadminbar.length, 5079 wpadminbar_height = has_wpadminbar ? $wpadminbar.height() : 0, 5080 $top_header = $('#top-header'), 5081 has_top_header = $top_header.length, 5082 top_header_height = has_top_header ? $top_header.height() : 0, 5083 $main_header = $('#main-header'), 5084 has_main_header = $main_header.length, 5085 main_header_height = has_main_header ? $main_header.outerHeight() : 0, 5086 fixed_main_header_height = et_pb_get_fixed_main_header_height(), 5087 is_mobile_first_module = 'undefined' !== typeof this_section_offset.top ? this_section_offset.top <= (main_header_height + wpadminbar_height) : false, 5088 is_wp_relative_admin_bar = $et_window.width() < 782, 5089 is_desktop_view = $et_window.width() > 980, 5090 is_tablet_view = $et_window.width() <= 980 && $et_window.width() >= 479, 5091 is_phone_view = $et_window.width() < 479, 5092 overall_header_height = window.et_is_vertical_nav && is_desktop_view ? wpadminbar_height + top_header_height : wpadminbar_height + top_header_height + main_header_height, 5093 is_first_module = 'undefined' !== typeof this_section_offset.top ? this_section_offset.top <= overall_header_height : false;
5094 5095 // In case theme stored the onload main-header height as data-attribute 5096 if ( $main_header.attr('data-height-onload') ) { 5097 main_header_height = parseFloat( $main_header.attr('data-height-onload') ); 5098 } 5099 5100 /** 5101 * WP Admin Bar: 5102 * 5103 * - Desktop fixed: standard 5104 * - WP Mobile relative: less than 782px window 5105 **/ 5106 if ( has_wpadminbar ) { 5107 if ( is_wp_relative_admin_bar ) { 5108 if ( is_first_module ) { 5109 sectionHeight -= wpadminbar_height; 5110 } 5111 } else { 5112 sectionHeight -= wpadminbar_height; 5113 } 5114 } 5115 5116 /** 5117 * Divi Top Header: 5118 * 5119 * - Desktop fixed: standard. 5120 * - Desktop fixed BUT first header's height shouldn't be substracted: hide nav until 5121 * scroll activated 5122 * - Desktop relative: fixed nav bar disabled 5123 * - Desktop relative: vertical nav activated 5124 */ 5125 if ( has_top_header ) { 5126 if ( is_desktop_view ) { 5127 if ( et_hide_nav && ! window.et_is_vertical_nav ) { 5128 if ( ! is_first_module ) { 5129 sectionHeight -= top_header_height; 5130 } 5131 } else if ( ! window.et_is_fixed_nav || window.et_is_vertical_nav ) { 5132 if ( is_first_module ) { 5133 sectionHeight -= top_header_height; 5134 } 5135 } else { 5136 sectionHeight -= top_header_height; 5137 } 5138 } 5139 } 5140 5141 /** 5142 * Divi Main Header: 5143 * 5144 * - Desktop fixed: standard. Initial and 'fixed' header might have different height 5145 * - Desktop relative: fixed nav bar disabled 5146 * - Desktop fixed BUT height should be ignored: vertical nav activated 5147 * - Desktop fixed BUT height should be ignored for first header only: main header uses 5148 * rgba 5149 * - Desktop fixed BUT first header's height shouldn't be substracted: hide nav until 5150 * scroll activated 5151 * - Tablet relative: standard. Including vertical header style 5152 * - Phone relative: standard. Including vertical header style 5153 */ 5154 if ( has_main_header ) { 5155 if ( is_desktop_view ) { 5156 if ( et_hide_nav && ! window.et_is_vertical_nav ) { 5157 if ( ! is_first_module ) { 5158 sectionHeight -= fixed_main_header_height; 5159 } 5160 } else if ( window.et_is_fixed_nav && ! window.et_is_vertical_nav ) { 5161 if ( is_first_module ) { 5162 sectionHeight -= main_header_height; 5163 } else { 5164 sectionHeight -= fixed_main_header_height; 5165 } 5166 } else if ( ! window.et_is_fixed_nav && ! window.et_is_vertical_nav ) { 5167 if ( is_first_module ) { 5168 sectionHeight -= main_header_height; 5169 } 5170 } 5171 } else { 5172 if ( is_first_module ) { 5173 sectionHeight -= main_header_height; 5174 } 5175 } 5176 } 5177 5178 // If the transparent primary nav + hide nav until scroll is being used, 5179 // cancel automatic padding-top added by transparent nav mechanism 5180 if ( $body.hasClass('et_transparent_nav') && $body.hasClass( 'et_hide_nav' ) && 0 === this_section_index ) { 5181 $this_section.css( 'padding-top', '' ); 5182 } 5183 5184 // reduce section height by its top border width 5185 var section_border_top_width = parseInt( $this_section.css( 'borderTopWidth' ) ); 5186 if ( section_border_top_width ) { 5187 sectionHeight -= section_border_top_width; 5188 } 5189 5190 // reduce section height by its bottom border width 5191 var section_border_bottom_width = parseInt( $this_section.css( 'borderBottomWidth' ) ); 5192 if ( section_border_bottom_width ) { 5193 sectionHeight -= section_border_bottom_width; 5194 } 5195 5196 $this_section.css('min-height', sectionHeight + 'px' ); 5197 $header.css('min-height', sectionHeight + 'px' ); 5198 5199 if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('bottom') ) { 5200 $header.addClass('bottom-bottom'); 5201 } 5202 5203 if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('center') ) { 5204 $header.addClass('center-center'); 5205 } 5206 5207 if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('bottom') ) { 5208 $header.addClass('center-bottom'); 5209 5210 var contentHeight = sectionHeight - $header_image.outerHeight( true ); 5211 5212 if ( contentHeight > 0 ) { 5213 $header_content.css('min-height', contentHeight + 'px' ).css('height', '10px' /*fixes IE11 render*/); 5214 } 5215 } 5216 5217 if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('center') ) { 5218 $header.addClass('bottom-center'); 5219 } 5220 5221 if ( ( $header.hasClass('left') || $header.hasClass('right') ) && !$header_content.length && $header_image.length ) { 5222 $header.css('justify-content', 'flex-end'); 5223 } 5224 5225 if ( $header.hasClass('center') && $header_content.hasClass('bottom') && !$header_image.length ) { 5226 $header_content.find('.header-content').css( 'margin-bottom', 80 + 'px' ); 5227 } 5228 5229 if ( $header_content.hasClass('bottom') && $header_image.hasClass('center') ) { 5230 $header_image.find('.header-image').css( 'margin-bottom', 80 + 'px' ); 5231 $header_image.css('align-self', 'flex-end'); 5232 } 5233 5234 // Detect if section height is lower than the content height 5235 var headerContentHeight = 0; 5236 5237 if ($header_content.length) { 5238 headerContentHeight += $header_content.outerHeight(); 5239 } 5240 if ($header_image.length) { 5241 headerContentHeight += $header_image.outerHeight(); 5242 } 5243 if (headerContentHeight > sectionHeight ) { 5244 $this_section.css('min-height', headerContentHeight + 'px'); 5245 $header.css('min-height', headerContentHeight + 'px'); 5246 } 5247 5248 // Justify the section content 5249 if ( $header_image.hasClass('bottom')) { 5250 if (headerContentHeight < sectionHeight ) { 5251 $this_section.css('min-height', (headerContentHeight + 80) + 'px'); 5252 $header.css('min-height', (headerContentHeight + 80) + 'px'); 5253 } 5254 $header.css('justify-content', 'flex-end'); 5255 } 5256 }, timeout ); 5257 }; 5258 window.et_calculate_fullscreen_section_size = function(){ 5259 $( 'section.et_pb_fullscreen' ).each( function(){ 5260 $.proxy( et_calc_fullscreen_section, $( this ) )(); 5261 }); 5262 5263 if (is_frontend_builder) { 5264 return; 5265 } 5266 5267 clearTimeout(et_calc_fullscreen_section.timeout); 5268 5269 et_calc_fullscreen_section.timeout = setTimeout(function () { 5270 $et_window.off('resize', et_calculate_fullscreen_section_size);
5271 $et_window.off('et-pb-header-height-calculated', et_calculate_fullscreen_section_size); 5272 5273 $et_window.trigger('resize'); 5274 5275 $et_window.on('resize', et_calculate_fullscreen_section_size); 5276 $et_window.on('et-pb-header-height-calculated', et_calculate_fullscreen_section_size); 5277 }); 5278 // 100ms timeout is set to make sure that the fulls screen section size is calculated 5279 // This allows the posibility that in some specific cases this may not be enought 5280 // so we may need to review this. 5281 }; 5282 5283 if (!is_frontend_builder) { 5284 $et_window.on('resize', et_calculate_fullscreen_section_size); 5285 $et_window.on('et-pb-header-height-calculated', et_calculate_fullscreen_section_size); 5286 } 5287 5288 5289 window.debounced_et_apply_builder_css_parallax = et_pb_debounce(et_apply_builder_css_parallax, 100); 5290 5291 window.et_pb_parallax_init = function($this_parallax) { 5292 var $this_parent = $this_parallax.parent(); 5293 var topWindow = isBuilder ? window.top : window; 5294 5295 if ($this_parallax.hasClass('et_pb_parallax_css')) { 5296 // Register faux CSS Parallax effect for builder modes with top window scroll 5297 if ($('body').hasClass('et-fb')) { 5298 $.proxy(et_apply_builder_css_parallax, $this_parent)(); 5299 5300 $(window).on('scroll.etCssParallaxBackground', $.proxy(et_apply_builder_css_parallax, $this_parent)); 5301 $(window).on('resize.etCssParallaxBackground', $.proxy(window.debounced_et_apply_builder_css_parallax, $this_parent)); 5302 } 5303 5304 return; 5305 } 5306 5307 $.proxy(et_parallax_set_height, $this_parent)(); 5308 $.proxy(et_apply_parallax, $this_parent)(); 5309 5310 $(window).on('scroll.etTrueParallaxBackground', $.proxy(et_apply_parallax, $this_parent)); 5311 $(window).on('resize.etTrueParallaxBackground', $.proxy(et_pb_debounce(et_parallax_set_height, 100), $this_parent)); 5312 $(window).on('resize.etTrueParallaxBackground', $.proxy(et_pb_debounce(et_apply_parallax, 100), $this_parent)); 5313 5314 $this_parent.find('.et-learn-more .heading-more').click(function() { 5315 setTimeout(function() { 5316 $.proxy(et_parallax_set_height, $this_parent)(); 5317 }, 300); 5318 }); 5319 }; 5320 5321 $( window ).resize( function(){ 5322 var window_width = $et_window.width(), 5323 et_container_css_width = $et_container.css( 'width' ), 5324 et_container_width_in_pixel = ( typeof et_container_css_width !== 'undefined' ) ? et_container_css_width.substr( -1, 1 ) !== '%' : '', 5325 et_container_actual_width = ( et_container_width_in_pixel ) ? $et_container.width() : ( ( $et_container.width() / 100 ) * window_width ), // $et_container.width() doesn't recognize pixel or percentage unit. It's our duty to understand what it returns and convert it properly 5326 containerWidthChanged = et_container_width !== et_container_actual_width; 5327 5328 et_pb_resize_section_video_bg(); 5329 et_pb_center_video(); 5330 et_fix_slider_height(); 5331 et_fix_nav_direction(); 5332 et_fix_html_margin(); 5333 5334 $et_pb_fullwidth_portfolio.each(function(){ 5335 set_container_height = $(this).hasClass('et_pb_fullwidth_portfolio_carousel') ? true : false; 5336 set_fullwidth_portfolio_columns( $(this), set_container_height ); 5337 }); 5338 5339 if ( containerWidthChanged || window.et_force_width_container_change ) { 5340 $('.container-width-change-notify').trigger('containerWidthChanged'); 5341 5342 setTimeout( function() { 5343 $et_pb_filterable_portfolio.each(function(){ 5344 set_filterable_grid_items( $(this) ); 5345 }); 5346 $et_pb_gallery.each(function(){ 5347 if ( $(this).hasClass( 'et_pb_gallery_grid' ) ) { 5348 set_gallery_grid_items( $(this) ); 5349 } 5350 }); 5351 }, 100 ); 5352 5353 et_container_width = et_container_actual_width; 5354 5355 etRecalculateOffset = true; 5356 5357 var $et_pb_circle_counter = $( '.et_pb_circle_counter' ); 5358 if ( $et_pb_circle_counter.length ) { 5359 $et_pb_circle_counter.each(function(){ 5360 var $this_counter = $(this).find('.et_pb_circle_counter_inner'); 5361 if ( ! $this_counter.is( ':visible' ) || typeof $this_counter.data('easyPieChart') === 'undefined' ) { 5362 return; 5363 } 5364 5365 // Update animation breakpoint variable and generate suffix. 5366 var current_mode = et_pb_get_current_window_mode(); 5367 et_animation_breakpoint = current_mode; 5368 var suffix = current_mode !== 'desktop' ? '-' + current_mode : ''; 5369 5370 // Update bar background color based on active mode.
5371 var bar_color = $this_counter.data( 'bar-bg-color' + suffix ); 5372 if ( typeof bar_color !== 'undefined' && bar_color !== '' ) { 5373 $this_counter.data('easyPieChart').options.barColor = bar_color; 5374 } 5375 5376 // Update track color based on active mode. 5377 var track_color = $this_counter.data( 'color' + suffix ); 5378 if ( typeof track_color !== 'undefined' && track_color !== '' ) { 5379 $this_counter.data('easyPieChart').options.trackColor = track_color; 5380 $this_counter.trigger('containerWidthChanged'); 5381 } 5382 5383 // Update track color alpha based on active mode. 5384 var track_color_alpha = $this_counter.data( 'alpha' + suffix ); 5385 if ( typeof track_color_alpha !== 'undefined' && track_color_alpha !== '' ) { 5386 $this_counter.data('easyPieChart').options.trackAlpha = track_color_alpha; 5387 $this_counter.trigger('containerWidthChanged'); 5388 } 5389 5390 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 5391 }); 5392 } 5393 if ( $et_pb_countdown_timer.length ) { 5394 $et_pb_countdown_timer.each(function(){ 5395 var timer = $(this); 5396 et_countdown_timer_labels( timer ); 5397 } ); 5398 } 5399 5400 // Reset to false 5401 window.et_force_width_container_change = false; 5402 } 5403 5404 window.et_fix_testimonial_inner_width(); 5405 5406 if ( $et_pb_counter_amount.length ) { 5407 $et_pb_counter_amount.each(function(){ 5408 window.et_bar_counters_init( $( this ) ); 5409 }); 5410 } /* $et_pb_counter_amount.length */ 5411 5412 // Reinit animation. 5413 isBuilder && et_pb_reinit_animation(); 5414 5415 // Reupdate maps filters. 5416 if ($et_pb_map.length || is_frontend_builder) { 5417 et_pb_update_maps_filters($et_pb_map); 5418 } 5419 5420 if (grid_containers.length || is_frontend_builder) { 5421 $(grid_containers).each(function () { 5422 window.et_pb_set_responsive_grid($(this), '.et_pb_grid_item'); 5423 }); 5424 } 5425 } ); 5426 5427 function fitvids_slider_fullscreen_init() { 5428 if ( $.fn.fitVids ) { 5429 $( '.et_pb_slide_video' ).fitVids(); 5430 $( '.et_pb_module' ).fitVids( { customSelector: "iframe[src^='http://www.hulu.com'], iframe[src^='http://www.dailymotion.com'], iframe[src^='http://www.funnyordie.com'], iframe[src^='https://embed-ssl.ted.com'], iframe[src^='http://embed.revision3.com'], iframe[src^='https://flickr.com'], iframe[src^='http://blip.tv'], iframe[src^='http://www.collegehumor.com']"} ); 5431 } 5432 5433 et_fix_slider_height(); 5434 5435 // calculate fullscreen section sizes on $( window ).ready to avoid jumping in some cases 5436 et_calculate_fullscreen_section_size(); 5437 } 5438 5439 if (is_frontend_builder) { 5440 $(window).one('et_fb_init_app_after', fitvids_slider_fullscreen_init); 5441 } else { 5442 fitvids_slider_fullscreen_init(); 5443 } 5444 5445 window.et_pb_fullwidth_header_scroll = function( event ) { 5446 event.preventDefault(); 5447 5448 var window_width = $et_window.width(), 5449 $body = $('body'), 5450 is_wp_relative_admin_bar = window_width < 782, 5451 is_transparent_main_header = $body.hasClass( 'et_transparent_nav' ), 5452 is_hide_nav = $body.hasClass( 'et_hide_nav' ), 5453 is_desktop_view = window_width > 980, 5454 is_tablet_view = window_width <= 980 && window_width >= 479, 5455 is_phone_view = window_width < 479, 5456 $this_section = $(this).parents( 'section' ), 5457 this_section_offset = $this_section.offset(), 5458 $wpadminbar = $('#wpadminbar'), 5459 $main_header = $('#main-header'), 5460 wpadminbar_height = $wpadminbar.length && ! is_wp_relative_admin_bar ? $wpadminbar.height() : 0, 5461 top_header_height = !window.et_is_fixed_nav || !is_desktop_view ? 0 : $top_header.height(), 5462 data_height_onload = typeof $main_header.attr('data-height-onload') === 'undefined' ? 0 : $main_header.attr('data-height-onload'), 5463 initial_fixed_difference = $main_header.height() === et_pb_get_fixed_main_header_height() || ! is_desktop_view || ! window.et_is_fixed_nav || is_transparent_main_header || is_hide_nav ? 0 : et_pb_get_fixed_main_header_height() - parseFloat( data_height_onload ), 5464 section_bottom = ( this_section_offset.top + $this_section.outerHeight( true ) + initial_fixed_difference ) - ( wpadminbar_height + top_header_height + et_pb_get_fixed_main_header_height() ), 5465 animate_modified = false;
5466 5467 if (!isVB && window.et_is_fixed_nav && is_transparent_main_header) { 5468 // We need to perform an extra adjustment which requires computing header height 5469 // in "fixed" mode. It can't be done directly on header because it will change 5470 // its appearance so an invisible clone is used instead. 5471 var clone = $main_header 5472 .clone() 5473 .addClass('et-disabled-animations et-fixed-header') 5474 .css('visibility', 'hidden') 5475 .appendTo($body); 5476 5477 section_bottom += et_pb_get_fixed_main_header_height() - clone.height(); 5478 clone.remove(); 5479 } 5480 5481 if ( $this_section.length ) { 5482 var fullscreen_scroll_duration = 800; 5483 5484 $( 'html, body' ).animate( { scrollTop : section_bottom }, { 5485 duration: fullscreen_scroll_duration 5486 } ); 5487 } 5488 }; 5489 5490 function et_pb_window_load_scripts() { 5491 et_fix_fullscreen_section(); 5492 et_calculate_fullscreen_section_size(); 5493 5494 $(document).on('click', '.et_pb_fullwidth_header_scroll a', et_pb_fullwidth_header_scroll ); 5495 5496 setTimeout( function() { 5497 $( '.et_pb_preload' ).removeClass( 'et_pb_preload' ); 5498 }, 500 ); 5499 5500 if ( $.fn.hashchange ) { 5501 $(window).hashchange( function(){ 5502 var hash = window.location.hash.substring(1); 5503 process_et_hashchange( hash ); 5504 }); 5505 $(window).hashchange(); 5506 } 5507 5508 if ( $et_pb_parallax.length && !et_is_mobile_device ) { 5509 $et_pb_parallax.each(function(){ 5510 et_pb_parallax_init( $(this) ); 5511 }); 5512 } 5513 5514 window.et_reinit_waypoint_modules(); 5515 5516 if ( $( '.et_audio_content' ).length ) { 5517 $( window ).trigger( 'resize' ); 5518 } 5519 } 5520 5521 if ( window.et_load_event_fired ) { 5522 et_pb_window_load_scripts(); 5523 } else { 5524 $( window ).load( function() { 5525 et_pb_window_load_scripts(); 5526 } ); 5527 } 5528 5529 if ( $( '.et_section_specialty' ).length ) { 5530 $( '.et_section_specialty' ).each( function() { 5531 var this_row = $( this ).find( '.et_pb_row' ); 5532 5533 this_row.find( '>.et_pb_column:not(.et_pb_specialty_column)' ).addClass( 'et_pb_column_single' ); 5534 }); 5535 } 5536 5537 /** 5538 * In particular browser, map + parallax doesn't play well due the use of CSS 3D transform 5539 */ 5540 if ( $('.et_pb_section_parallax').length && $('.et_pb_map').length ) { 5541 $('body').addClass( 'parallax-map-support' ); 5542 } 5543 5544 /** 5545 * Add conditional class for search widget in sidebar module 5546 */ 5547 $('.et_pb_widget_area ' + et_pb_custom.widget_search_selector ).each( function() { 5548 var $search_wrap = $(this), 5549 $search_input_submit = $search_wrap.find('input[type="submit"]'), 5550 search_input_submit_text = $search_input_submit.attr( 'value' ), 5551 $search_button = $search_wrap.find('button'), 5552 search_button_text = $search_button.text(), 5553 has_submit_button = $search_input_submit.length || $search_button.length ? true : false, 5554 min_column_width = 150; 5555 5556 if ( ! $search_wrap.find( 'input[type="text"]' ).length && ! $search_wrap.find( 'input[type="search"]' ).length ) { 5557 return; 5558 } 5559 5560 // Mark no button state 5561 if ( ! has_submit_button ) { 5562 $search_wrap.addClass( 'et-no-submit-button' ); 5563 } 5564 5565 // Mark narrow state 5566 if ( $search_wrap.width() < 150 ) { 5567 $search_wrap.addClass( 'et-narrow-wrapper' ); 5568 } 5569 5570 // Fixes issue where theme's search button has no text: treat it as non-existent 5571 if ( $search_input_submit.length && ( typeof search_input_submit_text == 'undefined' || search_input_submit_text === '' ) ) { 5572 $search_input_submit.remove(); 5573 $search_wrap.addClass( 'et-no-submit-button' ); 5574 } 5575 5576 if ( $search_button.length && ( typeof search_button_text == 'undefined' || search_button_text === '' ) ) { 5577 $search_button.remove(); 5578 $search_wrap.addClass( 'et-no-submit-button' ); 5579 } 5580 5581 } ); 5582 5583 // get the content of next/prev page via ajax for modules which have the .et_pb_ajax_pagination_container class 5584 $( 'body' ).on( 'click', '.et_pb_ajax_pagination_container .wp-pagenavi a,.et_pb_ajax_pagination_container .pagination a', function() { 5585 var this_link = $( this ); 5586 var href = this_link.attr( 'href' ); 5587 var current_href = window.location.href; 5588 var module_classes = this_link.closest( '.et_pb_module' ).attr( 'class' ).split( ' ' ); 5589 var module_class_processed = ''; 5590 var $current_module; 5591 var animation_classes = et_get_animation_classes(); 5592 5593 // global variable to store the cached content 5594 window.et_pb_ajax_pagination_cache = window.et_pb_ajax_pagination_cache || []; 5595 5596 // construct the selector for current module 5597 $.each(module_classes, function(index, value) { 5598 // skip animation classes so no wrong href is formed afterwards 5599 if ($.inArray(value, animation_classes) !== -1 || 'et_had_animation' === value) { 5600 return; 5601 } 5602 5603 if ('' !== value.trim()) { 5604 module_class_processed += '.' + value; 5605 } 5606 }); 5607 5608 $current_module = $( module_class_processed ); 5609 5610 // remove module animation to prevent conflicts with the page changing animation 5611 et_remove_animation( $current_module ); 5612 5613 // use cached content if it has beed retrieved already, otherwise retrieve the content via ajax 5614 if ( typeof window.et_pb_ajax_pagination_cache[ href + module_class_processed ] !== 'undefined' ) { 5615 $current_module.fadeTo( 'slow', 0.2, function() { 5616 $current_module.find( '.et_pb_ajax_pagination_container' ).replaceWith( window.et_pb_ajax_pagination_cache[ href + module_class_processed ] ); 5617 et_pb_set_paginated_content( $current_module, true ); 5618 } ); 5619 } else { 5620 // update cache for currently opened page if not set yet 5621 if ( typeof window.et_pb_ajax_pagination_cache[ current_href + module_class_processed ] === 'undefined' ) { 5622 window.et_pb_ajax_pagination_cache[ current_href + module_class_processed ] = $current_module.find( '.et_pb_ajax_pagination_container' ); 5623 } 5624 5625 $current_module.fadeTo( 'slow', 0.2, function() { 5626 jQuery.get( href, function( page ) { 5627 var $page = jQuery( page ); 5628 // Find custom style
5629 var $style = $page.filter( '#et-builder-module-design-cached-inline-styles' ); 5630 // Make sure it's included in the new content 5631 var $content = $page.find( module_class_processed + ' .et_pb_ajax_pagination_container' ).prepend( $style ); 5632 // Remove animations to prevent blocks from not showing 5633 et_remove_animation( $content.find( '.et_animated' ) ); 5634 // Replace current page with new one 5635 $current_module.find( '.et_pb_ajax_pagination_container' ).replaceWith( $content ); 5636 window.et_pb_ajax_pagination_cache[ href + module_class_processed ] = $content; 5637 et_pb_set_paginated_content( $current_module, false ); 5638 }); 5639 }); 5640 } 5641 5642 return false; 5643 }); 5644 5645 function et_pb_set_paginated_content( $current_module, is_cache ) { 5646 // Re-apply Salvattore grid to the new content if needed. 5647 if ( typeof $current_module.find( '.et_pb_salvattore_content' ).attr( 'data-columns' ) !== 'undefined' ) { 5648 // register grid only if the content is not from cache 5649 if ( ! is_cache ) { 5650 salvattore.registerGrid( $current_module.find( '.et_pb_salvattore_content' )[0] ); 5651 } 5652 salvattore.recreateColumns( $current_module.find( '.et_pb_salvattore_content' )[0] ); 5653 $current_module.find( '.et_pb_post' ).css( { 'opacity' : '1' } ); 5654 } 5655 5656 // init audio module on new content 5657 if ( $current_module.find( '.et_audio_container' ).length > 0 && typeof wp !== 'undefined' && typeof wp.mediaelement !== 'undefined' && typeof wp.mediaelement.initialize === 'function' ) { 5658 wp.mediaelement.initialize(); 5659 5660 $(window).trigger('resize'); 5661 } 5662 5663 // load waypoint modules such as counters and animated images 5664 if ( $current_module.find( '.et-waypoint, .et_pb_circle_counter, .et_pb_number_counter' ).length > 0 ) { 5665 $current_module.find( '.et-waypoint, .et_pb_circle_counter, .et_pb_number_counter' ).each( function() { 5666 var $waypoint_module = $( this ); 5667 5668 if ( $waypoint_module.hasClass( 'et_pb_circle_counter' ) ) { 5669 window.et_pb_reinit_circle_counters( $waypoint_module ); 5670 } 5671 5672 if ( $waypoint_module.hasClass( 'et_pb_number_counter' ) ) { 5673 window.et_pb_reinit_number_counters( $waypoint_module ); 5674 } 5675 5676 if ( $waypoint_module.find( '.et_pb_counter_amount' ).length > 0 ) { 5677 $waypoint_module.find( '.et_pb_counter_amount' ).each( function() { 5678 window.et_bar_counters_init( $( this ) ); 5679 }); 5680 } 5681 5682 $( this ).css({ 'opacity': '1'}); 5683 5684 window.et_reinit_waypoint_modules(); 5685 } ); 5686 } 5687 5688 /** 5689 * Init post gallery format 5690 */ 5691 if ( $current_module.find( '.et_pb_slider' ).length > 0 ) { 5692 $current_module.find('.et_pb_slider').each(function() { 5693 et_pb_slider_init($(this)); 5694 }); 5695 } 5696 5697 /** 5698 * Init post video format overlay click 5699 */ 5700 $current_module.on('click', '.et_pb_video_overlay', function(e) { 5701 e.preventDefault(); 5702 et_pb_play_overlayed_video($(this)); 5703 }); 5704 5705 // Re-apply fitvids to the new content. 5706 $current_module.fitVids( { customSelector: "iframe[src^='http://www.hulu.com'], iframe[src^='http://www.dailymotion.com'], iframe[src^='http://www.funnyordie.com'], iframe[src^='https://embed-ssl.ted.com'], iframe[src^='http://embed.revision3.com'], iframe[src^='https://flickr.com'], iframe[src^='http://blip.tv'], iframe[src^='http://www.collegehumor.com']"} ); 5707 5708 $current_module.fadeTo( 'slow', 1 ); 5709 5710 // reinit ET shortcodes. 5711 if (typeof window.et_shortcodes_init === 'function') { 5712 window.et_shortcodes_init($current_module); 5713 } 5714 5715 // reinit audio players. 5716 et_init_audio_modules(); 5717 5718 // scroll to the top of the module 5719 $( 'html, body' ).animate({ 5720 scrollTop: ( $current_module.offset().top - ( $( '#main-header' ).innerHeight() + $( '#top-header' ).innerHeight() + 50 ) ) 5721 }); 5722 5723 //Set classes for gallery and portfolio breakdowns 5724 var grid_items = $current_module.find('.et_pb_grid_item'); 5725 if (grid_items.length) { 5726 et_pb_set_responsive_grid($(grid_items.parent().get(0)), '.et_pb_grid_item'); 5727 } 5728 } 5729 5730 window.et_pb_search_init = function( $search ) { 5731 // Update animation breakpoint variable and generate suffix. 5732 var current_mode = et_pb_get_current_window_mode(); 5733 et_animation_breakpoint = current_mode; 5734 var suffix = current_mode !== 'desktop' ? '-' + current_mode : ''; 5735 5736 var $input_field = $search.find( '.et_pb_s' ); 5737 var $button = $search.find( '.et_pb_searchsubmit' ); 5738 var input_padding = $search.hasClass( 'et_pb_text_align_right' + suffix ) ? 'paddingLeft' : 'paddingRight'; 5739 var reverse_input_padding = input_padding === 'paddingLeft' ? 'paddingRight' : 'paddingLeft'; 5740 var disabled_button = $search.hasClass( 'et_pb_hide_search_button' ); 5741 var buttonHeight = $button.outerHeight(); 5742 var buttonWidth = $button.outerWidth(); 5743 var inputHeight = $input_field.innerHeight(); 5744 5745 // set the relative button position to get its height correctly 5746 $button.css( { 'position' : 'relative' } ); 5747 5748 if ( buttonHeight > inputHeight ) { 5749 $input_field.innerHeight( buttonHeight ); 5750 } 5751 5752 if ( ! disabled_button ) { 5753 // Reset reverse input padding. 5754 $input_field.css( reverse_input_padding, '' ); 5755 $input_field.css( input_padding, buttonWidth + 10 ); 5756 } 5757 5758 // reset the button position back to default 5759 $button.css( { 'position' : '' } ); 5760 }; 5761 5762 /** 5763 * Fix search module which has percentage based custom margin 5764 */ 5765 window.et_pb_search_percentage_custom_margin_fix = function( $search ) { 5766 var inputMargin = $search.find( '.et_pb_s' ).css( 'margin' ).split(' '); 5767 var inputMarginObj = {}; 5768 5769 switch(inputMargin.length) { 5770 case 4: 5771 inputMarginObj = { 5772 top: inputMargin[0], 5773 right: inputMargin[1], 5774 bottom: inputMargin[2], 5775 left: inputMargin[3], 5776 }; 5777 break; 5778 case 2: 5779 inputMarginObj = { 5780 top: inputMargin[0], 5781 right: inputMargin[1], 5782 bottom: inputMargin[0], 5783 left: inputMargin[1], 5784 }; 5785 break; 5786 default: 5787 inputMarginObj = { 5788 top: inputMargin[0], 5789 right: inputMargin[0], 5790 bottom: inputMargin[0], 5791 left: inputMargin[0], 5792 }; 5793 break; 5794 } 5795 5796 var inputRight = 0 - parseFloat(inputMarginObj.left) + 'px'; 5797 5798 $search.find('.et_pb_searchsubmit').css({ 5799 top: inputMarginObj.top, 5800 right: inputRight, 5801 bottom: inputMarginObj.bottom, 5802 }); 5803 }; 5804 5805 if ( $( '.et_pb_search' ).length ) { 5806 $( '.et_pb_search' ).each( function() { 5807 var $search = $(this); 5808 5809 if ( $search.is( '.et_pb_search_percentage_custom_margin' ) ) { 5810 et_pb_search_percentage_custom_margin_fix( $search ); 5811 } 5812 5813 et_pb_search_init( $search ); 5814 }); 5815 } 5816 5817 window.et_pb_comments_init = function( $comments_module ) { 5818 var $comments_module_button = $comments_module.find( '.comment-reply-link, .submit' ); 5819 5820 if ( $comments_module_button.length ) { 5821 $comments_module_button.addClass( 'et_pb_button' ); 5822 5823 if ( typeof $comments_module.attr( 'data-icon' ) !== 'undefined' && $comments_module.attr( 'data-icon' ) !== '' ) { 5824 $comments_module_button.attr( 'data-icon', $comments_module.attr( 'data-icon' ) ); 5825 $comments_module_button.addClass( 'et_pb_custom_button_icon' ); 5826 } 5827 5828 if ( typeof $comments_module.attr( 'data-icon-tablet' ) !== 'undefined' && $comments_module.attr( 'data-icon-tablet' ) !== '' ) { 5829 $comments_module_button.attr( 'data-icon-tablet', $comments_module.attr( 'data-icon-tablet' ) ); 5830 $comments_module_button.addClass( 'et_pb_custom_button_icon' ); 5831 } 5832 5833 if ( typeof $comments_module.attr( 'data-icon-phone' ) !== 'undefined' && $comments_module.attr( 'data-icon-phone' ) !== '' ) { 5834 $comments_module_button.attr( 'data-icon-phone', $comments_module.attr( 'data-icon-phone' ) ); 5835 $comments_module_button.addClass( 'et_pb_custom_button_icon' ); 5836 } 5837 } 5838 }; 5839 5840 // apply required classes for the Reply buttons in Comments Module 5841 if ( $( '.et_pb_comments_module' ).length ) { 5842 $( '.et_pb_comments_module' ).each( function() { 5843 var $comments_module = $( this ); 5844 5845 et_pb_comments_init( $comments_module ); 5846 }); 5847 } 5848 5849 window.et_fix_pricing_currency_position(); 5850 5851 $('.et_pb_contact_form_container, .et_pb_newsletter_custom_fields').each( function() { 5852 var $form = $(this); 5853 var subjects_selector = 'input, textarea, select'; 5854 var condition_check = function() { 5855 et_conditional_check( $form ); 5856 }; 5857 var debounced_condition_check = et_pb_debounce( condition_check, 250 ); 5858 5859 // Listen for any field change 5860 $form.on( 'change', subjects_selector, condition_check ); 5861 $form.on( 'keydown', subjects_selector, debounced_condition_check ); 5862 5863 // Conditions may be satisfied on default form state 5864 et_conditional_check( $form ); 5865 } ); 5866 5867 function et_conditional_check( $form ) { 5868 var $conditionals = $form.find('[data-conditional-logic]'); 5869 5870 // Upon change loop all the fields that have conditional logic 5871 $conditionals 5872 .each( function() { 5873 var $conditional = $(this); 5874 5875 // jQuery automatically parses the JSON 5876 var rules = $conditional.data('conditional-logic'); 5877 var relation = $conditional.data('conditional-relation'); 5878 5879 // Loop all the conditional logic rules 5880 var matched_rules = []; 5881 5882 for ( var i = 0; i < rules.length; i++ ) { 5883 var ruleset = rules[i]; 5884 var check_id = ruleset[0]; 5885 var check_type = ruleset[1]; 5886 var check_value = ruleset[2]; 5887 var $wrapper = $form.find('.et_pb_contact_field[data-id="' + check_i
5887d + '"]'); 5888 var field_id = $wrapper.data('id'); 5889 var field_type = $wrapper.data('type'); 5890 var field_value; 5891 5892 /* 5893 Check if the field wrapper is actually visible when including it in the rules check. 5894 This avoids the scenario with a parent, child and grandchild field where the parent 5895 field is changed but the grandchild remains visible, because the child one has the 5896 right value, even though it is not visible 5897 */ 5898 if ( ! $wrapper.is(':visible') ) { 5899 continue; 5900 } 5901 5902 // Get the proper compare value based on the field type 5903 switch( field_type ) { 5904 case 'input': 5905 case 'email': 5906 field_value = $wrapper.find('input').val(); 5907 break; 5908 case 'text': 5909 field_value = $wrapper.find('textarea').val(); 5910 break; 5911 case 'radio': 5912 field_value = $wrapper.find('input:checked').val() || ''; 5913 break; 5914 case 'checkbox': 5915 /* 5916 Conditional logic for checkboxes is a bit trickier since we have multiple values. 5917 To address that we first check if a checked checkbox with the desired value 5918 exists, which is represented by setting `field_value` to true or false. 5919 Next we always set `check_value` to true so we can compare against the 5920 result of the value check. 5921 */ 5922 var $checkbox = $wrapper.find(':checkbox:checked'); 5923 5924 field_value = false; 5925 5926 $checkbox.each(function() { 5927 if ( check_value === $(this).val() ) { 5928 field_value = true; 5929 5930 return false; 5931 } 5932 }); 5933 5934 check_value = true; 5935 break; 5936 case 'select': 5937 field_value = $wrapper.find('select').val(); 5938 break; 5939 } 5940 5941 /* 5942 'is empty' / 'is not empty' are comparing against an empty value so simply 5943 reset the `check_value` and update the condition to 'is' / 'is not' 5944 */ 5945 if ( 'is empty' === check_type || 'is not empty' === check_type ) { 5946 check_type = 'is empty' === check_type ? 'is' : 'is not'; 5947 check_value = ''; 5948 5949 /* 5950 `field_value` will always be `false` if all the checkboxes are unchecked 5951 since it only changes when a checked checkbox matches the `check_value` 5952 Because of `check_value` being reset to empty string we do the same 5953 to `field_value` (if it is `false`) to cover the 'is empty' case 5954 */ 5955 if ( 'checkbox' === field_type && false === field_value ) { 5956 field_value = ''; 5957 } 5958 } 5959 5960 // Check if the value IS matching (if it has to) 5961 if ( 'is' === check_type && field_value !== check_value ) { 5962 continue; 5963 } 5964 5965 // Check if the value IS NOT matching (if it has to) 5966 if ( 'is not' === check_type && field_value === check_value ) { 5967 continue; 5968 } 5969 5970 // Create the contains/not contains regular expresion 5971 var containsRegExp = new RegExp( check_value, 'i' ); 5972 5973 // Check if the value IS containing 5974 if ( 'contains' === check_type && ! field_value.match( containsRegExp ) ) { 5975 continue; 5976 } 5977 5978 // Check if the value IS NOT containing 5979 if ( 'does not contain' === check_type && field_value.match( containsRegExp ) ) { 5980 continue; 5981 } 5982 5983 // Prepare the values for the 'is greater than' / 'is less than' check 5984 var maybeNumericValue = parseInt( field_value ); 5985 var maybeNumbericCheckValue = parseInt( check_value ); 5986 5987 if ( 5988 ( 'is greater' === check_type || 'is less' === check_type ) && 5989 ( isNaN( maybeNumericValue ) || isNaN( maybeNumbericCheckValue ) ) 5990 ) { 5991 continue; 5992 } 5993 5994 // Check if the value is greater than 5995 if ( 'is greater' === check_type && maybeNumericValue <= maybeNumbericCheckValue) { 5996 continue; 5997 } 5998 5999 // Check if the value is less than 6000 if ( 'is less' === check_type && maybeNumericValue >= maybeNumbericCheckValue) { 6001 continue; 6002 } 6003 6004 matched_rules.push( true ); 6005 } 6006 6007 // Hide all the conditional fields initially 6008 $conditional.hide(); 6009 6010 /* 6011 Input fields may have HTML5 pattern validation which must be ignored 6012 if the field is not visible. In order for the pattern to not be 6013 taken into account the field must have novalidate property and 6014 to not be required (or to not have a pattern attribute) 6015 */ 6016 var $conditional_input = $conditional.find('input[type="text"]'); 6017 var conditional_pattern = $conditional_input.attr('pattern'); 6018 6019 $conditional_input.attr('novalidate', 'novalidate'); 6020 $conditional_input.attr('data-pattern', conditional_pattern); 6021 $conditional_input.removeAttr('pattern'); 6022 6023 if ( 'all' === relation && rules.length === matched_rules.length ) { 6024 $conditional.show(); 6025 $conditional_input.removeAttr('novalidate'); 6026 $conditional_input.attr('pattern', $conditional_input.data('pattern')); 6027 } 6028 6029 if ( 'any' === relation && 0 < matched_rules.length ) { 6030 $conditional.show(); 6031 $conditional_input.removeAttr('novalidate'); 6032 $conditional_input.attr('pattern', $conditional_input.data('pattern')); 6033 } 6034 } ); 6035 } 6036 6037 // Adjust z-index for animated full-width menu modules 6038 if ( 'undefined' !== typeof et_animation_data && et_animation_data.length > 0 ) { 6039 6040 // Store the maximum z-index that should be applied 6041 var maxFullwidthMenuIndex = 0; 6042 6043 // Increase the maximum z-index by one for each module 6044 for ( var i = 0; i < et_animation_data.length; i++ ) { 6045 var animation_entry = et_animation_data[i]; 6046 6047 if ( ! animation_entry.class ) { 6048 continue; 6049 } 6050 6051 if ( $('.' + animation_entry.class ).hasClass('et_pb_fullwidth_menu') ) { 6052 maxFullwidthMenuIndex++; 6053 } 6054 } 6055 6056 var $fullWidthMenus = $('.et_pb_fullwidth_menu'); 6057 6058 $fullWidthMenus.each(function() { 6059 var $fullWidthMenu = $(this); 6060 6061 // When the animation ends apply z-index in descending order to each of the animated modules 6062 $fullWidthMenu.on('webkitAnimationEnd oanimationend msAnimationEnd animationend', function() { 6063 $fullWidthMenu.css('z-index', maxFullwidthMenuIndex - $fullWidthMenu.index('.et_pb_fullwidth_menu') ); 6064 }); 6065 }); 6066 } 6067 6068 /** 6069 * Provide event listener for plugins to hook up to 6070 */ 6071 $(document).trigger('et_pb_after_init_modules'); 6072 }); 6073 }; 6074 6075 // Modification of underscore's _.debounce() 6076 // Underscore.js 1.8.3 6077 // http://underscorejs.org
6078 // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 6079 // Underscore may be freely distributed under the MIT license. 6080 window.et_pb_debounce = function(func, wait, immediate) { 6081 var timeout, args, context, timestamp, result; 6082 6083 var now = Date.now || new Date().getTime(); 6084 6085 var later = function() { 6086 var last = now - timestamp; 6087 6088 if (last < wait && last >= 0) { 6089 timeout = setTimeout(later, wait - last); 6090 } else { 6091 timeout = null; 6092 if (!immediate) { 6093 result = func.apply(context, args); 6094 if (!timeout) context = args = null; 6095 } 6096 } 6097 }; 6098 6099 return function() { 6100 context = this; 6101 args = arguments; 6102 timestamp = now; 6103 var callNow = immediate && !timeout; 6104 if (!timeout) timeout = setTimeout(later, wait); 6105 if (callNow) { 6106 result = func.apply(context, args); 6107 context = args = null; 6108 } 6109 6110 return result; 6111 }; 6112 }; 6113 6114 if ( et_pb_custom.is_ab_testing_active && 'yes' === et_pb_custom.is_cache_plugin_active ) { 6115 // update the window.et_load_event_fired variable to initiate the scripts properly 6116 $( window ).load( function() { 6117 window.et_load_event_fired = true; 6118 }); 6119 6120 // get the subject id for current visitor and display it 6121 // this ajax request performed only if AB Testing is enabled and cache plugin active 6122 $.ajax( { 6123 type: "POST", 6124 url: et_pb_custom.ajaxurl, 6125 dataType: "json", 6126 data: 6127 { 6128 action : 'et_pb_ab_get_subject_id', 6129 et_frontend_nonce : et_pb_custom.et_frontend_nonce, 6130 et_pb_ab_test_id : et_pb_custom.page_id 6131 }, 6132 success: function( subject_data ) { 6133 if ( subject_data ) { 6134 // append the subject content to appropriate placeholder 6135 $( '.et_pb_subject_placeholder_id_' + subject_data.id ).after( subject_data.content ); 6136 // remove all other placeholders from the DOM 6137 $( '.et_pb_subject_placeholder' ).remove(); 6138 6139 // init all scripts once the subject loaded 6140 window.et_pb_init_modules(); 6141 $( 'body' ).trigger( 'et_pb_ab_subject_ready' ); 6142 } 6143 } 6144 }); 6145 } else { 6146 window.et_pb_init_modules(); 6147 } 6148 6149 $(document).ready(function() { 6150 // Hover transition are disabled for section dividers to prevent visual glitches while document is loading, 6151 // we can enable them again now. 6152 $('.et_pb_top_inside_divider.et-no-transition, .et_pb_bottom_inside_divider.et-no-transition').removeClass('et-no-transition'); 6153 6154 // Set a delay just to make sure all modules are ready before we append box shadow container. 6155 // Similar approach exists on VB custom CSS output. 6156 setTimeout(function() { 6157 (et_pb_box_shadow_elements||[]).map(et_pb_box_shadow_apply_overlay); 6158 }, 0); 6159 }); 6160 6161 $(window).load(function() { 6162 var $body = $('body'); 6163 // set load event here because safari sometimes will not run load events registered on et_pb_init_modules. 6164 window.et_load_event_fired = true; 6165 // fix Safari letter-spacing bug when styles applied in `head` 6166 // Trigger styles redraw by changing body display property to differentvalue and reverting it back to original. 6167 if ($body.hasClass('safari')) { 6168 var original_display_value = $body.css('display'); 6169 var different_display_value = 'initial' === original_display_value ? 'block' : 'initial'; 6170 6171 $body.css({ 'display': different_display_value }); 6172 6173 setTimeout(function() { 6174 $body.css({ 'display': original_display_value }); 6175 }, 0); 6176 6177 // Keep this script here, as it needs to be executed only if the script from above is executed 6178 // As the script from above somehow affects WooCommerce single product image rendering. 6179 // https://github.com/elegantthemes/Divi/issues/7454 6180 if ($body.hasClass('woocommerce-page') && $body.hasClass('single-product')) { 6181 var $wc = $('.woocommerce div.product div.images.woocommerce-product-gallery'); 6182 6183 if ($wc.length === 0) { 6184 return; 6185 } 6186 6187 // Don't use jQuery to get element opacity, as it may return an outdated value. 6188 var opacity = parseInt($wc[0].style.opacity); 6189 6190 if (!opacity) { 6191 return; 6192 } 6193 6194 $wc.css({opacity: opacity - .09}); 6195 setTimeout(function() { 6196 $wc.css({opacity: opacity}); 6197 }, 0); 6198 } 6199 } 6200 6201 /* 6202 * Reinit Star Ratings in Woo Modules. 6203 * Deafuilt Woocommerce scripts do not init Star Ratings correctly 6204 * if there are more than 1 place with stars on page 6205 * Run this on .load event after woocommerce modules are ready and processed. 6206 */ 6207 if ($('.et_pb_module #rating').length > 0) { 6208 $('.et_pb_module #rating').each( function(){ 6209 window.et_pb_init_woo_star_rating($(this)); 6210 }); 6211 } 6212 6213 /* 6214 * Apply Custom icons to Woo Module Buttons. 6215 * All the buttons generated in WooCommerce template and we cannot add custom attributes 6216 * Therefore we have to use js to add it. 6217 */ 6218 if ($('.et_pb_woo_custom_button_icon').length > 0) { 6219 $('.et_pb_woo_custom_button_icon').each(function() { 6220 var $thisModule = $(this); 6221 var buttonClass = $thisModule.data('button-class'); 6222 var $buttonEl = $thisModule.find('.' + buttonClass); 6223 var buttonIcon = $thisModule.attr('data-button-icon'); 6224 var buttonIconTablet = $thisModule.attr('data-button-icon-tablet'); 6225 var buttonIconPhone = $thisModule.attr('data-button-icon-phone'); 6226 var buttonClassName = 'et_pb_promo_button et_pb_button'; 6227 6228 $buttonEl.addClass(buttonClassName); 6229 6230 if (buttonIcon || buttonIconTablet || buttonIconPhone) { 6231 $buttonEl.addClass('et_pb_custom_button_icon'); 6232 $buttonEl.attr('data-icon', buttonIcon); 6233 $buttonEl.attr('data-icon-tablet', buttonIconTablet); 6234 $buttonEl.attr('data-icon-phone', buttonIconPhone); 6235 } 6236 }); 6237 } 6238 6239 /** 6240 * Hide empty WooCommerce Meta module 6241 * Meta module component is toggled using classname, thus js visibility check to determine 6242 * whether the module is "empty" (visibility-wise) or not 6243 */ 6244 if ($('.et_pb_wc_meta').length > 0) { 6245 $('.et_pb_wc_meta').each(function() { 6246 var $thisModule = $(this); 6247 6248 if ('' === $thisModule.find('.product_meta span:visible').text()) { 6249 $thisModule.addClass('et_pb_wc_meta_empty'); 6250 } 6251 }); 6252 } 6253 }); 6254 6255 // Handle cases where builder modules are not initially visible and produce sizing 6256 // issues as a result (e.g. slider module inside popups, accordions etc.). 6257 $(document).ready(function() { 6258 if (MutationObserver === undefined) { 6259 // Bail if MutationObserver is not supported by the user agent. 6260 return; 6261 } 6262 6263 var getSectionParents = function($sections) { 6264 var filterMethod = $.uniqueSort !== undefined ? $.uniqueSort : $.unique; 6265 var $sectionParents = $([]); 6266 6267 $sections.each(function() { 6268 $sectionParents = $sectionParents.add($(this).parents()); 6269 }); 6270 6271 // Avoid duplicate section parents. 6272 return filterMethod($sectionParents.get()); 6273 }; 6274 6275 var getInvisibleNodes = function($sections) { 6276 return $sections.filter(function() { 6277 return !$(this).is(':visible'); 6278 }).length; 6279 }; 6280 6281 var $sections = $('.et_pb_section'); 6282 var sectionParents = getSectionParents($sections); 6283 var invisibleSections = getInvisibleNodes($sections); 6284 var maybeRefreshSections = function () { 6285 var newInvisibleSections = getInvisibleNodes($sections); 6286 if (newInvisibleSections < invisibleSections) { 6287 // Trigger resize if some previously invisible sections have become visible. 6288 $(window).trigger('resize'); 6289 } 6290 invisibleSections = newInvisibleSections; 6291 }; 6292 var observer = new MutationObserver(window.et_pb_debounce(maybeRefreshSections, 200)); 6293 6294 for (var i = 0; i < sectionParents.length; i++) { 6295 observer.observe(sectionParents[i], { 6296 childList: true, 6297 attributes: true, 6298 attributeFilter: ['class', 'style'], 6299 attributeOldValue: false, 6300 characterData: false, 6301 characterDataOldValue: false, 6302 subtree: false 6303 }); 6304 } 6305 }); 6306 6307 function et_fix_html_margin() { 6308 // Calculate admin bar height and apply correct margin to HTML in VB 6309 if ($('body').is('.et-fb')) { 6310 var $adminBar = $('#wpadminbar'); 6311 6312 if ($adminBar.length > 0) { 6313 setTimeout(function(){ 6314 $('#et_fix_html_margin').remove(); 6315 6316 $('<style />', { 6317 'id' : 'et_fix_html_margin', 6318 'text' : 'html.js.et-fb-top-html { margin-top: 0px !important; }' 6319 }).appendTo('head'); 6320 }, 0); 6321 } 6322 } 6323 } 6324 et_fix_html_margin(); 6325 6326 // Muti View Data Handler (Responsive + Hover) 6327 var et_multi_view = { 6328 contexts: ['content', 'attrs', 'styles', 'classes', 'visibility'], 6329 windowWidth: $(window).width(), 6330 init: function () { 6331 $('#main-header, #main-footer').off('mouseenter', et_multi_view.resetHoverStateHandler); 6332 $('#main-header, #main-footer').on('mouseenter', et_multi_view.resetHoverStateHandler); 6333 6334 $('[data-et-multi-view]').each(function () { 6335 var data = et_multi_view.getData($(this)); 6336 6337 et_multi_view.normalStateHandler(data); 6338 6339 if (data.$hoverSelector && data.$hoverSelector.length) { 6340 data.$hoverSelector.off('touchstart touchend', et_multi_view.touchStateHandler); 6341 data.$hoverSelector.on('touchstart touchend', et_multi_view.touchStateHandler); 6342 6343 data.$hoverSelector.off('mouseenter mouseleave', et_multi_view.hoverStateHandler); 6344 data.$hoverSelector.on('mouseenter mouseleave', et_multi_view.hoverStateHandler); 6345 } 6346 }); 6347 }, 6348 normalStateHandler: function (data) { 6349 if (!data || et_multi_view.isEmptyObject(data.normalState)) { 6350 return; 6351 } 6352 6353 et_multi_view.callbackHandlerDefault(data.normalState, data.$target, data.$source, data.slug); 6354 }, 6355 touchStateHandler: function (event) { 6356 var $hoverSelector = $(this); 6357 6358 if ('touchend' === event.type) { 6359 setTimeout(function () { 6360 $hoverSelector.on('mouseenter mouseleave', et_multi_view.hoverStateHandler); 6361 }, 1) 6362 } else if (event.type === 'touchstart') { 6363 $hoverSelector.off('mouseenter mouseleave', et_multi_view.hoverStateHandler); 6364 } 6365 }, 6366 hoverStateHandler: function (event) { 6367 var $hoverSelector = $(this); 6368 var datas = []; 6369 6370 if ($hoverSelector.data('etMultiView')) { 6371 datas.push(et_multi_view.getData($hoverSelector)); 6372 } 6373 6374 $hoverSelector.find('[data-et-multi-view]').each(function () { 6375 datas.push(et_multi_view.getData($(this))); 6376 }); 6377 6378 if (event.type === 'mouseenter' && !$hoverSelector.hasClass('et_multi_view__hovered')) { 6379 et_multi_view.resetHoverStateHandler($hoverSelector); 6380 $hoverSelector.addClass('et_multi_view__hovered'); 6381 6382 for (var index = 0; index < datas.length; index++) { 6383 var data = datas[index]; 6384 6385 if (data && !et_multi_view.isEmptyObject(data.normalState) && !et_multi_view.isEmptyObject(data.hoverState)) { 6386 et_multi_view.callbackHandlerDefault(data.hoverState, data.$target, data.$source, data.slug); 6387 } 6388 } 6389 } else if (event.type === 'mouseleave' && $hoverSelector.hasClass('et_multi_view__hovered')) { 6390 for (var index = 0; index < datas.length; index++) { 6391 var data = datas[index]; 6392 6393 if (data && !et_multi_view.isEmptyObject(data.normalState) && !et_multi_view.isEmptyObject(data.hoverState)) { 6394 et_multi_view.callbackHandlerDefault(data.normalState, data.$target, data.$source, data.slug); 6395 } 6396 } 6397 6398 $hoverSelector.removeClass('et_multi_view__hovered'); 6399 } 6400 }, 6401 resetHoverStateHandler: function ($exclude) { 6402 $('[data-et-multi-view]').each(function () { 6403 var data = et_multi_view.getData($(this)); 6404 6405 if (data && 6406 data.$hoverSelector && 6407 data.$hoverSelector.length && 6408 data.$hoverSelector.hasClass('et_multi_view__hovered') && 6409 !data.$hoverSelector.is($exclude) 6410 ) { 6411 data.$hoverSelector.trigger('mouseleave'); 6412 } 6413 }); 6414 }, 6415 getData: function ($source) { 6416 if (!$source || !$source.length) { 6417 return false;
6418 } 6419 6420 var screenMode = et_multi_view.getScreenMode(); 6421 var data = $source.data('etMultiView'); 6422 6423 if (!data) { 6424 return false; 6425 } 6426 6427 if (typeof data === 'string') { 6428 data = et_multi_view.tryParseJSON(data); 6429 } 6430 6431 if (!data || !data.schema || !data.slug) { 6432 return false; 6433 } 6434 6435 var $target = data.target ? $(data.target) : $source; 6436 6437 if (!$target || !$target.length) { 6438 return false; 6439 } 6440 6441 var normalState = {}; 6442 var hoverState = {}; 6443 6444 for (var i = 0; i < et_multi_view.contexts.length; i++) { 6445 var context = et_multi_view.contexts[i]; 6446 6447 // Set context data. 6448 if (data.schema && data.schema.hasOwnProperty(context)) { 6449 // Set normal state context data. 6450 if (data.schema[context].hasOwnProperty(screenMode)) { 6451 normalState[context] = data.schema[context][screenMode]; 6452 } else { 6453 if (screenMode === 'tablet' && data.schema[context].hasOwnProperty('desktop')) { 6454 normalState[context] = data.schema[context].desktop; 6455 } else if (screenMode === 'phone' && data.schema[context].hasOwnProperty('tablet')) { 6456 normalState[context] = data.schema[context].tablet; 6457 } else if (screenMode === 'phone' && data.schema[context].hasOwnProperty('desktop')) { 6458 normalState[context] = data.schema[context].desktop; 6459 } 6460 } 6461 6462 // Set hover state context data. 6463 if (data.schema[context].hasOwnProperty('hover')) { 6464 hoverState[context] = data.schema[context].hover; 6465 } 6466 } 6467 } 6468 6469 var $hoverSelector = data.hover_selector ? $(data.hover_selector) : false; 6470 6471 if (!$hoverSelector || !$hoverSelector.length) { 6472 $hoverSelector = $source.hasClass('.et_pb_module') ? $source : $source.closest('.et_pb_module'); 6473 } 6474 6475 return { 6476 normalState: normalState, 6477 hoverState: hoverState, 6478 $target: $target, 6479 $source: $source, 6480 $hoverSelector: $hoverSelector, 6481 slug: data.slug, 6482 screenMode: screenMode 6483 }; 6484 }, 6485 callbackHandlerDefault: function (data, $target, $source, slug) { 6486 var callbackHandlerCustom = et_multi_view.getCallbackHandlerCustom(slug, data, $target); 6487 6488 if (callbackHandlerCustom && typeof callbackHandlerCustom === 'function') { 6489 return callbackHandlerCustom(data, $target, $source, slug); 6490 } 6491 6492 var updated = {}; 6493 6494 if (data.hasOwnProperty('content')) { 6495 updated.content = et_multi_view.updateContent(data.content, $target, $source); 6496 } 6497 6498 if (data.hasOwnProperty('attrs')) { 6499 updated.attrs = et_multi_view.updateAttrs(data.attrs, $target, $source); 6500 } 6501 6502 if (data.hasOwnProperty('styles')) { 6503 updated.styles = et_multi_view.updateStyles(data.styles, $target, $source); 6504 } 6505 6506 if (data.hasOwnProperty('classes')) { 6507 updated.classes = et_multi_view.updateClasses(data.classes, $target, $source); 6508 } 6509 6510 if (data.hasOwnProperty('visibility')) { 6511 updated.visibility = et_multi_view.updateVisibility(data.visibility, $target, $source); 6512 } 6513 6514 return et_multi_view.isEmptyObject(updated) ? false : updated; 6515 }, 6516 callbackHandlerCounter: function (data, $target, $source, slug) { 6517 var updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6518 6519 if (updated && updated.attrs && updated.attrs.hasOwnProperty('data-width')) { 6520 window.et_bar_counters_init($target); 6521 } 6522 }, 6523 callbackHandlerNumberCounter: function (data, $target, $source, slug) { 6524 if ($target.hasClass('title')) { 6525 return et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6526 } 6527 6528 var attrs = data.attrs || false; 6529 6530 if (!attrs) { 6531 return; 6532 } 6533 6534 if (attrs.hasOwnProperty('data-percent-sign')) { 6535 et_multi_view.updateContent(attrs['data-percent-sign'], $target.find('.percent-sign'), $source); 6536 } 6537 6538 if (attrs.hasOwnProperty('data-number-value')) { 6539 var $the_counter = $target.closest('.et_pb_number_counter'); 6540 var numberValue = attrs['data-number-value'] || 50; 6541 var numberSeparator = attrs['data-number-separator'] || ''; 6542 6543 var updated = et_multi_view.updateAttrs({ 6544 'data-number-value': numberValue, 6545 'data-number-separator': numberSeparator, 6546 }
6546, $the_counter, $source); 6547 6548 if (updated && $the_counter.data('easyPieChart')) { 6549 $the_counter.data('easyPieChart').update(numberValue); 6550 } 6551 } 6552 }, 6553 callbackHandlerCircleCounter: function (data, $target, $source, slug) { 6554 if (!$target.hasClass('et_pb_circle_counter_inner')) { 6555 return et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6556 } 6557 6558 var attrs = data.attrs || false; 6559 6560 if (!attrs) { 6561 return; 6562 } 6563 6564 if (attrs.hasOwnProperty('data-percent-sign')) { 6565 et_multi_view.updateContent(attrs['data-percent-sign'], $target.find('.percent-sign'), $source); 6566 } 6567 6568 if (attrs.hasOwnProperty('data-number-value')) { 6569 var $the_counter = $target.closest('.et_pb_circle_counter_inner'); 6570 var numberValue = attrs['data-number-value']; 6571 6572 var attrsUpdated = et_multi_view.updateAttrs({ 6573 'data-number-value': numberValue, 6574 }, $the_counter, $source); 6575 6576 if (attrsUpdated && $the_counter.data('easyPieChart')) { 6577 window.et_pb_circle_counter_init($the_counter); 6578 $the_counter.data('easyPieChart').update(numberValue); 6579 } 6580 } 6581 }, 6582 callbackHandlerSlider: function (data, $target, $source, slug) { 6583 var updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6584 6585 if ($target.hasClass('et_pb_module') && updated && updated.classes) { 6586 if (updated.classes.add && updated.classes.add.indexOf('et_pb_slider_no_arrows') !== -1) { 6587 $target.find('.et-pb-slider-arrows').addClass('et_multi_view_hidden'); 6588 } 6589 6590 if (updated.classes.remove && updated.classes.remove.indexOf('et_pb_slider_no_arrows') !== -1) { 6591 $target.find('.et-pb-slider-arrows').removeClass('et_multi_view_hidden'); 6592 } 6593 6594 if (updated.classes.add && updated.classes.add.indexOf('et_pb_slider_no_pagination') !== -1) { 6595 $target.find('.et-pb-controllers').addClass('et_multi_view_hidden'); 6596 } 6597 6598 if (updated.classes.remove && updated.classes.remove.indexOf('et_pb_slider_no_pagination') !== -1) { 6599 $target.find('.et-pb-controllers').removeClass('et_multi_view_hidden'); 6600 } 6601 } 6602 }, 6603 callbackHandlerPostSlider: function (data, $target, $source, slug) { 6604 var updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6605 6606 if ($target.hasClass('et_pb_module') && updated && updated.classes) { 6607 if (updated.classes.add && updated.classes.add.indexOf('et_pb_slider_no_arrows') !== -1) { 6608 $target.find('.et-pb-slider-arrows').addClass('et_multi_view_hidden'); 6609 } 6610 6611 if (updated.classes.remove && updated.classes.remove.indexOf('et_pb_slider_no_arrows') !== -1) { 6612 $target.find('.et-pb-slider-arrows').removeClass('et_multi_view_hidden'); 6613 } 6614 6615 if (updated.classes.add && updated.classes.add.indexOf('et_pb_slider_no_pagination') !== -1) { 6616 $target.find('.et-pb-controllers').addClass('et_multi_view_hidden'); 6617 } 6618 6619 if (updated.classes.remove && updated.classes.remove.indexOf('et_pb_slider_no_pagination') !== -1) { 6620 $target.find('.et-pb-controllers').removeClass('et_multi_view_hidden'); 6621 } 6622 } 6623 }, 6624 callbackHandlerVideoSlider: function (data, $target, $source, slug) { 6625 var updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6626 6627 if ($target.hasClass('et_pb_slider') && updated && updated.classes) { 6628 if (updated.classes.add && updated.classes.add.indexOf('et_pb_slider_no_arrows') !== -1) { 6629 $target.find('.et-pb-slider-arrows').addClass('et_multi_view_hidden'); 6630 } 6631 6632 if (updated.classes.remove && updated.classes.remove.indexOf('et_pb_slider_no_arrows') !== -1) { 6633 $target.find('.et-pb-slider-arrows').removeClass('et_multi_view_hidden'); 6634 } 6635 6636 var isInitSlider = function () { 6637 if (updated.classes.add && updated.classes.add.indexOf('et_pb_slider_dots') !== -1) { 6638 return 'et_pb_slider_dots'; 6639 } 6640 6641 if (updated.classes.add && updated.classes.add.indexOf('et_pb_slider_carousel') !== -1) { 6642 return 'et_pb_slider_carousel'; 6643 } 6644 6645 return false; 6646 }; 6647 6648 var sliderControl = isInitSlider(); 6649 6650 if (sliderControl) { 6651 var sliderApi = $target.data('et_pb_simple_slider'); 6652 6653 if (typeof sliderApi === 'object') { 6654 sliderApi.et_slider_destroy(); 6655 } 6656 6657 et_pb_slider_init($target); 6658 6659 if (sliderControl === 'et_pb_slider_carousel') { 6660 $target.siblings('.et_pb_carousel').et_pb_simple_carousel({ 6661 slide_duration: 1000 6662 }); 6663 } 6664 } 6665 } 6666 }, 6667 callbackHandlerSliderItem: function (data, $target, $source, slug) { 6668 if (!$target.hasClass('et_pb_slide_video') && !$target.is('img')) { 6669 return et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6670 } 6671 6672 if ($target.hasClass('et_pb_slide_video')) { 6673 var $contentNew = data && data.content ? $(data.content) : false;
6674 var $contentOld = $target.html().indexOf('fluid-width-video-wrapper') !== -1 6675 ? $($target.find('.fluid-width-video-wrapper').html()) 6676 : $($target.html()); 6677 6678 if (!$contentNew || !$contentOld) { 6679 return; 6680 } 6681 var updated = false; 6682 6683 if ($contentNew.hasClass('wp-video') && $contentOld.hasClass('wp-video')) { 6684 var isVideoNeedUpdate = function () { 6685 if ($contentNew.find('source').length !== $contentOld.find('source').length) { 6686 return true; 6687 } 6688 6689 var isDifferentAttr = false; 6690 6691 $contentNew.find('source').each(function (index) { 6692 var $contentOldSource = $contentOld.find('source').eq(index); 6693 6694 if ($(this).attr('src') !== $contentOldSource.attr('src')) { 6695 isDifferentAttr = true; 6696 } 6697 }); 6698 6699 return isDifferentAttr; 6700 }; 6701 6702 if (isVideoNeedUpdate()) { 6703 updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6704 } 6705 } else if ($contentNew.is('iframe') && $contentOld.is('iframe') && $contentNew.attr('src') !== $contentOld.attr('src')) { 6706 updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6707 } else if (($contentNew.hasClass('wp-video') && $contentOld.is('iframe')) || ($contentNew.is('iframe') && $contentOld.hasClass('wp-video'))) { 6708 updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6709 } 6710 6711 if (updated && updated.content) { 6712 if ($contentNew.is('iframe')) { 6713 $target.closest('.et_pb_module').fitVids(); 6714 } else { 6715 var videoWidth = $contentNew.find('video').attr('width'); 6716 var videoHeight = $contentNew.find('video').attr('height'); 6717 var videContainerWidth = $target.width(); 6718 var videContainerHeight = (videContainerWidth / videoWidth) * videoHeight; 6719 6720 $target.find('video').mediaelementplayer({ 6721 videoWidth: parseInt(videContainerWidth), 6722 videoHeight: parseInt(videContainerHeight), 6723 autosizeProgress: false, 6724 success: function (mediaElement, domObject) { 6725 var $domObject = $(domObject); 6726 var videoMarginTop = (videContainerHeight - $domObject.height()) + $(mediaElement).height(); 6727 6728 $domObject.css('margin-top', videoMarginTop + 'px'); 6729 }, 6730 }); 6731 } 6732 } 6733 } else if ($target.is('img')) { 6734 var updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6735 6736 if (updated && updated.attrs && updated.attrs.src) { 6737 var $slider = $target.closest('.et_pb_module'); 6738 6739 $target.css('visibility', 'hidden'); 6740 6741 et_fix_slider_height($slider); 6742 6743 setTimeout(function () { 6744 et_fix_slider_height($slider); 6745 $target.css('visibility', 'visible'); 6746 }, 100); 6747 } 6748 } 6749 }, 6750 callbackHandlerVideo: function (data, $target, $source, slug) { 6751 if ($target.hasClass('et_pb_video_overlay')) { 6752 return et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6753 } 6754 6755 var updated = false; 6756 6757 var $contentNew = data && data.content ? $(data.content) : false; 6758 var $contentOld = $target.html().indexOf('fluid-width-video-wrapper') !== -1 6759 ? $($target.find('.fluid-width-video-wrapper').html()) 6760 : $($target.html()); 6761 6762 if (!$contentNew || !$contentOld) { 6763 return; 6764 } 6765 6766 if ($contentNew.is('video') && $contentOld.is('video')) { 6767 var isVideoNeedUpdate = function () { 6768 if ($contentNew.find('source').length !== $contentOld.find('source').length) { 6769 return true; 6770 } 6771 6772 var isDifferentAttr = false; 6773 6774 $contentNew.find('source').each(function (index) { 6775 var $contentOldSource = $contentOld.find('source').eq(index); 6776 6777 if ($(this).attr('src') !== $contentOldSource.attr('src')) { 6778 isDifferentAttr = true; 6779 } 6780 }); 6781 6782 return isDifferentAttr; 6783 }; 6784 6785 if (isVideoNeedUpdate()) { 6786 updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6787 } 6788 } else if ($contentNew.is('iframe') && $contentOld.is('iframe') && $contentNew.attr('src') !== $contentOld.attr('src')) { 6789 updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6790 } else if (($contentNew.is('video') && $contentOld.is('iframe')) || ($contentNew.is('iframe') && $contentOld.is('video'))) { 6791 updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6792 } 6793 6794 if (updated && updated.content) { 6795 if ($contentNew.is('iframe') && $.fn.fitVids) { 6796 $target.fitVids(); 6797 } 6798 } 6799 6800 return updated; 6801 }, 6802 callbackHandlerBlog: function (data, $target, $source, slug) { 6803 var updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6804 6805 if (updated && updated.classes && updated.classes.add && updated.classes.add.indexOf('et_pb_blog_show_content') !== -1) { 6806 et_reinit_waypoint_modules(); 6807 } 6808 }, 6809 callbackHandlerTestimonial: function (data, $target, $source, slug) { 6810 if (!$source.hasClass('et_pb_testimonial_description_inner')) { 6811 return et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6812 } 6813 6814 $.each($target.find('.et_pb_testimonial_author').prevAll(), function () { 6815 $(this).remove(); 6816 }); 6817 6818 $target.find('.et_pb_testimonial_author').before($(data.content)); 6819 6820 if (!$source.hasClass('et_multi_view_swapped')) { 6821 $source.addClass('et_multi_view_swapped'); 6822 } 6823 }, 6824 callbackHandlerWooCommerceBreadcrumb: function(data, $target, $source, slug) { 6825 if (data.content) { 6826 return et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6827 } 6828 if (data.attrs && data.attrs.hasOwnProperty('href')) { 6829 var hrefValue = data.attrs['href']; 6830 return et_multi_view.updateAttrs({href: hrefValue}, $target, $source); 6831 } 6832 }, 6833 callbackHandlerWooCommerceTabs: function(data, $target, $source, slug) { 6834 var updated = et_multi_view.callbackHandlerDefault(data, $target, $source, slug + '__faked'); 6835 6836 if (updated && updated.attrs && updated.attrs.hasOwnProperty('data-include_tabs')) { 6837 // Show only the enabled Tabs i.e. Hide all tabs and show as required. 6838 $target.find('li').hide(); 6839 $target.find('li').removeClass('et_pb_tab_active'); 6840 6841 var tabClasses = []; 6842 var include_tabs = updated.attrs['data-include_tabs'].split('|');
6843 include_tabs.forEach(function(elem) { 6844 if ('' === elem.trim()) { 6845 return; 6846 } 6847 tabClasses.push(elem + '_tab'); 6848 }); 6849 6850 tabClasses.forEach(function(elemClass, idx) { 6851 if (0 === idx) { 6852 $('.' + elemClass).addClass('et_pb_tab_active'); 6853 } 6854 $('.' + elemClass).show(); 6855 }); 6856 } 6857 }, 6858 getCallbackHandlerCustom: function (slug) { 6859 switch (slug) { 6860 case 'et_pb_counter': 6861 return et_multi_view.callbackHandlerCounter; 6862 6863 case 'et_pb_number_counter': 6864 return et_multi_view.callbackHandlerNumberCounter; 6865 6866 case 'et_pb_circle_counter': 6867 return et_multi_view.callbackHandlerCircleCounter; 6868 6869 case 'et_pb_slider': 6870 case 'et_pb_fullwidth_slider': 6871 return et_multi_view.callbackHandlerSlider; 6872 6873 case 'et_pb_post_slider': 6874 case 'et_pb_fullwidth_post_slider': 6875 return et_multi_view.callbackHandlerPostSlider; 6876 6877 case 'et_pb_video_slider': 6878 return et_multi_view.callbackHandlerVideoSlider; 6879 6880 case 'et_pb_slide': 6881 return et_multi_view.callbackHandlerSliderItem; 6882 6883 case 'et_pb_video': 6884 return et_multi_view.callbackHandlerVideo; 6885
6886 case 'et_pb_blog': 6887 return et_multi_view.callbackHandlerBlog; 6888 6889 case 'et_pb_testimonial': 6890 return et_multi_view.callbackHandlerTestimonial; 6891 6892 case 'et_pb_wc_breadcrumb': 6893 return et_multi_view.callbackHandlerWooCommerceBreadcrumb; 6894 case 'et_pb_wc_tabs': 6895 return et_multi_view.callbackHandlerWooCommerceTabs; 6896 6897 default: 6898 return false; 6899 } 6900 }, 6901 updateContent: function (content, $target, $source) { 6902 if (typeof content === 'undefined') { 6903 return false; 6904 } 6905 6906 var updated = false; 6907 6908 if ($target.html() !== content) { 6909 $target.empty().html(content); 6910 updated = true; 6911 } 6912 6913 if (updated && !$source.hasClass('et_multi_view_swapped')) { 6914 $source.addClass('et_multi_view_swapped'); 6915 } 6916 6917 return updated; 6918 }, 6919 updateAttrs: function (attrs, $target, $source) { 6920 if (!attrs) { 6921 return false; 6922 } 6923 6924 var updated = {}; 6925 6926 $.each(attrs, function (key, value) { 6927 switch (key) { 6928 case 'class': 6929 // Do nothing, use classes data contexts and updateClasses method instead. 6930 break; 6931 6932 case 'style': 6933 // Do nothing, use styles data contexts and updateStyles method instead. 6934 break; 6935 6936 default: 6937 if ($target.attr(key) !== value) { 6938 $target.attr(key, value); 6939 6940 if (key.indexOf('data-') === 0) { 6941 $target.data(key.replace('data-', ''), value); 6942 } 6943 6944 updated[key] = value; 6945 } 6946 break; 6947 } 6948 }); 6949 6950 if (et_multi_view.isEmptyObject(updated)) { 6951 return false; 6952 } 6953 6954 if (!$source.hasClass('et_multi_view_swapped')) { 6955 $source.addClass('et_multi_view_swapped'); 6956 } 6957 6958 return updated; 6959 }, 6960 updateStyles: function (styles, $target, $source) { 6961 if (!styles) { 6962 return false; 6963 } 6964 6965 var updated = {}; 6966 6967 $.each(styles, function (key, value) { 6968 if ($target.css(key) !== value) { 6969 $target.css(key, value); 6970 updated[key] = value; 6971 } 6972 }); 6973 6974 if (et_multi_view.isEmptyObject(updated)) { 6975 return false; 6976 } 6977 6978 if (!$source.hasClass('et_multi_view_swapped')) { 6979 $source.addClass('et_multi_view_swapped'); 6980 } 6981 6982 return updated; 6983 }, 6984 updateClasses: function (classes, $target, $source) { 6985 if (!classes) { 6986 return false; 6987 } 6988 6989 var updated = {}; 6990 6991 // Add CSS class 6992 if (classes.add) { 6993 for (var i = 0; i < classes.add.length; i++) {
6994 if (!$target.hasClass(classes.add[i])) { 6995 $target.addClass(classes.add[i]); 6996 6997 if (!updated.hasOwnProperty('add')) { 6998 updated.add = []; 6999 } 7000 updated.add.push(classes.add[i]); 7001 } 7002 } 7003 } 7004 7005 // Remove CSS class 7006 if (classes.remove) { 7007 for (var i = 0; i < classes.remove.length; i++) { 7008 if ($target.hasClass(classes.remove[i])) { 7009 $target.removeClass(classes.remove[i]); 7010 7011 if (!updated.hasOwnProperty('remove')) { 7012 updated.remove = []; 7013 } 7014 updated.remove.push(classes.remove[i]); 7015 } 7016 } 7017 } 7018 7019 if (et_multi_view.isEmptyObject(updated)) { 7020 return false; 7021 } 7022 7023 if (!$source.hasClass('et_multi_view_swapped')) { 7024 $source.addClass('et_multi_view_swapped'); 7025 } 7026 7027 return updated; 7028 }, 7029 updateVisibility: function (isVisible, $target, $source) { 7030 var updated = {}; 7031 7032 if (isVisible && $target.hasClass('et_multi_view_hidden')) { 7033 $target.removeClass('et_multi_view_hidden'); 7034 updated.isVisible = true; 7035 } 7036 7037 if (!isVisible && !$target.hasClass('et_multi_view_hidden')) { 7038 $target.addClass('et_multi_view_hidden'); 7039 updated.isHidden = true; 7040 } 7041 7042 if (et_multi_view.isEmptyObject(updated)) { 7043 return false; 7044 } 7045 7046 if (!$source.hasClass('et_multi_view_swapped')) { 7047 $source.addClass('et_multi_view_swapped'); 7048 } 7049 7050 return updated; 7051 }, 7052 isEmptyObject: function (obj) { 7053 if (!obj) { 7054 return true; 7055 } 7056 7057 var isEmpty = true; 7058 7059 for (var key in obj) { 7060 if (obj.hasOwnProperty(key)) { 7061 isEmpty = false; 7062 } 7063 } 7064 7065 return isEmpty; 7066 }, 7067 tryParseJSON: function (string) { 7068 try { 7069 return JSON.parse(string); 7070 } catch (e) { 7071 return false; 7072 } 7073 }, 7074 getScreenMode: function () { 7075 var screenMode; 7076 7077 if (et_multi_view.windowWidth > 980) { 7078 screenMode = 'desktop'; 7079 } else if (et_multi_view.windowWidth > 767) { 7080 screenMode = 'tablet'; 7081 } else { 7082 screenMode = 'phone'; 7083 } 7084 7085 return screenMode; 7086 }, 7087 }; 7088 7089 if (!isBuilder) { 7090 $(document).ready(et_multi_view.init); 7091 7092 var et_multi_view_timer = null; 7093 $(window).on('resize', function () { 7094 // Make sure only to run this when the actual window size width is changed 7095 var resizedWindowWidth = $(window).width(); 7096 7097 if (resizedWindowWidth === et_multi_view.windowWidth) { 7098 return; 7099 } 7100 7101 et_multi_view.windowWidth = resizedWindowWidth; 7102 7103 clearTimeout(et_multi_view_timer); 7104 7105 et_multi_view_timer = setTimeout(et_multi_view.init, 300); 7106 }); 7107 } 7108})(jQuery);
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.