1/*! ET frontend-builder-scripts.js */ 2(function($){ 3 var $et_window = $(window); 4 5 window.et_load_event_fired = false; 6 window.et_is_transparent_nav = $( 'body' ).hasClass( 'et_transparent_nav' ); 7 window.et_is_vertical_nav = $( 'body' ).hasClass( 'et_vertical_nav' ); 8 window.et_is_fixed_nav = $( 'body' ).hasClass( 'et_fixed_nav' ); 9 window.et_is_minified_js = $( 'body' ).hasClass( 'et_minified_js' ); 10 window.et_is_minified_css = $( 'body' ).hasClass( 'et_minified_css' ); 11 window.et_force_width_container_change = false; 12 13 jQuery.fn.reverse = [].reverse; 14 15 jQuery.fn.closest_descendent = function( selector ) { 16 var $found, 17 $current_children = this.children(); 18 19 while ( $current_children.length ) { 20 $found = $current_children.filter( selector ); 21 if ( $found.length ) { 22 break; 23 } 24 $current_children = $current_children.children(); 25 } 26 27 return $found; 28 }; 29 30 window.et_pb_init_modules = function() { 31 $.et_pb_simple_slider = function(el, options) { 32 var settings = $.extend( { 33 slide : '.et-slide', // slide class 34 arrows : '.et-pb-slider-arrows', // arrows container class 35 prev_arrow : '.et-pb-arrow-prev', // left arrow class 36 next_arrow : '.et-pb-arrow-next', // right arrow class 37 controls : '.et-pb-controllers a', // control selector 38 carousel_controls : '.et_pb_carousel_item', // carousel control selector 39 control_active_class : 'et-pb-active-control', // active control class name 40 previous_text : et_pb_custom.previous, // previous arrow text 41 next_text : et_pb_custom.next, // next arrow text 42 fade_speed : 500, // fade effect speed 43 use_arrows : true, // use arrows? 44 use_controls : true, // use controls? 45 manual_arrows : '', // html code for custom arrows 46 append_controls_to : '', // controls are appended to the slider element by default, here you can specify the element it should append to 47 controls_below : false, 48 controls_class : 'et-pb-controllers', // controls container class name 49 slideshow : false, // automattic animation? 50 slideshow_speed : 7000, // automattic animation speed 51 show_progress_bar : false, // show progress bar if automattic animation is active 52 tabs_animation : false, 53 use_carousel : false 54 }, options ); 55 56 var $et_slider = $(el), 57 $et_slide = $et_slider.closest_descendent( settings.slide ), 58 et_slides_number = $et_slide.length, 59 et_fade_speed = settings.fade_speed, 60 et_active_slide = 0, 61 $et_slider_arrows, 62 $et_slider_prev, 63 $et_slider_next, 64 $et_slider_controls, 65 $et_slider_carousel_controls, 66 et_slider_timer, 67 controls_html = '', 68 carousel_html = '', 69 $progress_bar = null, 70 progress_timer_count = 0, 71 $et_pb_container = $et_slider.find( '.et_pb_container' ), 72 et_pb_container_width = $et_pb_container.width(), 73 is_post_slider = $et_slider.hasClass( 'et_pb_post_slider' ); 74 75 $et_slider.et_animation_running = false; 76 77 $.data(el, "et_pb_simple_slider", $et_slider); 78 79 $et_slide.eq(0).addClass( 'et-pb-active-slide' ); 80 81 if ( ! settings.tabs_animation ) { 82 if ( !$et_slider.hasClass('et_pb_bg_layout_dark') && !$et_slider.hasClass('et_pb_bg_layout_light') ) { 83 $et_slider.addClass( et_get_bg_layout_color( $et_slide.eq(0) ) ); 84 } 85 } 86 87 if ( settings.use_arrows && et_slides_number > 1 ) { 88 if ( settings.manual_arrows == '' ) 89 $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>' ); 90 else 91 $et_slider.append( settings.manual_arrows ); 92 93 $et_slider_arrows = $et_slider.find( settings.arrows ); 94 $et_slider_prev = $et_slider.find( settings.prev_arrow ); 95 $et_slider_next = $et_slider.find( settings.next_arrow ); 96 97 $et_slider.on( 'click.et_pb_simple_slider', settings.next_arrow, function() { 98 if ( $et_slider.et_animation_running ) return false;
99 100 $et_slider.et_slider_move_to( 'next' ); 101 102 return false; 103 } ); 104 105 $et_slider.on( 'click.et_pb_simple_slider', settings.prev_arrow, function() { 106 if ( $et_slider.et_animation_running ) return false; 107 108 $et_slider.et_slider_move_to( 'previous' ); 109 110 return false; 111 } ); 112 113 // swipe support requires et-jquery-touch-mobile 114 $et_slider.on( 'swipeleft.et_pb_simple_slider', settings.slide, function( event ) { 115 // do not switch slide on selecting text in VB 116 if ( $( event.target ).closest( '.et-fb-popover-tinymce' ).length || $( event.target ).closest( '.et-fb-editable-element' ).length ) { 117 return; 118 } 119 120 $et_slider.et_slider_move_to( 'next' ); 121 }); 122 $et_slider.on( 'swiperight.et_pb_simple_slider', settings.slide, function( event ) { 123 // do not switch slide on selecting text in VB 124 if ( $( event.target ).closest( '.et-fb-popover-tinymce' ).length || $( event.target ).closest( '.et-fb-editable-element' ).length ) { 125 return; 126 } 127 128 $et_slider.et_slider_move_to( 'previous' ); 129 }); 130 } 131 132 if ( settings.use_controls && et_slides_number > 1 ) { 133 for ( var i = 1; i <= et_slides_number; i++ ) { 134 controls_html += '<a href="#"' + ( i == 1 ? ' class="' + settings.control_active_class + '"' : '' ) + '>
134' + i + '</a>'; 135 } 136 137 if ($et_slider.find('video').length > 0) { 138 settings.controls_class += ' et-pb-controllers-has-video-tag'; 139 } 140 141 controls_html = 142 '<div class="' + settings.controls_class + '">' + 143 controls_html + 144 '</div>'; 145 146 if ( settings.append_controls_to == '' ) 147 $et_slider.append( controls_html ); 148 else 149 $( settings.append_controls_to ).append( controls_html ); 150 151 if ( settings.controls_below ) 152 $et_slider_controls = $et_slider.parent().find( settings.controls ); 153 else 154 $et_slider_controls = $et_slider.find( settings.controls ); 155 156 $et_slider_controls.on( 'click.et_pb_simple_slider', function () { 157 if ( $et_slider.et_animation_running ) return false; 158 159 $et_slider.et_slider_move_to( $(this).index() ); 160 161 return false; 162 } ); 163 } 164 165 et_maybe_set_controls_color( $et_slide.eq(0) ); 166 167 if ( settings.use_carousel && et_slides_number > 1 ) { 168 for ( var i = 1; i <= et_slides_number; i++ ) { 169 slide_id = i - 1; 170 image_src = ( $et_slide.eq(slide_id).data('image') !== undefined ) ? 'url(' + $et_slide.eq(slide_id).data('image') + ')' : 'none'; 171 carousel_html += '<div class="et_pb_carousel_item ' + ( i == 1 ? settings.control_active_class : '' ) + '" data-slide-id="'+ slide_id +'">' + 172 '<div class="et_pb_video_overlay" href="#" style="background-image: ' + image_src + ';">' + 173 '<div class="et_pb_video_overlay_hover"><a href="#" class="et_pb_video_play"></a></div>' + 174 '</div>' + 175 '</div>'; 176 } 177 178 carousel_html = 179 '<div class="et_pb_carousel">' + 180 '<div class="et_pb_carousel_items">' + 181 carousel_html + 182 '</div>' + 183 '</div>'; 184 $et_slider.after( carousel_html ); 185 186 $et_slider_carousel_controls = $et_slider.siblings('.et_pb_carousel').find( settings.carousel_controls ); 187 $et_slider_carousel_controls.on( 'click.et_pb_simple_slider', function() { 188 if ( $et_slider.et_animation_running ) return false; 189 190 var $this = $(this); 191 $et_slider.et_slider_move_to( $this.data('slide-id') ); 192 193 return false; 194 } ); 195 } 196 197 if ( settings.slideshow && et_slides_number > 1 ) { 198 $et_slider.on( 'mouseenter.et_pb_simple_slider', function() { 199 if ( $et_slider.hasClass( 'et_slider_auto_ignore_hover' ) ) { 200 return; 201 } 202 203 $et_slider.addClass( 'et_slider_hovered' ); 204 205 if ( typeof et_slider_timer != 'undefined' ) { 206 clearInterval( et_slider_timer ); 207 } 208 }).on( 'mouseleave.et_pb_simple_slider', function() { 209 if ( $et_slider.hasClass( 'et_slider_auto_ignore_hover' ) ) { 210 return; 211 } 212 213 $et_slider.removeClass( 'et_slider_hovered' ); 214 215 et_slider_auto_rotate(); 216 } ); 217 } 218 219 et_slider_auto_rotate(); 220 221 function et_slider_auto_rotate(){ 222 if ( settings.slideshow && et_slides_number > 1 && ! $et_slider.hasClass( 'et_slider_hovered' ) ) { 223 et_slider_timer = setTimeout( function() { 224 $et_slider.et_slider_move_to( 'next' ); 225 }, settings.slideshow_speed ); 226 } 227 } 228 229 $et_slider.et_slider_destroy = function() { 230 // Clear existing timer / auto rotate 231 if ( typeof et_slider_timer != 'undefined' ) { 232 clearInterval( et_slider_timer ); 233 } 234 235 // Deregister all own existing events 236 $et_slider.off( '.et_pb_simple_slider' ); 237 238 // Removing existing style from slide(s) 239 $et_slider.find('.et_pb_slide').css({ 240 'z-index': '', 241 'display': '', 242 'opacity': '', 243 }); 244 245 // Removing existing classnames from slide(s) 246 $et_slider.find('.et-pb-active-slide').removeClass('et-pb-active-slide'); 247 $et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide'); 248 249 // Removing DOM that was added by slider 250 $et_slider.find('.et-pb-slider-arrows, .et-pb-controllers').remove(); 251 $et_slider.siblings('.et_pb_carousel').remove(); 252 253 // Remove references 254 $et_slider.removeData( 'et_pb_simple_slider' ); 255 }; 256 257 function et_stop_video( active_slide ) { 258 var $et_video, et_video_src; 259 260 // if there is a video in the slide, stop it when switching to another slide 261 if ( active_slide.has( 'iframe' ).length ) {
262 $et_video = active_slide.find( 'iframe' ); 263 et_video_src = $et_video.attr( 'src' ); 264 265 $et_video.attr( 'src', '' ); 266 $et_video.attr( 'src', et_video_src ); 267 268 } else if ( active_slide.has( 'video' ).length ) { 269 if ( !active_slide.find('.et_pb_section_video_bg').length ) { 270 $et_video = active_slide.find( 'video' ); 271 $et_video[0].pause(); 272 } 273 } 274 } 275 276 $et_slider.et_fix_slider_content_images = et_fix_slider_content_images; 277 278 function et_fix_slider_content_images() { 279 var $this_slider = $et_slider, 280 $slide_image_container = $this_slider.find( '.et-pb-active-slide .et_pb_slide_image' ), 281 $slide_video_container = $this_slider.find( '.et-pb-active-slide .et_pb_slide_video' ), 282 $slide = $slide_image_container.closest( '.et_pb_slide' ), 283 $slider = $slide.closest( '.et_pb_slider' ), 284 slide_height = parseFloat( $slider.innerHeight() ), 285 image_height = parseFloat( slide_height * 0.8 ), 286 slide_image_container_height = parseFloat( $slide_image_container.height() ), 287 slide_video_container_height = parseFloat( $slide_video_container.height() ); 288 289 if ( ! isNaN( image_height ) ) { 290 $slide_image_container.find( 'img' ).css( 'maxHeight', image_height + 'px' ); 291 292 slide_image_container_height = parseInt( $slide_image_container.height() ) 293 } 294 295 if ( ! isNaN( slide_image_container_height ) && $slide.hasClass( 'et_pb_media_alignment_center' ) ) { 296 $slide_image_container.css( 'marginTop', '-' + ( slide_image_container_height / 2 ) + 'px' ); 297 } 298 299 if ( ! isNaN( slide_video_container_height ) ) { 300 $slide_video_container.css( 'marginTop', '-' + ( slide_video_container_height / 2 ) + 'px' ); 301 } 302 } 303 304 function et_get_bg_layout_color( $slide ) { 305 if ( $slide.hasClass( 'et_pb_bg_layout_light' ) ) { 306 return 'et_pb_bg_layout_light'; 307 } 308 309 return 'et_pb_bg_layout_dark'; 310 } 311 312 function et_maybe_set_controls_color( $slide ) { 313 var next_slide_dot_color, 314 $arrows, 315 arrows_color; 316 317 if ( typeof $et_slider_controls !== 'undefined' && $et_slider_controls.length ) { 318 next_slide_dot_color = $slide.attr( 'data-dots_color' ) || ''; 319 320 if ( next_slide_dot_color !== '' ) { 321 $et_slider_controls.attr( 'style', 'background-color: ' + hex_to_rgba( next_slide_dot_color, '0.3' ) + ';' ); 322 $et_slider_controls.filter( '.et-pb-active-control' ).attr( 'style', 'background-color: ' + hex_to_rgba( next_slide_dot_color ) + '!important;' ); 323 } else { 324 $et_slider_controls.removeAttr( 'style' ); 325 } 326 } 327 328 if ( typeof $et_slider_arrows !== 'undefined' && $et_slider_arrows.length ) { 329 $arrows = $et_slider_arrows.find( 'a' ); 330 arrows_color = $slide.attr( 'data-arrows_color' ) || ''; 331 332 if ( arrows_color !== '' ) { 333 $arrows.attr( 'style', 'color: ' + arrows_color + '!important;' ); 334 } else { 335 $arrows.css( 'color', 'inherit' ); 336 } 337 } 338 } 339 340 // fix the appearance of some modules inside the post slider 341 function et_fix_builder_content() { 342 if ( is_post_slider ) { 343 setTimeout( function() { 344 var $et_pb_circle_counter = $( '.et_pb_circle_counter' ), 345 $et_pb_number_counter = $( '.et_pb_number_counter' ); 346 347 window.et_fix_testimonial_inner_width(); 348 349 if ( $et_pb_circle_counter.length ) { 350 window.et_pb_reinit_circle_counters( $et_pb_circle_counter ); 351 } 352 353 if ( $et_pb_number_counter.length ) { 354 window.et_pb_reinit_number_counters( $et_pb_number_counter ); 355 } 356 window.et_reinit_waypoint_modules(); 357 }, 1000 ); 358 } 359 } 360 361 function hex_to_rgba( color, alpha ) { 362 var color_16 = parseInt( color.replace( '#', '' ), 16 ), 363 red = ( color_16 >> 16 ) & 255, 364 green = ( color_16 >> 8 ) & 255, 365 blue = color_16 & 255, 366 alpha = alpha || 1, 367 rgba; 368 369 rgba = red + ',' + green + ',' + blue + ',' + alpha; 370 rgba = 'rgba(' + rgba + ')'; 371 372 return rgba; 373 } 374 375 if ( window.et_load_event_fired ) { 376 et_fix_slider_height( $et_slider ); 377 } else { 378 $et_window.on( 'load', function() { 379 et_fix_slider_height( $et_slider ); 380 } ); 381 } 382 383 $et_window.on( 'resize.et_simple_slider', function() { 384 et_fix_slider_height( $et_slider ); 385 } ); 386 387 $et_slider.et_slider_move_to = function ( direction ) { 388 var $active_slide = $et_slide.eq( et_active_slide ); 389 390 $et_slider.et_animation_running = true; 391 392 $et_slider.removeClass('et_slide_transition_to_next et_slide_transition_to_previous').addClass('et_slide_transition_to_' + direction ); 393 394 $et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide'); 395 396 if ( direction == 'next' || direction == 'previous' ){ 397 398 if ( direction == 'next' ) 399 et_active_slide = ( et_active_slide + 1 ) < et_slides_number ? et_active_slide + 1 : 0; 400 else 401 et_active_slide = ( et_active_slide - 1 ) >= 0 ? et_active_slide - 1 : et_slides_number - 1; 402 403 } else { 404 405 if ( et_active_slide == direction ) { 406 $et_slider.et_animation_running = false;
407 return; 408 } 409 410 et_active_slide = direction; 411 412 } 413 414 if ( typeof et_slider_timer != 'undefined' ) 415 clearInterval( et_slider_timer ); 416 417 var $next_slide = $et_slide.eq( et_active_slide ); 418 419 $et_slider.trigger('slide', {current: $active_slide, next: $next_slide}); 420 421 if ( typeof $active_slide.find('video')[0] !== 'undefined' && typeof $active_slide.find('video')[0]['player'] !== 'undefined' ) { 422 $active_slide.find('video')[0].player.pause(); 423 } 424 425 if ( typeof $next_slide.find('video')[0] !== 'undefined' && typeof $next_slide.find('video')[0]['player'] !== 'undefined' ) { 426 $next_slide.find('video')[0].player.play(); 427 } 428 429 var $active_slide_video = $active_slide.find('.et_pb_video_box iframe'); 430 431 if ( $active_slide_video.length ) { 432 var active_slide_video_src = $active_slide_video.attr('src'); 433 434 // Removes the "autoplay=1" parameter when switching slides 435 // by covering three possible cases: 436 437 // "?autoplay=1" at the end of the URL 438 active_slide_video_src = active_slide_video_src.replace(/\?autoplay=1$/, ''); 439 440 // "?autoplay=1" followed by another parameter 441 active_slide_video_src = active_slide_video_src.replace(/\?autoplay=1&(amp;)?/, '?'); 442 443 // "&autoplay=1" anywhere in the URL 444 active_slide_video_src = active_slide_video_src.replace(/&(amp;)?autoplay=1/, ''); 445 446 // Delays the URL update so that the cross-fade animation's smoothness is not affected 447 setTimeout(function() { 448 $active_slide_video.attr({ 449 'src': active_slide_video_src 450 }); 451 }, settings.fade_speed); 452 453 // Restores video overlay 454 $active_slide_video.parents('.et_pb_video_box').next('.et_pb_video_overlay').css({ 455 'display' : 'block', 456 'opacity' : 1 457 }); 458 } 459 460 $et_slider.trigger( 'simple_slider_before_move_to', { direction : direction, next_slide : $next_slide }); 461 462 $et_slide.each( function(){ 463 $(this).css( 'zIndex', 1 ); 464 } ); 465 // add 'slide-status' data attribute so it can be used to determine active slide in Visual Builder 466 $active_slide.css( 'zIndex', 2 ).removeClass( 'et-pb-active-slide' ).addClass('et-pb-moved-slide').data('slide-status', 'inactive'); 467 $next_slide.css( { 'display' : 'block', opacity : 0 } ).addClass( 'et-pb-active-slide' ).data('slide-status', 'active'); 468 469 et_fix_slider_content_images(); 470 471 et_fix_builder_content(); 472 473 if ( settings.use_controls ) 474 $et_slider_controls.removeClass( settings.control_active_class ).eq( et_active_slide ).addClass( settings.control_active_class ); 475 476 if ( settings.use_carousel && $et_slider_carousel_controls ) 477 $et_slider_carousel_controls.removeClass( settings.control_active_class ).eq( et_active_slide ).addClass( settings.control_active_class ); 478 479 if ( ! settings.tabs_animation ) { 480 et_maybe_set_controls_color( $next_slide ); 481 482 $next_slide.animate( { opacity : 1 }, et_fade_speed ); 483 $active_slide.addClass( 'et_slide_transition' ).css( { 'display' : 'list-item', 'opacity' : 1 } ).animate( { opacity : 0 }, et_fade_speed, function(){ 484 var active_slide_layout_bg_color = et_get_bg_layout_color( $active_slide ), 485 next_slide_layout_bg_color = et_get_bg_layout_color( $next_slide ); 486 487 $(this).css('display', 'none').removeClass( 'et_slide_transition' ); 488 489 et_stop_video( $active_slide ); 490 491 $et_slider 492 .removeClass( active_slide_layout_bg_color ) 493 .addClass( next_slide_layout_bg_color ); 494 495 $et_slider.et_animation_running = false; 496 497 $et_slider.trigger( 'simple_slider_after_move_to', { next_slide : $next_slide } ); 498 } ); 499 } else { 500 $next_slide.css( { 'display' : 'none', opacity : 0 } ); 501 502 $active_slide.addClass( 'et_slide_transition' ).css( { 'display' : 'block', 'opacity' : 1 } ).animate( { opacity : 0 }, et_fade_speed, function(){ 503 $(this).css('display', 'none').removeClass( 'et_slide_transition' ); 504 505 $next_slide.css( { 'display' : 'block', 'opacity' : 0 } ).animate( { opacity : 1 }, et_fade_speed, function() { 506 $et_slider.et_animation_running = false;
507 508 $et_slider.trigger( 'simple_slider_after_move_to', { next_slide : $next_slide } ); 509 } ); 510 } ); 511 } 512 513 if ( $next_slide.find( '.et_parallax_bg' ).length ) { 514 // reinit parallax on slide change to make sure it displayed correctly 515 window.et_pb_parallax_init( $next_slide.find( '.et_parallax_bg' ) ); 516 } 517 518 et_slider_auto_rotate(); 519 } 520 }; 521 522 $.fn.et_pb_simple_slider = function( options ) { 523 return this.each(function() { 524 var slider = $.data( this, 'et_pb_simple_slider' ); 525 return slider ? slider : new $.et_pb_simple_slider( this, options ); 526 }); 527 }; 528 529 var et_hash_module_seperator = '||', 530 et_hash_module_param_seperator = '|'; 531 532 function process_et_hashchange( hash ) { 533 if ( ( hash.indexOf( et_hash_module_seperator, 0 ) ) !== -1 ) { 534 modules = hash.split( et_hash_module_seperator ); 535 for ( var i = 0; i < modules.length; i++ ) { 536 var module_params = modules[i].split( et_hash_module_param_seperator ); 537 var element = module_params[0]; 538 module_params.shift(); 539 if ( $('#' + element ).length ) { 540 $('#' + element ).trigger({ 541 type: "et_hashchange", 542 params: module_params 543 }); 544 } 545 } 546 } else { 547 module_params = hash.split( et_hash_module_param_seperator ); 548 var element = module_params[0]; 549 module_params.shift(); 550 if ( $('#' + element ).length ) { 551 $('#' + element ).trigger({ 552 type: "et_hashchange", 553 params: module_params 554 }); 555 } 556 } 557 } 558 559 function et_set_hash( module_state_hash ) { 560 module_id = module_state_hash.split( et_hash_module_param_seperator )[0]; 561 if ( !$('#' + module_id ).length ) { 562 return; 563 } 564 565 if ( window.location.hash ) { 566 var hash = window.location.hash.substring(1), //Puts hash in variable, and removes the # character 567 new_hash = []; 568 569 if ( ( hash.indexOf( et_hash_module_seperator, 0 ) ) !== -1 ) { 570 modules = hash.split( et_hash_module_seperator ); 571 var in_hash = false; 572 for ( var i = 0; i < modules.length; i++ ) { 573 var element = modules[i].split( et_hash_module_param_seperator )[0]; 574 if ( element === module_id ) { 575 new_hash.push( module_state_hash ); 576 in_hash = true; 577 } else { 578 new_hash.push( modules[i] ); 579 } 580 } 581 if ( !in_hash ) { 582 new_hash.push( module_state_hash ); 583 } 584 } else { 585 module_params = hash.split( et_hash_module_param_seperator ); 586 var element = module_params[0]; 587 if ( element !== module_id ) { 588 new_hash.push( hash ); 589 } 590 new_hash.push( module_state_hash ); 591 } 592 593 hash = new_hash.join( et_hash_module_seperator ); 594 } else { 595 hash = module_state_hash; 596 } 597 598 var yScroll = document.body.scrollTop; 599 window.location.hash = hash; 600 document.body.scrollTop = yScroll; 601 } 602 603 $.et_pb_simple_carousel = function(el, options) { 604 var settings = $.extend( { 605 slide_duration : 500, 606 }, options ); 607 608 var $et_carousel = $(el), 609 $carousel_items = $et_carousel.find('.et_pb_carousel_items'), 610 $the_carousel_items = $carousel_items.find('.et_pb_carousel_item'); 611 612 $et_carousel.et_animation_running = false; 613 614 $et_carousel.addClass('container-width-change-notify').on('containerWidthChanged', function( event ){ 615 set_carousel_columns( $et_carousel ); 616 set_carousel_height( $et_carousel ); 617 }); 618 619 $carousel_items.data('items', $the_carousel_items.toArray() ); 620 $et_carousel.data('columns_setting_up', false ); 621 622 $carousel_items.prepend('<div class="et-pb-slider-arrows"><a class="et-pb-slider-arrow et-pb-arrow-prev" href="#">' + '<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>'); 623 624 set_carousel_columns( $et_carousel ); 625 set_carousel_height( $et_carousel ); 626 627 $et_carousel_next = $et_carousel.find( '.et-pb-arrow-next' ); 628 $et_carousel_prev = $et_carousel.find( '.et-pb-arrow-prev' ); 629 630 $et_carousel.on( 'click', '.et-pb-arrow-next', function(){ 631 if ( $et_carousel.et_animation_running ) return false; 632 633 $et_carousel.et_carousel_move_to( 'next' ); 634 635 return false;
636 } ); 637 638 $et_carousel.on( 'click', '.et-pb-arrow-prev', function(){ 639 if ( $et_carousel.et_animation_running ) return false; 640 641 $et_carousel.et_carousel_move_to( 'previous' ); 642 643 return false; 644 } ); 645 646 // swipe support requires et-jquery-touch-mobile 647 $et_carousel.on( 'swipeleft', function() { 648 $et_carousel.et_carousel_move_to( 'next' ); 649 }); 650 $et_carousel.on( 'swiperight', function() { 651 $et_carousel.et_carousel_move_to( 'previous' ); 652 }); 653 654 function set_carousel_height( $the_carousel ) { 655 var carousel_items_width = $the_carousel_items.width(), 656 carousel_items_height = $the_carousel_items.height(); 657 658 // Account for borders when needed 659 if ($the_carousel.parent().hasClass('et_pb_with_border')) { 660 carousel_items_height = $the_carousel_items.outerHeight(); 661 } 662 $carousel_items.css('height', carousel_items_height + 'px' ); 663 } 664 665 function set_carousel_columns( $the_carousel ) { 666 var columns, 667 $carousel_parent = $the_carousel.parents('.et_pb_column'), 668 carousel_items_width = $carousel_items.width(), 669 carousel_item_count = $the_carousel_items.length; 670 671 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') ) { 672 if ( $et_window.width() < 768 ) { 673 columns = 3; 674 } else { 675 columns = 4; 676 } 677 } else if ( $carousel_parent.hasClass('et_pb_column_1_2') || $carousel_parent.hasClass('et_pb_column_3_8') || $carousel_parent.hasClass('et_pb_column_1_3') ) { 678 columns = 3; 679 } else if ( $carousel_parent.hasClass('et_pb_column_1_4') ) { 680 if ( $et_window.width() > 480 && $et_window.width() < 980 ) { 681 columns = 3; 682 } else { 683 columns = 2; 684 } 685 } 686 687 if ( columns === $carousel_items.data('portfolio-columns') ) { 688 return; 689 } 690 691 if ( $the_carousel.data('columns_setting_up') ) { 692 return; 693 } 694 695 $the_carousel.data('columns_setting_up', true ); 696 697 // store last setup column 698 $carousel_items.removeClass('columns-' + $carousel_items.data('portfolio-columns') ); 699 $carousel_items.addClass('columns-' + columns ); 700 $carousel_items.data('portfolio-columns', columns ); 701 702 // kill all previous groups to get ready to re-group 703 if ( $carousel_items.find('.et-carousel-group').length ) { 704 $the_carousel_items.appendTo( $carousel_items ); 705 $carousel_items.find('.et-carousel-group').remove(); 706 } 707 708 // setup the grouping 709 var the_carousel_items = $carousel_items.data('items'), 710 $carousel_group = $('<div class="et-carousel-group active">').appendTo( $carousel_items ); 711 712 $the_carousel_items.data('position', ''); 713 if ( the_carousel_items.length <= columns ) { 714 $carousel_items.find('.et-pb-slider-arrows').hide(); 715 } else { 716 $carousel_items.find('.et-pb-slider-arrows').show(); 717 } 718 719 for ( position = 1, x=0 ;x < the_carousel_items.length; x++, position++ ) { 720 if ( x < columns ) { 721 $( the_carousel_items[x] ).show(); 722 $( the_carousel_items[x] ).appendTo( $carousel_group ); 723 $( the_carousel_items[x] ).data('position', position ); 724 $( the_carousel_items[x] ).addClass('position_' + position ); 725 } else { 726 position = $( the_carousel_items[x] ).data('position'); 727 $( the_carousel_items[x] ).removeClass('position_' + position ); 728 $( the_carousel_items[x] ).data('position', '' ); 729 $( the_carousel_items[x] ).hide(); 730 } 731 } 732 733 $the_carousel.data('columns_setting_up', false ); 734 735 } /* end set_carousel_columns() */ 736 737 $et_carousel.et_carousel_move_to = function ( direction ) { 738 var $active_carousel_group = $carousel_items.find('.et-carousel-group.active'), 739 items = $carousel_items.data('items'), 740 columns = $carousel_items.data('portfolio-columns'); 741 742 $et_carousel.et_animation_running = true; 743 744 var left = 0; 745 $active_carousel_group.children().each(function(){ 746 $(this).css({'position':'absolute', 'left': left }); 747 left = left + $(this).outerWidth(true); 748 }); 749 750 // Avoid unwanted horizontal scroll on body when carousel is slided 751 $('body').addClass('et-pb-is-sliding-carousel'); 752 753 // Deterimine number of carousel group item 754 var carousel_group_item_size = $active_carousel_group.find('.et_pb_carousel_item').size(); 755 var carousel_group_item_progress = 0; 756 757 if ( direction == 'next' ) { 758 var $next_carousel_group, 759 current_position = 1, 760 next_position = 1, 761 active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ), 762 active_items_end = active_items_start + columns, 763 next_items_start = active_items_end, 764 next_items_end = next_items_start + columns; 765 766 $next_carousel_group = $('<div class="et-carousel-group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group ); 767 $next_carousel_group.css({ 'width': $active_carousel_group.innerWidth() }).show(); 768 769 // this is an endless loop, so it can decide internally when to break out, so that next_position 770 // can get filled up, even to the extent of an element having both and current_ and next_ position 771 for( x = 0, total = 0 ; ; x++, total++ ) { 772 if ( total >= active_items_start && total < active_items_end ) { 773 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 774 $( items[x] ).data('current_position', current_position ); 775 current_position++; 776 } 777 778 if ( total >= next_items_start && total < next_items_end ) { 779 $( items[x] ).data('next_position', next_position ); 780 $( items[x] ).addClass('changing_position next_position next_position_' + next_position ); 781 782 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 783 $( items[x] ).addClass('container_append'); 784 } else { 785 $( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 786 $( items[x] ).addClass('delayed_container_append'); 787 } 788 789 next_position++; 790 } 791 792 if ( next_position > columns ) { 793 break; 794 } 795 796 if ( x >= ( items.length -1 )) { 797 x = -1; 798 } 799 } 800 801 var sorted = $carousel_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 802 var el_a_position = parseInt( $(a).data('next_position') ); 803 var el_b_position = parseInt( $(b).data('next_position') ); 804 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 805 }); 806 807 $( sorted ).show().appendTo( $next_carousel_group ); 808 809 var left = 0; 810 $next_carousel_group.children().each(function(){ 811 $(this).css({'position':'absolute', 'left': left }); 812 left = left + $(this).outerWidth(true); 813 }); 814 815 $active_carousel_group.animate({ 816 left: '-100%' 817 }, {
818 duration: settings.slide_duration, 819 progress: function(animation, progress) { 820 if (progress > (carousel_group_item_progress/carousel_group_item_size)) { 821 carousel_group_item_progress++; 822 823 // Adding classnames on incoming/outcoming carousel item 824 $active_carousel_group.find('.et_pb_carousel_item:nth-child(' + carousel_group_item_progress + ')').addClass('item-fade-out'); 825 $next_carousel_group.find('.et_pb_carousel_item:nth-child(' + carousel_group_item_progress + ')').addClass('item-fade-in'); 826 } 827 }, 828 complete: function() { 829 $carousel_items.find('.delayed_container_append').each(function(){ 830 left = $( '#' + $(this).attr('id') + '-dup' ).css('left'); 831 $(this).css({'position':'absolute', 'left': left }); 832 $(this).appendTo( $next_carousel_group ); 833 }); 834 835 $active_carousel_group.removeClass('active'); 836 $active_carousel_group.children().each(function(){ 837 position = $(this).data('position'); 838 current_position = $(this).data('current_position'); 839 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 840 $(this).data('position', ''); 841 $(this).data('current_position', ''); 842 $(this).hide(); 843 $(this).css({'position': '', 'left': ''}); 844 $(this).appendTo( $carousel_items ); 845 }); 846 847 // Removing classnames on incoming/outcoming carousel item 848 $carousel_items.find('.item-fade-out').removeClass('item-fade-out'); 849 $next_carousel_group.find('.item-fade-in').removeClass('item-fade-in'); 850 851 // Remove horizontal scroll prevention class name on body 852 $('body').removeClass('et-pb-is-sliding-carousel'); 853 854 $active_carousel_group.remove(); 855 856 } 857 } ); 858 859 next_left = $active_carousel_group.width() + parseInt( $the_carousel_items.first().css('marginRight').slice(0, -2) ); 860 $next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: next_left }); 861 $next_carousel_group.animate({ 862 left: '0%' 863 }, { 864 duration: settings.slide_duration, 865 complete: function(){ 866 $next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''}); 867 868 $next_carousel_group.find('.changing_position').each(function( index ){ 869 position = $(this).data('position'); 870 current_position = $(this).data('current_position'); 871 next_position = $(this).data('next_position'); 872 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position ); 873 $(this).data('current_position', ''); 874 $(this).data('next_position', ''); 875 $(this).data('position', ( index + 1 ) ); 876 }); 877 878 $next_carousel_group.children().css({'position': '', 'left': ''}); 879 $next_carousel_group.find('.delayed_container_append_dup').remove(); 880 881 $et_carousel.et_animation_running = false; 882 } 883 } ); 884 885 } else if ( direction == 'previous' ) { 886 var $prev_carousel_group, 887 current_position = columns, 888 prev_position = columns, 889 columns_span = columns - 1, 890 active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ), 891 active_items_end = active_items_start - columns_span, 892 prev_items_start = active_items_end - 1, 893 prev_items_end = prev_items_start - columns_span; 894 895 $prev_carousel_group = $('<div class="et-carousel-group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group ); 896 $prev_carousel_group.css({ 'left': '-' + $active_carousel_group.innerWidth(), 'width': $active_carousel_group.innerWidth() }).show(); 897 898 // this is an endless loop, so it can decide internally when to break out, so that next_position 899 // can get filled up, even to the extent of an element having both and current_ and next_ position 900 for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) { 901 902 if ( total <= active_items_start && total >= active_items_end ) { 903 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 904 $( items[x] ).data('current_position', current_position ); 905 current_position--; 906 } 907 908 if ( total <= prev_items_start && total >= prev_items_end ) { 909 $( items[x] ).data('prev_position', prev_position ); 910 $( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position ); 911 912 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 913 $( items[x] ).addClass('container_append'); 914 } else { 915 $( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 916 $( items[x] ).addClass('delayed_container_append'); 917 } 918 919 prev_position--; 920 } 921 922 if ( prev_position <= 0 ) { 923 break; 924 } 925 926 if ( x == 0 ) { 927 x = items.length; 928 } 929 } 930 931 var sorted = $carousel_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 932 var el_a_position = parseInt( $(a).data('prev_position') ); 933 var el_b_position = parseInt( $(b).data('prev_position') ); 934 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 935 }); 936 937 $( sorted ).show().appendTo( $prev_carousel_group ); 938 939 var left = 0; 940 $prev_carousel_group.children().each(function(){ 941 $(this).css({'position':'absolute', 'left': left }); 942 left = left + $(this).outerWidth(true); 943 }); 944 945 $active_carousel_group.animate({ 946 left: '100%' 947 }, {
948 duration: settings.slide_duration, 949 progress: function(animation, progress) { 950 if (progress > (carousel_group_item_progress/carousel_group_item_size)) { 951 952 var group_item_nth = carousel_group_item_size - carousel_group_item_progress; 953 954 // Add fadeIn / fadeOut className to incoming/outcoming carousel item 955 $active_carousel_group.find('.et_pb_carousel_item:nth-child(' + group_item_nth + ')').addClass('item-fade-out'); 956 $prev_carousel_group.find('.et_pb_carousel_item:nth-child(' + group_item_nth + ')').addClass('item-fade-in'); 957 958 carousel_group_item_progress++; 959 } 960 }, 961 complete: function() { 962 $carousel_items.find('.delayed_container_append').reverse().each(function(){ 963 left = $( '#' + $(this).attr('id') + '-dup' ).css('left'); 964 $(this).css({'position':'absolute', 'left': left }); 965 $(this).prependTo( $prev_carousel_group ); 966 }); 967 968 $active_carousel_group.removeClass('active'); 969 $active_carousel_group.children().each(function(){ 970 position = $(this).data('position'); 971 current_position = $(this).data('current_position'); 972 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 973 $(this).data('position', ''); 974 $(this).data('current_position', ''); 975 $(this).hide(); 976 $(this).css({'position': '', 'left': ''}); 977 $(this).appendTo( $carousel_items ); 978 }); 979 980 // Removing classnames on incoming/outcoming carousel item 981 $carousel_items.find('.item-fade-out').removeClass('item-fade-out'); 982 $prev_carousel_group.find('.item-fade-in').removeClass('item-fade-in'); 983 984 // Remove horizontal scroll prevention class name on body 985 $('body').removeClass('et-pb-is-sliding-carousel'); 986 987 $active_carousel_group.remove(); 988 } 989 } ); 990 991 prev_left = (-1) * $active_carousel_group.width() - parseInt( $the_carousel_items.first().css('marginRight').slice(0, -2) ); 992 $prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: prev_left }); 993 $prev_carousel_group.animate({ 994 left: '0%' 995 }, { 996 duration: settings.slide_duration, 997 complete: function(){ 998 $prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''}); 999 1000 $prev_carousel_group.find('.delayed_container_append_dup').remove(); 1001 1002 $prev_carousel_group.find('.changing_position').each(function( index ){ 1003 position = $(this).data('position'); 1004 current_position = $(this).data('current_position'); 1005 prev_position = $(this).data('prev_position'); 1006 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position ); 1007 $(this).data('current_position', ''); 1008 $(this).data('prev_position', ''); 1009 position = index + 1; 1010 $(this).data('position', position ); 1011 $(this).addClass('position_' + position ); 1012 }); 1013 1014 $prev_carousel_group.children().css({'position': '', 'left': ''}); 1015 $et_carousel.et_animation_running = false; 1016 } 1017 } ); 1018 } 1019 } 1020 }; 1021 1022 $.fn.et_pb_simple_carousel = function( options ) { 1023 return this.each(function() { 1024 var carousel = $.data( this, 'et_pb_simple_carousel' ); 1025 return carousel ? carousel : new $.et_pb_simple_carousel( this, options ); 1026 }); 1027 }; 1028 1029 $(document).ready( function(){ 1030 /** 1031 * Provide event listener for plugins to hook up to 1032 */ 1033 $(window).trigger('et_pb_before_init_modules'); 1034 1035 var $et_pb_slider = $( '.et_pb_slider' ), 1036 $et_pb_tabs = $( '.et_pb_tabs' ), 1037 $et_pb_video_section = $('.et_pb_section_video_bg'), 1038 $et_pb_newsletter_button = $( '.et_pb_newsletter_button' ), 1039 $et_pb_filterable_portfolio = $( '.et_pb_filterable_portfolio' ), 1040 $et_pb_fullwidth_portfolio = $( '.et_pb_fullwidth_portfolio' ), 1041 $et_pb_gallery = $( '.et_pb_gallery' ), 1042 $et_pb_countdown_timer = $( '.et_pb_countdown_timer' ), 1043 $et_post_gallery = $( '.et_post_gallery' ), 1044 $et_lightbox_image = $( '.et_pb_lightbox_image'), 1045 $et_pb_map = $( '.et_pb_map_container' ), 1046 $et_pb_circle_counter = $( '.et_pb_circle_counter' ), 1047 $et_pb_number_counter = $( '.et_pb_number_counter' ), 1048 $et_pb_parallax = $( '.et_parallax_bg' ), 1049 $et_pb_shop = $( '.et_pb_shop' ), 1050 $et_pb_post_fullwidth = $( '.single.et_pb_pagebuilder_layout.et_full_width_page' ), 1051 et_is_mobile_device = navigator.userAgent.match( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/ ) !== null, 1052 et_is_ipad = navigator.userAgent.match( /iPad/ ), 1053 et_is_ie9 = navigator.userAgent.match( /MSIE 9.0/ ) !== null, 1054 et_all_rows = $('.et_pb_row'), 1055 $et_container = ! et_pb_custom.is_builder_plugin_used ? $( '.container' ) : et_all_rows, 1056 et_container_width = $et_container.width(), 1057 et_is_vertical_fixed_nav = $( 'body' ).hasClass( 'et_vertical_fixed' ), 1058 et_is_rtl = $( 'body' ).hasClass( 'rtl' ), 1059 et_hide_nav = $( 'body' ).hasClass( 'et_hide_nav' ), 1060 et_header_style_left = $( 'body' ).hasClass( 'et_header_style_left' ), 1061 $top_header = $('#top-header'), 1062 $main_header = $('#main-header'), 1063 $main_container_wrapper = $( '#page-container' ), 1064 $et_transparent_nav = $( '.et_transparent_nav' ), 1065 $et_pb_first_row = $( 'body.et_pb_pagebuilder_layout .et_pb_section:first-child' ), 1066 $et_main_content_first_row = $( '#main-content .container:first-child' ), 1067 $et_main_content_first_row_meta_wrapper = $et_main_content_first_row.find('.et_post_meta_wrapper:first'), 1068 $et_main_content_first_row_meta_wrapper_title = $et_main_content_first_row_meta_wrapper.find( 'h1' ), 1069 $et_main_content_first_row_content = $et_main_content_first_row.find('.entry-content:first'), 1070 $et_single_post = $( 'body.single-post' ), 1071 etRecalculateOffset = false, 1072 et_header_height, 1073 et_header_modifier, 1074 et_header_offset, 1075 et_primary_header_top, 1076 $et_header_style_split = $('.et_header_style_split'), 1077 $et_top_navigation = $('#et-top-navigation'), 1078 $logo = $('#logo'), 1079 $et_sticky_image = $('.et_pb_image_sticky'), 1080 $et_pb_counter_amount = $('.et_pb_counter_amount'), 1081 $et_pb_carousel = $( '.et_pb_carousel' ), 1082 $et_menu_selector = et_pb_custom.is_divi_theme_used ? $( 'ul.nav' ) : $( '.et_pb_fullwidth_menu ul.nav' ), 1083 et_pb_ab_bounce_rate = et_pb_custom.ab_bounce_rate * 1000, 1084 et_pb_ab_logged_status = { 1085 read_page: false, 1086 read_goal: false, 1087 view_goal: false, 1088 click_goal: false, 1089 con_goal: false, 1090 con_short: false, 1091 }; 1092 1093 window.et_pb_slider_init = function( $this_slider ) { 1094 var et_slider_settings = { 1095 fade_speed : 700, 1096 slide : ! $this_slider.hasClass( 'et_pb_gallery' ) ? '.et_pb_slide' : '.et_pb_gallery_item' 1097 }; 1098 1099 if ( $this_slider.hasClass('et_pb_slider_no_arrows') ) 1100 et_slider_settings.use_arrows = false;
1101 1102 if ( $this_slider.hasClass('et_pb_slider_no_pagination') ) 1103 et_slider_settings.use_controls = false; 1104 1105 if ( $this_slider.hasClass('et_slider_auto') ) { 1106 var et_slider_autospeed_class_value = /et_slider_speed_(\d+)/g; 1107 1108 et_slider_settings.slideshow = true; 1109 1110 var et_slider_autospeed = et_slider_autospeed_class_value.exec( $this_slider.attr('class') ); 1111 1112 et_slider_settings.slideshow_speed = et_slider_autospeed === null ? 10 : et_slider_autospeed[1]; 1113 } 1114 1115 if ( $this_slider.parent().hasClass('et_pb_video_slider') ) { 1116 et_slider_settings.controls_below = true; 1117 et_slider_settings.append_controls_to = $this_slider.parent(); 1118 1119 setTimeout( function() { 1120 $( '.et_pb_preload' ).removeClass( 'et_pb_preload' ); 1121 }, 500 ); 1122 } 1123 1124 if ( $this_slider.hasClass('et_pb_slider_carousel') ) 1125 et_slider_settings.use_carousel = true; 1126 1127 $this_slider.et_pb_simple_slider( et_slider_settings ); 1128 } 1129 1130 var $et_top_menu = $et_menu_selector, 1131 et_parent_menu_longpress_limit = 300, 1132 et_parent_menu_longpress_start, 1133 et_parent_menu_click = true, 1134 is_frontend_builder = $('body').hasClass('et-fb'), 1135 et_menu_hover_triggered = false; 1136 1137 // log the conversion if visitor is on Thank You page and comes from the Shop module which is the Goal 1138 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' ) ) { 1139 var shop_log_data = et_pb_get_cookie_value( 'et_pb_ab_shop_log' ).split( '_' ); 1140 page_id = shop_log_data[0], 1141 subject_id = shop_log_data[1], 1142 test_id = shop_log_data[2]; 1143 1144 et_pb_ab_update_stats( 'con_goal', page_id, subject_id, test_id ); 1145 1146 // remove the cookie after conversion is logged 1147 et_pb_set_cookie( 0, 'et_pb_ab_shop_log=true' ); 1148 } 1149 1150 // log the conversion if visitor is on page with tracking shortcode 1151 if ( $( '.et_pb_ab_split_track' ).length ) { 1152 $( '.et_pb_ab_split_track' ).each( function() { 1153 var tracking_test = $( this ).data( 'test_id' ), 1154 cookies_name = 'et_pb_ab_shortcode_track_' + tracking_test; 1155 1156 if ( typeof et_pb_get_cookie_value( cookies_name ) !== 'undefined' && '' !== et_pb_get_cookie_value( cookies_name ) ) { 1157 var track_data = et_pb_get_cookie_value( cookies_name ).split( '_' ); 1158 page_id = track_data[0], 1159 subject_id = track_data[1], 1160 test_id = track_data[2]; 1161 1162 et_pb_ab_update_stats( 'con_short', page_id, subject_id, test_id ); 1163 1164 // remove the cookie after conversion is logged 1165 et_pb_set_cookie( 0, cookies_name + '=true' ); 1166 } 1167 }); 1168 } 1169 1170 // init AB Testing if enabled 1171 if ( et_pb_custom.is_ab_testing_active ) { 1172 et_pb_init_ab_test(); 1173 } 1174 1175 if (et_all_rows.length) { 1176 et_all_rows.each(function () { 1177 var $this_row = $(this), 1178 row_class = ''; 1179 1180 row_class = et_get_column_types($this_row.find('>.et_pb_column')); 1181 1182 if ('' !== row_class) { 1183 $this_row.addClass(row_class); 1184 } 1185 1186 if ($this_row.find('.et_pb_row_inner').length) { 1187 $this_row.find('.et_pb_row_inner').each(function () { 1188 var $this_row_inner = $(this); 1189 row_class = et_get_column_types($this_row_inner.find('.et_pb_column')); 1190 1191 if ('' !== row_class) { 1192 $this_row_inner.addClass(row_class); 1193 } 1194 }); 1195 } 1196 }); 1197 } 1198 1199 function et_get_column_types($columns) { 1200 var row_class = ''; 1201 1202 if ($columns.length) { 1203 $columns.each(function () { 1204 var $column = $(this); 1205 var column_type = $column.attr('class').split('et_pb_column_')[1]; 1206 var column_type_clean = typeof column_type !== 'undefined' ? column_type.split(' ', 1)[0] : '4_4'; 1207 var column_type_updated = column_type_clean.replace('_', '-').trim(); 1208 1209 row_class += '_' + column_type_updated; 1210 }); 1211 1212 if ((row_class.indexOf('1-4') !== -1) 1213 || (row_class.indexOf('1-5_1-5') !== -1) 1214 || (row_class.indexOf('1-6_1-6') !== -1)) { 1215 switch (row_class) { 1216 case '_1-4_1-4_1-4_1-4': 1217 row_class = 'et_pb_row_4col'; 1218 break; 1219 case '_1-5_1-5_1-5_1-5_1-5': 1220 row_class = 'et_pb_row_5col'; 1221 break; 1222 case '_1-6_1-6_1-6_1-6_1-6_1-6': 1223 row_class = 'et_pb_row_6col'; 1224 break; 1225 default: 1226 row_class = 'et_pb_row' + row_class; 1227 } 1228 } else { 1229 row_class = ''; 1230 } 1231 } 1232 return row_class; 1233 } 1234 1235 window.et_pb_init_nav_menu( $et_top_menu ); 1236 1237 $et_sticky_image.each( function() { 1238 window.et_pb_apply_sticky_image_effect($(this)); 1239 } ); 1240 1241 if ( et_is_mobile_device ) { 1242 $( '.et_pb_section_video_bg' ).each( function() { 1243 var $this_el = $(this); 1244 1245 $this_el.closest( '.et_pb_preload' ).removeClass( 'et_pb_preload' ) 1246 1247 $this_el.remove(); 1248 } ); 1249 1250 $( 'body' ).addClass( 'et_mobile_device' ); 1251 1252 if ( ! et_is_ipad ) { 1253 $( 'body' ).addClass( 'et_mobile_device_not_ipad' ); 1254 } 1255 } 1256 1257 if ( et_is_ie9 ) { 1258 $( 'body' ).addClass( 'et_ie9' ); 1259 } 1260 1261 if ( $et_pb_video_section.length || is_frontend_builder ) { 1262 window.et_pb_video_section_init = function( $et_pb_video_section ) { 1263 $et_pb_video_section.find( 'video' ).mediaelementplayer( { 1264 pauseOtherPlayers: false, 1265 success : function( mediaElement, domObject ) { 1266 mediaElement.addEventListener( 'loadeddata', function() { 1267 et_pb_resize_section_video_bg( $(domObject) );
1268 et_pb_center_video( $(domObject).closest( '.mejs-video' ) ); 1269 }, false ); 1270 1271 mediaElement.addEventListener( 'canplay', function() { 1272 $(domObject).closest( '.et_pb_preload' ).removeClass( 'et_pb_preload' ); 1273 }, false ); 1274 } 1275 } ); 1276 } 1277 et_pb_video_section_init( $et_pb_video_section ); 1278 } 1279 1280 if ( $et_post_gallery.length ) { 1281 // swipe support in magnific popup only if gallery exists 1282 var magnificPopup = $.magnificPopup.instance; 1283 1284 $( 'body' ).on( 'swiperight', '.mfp-container', function() { 1285 magnificPopup.prev(); 1286 } ); 1287 $( 'body' ).on( 'swipeleft', '.mfp-container', function() { 1288 magnificPopup.next(); 1289 } ); 1290 1291 $et_post_gallery.each(function() { 1292 $(this).magnificPopup( { 1293 delegate: '.et_pb_gallery_image a', 1294 type: 'image', 1295 removalDelay: 500, 1296 gallery: { 1297 enabled: true, 1298 navigateByImgClick: true 1299 }, 1300 mainClass: 'mfp-fade', 1301 zoom: { 1302 enabled: ! et_pb_custom.is_builder_plugin_used, 1303 duration: 500, 1304 opener: function(element) { 1305 return element.find('img'); 1306 } 1307 }, 1308 autoFocusLast: false 1309 } ); 1310 } ); 1311 // prevent attaching of any further actions on click 1312 $et_post_gallery.find( 'a' ).unbind( 'click' ); 1313 } 1314 1315 if ( $et_lightbox_image.length || is_frontend_builder ) { 1316 // prevent attaching of any further actions on click 1317 $et_lightbox_image.unbind( 'click' ); 1318 $et_lightbox_image.bind( 'click' ); 1319 1320 window.et_pb_image_lightbox_init = function( $et_lightbox_image ) { 1321 $et_lightbox_image.magnificPopup( { 1322 type: 'image', 1323 removalDelay: 500, 1324 mainClass: 'mfp-fade', 1325 zoom: { 1326 enabled: ! et_pb_custom.is_builder_plugin_used, 1327 duration: 500, 1328 opener: function(element) { 1329 return element.find('img'); 1330 } 1331 }, 1332 autoFocusLast: false 1333 } ); 1334 } 1335 1336 et_pb_image_lightbox_init( $et_lightbox_image ); 1337 } 1338 1339 if ( $et_pb_slider.length || is_frontend_builder ) { 1340 $et_pb_slider.each( function() { 1341 $this_slider = $(this); 1342 1343 et_pb_slider_init( $this_slider ); 1344 } ); 1345 } 1346 1347 $et_pb_carousel = $( '.et_pb_carousel' ); 1348 if ( $et_pb_carousel.length || is_frontend_builder ) { 1349 $et_pb_carousel.each( function() { 1350 var $this_carousel = $(this), 1351 et_carousel_settings = { 1352 slide_duration: 1000 1353 }; 1354 1355 $this_carousel.et_pb_simple_carousel( et_carousel_settings ); 1356 } ); 1357 } 1358 1359 if ( $et_pb_fullwidth_portfolio.length || is_frontend_builder ) { 1360 1361 window.et_fullwidth_portfolio_init = function( $the_portfolio ) { 1362 var $portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'); 1363 1364 $portfolio_items.data('items', $portfolio_items.find('.et_pb_portfolio_item').toArray() ); 1365 $the_portfolio.data('columns_setting_up', false ); 1366 1367 if ( $the_portfolio.hasClass('et_pb_fullwidth_portfolio_carousel') ) { 1368 // add left and right arrows 1369 $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>'); 1370 1371 set_fullwidth_portfolio_columns( $the_portfolio, true ); 1372 1373 et_carousel_auto_rotate( $the_portfolio ); 1374 1375 // swipe support 1376 $the_portfolio.on( 'swiperight', function() { 1377 $( this ).find( '.et-pb-arrow-prev' ).click(); 1378 }); 1379 $the_portfolio.on( 'swipeleft', function() { 1380 $( this ).find( '.et-pb-arrow-next' ).click(); 1381 }); 1382 1383 $the_portfolio.hover( 1384 function(){ 1385 $(this).addClass('et_carousel_hovered'); 1386 if ( typeof $(this).data('et_carousel_timer') != 'undefined' ) { 1387 clearInterval( $(this).data('et_carousel_timer') ); 1388 } 1389 }, 1390 function(){ 1391 $(this).removeClass('et_carousel_hovered'); 1392 et_carousel_auto_rotate( $(this) ); 1393 } 1394 ); 1395 1396 $the_portfolio.data('carouseling', false ); 1397 1398 $the_portfolio.on('click', '.et-pb-slider-arrows a', function(e){ 1399 fullwidth_portfolio_carousel_slide( $( this) ); 1400 e.preventDefault(); 1401 return false;
1402 }); 1403 1404 } else { 1405 // setup fullwidth portfolio grid 1406 set_fullwidth_portfolio_columns( $the_portfolio, false ); 1407 } 1408 } 1409 1410 function fullwidth_portfolio_carousel_slide( $arrow ) { 1411 var $the_portfolio = $arrow.parents('.et_pb_fullwidth_portfolio'), 1412 $portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'), 1413 $the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'), 1414 $active_carousel_group = $portfolio_items.find('.et_pb_carousel_group.active'), 1415 slide_duration = 700, 1416 items = $portfolio_items.data('items'), 1417 columns = $portfolio_items.data('portfolio-columns'), 1418 item_width = $active_carousel_group.innerWidth() / columns, 1419 original_item_width = ( 100 / columns ) + '%'; 1420 1421 if ( 'undefined' == typeof items ) { 1422 return; 1423 } 1424 1425 if ( $the_portfolio.data('carouseling') ) { 1426 return; 1427 } 1428 1429 $the_portfolio.data('carouseling', true); 1430 1431 $active_carousel_group.children().each(function(){ 1432 $(this).css({'width': item_width + 1, 'max-width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('position') - 1 ) ) }); 1433 }); 1434 1435 if ( $arrow.hasClass('et-pb-arrow-next') ) { 1436 var $next_carousel_group, 1437 current_position = 1, 1438 next_position = 1, 1439 active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ), 1440 active_items_end = active_items_start + columns, 1441 next_items_start = active_items_end, 1442 next_items_end = next_items_start + columns, 1443 active_carousel_width = $active_carousel_group.innerWidth(); 1444 1445 $next_carousel_group = $('<div class="et_pb_carousel_group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group ); 1446 $next_carousel_group.css({ 'width': active_carousel_width, 'max-width': active_carousel_width }).show(); 1447 1448 // this is an endless loop, so it can decide internally when to break out, so that next_position 1449 // can get filled up, even to the extent of an element having both and current_ and next_ position 1450 for( x = 0, total = 0 ; ; x++, total++ ) { 1451 if ( total >= active_items_start && total < active_items_end ) { 1452 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 1453 $( items[x] ).data('current_position', current_position ); 1454 current_position++; 1455 } 1456 1457 if ( total >= next_items_start && total < next_items_end ) { 1458 $( items[x] ).data('next_position', next_position ); 1459 $( items[x] ).addClass('changing_position next_position next_position_' + next_position ); 1460 1461 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 1462 $( items[x] ).addClass('container_append'); 1463 } else { 1464 $( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 1465 $( items[x] ).addClass('delayed_container_append'); 1466 } 1467 1468 next_position++; 1469 } 1470 1471 if ( next_position > columns ) { 1472 break; 1473 } 1474 1475 if ( x >= ( items.length -1 )) { 1476 x = -1; 1477 } 1478 } 1479 1480 sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 1481 var el_a_position = parseInt( $(a).data('next_position') ); 1482 var el_b_position = parseInt( $(b).data('next_position') ); 1483 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 1484 }); 1485 1486 $( sorted ).show().appendTo( $next_carousel_group ); 1487 1488 $next_carousel_group.children().each(function(){ 1489 $(this).css({'width': item_width, 'max-width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) }); 1490 }); 1491 1492 $active_carousel_group.animate({ 1493 left: '-100%' 1494 }, { 1495 duration: slide_duration, 1496 complete: function() { 1497 $portfolio_items.find('.delayed_container_append').each(function(){ 1498 $(this).css({'width': item_width, 'max-width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) }); 1499 $(this).appendTo( $next_carousel_group ); 1500 }); 1501 1502 $active_carousel_group.removeClass('active'); 1503 $active_carousel_group.children().each(function(){ 1504 position = $(this).data('position'); 1505 current_position = $(this).data('current_position'); 1506 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 1507 $(this).data('position', ''); 1508 $(this).data('current_position', ''); 1509 $(this).hide(); 1510 $(this).css({'position': '', 'width': '', 'max-width': '', 'left': ''}); 1511 $(this).appendTo( $portfolio_items ); 1512 }); 1513 1514 $active_carousel_group.remove(); 1515 1516 et_carousel_auto_rotate( $the_portfolio ); 1517 1518 } 1519 } ); 1520 1521 $next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '100%'}); 1522 $next_carousel_group.animate({ 1523 left: '0%' 1524 }, {
1525 duration: slide_duration, 1526 complete: function(){ 1527 setTimeout(function(){ 1528 $next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'max-width':'', 'top':'', 'left': ''}); 1529 1530 $next_carousel_group.find('.delayed_container_append_dup').remove(); 1531 1532 $next_carousel_group.find('.changing_position').each(function( index ){ 1533 position = $(this).data('position'); 1534 current_position = $(this).data('current_position'); 1535 next_position = $(this).data('next_position'); 1536 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position ); 1537 $(this).data('current_position', ''); 1538 $(this).data('next_position', ''); 1539 $(this).data('position', ( index + 1 ) ); 1540 }); 1541 1542 $next_carousel_group.children().css({'position': '', 'width': original_item_width, 'max-width': original_item_width, 'left': ''}); 1543 1544 $the_portfolio.data('carouseling', false); 1545 }, 100 ); 1546 } 1547 } ); 1548 1549 } else { 1550 var $prev_carousel_group, 1551 current_position = columns, 1552 prev_position = columns, 1553 columns_span = columns - 1, 1554 active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ), 1555 active_items_end = active_items_start - columns_span, 1556 prev_items_start = active_items_end - 1, 1557 prev_items_end = prev_items_start - columns_span, 1558 active_carousel_width = $active_carousel_group.innerWidth(); 1559 1560 $prev_carousel_group = $('<div class="et_pb_carousel_group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group ); 1561 $prev_carousel_group.css({ 'left': '-' + active_carousel_width, 'width': active_carousel_width, 'max-width': active_carousel_width }).show(); 1562 1563 // this is an endless loop, so it can decide internally when to break out, so that next_position 1564 // can get filled up, even to the extent of an element having both and current_ and next_ position 1565 for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) { 1566 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 <= prev_items_start && total >= prev_items_end ) { 1574 $( items[x] ).data('prev_position', prev_position ); 1575 $( items[x] ).addClass('changing_position prev_position prev_position_' + prev_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 ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 1581 $( items[x] ).addClass('delayed_container_append'); 1582 } 1583 1584 prev_position--; 1585 } 1586 1587 if ( prev_position <= 0 ) { 1588 break; 1589 } 1590 1591 if ( x == 0 ) { 1592 x = items.length; 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('prev_position') ); 1598 var el_b_position = parseInt( $(b).data('prev_position') ); 1599 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 1600 }); 1601 1602 $( sorted ).show().appendTo( $prev_carousel_group ); 1603 1604 $prev_carousel_group.children().each(function(){ 1605 $(this).css({'width': item_width, 'max-width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_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').reverse().each(function(){ 1614 $(this).css({'width': item_width, 'max-width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) }); 1615 $(this).prependTo( $prev_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 } ); 1633 1634 $prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '-100%'}); 1635 $prev_carousel_group.animate({ 1636 left: '0%' 1637 }, {
1638 duration: slide_duration, 1639 complete: function(){ 1640 setTimeout(function(){ 1641 $prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'max-width':'', 'top':'', 'left': ''}); 1642 1643 $prev_carousel_group.find('.delayed_container_append_dup').remove(); 1644 1645 $prev_carousel_group.find('.changing_position').each(function( index ){ 1646 position = $(this).data('position'); 1647 current_position = $(this).data('current_position'); 1648 prev_position = $(this).data('prev_position'); 1649 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position ); 1650 $(this).data('current_position', ''); 1651 $(this).data('prev_position', ''); 1652 position = index + 1; 1653 $(this).data('position', position ); 1654 $(this).addClass('position_' + position ); 1655 }); 1656 1657 $prev_carousel_group.children().css({'position': '', 'width': original_item_width, 'max-width': original_item_width, 'left': ''}); 1658 $the_portfolio.data('carouseling', false); 1659 }, 100 ); 1660 } 1661 } ); 1662 } 1663 } 1664 1665 function set_fullwidth_portfolio_columns( $the_portfolio, carousel_mode ) { 1666 var columns, 1667 $portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'), 1668 portfolio_items_width = $portfolio_items.width(), 1669 $the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'), 1670 portfolio_item_count = $the_portfolio_items.length; 1671 1672 if ('undefined' === typeof $the_portfolio_items) { 1673 return; 1674 } 1675 1676 // calculate column breakpoints 1677 if ( portfolio_items_width >= 1600 ) { 1678 columns = 5; 1679 } else if ( portfolio_items_width >= 1024 ) { 1680 columns = 4; 1681 } else if ( portfolio_items_width >= 768 ) { 1682 columns = 3; 1683 } else if ( portfolio_items_width >= 480 ) { 1684 columns = 2; 1685 } else { 1686 columns = 1; 1687 } 1688 1689 // set height of items 1690 portfolio_item_width = portfolio_items_width / columns;
1691 portfolio_item_height = portfolio_item_width * .75; 1692 1693 if ( carousel_mode ) { 1694 $portfolio_items.css({ 'height' : portfolio_item_height }); 1695 } 1696 1697 $the_portfolio_items.css({ 'height' : portfolio_item_height }); 1698 1699 if ( columns === $portfolio_items.data('portfolio-columns') ) { 1700 return; 1701 } 1702 1703 if ( $the_portfolio.data('columns_setting_up') ) { 1704 return; 1705 } 1706 1707 $the_portfolio.data('columns_setting_up', true ); 1708 1709 var portfolio_item_width_percentage = ( 100 / columns ) + '%'; 1710 $the_portfolio_items.css({ 'width' : portfolio_item_width_percentage, 'max-width' : portfolio_item_width_percentage }); 1711 1712 // store last setup column 1713 $portfolio_items.removeClass('columns-' + $portfolio_items.data('portfolio-columns') ); 1714 $portfolio_items.addClass('columns-' + columns ); 1715 $portfolio_items.data('portfolio-columns', columns ); 1716 1717 if ( !carousel_mode ) { 1718 return $the_portfolio.data('columns_setting_up', false ); 1719 } 1720 1721 // kill all previous groups to get ready to re-group 1722 if ( $portfolio_items.find('.et_pb_carousel_group').length ) { 1723 $the_portfolio_items.appendTo( $portfolio_items ); 1724 $portfolio_items.find('.et_pb_carousel_group').remove(); 1725 } 1726 1727 // setup the grouping 1728 var the_portfolio_items = $portfolio_items.data('items' ), 1729 $carousel_group = $('<div class="et_pb_carousel_group active">').appendTo( $portfolio_items ); 1730 1731 if ('undefined' === typeof the_portfolio_items) { 1732 return; 1733 } 1734 1735 $the_portfolio_items.data('position', ''); 1736 if ( the_portfolio_items.length <= columns ) { 1737 $portfolio_items.find('.et-pb-slider-arrows').hide(); 1738 } else { 1739 $portfolio_items.find('.et-pb-slider-arrows').show(); 1740 } 1741 1742 for ( position = 1, x=0 ;x < the_portfolio_items.length; x++, position++ ) { 1743 if ( x < columns ) { 1744 $( the_portfolio_items[x] ).show(); 1745 $( the_portfolio_items[x] ).appendTo( $carousel_group ); 1746 $( the_portfolio_items[x] ).data('position', position ); 1747 $( the_portfolio_items[x] ).addClass('position_' + position ); 1748 } else { 1749 position = $( the_portfolio_items[x] ).data('position'); 1750 $( the_portfolio_items[x] ).removeClass('position_' + position ); 1751 $( the_portfolio_items[x] ).data('position', '' ); 1752 $( the_portfolio_items[x] ).hide(); 1753 } 1754 } 1755 1756 $the_portfolio.data('columns_setting_up', false ); 1757 1758 } 1759 1760 function et_carousel_auto_rotate( $carousel ) { 1761 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' ) ) { 1762 1763 et_carousel_timer = setTimeout( function() { 1764 fullwidth_portfolio_carousel_slide( $carousel.find('.et-pb-arrow-next') ); 1765 }, $carousel.data('auto-rotate-speed') ); 1766 1767 $carousel.data('et_carousel_timer', et_carousel_timer); 1768 } 1769 } 1770 1771 $et_pb_fullwidth_portfolio.each(function(){ 1772 et_fullwidth_portfolio_init( $(this) ); 1773 }); 1774 } 1775 1776 function et_audio_module_set() { 1777 if ( $( '.et_pb_audio_module .mejs-audio' ).length || $( '.et_audio_content .mejs-audio' ).length ) { 1778 $( '.et_audio_container' ).each( function(){ 1779 et_pb_audio_module_init( $(this) ); 1780 }); 1781 } 1782 } 1783 1784 window.et_pb_audio_module_init = function( $audio_container ) { 1785 var $this_player = $audio_container, 1786 $time_rail = $this_player.find( '.mejs-time-rail' ), 1787 $time_slider = $this_player.find( '.mejs-time-slider' ); 1788 // remove previously added width and min-width attributes to calculate the new sizes accurately 1789 $time_rail.removeAttr( 'style' ); 1790 $time_slider.removeAttr( 'style' ); 1791 1792 var $count_timer = $this_player.find( 'div.mejs-currenttime-container' ), 1793 $count_timer_width_container = $this_player.find( '.mejs-duration-container' ).length ? $this_player.find( '.mejs-duration-container' ) : $this_player.find( '.mejs-currenttime-container' ), 1794 player_width = $this_player.width(), 1795 controls_play_width = $this_player.find( '.mejs-play' ).outerWidth(), 1796 time_width = $count_timer_width_container.outerWidth(), 1797 volume_icon_width = $this_player.find( '.mejs-volume-button' ).outerWidth(), 1798 volume_bar_width = $this_player.find( '.mejs-horizontal-volume-slider' ).outerWidth(), 1799 new_time_rail_width; 1800 1801 $count_timer.addClass( 'custom' ); 1802 $this_player.find( '.mejs-controls div.mejs-duration-container' ).replaceWith( $count_timer ); 1803 new_time_rail_width = player_width - ( controls_play_width + time_width + volume_icon_width + volume_bar_width + 65 ); 1804 1805 if ( 0 < new_time_rail_width ) { 1806 $time_rail.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' ); 1807 $time_slider.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' ); 1808 } 1809 } 1810 1811 if ( $('.et_pb_section_video').length ) { 1812 window._wpmejsSettings.pauseOtherPlayers = false;
1813 } 1814 1815 if ( $et_pb_filterable_portfolio.length || is_frontend_builder ) { 1816 1817 window.et_pb_filterable_portfolio_init = function( $selector ) { 1818 if ( typeof $selector !== 'undefined' ){ 1819 set_filterable_portfolio_init( $selector ); 1820 } else { 1821 $et_pb_filterable_portfolio.each(function(){ 1822 set_filterable_portfolio_init( $(this) ) 1823 }); 1824 } 1825 } 1826 1827 window.set_filterable_portfolio_init = function( $the_portfolio ) { 1828 var $the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'), 1829 $left_orientatation = true == $the_portfolio.data( 'rtl' ) ? false : true, 1830 all_portfolio_items = $the_portfolio_items.clone(); // cache for all the portfolio items 1831 1832 $the_portfolio.show(); 1833 $the_portfolio.find('.et_pb_portfolio_item').addClass('active'); 1834 $the_portfolio.css('display', 'block'); 1835 1836 set_filterable_grid_items( $the_portfolio ); 1837 1838 $the_portfolio.on('click', '.et_pb_portfolio_filter a', function(e){ 1839 e.preventDefault(); 1840 var category_slug = $(this).data('category-slug'); 1841 var $the_portfolio = $(this).parents('.et_pb_filterable_portfolio'); 1842 var $the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'); 1843 1844 if ( 'all' == category_slug ) { 1845 $the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active'); 1846 $the_portfolio.find('.et_pb_portfolio_filter_all a').addClass('active'); 1847 1848 // remove all items from the portfolio items container 1849 $the_portfolio_items.empty(); 1850 1851 // fill the portfolio items container with cached items from memory 1852 $the_portfolio_items.append( all_portfolio_items.find( '.et_pb_portfolio_item' ).clone() ); 1853 $the_portfolio.find('.et_pb_portfolio_item').addClass('active'); 1854 } else { 1855 $the_portfolio.find('.et_pb_portfolio_filter_all').removeClass('active'); 1856 $the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active'); 1857 $the_portfolio.find('.et_pb_portfolio_filter_all a').removeClass('active'); 1858 $(this).addClass('active'); 1859 1860 // remove all items from the portfolio items container 1861 $the_portfolio_items.empty(); 1862 1863 // fill the portfolio items container with cached items from memory 1864 $the_portfolio_items.append( all_portfolio_items.find( '.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).clone() ); 1865 1866 $the_portfolio_items.find('.et_pb_portfolio_item').removeClass('active'); 1867 $the_portfolio_items.find('.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).addClass('active').removeClass( 'inactive' ); 1868 } 1869 1870 set_filterable_grid_items( $the_portfolio ); 1871 setTimeout(function(){ 1872 set_filterable_portfolio_hash( $the_portfolio ); 1873 }, 500 ); 1874 1875 $the_portfolio.find('.et_pb_portfolio_item').removeClass( 'first_in_row last_in_row' ); 1876 et_pb_set_responsive_grid( $the_portfolio, '.et_pb_portfolio_item:visible' ); 1877 }); 1878 1879 $the_portfolio.on('click', '.et_pb_portofolio_pagination a', function(e){ 1880 e.preventDefault(); 1881 1882 var to_page = $(this).data('page'); 1883 var $the_portfolio = $(this).parents('.et_pb_filterable_portfolio'); 1884 var $the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'); 1885 1886 et_pb_smooth_scroll( $the_portfolio, false, 800 ); 1887 1888 if ( $(this).hasClass('page-prev') ) { 1889 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1; 1890 } else if ( $(this).hasClass('page-next') ) { 1891 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1; 1892 } 1893 1894 $(this).parents('ul').find('a').removeClass('active'); 1895 $(this).parents('ul').find('a.page-' + to_page ).addClass('active'); 1896 1897 var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(), 1898 total_pages = $(this).parents('ul').find('li.page').length; 1899 1900 $(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show(); 1901 $(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show(); 1902 1903 $(this).parents('ul').find('li.page').each(function(i){ 1904 if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) { 1905 if ( i < ( current_index - 3 ) ) { 1906 $(this).hide(); 1907 } else if ( i > ( current_index + 1 ) ) { 1908 $(this).hide(); 1909 } else { 1910 $(this).show(); 1911 } 1912 1913 if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) { 1914 $(this).show(); 1915 } else if ( current_index <= 3 && i <= 4 ) { 1916 $(this).show(); 1917 } 1918 1919 } 1920 }); 1921 1922 if ( to_page > 1 ) { 1923 $(this).parents('ul').find('li.prev').show(); 1924 } else { 1925 $(this).parents('ul').find('li.prev').hide(); 1926 } 1927 1928 if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) { 1929 $(this).parents('ul').find('li.next').hide(); 1930 } else { 1931 $(this).parents('ul').find('li.next').show(); 1932 } 1933 1934 $the_portfolio.find('.et_pb_portfolio_item').hide(); 1935 $the_portfolio.find('.et_pb_portfolio_item').filter(function( index ) { 1936 return $(this).data('page') === to_page; 1937 }).show(); 1938 1939 window.et_pb_set_responsive_grid( $the_portfolio.find( '.et_pb_portfolio_items' ), '.et_pb_portfolio_item' ); 1940 1941 setTimeout(function(){ 1942 set_filterable_portfolio_hash( $the_portfolio ); 1943 }, 500 ); 1944 1945 $the_portfolio.find('.et_pb_portfolio_item').removeClass( 'first_in_row last_in_row' ); 1946 et_pb_set_responsive_grid( $the_portfolio, '.et_pb_portfolio_item:visible' ); 1947 }); 1948 1949 $(this).on('et_hashchange', function( event ){ 1950 var params = event.params; 1951 $the_portfolio = $( '#' + event.target.id ); 1952 1953 if ( !$the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').hasClass('active') ) { 1954 $the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').click(); 1955 } 1956 1957 if ( params[1] ) { 1958 setTimeout(function(){ 1959 if ( !$the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).hasClass('active') ) { 1960 $the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).addClass('active').click(); 1961 } 1962 }, 300 ); 1963 } 1964 }); 1965 } 1966 1967 // init portfolio if .load event was fired already, wait for the window load otherwise. 1968 if ( window.et_load_event_fired ) { 1969 et_pb_filterable_portfolio_init(); 1970 } else { 1971 $(window).load(function(){ 1972 et_pb_filterable_portfolio_init(); 1973 }); // End $(window).load() 1974 } 1975 1976 function set_filterable_grid_items( $the_portfolio ) { 1977 var active_category = $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug'); 1978 1979 window.et_pb_set_responsive_grid( $the_portfolio.find( '.et_pb_portfolio_items' ), '.et_pb_portfolio_item' ); 1980 1981 if ( 'all' === active_category ) { 1982 $the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item'); 1983 } else { 1984 $the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item.project_category_' + active_category); 1985 } 1986 1987 var visible_grid_items = $the_portfolio_visible_items.length, 1988 posts_number = $the_portfolio.data('posts-number'), 1989 pages = 0 === posts_number ? 1 : Math.ceil( visible_grid_items / posts_number ); 1990 1991 set_filterable_grid_pages( $the_portfolio, pages ); 1992 1993 var visible_grid_items = 0; 1994 var _page = 1; 1995 $the_portfolio.find('.et_pb_portfolio_item').data('page', ''); 1996 $the_portfolio_visible_items.each(function(i){ 1997 visible_grid_items++; 1998 if ( 0 === parseInt( visible_grid_items % posts_number ) ) { 1999 $(this).data('page', _page); 2000 _page++; 2001 } else { 2002 $(this).data('page', _page); 2003 } 2004 }); 2005 2006 $the_portfolio_visible_items.filter(function() { 2007 return $(this).data('page') == 1; 2008 }).show(); 2009 2010 $the_portfolio_visible_items.filter(function() { 2011 return $(this).data('page') != 1; 2012 }).hide(); 2013 } 2014 2015 function set_filterable_grid_pages( $the_portfolio, pages ) { 2016 $pagination = $the_portfolio.find('.et_pb_portofolio_pagination'); 2017 2018 if ( !$pagination.length ) { 2019 return; 2020 } 2021 2022 $pagination.html('<ul></ul>'); 2023 if ( pages <= 1 ) { 2024 return; 2025 } 2026 2027 $pagination_list = $pagination.children('ul'); 2028 $pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + et_pb_custom.prev + '</a></li>'); 2029 for( var page = 1; page <= pages; page++ ) { 2030 var first_page_class = page === 1 ? ' active' : '', 2031 last_page_class = page === pages ? ' last-page' : '', 2032 hidden_page_class = page >= 5 ? ' style="display:none;"' : ''; 2033 $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>'); 2034 } 2035 $pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + et_pb_custom.next + '</a></li>'); 2036 } 2037 2038 function set_filterable_portfolio_hash( $the_portfolio ) { 2039 2040 if ( !$the_portfolio.attr('id') ) { 2041 return; 2042 } 2043 2044 var this_portfolio_state = []; 2045 this_portfolio_state.push( $the_portfolio.attr('id') ); 2046 this_portfolio_state.push( $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug') ); 2047 2048 if ( $the_portfolio.find('.et_pb_portofolio_pagination a.active').length ) { 2049 this_portfolio_state.push( $the_portfolio.find('.et_pb_portofolio_pagination a.active').data('page') ); 2050 } else { 2051 this_portfolio_state.push( 1 ); 2052 } 2053 2054 this_portfolio_state = this_portfolio_state.join( et_hash_module_param_seperator ); 2055 2056 et_set_hash( this_portfolio_state ); 2057 } 2058 } /* end if ( $et_pb_filterable_portfolio.length ) */ 2059 2060 if ( $et_pb_gallery.length || is_frontend_builder ) { 2061 2062 window.set_gallery_grid_items = function( $the_gallery ) { 2063 var $the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'), 2064 $the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item'); 2065 2066 var total_grid_items = $the_gallery_items.length, 2067 posts_number_original = parseInt( $the_gallery_items_container.attr('data-per_page') ), 2068 posts_number = isNaN( posts_number_original ) || 0 === posts_number_original ? 4 : posts_number_original, 2069 pages = Math.ceil( total_grid_items / posts_number ); 2070 2071 set_gallery_grid_pages( $the_gallery, pages ); 2072 2073 var total_grid_items = 0; 2074 var _page = 1; 2075 2076 // Remove existing fillers, if any 2077 $the_gallery_items_container.find('.et_pb_gallery_filler').remove(); 2078 var filler = '<div class="et_pb_gallery_filler"></div>'; 2079 var fillers_added = 0; 2080 2081 $the_gallery_items.data('page', ''); 2082 $the_gallery_items.each(function(i){ 2083 total_grid_items++; 2084 // Do some caching 2085 var $this = $(this); 2086 if ( 0 === parseInt( total_grid_items % posts_number ) ) { 2087 $this.data('page', _page); 2088 // This is the last item in the current page, since the grid layout is controlled
2089 // by css rules using nth-child selectors, we need to make sure the current item 2090 // is also the last on its column or else layout might break in other pages. 2091 // To do so, we add as many empty filler as needed until the element right margin is 0 2092 fillers_added = 0; 2093 while (fillers_added < 4 && '0px' !== $this.css('marginRight')) { 2094 // We can't possibly need more than 3 fillers for each row, make sure we exit anyway 2095 // to prevent infinite loops. 2096 fillers_added++ 2097 $this.before($(filler)); 2098 } 2099 _page++; 2100 } else { 2101 $this.data('page', _page); 2102 } 2103 2104 }); 2105 2106 var visible_items = $the_gallery_items.filter(function() { 2107 return $(this).data('page') == 1; 2108 }).show(); 2109 2110 $the_gallery_items.filter(function() { 2111 return $(this).data('page') != 1; 2112 }).hide(); 2113 } 2114 2115 window.set_gallery_grid_pages = function( $the_gallery, pages ) { 2116 $pagination = $the_gallery.find('.et_pb_gallery_pagination'); 2117 2118 if ( !$pagination.length ) { 2119 return; 2120 } 2121 2122 $pagination.html('<ul></ul>'); 2123 if ( pages <= 1 ) { 2124 $pagination.hide(); 2125 return; 2126 } 2127 2128 $pagination_list = $pagination.children('ul'); 2129 $pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + et_pb_custom.prev + '</a></li>'); 2130 for( var page = 1; page <= pages; page++ ) { 2131 var first_page_class = page === 1 ? ' active' : '', 2132 last_page_class = page === pages ? ' last-page' : '', 2133 hidden_page_class = page >= 5 ? ' style="display:none;"' : ''; 2134 $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>'); 2135 } 2136 $pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + et_pb_custom.next + '</a></li>'); 2137 } 2138 2139 window.set_gallery_hash = function( $the_gallery ) { 2140 2141 if ( !$the_gallery.attr('id') ) { 2142 return; 2143 } 2144 2145 var this_gallery_state = []; 2146 this_gallery_state.push( $the_gallery.attr('id') ); 2147 2148 if ( $the_gallery.find('.et_pb_gallery_pagination a.active').length ) { 2149 this_gallery_state.push( $the_gallery.find('.et_pb_gallery_pagination a.active').data('page') ); 2150 } else { 2151 this_gallery_state.push( 1 ); 2152 } 2153 2154 this_gallery_state = this_gallery_state.join( et_hash_module_param_seperator ); 2155 2156 et_set_hash( this_gallery_state ); 2157 } 2158 2159 window.et_pb_gallery_init = function( $the_gallery ) { 2160 if ( $the_gallery.hasClass( 'et_pb_gallery_grid' ) ) { 2161 2162 $the_gallery.show(); 2163 set_gallery_grid_items( $the_gallery ); 2164 2165 $the_gallery.on('et_hashchange', function( event ){ 2166 var params = event.params; 2167 $the_gallery = $( '#' + event.target.id ); 2168 2169 if ( page_to = params[0] ) { 2170 if ( !$the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).hasClass('active') ) { 2171 $the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).addClass('active').click(); 2172 } 2173 } 2174 }); 2175 } 2176 } 2177 2178 $et_pb_gallery.each(function(){ 2179 var $the_gallery = $(this); 2180 2181 et_pb_gallery_init( $the_gallery ); 2182 }); 2183 2184 $et_pb_gallery.data('paginating', false ); 2185 2186 window.et_pb_gallery_pagination_nav = function( $the_gallery ) { 2187 $the_gallery.on('click', '.et_pb_gallery_pagination a', function(e){ 2188 e.preventDefault(); 2189 2190 var to_page = $(this).data('page'), 2191 $the_gallery = $(this).parents('.et_pb_gallery'), 2192 $the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'), 2193 $the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item'); 2194 2195 if ( $the_gallery.data('paginating') ) { 2196 return; 2197 } 2198 2199 $the_gallery.data('paginating', true ); 2200 2201 if ( $(this).hasClass('page-prev') ) { 2202 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1; 2203 } else if ( $(this).hasClass('page-next') ) { 2204 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1; 2205 } 2206 2207 $(this).parents('ul').find('a').removeClass('active'); 2208 $(this).parents('ul').find('a.page-' + to_page ).addClass('active'); 2209 2210 var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(), 2211 total_pages = $(this).parents('ul').find('li.page').length; 2212 2213 $(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show(); 2214 $(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show(); 2215 2216 $(this).parents('ul').find('li.page').each(function(i){ 2217 if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) { 2218 if ( i < ( current_index - 3 ) ) { 2219 $(this).hide(); 2220 } else if ( i > ( current_index + 1 ) ) { 2221 $(this).hide(); 2222 } else { 2223 $(this).show(); 2224 } 2225 2226 if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) { 2227 $(this).show(); 2228 } else if ( current_index <= 3 && i <= 4 ) { 2229 $(this).show(); 2230 } 2231 2232 } 2233 }); 2234 2235 if ( to_page > 1 ) { 2236 $(this).parents('ul').find('li.prev').show(); 2237 } else { 2238 $(this).parents('ul').find('li.prev').hide(); 2239 } 2240 2241 if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) { 2242 $(this).parents('ul').find('li.next').hide(); 2243 } else { 2244 $(this).parents('ul').find('li.next').show(); 2245 } 2246 2247 $the_gallery_items.hide(); 2248 var visible_items = $the_gallery_items.filter(function( index ) { 2249 return $(this).data('page') === to_page; 2250 }).show(); 2251 2252 $the_gallery.data('paginating', false ); 2253 2254 window.et_pb_set_responsive_grid( $the_gallery_items_container, '.et_pb_gallery_item' ); 2255 2256 setTimeout(function(){ 2257 set_gallery_hash( $the_gallery ); 2258 }, 100 ); 2259 2260 $( 'html, body' ).animate( { scrollTop : $the_gallery.offset().top - 200 }, 200 ); 2261 }); 2262 } 2263 et_pb_gallery_pagination_nav( $et_pb_gallery ); 2264 2265 // Frontend builder's interface wouldn't be able to use $et_pb_gallery as selector 2266 // due to its react component's nature. Using more global selector works. 2267 if ( is_frontend_builder ) { 2268 et_pb_gallery_pagination_nav( $('#et-fb-app') ); 2269 } 2270 2271 } /* end if ( $et_pb_gallery.length ) */ 2272 2273 if ( $et_pb_counter_amount.length ) { 2274 $et_pb_counter_amount.each(function(){ 2275 window.et_bar_counters_init( $( this ) ); 2276 }); 2277 } /* $et_pb_counter_amount.length */ 2278 2279 window.et_countdown_timer = function( timer ) { 2280 var end_date = parseInt( timer.attr( 'data-end-timestamp') ), 2281 current_date = new Date().getTime() / 1000, 2282 seconds_left = ( end_date - current_date ); 2283 2284 days = parseInt(seconds_left / 86400); 2285 days = days > 0 ? days : 0; 2286 seconds_left = seconds_left % 86400; 2287 2288 hours = parseInt(seconds_left / 3600); 2289 hours = hours > 0 ? hours : 0; 2290 2291 seconds_left = seconds_left % 3600; 2292 2293 minutes = parseInt(seconds_left / 60); 2294 minutes = minutes > 0 ? minutes : 0; 2295 2296 seconds = parseInt(seconds_left % 60); 2297 seconds = seconds > 0 ? seconds : 0; 2298
2299 var $days_section = timer.find('.days > .value').parent('.section'), 2300 $hours_section = timer.find('.hours > .value').parent('.section'), 2301 $minutes_section = timer.find('.minutes > .value').parent('.section'), 2302 $seconds_section = timer.find('.seconds > .value').parent('.section'); 2303 2304 2305 if ( days == 0 ) { 2306 if ( ! $days_section.hasClass('zero') ) { 2307 timer.find('.days > .value').html( '000' ).parent('.section').addClass('zero').next().addClass('zero'); 2308 } 2309 } else { 2310 days_slice = days.toString().length >= 3 ? days.toString().length : 3; 2311 timer.find('.days > .value').html( ('000' + days).slice(-days_slice) ); 2312 2313 if ( $days_section.hasClass('zero') ) { 2314 $days_section.removeClass('zero').next().removeClass('zero'); 2315 } 2316 } 2317 2318 if ( days == 0 && hours == 0 ) { 2319 if ( ! $hours_section.hasClass('zero') ) { 2320 timer.find('.hours > .value').html('00').parent('.section').addClass('zero').next().addClass('zero'); 2321 } 2322 } else { 2323 timer.find('.hours > .value').html( ( '0' + hours ).slice(-2) ); 2324 2325 if ( $hours_section.hasClass('zero') ) { 2326 $hours_section.removeClass('zero').next().removeClass('zero'); 2327 } 2328 } 2329 2330 if ( days == 0 && hours == 0 && minutes == 0 ) { 2331 if ( ! $minutes_section.hasClass('zero') ) { 2332 timer.find('.minutes > .value').html('00').parent('.section').addClass('zero').next().addClass('zero'); 2333 } 2334 } else { 2335 timer.find('.minutes > .value').html( ( '0' + minutes ).slice(-2) ); 2336 2337 if ( $minutes_section.hasClass('zero') ) { 2338 $minutes_section.removeClass('zero').next().removeClass('zero'); 2339 } 2340 } 2341 2342 if ( days == 0 && hours == 0 && minutes == 0 && seconds == 0 ) { 2343 if ( ! $seconds_section.hasClass('zero') ) { 2344 timer.find('.seconds > .value').html('00').parent('.section').addClass('zero'); 2345 } 2346 } else { 2347 timer.find('.seconds > .value').html( ( '0' + seconds ).slice(-2) ); 2348 2349 if ( $seconds_section.hasClass('zero') ) { 2350 $seconds_section.removeClass('zero').next().removeClass('zero'); 2351 } 2352 } 2353 } 2354 2355 window.et_countdown_timer_labels = function( timer ) { 2356 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 ) {
2357 timer.find('.days .label').html( timer.find('.days').data('short') ); 2358 timer.find('.hours .label').html( timer.find('.hours').data('short') ); 2359 timer.find('.minutes .label').html( timer.find('.minutes').data('short') ); 2360 timer.find('.seconds .label').html( timer.find('.seconds').data('short') ); 2361 } else { 2362 timer.find('.days .label').html( timer.find('.days').data('full') ); 2363 timer.find('.hours .label').html( timer.find('.hours').data('full') ); 2364 timer.find('.minutes .label').html( timer.find('.minutes').data('full') ); 2365 timer.find('.seconds .label').html( timer.find('.seconds').data('full') ); 2366 } 2367 } 2368 2369 if ( $et_pb_countdown_timer.length || is_frontend_builder ) { 2370 window.et_pb_countdown_timer_init = function( $et_pb_countdown_timer ) { 2371 $et_pb_countdown_timer.each(function(){ 2372 var timer = $(this); 2373 et_countdown_timer_labels( timer ); 2374 et_countdown_timer( timer ); 2375 setInterval(function(){ 2376 et_countdown_timer( timer ); 2377 }, 1000); 2378 }); 2379 } 2380 et_pb_countdown_timer_init( $et_pb_countdown_timer ); 2381 } 2382 2383 if ( $et_pb_tabs.length || is_frontend_builder ) { 2384 window.et_pb_tabs_init = function( $et_pb_tabs ) { 2385 var $et_pb_tabs_li = $et_pb_tabs.find( '.et_pb_tabs_controls li' ); 2386 2387 $et_pb_tabs.et_pb_simple_slider( { 2388 use_controls : false, 2389 use_arrows : false, 2390 slide : '.et_pb_all_tabs > div', 2391 tabs_animation : true 2392 } ).on('et_hashchange', function( event ){ 2393 var params = event.params; 2394 var $the_tabs = $( '#' + event.target.id ); 2395 var active_tab = params[0]; 2396 if ( !$the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).hasClass('et_pb_tab_active') ) { 2397 $the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).click(); 2398 } 2399 }); 2400 2401 $et_pb_tabs_li.click( function() { 2402 var $this_el = $(this), 2403 $tabs_container = $this_el.closest( '.et_pb_tabs' ).data('et_pb_simple_slider'); 2404 2405 if ( $tabs_container.et_animation_running ) return false; 2406 2407 $this_el.addClass( 'et_pb_tab_active' ).siblings().removeClass( 'et_pb_tab_active' ); 2408 2409 $tabs_container.data('et_pb_simple_slider').et_slider_move_to( $this_el.index() ); 2410 2411 if ( $this_el.closest( '.et_pb_tabs' ).attr('id') ) { 2412 var tab_state = []; 2413 tab_state.push( $this_el.closest( '.et_pb_tabs' ).attr('id') ); 2414 tab_state.push( $this_el.index() ); 2415 tab_state = tab_state.join( et_hash_module_param_seperator ); 2416 et_set_hash( tab_state ); 2417 } 2418 2419 return false; 2420 } ); 2421 2422 window.et_pb_set_tabs_height(); 2423 } 2424 window.et_pb_tabs_init( $et_pb_tabs ); 2425 } 2426 2427 if ( $et_pb_map.length || is_frontend_builder ) { 2428 function et_pb_init_maps() { 2429 $et_pb_map.each(function(){ 2430 et_pb_map_init( $(this) ); 2431 }); 2432 } 2433 2434 window.et_pb_map_init = function( $this_map_container ) { 2435 if ( typeof google === 'undefined' || typeof google.maps === 'undefined' ) { 2436 return; 2437 } 2438 2439 var $this_map = $this_map_container.children('.et_pb_map'), 2440 this_map_grayscale = $this_map_container.attr( 'data-grayscale' ) || 0, 2441 is_draggable = ( et_is_mobile_device && $this_map.data('mobile-dragging') !== 'off' ) || ! et_is_mobile_device, 2442 infowindow_active; 2443 2444 if ( this_map_grayscale !== 0 ) { 2445 this_map_grayscale = '-' + this_map_grayscale.toString(); 2446 } 2447 2448 $this_map_container.data('map', new google.maps.Map( $this_map[0], { 2449 zoom: parseInt( $this_map.attr('data-zoom') ), 2450 center: new google.maps.LatLng( parseFloat( $this_map.attr('data-center-lat') ) , parseFloat( $this_map.attr('data-center-lng') )), 2451 mapTypeId: google.maps.MapTypeId.ROADMAP, 2452 scrollwheel: $this_map.attr('data-mouse-wheel') == 'on' ? true : false, 2453 draggable: is_draggable, 2454 panControlOptions: { 2455 position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP 2456 }, 2457 zoomControlOptions: { 2458 position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP 2459 }, 2460 styles: [ { 2461 stylers: [ 2462 { saturation: parseInt( this_map_grayscale ) } 2463 ] 2464 } ] 2465 })); 2466 2467 $this_map_container.find('.et_pb_map_pin').each(function(){ 2468 var $this_marker = $(this); 2469 2470 var marker = new google.maps.Marker({ 2471 position: new google.maps.LatLng( parseFloat( $this_marker.attr('data-lat') ) , parseFloat( $this_marker.attr('data-lng') ) ), 2472 map: $this_map_container.data('map'), 2473 title: $this_marker.attr('data-title'), 2474 icon: { url: et_pb_custom.builder_images_uri + '/marker.png', size: new google.maps.Size( 46, 43 ), anchor: new google.maps.Point( 16, 43 ) }, 2475 shape: { coord: [1, 1, 46, 43], type: 'rect' }, 2476 anchorPoint: new google.maps.Point(0, -45) 2477 }); 2478 2479 if ( $this_marker.find('.infowindow').length ) { 2480 var infowindow = new google.maps.InfoWindow({ 2481 content: $this_marker.html() 2482 }); 2483 2484 google.maps.event.addListener( $this_map_container.data('map'), 'click', function() { 2485 infowindow.close(); 2486 }); 2487 2488 google.maps.event.addListener(marker, 'click', function() { 2489 if( infowindow_active ) { 2490 infowindow_active.close(); 2491 } 2492 infowindow_active = infowindow; 2493 2494 infowindow.open( $this_map_container.data('map'), marker ); 2495 }); 2496 } 2497 }); 2498 } 2499 2500 if ( window.et_load_event_fired ) { 2501 et_pb_init_maps(); 2502 } else { 2503 if ( typeof google !== 'undefined' && typeof google.maps !== 'undefined' ) { 2504 google.maps.event.addDomListener(window, 'load', function() { 2505 et_pb_init_maps(); 2506 } ); 2507 } 2508 } 2509 } 2510 2511 if ( $et_pb_shop.length ) { 2512 $et_pb_shop.each( function() { 2513 var $this_el = $(this), 2514 icon = $this_el.data('icon') || ''; 2515 2516 if ( icon === '' ) { 2517 return true; 2518 } 2519 2520 $this_el.find( '.et_overlay' ) 2521 .attr( 'data-icon', icon ) 2522 .addClass( 'et_pb_inline_icon' ); 2523 } ); 2524 } 2525 2526 if ( $et_pb_circle_counter.length || is_frontend_builder || $( '.et_pb_ajax_pagination_container' ).length > 0 ) { 2527 window.et_pb_circle_counter_init = function($the_counter, animate) { 2528 if ( $the_counter.width() <= 0 ) { 2529 return; 2530 } 2531 2532 $the_counter.easyPieChart({ 2533 animate: { 2534 duration: 1800, 2535 enabled: true 2536 }, 2537 size: 0 !== $the_counter.width() ? $the_counter.width() : 10, // set the width to 10 if actual width is 0 to avoid js errors 2538 barColor: $the_counter.data( 'bar-bg-color' ), 2539 trackColor: $the_counter.data( 'color' ) || '#000000', 2540 trackAlpha: $the_counter.data( 'alpha' ) || '0.1', 2541 scaleColor: false, 2542 lineWidth: 5, 2543 onStart: function() { 2544 $(this.el).find('.percent p').css({ 'visibility' : 'visible' }); 2545 }, 2546 onStep: function(from, to, percent) { 2547 $(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) ); 2548 }, 2549 onStop: function(from, to) { 2550 $(this.el).find('.percent-value').text( $(this.el).data('number-value') ); 2551 } 2552 }); 2553 } 2554 2555 window.et_pb_reinit_circle_counters = function( $et_pb_circle_counter ) { 2556 $et_pb_circle_counter.each(function(){ 2557 var $the_counter = $(this); 2558 window.et_pb_circle_counter_init($the_counter, false); 2559 2560 $the_counter.on('containerWidthChanged', function( event ){ 2561 $the_counter = $( event.target ); 2562 $the_counter.find('canvas').remove(); 2563 $the_counter.removeData('easyPieChart' ); 2564 window.et_pb_circle_counter_init($the_counter, true); 2565 }); 2566 2567 }); 2568 } 2569 window.et_pb_reinit_circle_counters( $et_pb_circle_counter ); 2570 } 2571 2572 if ( $et_pb_number_counter.length || is_frontend_builder || $( '.et_pb_ajax_pagination_container' ).length > 0 ) { 2573 window.et_pb_reinit_number_counters = function( $et_pb_number_counter ) { 2574 2575 var is_firefox = $('body').hasClass('gecko'); 2576 2577 function et_format_number( number_value, separator ) { 2578 return number_value.toString().replace( /\B(?=(\d{3})+(?!\d))/g, separator ); 2579 } 2580 2581 if ( $.fn.fitText ) { 2582 $et_pb_number_counter.find( '.percent p' ).fitText( 0.3 ); 2583 } 2584 2585 $et_pb_number_counter.each(function(){ 2586 var $this_counter = $(this); 2587 var separator = $this_counter.data('number-separator'); 2588 2589 $this_counter.easyPieChart({ 2590 animate: { 2591 duration: 1800, 2592 enabled: true 2593 }, 2594 size: is_firefox ? 1 : 0, // firefox can't print page when it contains 0 sized canvas elements. 2595 trackColor: false, 2596 scaleColor: false, 2597 lineWidth: 0, 2598 onStart: function () { 2599 $(this.el).addClass('active'); 2600 }, 2601 onStep: function(from, to, percent) { 2602 if ( percent != to ) 2603 $(this.el).find('.percent-value').text( et_format_number( Math.round( parseInt( percent ) ), separator ) ); 2604 }, 2605 onStop: function(from, to) { 2606 $(this.el).find('.percent-value').text( et_format_number( $(this.el).data('number-value'), separator ) ); 2607 } 2608 }); 2609 }); 2610 }; 2611 window.et_pb_reinit_number_counters( $et_pb_number_counter ); 2612 } 2613 2614 window.et_apply_parallax = function() { 2615 if ( ! $(this).length || typeof $(this) === 'undefined' || typeof $(this).offset() === 'undefined') { 2616 return; 2617 } 2618 2619 var $this = $(this), 2620 element_top = $this.offset().top, 2621 window_top = $et_window.scrollTop(), 2622 y_pos = ( ( ( window_top + $et_window.height() ) - element_top ) * 0.3 ), 2623 main_position; 2624 2625 main_position = 'translate(0, ' + y_pos + 'px)'; 2626 2627 $this.children('.et_parallax_bg').css( { 2628 '-webkit-transform' : main_position, 2629 '-moz-transform' : main_position, 2630 '-ms-transform' : main_position, 2631 'transform' : main_position 2632 } ); 2633 } 2634 2635 window.et_parallax_set_height = function() { 2636 var $this = $(this), 2637 bg_height; 2638 2639 bg_height = ( $et_window.height() * 0.3 + $this.innerHeight() ); 2640 2641 $this.find('.et_parallax_bg').css( { 'height' : bg_height } ); 2642 } 2643 2644 function et_toggle_animation_callback( initial_toggle_state, $module, $section ) { 2645 if ( 'closed' === initial_toggle_state ) { 2646 $module.removeClass('et_pb_toggle_close').addClass('et_pb_toggle_open'); 2647 } else { 2648 $module.removeClass('et_pb_toggle_open').addClass('et_pb_toggle_close'); 2649 } 2650 2651 if ( $section.hasClass( 'et_pb_section_parallax' ) && !$section.children().hasClass( 'et_pb_parallax_css') ) { 2652 $.proxy( et_parallax_set_height, $section )(); 2653 } 2654 } 2655 2656 $( 'body' ).on( 'click', '.et_pb_toggle_title, .et_fb_toggle_overlay', function() { 2657 var $this_heading = $(this), 2658 $module = $this_heading.closest('.et_pb_toggle'), 2659 $section = $module.parents( '.et_pb_section' ), 2660 $content = $module.find('.et_pb_toggle_content'), 2661 $accordion = $module.closest( '.et_pb_accordion' ), 2662 is_accordion = $accordion.length, 2663 is_accordion_toggling = $accordion.hasClass( 'et_pb_accordion_toggling' ), 2664 window_offset_top = $(window).scrollTop(), 2665 fixed_header_height = 0, 2666 initial_toggle_state = $module.hasClass( 'et_pb_toggle_close' ) ? 'closed' : 'opened', 2667 $accordion_active_toggle, 2668 module_offset; 2669 2670 if ( is_accordion ) { 2671 if ( $module.hasClass('et_pb_toggle_open') || is_accordion_toggling ) { 2672 return false;
2673 } 2674 2675 $accordion.addClass( 'et_pb_accordion_toggling' ); 2676 $accordion_active_toggle = $module.siblings('.et_pb_toggle_open'); 2677 } 2678 2679 if ( $content.is( ':animated' ) ) { 2680 return; 2681 } 2682 2683 $content.slideToggle(700, function () { 2684 et_toggle_animation_callback(initial_toggle_state, $module, $section); 2685 }); 2686 2687 if ( is_accordion ) { 2688 $accordion_active_toggle.find('.et_pb_toggle_content').slideToggle( 700, function() { 2689 $accordion_active_toggle.removeClass( 'et_pb_toggle_open' ).addClass('et_pb_toggle_close'); 2690 $accordion.removeClass( 'et_pb_accordion_toggling' ); 2691 2692 module_offset = $module.offset(); 2693 2694 // Calculate height of fixed nav 2695 if ( $('#wpadminbar').length ) { 2696 fixed_header_height += $('#wpadminbar').height(); 2697 } 2698 2699 if ( $('#top-header').length ) { 2700 fixed_header_height += $('#top-header').height(); 2701 } 2702 2703 if ( $('#main-header').length && ! window.et_is_vertical_nav ) { 2704 fixed_header_height += $('#main-header').height(); 2705 } 2706 2707 // Compare accordion offset against window's offset and adjust accordingly 2708 if ( ( window_offset_top + fixed_header_height ) > module_offset.top ) { 2709 $('html, body').animate({ scrollTop : ( module_offset.top - fixed_header_height - 50 ) }); 2710 } 2711 } ); 2712 } 2713 } ); 2714 2715 // Email Validation 2716 // Use the regex defined in the HTML5 spec for input[type=email] validation 2717 // (see https://www.w3.org/TR/2016/REC-html51-20161101/sec-forms.html#email-state-typeemail) 2718 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])?)*$/; 2719 2720 var $et_contact_container = $( '.et_pb_contact_form_container' ); 2721 2722 if ( $et_contact_container.length ) { 2723 $et_contact_container.each( function() { 2724 var $this_contact_container = $( this ), 2725 $et_contact_form = $this_contact_container.find( 'form' ), 2726 $et_contact_submit = $this_contact_container.find( 'input.et_pb_contact_submit' ),
2727 $et_inputs = $et_contact_form.find( 'input[type=text], .et_pb_checkbox_handle, input[type=radio]:checked, textarea, .et_pb_contact_select' ), 2728 redirect_url = typeof $this_contact_container.data( 'redirect_url' ) !== 'undefined' ? $this_contact_container.data( 'redirect_url' ) : ''; 2729 2730 $et_contact_form.find( 'input[type=checkbox]' ).on( 'change', function() { 2731 var $checkbox = $(this); 2732 var $checkbox_field = $checkbox.siblings( 'input[type=text]:first' ); 2733 var is_checked = $checkbox.prop( 'checked' ); 2734 2735 $checkbox_field.val( is_checked ? $checkbox_field.data( 'checked' ) : $checkbox_field.data( 'unchecked' ) ); 2736 } ); 2737 2738 $et_contact_form.on( 'submit', function( event ) { 2739 var $this_contact_form = $( this ), 2740 $this_inputs = $this_contact_form.find( 'input[type=text], .et_pb_checkbox_handle, .et_pb_contact_field[data-type="radio"], textarea, select' ), 2741 this_et_contact_error = false, 2742 $et_contact_message = $this_contact_form.closest( '.et_pb_contact_form_container' ).find( '.et-pb-contact-message' ), 2743 et_message = '', 2744 et_fields_message = '', 2745 $this_contact_container = $this_contact_form.closest( '.et_pb_contact_form_container' ), 2746 $captcha_field = $this_contact_form.find( '.et_pb_contact_captcha' ), 2747 form_unique_id = typeof $this_contact_container.data( 'form_unique_num' ) !== 'undefined' ? $this_contact_container.data( 'form_unique_num' ) : 0, 2748 inputs_list = []; 2749 et_message = '<ul>'; 2750 2751 $this_inputs.removeClass( 'et_contact_error' ); 2752 2753 var hidden_fields = []; 2754 2755 $this_inputs.each( function(){ 2756 var $this_el = $( this ); 2757 var $this_wrapper = false; 2758 2759 if ( 'checkbox' === $this_el.data('field_type') ) { 2760 $this_wrapper = $this_el.parents('.et_pb_contact_field'); 2761 $this_wrapper.removeClass( 'et_contact_error' ); 2762 } 2763 2764 if ( 'radio' === $this_el.data('type') ) { 2765 $this_el = $this_el.find('input[type="radio"]'); 2766 $this_wrapper = $this_el.parents('.et_pb_contact_field'); 2767 } 2768 2769 var this_id = $this_el.attr( 'id' ); 2770 var this_val = $this_el.val(); 2771 var this_label = $this_el.siblings( 'label:first' ).text(); 2772 var field_type = typeof $this_el.data( 'field_type' ) !== 'undefined' ? $this_el.data( 'field_type' ) : 'text'; 2773 var required_mark = typeof $this_el.data( 'required_mark' ) !== 'undefined' ? $this_el.data( 'required_mark' ) : 'not_required'; 2774 var original_id = typeof $this_el.data( 'original_id' ) !== 'undefined' ? $this_el.data( 'original_id' ) : ''; 2775 var unchecked = false; 2776 var default_value; 2777 2778 // radio field properties adjustment 2779 if ( 'radio' === field_type ) { 2780 if ( 0 !== $this_wrapper.find( 'input[type="radio"]').length ) { 2781 field_type = 'radio'; 2782 2783 var $firstRadio = $this_wrapper.find('input[type="radio"]:first'); 2784 2785 required_mark = typeof $firstRadio.data( 'required_mark' ) !== 'undefined' ? $firstRadio.data( 'required_mark' ) : 'not_required'; 2786 2787 this_val = ''; 2788 if ( $this_wrapper.find('input[type="radio"]:checked') ) { 2789 this_val = $this_wrapper.find('input[type="radio"]:checked').val(); 2790 } 2791 } 2792 2793 this_label = $this_wrapper.find('.et_pb_contact_form_label').text(); 2794 this_id = $this_wrapper.find('input[type="radio"]:first').attr('name'); 2795 original_id = $this_wrapper.attr('data-id'); 2796 2797 if ( 0 === $this_wrapper.find('input[type="radio"]:checked').length ) { 2798 unchecked = true; 2799 } 2800 } 2801 2802 // radio field properties adjustment 2803 if ( 'checkbox' === field_type ) { 2804 this_val = ''; 2805 2806 if ( 0 !== $this_wrapper.find( 'input[type="checkbox"]').length ) { 2807 field_type = 'checkbox'; 2808 2809 var $checkboxHandle = $this_wrapper.find('.et_pb_checkbox_handle'); 2810 2811 required_mark = typeof $checkboxHandle.data( 'required_mark' ) !== 'undefined' ? $checkboxHandle.data( 'required_mark' ) : 'not_required'; 2812 2813 if ( $this_wrapper.find('input[type="checked"]:checked') ) { 2814 this_val = []; 2815 $this_wrapper.find('input[type="checkbox"]:checked').each(function() { 2816 this_val.push( $(this).val() ); 2817 }); 2818 2819 this_val = this_val.join(', '); 2820 } 2821 } 2822 2823 $this_wrapper.find('.et_pb_checkbox_handle').val(this_val); 2824 2825 this_label = $this_wrapper.find('.et_pb_contact_form_label').text(); 2826 this_id = $this_wrapper.find('.et_pb_checkbox_handle').attr('name'); 2827 original_id = $this_wrapper.attr('data-id'); 2828 2829 if ( 0 === $this_wrapper.find('input[type="checkbox"]:checked').length ) { 2830 unchecked = true; 2831 } 2832 } 2833 2834 // Escape double quotes in label 2835 this_label = this_label.replace(/"/g, """); 2836 2837 // Store the labels of the conditionally hidden fields so that they can be 2838 // removed later if a custom message pattern is enabled 2839 if ( ! $this_el.is(':visible') && 'hidden' !== $this_el.attr('type') && 'radio' !== $this_el.attr('type') ) { 2840 hidden_fields.push( original_id ); 2841 return; 2842 } 2843 2844 if ( ( 'hidden' === $this_el.attr('type') || 'radio' === $this_el.attr('type') ) && ! $this_el.parents('.et_pb_contact_field').is(':visible') ) { 2845 hidden_fields.push( original_id ); 2846 return; 2847 } 2848 2849 // add current field data into array of inputs 2850 if ( typeof this_id !== 'undefined' ) {
2851 inputs_list.push( { 'field_id' : this_id, 'original_id' : original_id, 'required_mark' : required_mark, 'field_type' : field_type, 'field_label' : this_label } ); 2852 } 2853 2854 // add error message for the field if it is required and empty 2855 if ( 'required' === required_mark && ( '' === this_val || true === unchecked ) ) { 2856 2857 if ( false === $this_wrapper ) { 2858 $this_el.addClass( 'et_contact_error' ); 2859 } else { 2860 $this_wrapper.addClass( 'et_contact_error' ); 2861 } 2862 2863 this_et_contact_error = true; 2864 2865 default_value = this_label; 2866 2867 if ( '' === default_value ) { 2868 default_value = et_pb_custom.captcha; 2869 } 2870 2871 et_fields_message += '<li>' + default_value + '</li>'; 2872 } 2873 2874 // add error message if email field is not empty and fails the email validation 2875 if ( 'email' === field_type ) { 2876 // remove trailing/leading spaces and convert email to lowercase 2877 var processed_email = this_val.trim().toLowerCase(); 2878 var is_valid_email = et_email_reg_html5.test( processed_email ); 2879 2880 if ( '' !== processed_email && this_label !== processed_email && ! is_valid_email ) { 2881 $this_el.addClass( 'et_contact_error' ); 2882 this_et_contact_error = true; 2883 2884 if ( ! is_valid_email ) { 2885 et_message += '<li>' + et_pb_custom.invalid + '</li>'; 2886 } 2887 } 2888 } 2889 }); 2890 2891 // check the captcha value if required for current form 2892 if ( $captcha_field.length && '' !== $captcha_field.val() ) { 2893 var first_digit = parseInt( $captcha_field.data( 'first_digit' ) ), 2894 second_digit = parseInt( $captcha_field.data( 'second_digit' ) ); 2895 2896 if ( parseInt( $captcha_field.val() ) !== first_digit + second_digit ) { 2897 2898 et_message += '<li>' + et_pb_custom.wrong_captcha + '</li>'; 2899 this_et_contact_error = true; 2900 2901 // generate new digits for captcha 2902 first_digit = Math.floor( ( Math.random() * 15 ) + 1 ); 2903 second_digit = Math.floor( ( Math.random() * 15 ) + 1 ); 2904 2905 // set new digits for captcha 2906 $captcha_field.data( 'first_digit', first_digit ); 2907 $captcha_field.data( 'second_digit', second_digit ); 2908 2909 // regenerate captcha on page 2910 $this_contact_form.find( '.et_pb_contact_captcha_question' ).empty().append( first_digit + ' + ' + second_digit ); 2911 } 2912 2913 } 2914 2915 if ( ! this_et_contact_error ) { 2916 var $href = $( this ).attr( 'action' ), 2917 form_data = $( this ).serializeArray(); 2918 2919 form_data.push( { 2920 'name': 'et_pb_contact_email_fields_' + form_unique_id, 2921 'value' : JSON.stringify( inputs_list ) 2922 } ); 2923 2924 if ( hidden_fields.length > 0 ) { 2925 form_data.push( { 2926 'name': 'et_pb_contact_email_hidden_fields_' + form_unique_id, 2927 'value' : JSON.stringify( hidden_fields ) 2928 } ); 2929 } 2930 2931 $this_contact_container.removeClass('et_animated').removeAttr('style').fadeTo( 'fast', 0.2, function() { 2932 $this_contact_container.load( $href + ' #' + $this_contact_form.closest( '.et_pb_contact_form_container' ).attr( 'id' ) + '> *', form_data, function( responseText ) { 2933 if ( ! $( responseText ).find( '.et_pb_contact_error_text').length ) { 2934 2935 et_pb_maybe_log_event( $this_contact_container, 'con_goal' ); 2936 2937 // redirect if redirect URL is not empty and no errors in contact form 2938 if ( '' !== redirect_url ) { 2939 window.location.href = redirect_url; 2940 } 2941 } 2942 2943 $this_contact_container.fadeTo( 'fast', 1 ); 2944 } ); 2945 } ); 2946 } 2947 2948 et_message += '</ul>'; 2949 2950 if ( '' !== et_fields_message ) { 2951 if ( et_message != '<ul></ul>' ) { 2952 et_message = '<p class="et_normal_padding">' + et_pb_custom.contact_error_message + '</p>' + et_message; 2953 } 2954 2955 et_fields_message = '<ul>' + et_fields_message + '</ul>'; 2956 2957 et_fields_message = '<p>' + et_pb_custom.fill_message + '</p>' + et_fields_message; 2958 2959 et_message = et_fields_message + et_message; 2960 } 2961 2962 if ( et_message != '<ul></ul>' ) { 2963 $et_contact_message.html( et_message ); 2964 2965 // If parent of this contact form uses parallax 2966 if ( $this_contact_container.parents('.et_pb_section_parallax').length ) { 2967 $this_contact_container.parents('.et_pb_section_parallax').each(function() { 2968 var $parallax_element = $(this), 2969 $parallax = $parallax_element.children('.et_parallax_bg'), 2970 is_true_parallax = ( ! $parallax.hasClass( 'et_pb_parallax_css' ) ); 2971 2972 if ( is_true_parallax ) { 2973 $et_window.trigger( 'resize' ); 2974 } 2975 }); 2976 } 2977 } 2978 2979 event.preventDefault(); 2980 }); 2981 }); 2982 } 2983 2984 window.et_pb_play_overlayed_video = function( $play_video ) { 2985 var $this = $play_video; 2986 var $video_image = $this.closest('.et_pb_video_overlay'); 2987 var $wrapper = $this.closest('.et_pb_video, .et_main_video_container, .et_pb_video_wrap'); 2988 var $video_iframe = $wrapper.find('iframe'); 2989 var is_embedded = $video_iframe.length > 0; 2990 var is_fb_video = $wrapper.find('.fb-video').length; 2991 var video_iframe_src; 2992 var video_iframe_src_splitted; 2993 var video_iframe_src_autoplay; 2994 2995 if (is_embedded) { 2996 if (is_fb_video && 'undefined' !== typeof $video_iframe[2]) { 2997 // Facebook uses three http/https/iframe 2998 $video_iframe = $($video_iframe[2]); 2999 } 3000 3001 // Add autoplay parameter to automatically play embedded content when overlay is clicked 3002 video_iframe_src = $video_iframe.attr('src'); 3003 video_iframe_src_splitted = video_iframe_src.split("?"); 3004 3005 if (video_iframe_src.indexOf('autoplay=') !== -1) { 3006 return; 3007 } 3008 3009 if (typeof video_iframe_src_splitted[1] !== 'undefined') { 3010 video_iframe_src_autoplay = video_iframe_src_splitted[0] + "?autoplay=1&" + video_iframe_src_splitted[1]; 3011 } else { 3012 video_iframe_src_autoplay = video_iframe_src_splitted[0] + "?autoplay=1"; 3013 } 3014 3015 $video_iframe.attr({ 3016 'src': video_iframe_src_autoplay 3017 }); 3018 } else { 3019 $wrapper.find('video').get(0).play(); 3020 } 3021 3022 3023 $video_image.fadeTo( 500, 0, function() { 3024 var $image = $(this); 3025 3026 $image.css( 'display', 'none' ); 3027 } ); 3028 }; 3029 3030 $( '.et_pb_post .et_pb_video_overlay, .et_pb_video .et_pb_video_overlay, .et_pb_video_wrap .et_pb_video_overlay' ).click( function() { 3031 var $this = $(this); 3032 3033 et_pb_play_overlayed_video( $this ); 3034 3035 return false;
3036 } ); 3037 3038 window.et_pb_resize_section_video_bg = function( $video ) { 3039 $element = typeof $video !== 'undefined' ? $video.closest( '.et_pb_section_video_bg' ) : $( '.et_pb_section_video_bg' ); 3040 3041 $element.each( function() { 3042 var $this_el = $(this); 3043 3044 if ( is_frontend_builder ) { 3045 $this_el.removeAttr('data-ratio'); 3046 $this_el.find('video').removeAttr('style'); 3047 } 3048 3049 var el_ratio = parseFloat( $this_el.attr( 'data-ratio' ) ); 3050 var el_width = parseInt( $this_el.find( 'video' ).attr( 'width' ) || $this_el.find( 'video' ).width() ); 3051 var el_height = parseInt( $this_el.find( 'video' ).attr( 'height' ) || $this_el.find( 'video' ).height() ); 3052 3053 var ratio = ( ! isNaN( el_ratio ) ) ? el_ratio : ( el_width / el_height ); 3054 3055 var $video_elements = $this_el.find( '.mejs-video, video, object' ).css( 'margin', 0 ); 3056 3057 var $container = $this_el.closest( '.et_pb_section_video' ).length 3058 ? $this_el.closest( '.et_pb_section_video' ) 3059 : $this_el.closest( '.et_pb_slides' ); 3060 3061 var body_width = $container.innerWidth(); 3062 3063 var container_height = $container.innerHeight(); 3064 3065 var width, height; 3066 3067 if ( typeof $this_el.attr( 'data-ratio' ) == 'undefined' && !isNaN(ratio) ) { 3068 $this_el.attr( 'data-ratio', ratio ); 3069 } 3070 3071 if ( body_width / container_height < ratio ) { 3072 width = container_height * ratio; 3073 height = container_height; 3074 } else { 3075 width = body_width; 3076 height = body_width / ratio; 3077 } 3078 3079 $video_elements.width( width ).height( height ); 3080 3081 // need to re-set the values to make it work correctly in Frontend builder 3082 if ( is_frontend_builder ) { 3083 setTimeout( function() { 3084 $video_elements.width( width ).height( height ); 3085 }, 0 ); 3086 } 3087 } ); 3088 }; 3089 3090 window.et_pb_center_video = function( $video ) { 3091 $element = typeof $video !== 'undefined' ? $video : $( '.et_pb_section_video_bg .mejs-video' ); 3092 3093 if ( ! $element.length ) { 3094 return; 3095 } 3096 3097 $element.each( function() { 3098 var $this_el = $(this); 3099 3100 et_pb_adjust_video_margin( $this_el ); 3101 3102 // need to re-calculate the values in Frontend builder 3103 if ( is_frontend_builder ) { 3104 setTimeout( function() { 3105 et_pb_adjust_video_margin( $this_el ); 3106 }, 0 ); 3107 } 3108 3109 if ( typeof $video !== 'undefined' ) { 3110 if ( $video.closest( '.et_pb_slider' ).length && ! $video.closest( '.et_pb_first_video' ).length ) { 3111 return false; 3112 } 3113 } 3114 } ); 3115 }; 3116 3117 window.et_pb_adjust_video_margin = function( $el ) { 3118 var $video_width = $el.width() / 2; 3119 var $video_width_negative = 0 - $video_width; 3120 3121 $el.css("margin-left", $video_width_negative ); 3122 } 3123 3124 function et_fix_slider_height( $slider ) { 3125 var $this_slider = $slider || $et_pb_slider; 3126 3127 if ( ! $this_slider || ! $this_slider.length ) { 3128 return; 3129 } 3130 3131 $this_slider.each( function() { 3132 var $slide_section = $(this).parent( '.et_pb_section' ), 3133 $slides = $(this).find( '.et_pb_slide' ), 3134 $slide_containers = $slides.find( '.et_pb_container' ), 3135 max_height = 0, 3136 image_margin = 0, 3137 need_image_margin_top = $(this).hasClass( 'et_pb_post_slider_image_top' ), 3138 need_image_margin_bottom = $(this).hasClass( 'et_pb_post_slider_image_bottom' ); 3139 3140 // If this is appears at the first section beneath transparent nav, skip it 3141 // leave it to et_fix_page_container_position() 3142 if ( $slide_section.is( '.et_pb_section_first' ) ){ 3143 return true; 3144 } 3145 3146 $slide_containers.css( 'height', 0 ); 3147 3148 // make slides visible to calculate the height correctly 3149 $slides.addClass( 'et_pb_temp_slide' ); 3150 3151 if ( typeof $(this).data('et_pb_simple_slider') === 'object' ) { 3152 $(this).data('et_pb_simple_slider').et_fix_slider_content_images(); 3153 } 3154 3155 $slides.each( function() { 3156 var height = parseFloat( $(this).innerHeight() ), 3157 $slide_image = $(this).find( '.et_pb_slide_image' ), 3158 adjustedHeight = parseFloat( $(this).data( 'adjustedHeight' ) ), 3159 autoTopPadding = isNaN( adjustedHeight ) ? 0 : adjustedHeight; 3160 3161 // reduce the height by autopadding value if slider height was adjusted. This is required in VB. 3162 height = ( autoTopPadding && autoTopPadding < height ) ? ( height - autoTopPadding ) : height; 3163 3164 if ( need_image_margin_top || need_image_margin_bottom ) { 3165 if ( $slide_image.length ) { 3166 // get the margin from slides with image 3167 image_margin = need_image_margin_top ? parseFloat( $slide_image.css( 'margin-top' ) ) : parseFloat( $slide_image.css( 'margin-bottom' ) ); 3168 image_margin += 10; 3169 } else { 3170 // add class to slides without image to adjust their height accordingly 3171 $(this).find( '.et_pb_container' ).addClass( 'et_pb_no_image' ); 3172 } 3173 } 3174 3175 // mark the slides without content 3176 if ( 0 === Math.abs( parseInt( $(this).find( '.et_pb_slide_description' ).height() ) ) ) { 3177 $(this).find( '.et_pb_container' ).addClass( 'et_pb_empty_slide' ); 3178 } 3179 3180 if ( max_height < height ) { 3181 max_height = height; 3182 } 3183 } ); 3184 3185 if ( ( max_height + image_margin ) < 1 ) { 3186 // No slides have any content. It's probably being used with background images only. 3187 // Reset the height so that it falls back to the default padding for the content. 3188 $slide_containers.css( 'height', '' ); 3189 3190 } else { 3191 $slide_containers.css( 'height', max_height + image_margin ); 3192 } 3193 3194 // remove temp class after getting the slider height 3195 $slides.removeClass( 'et_pb_temp_slide' ); 3196 3197 // Show the active slide's image (if exists) 3198 $slides.filter('.et-pb-active-slide') 3199 .find( '.et_pb_slide_image' ) 3200 .children( 'img' ) 3201 .addClass( 'active' ); 3202 } ); 3203 } 3204 var debounced_et_fix_slider_height = {}; 3205 3206 // This function can end up being called a lot of times and it's quite expensive in terms of cpu due to 3207 // recalculating styles. Debouncing it (VB only) for performances reasons. 3208 window.et_fix_slider_height = !is_frontend_builder ? et_fix_slider_height : function($slider) { 3209 var $this_slider = $slider || $et_pb_slider; 3210 3211 if ( ! $this_slider || ! $this_slider.length ) { 3212 return; 3213 } 3214 3215 // Create a debounced function per slider 3216 var address = $this_slider.data('address'); 3217 if (!debounced_et_fix_slider_height[address]) { 3218 debounced_et_fix_slider_height[address] = window.et_pb_debounce(et_fix_slider_height, 100); 3219 } 3220 debounced_et_fix_slider_height[address]($slider); 3221 } 3222 3223 /** 3224 * Add conditional class to prevent unwanted dropdown nav 3225 */ 3226 function et_fix_nav_direction() { 3227 window_width = $(window).width(); 3228 $('.nav li.et-reverse-direction-nav').removeClass( 'et-reverse-direction-nav' ); 3229 $('.nav li li ul').each(function(){ 3230 var $dropdown = $(this), 3231 dropdown_width = $dropdown.width(), 3232 dropdown_offset = $dropdown.offset(), 3233 $parents = $dropdown.parents('.nav > li'); 3234 3235 if ( dropdown_offset.left > ( window_width - dropdown_width ) ) { 3236 $parents.addClass( 'et-reverse-direction-nav' ); 3237 } 3238 }); 3239 } 3240 et_fix_nav_direction(); 3241 3242 et_pb_form_placeholders_init( $( '.et_pb_comments_module #commentform' ) ); 3243 3244 $('.et_pb_fullwidth_menu ul.nav').each(function(i) { 3245 i++; 3246 et_duplicate_menu( $(this), $(this).parents('.et_pb_row').find('div .mobile_nav'), 'mobile_menu' + i, 'et_mobile_menu' ); 3247 }); 3248 3249 $('.et_pb_fullwidth_menu').each(function() { 3250 var this_menu = $( this ), 3251 bg_color = this_menu.data( 'bg_color' ); 3252 if ( bg_color ) { 3253 this_menu.find( 'ul' ).css( { 'background-color' : bg_color } ); 3254 } 3255 }); 3256 3257 $et_pb_newsletter_button.click( function( event ) { 3258 et_pb_submit_newsletter( $(this), event ); 3259 } ); 3260 3261 $et_pb_newsletter_button 3262 .closest('.et_pb_newsletter') 3263 .find('input[type=checkbox]') 3264 .on('change', function() { 3265 var $checkbox = $(this); 3266 var $checkbox_field = $checkbox.siblings('input[type=text]:first'); 3267 var is_checked = $checkbox.prop('checked'); 3268 3269 $checkbox_field.val(is_checked ? $checkbox_field.data('checked') : $checkbox_field.data('unchecked')); 3270 }); 3271 3272 window.et_pb_submit_newsletter = function( $submit, event ) { 3273 if ($submit.closest('.et_pb_login_form').length) { 3274 et_pb_maybe_log_event($submit.closest('.et_pb_newsletter'), 'con_goal'); 3275 return; 3276 } 3277 3278 if ( typeof event !== 'undefined' ) { 3279 event.preventDefault(); 3280 } 3281
3282 // check if it is a feedburner feed subscription 3283 if ($('.et_pb_feedburner_form').length > 0) { 3284 $feed_name = $('.et_pb_feedburner_form input[name=uri]').val(); 3285 window.open('https://feedburner.google.com/fb/a/mailverify?uri=' + $feed_name, 'et-feedburner-subscribe', 'scrollbars=yes,width=550,height=520'); 3286 return true; 3287 } // otherwise keep things moving 3288 3289 var $newsletter_container = $submit.closest('.et_pb_newsletter'); 3290 var $name = $newsletter_container.find('input[name="et_pb_signup_firstname"]'); 3291 var $lastname = $newsletter_container.find('input[name="et_pb_signup_lastname"]'); 3292 var $email = $newsletter_container.find('input[name="et_pb_signup_email"]'); 3293 var list_id = $newsletter_container.find('input[name="et_pb_signup_list_id"]').val(); 3294 var $error_message = $newsletter_container.find('.et_pb_newsletter_error').hide(); 3295 var provider = $newsletter_container.find('input[name="et_pb_signup_provider"]').val(); 3296 var account = $newsletter_container.find('input[name="et_pb_signup_account_name"]').val(); 3297 var ip_address = $newsletter_container.find('input[name="et_pb_signup_ip_address"]').val(); 3298 3299 var $fields_container = $newsletter_container.find('.et_pb_newsletter_fields'); 3300 3301 var $success_message = $newsletter_container.find( '.et_pb_newsletter_success' ); 3302 var redirect_url = $newsletter_container.data( 'redirect_url' ); 3303 var redirect_query = $newsletter_container.data( 'redirect_query' ); 3304 var custom_fields = {}; 3305 var hidden_fields = []; 3306 var et_message = '<ul>'; 3307 var et_fields_message = ''; 3308 3309 var $custom_fields = $fields_container 3310 .find('input[type=text], .et_pb_checkbox_handle, .et_pb_contact_field[data-type="radio"], textarea, select') 3311 .filter('.et_pb_signup_custom_field, .et_pb_signup_custom_field *'); 3312 3313 3314 $name.removeClass( 'et_pb_signup_error' ); 3315 $lastname.removeClass( 'et_pb_signup_error' ); 3316 $email.removeClass( 'et_pb_signup_error' ); 3317 $custom_fields.removeClass('et_contact_error'); 3318 $error_message.html(''); 3319 3320 // Validate user input 3321 var is_valid = true; 3322 var form = $submit.closest('.et_pb_newsletter_form form'); 3323 if (form.length > 0 && typeof form[0].reportValidity === 'function') { 3324 // Checks HTML5 validation constraints 3325 is_valid = form[0].reportValidity(); 3326 } 3327 3328 if ( $name.length > 0 && ! $name.val() ) { 3329 $name.addClass( 'et_pb_signup_error' ); 3330 is_valid = false; 3331 } 3332 3333 if ( $lastname.length > 0 && ! $lastname.val() ) { 3334 $lastname.addClass( 'et_pb_signup_error' ); 3335 is_valid = false; 3336 } 3337 3338 if ( ! et_email_reg_html5.test( $email.val() ) ) { 3339 $email.addClass( 'et_pb_signup_error' ); 3340 is_valid = false; 3341 } 3342 3343 if ( ! is_valid ) { 3344 return; 3345 } 3346 3347 $custom_fields.each(function() { 3348 var $this_el = $(this); 3349 var $this_wrapper = false;
3350 3351 if ('checkbox' === $this_el.data('field_type')) { 3352 $this_wrapper = $this_el.parents('.et_pb_contact_field'); 3353 $this_wrapper.removeClass('et_contact_error'); 3354 } 3355 3356 if ('radio' === $this_el.data('type')) { 3357 $this_el = $this_el.find('input[type="radio"]'); 3358 $this_wrapper = $this_el.parents('.et_pb_contact_field'); 3359 } 3360 3361 var this_id = $this_el.data('id'); 3362 var this_val = $this_el.val(); 3363 var this_label = $this_el.siblings('label:first').text(); 3364 var field_type = typeof $this_el.data('field_type') !== 'undefined' ? $this_el.data('field_type') : 'text'; 3365 var required_mark = typeof $this_el.data('required_mark') !== 'undefined' ? $this_el.data('required_mark') : 'not_required'; 3366 var original_id = typeof $this_el.data('original_id') !== 'undefined' ? $this_el.data('original_id') : ''; 3367 var unchecked = false; 3368 var default_value; 3369 3370 if (! this_id) { 3371 this_id = $this_el.data('original_id'); 3372 } 3373 3374 // radio field properties adjustment 3375 if ('radio' === field_type) { 3376 if (0 !== $this_wrapper.find('input[type="radio"]').length) { 3377 var $firstRadio = $this_wrapper.find('input[type="radio"]:first'); 3378 3379 required_mark = typeof $firstRadio.data('required_mark') !== 'undefined' ? $firstRadio.data('required_mark') : 'not_required'; 3380 3381 this_val = ''; 3382 3383 if ($this_wrapper.find('input[type="radio"]:checked')) { 3384 this_val = $this_wrapper.find('input[type="radio"]:checked').val(); 3385 } 3386 } 3387 3388 this_label = $this_wrapper.find('.et_pb_contact_form_label').text(); 3389 this_id = $this_el.data('original_id'); 3390 3391 if (! $.isEmptyObject(this_val)) { 3392 custom_fields[this_id] = this_val; 3393 } 3394 3395 if (0 === $this_wrapper.find('input[type="radio"]:checked').length) { 3396 unchecked = true; 3397 } 3398 3399 if (this_val) { 3400 custom_fields[this_id] = this_val; 3401 } 3402 3403 } else if ('checkbox' === field_type) { 3404 this_val = {}; 3405 3406 if (0 !== $this_wrapper.find('input[type="checkbox"]').length) { 3407 var $checkboxHandle = $this_wrapper.find('.et_pb_checkbox_handle'); 3408 3409 required_mark = typeof $checkboxHandle.data('required_mark') !== 'undefined' ? $checkboxHandle.data('required_mark') : 'not_required'; 3410 3411 if ($this_wrapper.find('input[type="checked"]:checked')) { 3412 $this_wrapper.find('input[type="checkbox"]:checked').each(function() { 3413 var field_id = $(this).data('id'); 3414 this_val[field_id] = $(this).val(); 3415 }); 3416 } 3417 } 3418 3419 this_label = $this_wrapper.find('.et_pb_contact_form_label').text(); 3420 this_id = $this_wrapper.attr('data-id'); 3421 3422 if (! $.isEmptyObject(this_val)) { 3423 custom_fields[this_id] = this_val; 3424 } 3425 3426 if (0 === $this_wrapper.find('input[type="checkbox"]:checked').length) { 3427 unchecked = true; 3428 } 3429 } else if ('ontraport' === provider && 'select' === field_type) { 3430 // Need to pass option ID as a value for dropdown menu in Ontraport 3431 var $selected_option = $this_el.find(':selected'); 3432 custom_fields[this_id] = $selected_option.length > 0 ? $selected_option.data('id') : this_val; 3433 } else { 3434 custom_fields[this_id] = this_val; 3435 } 3436 3437 // Escape double quotes in label 3438 this_label = this_label.replace(/"/g, """); 3439 3440 // Store the labels of the conditionally hidden fields so that they can be 3441 // removed later if a custom message pattern is enabled 3442 if (! $this_el.is(':visible') && 'hidden' !== $this_el.attr('type') && 'radio' !== $this_el.attr('type')) { 3443 hidden_fields.push(original_id); 3444 return; 3445 } 3446 3447 if (('hidden' === $this_el.attr('type') || 'radio' === $this_el.attr('type')) && ! $this_el.parents('.et_pb_contact_field').is(':visible')) { 3448 hidden_fields.push(this_id); 3449 return; 3450 } 3451 3452 // add error message for the field if it is required and empty 3453 if ('required' === required_mark && ('' === this_val || true === unchecked)) { 3454 3455 if (false === $this_wrapper) { 3456 $this_el.addClass('et_contact_error'); 3457 } else { 3458 $this_wrapper.addClass('et_contact_error'); 3459 } 3460 3461 is_valid = false;
3462 3463 default_value = this_label; 3464 3465 if ('' === default_value) { 3466 default_value = et_pb_custom.captcha; 3467 } 3468 3469 et_fields_message += '<li>' + default_value + '</li>'; 3470 } 3471 3472 // add error message if email field is not empty and fails the email validation 3473 if ('email' === field_type) { 3474 // remove trailing/leading spaces and convert email to lowercase 3475 var processed_email = this_val.trim().toLowerCase(); 3476 var is_valid_email = et_email_reg_html5.test(processed_email); 3477 3478 if ('' !== processed_email && this_label !== processed_email && ! is_valid_email) { 3479 $this_el.addClass('et_contact_error'); 3480 is_valid = false; 3481 3482 if (! is_valid_email) { 3483 et_message += '<li>' + et_pb_custom.invalid + '</li>'; 3484 } 3485 } 3486 } 3487 }); 3488 3489 et_message += '</ul>'; 3490 3491 if ('' !== et_fields_message) { 3492 if (et_message !== '<ul></ul>') { 3493 et_message = '<p class="et_normal_padding">' + et_pb_custom.contact_error_message + '</p>' + et_message; 3494 } 3495 3496 et_fields_message = '<ul>' + et_fields_message + '</ul>'; 3497 3498 et_fields_message = '<p>' + et_pb_custom.fill_message + '</p>' + et_fields_message; 3499 3500 et_message = et_fields_message + et_message; 3501 } 3502 3503 if (et_message !== '<ul></ul>') { 3504 $error_message.html(et_message).show(); 3505 3506 // If parent of this contact form uses parallax 3507 if ($newsletter_container.parents('.et_pb_section_parallax').length) { 3508 $newsletter_container.parents('.et_pb_section_parallax').each(function() { 3509 var $parallax_element = $(this), 3510 $parallax = $parallax_element.children('.et_parallax_bg'), 3511 is_true_parallax = (! $parallax.hasClass('et_pb_parallax_css')); 3512 3513 if (is_true_parallax) { 3514 $et_window.trigger('resize'); 3515 } 3516 }); 3517 } 3518 3519 return; 3520 } 3521 3522 function get_redirect_query() { 3523 var query = {}; 3524 3525 if ( ! redirect_query ) { 3526 return ''; 3527 } 3528 3529 if ( $name.length > 0 && redirect_query.indexOf( 'name' ) > -1 ) { 3530 query.first_name = $name.val(); 3531 } 3532 3533 if ( $lastname.length > 0 && redirect_query.indexOf( 'last_name' ) > -1 ) { 3534 query.last_name = $lastname.val(); 3535 } 3536 3537 if ( redirect_query.indexOf( 'email' ) > -1 ) { 3538 query.email = $email.val(); 3539 } 3540 3541 if ( redirect_query.indexOf( 'ip_address' ) > -1 ) { 3542 query.ip_address = $newsletter_container.data( 'ip_address' ); 3543 } 3544 3545 if ( redirect_query.indexOf( 'css_id' ) > -1 ) { 3546 query.form_id = $newsletter_container.attr( 'id' ); 3547 } 3548 3549 return decodeURIComponent( $.param( query ) ); 3550 } 3551 3552 $.ajax( { 3553 type: "POST", 3554 url: et_pb_custom.ajaxurl, 3555 dataType: "json", 3556 data: { 3557 action : 'et_pb_submit_subscribe_form', 3558 et_frontend_nonce : et_pb_custom.et_frontend_nonce, 3559 et_list_id : list_id, 3560 et_firstname : $name.val(), 3561 et_lastname : $lastname.val(), 3562 et_email : $email.val(), 3563 et_provider : provider, 3564 et_account: account, 3565 et_ip_address: ip_address, 3566 et_custom_fields: custom_fields, 3567 et_hidden_fields: hidden_fields 3568 }, 3569 beforeSend: function() { 3570 $newsletter_container 3571 .find( '.et_pb_newsletter_button' ) 3572 .addClass( 'et_pb_button_text_loading' ) 3573 .find('.et_subscribe_loader') 3574 .show(); 3575 }, 3576 complete: function() { 3577 $newsletter_container 3578 .find( '.et_pb_newsletter_button' ) 3579 .removeClass( 'et_pb_button_text_loading' ) 3580 .find('.et_subscribe_loader') 3581 .hide(); 3582 }, 3583 success: function( data ) { 3584 if ( ! data ) { 3585 $error_message.html( et_pb_custom.subscription_failed ).show(); 3586 return; 3587 } 3588 3589 if ( data.error ) { 3590 $error_message.show().append('<h2>').text( data.error ); 3591 } 3592 3593 if ( data.success ) { 3594 if ( redirect_url ) { 3595 et_pb_maybe_log_event( $newsletter_container, 'con_goal', function() { 3596 var query = get_redirect_query(); 3597 3598 if ( redirect_url.indexOf( '?' ) > -1 ) { 3599 redirect_url += '&'; 3600 } else { 3601 redirect_url += '?'; 3602 } 3603 3604 window.location = redirect_url + query; 3605 } ); 3606 } else { 3607 et_pb_maybe_log_event( $newsletter_container, 'con_goal' ); 3608 $newsletter_container.find( '.et_pb_newsletter_fields' ).hide(); 3609 $success_message.show(); 3610 } 3611 } 3612 } 3613 } ); 3614 }; 3615 3616 window.et_fix_testimonial_inner_width = function() { 3617 var window_width = $( window ).width(); 3618 3619 if ( window_width > 959 ) { 3620 $( '.et_pb_testimonial' ).each( function() { 3621 if ( ! $(this).is( ':visible' ) ) { 3622 return; 3623 } 3624 3625 var $testimonial = $(this); 3626 var $portrait = $testimonial.find( '.et_pb_testimonial_portrait' ); 3627 var portrait_width = $portrait.outerWidth( true ); 3628 var $testimonial_descr = $testimonial.find( '.et_pb_testimonial_description' ); 3629 var $outer_column = $testimonial.closest( '.et_pb_column' ); 3630 var testimonial_indent = ! ( $outer_column.hasClass( 'et_pb_column_1_3' ) || $outer_column.hasClass( 'et_pb_column_1_4' ) || $outer_column.hasClass( 'et_pb_column_3_8' ) ) ? portrait_width : 0; 3631 3632 $testimonial_descr.css( 'margin-left', testimonial_indent ); 3633 } ); 3634 } else if ( window_width > 767 ) { 3635 $( '.et_pb_testimonial' ).each( function() { 3636 if ( ! $(this).is( ':visible' ) ) { 3637 return; 3638 } 3639 3640 var $testimonial = $(this); 3641 var $portrait = $testimonial.find( '.et_pb_testimonial_portrait' ); 3642 var portrait_width = $portrait.outerWidth( true ); 3643 var $testimonial_descr = $testimonial.find( '.et_pb_testimonial_description' ); 3644 var $outer_column = $testimonial.closest( '.et_pb_column' ); 3645 var testimonial_indent = ! ( $outer_column.hasClass( 'et_pb_column_1_4' ) || $outer_column.hasClass( 'et_pb_column_3_8' ) ) ? portrait_width : 0; 3646 3647 $testimonial_descr.css( 'margin-left', testimonial_indent ); 3648 } ); 3649 } else { 3650 $( '.et_pb_testimonial_description' ).removeAttr( 'style' ); 3651 } 3652 } 3653 window.et_fix_testimonial_inner_width(); 3654 3655 window.et_pb_video_background_init = function( $this_video_background, this_video_background ) { 3656 var $video_background_wrapper = $this_video_background.closest( '.et_pb_section_video_bg' ); 3657 3658 // Initializing video values 3659 var onplaying = false;
3660 var onpause = true; 3661 3662 // On video playing toggle values 3663 this_video_background.onplaying = function() { 3664 onplaying = true; 3665 onpause = false; 3666 }; 3667 3668 // On video pause toggle values 3669 this_video_background.onpause = function() { 3670 onplaying = false; 3671 onpause = true; 3672 }; 3673 3674 // Entering video's top viewport 3675 et_waypoint( $video_background_wrapper, { 3676 offset: '100%', 3677 handler : function( direction ) { 3678 // This has to be placed inside handler to make it works with changing class name in VB 3679 var is_play_outside_viewport = $video_background_wrapper.hasClass( 'et_pb_video_play_outside_viewport' ); 3680 3681 if ( $this_video_background.is(':visible') && direction === 'down' ) { 3682 if ( this_video_background.paused && ! onplaying ) { 3683 this_video_background.play(); 3684 } 3685 } else if ( $this_video_background.is(':visible') && direction === 'up' ) { 3686 if ( ! this_video_background.paused && ! onpause && ! is_play_outside_viewport ) { 3687 this_video_background.pause(); 3688 } 3689 } 3690 } 3691 }, 2 ); 3692 3693 // Entering video's bottom viewport 3694 et_waypoint( $video_background_wrapper, { 3695 offset: function() { 3696 var video_height = this.element.clientHeight, 3697 toggle_offset = Math.ceil( window.innerHeight / 2); 3698 3699 if ( video_height > toggle_offset ) { 3700 toggle_offset = video_height; 3701 } 3702 3703 return toggle_offset * (-1); 3704 }, 3705 handler : function( direction ) { 3706 // This has to be placed inside handler to make it works with changing class name in VB 3707 var is_play_outside_viewport = $video_background_wrapper.hasClass( 'et_pb_video_play_outside_viewport' ); 3708 3709 if ( $this_video_background.is(':visible') && direction === 'up' ) { 3710 if ( this_video_background.paused && ! onplaying ) { 3711 this_video_background.play(); 3712 } 3713 } else if ( $this_video_background.is(':visible') && direction === 'down' ) { 3714 if ( ! this_video_background.paused && ! onpause && ! is_play_outside_viewport ) { 3715 this_video_background.pause(); 3716 } 3717 } 3718 } 3719 }, 2 ); 3720 }; 3721 3722 function et_waypoint( $element, options, max_instances ) { 3723 max_instances = max_instances || $element.data( 'et_waypoint_max_instances' ) || 1; 3724 var current_instances = $element.data( 'et_waypoint' ) || []; 3725 3726 if ( current_instances.length < max_instances ) { 3727 var new_instances = $element.waypoint( options ); 3728 3729 if ( new_instances && new_instances.length > 0 ) { 3730 current_instances.push( new_instances[0] ); 3731 $element.data( 'et_waypoint', current_instances ); 3732 } 3733 } else { 3734 // Reinit existing 3735 for ( var i = 0; i < current_instances.length; i++ ) { 3736 current_instances[i].context.refresh(); 3737 } 3738 } 3739 } 3740 3741 /** 3742 * Returns an offset to be used for waypoints. 3743 * @param {element} element The element being passed. 3744 * @param {string} fallback String of either pixels or percent. 3745 * @return {string} Returns either the fallback or 'bottom-in-view' 3746 */ 3747 function et_get_offset( element, fallback ) { 3748 // cache things so we can test. 3749 var section_index = element.parents('.et_pb_section').index(), 3750 section_length = $('.et_pb_section').length - 1, 3751 row_index = element.parents('.et_pb_row').index(), 3752 row_length = element.parents('.et_pb_section').children().length - 1; 3753 3754 // return bottom-in-view if it is the last element otherwise return the user defined fallback 3755 if ( section_index === section_length && row_index === row_length ) { 3756 return 'bottom-in-view'; 3757 } 3758 return fallback; 3759 } 3760 3761 function et_animate_element( $element ) { 3762 var animation_style = $element.attr('data-animation-style'); 3763 var animation_repeat = $element.attr('data-animation-repeat'); 3764 var animation_duration = $element.attr('data-animation-duration'); 3765 var animation_delay = $element.attr('data-animation-delay'); 3766 var animation_intensity = $element.attr('data-animation-intensity'); 3767 var animation_starting_opacity = $element.attr('data-animation-starting-opacity'); 3768 var animation_speed_curve = $element.attr('data-animation-speed-curve'); 3769 3770 // Remove all the animation data attributes once the variables have been set 3771 et_remove_animation_data( $element ); 3772 3773 // Opacity can be 0 to 1 so the starting opacity is equal to the percentage number multiplied by 0.01 3774 var starting_opacity = isNaN( parseInt( animation_starting_opacity ) ) ? 0 : parseInt( animation_starting_opacity ) * 0.01; 3775 3776 // Check if the animation speed curve is one of the allowed ones and set it to the default one if it is not 3777 if ( $.inArray( animation_speed_curve, ['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out'] ) === -1 ) { 3778 animation_speed_curve = 'ease-in-out'; 3779 } 3780 3781 $element.css({ 3782 'animation-duration' : animation_duration, 3783 'animation-delay' : animation_delay, 3784 'opacity' : starting_opacity, 3785 'animation-timing-function' : animation_speed_curve 3786 }); 3787 3788 var intensity_css = {}; 3789 var intensity_percentage = isNaN( parseInt( animation_intensity ) ) ? 50 : parseInt( animation_intensity ); 3790 3791 // All the animations that can have intensity 3792 var intensity_animations = ['slide', 'zoom', 'flip', 'fold', 'roll']; 3793 3794 var original_animation = false;
3795 var original_direction = false; 3796 3797 // Check if current animation can have intensity 3798 for ( var i = 0; i < intensity_animations.length; i++ ) { 3799 var animation = intensity_animations[i]; 3800 3801 // As the animation style is a combination of type and direction check if 3802 // the current animation contains any of the allowed animation types 3803 if ( ! animation_style || animation_style.substr( 0, animation.length ) !== animation ) { 3804 continue; 3805 } 3806 3807 // If it does set the original animation to the base animation type 3808 var original_animation = animation; 3809 3810 // Get the remainder of the animation style and set it as the direction 3811 var original_direction = animation_style.substr( animation.length, animation_style.length ); 3812 3813 // If that is not empty convert it to lower case for better readability's sake 3814 if ( '' !== original_direction ) { 3815 original_direction = original_direction.toLowerCase(); 3816 } 3817 3818 break; 3819 } 3820 3821 if ( original_animation !== false && original_direction !== false ) { 3822 intensity_css = et_process_animation_intensity( original_animation, original_direction, intensity_percentage ); 3823 } 3824 3825 if ( ! $.isEmptyObject( intensity_css ) ) { 3826 $element.css( intensity_css ); 3827 } 3828 3829 $element.addClass( 'et_animated' ); 3830 $element.addClass( animation_style ); 3831 $element.addClass( animation_repeat ); 3832 3833 // Remove the animation after it completes if it is not an infinite one 3834 if ( ! animation_repeat ) { 3835 var animation_duration_ms = parseInt( animation_duration ); 3836 var animation_delay_ms = parseInt( animation_delay ); 3837 3838 setTimeout( function() { 3839 et_remove_animation( $element ); 3840 }, animation_duration_ms + animation_delay_ms ); 3841 } 3842 } 3843 3844 function et_process_animation_data( waypoints_enabled ) { 3845 if ( 'undefined' !== typeof et_animation_data && et_animation_data.length > 0 ) { 3846 $('body').css('overflow-x', 'hidden'); 3847 $('#page-container').css('overflow-y', 'hidden'); 3848 3849 for ( var i = 0; i < et_animation_data.length; i++ ) { 3850 var animation_entry = et_animation_data[i]; 3851 3852 if ( 3853 ! animation_entry.class || 3854 ! animation_entry.style || 3855 ! animation_entry.repeat || 3856 ! animation_entry.duration || 3857 ! animation_entry.delay || 3858 ! animation_entry.intensity || 3859 ! animation_entry.starting_opacity || 3860 ! animation_entry.speed_curve 3861 ) { 3862 continue; 3863 } 3864 3865 var $animated = $('.' + animation_entry.class); 3866 3867 $animated.attr({ 3868 'data-animation-style' : animation_entry.style, 3869 'data-animation-repeat' : 'once' === animation_entry.repeat ? '' : 'infinite', 3870 'data-animation-duration' : animation_entry.duration, 3871 'data-animation-delay' : animation_entry.delay, 3872 'data-animation-intensity' : animation_entry.intensity, 3873 'data-animation-starting-opacity': animation_entry.starting_opacity, 3874 'data-animation-speed-curve' : animation_entry.speed_curve 3875 }); 3876 3877 // Process the waypoints logic if the waypoints are not ignored 3878 // Otherwise add the animation to the element right away 3879 if ( true === waypoints_enabled ) { 3880 if ( $animated.hasClass('et_pb_circle_counter') ) { 3881 et_waypoint( $animated, { 3882 offset: '100%', 3883 handler: function() { 3884 if ( $(this.element).data( 'PieChartHasLoaded' ) || typeof $(this.element).data('easyPieChart') === 'undefined' ) { 3885 return; 3886 } 3887 3888 $(this.element).data('easyPieChart').update( $(this.element).data('number-value') ); 3889 3890 $(this.element).data( 'PieChartHasLoaded', true ); 3891 3892 et_animate_element( $(this.element) ); 3893 } 3894 }); 3895 3896 // 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 3897 et_waypoint( $animated, { 3898 offset: 'bottom-in-view', 3899 handler: function() { 3900 if ( $(this.element).data( 'PieChartHasLoaded' ) || typeof $(this.element).data('easyPieChart')
3900=== 'undefined' ) { 3901 return; 3902 } 3903 3904 $(this.element).data('easyPieChart').update( $(this.element).data('number-value') ); 3905 3906 $(this.element).data( 'PieChartHasLoaded', true ); 3907 3908 et_animate_element( $(this.element) ); 3909 } 3910 }); 3911 } else if ( $animated.hasClass('et_pb_number_counter') ) { 3912 et_waypoint( $animated, { 3913 offset: '100%', 3914 handler: function() { 3915 $(this.element).data('easyPieChart').update( $(this.element).data('number-value') ); 3916 et_animate_element( $(this.element) ); 3917 } 3918 }); 3919 3920 // 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 3921 et_waypoint( $animated, { 3922 offset: 'bottom-in-view', 3923 handler: function() { 3924 $(this.element).data('easyPieChart').update( $(this.element).data('number-value') ); 3925 et_animate_element( $(this.element) ); 3926 } 3927 }); 3928 } else { 3929 et_waypoint( $animated, { 3930 offset: '100%', 3931 handler: function() { 3932 et_animate_element( $(this.element) ); 3933 } 3934 } ); 3935 } 3936 } else { 3937 et_animate_element( $animated ); 3938 } 3939 } 3940 } 3941 } 3942 3943 function et_process_animation_intensity( animation, direction, intensity ) { 3944 var intensity_css = {}; 3945 3946 switch( animation ) { 3947 case 'slide': 3948 switch( direction ) { 3949 case 'top': 3950 var percentage = intensity * -2; 3951 3952 intensity_css = { 3953 transform: 'translate3d(0, ' + percentage + '%, 0)' 3954 }; 3955 3956 break; 3957 3958 case 'right': 3959 var percentage = intensity * 2; 3960 3961 intensity_css = { 3962 transform: 'translate3d(' + percentage + '%, 0, 0)' 3963 }; 3964 3965 break; 3966 3967 case 'bottom': 3968 var percentage = intensity * 2; 3969 3970 intensity_css = { 3971 transform: 'translate3d(0, ' + percentage + '%, 0)' 3972 }; 3973 3974 break; 3975 3976 case 'left': 3977 var percentage = intensity * -2; 3978 3979 intensity_css = { 3980 transform: 'translate3d(' + percentage + '%, 0, 0)' 3981 }; 3982 3983 break; 3984 3985 default: 3986 var scale = ( 100 - intensity ) * 0.01; 3987 3988 intensity_css = { 3989 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 3990 }; 3991 break; 3992 } 3993 break; 3994 3995 case 'zoom': 3996 var scale = ( 100 - intensity ) * 0.01; 3997 3998 switch( direction ) { 3999 case 'top': 4000 intensity_css = { 4001 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4002 }; 4003 4004 break; 4005 4006 case 'right': 4007 intensity_css = { 4008 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4009 }; 4010 4011 break; 4012 4013 case 'bottom': 4014 intensity_css = { 4015 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4016 }; 4017 4018 break; 4019 4020 case 'left': 4021 intensity_css = { 4022 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4023 }; 4024 4025 break; 4026 4027 default: 4028 intensity_css = { 4029 transform: 'scale3d(' + scale + ', ' + scale + ', ' + scale + ')' 4030 }; 4031 break; 4032 } 4033 4034 break; 4035 4036 case 'flip': 4037 switch ( direction ) { 4038 case 'right': 4039 var degree = Math.ceil( ( 90 / 100 ) * intensity ); 4040 4041 intensity_css = { 4042 transform: 'perspective(2000px) rotateY(' + degree+ 'deg)' 4043 }; 4044 break; 4045 4046 case 'left': 4047 var degree = Math.ceil( ( 90 / 100 ) * intensity ) * -1; 4048 4049 intensity_css = { 4050 transform: 'perspective(2000px) rotateY(' + degree+ 'deg)' 4051 }; 4052 break; 4053 4054 case 'top': 4055 default: 4056 var degree = Math.ceil( ( 90 / 100 ) * intensity ); 4057 4058 intensity_css = { 4059 transform: 'perspective(2000px) rotateX(' + degree+ 'deg)' 4060 }; 4061 break; 4062 4063 case 'bottom': 4064 var degree = Math.ceil( ( 90 / 100 ) * intensity ) * -1; 4065 4066 intensity_css = { 4067 transform: 'perspective(2000px) rotateX(' + degree+ 'deg)' 4068 }; 4069 break; 4070 } 4071 4072 break; 4073 4074 case 'fold': 4075 switch( direction ) { 4076 case 'top':
4077 var degree = Math.ceil( ( 90 / 100 ) * intensity ) * -1; 4078 4079 intensity_css = { 4080 transform: 'perspective(2000px) rotateX(' + degree + 'deg)' 4081 }; 4082 4083 break; 4084 case 'bottom': 4085 var degree = Math.ceil( ( 90 / 100 ) * intensity ); 4086 4087 intensity_css = { 4088 transform: 'perspective(2000px) rotateX(' + degree + 'deg)' 4089 }; 4090 4091 break; 4092 4093 case 'left': 4094 var degree = Math.ceil( ( 90 / 100 ) * intensity ); 4095 4096 intensity_css = { 4097 transform: 'perspective(2000px) rotateY(' + degree + 'deg)' 4098 }; 4099 4100 break; 4101 case 'right': 4102 default: 4103 var degree = Math.ceil( ( 90 / 100 ) * intensity ) * -1; 4104 4105 intensity_css = { 4106 transform: 'perspective(2000px) rotateY(' + degree + 'deg)' 4107 }; 4108 4109 break; 4110 } 4111 4112 break; 4113 4114 case 'roll': 4115 switch( direction ) { 4116 case 'right': 4117 case 'bottom': 4118 var degree = Math.ceil( ( 360 / 100 ) * intensity ) * -1; 4119 4120 intensity_css = { 4121 transform: 'rotateZ(' + degree + 'deg)' 4122 }; 4123 4124 break; 4125 case 'top': 4126 case 'left': 4127 var degree = Math.ceil( ( 360 / 100 ) * intensity ); 4128 4129 intensity_css = { 4130 transform: 'rotateZ(' + degree + 'deg)' 4131 } 4132 4133 break; 4134 default: 4135 var degree = Math.ceil( ( 360 / 100 ) * intensity ); 4136 4137 intensity_css = { 4138 transform: 'rotateZ(' + degree + 'deg)' 4139 }; 4140 4141 break; 4142 } 4143 4144 break; 4145 } 4146 4147 return intensity_css; 4148 } 4149 4150 function et_has_animation_data( $element ) { 4151 var has_animation = false; 4152 4153 if ( 'undefined' !== typeof et_animation_data && et_animation_data.length > 0 ) { 4154 for ( var i = 0; i < et_animation_data.length; i++ ) { 4155 var animation_entry = et_animation_data[i]; 4156 4157 if ( ! animation_entry.class ) { 4158 continue; 4159 } 4160 4161 if ( $element.hasClass( animation_entry.class ) ) { 4162 has_animation = true; 4163 break; 4164 } 4165 } 4166 } 4167 4168 return has_animation; 4169 } 4170 4171 function et_get_animation_classes() { 4172 return [ 4173 'et_animated', 'infinite', 'et-waypoint', 4174 'fade', 'fadeTop', 'fadeRight', 'fadeBottom', 'fadeLeft', 4175 'slide', 'slideTop', 'slideRight', 'slideBottom', 'slideLeft', 4176 'bounce', 'bounceTop', 'bounceRight', 'bounceBottom', 'bounceLeft', 4177 'zoom', 'zoomTop', 'zoomRight', 'zoomBottom', 'zoomLeft', 4178 'flip', 'flipTop', 'flipRight', 'flipBottom', 'flipLeft', 4179 'fold', 'foldTop', 'foldRight', 'foldBottom', 'foldLeft', 4180 'roll', 'rollTop', 'rollRight', 'rollBottom', 'rollLeft' 4181 ]; 4182 } 4183 4184 function et_remove_animation( $element ) { 4185 var animation_classes = et_get_animation_classes(); 4186 4187 $element.removeClass( animation_classes.join(' ') ); 4188 $element.css({ 4189 'animation-delay' : '', 4190 'animation-duration' : '', 4191 'animation-timing-function' : '', 4192 'opacity' : '', 4193 'transform' : '' 4194 }); 4195 } 4196 4197 function et_remove_animation_data( $element ) { 4198 var attr_name; 4199 var data_attrs_to_remove = []; 4200 var data_attrs = $element.get(0).attributes; 4201 4202 for ( var i = 0; i < data_attrs.length; i++ ) { 4203 if ( 'data-animation-' === data_attrs[i].name.substring( 0, 15 ) ) { 4204 data_attrs_to_remove.push( data_attrs[i].name ); 4205 } 4206 } 4207 4208 $.each( data_attrs_to_remove, function( index, attr_name ) { 4209 $element.removeAttr( attr_name ); 4210 } ); 4211 }; 4212 4213 window.et_reinit_waypoint_modules = et_pb_debounce( function() { 4214 var $et_pb_circle_counter = $( '.et_pb_circle_counter' ), 4215 $et_pb_number_counter = $( '.et_pb_number_counter' ), 4216 $et_pb_video_background = $( '.et_pb_section_video_bg video' ); 4217 4218 // if waypoint is available and we are not ignoring them. 4219 if ( $.fn.waypoint && 'yes' !== et_pb_custom.ignore_waypoints ) { 4220 et_process_animation_data( true ); 4221 4222 // get all of our waypoint things. 4223 var modules = $( '.et_pb_counter_container, .et-waypoint' ); 4224 modules.each(function(){ 4225 et_waypoint( $(this), { 4226 offset: et_get_offset( $(this), '100%' ), 4227 handler: function() { 4228 // what actually triggers the animation. 4229 $(this.element).addClass( 'et-animated' ); 4230 } 4231 }, 2 ); 4232 }); 4233 4234 // Set waypoint for circle counter module. 4235 if ( $et_pb_circle_counter.length ) { 4236 // iterate over each. 4237 $et_pb_circle_counter.each(function(){ 4238 var $this_counter = $(this); 4239 if ( ! $this_counter.is( ':visible' ) || et_has_animation_data( $this_counter ) ) { 4240 return; 4241 } 4242 4243 et_waypoint( $this_counter, { 4244 offset: et_get_offset( $(this), '100%'), 4245 handler: function() { 4246 if ( $this_counter.data( 'PieChartHasLoaded' ) || typeof $this_counter.data('easyPieChart')
4246=== 'undefined' ) { 4247 return; 4248 } 4249 4250 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4251 4252 $this_counter.data( 'PieChartHasLoaded', true ); 4253 } 4254 }, 2 ); 4255 }); 4256 } 4257 4258 // Set waypoint for number counter module. 4259 if ( $et_pb_number_counter.length ) { 4260 $et_pb_number_counter.each(function(){ 4261 var $this_counter = $(this); 4262 4263 if ( et_has_animation_data( $this_counter ) ) { 4264 return; 4265 } 4266 4267 et_waypoint( $this_counter, { 4268 offset: et_get_offset( $(this), '100%' ), 4269 handler: function() { 4270 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4271 } 4272 }); 4273 }); 4274 } 4275 4276 // Set waypoint for goal module. 4277 if ( $( '.et_pb_ab_goal' ).length ) { 4278 var $et_pb_ab_goal = $( '.et_pb_ab_goal' ); 4279 4280 et_waypoint( $et_pb_ab_goal, { 4281 offset: et_get_offset( $(this), '80%'), 4282 handler: function() { 4283 if ( et_pb_ab_logged_status['read_goal'] || ! $et_pb_ab_goal.length || ! $et_pb_ab_goal.visible( true ) ) { 4284 return; 4285 } 4286 4287 // log the goal_read if goal is still visible after 3 seconds. 4288 setTimeout( function() { 4289 if ( $et_pb_ab_goal.length && $et_pb_ab_goal.visible( true ) && ! et_pb_ab_logged_status['read_goal'] ) { 4290 et_pb_ab_update_stats( 'read_goal' ); 4291 } 4292 }, 3000 ); 4293 4294 et_pb_maybe_log_event( $et_pb_ab_goal, 'view_goal' ); 4295 } 4296 }); 4297 } 4298 } else { 4299 // if no waypoints supported then apply all the animations right away 4300 et_process_animation_data( false ); 4301 4302 $( '.et_pb_counter_container, .et-waypoint' ).addClass( 'et-animated' ); 4303 4304 if ( $et_pb_circle_counter.length ) { 4305 $et_pb_circle_counter.each(function() { 4306 var $this_counter = $(this); 4307 4308 if ( ! $this_counter.is( ':visible' ) ) { 4309 return; 4310 } 4311 4312 if ( $this_counter.data( 'PieChartHasLoaded' ) ) { 4313 return; 4314 } 4315 4316 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4317 4318 $this_counter.data( 'PieChartHasLoaded', true ); 4319 } ); 4320 } 4321 4322 if ( $et_pb_number_counter.length ) { 4323 $et_pb_number_counter.each(function(){ 4324 var $this_counter = $(this); 4325 4326 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4327 }); 4328 } 4329 4330 // log the stats without waypoints 4331 if ( $( '.et_pb_ab_goal' ).length ) { 4332 var $et_pb_ab_goal = $( '.et_pb_ab_goal' ); 4333 4334 if ( et_pb_ab_logged_status['read_goal'] || ! $et_pb_ab_goal.length || ! $et_pb_ab_goal.visible( true ) ) { 4335 return; 4336 } 4337 4338 // log the goal_read if goal is still visible after 3 seconds. 4339 setTimeout( function() { 4340 if ( $et_pb_ab_goal.length && $et_pb_ab_goal.visible( true ) && ! et_pb_ab_logged_status['read_goal'] ) { 4341 et_pb_ab_update_stats( 'read_goal' ); 4342 } 4343 }, 3000 ); 4344 4345 et_pb_maybe_log_event( $et_pb_ab_goal, 'view_goal' ); 4346 } 4347 } // End checking of waypoints. 4348 4349 if ( $et_pb_video_background.length ) { 4350 $et_pb_video_background.each( function(){ 4351 var $this_video_background = $(this); 4352 4353 et_pb_video_background_init( $this_video_background, this ); 4354 }); 4355 } // End of et_pb_debounce(). 4356 }, 100 ); 4357 4358 function et_pb_init_ab_test() { 4359 var $et_pb_ab_goal = $( '.et_pb_ab_goal' ), 4360 et_ab_subject_id = et_pb_get_subject_id(); 4361 4362 // Disable AB Testing tracking on VB 4363 // AB Testing should not record anything on AB Testing 4364 if ( is_frontend_builder ) { 4365 return; 4366 } 4367 4368 $.each( et_pb_ab_logged_status, function( key, value ) { 4369 var cookie_subject = 'click_goal' === key || 'con_short' === key ? '' : et_ab_subject_id; 4370 4371 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' ); 4372 4373 }); 4374 4375 // log the page read event if user stays on page long enough and if not logged for current subject 4376 if ( ! et_pb_ab_logged_status['read_page'] ) { 4377 setTimeout( function() { 4378 et_pb_ab_update_stats( 'read_page' ); 4379 }, et_pb_ab_bounce_rate ); 4380 } 4381 4382 // add the cookies for shortcode tracking, if enabled 4383 if ( 'on' === et_pb_custom.is_shortcode_tracking && ! et_pb_ab_logged_status['con_short'] ) { 4384 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 ); 4385 } 4386 4387 if ( $et_pb_ab_goal.length ) { 4388 // if goal is a module and has a button then track the conversions, otherwise track clicks 4389 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 ) ) { 4390 // Log con_goal if current goal doesn't require any specific conversion calculation 4391 if ( ! $et_pb_ab_goal.hasClass( 'et_pb_contact_form_container' ) && ! $et_pb_ab_goal.hasClass( 'et_pb_newsletter' ) ) { 4392 var $goal_button = $et_pb_ab_goal.hasClass( 'et_pb_button' ) ? $et_pb_ab_goal : $et_pb_ab_goal.find( '.et_pb_button' ); 4393 4394 if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) ) { 4395 var page_url = window.location.href, 4396 comment_submitted = -1 !== page_url.indexOf( '#comment-' ) ? true : false, 4397 log_conversion = et_pb_check_cookie_value( 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id, 'true' ); 4398 4399 if ( comment_submitted && log_conversion ) { 4400 et_pb_ab_update_stats( 'con_goal' ); 4401 et_pb_set_cookie( 0, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' ); 4402 } 4403 } 4404 4405 $goal_button.click( function(){ 4406 if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) && ! et_pb_ab_logged_status['con_goal'] ) { 4407 et_pb_set_cookie( 365, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' ); 4408 return; 4409 } 4410 4411 et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' ); 4412 }); 4413 } 4414 } else { 4415 $et_pb_ab_goal.click( function() { 4416 if ( $et_pb_ab_goal.hasClass( 'et_pb_shop' ) && ! et_pb_ab_logged_status['con_goal'] ) { 4417 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 ); 4418 } 4419 4420 et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' ); 4421 }); 4422 } 4423 } 4424 } 4425 4426 function et_pb_maybe_log_event( $goal_container, event, callback ) { 4427 var log_event = typeof event === 'undefined' ? 'con_goal' : event; 4428 4429 if ( ! $goal_container.hasClass( 'et_pb_ab_goal' ) || et_pb_ab_logged_status[ log_event ] ) { 4430 if ( 'undefined' !== typeof callback ) { 4431 callback(); 4432 } 4433 4434 return; 4435 } 4436 4437 // log the event if it's not logged for current user 4438 et_pb_ab_update_stats( log_event, callback ); 4439 } 4440 4441 function et_pb_ab_update_stats( record_type, set_page_id, set_subject_id, set_test_id, callback ) { 4442 var subject_id = typeof set_subject_id === 'undefined' ? et_pb_get_subject_id() : set_subject_id, 4443 page_id = typeof set_page_id === 'undefined' ? et_pb_custom.page_id : set_page_id, 4444 test_id = typeof set_test_id === 'undefined' ? et_pb_custom.unique_test_id : set_test_id, 4445 stats_data = JSON.stringify({ 'test_id' : page_id, 'subject_id' : subject_id, 'record_type' : record_type }),
4446 cookie_subject = 'click_goal' === record_type || 'con_short' === record_type ? '' : subject_id; 4447 4448 et_pb_set_cookie( 365, 'et_pb_ab_' + record_type + '_' + page_id + test_id + cookie_subject + '=true' ); 4449 4450 et_pb_ab_logged_status[record_type] = true; 4451 4452 $.ajax({ 4453 type: 'POST', 4454 url: et_pb_custom.ajaxurl, 4455 data: { 4456 action : 'et_pb_update_stats_table', 4457 stats_data_array : stats_data, 4458 et_ab_log_nonce : et_pb_custom.et_ab_log_nonce 4459 } 4460 }).always( function() { 4461 if ( 'undefined' !== typeof callback ) { 4462 callback(); 4463 } 4464 } ); 4465 } 4466 4467 function et_pb_get_subject_id() { 4468 var $subject = $( '.et_pb_ab_subject' ); 4469 4470 // In case no subject found 4471 if ( $subject.length <= 0 || $('html').is('.et_fb_preview_active--wireframe_preview') ) { 4472 return false; 4473 } 4474 4475 var subject_classname = $subject.attr( 'class' ), 4476 subject_id_raw = subject_classname.split( 'et_pb_ab_subject_id-' )[1], 4477 subject_id_clean = subject_id_raw.split( ' ' )[0], 4478 subject_id_separated = subject_id_clean.split( '_' ), 4479 subject_id = subject_id_separated[1]; 4480 4481 return subject_id; 4482 } 4483 4484 function et_pb_set_cookie_expire( days ) { 4485 var ms = days*24*60*60*1000; 4486 4487 var date = new Date(); 4488 date.setTime( date.getTime() + ms ); 4489 4490 return "; expires=" + date.toUTCString(); 4491 } 4492 4493 function et_pb_check_cookie_value( cookie_name, value ) { 4494 return et_pb_get_cookie_value( cookie_name ) == value; 4495 } 4496 4497 function et_pb_get_cookie_value( cookie_name ) { 4498 return et_pb_parse_cookies()[cookie_name]; 4499 } 4500 4501 function et_pb_parse_cookies() { 4502 var cookies = document.cookie.split( '; ' ); 4503 4504 var ret = {}; 4505 for ( var i = cookies.length - 1; i >= 0; i-- ) { 4506 var el = cookies[i].split( '=' ); 4507 ret[el[0]] = el[1]; 4508 } 4509 return ret; 4510 } 4511 4512 function et_pb_set_cookie( expire, cookie_content ) { 4513 cookie_expire = et_pb_set_cookie_expire( expire ); 4514 document.cookie = cookie_content + cookie_expire + "; path=/"; 4515 } 4516 4517 function et_pb_get_fixed_main_header_height() { 4518 if ( ! window.et_is_fixed_nav ) { 4519 return 0; 4520 } 4521 4522 var fixed_height_onload = typeof $('#main-header').attr('data-fixed-height-onload') === 'undefined' ? 0 : $('#main-header').attr('data-fixed-height-onload'); 4523 4524 return ! window.et_is_fixed_nav ? 0 : parseFloat( fixed_height_onload ); 4525 } 4526 4527 var fullscreen_section_width = {}; 4528 var fullscreen_section_timeout = {}; 4529 4530 window.et_calc_fullscreen_section = function(event) { 4531 var isResizing = typeof event === 'object' && event.type === 'resize', 4532 $et_window = $(window), 4533 $this_section = $(this), 4534 section_index = $this_section.index('.et_pb_fullscreen'), 4535 timeout = isResizing && typeof fullscreen_section_width[section_index] !== 'undefined' && event.target.window_width > fullscreen_section_width[section_index] ? 800 : 0; 4536 4537 fullscreen_section_width[section_index] = $et_window.width(); 4538 4539 if ( typeof fullscreen_section_timeout[section_index] !== 'undefined' ) { 4540 clearTimeout( fullscreen_section_timeout[section_index] ); 4541 } 4542 4543 fullscreen_section_timeout[section_index] = setTimeout( function() { 4544 var $body = $( 'body' ), 4545 this_section_index = $this_section.index('.et_pb_fullwidth_header'), 4546 this_section_offset = $this_section.offset(), 4547 $header = $this_section.children('.et_pb_fullwidth_header_container'), 4548 $header_content = $header.children('.header-content-container'), 4549 $header_image = $header.children('.header-image-container'), 4550 sectionHeight = window.innerHeight || $et_window.height(), 4551 $wpadminbar = $('#wpadminbar'), 4552 has_wpadminbar = $wpadminbar.length, 4553 wpadminbar_height = has_wpadminbar ? $wpadminbar.height() : 0, 4554 $top_header = $('#top-header'), 4555 has_top_header = $top_header.length, 4556 top_header_height = has_top_header ? $top_header.height() : 0, 4557 $main_header = $('#main-header'), 4558 has_main_header = $main_header.length, 4559 main_header_height = has_main_header ? $main_header.outerHeight() : 0, 4560 fixed_main_header_height = et_pb_get_fixed_main_header_height(), 4561 is_mobile_first_module = this_section_offset.top <= (main_header_height + wpadminbar_height), 4562 is_wp_relative_admin_bar = $et_window.width() < 782, 4563 is_desktop_view = $et_window.width() > 980, 4564 is_tablet_view = $et_window.width() <= 980 && $et_window.width() >= 479, 4565 is_phone_view = $et_window.width() < 479, 4566 overall_header_height = window.et_is_vertical_nav && is_desktop_view ? wpadminbar_height + top_header_height : wpadminbar_height + top_header_height + main_header_height, 4567 is_first_module = this_section_offset.top <= overall_header_height; 4568 4569 // In case theme stored the onload main-header height as data-attribute 4570 if ( $main_header.attr('data-height-onload') ) { 4571 main_header_height = parseFloat( $main_header.attr('data-height-onload') ); 4572 } 4573 4574 /** 4575 * WP Admin Bar: 4576 * 4577 * - Desktop fixed: standard 4578 * - WP Mobile relative: less than 782px window 4579 **/ 4580 if ( has_wpadminbar ) { 4581 if ( is_wp_relative_admin_bar ) { 4582 if ( is_first_module ) { 4583 sectionHeight -= wpadminbar_height; 4584 } 4585 } else { 4586 sectionHeight -= wpadminbar_height; 4587 } 4588 } 4589 4590 /** 4591 * Divi Top Header: 4592 * 4593 * - Desktop fixed: standard. 4594 * - Desktop fixed BUT first header's height shouldn't be substracted: hide nav until scroll activated 4595 * - Desktop relative: fixed nav bar disabled 4596 * - Desktop relative: vertical nav activated 4597 */ 4598 if ( has_top_header ) { 4599 if ( is_desktop_view ) { 4600 if ( et_hide_nav && ! window.et_is_vertical_nav ) { 4601 if ( ! is_first_module ) { 4602 sectionHeight -= top_header_height; 4603 } 4604 } else if ( ! window.et_is_fixed_nav || window.et_is_vertical_nav ) { 4605 if ( is_first_module ) { 4606 sectionHeight -= top_header_height; 4607 } 4608 } else { 4609 sectionHeight -= top_header_height; 4610 } 4611 } 4612 } 4613 4614 /** 4615 * Divi Main Header: 4616 * 4617 * - Desktop fixed: standard. Initial and 'fixed' header might have different height 4618 * - Desktop relative: fixed nav bar disabled 4619 * - Desktop fixed BUT height should be ignored: vertical nav activated 4620 * - Desktop fixed BUT height should be ignored for first header only: main header uses rgba 4621 * - Desktop fixed BUT first header's height shouldn't be substracted: hide nav until scroll activated 4622 * - Tablet relative: standard. Including vertical header style 4623 * - Phone relative: standard. Including vertical header style 4624 */ 4625 if ( has_main_header ) { 4626 if ( is_desktop_view ) { 4627 if ( et_hide_nav && ! window.et_is_vertical_nav ) { 4628 if ( ! is_first_module ) { 4629 sectionHeight -= fixed_main_header_height; 4630 } 4631 } else if ( window.et_is_fixed_nav && ! window.et_is_vertical_nav ) { 4632 if ( is_first_module ) { 4633 sectionHeight -= main_header_height; 4634 } else { 4635 sectionHeight -= fixed_main_header_height; 4636 } 4637 } else if ( ! window.et_is_fixed_nav && ! window.et_is_vertical_nav ) { 4638 if ( is_first_module ) { 4639 sectionHeight -= main_header_height; 4640 } 4641 } 4642 } else { 4643 if ( is_first_module ) { 4644 sectionHeight -= main_header_height; 4645 } 4646 } 4647 } 4648 4649 // If the transparent primary nav + hide nav until scroll is being used, 4650 // cancel automatic padding-top added by transparent nav mechanism 4651 if ( $body.hasClass('et_transparent_nav') && $body.hasClass( 'et_hide_nav' ) && 0 === this_section_index ) { 4652 $this_section.css( 'padding-top', '' ); 4653 } 4654 4655 // reduce section height by its top border width 4656 var section_border_top_width = parseInt( $this_section.css( 'borderTopWidth' ) ); 4657 if ( section_border_top_width ) { 4658 sectionHeight -= section_border_top_width; 4659 } 4660 4661 // reduce section height by its bottom border width 4662 var section_border_bottom_width = parseInt( $this_section.css( 'borderBottomWidth' ) ); 4663 if ( section_border_bottom_width ) { 4664 sectionHeight -= section_border_bottom_width; 4665 } 4666 4667 $this_section.css('min-height', sectionHeight + 'px' ); 4668 $header.css('min-height', sectionHeight + 'px' ); 4669 4670 if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('bottom') ) { 4671 $header.addClass('bottom-bottom'); 4672 } 4673 4674 if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('center') ) { 4675 $header.addClass('center-center'); 4676 } 4677 4678 if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('bottom') ) { 4679 $header.addClass('center-bottom'); 4680 4681 var contentHeight = sectionHeight - $header_image.outerHeight( true ); 4682 4683 if ( contentHeight > 0 ) { 4684 $header_content.css('min-height', contentHeight + 'px' ).css('height', '10px' /*fixes IE11 render*/); 4685 } 4686 } 4687 4688 if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('center') ) { 4689 $header.addClass('bottom-center'); 4690 } 4691 4692 if ( ( $header.hasClass('left') || $header.hasClass('right') ) && !$header_content.length && $header_image.length ) { 4693 $header.css('justify-content', 'flex-end'); 4694 } 4695 4696 if ( $header.hasClass('center') && $header_content.hasClass('bottom') && !$header_image.length ) { 4697 $header_content.find('.header-content').css( 'margin-bottom', 80 + 'px' ); 4698 } 4699 4700 if ( $header_content.hasClass('bottom') && $header_image.hasClass('center') ) { 4701 $header_image.find('.header-image').css( 'margin-bottom', 80 + 'px' ); 4702 $header_image.css('align-self', 'flex-end'); 4703 } 4704 4705 // Mobile device and small screen handler 4706 if ((et_is_mobile_device && !et_is_ipad) || $et_window.width() < 768){ 4707 // Detect if section height is lower than the content height 4708 var headerContentHeight = 0; 4709 if ($header_content.length) { 4710 headerContentHeight += $header_content.outerHeight(); 4711 } 4712 if ($header_image.length) { 4713 headerContentHeight += $header_image.outerHeight(); 4714 } 4715 if (headerContentHeight > sectionHeight ) { 4716 $this_section.css('min-height', headerContentHeight + 'px'); 4717 $header.css('min-height', headerContentHeight + 'px'); 4718 } 4719 4720 // Justify the section content 4721 if ( $header_image.hasClass('bottom')) { 4722 if (headerContentHeight < sectionHeight ) { 4723 $this_section.css('min-height', (headerContentHeight + 80) + 'px'); 4724 $header.css('min-height', (headerContentHeight + 80) + 'px'); 4725 } 4726 $header.css('justify-content', 'flex-end'); 4727 } 4728 } 4729 4730 }, timeout ); 4731 } 4732 4733 window.et_pb_parallax_init = function( $this_parallax ) { 4734 if ( $this_parallax.hasClass('et_pb_parallax_css') ) { 4735 return; 4736 } 4737 4738 var $this_parent = $this_parallax.parent(); 4739 4740 $.proxy( et_parallax_set_height, $this_parent )(); 4741 4742 $.proxy( et_apply_parallax, $this_parent )(); 4743 4744 $et_window.on( 'scroll', $.proxy( et_apply_parallax, $this_parent ) ); 4745 4746 $et_window.on( 'resize', $.proxy( et_parallax_set_height, $this_parent ) ); 4747 4748 $et_window.on( 'resize', $.proxy( et_apply_parallax, $this_parent ) ); 4749 4750 $this_parent.find('.et-learn-more .heading-more').click( function() { 4751 setTimeout(function(){ 4752 $.proxy( et_parallax_set_height, $this_parent )(); 4753 }, 300 ); 4754 }); 4755 } 4756 4757 $( window ).resize( function(){ 4758 var window_width = $et_window.width(),
4759 et_container_css_width = $et_container.css( 'width' ), 4760 et_container_width_in_pixel = ( typeof et_container_css_width !== 'undefined' ) ? et_container_css_width.substr( -1, 1 ) !== '%' : '', 4761 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 4762 containerWidthChanged = et_container_width !== et_container_actual_width; 4763 4764 et_pb_resize_section_video_bg(); 4765 et_pb_center_video(); 4766 et_fix_slider_height(); 4767 et_fix_nav_direction(); 4768 4769 $et_pb_fullwidth_portfolio.each(function(){ 4770 set_container_height = $(this).hasClass('et_pb_fullwidth_portfolio_carousel') ? true : false; 4771 set_fullwidth_portfolio_columns( $(this), set_container_height ); 4772 }); 4773 4774 if ( containerWidthChanged || window.et_force_width_container_change ) { 4775 $('.container-width-change-notify').trigger('containerWidthChanged'); 4776 4777 setTimeout( function() { 4778 $et_pb_filterable_portfolio.each(function(){ 4779 set_filterable_grid_items( $(this) ); 4780 }); 4781 $et_pb_gallery.each(function(){ 4782 if ( $(this).hasClass( 'et_pb_gallery_grid' ) ) { 4783 set_gallery_grid_items( $(this) ); 4784 } 4785 }); 4786 }, 100 ); 4787 4788 et_container_width = et_container_actual_width; 4789 4790 etRecalculateOffset = true; 4791 4792 var $et_pb_circle_counter = $( '.et_pb_circle_counter' ); 4793 if ( $et_pb_circle_counter.length ) { 4794 $et_pb_circle_counter.each(function(){ 4795 var $this_counter = $(this); 4796 if ( ! $this_counter.is( ':visible' ) || typeof $this_counter.data('easyPieChart') === 'undefined' ) { 4797 return; 4798 } 4799 4800 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 4801 }); 4802 } 4803 if ( $et_pb_countdown_timer.length ) { 4804 $et_pb_countdown_timer.each(function(){ 4805 var timer = $(this); 4806 et_countdown_timer_labels( timer ); 4807 } ); 4808 } 4809 4810 // Reset to false 4811 window.et_force_width_container_change = false; 4812 } 4813 4814 window.et_fix_testimonial_inner_width(); 4815 4816 et_audio_module_set(); 4817 4818 if ( $et_pb_counter_amount.length ) { 4819 $et_pb_counter_amount.each(function(){ 4820 window.et_bar_counters_init( $( this ) ); 4821 }); 4822 } /* $et_pb_counter_amount.length */ 4823 } ); 4824 4825 $( window ).ready( function(){ 4826 if ( $.fn.fitVids ) { 4827 $( '.et_pb_slide_video' ).fitVids(); 4828 $( '.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']"} ); 4829 } 4830 4831 et_fix_slider_height(); 4832 4833 // calculate fullscreen section sizes on $( window ).ready to avoid jumping in some cases 4834 $( 'section.et_pb_fullscreen' ).each( function(){ 4835 var $this_section = $( this ); 4836 4837 $.proxy( et_calc_fullscreen_section, $this_section )(); 4838 4839 $et_window.on( 'resize', $.proxy( et_calc_fullscreen_section, $this_section ) ); 4840 }); 4841 } ); 4842 4843 window.et_pb_fullwidth_header_scroll = function( event ) { 4844 event.preventDefault(); 4845 4846 var window_width = $et_window.width(), 4847 $body = $('body'), 4848 is_wp_relative_admin_bar = window_width < 782, 4849 is_transparent_main_header = $body.hasClass( 'et_transparent_nav' ), 4850 is_hide_nav = $body.hasClass( 'et_hide_nav' ), 4851 is_desktop_view = window_width > 980, 4852 is_tablet_view = window_width <= 980 && window_width >= 479, 4853 is_phone_view = window_width < 479, 4854 $this_section = $(this).parents( 'section' ), 4855 this_section_offset = $this_section.offset(), 4856 $wpadminbar = $('#wpadminbar'), 4857 $main_header = $('#main-header'), 4858 wpadminbar_height = $wpadminbar.length && ! is_wp_relative_admin_bar ? $wpadminbar.height() : 0, 4859 top_header_height = !window.et_is_fixed_nav || !is_de
4859sktop_view ? 0 : $top_header.height(), 4860 data_height_onload = typeof $main_header.attr('data-height-onload') === 'undefined' ? 0 : $main_header.attr('data-height-onload'); 4861 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 ), 4862 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() ), 4863 animate_modified = false; 4864 4865 if ( $this_section.length ) { 4866 var fullscreen_scroll_duration = 800; 4867 4868 $( 'html, body' ).animate( { scrollTop : section_bottom }, { 4869 duration: fullscreen_scroll_duration 4870 } ); 4871 } 4872 } 4873 4874 function et_pb_window_load_scripts() { 4875 et_fix_fullscreen_section(); 4876 4877 // recalculate fullscreen section sizes on load 4878 $( 'section.et_pb_fullscreen' ).each( function(){ 4879 var $this_section = $( this ); 4880 4881 $.proxy( et_calc_fullscreen_section, $this_section )(); 4882 }); 4883 4884 $( '.et_pb_fullwidth_header_scroll' ).on('click', 'a', et_pb_fullwidth_header_scroll ); 4885 4886 setTimeout( function() { 4887 $( '.et_pb_preload' ).removeClass( 'et_pb_preload' ); 4888 }, 500 ); 4889 4890 if ( $.fn.hashchange ) { 4891 $(window).hashchange( function(){ 4892 var hash = window.location.hash.substring(1); 4893 process_et_hashchange( hash ); 4894 }); 4895 $(window).hashchange(); 4896 } 4897 4898 if ( $et_pb_parallax.length && !et_is_mobile_device ) { 4899 $et_pb_parallax.each(function(){ 4900 et_pb_parallax_init( $(this) ); 4901 }); 4902 } 4903 4904 et_audio_module_set(); 4905 4906 window.et_reinit_waypoint_modules(); 4907 4908 if ( $( '.et_audio_content' ).length ) { 4909 $( window ).trigger( 'resize' ); 4910 } 4911 } 4912 4913 if ( window.et_load_event_fired ) { 4914 et_pb_window_load_scripts(); 4915 } else { 4916 $( window ).load( function() { 4917 et_pb_window_load_scripts(); 4918 } ); 4919 } 4920 4921 if ( $( '.et_section_specialty' ).length ) { 4922 $( '.et_section_specialty' ).each( function() { 4923 var this_row = $( this ).find( '.et_pb_row' ); 4924 4925 this_row.find( '>.et_pb_column:not(.et_pb_specialty_column)' ).addClass( 'et_pb_column_single' ); 4926 }); 4927 } 4928 4929 /** 4930 * In particular browser, map + parallax doesn't play well due the use of CSS 3D transform 4931 */ 4932 if ( $('.et_pb_section_parallax').length && $('.et_pb_map').length ) { 4933 $('body').addClass( 'parallax-map-support' ); 4934 } 4935 4936 /** 4937 * Add conditional class for search widget in sidebar module 4938 */ 4939 $('.et_pb_widget_area ' + et_pb_custom.widget_search_selector ).each( function() { 4940 var $search_wrap = $(this), 4941 $search_input_submit = $search_wrap.find('input[type="submit"]'), 4942 search_input_submit_text = $search_input_submit.attr( 'value' ), 4943 $search_button = $search_wrap.find('button'), 4944 search_button_text = $search_button.text(), 4945 has_submit_button = $search_input_submit.length || $search_button.length ? true : false, 4946 min_column_width = 150; 4947 4948 if ( ! $search_wrap.find( 'input[type="text"]' ).length && ! $search_wrap.find( 'input[type="search"]' ).length ) { 4949 return; 4950 } 4951 4952 // Mark no button state 4953 if ( ! has_submit_button ) { 4954 $search_wrap.addClass( 'et-no-submit-button' ); 4955 } 4956 4957 // Mark narrow state 4958 if ( $search_wrap.width() < 150 ) { 4959 $search_wrap.addClass( 'et-narrow-wrapper' ); 4960 } 4961 4962 // Fixes issue where theme's search button has no text: treat it as non-existent 4963 if ( $search_input_submit.length && ( typeof search_input_submit_text == 'undefined' || search_input_submit_text === '' ) ) { 4964 $search_input_submit.remove(); 4965 $search_wrap.addClass( 'et-no-submit-button' ); 4966 } 4967 4968 if ( $search_button.length && ( typeof search_button_text == 'undefined' || search_button_text === '' ) ) { 4969 $search_button.remove(); 4970 $search_wrap.addClass( 'et-no-submit-button' ); 4971 } 4972 4973 } ); 4974 4975 // get the content of next/prev page via ajax for modules which have the .et_pb_ajax_pagination_container class 4976 $( 'body' ).on( 'click', '.et_pb_ajax_pagination_container .wp-pagenavi a,.et_pb_ajax_pagination_container .pagination a', function() { 4977 var this_link = $( this ); 4978 var href = this_link.attr( 'href' ); 4979 var current_href = window.location.href; 4980 var module_classes = this_link.closest( '.et_pb_module' ).attr( 'class' ).split( ' ' ); 4981 var module_class_processed = ''; 4982 var $current_module; 4983 var animation_classes = et_get_animation_classes(); 4984 4985 // global variable to store the cached content 4986 window.et_pb_ajax_pagination_cache = window.et_pb_ajax_pagination_cache || []; 4987 4988 // construct the selector for current module 4989 $.each( module_classes, function( index, value ) { 4990 // skip animation classes so no wrong href is formed afterwards 4991 if ( $.inArray( value, animation_classes ) !== -1 ) { 4992 return; 4993 } 4994
4995 if ( '' !== value.trim() ) { 4996 module_class_processed += '.' + value; 4997 } 4998 }); 4999 5000 $current_module = $( module_class_processed ); 5001 5002 // remove module animation to prevent conflicts with the page changing animation 5003 et_remove_animation( $current_module ); 5004 5005 // use cached content if it has beed retrieved already, otherwise retrieve the content via ajax 5006 if ( typeof window.et_pb_ajax_pagination_cache[ href + module_class_processed ] !== 'undefined' ) { 5007 $current_module.fadeTo( 'slow', 0.2, function() { 5008 $current_module.find( '.et_pb_ajax_pagination_container' ).replaceWith( window.et_pb_ajax_pagination_cache[ href + module_class_processed ] ); 5009 et_pb_set_paginated_content( $current_module, true ); 5010 } ); 5011 } else { 5012 // update cache for currently opened page if not set yet 5013 if ( typeof window.et_pb_ajax_pagination_cache[ current_href + module_class_processed ] === 'undefined' ) { 5014 window.et_pb_ajax_pagination_cache[ current_href + module_class_processed ] = $current_module.find( '.et_pb_ajax_pagination_container' ); 5015 } 5016 5017 $current_module.fadeTo( 'slow', 0.2, function() { 5018 jQuery.get( href, function( page ) { 5019 var $page = jQuery( page ); 5020 // Find custom style 5021 var $style = $page.filter( '#et-builder-module-design-cached-inline-styles' ); 5022 // Make sure it's included in the new content 5023 var $content = $page.find( module_class_processed + ' .et_pb_ajax_pagination_container' ).prepend( $style ); 5024 // Remove animations to prevent blocks from not showing 5025 et_remove_animation( $content.find( '.et_animated' ) ); 5026 // Replace current page with new one 5027 $current_module.find( '.et_pb_ajax_pagination_container' ).replaceWith( $content ); 5028 window.et_pb_ajax_pagination_cache[ href + module_class_processed ] = $content; 5029 et_pb_set_paginated_content( $current_module, false ); 5030 }); 5031 }); 5032 } 5033 5034 return false; 5035 }); 5036 5037 function et_pb_set_paginated_content( $current_module, is_cache ) { 5038 // Re-apply Salvattore grid to the new content if needed. 5039 if ( typeof $current_module.find( '.et_pb_salvattore_content' ).attr( 'data-columns' ) !== 'undefined' ) { 5040 // register grid only if the content is not from cache 5041 if ( ! is_cache ) { 5042 salvattore.registerGrid( $current_module.find( '.et_pb_salvattore_content' )[0] ); 5043 } 5044 salvattore.recreateColumns( $current_module.find( '.et_pb_salvattore_content' )[0] ); 5045 $current_module.find( '.et_pb_post' ).css( { 'opacity' : '1' } ); 5046 } 5047 5048 // init audio module on new content 5049 if ( $current_module.find( '.et_audio_container' ).length > 0 && typeof wp !== 'undefined' && typeof wp.mediaelement !== 'undefined' && typeof wp.mediaelement.initialize === 'function' ) { 5050 wp.mediaelement.initialize(); 5051 5052 $(window).trigger('resize'); 5053 } 5054 5055 // load waypoint modules such as counters and animated images 5056 if ( $current_module.find( '.et-waypoint, .et_pb_circle_counter, .et_pb_number_counter' ).length > 0 ) { 5057 $current_module.find( '.et-waypoint, .et_pb_circle_counter, .et_pb_number_counter' ).each( function() { 5058 var $waypoint_module = $( this ); 5059 5060 if ( $waypoint_module.hasClass( 'et_pb_circle_counter' ) ) { 5061 window.et_pb_reinit_circle_counters( $waypoint_module ); 5062 } 5063 5064 if ( $waypoint_module.hasClass( 'et_pb_number_counter' ) ) { 5065 window.et_pb_reinit_number_counters( $waypoint_module ); 5066 } 5067 5068 if ( $waypoint_module.find( '.et_pb_counter_amount' ).length > 0 ) { 5069 $waypoint_module.find( '.et_pb_counter_amount' ).each( function() { 5070 window.et_bar_counters_init( $( this ) ); 5071 }); 5072 } 5073 5074 $( this ).css({ 'opacity': '1'}); 5075 5076 window.et_reinit_waypoint_modules(); 5077 } ); 5078 } 5079 5080 /** 5081 * Init post gallery format 5082 */ 5083 if ( $current_module.find( '.et_pb_slider' ).length > 0 ) { 5084 $current_module.find('.et_pb_slider').each(function() { 5085 et_pb_slider_init($(this)); 5086 }); 5087 } 5088 5089 /** 5090 * Init post video format overlay click 5091 */ 5092 $current_module.on('click', '.et_pb_video_overlay', function(e) { 5093 e.preventDefault(); 5094 et_pb_play_overlayed_video($(this)); 5095 }) 5096 5097 // Re-apply fitvids to the new content. 5098 $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']"} ); 5099 5100 $current_module.fadeTo( 'slow', 1 ); 5101 5102 // reinit ET shortcodes. 5103 if (typeof window.et_shortcodes_init === 'function') { 5104 window.et_shortcodes_init($current_module); 5105 } 5106 5107 // scroll to the top of the module 5108 $( 'html, body' ).animate({ 5109 scrollTop: ( $current_module.offset().top - ( $( '#main-header' ).innerHeight() + $( '#top-header' ).innerHeight() + 50 ) ) 5110 }); 5111 } 5112 5113 window.et_pb_search_init = function( $search ) { 5114 var $input_field = $search.find( '.et_pb_s' ); 5115 var $button = $search.find( '.et_pb_searchsubmit' ); 5116 var input_padding = $search.hasClass( 'et_pb_text_align_right' ) ? 'paddingLeft' : 'paddingRight'; 5117 var disabled_button = $search.hasClass( 'et_pb_hide_search_button' ); 5118 var buttonHeight = $button.outerHeight(); 5119 var buttonWidth = $button.outerWidth(); 5120 var inputHeight = $input_field.innerHeight(); 5121 5122 // set the relative button position to get its height correctly 5123 $button.css( { 'position' : 'relative' } ); 5124 5125 if ( buttonHeight > inputHeight ) { 5126 $input_field.innerHeight( buttonHeight ); 5127 } 5128 5129 if ( ! disabled_button ) { 5130 $input_field.css( input_padding, buttonWidth + 10 ); 5131 } 5132 5133 // reset the button position back to default 5134 $button.css( { 'position' : '' } ); 5135 } 5136 5137 /** 5138 * Fix search module which has percentage based custom margin 5139 */ 5140 window.et_pb_search_percentage_custom_margin_fix = function( $search ) { 5141 var inputMargin = $search.find( '.et_pb_s' ).css( 'margin' ).split(' '); 5142 var inputMarginObj = {}; 5143 5144 switch(inputMargin.length) { 5145 case 4: 5146 inputMarginObj = { 5147 top: inputMargin[0], 5148 right: inputMargin[1], 5149 bottom: inputMargin[2], 5150 left: inputMargin[3], 5151 }; 5152 break; 5153 case 2: 5154 inputMarginObj = { 5155 top: inputMargin[0], 5156 right: inputMargin[1], 5157 bottom: inputMargin[0], 5158 left: inputMargin[1], 5159 }; 5160 break; 5161 default: 5162 inputMarginObj = { 5163 top: inputMargin[0], 5164 right: inputMargin[0], 5165 bottom: inputMargin[0], 5166 left: inputMargin[0], 5167 }; 5168 break; 5169 } 5170 5171 var inputRight = 0 - parseFloat(inputMarginObj.left) + 'px'; 5172 5173 $search.find('.et_pb_searchsubmit').css({ 5174 top: inputMarginObj.top, 5175 right: inputRight, 5176 bottom: inputMarginObj.bottom, 5177 }); 5178 } 5179 5180 if ( $( '.et_pb_search' ).length ) { 5181 $( '.et_pb_search' ).each( function() { 5182 var $search = $(this); 5183 5184 if ( $search.is( '.et_pb_search_percentage_custom_margin' ) ) { 5185 et_pb_search_percentage_custom_margin_fix( $search ); 5186 } 5187 5188 et_pb_search_init( $search ); 5189 }); 5190 } 5191 5192 window.et_pb_comments_init = function( $comments_module ) { 5193 var $comments_module_button = $comments_module.find( '.comment-reply-link, .submit' ); 5194 5195 if ( $comments_module_button.length ) { 5196 $comments_module_button.addClass( 'et_pb_button' ); 5197 5198 if ( typeof $comments_module.attr( 'data-icon' ) !== 'undefined' && $comments_module.attr( 'data-icon' ) !== '' ) { 5199 $comments_module_button.attr( 'data-icon', $comments_module.attr( 'data-icon' ) ); 5200 $comments_module_button.addClass( 'et_pb_custom_button_icon' ); 5201 } 5202 } 5203 }; 5204 5205 // apply required classes for the Reply buttons in Comments Module 5206 if ( $( '.et_pb_comments_module' ).length ) { 5207 $( '.et_pb_comments_module' ).each( function() { 5208 var $comments_module = $( this ); 5209 5210 et_pb_comments_init( $comments_module ); 5211 }); 5212 } 5213 5214 window.et_fix_pricing_currency_position(); 5215 5216 $('.et_pb_contact_form_container, .et_pb_newsletter_custom_fields').each( function() { 5217 var $form = $(this); 5218 var subjects_selector = 'input, textarea, select'; 5219 var condition_check = function() { 5220 et_conditional_check( $form ); 5221 }; 5222 var debounced_condition_check = et_pb_debounce( condition_check, 250 ); 5223 5224 // Listen for any field change 5225 $form.on( 'change', subjects_selector, condition_check ); 5226 $form.on( 'keydown', subjects_selector, debounced_condition_check ); 5227 5228 // Conditions may be satisfied on default form state 5229 et_conditional_check( $form ); 5230 } ); 5231 5232 function et_conditional_check( $form ) { 5233 var $conditionals = $form.find('[data-conditional-logic]'); 5234 5235 // Upon change loop all the fields that have conditional logic 5236 $conditionals 5237 .each( function() { 5238 var $conditional = $(this); 5239 5240 // jQuery automatically parses the JSON 5241 var rules = $conditional.data('conditional-logic'); 5242 var relation = $conditional.data('conditional-relation'); 5243 5244 // Loop all the conditional logic rules 5245 var matched_rules = []; 5246 5247 for ( var i = 0; i < rules.length; i++ ) { 5248 var ruleset = rules[i]; 5249 var check_id = ruleset[0]; 5250 var check_type = ruleset[1]; 5251 var check_value = ruleset[2]; 5252 var $wrapper = $form.find('.et_pb_contact_field[data-id="' + check_i
5252d + '"]'); 5253 var field_id = $wrapper.data('id'); 5254 var field_type = $wrapper.data('type'); 5255 var field_value; 5256 5257 /* 5258 Check if the field wrapper is actually visible when including it in the rules check. 5259 This avoids the scenario with a parent, child and grandchild field where the parent 5260 field is changed but the grandchild remains visible, because the child one has the 5261 right value, even though it is not visible 5262 */ 5263 if ( ! $wrapper.is(':visible') ) { 5264 continue; 5265 } 5266 5267 // Get the proper compare value based on the field type 5268 switch( field_type ) { 5269 case 'input': 5270 case 'email': 5271 field_value = $wrapper.find('input').val(); 5272 break; 5273 case 'text': 5274 field_value = $wrapper.find('textarea').val(); 5275 break; 5276 case 'radio': 5277 field_value = $wrapper.find('input:checked').val() || ''; 5278 break; 5279 case 'checkbox': 5280 /* 5281 Conditional logic for checkboxes is a bit trickier since we have multiple values. 5282 To address that we first check if a checked checkbox with the desired value 5283 exists, which is represented by setting `field_value` to true or false. 5284 Next we always set `check_value` to true so we can compare against the 5285 result of the value check. 5286 */ 5287 var $checkbox = $wrapper.find(':checkbox:checked'); 5288 5289 field_value = false; 5290 5291 $checkbox.each(function() { 5292 if ( check_value === $(this).val() ) { 5293 field_value = true; 5294 5295 return false; 5296 } 5297 }); 5298 5299 check_value = true; 5300 break; 5301 case 'select': 5302 field_value = $wrapper.find('select').val(); 5303 break; 5304 } 5305 5306 /* 5307 'is empty' / 'is not empty' are comparing against an empty value so simply 5308 reset the `check_value` and update the condition to 'is' / 'is not' 5309 */ 5310 if ( 'is empty' === check_type || 'is not empty' === check_type ) { 5311 check_type = 'is empty' === check_type ? 'is' : 'is not'; 5312 check_value = ''; 5313 5314 /* 5315 `field_value` will always be `false` if all the checkboxes are unchecked 5316 since it only changes when a checked checkbox matches the `check_value` 5317 Because of `check_value` being reset to empty string we do the same 5318 to `field_value` (if it is `false`) to cover the 'is empty' case 5319 */ 5320 if ( 'checkbox' === field_type && false === field_value ) { 5321 field_value = ''; 5322 } 5323 } 5324 5325 // Check if the value IS matching (if it has to) 5326 if ( 'is' === check_type && field_value !== check_value ) { 5327 continue; 5328 } 5329 5330 // Check if the value IS NOT matching (if it has to) 5331 if ( 'is not' === check_type && field_value === check_value ) { 5332 continue; 5333 } 5334 5335 // Create the contains/not contains regular expresion 5336 var containsRegExp = new RegExp( check_value, 'i' ); 5337 5338 // Check if the value IS containing 5339 if ( 'contains' === check_type && ! field_value.match( containsRegExp ) ) { 5340 continue; 5341 } 5342 5343 // Check if the value IS NOT containing 5344 if ( 'does not contain' === check_type && field_value.match( containsRegExp ) ) { 5345 continue; 5346 } 5347 5348 // Prepare the values for the 'is greater than' / 'is less than' check 5349 var maybeNumericValue = parseInt( field_value ); 5350 var maybeNumbericCheckValue = parseInt( check_value ); 5351 5352 if ( 5353 ( 'is greater' === check_type || 'is less' === check_type ) && 5354 ( isNaN( maybeNumericValue ) || isNaN( maybeNumbericCheckValue ) ) 5355 ) { 5356 continue; 5357 } 5358 5359 // Check if the value is greater than 5360 if ( 'is greater' === check_type && maybeNumericValue <= maybeNumbericCheckValue) { 5361 continue; 5362 } 5363 5364 // Check if the value is less than 5365 if ( 'is less' === check_type && maybeNumericValue >= maybeNumbericCheckValue) { 5366 continue; 5367 } 5368 5369 matched_rules.push( true ); 5370 } 5371 5372 // Hide all the conditional fields initially 5373 $conditional.hide(); 5374 5375 /* 5376 Input fields may have HTML5 pattern validation which must be ignored 5377 if the field is not visible. In order for the pattern to not be 5378 taken into account the field must have novalidate property and 5379 to not be required (or to not have a pattern attribute) 5380 */ 5381 var $conditional_input = $conditional.find('input[type="text"]'); 5382 var conditional_pattern = $conditional_input.attr('pattern'); 5383 5384 $conditional_input.attr('novalidate', 'novalidate'); 5385 $conditional_input.attr('data-pattern', conditional_pattern); 5386 $conditional_input.removeAttr('pattern'); 5387 5388 if ( 'all' === relation && rules.length === matched_rules.length ) { 5389 $conditional.show(); 5390 $conditional_input.removeAttr('novalidate'); 5391 $conditional_input.attr('pattern', $conditional_input.data('pattern')); 5392 } 5393 5394 if ( 'any' === relation && 0 < matched_rules.length ) { 5395 $conditional.show(); 5396 $conditional_input.removeAttr('novalidate'); 5397 $conditional_input.attr('pattern', $conditional_input.data('pattern')); 5398 } 5399 } ); 5400 } 5401 5402 // Adjust z-index for animated full-width menu modules 5403 if ( 'undefined' !== typeof et_animation_data && et_animation_data.length > 0 ) { 5404 5405 // Store the maximum z-index that should be applied 5406 var maxFullwidthMenuIndex = 0; 5407 5408 // Increase the maximum z-index by one for each module 5409 for ( var i = 0; i < et_animation_data.length; i++ ) { 5410 var animation_entry = et_animation_data[i]; 5411 5412 if ( ! animation_entry.class ) { 5413 continue; 5414 } 5415 5416 if ( $('.' + animation_entry.class ).hasClass('et_pb_fullwidth_menu') ) { 5417 maxFullwidthMenuIndex++; 5418 } 5419 } 5420 5421 var $fullWidthMenus = $('.et_pb_fullwidth_menu'); 5422 5423 $fullWidthMenus.each(function() { 5424 var $fullWidthMenu = $(this); 5425 5426 // When the animation ends apply z-index in descending order to each of the animated modules 5427 $fullWidthMenu.on('webkitAnimationEnd oanimationend msAnimationEnd animationend', function() { 5428 $fullWidthMenu.css('z-index', maxFullwidthMenuIndex - $fullWidthMenu.index('.et_pb_fullwidth_menu') ); 5429 }); 5430 }); 5431 } 5432 5433 /** 5434 * Provide event listener for plugins to hook up to 5435 */ 5436 $(document).trigger('et_pb_after_init_modules'); 5437 }); 5438 } 5439 5440 // Modification of underscore's _.debounce() 5441 // Underscore.js 1.8.3 5442 // http://underscorejs.org
5443 // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 5444 // Underscore may be freely distributed under the MIT license. 5445 window.et_pb_debounce = function(func, wait, immediate) { 5446 var timeout, args, context, timestamp, result; 5447 5448 var now = Date.now || new Date().getTime(); 5449 5450 var later = function() { 5451 var last = now - timestamp; 5452 5453 if (last < wait && last >= 0) { 5454 timeout = setTimeout(later, wait - last); 5455 } else { 5456 timeout = null; 5457 if (!immediate) { 5458 result = func.apply(context, args); 5459 if (!timeout) context = args = null; 5460 } 5461 } 5462 }; 5463 5464 return function() { 5465 context = this; 5466 args = arguments; 5467 timestamp = now; 5468 var callNow = immediate && !timeout; 5469 if (!timeout) timeout = setTimeout(later, wait); 5470 if (callNow) { 5471 result = func.apply(context, args); 5472 context = args = null; 5473 } 5474 5475 return result; 5476 }; 5477 }; 5478 5479 if ( et_pb_custom.is_ab_testing_active && 'yes' === et_pb_custom.is_cache_plugin_active ) { 5480 // update the window.et_load_event_fired variable to initiate the scripts properly 5481 $( window ).load( function() { 5482 window.et_load_event_fired = true; 5483 }); 5484 5485 // get the subject id for current visitor and display it 5486 // this ajax request performed only if AB Testing is enabled and cache plugin active 5487 $.ajax( { 5488 type: "POST", 5489 url: et_pb_custom.ajaxurl, 5490 dataType: "json", 5491 data: 5492 { 5493 action : 'et_pb_ab_get_subject_id', 5494 et_frontend_nonce : et_pb_custom.et_frontend_nonce, 5495 et_pb_ab_test_id : et_pb_custom.page_id 5496 }, 5497 success: function( subject_data ) { 5498 if ( subject_data ) { 5499 // append the subject content to appropriate placeholder 5500 $( '.et_pb_subject_placeholder_id_' + subject_data.id ).after( subject_data.content ); 5501 // remove all other placeholders from the DOM 5502 $( '.et_pb_subject_placeholder' ).remove(); 5503 5504 // init all scripts once the subject loaded 5505 window.et_pb_init_modules(); 5506 $( 'body' ).trigger( 'et_pb_ab_subject_ready' ); 5507 } 5508 } 5509 }); 5510 } else { 5511 window.et_pb_init_modules(); 5512 } 5513 5514 $(document).ready(function() { 5515 ( et_pb_box_shadow_elements||[] ).map(et_pb_box_shadow_apply_overlay); 5516 }); 5517 5518 $(window).load(function() { 5519 var $body = $('body'); 5520 // fix Safari letter-spacing bug when styles applied in `head` 5521 // Trigger styles redraw by changing body display property to differentvalue and reverting it back to original. 5522 if ($body.hasClass('safari')) { 5523 var original_display_value = $body.css('display'); 5524 var different_display_value = 'initial' === original_display_value ? 'block' : 'initial'; 5525 5526 $body.css({ 'display': different_display_value }); 5527 5528 setTimeout(function() { 5529 $body.css({ 'display': original_display_value }); 5530 }, 0); 5531 5532 // Keep this script here, as it needs to be executed only if the script from above is executed 5533 // As the script from above somehow affects WooCommerce single product image rendering. 5534 // https://github.com/elegantthemes/Divi/issues/7454 5535 if ($body.hasClass('woocommerce-page') && $body.hasClass('single-product')) { 5536 var $wc = $('.woocommerce div.product div.images.woocommerce-product-gallery'); 5537 5538 if ($wc.length === 0) { 5539 return; 5540 } 5541 5542 // Don't use jQuery to get element opacity, as it may return an outdated value. 5543 var opacity = parseInt($wc[0].style.opacity); 5544 5545 if (!opacity) { 5546 return; 5547 } 5548 5549 $wc.css({opacity: opacity - .09}); 5550 setTimeout(function() { 5551 $wc.css({opacity: opacity}); 5552 }, 0); 5553 } 5554 } 5555 }); 5556 5557 // Handle cases where builder modules are not initially visible and produce sizing 5558 // issues as a result (e.g. slider module inside popups, accordions etc.). 5559 $(document).ready(function() { 5560 if (MutationObserver === undefined) { 5561 // Bail if MutationObserver is not supported by the user agent. 5562 return; 5563 } 5564 5565 var getSectionParents = function($sections) { 5566 var filterMethod = $.uniqueSort !== undefined ? $.uniqueSort : $.unique; 5567 var $sectionParents = $([]); 5568 5569 $sections.each(function() { 5570 $sectionParents = $sectionParents.add($(this).parents()); 5571 }); 5572 5573 // Avoid duplicate section parents. 5574 return filterMethod($sectionParents.get()); 5575 }; 5576 5577 var getInvisibleNodes = function($sections) { 5578 return $sections.filter(function() { 5579 return !$(this).is(':visible'); 5580 }).length; 5581 }; 5582 5583 var $sections = $('.et_pb_section'); 5584 var sectionParents = getSectionParents($sections); 5585 var invisibleSections = getInvisibleNodes($sections); 5586 var maybeRefreshSections = function () { 5587 var newInvisibleSections = getInvisibleNodes($sections); 5588 if (newInvisibleSections < invisibleSections) { 5589 // Trigger resize if some previously invisible sections have become visible. 5590 $(window).trigger('resize'); 5591 } 5592 invisibleSections = newInvisibleSections; 5593 }; 5594 var observer = new MutationObserver(window.et_pb_debounce(maybeRefreshSections, 200)); 5595 5596 for (var i = 0; i < sectionParents.length; i++) { 5597 observer.observe(sectionParents[i], { 5598 childList: true, 5599 attributes: true, 5600 attributeFilter: ['class', 'style'], 5601 attributeOldValue: false, 5602 characterData: false, 5603 characterDataOldValue: false, 5604 subtree: false 5605 }); 5606 } 5607 }); 5608})(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.