1(function($){ 2 var $et_window = $(window); 3 4 window.et_load_event_fired = false; 5 6 jQuery.fn.reverse = [].reverse; 7 8 jQuery.fn.closest_descendent = function( selector ) { 9 var $found, 10 $current_children = this.children(); 11 12 while ( $current_children.length ) { 13 $found = $current_children.filter( selector ); 14 if ( $found.length ) { 15 break; 16 } 17 $current_children = $current_children.children(); 18 } 19 20 return $found; 21 }; 22 23 window.et_pb_init_modules = function() { 24 $.et_pb_simple_slider = function(el, options) { 25 var settings = $.extend( { 26 slide : '.et-slide', // slide class 27 arrows : '.et-pb-slider-arrows', // arrows container class 28 prev_arrow : '.et-pb-arrow-prev', // left arrow class 29 next_arrow : '.et-pb-arrow-next', // right arrow class 30 controls : '.et-pb-controllers a', // control selector 31 carousel_controls : '.et_pb_carousel_item', // carousel control selector 32 control_active_class : 'et-pb-active-control', // active control class name 33 previous_text : et_pb_custom.previous, // previous arrow text 34 next_text : et_pb_custom.next, // next arrow text 35 fade_speed : 500, // fade effect speed 36 use_arrows : true, // use arrows? 37 use_controls : true, // use controls? 38 manual_arrows : '', // html code for custom arrows 39 append_controls_to : '', // controls are appended to the slider element by default, here you can specify the element it should append to 40 controls_below : false, 41 controls_class : 'et-pb-controllers', // controls container class name 42 slideshow : false, // automattic animation? 43 slideshow_speed : 7000, // automattic animation speed 44 show_progress_bar : false, // show progress bar if automattic animation is active 45 tabs_animation : false, 46 use_carousel : false 47 }, options ); 48 49 var $et_slider = $(el), 50 $et_slide = $et_slider.closest_descendent( settings.slide ), 51 et_slides_number = $et_slide.length, 52 et_fade_speed = settings.fade_speed, 53 et_active_slide = 0, 54 $et_slider_arrows, 55 $et_slider_prev, 56 $et_slider_next, 57 $et_slider_controls, 58 $et_slider_carousel_controls, 59 et_slider_timer, 60 controls_html = '', 61 carousel_html = '', 62 $progress_bar = null, 63 progress_timer_count = 0, 64 $et_pb_container = $et_slider.find( '.et_pb_container' ), 65 et_pb_container_width = $et_pb_container.width(), 66 is_post_slider = $et_slider.hasClass( 'et_pb_post_slider' ); 67 68 $et_slider.et_animation_running = false; 69 70 $.data(el, "et_pb_simple_slider", $et_slider); 71 72 $et_slide.eq(0).addClass( 'et-pb-active-slide' ); 73 74 if ( ! settings.tabs_animation ) { 75 if ( !$et_slider.hasClass('et_pb_bg_layout_dark') && !$et_slider.hasClass('et_pb_bg_layout_light') ) { 76 $et_slider.addClass( et_get_bg_layout_color( $et_slide.eq(0) ) ); 77 } 78 } 79 80 if ( settings.use_arrows && et_slides_number > 1 ) { 81 if ( settings.manual_arrows == '' ) 82 $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>' ); 83 else 84 $et_slider.append( settings.manual_arrows ); 85 86 $et_slider_arrows = $et_slider.find( settings.arrows ); 87 $et_slider_prev = $et_slider.find( settings.prev_arrow ); 88 $et_slider_next = $et_slider.find( settings.next_arrow ); 89 90 $et_slider_next.click( function(){ 91 if ( $et_slider.et_animation_running ) return false; 92 93 $et_slider.et_slider_move_to( 'next' ); 94 95 return false; 96 } ); 97 98 $et_slider_prev.click( function(){ 99 if ( $et_slider.et_animation_running ) return false; 100 101 $et_slider.et_slider_move_to( 'previous' ); 102 103 return false; 104 } ); 105 106 // swipe support requires et-jquery-touch-mobile 107 $et_slider.find( settings.slide ).on( 'swipeleft', function() { 108 $et_slider.et_slider_move_to( 'next' ); 109 }); 110 $et_slider.find( settings.slide ).on( 'swiperight', function() { 111 $et_slider.et_slider_move_to( 'previous' ); 112 }); 113 } 114 115 if ( settings.use_controls && et_slides_number > 1 ) { 116 for ( var i = 1; i <= et_slides_number; i++ ) { 117 controls_html += '<a href="#"' + ( i == 1 ? ' class="' + settings.control_active_class + '"' : '' ) + '>
117' + i + '</a>'; 118 } 119 120 controls_html = 121 '<div class="' + settings.controls_class + '">' + 122 controls_html + 123 '</div>'; 124 125 if ( settings.append_controls_to == '' ) 126 $et_slider.append( controls_html ); 127 else 128 $( settings.append_controls_to ).append( controls_html ); 129 130 if ( settings.controls_below ) 131 $et_slider_controls = $et_slider.parent().find( settings.controls ); 132 else 133 $et_slider_controls = $et_slider.find( settings.controls ); 134 135 et_maybe_set_controls_color( $et_slide.eq(0) ); 136 137 $et_slider_controls.click( function(){ 138 if ( $et_slider.et_animation_running ) return false; 139 140 $et_slider.et_slider_move_to( $(this).index() ); 141 142 return false; 143 } ); 144 } 145 146 if ( settings.use_carousel && et_slides_number > 1 ) { 147 for ( var i = 1; i <= et_slides_number; i++ ) { 148 slide_id = i - 1; 149 image_src = ( $et_slide.eq(slide_id).data('image') !== undefined ) ? 'url(' + $et_slide.eq(slide_id).data('image') + ')' : 'none'; 150 carousel_html += '<div class="et_pb_carousel_item ' + ( i == 1 ? settings.control_active_class : '' ) + '" data-slide-id="'+ slide_id +'">' + 151 '<div class="et_pb_video_overlay" href="#" style="background-image: ' + image_src + ';">' + 152 '<div class="et_pb_video_overlay_hover"><a href="#" class="et_pb_video_play"></a></div>' + 153 '</div>' + 154 '</div>'; 155 } 156 157 carousel_html = 158 '<div class="et_pb_carousel">' + 159 '<div class="et_pb_carousel_items">' + 160 carousel_html + 161 '</div>' + 162 '</div>'; 163 $et_slider.after( carousel_html ); 164 165 $et_slider_carousel_controls = $et_slider.siblings('.et_pb_carousel').find( settings.carousel_controls ); 166 $et_slider_carousel_controls.click( function(){ 167 if ( $et_slider.et_animation_running ) return false; 168 169 var $this = $(this); 170 $et_slider.et_slider_move_to( $this.data('slide-id') ); 171 172 return false; 173 } ); 174 } 175 176 if ( settings.slideshow && et_slides_number > 1 ) { 177 $et_slider.hover( function() { 178 if ( $et_slider.hasClass( 'et_slider_auto_ignore_hover' ) ) { 179 return; 180 } 181 182 $et_slider.addClass( 'et_slider_hovered' ); 183 184 if ( typeof et_slider_timer != 'undefined' ) { 185 clearInterval( et_slider_timer ); 186 } 187 }, function() { 188 if ( $et_slider.hasClass( 'et_slider_auto_ignore_hover' ) ) { 189 return; 190 } 191 192 $et_slider.removeClass( 'et_slider_hovered' ); 193 194 et_slider_auto_rotate(); 195 } ); 196 } 197 198 et_slider_auto_rotate(); 199 200 function et_slider_auto_rotate(){ 201 if ( settings.slideshow && et_slides_number > 1 && ! $et_slider.hasClass( 'et_slider_hovered' ) ) { 202 et_slider_timer = setTimeout( function() { 203 $et_slider.et_slider_move_to( 'next' ); 204 }, settings.slideshow_speed ); 205 } 206 } 207 208 $et_slider.et_slider_destroy = function() { 209 // Clear existing timer / auto rotate 210 if ( typeof et_slider_timer != 'undefined' ) { 211 clearInterval( et_slider_timer ); 212 } 213 214 // Deregister existing events 215 $et_slider.unbind('mouseenter mouseleave'); 216 $et_slider.find('.et-pb-slider-arrows a, .et-pb-controllers a').unbind('click'); 217 218 // Removing existing style from slide(s) 219 $et_slider.find('.et_pb_slide').css({ 220 'z-index': '', 221 'display': '', 222 'opacity': '', 223 }); 224 225 // Removing existing classnames from slide(s) 226 $et_slider.find('.et-pb-active-slide').removeClass('et-pb-active-slide'); 227 $et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide'); 228 229 // Removing DOM that was added by slider 230 $et_slider.find('.et-pb-slider-arrows, .et-pb-controllers').remove(); 231 $et_slider.siblings('.et_pb_carousel').remove(); 232 } 233 234 function et_stop_video( active_slide ) { 235 var $et_video, et_video_src; 236 237 // if there is a video in the slide, stop it when switching to another slide 238 if ( active_slide.has( 'iframe' ).length ) { 239 $et_video = active_slide.find( 'iframe' ); 240 et_video_src = $et_video.attr( 'src' ); 241 242 $et_video.attr( 'src', '' ); 243 $et_video.attr( 'src', et_video_src ); 244 245 } else if ( active_slide.has( 'video' ).length ) { 246 if ( !active_slide.find('.et_pb_section_video_bg').length ) { 247 $et_video = active_slide.find( 'video' ); 248 $et_video[0].pause(); 249 } 250 } 251 } 252 253 function et_fix_slider_content_images() { 254 var $this_slider = $et_slider, 255 $slide_image_container = $this_slider.find( '.et-pb-active-slide .et_pb_slide_image' ); 256 $slide_video_container = $this_slider.find( '.et-pb-active-slide .et_pb_slide_video' ); 257 $slide = $slide_image_container.closest( '.et_pb_slide' ), 258 $slider = $slide.closest( '.et_pb_slider' ),
259 slide_height = $slider.innerHeight(), 260 image_height = parseInt( slide_height * 0.8 ), 261 $top_header = $('#top-header'), 262 $main_header = $('#main-header'), 263 $et_transparent_nav = $( '.et_transparent_nav' ), 264 $et_vertical_nav = $('.et_vertical_nav'); 265 266 $slide_image_container.find( 'img' ).css( 'maxHeight', image_height + 'px' ); 267 268 if ( $slide.hasClass( 'et_pb_media_alignment_center' ) ) { 269 $slide_image_container.css( 'marginTop', '-' + parseInt( $slide_image_container.height() / 2 ) + 'px' ); 270 } 271 272 $slide_video_container.css( 'marginTop', '-' + parseInt( $slide_video_container.height() / 2 ) + 'px' ); 273 274 $slide_image_container.find( 'img' ).addClass( 'active' ); 275 } 276 277 function et_get_bg_layout_color( $slide ) { 278 if ( $slide.hasClass( 'et_pb_bg_layout_dark' ) ) { 279 return 'et_pb_bg_layout_dark'; 280 } 281 282 return 'et_pb_bg_layout_light'; 283 } 284 285 function et_maybe_set_controls_color( $slide ) { 286 var next_slide_dot_color, 287 $arrows, 288 arrows_color; 289 290 if ( typeof $et_slider_controls !== 'undefined' && $et_slider_controls.length ) { 291 next_slide_dot_color = $slide.attr( 'data-dots_color' ) || ''; 292 293 if ( next_slide_dot_color !== '' ) { 294 $et_slider_controls.attr( 'style', 'background-color: ' + hex_to_rgba( next_slide_dot_color, '0.3' ) + ';' ) 295 $et_slider_controls.filter( '.et-pb-active-control' ).attr( 'style', 'background-color: ' + hex_to_rgba( next_slide_dot_color ) + '!important;' ); 296 } else { 297 $et_slider_controls.removeAttr( 'style' ); 298 } 299 } 300 301 if ( typeof $et_slider_arrows !== 'undefined' && $et_slider_arrows.length ) { 302 $arrows = $et_slider_arrows.find( 'a' ); 303 arrows_color = $slide.attr( 'data-arrows_color' ) || ''; 304 305 if ( arrows_color !== '' ) { 306 $arrows.css( 'color', arrows_color ); 307 } else { 308 $arrows.css( 'color', 'inherit' ); 309 } 310 } 311 } 312 313 // fix the appearance of some modules inside the post slider 314 function et_fix_builder_content() { 315 if ( is_post_slider ) { 316 setTimeout( function() { 317 var $et_pb_circle_counter = $( '.et_pb_circle_counter' ), 318 $et_pb_number_counter = $( '.et_pb_number_counter' ); 319 320 window.et_fix_testimonial_inner_width(); 321 322 if ( $et_pb_circle_counter.length ) { 323 window.et_pb_reinit_circle_counters( $et_pb_circle_counter ); 324 } 325 326 if ( $et_pb_number_counter.length ) { 327 window.et_pb_reinit_number_counters( $et_pb_number_counter ); 328 } 329 window.et_reinit_waypoint_modules(); 330 }, 1000 ); 331 } 332 } 333 334 function hex_to_rgba( color, alpha ) { 335 var color_16 = parseInt( color.replace( '#', '' ), 16 ), 336 red = ( color_16 >> 16 ) & 255, 337 green = ( color_16 >> 8 ) & 255, 338 blue = color_16 & 255, 339 alpha = alpha || 1, 340 rgba; 341 342 rgba = red + ',' + green + ',' + blue + ',' + alpha; 343 rgba = 'rgba(' + rgba + ')'; 344 345 return rgba; 346 } 347 348 if ( window.et_load_event_fired ) { 349 et_fix_slider_content_images(); 350 } else { 351 $et_window.load( function() { 352 et_fix_slider_content_images(); 353 } ); 354 } 355 356 $et_window.resize( function() { 357 et_fix_slider_content_images(); 358 } ); 359 360 $et_slider.et_slider_move_to = function ( direction ) { 361 var $active_slide = $et_slide.eq( et_active_slide ), 362 $next_slide; 363 364 $et_slider.et_animation_running = true; 365 366 $et_slider.removeClass('et_slide_transition_to_next et_slide_transition_to_previous').addClass('et_slide_transition_to_' + direction ); 367 368 $et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide'); 369 370 if ( direction == 'next' || direction == 'previous' ){ 371 372 if ( direction == 'next' ) 373 et_active_slide = ( et_active_slide + 1 ) < et_slides_number ? et_active_slide + 1 : 0; 374 else 375 et_active_slide = ( et_active_slide - 1 ) >= 0 ? et_active_slide - 1 : et_slides_number - 1; 376 377 } else { 378 379 if ( et_active_slide == direction ) { 380 $et_slider.et_animation_running = false;
381 return; 382 } 383 384 et_active_slide = direction; 385 386 } 387 388 if ( typeof et_slider_timer != 'undefined' ) 389 clearInterval( et_slider_timer ); 390 391 $next_slide = $et_slide.eq( et_active_slide ); 392 393 if ( typeof $active_slide.find('video')[0] !== 'undefined' && typeof $active_slide.find('video')[0]['player'] !== 'undefined' ) { 394 $active_slide.find('video')[0].player.pause(); 395 } 396 397 if ( typeof $next_slide.find('video')[0] !== 'undefined' && typeof $next_slide.find('video')[0]['player'] !== 'undefined' ) { 398 $next_slide.find('video')[0].player.play(); 399 } 400 401 $et_slider.trigger( 'simple_slider_before_move_to', { direction : direction, next_slide : $next_slide }); 402 403 $et_slide.each( function(){ 404 $(this).css( 'zIndex', 1 ); 405 } ); 406 $active_slide.css( 'zIndex', 2 ).removeClass( 'et-pb-active-slide' ).addClass('et-pb-moved-slide'); 407 $next_slide.css( { 'display' : 'block', opacity : 0 } ).addClass( 'et-pb-active-slide' ); 408 409 et_fix_slider_content_images(); 410 411 et_fix_builder_content(); 412 413 if ( settings.use_controls ) 414 $et_slider_controls.removeClass( settings.control_active_class ).eq( et_active_slide ).addClass( settings.control_active_class ); 415 416 if ( settings.use_carousel ) 417 $et_slider_carousel_controls.removeClass( settings.control_active_class ).eq( et_active_slide ).addClass( settings.control_active_class ); 418 419 if ( ! settings.tabs_animation ) { 420 et_maybe_set_controls_color( $next_slide ); 421 422 $next_slide.animate( { opacity : 1 }, et_fade_speed ); 423 $active_slide.addClass( 'et_slide_transition' ).css( { 'display' : 'list-item', 'opacity' : 1 } ).animate( { opacity : 0 }, et_fade_speed, function(){ 424 var active_slide_layout_bg_color = et_get_bg_layout_color( $active_slide ), 425 next_slide_layout_bg_color = et_get_bg_layout_color( $next_slide ); 426 427 $(this).css('display', 'none').removeClass( 'et_slide_transition' ); 428 429 et_stop_video( $active_slide ); 430 431 $et_slider 432 .removeClass( active_slide_layout_bg_color ) 433 .addClass( next_slide_layout_bg_color ); 434 435 $et_slider.et_animation_running = false; 436 437 $et_slider.trigger( 'simple_slider_after_move_to', { next_slide : $next_slide } ); 438 } ); 439 } else { 440 $next_slide.css( { 'display' : 'none', opacity : 0 } ); 441 442 $active_slide.addClass( 'et_slide_transition' ).css( { 'display' : 'block', 'opacity' : 1 } ).animate( { opacity : 0 }, et_fade_speed, function(){ 443 $(this).css('display', 'none').removeClass( 'et_slide_transition' ); 444 445 $next_slide.css( { 'display' : 'block', 'opacity' : 0 } ).animate( { opacity : 1 }, et_fade_speed, function() { 446 $et_slider.et_animation_running = false; 447 448 $et_slider.trigger( 'simple_slider_after_move_to', { next_slide : $next_slide } ); 449 } ); 450 } ); 451 } 452 453 // reinit parallax on slide change to make sure it displayed correctly 454 window.et_pb_parallax_init( $next_slide ); 455 456 et_slider_auto_rotate(); 457 } 458 } 459 460 $.fn.et_pb_simple_slider = function( options ) { 461 return this.each(function() { 462 new $.et_pb_simple_slider(this, options); 463 }); 464 } 465 466 var et_hash_module_seperator = '||', 467 et_hash_module_param_seperator = '|'; 468 469 function process_et_hashchange( hash ) { 470 if ( ( hash.indexOf( et_hash_module_seperator, 0 ) ) !== -1 ) { 471 modules = hash.split( et_hash_module_seperator ); 472 for ( var i = 0; i < modules.length; i++ ) { 473 var module_params = modules[i].split( et_hash_module_param_seperator ); 474 var element = module_params[0]; 475 module_params.shift(); 476 if ( $('#' + element ).length ) { 477 $('#' + element ).trigger({ 478 type: "et_hashchange", 479 params: module_params 480 }); 481 } 482 } 483 } else { 484 module_params = hash.split( et_hash_module_param_seperator ); 485 var element = module_params[0]; 486 module_params.shift(); 487 if ( $('#' + element ).length ) { 488 $('#' + element ).trigger({ 489 type: "et_hashchange", 490 params: module_params 491 }); 492 } 493 } 494 } 495 496 function et_set_hash( module_state_hash ) { 497 module_id = module_state_hash.split( et_hash_module_param_seperator )[0]; 498 if ( !$('#' + module_id ).length ) { 499 return; 500 } 501 502 if ( window.location.hash ) { 503 var hash = window.location.hash.substring(1), //Puts hash in variable, and removes the # character 504 new_hash = []; 505 506 if ( ( hash.indexOf( et_hash_module_seperator, 0 ) ) !== -1 ) { 507 modules = hash.split( et_hash_module_seperator ); 508 var in_hash = false;
509 for ( var i = 0; i < modules.length; i++ ) { 510 var element = modules[i].split( et_hash_module_param_seperator )[0]; 511 if ( element === module_id ) { 512 new_hash.push( module_state_hash ); 513 in_hash = true; 514 } else { 515 new_hash.push( modules[i] ); 516 } 517 } 518 if ( !in_hash ) { 519 new_hash.push( module_state_hash ); 520 } 521 } else { 522 module_params = hash.split( et_hash_module_param_seperator ); 523 var element = module_params[0]; 524 if ( element !== module_id ) { 525 new_hash.push( hash ); 526 } 527 new_hash.push( module_state_hash ); 528 } 529 530 hash = new_hash.join( et_hash_module_seperator ); 531 } else { 532 hash = module_state_hash; 533 } 534 535 var yScroll = document.body.scrollTop; 536 window.location.hash = hash; 537 document.body.scrollTop = yScroll; 538 } 539 540 $.et_pb_simple_carousel = function(el, options) { 541 var settings = $.extend( { 542 slide_duration : 500, 543 }, options ); 544 545 var $et_carousel = $(el), 546 $carousel_items = $et_carousel.find('.et_pb_carousel_items'), 547 $the_carousel_items = $carousel_items.find('.et_pb_carousel_item'); 548 549 $et_carousel.et_animation_running = false; 550 551 $et_carousel.addClass('container-width-change-notify').on('containerWidthChanged', function( event ){ 552 set_carousel_columns( $et_carousel ); 553 set_carousel_height( $et_carousel ); 554 }); 555 556 $carousel_items.data('items', $the_carousel_items.toArray() ); 557 $et_carousel.data('columns_setting_up', false ); 558 559 $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>'); 560 561 set_carousel_columns( $et_carousel ); 562 set_carousel_height( $et_carousel ); 563 564 $et_carousel_next = $et_carousel.find( '.et-pb-arrow-next' ); 565 $et_carousel_prev = $et_carousel.find( '.et-pb-arrow-prev' ); 566 567 $et_carousel.on( 'click', '.et-pb-arrow-next', function(){ 568 if ( $et_carousel.et_animation_running ) return false; 569 570 $et_carousel.et_carousel_move_to( 'next' ); 571 572 return false; 573 } ); 574 575 $et_carousel.on( 'click', '.et-pb-arrow-prev', function(){ 576 if ( $et_carousel.et_animation_running ) return false; 577 578 $et_carousel.et_carousel_move_to( 'previous' ); 579 580 return false; 581 } ); 582 583 // swipe support requires et-jquery-touch-mobile 584 $et_carousel.on( 'swipeleft', function() { 585 $et_carousel.et_carousel_move_to( 'next' ); 586 }); 587 $et_carousel.on( 'swiperight', function() { 588 $et_carousel.et_carousel_move_to( 'previous' ); 589 }); 590 591 function set_carousel_height( $the_carousel ) { 592 var carousel_items_width = $the_carousel_items.width(), 593 carousel_items_height = $the_carousel_items.height(); 594 595 $carousel_items.css('height', carousel_items_height + 'px' ); 596 } 597 598 function set_carousel_columns( $the_carousel ) { 599 var columns, 600 $carousel_parent = $the_carousel.parents('.et_pb_column'), 601 carousel_items_width = $carousel_items.width(), 602 carousel_item_count = $the_carousel_items.length; 603 604 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') ) { 605 if ( $et_window.width() < 768 ) { 606 columns = 3; 607 } else { 608 columns = 4; 609 } 610 } 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') ) { 611 columns = 3; 612 } else if ( $carousel_parent.hasClass('et_pb_column_1_4') ) { 613 if ( $et_window.width() > 480 && $et_window.width() < 980 ) { 614 columns = 3; 615 } else { 616 columns = 2; 617 } 618 } 619 620 if ( columns === $carousel_items.data('portfolio-columns') ) { 621 return; 622 } 623 624 if ( $the_carousel.data('columns_setting_up') ) { 625 return; 626 } 627 628 $the_carousel.data('columns_setting_up', true ); 629 630 // store last setup column 631 $carousel_items.removeClass('columns-' + $carousel_items.data('portfolio-columns') ); 632 $carousel_items.addClass('columns-' + columns ); 633 $carousel_items.data('portfolio-columns', columns ); 634 635 // kill all previous groups to get ready to re-group 636 if ( $carousel_items.find('.et-carousel-group').length ) { 637 $the_carousel_items.appendTo( $carousel_items ); 638 $carousel_items.find('.et-carousel-group').remove(); 639 } 640 641 // setup the grouping 642 var the_carousel_items = $carousel_items.data('items'), 643 $carousel_group = $('<div class="et-carousel-group active">').appendTo( $carousel_items ); 644 645 $the_carousel_items.data('position', ''); 646 if ( the_carousel_items.length <= columns ) { 647 $carousel_items.find('.et-pb-slider-arrows').hide(); 648 } else { 649 $carousel_items.find('.et-pb-slider-arrows').show(); 650 } 651 652 for ( position = 1, x=0 ;x < the_carousel_items.length; x++, position++ ) { 653 if ( x < columns ) { 654 $( the_carousel_items[x] ).show(); 655 $( the_carousel_items[x] ).appendTo( $carousel_group ); 656 $( the_carousel_items[x] ).data('position', position ); 657 $( the_carousel_items[x] ).addClass('position_' + position ); 658 } else { 659 position = $( the_carousel_items[x] ).data('position'); 660 $( the_carousel_items[x] ).removeClass('position_' + position ); 661 $( the_carousel_items[x] ).data('position', '' ); 662 $( the_carousel_items[x] ).hide(); 663 } 664 } 665 666 $the_carousel.data('columns_setting_up', false ); 667 668 } /* end set_carousel_columns() */ 669 670 $et_carousel.et_carousel_move_to = function ( direction ) { 671 var $active_carousel_group = $carousel_items.find('.et-carousel-group.active'), 672 items = $carousel_items.data('items'), 673 columns = $carousel_items.data('portfolio-columns'); 674 675 $et_carousel.et_animation_running = true; 676 677 var left = 0; 678 $active_carousel_group.children().each(function(){ 679 $(this).css({'position':'absolute', 'left': left }); 680 left = left + $(this).outerWidth(true); 681 }); 682 683 if ( direction == 'next' ) { 684 var $next_carousel_group, 685 current_position = 1, 686 next_position = 1, 687 active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ), 688 active_items_end = active_items_start + columns, 689 next_items_start = active_items_end, 690 next_items_end = next_items_start + columns; 691 692 $next_carousel_group = $('<div class="et-carousel-group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group ); 693 $next_carousel_group.css({ 'width': $active_carousel_group.innerWidth() }).show(); 694 695 // this is an endless loop, so it can decide internally when to break out, so that next_position 696 // can get filled up, even to the extent of an element having both and current_ and next_ position 697 for( x = 0, total = 0 ; ; x++, total++ ) { 698 if ( total >= active_items_start && total < active_items_end ) { 699 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 700 $( items[x] ).data('current_position', current_position ); 701 current_position++; 702 } 703 704 if ( total >= next_items_start && total < next_items_end ) { 705 $( items[x] ).data('next_position', next_position ); 706 $( items[x] ).addClass('changing_position next_position next_position_' + next_position ); 707 708 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 709 $( items[x] ).addClass('container_append'); 710 } else { 711 $( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 712 $( items[x] ).addClass('delayed_container_append'); 713 } 714 715 next_position++; 716 } 717 718 if ( next_position > columns ) { 719 break; 720 } 721 722 if ( x >= ( items.length -1 )) { 723 x = -1; 724 } 725 } 726 727 var sorted = $carousel_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 728 var el_a_position = parseInt( $(a).data('next_position') ); 729 var el_b_position = parseInt( $(b).data('next_position') ); 730 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 731 }); 732 733 $( sorted ).show().appendTo( $next_carousel_group ); 734 735 var left = 0; 736 $next_carousel_group.children().each(function(){ 737 $(this).css({'position':'absolute', 'left': left }); 738 left = left + $(this).outerWidth(true); 739 }); 740 741 $active_carousel_group.animate({ 742 left: '-100%' 743 }, {
744 duration: settings.slide_duration, 745 complete: function() { 746 $carousel_items.find('.delayed_container_append').each(function(){ 747 left = $( '#' + $(this).attr('id') + '-dup' ).css('left'); 748 $(this).css({'position':'absolute', 'left': left }); 749 $(this).appendTo( $next_carousel_group ); 750 }); 751 752 $active_carousel_group.removeClass('active'); 753 $active_carousel_group.children().each(function(){ 754 position = $(this).data('position'); 755 current_position = $(this).data('current_position'); 756 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 757 $(this).data('position', ''); 758 $(this).data('current_position', ''); 759 $(this).hide(); 760 $(this).css({'position': '', 'left': ''}); 761 $(this).appendTo( $carousel_items ); 762 }); 763 764 $active_carousel_group.remove(); 765 766 } 767 } ); 768 769 next_left = $active_carousel_group.width() + parseInt( $the_carousel_items.first().css('marginRight').slice(0, -2) ); 770 $next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: next_left }); 771 $next_carousel_group.animate({ 772 left: '0%' 773 }, { 774 duration: settings.slide_duration, 775 complete: function(){ 776 $next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''}); 777 778 $next_carousel_group.find('.changing_position').each(function( index ){ 779 position = $(this).data('position'); 780 current_position = $(this).data('current_position'); 781 next_position = $(this).data('next_position'); 782 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position ); 783 $(this).data('current_position', ''); 784 $(this).data('next_position', ''); 785 $(this).data('position', ( index + 1 ) ); 786 }); 787 788 $next_carousel_group.children().css({'position': '', 'left': ''}); 789 $next_carousel_group.find('.delayed_container_append_dup').remove(); 790 791 $et_carousel.et_animation_running = false; 792 } 793 } ); 794 795 } else if ( direction == 'previous' ) { 796 var $prev_carousel_group, 797 current_position = columns, 798 prev_position = columns, 799 columns_span = columns - 1, 800 active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ), 801 active_items_end = active_items_start - columns_span, 802 prev_items_start = active_items_end - 1, 803 prev_items_end = prev_items_start - columns_span; 804 805 $prev_carousel_group = $('<div class="et-carousel-group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group ); 806 $prev_carousel_group.css({ 'left': '-' + $active_carousel_group.innerWidth(), 'width': $active_carousel_group.innerWidth() }).show(); 807 808 // this is an endless loop, so it can decide internally when to break out, so that next_position 809 // can get filled up, even to the extent of an element having both and current_ and next_ position 810 for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) { 811 812 if ( total <= active_items_start && total >= active_items_end ) { 813 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 814 $( items[x] ).data('current_position', current_position ); 815 current_position--; 816 } 817 818 if ( total <= prev_items_start && total >= prev_items_end ) { 819 $( items[x] ).data('prev_position', prev_position ); 820 $( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position ); 821 822 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 823 $( items[x] ).addClass('container_append'); 824 } else { 825 $( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 826 $( items[x] ).addClass('delayed_container_append'); 827 } 828 829 prev_position--; 830 } 831 832 if ( prev_position <= 0 ) { 833 break; 834 } 835 836 if ( x == 0 ) { 837 x = items.length; 838 } 839 } 840 841 var sorted = $carousel_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 842 var el_a_position = parseInt( $(a).data('prev_position') ); 843 var el_b_position = parseInt( $(b).data('prev_position') ); 844 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 845 }); 846 847 $( sorted ).show().appendTo( $prev_carousel_group ); 848 849 var left = 0; 850 $prev_carousel_group.children().each(function(){ 851 $(this).css({'position':'absolute', 'left': left }); 852 left = left + $(this).outerWidth(true); 853 }); 854 855 $active_carousel_group.animate({ 856 left: '100%' 857 }, {
858 duration: settings.slide_duration, 859 complete: function() { 860 $carousel_items.find('.delayed_container_append').reverse().each(function(){ 861 left = $( '#' + $(this).attr('id') + '-dup' ).css('left'); 862 $(this).css({'position':'absolute', 'left': left }); 863 $(this).prependTo( $prev_carousel_group ); 864 }); 865 866 $active_carousel_group.removeClass('active'); 867 $active_carousel_group.children().each(function(){ 868 position = $(this).data('position'); 869 current_position = $(this).data('current_position'); 870 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 871 $(this).data('position', ''); 872 $(this).data('current_position', ''); 873 $(this).hide(); 874 $(this).css({'position': '', 'left': ''}); 875 $(this).appendTo( $carousel_items ); 876 }); 877 878 $active_carousel_group.remove(); 879 } 880 } ); 881 882 prev_left = (-1) * $active_carousel_group.width() - parseInt( $the_carousel_items.first().css('marginRight').slice(0, -2) ); 883 $prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: prev_left }); 884 $prev_carousel_group.animate({ 885 left: '0%' 886 }, { 887 duration: settings.slide_duration, 888 complete: function(){ 889 $prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''}); 890 891 $prev_carousel_group.find('.delayed_container_append_dup').remove(); 892 893 $prev_carousel_group.find('.changing_position').each(function( index ){ 894 position = $(this).data('position'); 895 current_position = $(this).data('current_position'); 896 prev_position = $(this).data('prev_position'); 897 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position ); 898 $(this).data('current_position', ''); 899 $(this).data('prev_position', ''); 900 position = index + 1; 901 $(this).data('position', position ); 902 $(this).addClass('position_' + position ); 903 }); 904 905 $prev_carousel_group.children().css({'position': '', 'left': ''}); 906 $et_carousel.et_animation_running = false; 907 } 908 } ); 909 } 910 } 911 } 912 913 $.fn.et_pb_simple_carousel = function( options ) { 914 return this.each(function() { 915 new $.et_pb_simple_carousel(this, options); 916 }); 917 } 918 919 $(document).ready( function(){ 920 /** 921 * Provide event listener for plugins to hook up to 922 */ 923 $(window).trigger('et_pb_before_init_modules'); 924 925 var $et_pb_slider = $( '.et_pb_slider' ), 926 $et_pb_tabs = $( '.et_pb_tabs' ), 927 $et_pb_video_section = $('.et_pb_section_video_bg'), 928 $et_pb_newsletter_button = $( '.et_pb_newsletter_button' ), 929 $et_pb_filterable_portfolio = $( '.et_pb_filterable_portfolio' ), 930 $et_pb_fullwidth_portfolio = $( '.et_pb_fullwidth_portfolio' ), 931 $et_pb_gallery = $( '.et_pb_gallery' ), 932 $et_pb_countdown_timer = $( '.et_pb_countdown_timer' ), 933 $et_post_gallery = $( '.et_post_gallery' ), 934 $et_lightbox_image = $( '.et_pb_lightbox_image'), 935 $et_pb_map = $( '.et_pb_map_container' ), 936 $et_pb_circle_counter = $( '.et_pb_circle_counter' ), 937 $et_pb_number_counter = $( '.et_pb_number_counter' ), 938 $et_pb_parallax = $( '.et_parallax_bg' ), 939 $et_pb_shop = $( '.et_pb_shop' ), 940 $et_pb_post_fullwidth = $( '.single.et_pb_pagebuilder_layout.et_full_width_page' ), 941 et_is_mobile_device = navigator.userAgent.match( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/ ) !== null, 942 et_is_ipad = navigator.userAgent.match( /iPad/ ), 943 et_is_ie9 = navigator.userAgent.match( /MSIE 9.0/ ) !== null, 944 $et_container = ! et_pb_custom.is_builder_plugin_used ? $( '.container' ) : $( '.et_pb_row' ), 945 et_container_width = $et_container.width(), 946 et_is_fixed_nav = $( 'body' ).hasClass( 'et_fixed_nav' ), 947 et_is_vertical_nav = $( 'body' ).hasClass( 'et_vertical_nav' ), 948 et_is_vertical_fixed_nav = $( 'body' ).hasClass( 'et_vertical_fixed' ), 949 et_is_rtl = $( 'body' ).hasClass( 'rtl' ), 950 et_hide_nav = $( 'body' ).hasClass( 'et_hide_nav' ), 951 et_header_style_left = $( 'body' ).hasClass( 'et_header_style_left' ), 952 et_vertical_navigation = $( 'body' ).hasClass( 'et_vertical_nav' ), 953 $top_header = $('#top-header'), 954 $main_header = $('#main-header'), 955 $main_container_wrapper = $( '#page-container' ), 956 $et_transparent_nav = $( '.et_transparent_nav' ), 957 $et_pb_first_row = $( 'body.et_pb_pagebuilder_layout .et_pb_section:first-child' ), 958 $et_main_content_first_row = $( '#main-content .container:first-child' ), 959 $et_main_content_first_row_meta_wrapper = $et_main_content_first_row.find('.et_post_meta_wrapper:first'), 960 $et_main_content_first_row_meta_wrapper_title = $et_main_content_first_row_meta_wrapper.find( 'h1' ), 961 $et_main_content_first_row_content = $et_main_content_first_row.find('.entry-content:first'), 962 $et_single_post = $( 'body.single-post' ), 963 etRecalculateOffset = false, 964 et_header_height, 965 et_header_modifier, 966 et_header_offset, 967 et_primary_header_top, 968 $et_vertical_nav = $('.et_vertical_nav'), 969 $et_header_style_split = $('.et_header_style_split'), 970 $et_top_navigation = $('#et-top-navigation'), 971 $logo = $('#logo'), 972 $et_sticky_image = $('.et_pb_image_sticky'), 973 $et_pb_counter_amount = $('.et_pb_counter_amount'), 974 $et_pb_carousel = $( '.et_pb_carousel' ), 975 $et_menu_selector = et_pb_custom.is_divi_theme_used ? $( 'ul.nav' ) : $( '.et_pb_fullwidth_menu ul.nav' ), 976 et_pb_ab_bounce_rate = et_pb_custom.ab_bounce_rate * 1000, 977 et_pb_ab_logged_status = { 978 read_page: false, 979 read_goal: false, 980 view_goal: false, 981 click_goal: false, 982 con_goal: false, 983 con_short: false, 984 }; 985 986 window.et_pb_slider_init = function( $this_slider ) { 987 var et_slider_settings = { 988 fade_speed : 700, 989 slide : ! $this_slider.hasClass( 'et_pb_gallery' ) ? '.et_pb_slide' : '.et_pb_gallery_item' 990 } 991 992 if ( $this_slider.hasClass('et_pb_slider_no_arrows') ) 993 et_slider_settings.use_arrows = false;
994 995 if ( $this_slider.hasClass('et_pb_slider_no_pagination') ) 996 et_slider_settings.use_controls = false; 997 998 if ( $this_slider.hasClass('et_slider_auto') ) { 999 var et_slider_autospeed_class_value = /et_slider_speed_(\d+)/g; 1000 1001 et_slider_settings.slideshow = true; 1002 1003 et_slider_autospeed = et_slider_autospeed_class_value.exec( $this_slider.attr('class') ); 1004 1005 et_slider_settings.slideshow_speed = et_slider_autospeed === null ? 10 : et_slider_autospeed[1]; 1006 } 1007 1008 if ( $this_slider.parent().hasClass('et_pb_video_slider') ) { 1009 et_slider_settings.controls_below = true; 1010 et_slider_settings.append_controls_to = $this_slider.parent(); 1011 1012 setTimeout( function() { 1013 $( '.et_pb_preload' ).removeClass( 'et_pb_preload' ); 1014 }, 500 ); 1015 } 1016 1017 if ( $this_slider.hasClass('et_pb_slider_carousel') ) 1018 et_slider_settings.use_carousel = true; 1019 1020 $this_slider.et_pb_simple_slider( et_slider_settings ); 1021 } 1022 1023 var $et_top_menu = $et_menu_selector, 1024 et_parent_menu_longpress_limit = 300, 1025 et_parent_menu_longpress_start, 1026 et_parent_menu_click = true, 1027 is_frontend_builder = $('body').hasClass('et-fb'), 1028 et_menu_hover_triggered = false; 1029 1030 // log the conversion if visitor is on Thank You page and comes from the Shop module which is the Goal 1031 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' ) ) { 1032 var shop_log_data = et_pb_get_cookie_value( 'et_pb_ab_shop_log' ).split( '_' ); 1033 page_id = shop_log_data[0], 1034 subject_id = shop_log_data[1], 1035 test_id = shop_log_data[2]; 1036 1037 et_pb_ab_update_stats( 'con_goal', page_id, subject_id, test_id ); 1038 1039 // remove the cookie after conversion is logged 1040 et_pb_set_cookie( 0, 'et_pb_ab_shop_log=true' ); 1041 } 1042 1043 // log the conversion if visitor is on page with tracking shortcode 1044 if ( $( '.et_pb_ab_split_track' ).length ) { 1045 $( '.et_pb_ab_split_track' ).each( function() { 1046 var tracking_test = $( this ).data( 'test_id' ), 1047 cookies_name = 'et_pb_ab_shortcode_track_' + tracking_test; 1048 1049 if ( typeof et_pb_get_cookie_value( cookies_name ) !== 'undefined' && '' !== et_pb_get_cookie_value( cookies_name ) ) { 1050 var track_data = et_pb_get_cookie_value( cookies_name ).split( '_' ); 1051 page_id = track_data[0], 1052 subject_id = track_data[1], 1053 test_id = track_data[2]; 1054 1055 et_pb_ab_update_stats( 'con_short', page_id, subject_id, test_id ); 1056 1057 // remove the cookie after conversion is logged 1058 et_pb_set_cookie( 0, cookies_name + '=true' ); 1059 } 1060 }); 1061 } 1062 1063 // init split testing if enabled 1064 if ( et_pb_custom.is_ab_testing_active ) { 1065 et_pb_init_ab_test(); 1066 } 1067 1068 if ( $( '.et_pb_row' ).length ) { 1069 $( '.et_pb_row' ).each( function() { 1070 var $this_row = $( this ), 1071 row_class = ''; 1072 1073 row_class = et_get_column_types( $this_row.find( '>.et_pb_column' ) ); 1074 1075 if ( '' !== row_class && ( -1 !== row_class.indexOf( '1-4' ) || '_4col' === row_class ) ) { 1076 $this_row.addClass( 'et_pb_row' + row_class ); 1077 } 1078 1079 if ( $this_row.find( '.et_pb_row_inner' ).length ) { 1080 $this_row.find( '.et_pb_row_inner' ).each( function() { 1081 var $this_row_inner = $( this ); 1082 row_class = et_get_column_types( $this_row_inner.find( '.et_pb_column' ) ); 1083 1084 if ( '' !== row_class && -1 !== row_class.indexOf( '1-4' ) ) { 1085 $this_row_inner.addClass( 'et_pb_row' + row_class ); 1086 } 1087 }); 1088 } 1089 }); 1090 } 1091 1092 function et_get_column_types( $columns ) { 1093 var row_class = ''; 1094 1095 if ( $columns.length ) { 1096 $columns.each( function() { 1097 var $this_column = $( this ), 1098 column_type = $this_column.attr( 'class' ).split( 'et_pb_column_' )[1], 1099 column_type_clean = typeof column_type !== 'undefined' ? column_type.split( ' ', 1 )[0] : '4_4', 1100 column_type_updated = column_type_clean.replace( '_', '-' ).trim(); 1101 1102 row_class += '_' + column_type_updated; 1103 }); 1104 1105 row_class = '_1-4_1-4_1-4_1-4' === row_class ? '_4col' : row_class; 1106 } 1107 1108 return row_class; 1109 } 1110 1111 $et_top_menu.find( 'li' ).hover( function() { 1112 if ( ! $(this).closest( 'li.mega-menu' ).length || $(this).hasClass( 'mega-menu' ) ) { 1113 $(this).addClass( 'et-show-dropdown' ); 1114 $(this).removeClass( 'et-hover' ).addClass( 'et-hover' ); 1115 et_menu_hover_triggered = true; 1116 } 1117 }, function() { 1118 var $this_el = $(this); 1119 1120 $this_el.removeClass( 'et-show-dropdown' ).addClass( 'et-dropdown-removing' ); 1121 1122 et_menu_hover_triggered = false;
1123 1124 setTimeout( function() { 1125 if ( ! $this_el.hasClass( 'et-show-dropdown' ) ) { 1126 $this_el.removeClass( 'et-hover' ).removeClass( 'et-dropdown-removing' ); 1127 } 1128 }, 200 ); 1129 } ); 1130 1131 // Dropdown menu adjustment for touch screen 1132 $et_top_menu.find('.menu-item-has-children > a').on( 'touchstart', function(){ 1133 et_parent_menu_longpress_start = new Date().getTime(); 1134 } ).on( 'touchend', function(){ 1135 var et_parent_menu_longpress_end = new Date().getTime() 1136 if ( et_parent_menu_longpress_end >= et_parent_menu_longpress_start + et_parent_menu_longpress_limit ) { 1137 et_parent_menu_click = true; 1138 } else { 1139 et_parent_menu_click = false; 1140 1141 // Some devices emulate hover event on touch, so check that hover event was not triggered to avoid extra mouseleave event triggering 1142 if ( ! et_menu_hover_triggered ) { 1143 // Close sub-menu if toggled 1144 var $et_parent_menu = $(this).parent('li'); 1145 if ( $et_parent_menu.hasClass( 'et-hover') ) { 1146 $et_parent_menu.trigger( 'mouseleave' ); 1147 } else { 1148 $et_parent_menu.trigger( 'mouseenter' ); 1149 } 1150 } 1151 } 1152 et_parent_menu_longpress_start = 0; 1153 } ).click(function() { 1154 if ( et_parent_menu_click ) { 1155 return true; 1156 } 1157 1158 return false; 1159 } ); 1160 1161 $et_top_menu.find( 'li.mega-menu' ).each(function(){ 1162 var $li_mega_menu = $(this), 1163 $li_mega_menu_item = $li_mega_menu.children( 'ul' ).children( 'li' ), 1164 li_mega_menu_item_count = $li_mega_menu_item.length; 1165 1166 if ( li_mega_menu_item_count < 4 ) { 1167 $li_mega_menu.addClass( 'mega-menu-parent mega-menu-parent-' + li_mega_menu_item_count ); 1168 } 1169 }); 1170 1171 $et_sticky_image.each( function() { 1172 var $this_el = $(this), 1173 $row = $this_el.closest('.et_pb_row'), 1174 $section = $row.closest('.et_pb_section'), 1175 $column = $this_el.closest( '.et_pb_column' ), 1176 sticky_class = 'et_pb_section_sticky', 1177 sticky_mobile_class = 'et_pb_section_sticky_mobile'; 1178 1179 // If it is not in the last row, continue 1180 if ( ! $row.is( ':last-child' ) ) { 1181 return true; 1182 } 1183 1184 // Make sure sticky image is the last element in the column 1185 if ( ! $this_el.is( ':last-child' ) ) { 1186 return true; 1187 } 1188 1189 // If it is in the last row, find the parent section and attach new class to it 1190 if ( ! $section.hasClass( sticky_class ) ) { 1191 $section.addClass( sticky_class ); 1192 } 1193 1194 $column.addClass( 'et_pb_row_sticky' ); 1195 1196 if ( ! $section.hasClass( sticky_mobile_class ) && $column.is( ':last-child' ) ) { 1197 $section.addClass( sticky_mobile_class ); 1198 } 1199 } ); 1200 1201 if ( et_is_mobile_device ) { 1202 $( '.et_pb_section_video_bg' ).each( function() { 1203 var $this_el = $(this); 1204 1205 $this_el.closest( '.et_pb_preload' ).removeClass( 'et_pb_preload' ) 1206 1207 $this_el.remove(); 1208 } ); 1209 1210 $( 'body' ).addClass( 'et_mobile_device' ); 1211 1212 if ( ! et_is_ipad ) { 1213 $( 'body' ).addClass( 'et_mobile_device_not_ipad' ); 1214 } 1215 } 1216 1217 if ( et_is_ie9 ) { 1218 $( 'body' ).addClass( 'et_ie9' ); 1219 } 1220 1221 if ( $et_pb_video_section.length || is_frontend_builder ) { 1222 window.et_pb_video_section_init = function( $et_pb_video_section ) { 1223 $et_pb_video_section.find( 'video' ).mediaelementplayer( { 1224 pauseOtherPlayers: false, 1225 success : function( mediaElement, domObject ) { 1226 mediaElement.addEventListener( 'loadeddata', function() { 1227 et_pb_resize_section_video_bg( $(domObject) ); 1228 et_pb_center_video( $(domObject) ); 1229 }, false ); 1230 1231 mediaElement.addEventListener( 'canplay', function() { 1232 $(domObject).closest( '.et_pb_preload' ).removeClass( 'et_pb_preload' ); 1233 }, false ); 1234 } 1235 } ); 1236 } 1237 et_pb_video_section_init( $et_pb_video_section ); 1238 } 1239 1240 if ( $et_post_gallery.length ) { 1241 // swipe support in magnific popup only if gallery exists 1242 var magnificPopup = $.magnificPopup.instance; 1243 1244 $( 'body' ).on( 'swiperight', '.mfp-container', function() { 1245 magnificPopup.prev(); 1246 } ); 1247 $( 'body' ).on( 'swipeleft', '.mfp-container', function() { 1248 magnificPopup.next(); 1249 } ); 1250 1251 $et_post_gallery.each(function() { 1252 $(this).magnificPopup( { 1253 delegate: '.et_pb_gallery_image a', 1254 type: 'image', 1255 removalDelay: 500, 1256 gallery: { 1257 enabled: true, 1258 navigateByImgClick: true 1259 }, 1260 mainClass: 'mfp-fade', 1261 zoom: { 1262 enabled: true, 1263 duration: 500, 1264 opener: function(element) { 1265 return element.find('img'); 1266 } 1267 } 1268 } ); 1269 } ); 1270 // prevent attaching of any further actions on click 1271 $et_post_gallery.find( 'a' ).unbind( 'click' ); 1272 } 1273 1274 if ( $et_lightbox_image.length || is_frontend_builder ) { 1275 // prevent attaching of any further actions on click 1276 $et_lightbox_image.unbind( 'click' ); 1277 $et_lightbox_image.bind( 'click' ); 1278 1279 window.et_pb_image_lightbox_init = function( $et_lightbox_image ) { 1280 $et_lightbox_image.magnificPopup( { 1281 type: 'image', 1282 removalDelay: 500, 1283 mainClass: 'mfp-fade', 1284 zoom: { 1285 enabled: true, 1286 duration: 500, 1287 opener: function(element) { 1288 return element.find('img'); 1289 } 1290 } 1291 } ); 1292 } 1293 1294 et_pb_image_lightbox_init( $et_lightbox_image ); 1295 } 1296 1297 if ( $et_pb_slider.length || is_frontend_builder ) { 1298 $et_pb_slider.each( function() { 1299 $this_slider = $(this); 1300 1301 et_pb_slider_init( $this_slider ); 1302 } ); 1303 } 1304 1305 $et_pb_carousel = $( '.et_pb_carousel' ); 1306 if ( $et_pb_carousel.length || is_frontend_builder ) { 1307 $et_pb_carousel.each( function() { 1308 var $this_carousel = $(this), 1309 et_carousel_settings = { 1310 fade_speed : 1000 1311 }; 1312 1313 $this_carousel.et_pb_simple_carousel( et_carousel_settings ); 1314 } ); 1315 } 1316 1317 if ( $et_pb_fullwidth_portfolio.length || is_frontend_builder ) { 1318 1319 window.et_fullwidth_portfolio_init = function( $the_portfolio ) { 1320 var $portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'); 1321 1322 $portfolio_items.data('items', $portfolio_items.find('.et_pb_portfolio_item').toArray() ); 1323 $the_portfolio.data('columns_setting_up', false ); 1324 1325 if ( $the_portfolio.hasClass('et_pb_fullwidth_portfolio_carousel') ) { 1326 // add left and right arrows 1327 $portfolio_items.prepend('<div class="et-pb-slider-arrows"><a class="et-pb-arrow-prev" href="#">
1327' + '<span>' + et_pb_custom.previous + '</span>' + '</a><a class="et-pb-arrow-next" href="#">' + '<span>' + et_pb_custom.next + '</span>' + '</a></div>'); 1328 1329 set_fullwidth_portfolio_columns( $the_portfolio, true ); 1330 1331 et_carousel_auto_rotate( $the_portfolio ); 1332 1333 // swipe support 1334 $the_portfolio.on( 'swiperight', function() { 1335 $( this ).find( '.et-pb-arrow-prev' ).click(); 1336 }); 1337 $the_portfolio.on( 'swipeleft', function() { 1338 $( this ).find( '.et-pb-arrow-next' ).click(); 1339 }); 1340 1341 $the_portfolio.hover( 1342 function(){ 1343 $(this).addClass('et_carousel_hovered'); 1344 if ( typeof $(this).data('et_carousel_timer') != 'undefined' ) { 1345 clearInterval( $(this).data('et_carousel_timer') ); 1346 } 1347 }, 1348 function(){ 1349 $(this).removeClass('et_carousel_hovered'); 1350 et_carousel_auto_rotate( $(this) ); 1351 } 1352 ); 1353 1354 $the_portfolio.data('carouseling', false ); 1355 1356 $the_portfolio.on('click', '.et-pb-slider-arrows a', function(e){ 1357 fullwidth_portfolio_carousel_slide( $( this) ); 1358 e.preventDefault(); 1359 return false; 1360 }); 1361 1362 } else { 1363 // setup fullwidth portfolio grid 1364 set_fullwidth_portfolio_columns( $the_portfolio, false ); 1365 } 1366 } 1367 1368 function fullwidth_portfolio_carousel_slide( $arrow ) { 1369 var $the_portfolio = $arrow.parents('.et_pb_fullwidth_portfolio'), 1370 $portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'), 1371 $the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'), 1372 $active_carousel_group = $portfolio_items.find('.et_pb_carousel_group.active'), 1373 slide_duration = 700, 1374 items = $portfolio_items.data('items'), 1375 columns = $portfolio_items.data('portfolio-columns'), 1376 item_width = $active_carousel_group.innerWidth() / columns, //$active_carousel_group.children().first().innerWidth(), 1377 original_item_width = ( 100 / columns ) + '%'; 1378 1379 if ( 'undefined' == typeof items ) { 1380 return; 1381 } 1382 1383 if ( $the_portfolio.data('carouseling') ) { 1384 return; 1385 } 1386 1387 $the_portfolio.data('carouseling', true); 1388 1389 $active_carousel_group.children().each(function(){ 1390 $(this).css({'width': $(this).innerWidth() + 1, 'position':'absolute', 'left': ( $(this).innerWidth() * ( $(this).data('position') - 1 ) ) }); 1391 }); 1392 1393 if ( $arrow.hasClass('et-pb-arrow-next') ) { 1394 var $next_carousel_group, 1395 current_position = 1, 1396 next_position = 1, 1397 active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ), 1398 active_items_end = active_items_start + columns, 1399 next_items_start = active_items_end, 1400 next_items_end = next_items_start + columns; 1401 1402 $next_carousel_group = $('<div class="et_pb_carousel_group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group ); 1403 $next_carousel_group.css({ 'width': $active_carousel_group.innerWidth() }).show(); 1404 1405 // this is an endless loop, so it can decide internally when to break out, so that next_position 1406 // can get filled up, even to the extent of an element having both and current_ and next_ position 1407 for( x = 0, total = 0 ; ; x++, total++ ) { 1408 if ( total >= active_items_start && total < active_items_end ) { 1409 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 1410 $( items[x] ).data('current_position', current_position ); 1411 current_position++; 1412 } 1413 1414 if ( total >= next_items_start && total < next_items_end ) { 1415 $( items[x] ).data('next_position', next_position ); 1416 $( items[x] ).addClass('changing_position next_position next_position_' + next_position ); 1417 1418 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 1419 $( items[x] ).addClass('container_append'); 1420 } else { 1421 $( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 1422 $( items[x] ).addClass('delayed_container_append'); 1423 } 1424 1425 next_position++; 1426 } 1427 1428 if ( next_position > columns ) { 1429 break; 1430 } 1431 1432 if ( x >= ( items.length -1 )) { 1433 x = -1; 1434 } 1435 } 1436 1437 sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 1438 var el_a_position = parseInt( $(a).data('next_position') ); 1439 var el_b_position = parseInt( $(b).data('next_position') ); 1440 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 1441 }); 1442 1443 $( sorted ).show().appendTo( $next_carousel_group ); 1444 1445 $next_carousel_group.children().each(function(){ 1446 $(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) }); 1447 }); 1448 1449 $active_carousel_group.animate({ 1450 left: '-100%' 1451 }, {
1452 duration: slide_duration, 1453 complete: function() { 1454 $portfolio_items.find('.delayed_container_append').each(function(){ 1455 $(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) }); 1456 $(this).appendTo( $next_carousel_group ); 1457 }); 1458 1459 $active_carousel_group.removeClass('active'); 1460 $active_carousel_group.children().each(function(){ 1461 position = $(this).data('position'); 1462 current_position = $(this).data('current_position'); 1463 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 1464 $(this).data('position', ''); 1465 $(this).data('current_position', ''); 1466 $(this).hide(); 1467 $(this).css({'position': '', 'width': '', 'left': ''}); 1468 $(this).appendTo( $portfolio_items ); 1469 }); 1470 1471 $active_carousel_group.remove(); 1472 1473 et_carousel_auto_rotate( $the_portfolio ); 1474 1475 } 1476 } ); 1477 1478 $next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '100%'}); 1479 $next_carousel_group.animate({ 1480 left: '0%' 1481 }, { 1482 duration: slide_duration, 1483 complete: function(){ 1484 setTimeout(function(){ 1485 $next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''}); 1486 1487 $next_carousel_group.find('.delayed_container_append_dup').remove(); 1488 1489 $next_carousel_group.find('.changing_position').each(function( index ){ 1490 position = $(this).data('position'); 1491 current_position = $(this).data('current_position'); 1492 next_position = $(this).data('next_position'); 1493 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position ); 1494 $(this).data('current_position', ''); 1495 $(this).data('next_position', ''); 1496 $(this).data('position', ( index + 1 ) ); 1497 }); 1498 1499 $next_carousel_group.children().css({'position': '', 'width': original_item_width, 'left': ''}); 1500 1501 $the_portfolio.data('carouseling', false); 1502 }, 100 ); 1503 } 1504 } ); 1505 1506 } else { 1507 var $prev_carousel_group, 1508 current_position = columns, 1509 prev_position = columns, 1510 columns_span = columns - 1, 1511 active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ), 1512 active_items_end = active_items_start - columns_span, 1513 prev_items_start = active_items_end - 1, 1514 prev_items_end = prev_items_start - columns_span; 1515 1516 $prev_carousel_group = $('<div class="et_pb_carousel_group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group ); 1517 $prev_carousel_group.css({ 'left': '-' + $active_carousel_group.innerWidth(), 'width': $active_carousel_group.innerWidth() }).show(); 1518 1519 // this is an endless loop, so it can decide internally when to break out, so that next_position 1520 // can get filled up, even to the extent of an element having both and current_ and next_ position 1521 for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) { 1522 1523 if ( total <= active_items_start && total >= active_items_end ) { 1524 $( items[x] ).addClass( 'changing_position current_position current_position_' + current_position ); 1525 $( items[x] ).data('current_position', current_position ); 1526 current_position--; 1527 } 1528 1529 if ( total <= prev_items_start && total >= prev_items_end ) { 1530 $( items[x] ).data('prev_position', prev_position ); 1531 $( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position ); 1532 1533 if ( !$( items[x] ).hasClass( 'current_position' ) ) { 1534 $( items[x] ).addClass('container_append'); 1535 } else { 1536 $( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' ); 1537 $( items[x] ).addClass('delayed_container_append'); 1538 } 1539 1540 prev_position--; 1541 } 1542 1543 if ( prev_position <= 0 ) { 1544 break; 1545 } 1546 1547 if ( x == 0 ) { 1548 x = items.length; 1549 } 1550 } 1551 1552 sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) { 1553 var el_a_position = parseInt( $(a).data('prev_position') ); 1554 var el_b_position = parseInt( $(b).data('prev_position') ); 1555 return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0; 1556 }); 1557 1558 $( sorted ).show().appendTo( $prev_carousel_group ); 1559 1560 $prev_carousel_group.children().each(function(){ 1561 $(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) }); 1562 }); 1563 1564 $active_carousel_group.animate({ 1565 left: '100%' 1566 }, {
1567 duration: slide_duration, 1568 complete: function() { 1569 $portfolio_items.find('.delayed_container_append').reverse().each(function(){ 1570 $(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) }); 1571 $(this).prependTo( $prev_carousel_group ); 1572 }); 1573 1574 $active_carousel_group.removeClass('active'); 1575 $active_carousel_group.children().each(function(){ 1576 position = $(this).data('position'); 1577 current_position = $(this).data('current_position'); 1578 $(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position ); 1579 $(this).data('position', ''); 1580 $(this).data('current_position', ''); 1581 $(this).hide(); 1582 $(this).css({'position': '', 'width': '', 'left': ''}); 1583 $(this).appendTo( $portfolio_items ); 1584 }); 1585 1586 $active_carousel_group.remove(); 1587 } 1588 } ); 1589 1590 $prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '-100%'}); 1591 $prev_carousel_group.animate({ 1592 left: '0%' 1593 }, { 1594 duration: slide_duration, 1595 complete: function(){ 1596 setTimeout(function(){ 1597 $prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''}); 1598 1599 $prev_carousel_group.find('.delayed_container_append_dup').remove(); 1600 1601 $prev_carousel_group.find('.changing_position').each(function( index ){ 1602 position = $(this).data('position'); 1603 current_position = $(this).data('current_position'); 1604 prev_position = $(this).data('prev_position'); 1605 $(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position ); 1606 $(this).data('current_position', ''); 1607 $(this).data('prev_position', ''); 1608 position = index + 1; 1609 $(this).data('position', position ); 1610 $(this).addClass('position_' + position ); 1611 }); 1612 1613 $prev_carousel_group.children().css({'position': '', 'width': original_item_width, 'left': ''}); 1614 $the_portfolio.data('carouseling', false); 1615 }, 100 ); 1616 } 1617 } ); 1618 } 1619 } 1620 1621 function set_fullwidth_portfolio_columns( $the_portfolio, carousel_mode ) { 1622 var columns, 1623 $portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'), 1624 portfolio_items_width = $portfolio_items.width(), 1625 $the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'), 1626 portfolio_item_count = $the_portfolio_items.length; 1627 1628 if ('undefined' === typeof $the_portfolio_items) { 1629 return; 1630 } 1631 1632 // calculate column breakpoints 1633 if ( portfolio_items_width >= 1600 ) { 1634 columns = 5; 1635 } else if ( portfolio_items_width >= 1024 ) { 1636 columns = 4; 1637 } else if ( portfolio_items_width >= 768 ) { 1638 columns = 3; 1639 } else if ( portfolio_items_width >= 480 ) { 1640 columns = 2; 1641 } else { 1642 columns = 1; 1643 } 1644 1645 // set height of items 1646 portfolio_item_width = portfolio_items_width / columns;
1647 portfolio_item_height = portfolio_item_width * .75; 1648 1649 if ( carousel_mode ) { 1650 $portfolio_items.css({ 'height' : portfolio_item_height }); 1651 } 1652 1653 $the_portfolio_items.css({ 'height' : portfolio_item_height }); 1654 1655 if ( columns === $portfolio_items.data('portfolio-columns') ) { 1656 return; 1657 } 1658 1659 if ( $the_portfolio.data('columns_setting_up') ) { 1660 return; 1661 } 1662 1663 $the_portfolio.data('columns_setting_up', true ); 1664 1665 var portfolio_item_width_percentage = ( 100 / columns ) + '%'; 1666 $the_portfolio_items.css({ 'width' : portfolio_item_width_percentage }); 1667 1668 // store last setup column 1669 $portfolio_items.removeClass('columns-' + $portfolio_items.data('portfolio-columns') ); 1670 $portfolio_items.addClass('columns-' + columns ); 1671 $portfolio_items.data('portfolio-columns', columns ); 1672 1673 if ( !carousel_mode ) { 1674 return $the_portfolio.data('columns_setting_up', false ); 1675 } 1676 1677 // kill all previous groups to get ready to re-group 1678 if ( $portfolio_items.find('.et_pb_carousel_group').length ) { 1679 $the_portfolio_items.appendTo( $portfolio_items ); 1680 $portfolio_items.find('.et_pb_carousel_group').remove(); 1681 } 1682 1683 // setup the grouping 1684 var the_portfolio_items = $portfolio_items.data('items' ), 1685 $carousel_group = $('<div class="et_pb_carousel_group active">').appendTo( $portfolio_items ); 1686 1687 if ('undefined' === typeof the_portfolio_items) { 1688 return; 1689 } 1690 1691 $the_portfolio_items.data('position', ''); 1692 if ( the_portfolio_items.length <= columns ) { 1693 $portfolio_items.find('.et-pb-slider-arrows').hide(); 1694 } else { 1695 $portfolio_items.find('.et-pb-slider-arrows').show(); 1696 } 1697 1698 for ( position = 1, x=0 ;x < the_portfolio_items.length; x++, position++ ) { 1699 if ( x < columns ) { 1700 $( the_portfolio_items[x] ).show(); 1701 $( the_portfolio_items[x] ).appendTo( $carousel_group ); 1702 $( the_portfolio_items[x] ).data('position', position ); 1703 $( the_portfolio_items[x] ).addClass('position_' + position ); 1704 } else { 1705 position = $( the_portfolio_items[x] ).data('position'); 1706 $( the_portfolio_items[x] ).removeClass('position_' + position ); 1707 $( the_portfolio_items[x] ).data('position', '' ); 1708 $( the_portfolio_items[x] ).hide(); 1709 } 1710 } 1711 1712 $the_portfolio.data('columns_setting_up', false ); 1713 1714 } 1715 1716 function et_carousel_auto_rotate( $carousel ) { 1717 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' ) ) { 1718 1719 et_carousel_timer = setTimeout( function() { 1720 fullwidth_portfolio_carousel_slide( $carousel.find('.et-pb-arrow-next') ); 1721 }, $carousel.data('auto-rotate-speed') ); 1722 1723 $carousel.data('et_carousel_timer', et_carousel_timer); 1724 } 1725 } 1726 1727 $et_pb_fullwidth_portfolio.each(function(){ 1728 et_fullwidth_portfolio_init( $(this) ); 1729 }); 1730 } 1731 1732 function et_audio_module_set() { 1733 if ( $( '.et_pb_audio_module .mejs-audio' ).length || $( '.et_audio_content .mejs-audio' ).length ) { 1734 $( '.et_audio_container' ).each( function(){ 1735 et_pb_audio_module_init( $(this) ); 1736 }); 1737 } 1738 } 1739 1740 window.et_pb_audio_module_init = function( $audio_container ) { 1741 var $this_player = $audio_container, 1742 $time_rail = $this_player.find( '.mejs-time-rail' ), 1743 $time_slider = $this_player.find( '.mejs-time-slider' ); 1744 // remove previously added width and min-width attributes to calculate the new sizes accurately 1745 $time_rail.removeAttr( 'style' ); 1746 $time_slider.removeAttr( 'style' ); 1747 1748 var $count_timer = $this_player.find( 'div.mejs-currenttime-container' ), 1749 player_width = $this_player.width(), 1750 controls_play_width = $this_player.find( '.mejs-play' ).outerWidth(), 1751 time_width = $this_player.find( '.mejs-currenttime-container' ).outerWidth(), 1752 volume_icon_width = $this_player.find( '.mejs-volume-button' ).outerWidth(), 1753 volume_bar_width = $this_player.find( '.mejs-horizontal-volume-slider' ).outerWidth(), 1754 new_time_rail_width; 1755 1756 $count_timer.addClass( 'custom' ); 1757 $this_player.find( '.mejs-controls div.mejs-duration-container' ).replaceWith( $count_timer ); 1758 new_time_rail_width = player_width - ( controls_play_width + time_width + volume_icon_width + volume_bar_width + 65 ); 1759 1760 if ( 0 < new_time_rail_width ) { 1761 $time_rail.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' ); 1762 $time_slider.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' ); 1763 } 1764 } 1765 1766 if ( $('.et_pb_section_video').length ) { 1767 window._wpmejsSettings.pauseOtherPlayers = false;
1768 } 1769 1770 if ( $et_pb_filterable_portfolio.length || is_frontend_builder ) { 1771 1772 window.et_pb_filterable_portfolio_init = function( $selector ) { 1773 if ( typeof $selector !== 'undefined' ){ 1774 set_filterable_portfolio_init( $selector ); 1775 } else { 1776 $et_pb_filterable_portfolio.each(function(){ 1777 set_filterable_portfolio_init( $(this) ) 1778 }); 1779 } 1780 } 1781 1782 window.set_filterable_portfolio_init = function( $the_portfolio ) { 1783 var $the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'), 1784 $left_orientatation = true == $the_portfolio.data( 'rtl' ) ? false : true; 1785 1786 $the_portfolio.show(); 1787 1788 set_filterable_grid_items( $the_portfolio ); 1789 1790 $the_portfolio.on('click', '.et_pb_portfolio_filter a', function(e){ 1791 e.preventDefault(); 1792 var category_slug = $(this).data('category-slug'); 1793 $the_portfolio_items = $(this).parents('.et_pb_filterable_portfolio').find('.et_pb_portfolio_items'); 1794 1795 if ( 'all' == category_slug ) { 1796 $the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active'); 1797 $the_portfolio.find('.et_pb_portfolio_filter_all a').addClass('active'); 1798 $the_portfolio.find('.et_pb_portfolio_item').removeClass('active inactive'); 1799 $the_portfolio.find('.et_pb_portfolio_item').show(); 1800 $the_portfolio.find('.et_pb_portfolio_item').addClass('active'); 1801 } else { 1802 $the_portfolio.find('.et_pb_portfolio_filter_all').removeClass('active'); 1803 $the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active'); 1804 $the_portfolio.find('.et_pb_portfolio_filter_all a').removeClass('active'); 1805 $(this).addClass('active'); 1806 1807 $the_portfolio_items.find('.et_pb_portfolio_item').hide(); 1808 $the_portfolio_items.find('.et_pb_portfolio_item').addClass( 'inactive' ); 1809 $the_portfolio_items.find('.et_pb_portfolio_item').removeClass('active'); 1810 $the_portfolio_items.find('.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).show(); 1811 $the_portfolio_items.find('.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).addClass('active').removeClass( 'inactive' ); 1812 } 1813 1814 set_filterable_grid_items( $the_portfolio ); 1815 setTimeout(function(){ 1816 set_filterable_portfolio_hash( $the_portfolio ); 1817 }, 500 ); 1818 }); 1819 1820 $the_portfolio.on('click', '.et_pb_portofolio_pagination a', function(e){ 1821 e.preventDefault(); 1822 1823 var to_page = $(this).data('page'), 1824 $the_portfolio = $(this).parents('.et_pb_filterable_portfolio'), 1825 $the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'); 1826 1827 et_pb_smooth_scroll( $the_portfolio, false, 800 ); 1828 1829 if ( $(this).hasClass('page-prev') ) { 1830 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1; 1831 } else if ( $(this).hasClass('page-next') ) { 1832 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1; 1833 } 1834 1835 $(this).parents('ul').find('a').removeClass('active'); 1836 $(this).parents('ul').find('a.page-' + to_page ).addClass('active'); 1837 1838 var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(), 1839 total_pages = $(this).parents('ul').find('li.page').length; 1840 1841 $(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show(); 1842 $(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show(); 1843 1844 $(this).parents('ul').find('li.page').each(function(i){ 1845 if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) { 1846 if ( i < ( current_index - 3 ) ) { 1847 $(this).hide(); 1848 } else if ( i > ( current_index + 1 ) ) { 1849 $(this).hide(); 1850 } else { 1851 $(this).show(); 1852 } 1853 1854 if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) { 1855 $(this).show(); 1856 } else if ( current_index <= 3 && i <= 4 ) { 1857 $(this).show(); 1858 } 1859 1860 } 1861 }); 1862 1863 if ( to_page > 1 ) { 1864 $(this).parents('ul').find('li.prev').show(); 1865 } else { 1866 $(this).parents('ul').find('li.prev').hide(); 1867 } 1868 1869 if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) { 1870 $(this).parents('ul').find('li.next').hide(); 1871 } else { 1872 $(this).parents('ul').find('li.next').show(); 1873 } 1874 1875 $the_portfolio.find('.et_pb_portfolio_item').hide(); 1876 $the_portfolio.find('.et_pb_portfolio_item').filter(function( index ) { 1877 return $(this).data('page') === to_page; 1878 }).show(); 1879 1880 setTimeout(function(){ 1881 set_filterable_portfolio_hash( $the_portfolio ); 1882 }, 500 ); 1883 }); 1884 1885 $(this).on('et_hashchange', function( event ){ 1886 var params = event.params; 1887 $the_portfolio = $( '#' + event.target.id ); 1888 1889 if ( !$the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').hasClass('active') ) { 1890 $the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').click(); 1891 } 1892 1893 if ( params[1] ) { 1894 setTimeout(function(){ 1895 if ( !$the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).hasClass('active') ) { 1896 $the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).addClass('active').click(); 1897 } 1898 }, 300 ); 1899 } 1900 }); 1901 } 1902 1903 // init portfolio if .load event was fired already, wait for the window load otherwise. 1904 if ( window.et_load_event_fired ) { 1905 et_pb_filterable_portfolio_init(); 1906 } else { 1907 $(window).load(function(){ 1908 et_pb_filterable_portfolio_init(); 1909 }); // End $(window).load() 1910 } 1911 1912 function set_filterable_grid_items( $the_portfolio ) { 1913 var active_category = $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug'), 1914 container_width = $the_portfolio.find( '.et_pb_portfolio_items' ).innerWidth(), 1915 item_width = $the_portfolio.find( '.et_pb_portfolio_item' ).outerWidth( true ), 1916 last_item_margin = item_width - $the_portfolio.find( '.et_pb_portfolio_item' ).outerWidth(), 1917 columns_count = Math.round( ( container_width + last_item_margin ) / item_width ), 1918 counter = 1, 1919 first_in_row = 1; 1920 1921 $the_portfolio.find( '.et_pb_portfolio_item' ).removeClass( 'last_in_row first_in_row' ); 1922 $the_portfolio.find( '.et_pb_portfolio_item' ).each( function() { 1923 var $this_el = $( this ); 1924 1925 if ( ! $this_el.hasClass( 'inactive' ) ) { 1926 if ( first_in_row === counter ) { 1927 $this_el.addClass( 'first_in_row' ); 1928 } 1929 1930 if ( 0 === counter % columns_count ) { 1931 $this_el.addClass( 'last_in_row' ); 1932 first_in_row = counter + 1; 1933 } 1934 counter++; 1935 } 1936 }); 1937 1938 if ( 'all' === active_category ) { 1939 $the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item'); 1940 } else { 1941 $the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item.project_category_' + active_category); 1942 } 1943 1944 var visible_grid_items = $the_portfolio_visible_items.length, 1945 posts_number = $the_portfolio.data('posts-number'), 1946 pages = Math.ceil( visible_grid_items / posts_number ); 1947 1948 set_filterable_grid_pages( $the_portfolio, pages ); 1949 1950 var visible_grid_items = 0; 1951 var _page = 1; 1952 $the_portfolio.find('.et_pb_portfolio_item').data('page', ''); 1953 $the_portfolio_visible_items.each(function(i){ 1954 visible_grid_items++; 1955 if ( 0 === parseInt( visible_grid_items % posts_number ) ) { 1956 $(this).data('page', _page); 1957 _page++; 1958 } else { 1959 $(this).data('page', _page); 1960 } 1961 }); 1962 1963 $the_portfolio_visible_items.filter(function() { 1964 return $(this).data('page') == 1; 1965 }).show(); 1966 1967 $the_portfolio_visible_items.filter(function() { 1968 return $(this).data('page') != 1; 1969 }).hide(); 1970 } 1971 1972 function set_filterable_grid_pages( $the_portfolio, pages ) { 1973 $pagination = $the_portfolio.find('.et_pb_portofolio_pagination'); 1974 1975 if ( !$pagination.length ) { 1976 return; 1977 } 1978 1979 $pagination.html('<ul></ul>'); 1980 if ( pages <= 1 ) { 1981 return; 1982 } 1983 1984 $pagination_list = $pagination.children('ul'); 1985 $pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + et_pb_custom.prev + '</a></li>'); 1986 for( var page = 1; page <= pages; page++ ) { 1987 var first_page_class = page === 1 ? ' active' : '', 1988 last_page_class = page === pages ? ' last-page' : '', 1989 hidden_page_class = page >= 5 ? ' style="display:none;"' : ''; 1990 $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>'); 1991 } 1992 $pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + et_pb_custom.next + '</a></li>'); 1993 } 1994 1995 function set_filterable_portfolio_hash( $the_portfolio ) { 1996 1997 if ( !$the_portfolio.attr('id') ) { 1998 return; 1999 } 2000 2001 var this_portfolio_state = []; 2002 this_portfolio_state.push( $the_portfolio.attr('id') ); 2003 this_portfolio_state.push( $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug') ); 2004 2005 if ( $the_portfolio.find('.et_pb_portofolio_pagination a.active').length ) { 2006 this_portfolio_state.push( $the_portfolio.find('.et_pb_portofolio_pagination a.active').data('page') ); 2007 } else { 2008 this_portfolio_state.push( 1 ); 2009 } 2010 2011 this_portfolio_state = this_portfolio_state.join( et_hash_module_param_seperator ); 2012 2013 et_set_hash( this_portfolio_state ); 2014 } 2015 } /* end if ( $et_pb_filterable_portfolio.length ) */ 2016 2017 if ( $et_pb_gallery.length || is_frontend_builder ) { 2018 2019 window.set_gallery_grid_items = function( $the_gallery ) { 2020 var $the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'), 2021 $the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item'); 2022 2023 var total_grid_items = $the_gallery_items.length, 2024 posts_number = $the_gallery_items_container.attr('data-per_page'), 2025 pages = Math.ceil( total_grid_items / posts_number ); 2026 2027 set_gallery_grid_pages( $the_gallery, pages ); 2028 2029 var total_grid_items = 0; 2030 var _page = 1; 2031 $the_gallery_items.data('page', ''); 2032 $the_gallery_items.each(function(i){ 2033 total_grid_items++; 2034 if ( 0 === parseInt( total_grid_items % posts_number ) ) { 2035 $(this).data('page', _page); 2036 _page++; 2037 } else { 2038 $(this).data('page', _page); 2039 } 2040 2041 }); 2042 2043 var visible_items = $the_gallery_items.filter(function() { 2044 return $(this).data('page') == 1; 2045 }).show(); 2046 2047 $the_gallery_items.filter(function() { 2048 return $(this).data('page') != 1; 2049 }).hide(); 2050 } 2051 2052 window.set_gallery_grid_pages = function( $the_gallery, pages ) { 2053 $pagination = $the_gallery.find('.et_pb_gallery_pagination'); 2054 2055 if ( !$pagination.length ) { 2056 return; 2057 } 2058 2059 $pagination.html('<ul></ul>'); 2060 if ( pages <= 1 ) { 2061 $pagination.hide(); 2062 return; 2063 } 2064 2065 $pagination_list = $pagination.children('ul'); 2066 $pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + et_pb_custom.prev + '</a></li>'); 2067 for( var page = 1; page <= pages; page++ ) { 2068 var first_page_class = page === 1 ? ' active' : '', 2069 last_page_class = page === pages ? ' last-page' : '', 2070 hidden_page_class = page >= 5 ? ' style="display:none;"' : ''; 2071 $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>'); 2072 } 2073 $pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + et_pb_custom.next + '</a></li>'); 2074 } 2075 2076 window.set_gallery_hash = function( $the_gallery ) { 2077 2078 if ( !$the_gallery.attr('id') ) { 2079 return; 2080 } 2081 2082 var this_gallery_state = []; 2083 this_gallery_state.push( $the_gallery.attr('id') ); 2084 2085 if ( $the_gallery.find('.et_pb_gallery_pagination a.active').length ) { 2086 this_gallery_state.push( $the_gallery.find('.et_pb_gallery_pagination a.active').data('page') ); 2087 } else { 2088 this_gallery_state.push( 1 ); 2089 } 2090 2091 this_gallery_state = this_gallery_state.join( et_hash_module_param_seperator ); 2092 2093 et_set_hash( this_gallery_state ); 2094 } 2095 2096 window.et_pb_gallery_init = function( $the_gallery ) { 2097 if ( $the_gallery.hasClass( 'et_pb_gallery_grid' ) ) { 2098 2099 $the_gallery.show(); 2100 set_gallery_grid_items( $the_gallery ); 2101 2102 $the_gallery.on('et_hashchange', function( event ){ 2103 var params = event.params; 2104 $the_gallery = $( '#' + event.target.id ); 2105 2106 if ( page_to = params[0] ) { 2107 if ( !$the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).hasClass('active') ) { 2108 $the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).addClass('active').click(); 2109 } 2110 } 2111 }); 2112 } 2113 } 2114 2115 $et_pb_gallery.each(function(){ 2116 var $the_gallery = $(this); 2117 2118 et_pb_gallery_init( $the_gallery ); 2119 }); 2120 2121 $et_pb_gallery.data('paginating', false ); 2122 2123 window.et_pb_gallery_pagination_nav = function( $the_gallery ) { 2124 $the_gallery.on('click', '.et_pb_gallery_pagination a', function(e){ 2125 e.preventDefault(); 2126 2127 var to_page = $(this).data('page'), 2128 $the_gallery = $(this).parents('.et_pb_gallery'), 2129 $the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'), 2130 $the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item'); 2131 2132 if ( $the_gallery.data('paginating') ) { 2133 return; 2134 } 2135 2136 $the_gallery.data('paginating', true ); 2137 2138 if ( $(this).hasClass('page-prev') ) { 2139 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1; 2140 } else if ( $(this).hasClass('page-next') ) { 2141 to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1; 2142 } 2143 2144 $(this).parents('ul').find('a').removeClass('active'); 2145 $(this).parents('ul').find('a.page-' + to_page ).addClass('active'); 2146 2147 var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(), 2148 total_pages = $(this).parents('ul').find('li.page').length; 2149 2150 $(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show(); 2151 $(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show(); 2152 2153 $(this).parents('ul').find('li.page').each(function(i){ 2154 if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) { 2155 if ( i < ( current_index - 3 ) ) { 2156 $(this).hide(); 2157 } else if ( i > ( current_index + 1 ) ) { 2158 $(this).hide(); 2159 } else { 2160 $(this).show(); 2161 } 2162 2163 if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) { 2164 $(this).show(); 2165 } else if ( current_index <= 3 && i <= 4 ) { 2166 $(this).show(); 2167 } 2168 2169 } 2170 }); 2171 2172 if ( to_page > 1 ) { 2173 $(this).parents('ul').find('li.prev').show(); 2174 } else { 2175 $(this).parents('ul').find('li.prev').hide(); 2176 } 2177 2178 if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) { 2179 $(this).parents('ul').find('li.next').hide(); 2180 } else { 2181 $(this).parents('ul').find('li.next').show(); 2182 } 2183 2184 $the_gallery_items.hide(); 2185 var visible_items = $the_gallery_items.filter(function( index ) { 2186 return $(this).data('page') === to_page; 2187 }).show(); 2188 2189 $the_gallery.data('paginating', false ); 2190 2191 setTimeout(function(){ 2192 set_gallery_hash( $the_gallery ); 2193 }, 100 ); 2194 2195 $( 'html, body' ).animate( { scrollTop : $the_gallery.offset().top - 200 }, 200 ); 2196 }); 2197 } 2198 et_pb_gallery_pagination_nav( $et_pb_gallery ); 2199 2200 // Frontend builder's interface wouldn't be able to use $et_pb_gallery as selector 2201 // due to its react component's nature. Using more global selector works. 2202 if ( is_frontend_builder ) { 2203 et_pb_gallery_pagination_nav( $('#et-fb-app') ); 2204 } 2205 2206 } /* end if ( $et_pb_gallery.length ) */ 2207 2208 if ( $et_pb_counter_amount.length ) { 2209 $et_pb_counter_amount.each(function(){ 2210 var $bar_item
2210 = $(this), 2211 bar_item_width = $bar_item.attr( 'data-width' ), 2212 bar_item_padding = Math.ceil( parseFloat( $bar_item.css('paddingLeft') ) ) + Math.ceil( parseFloat( $bar_item.css('paddingRight') ) ), 2213 $bar_item_text = $bar_item.children( '.et_pb_counter_amount_number' ), 2214 bar_item_text_width = $bar_item_text.width() + bar_item_padding; 2215 2216 $bar_item.css({ 2217 'width' : bar_item_width, 2218 'min-width' : bar_item_text_width 2219 }); 2220 }); 2221 } /* $et_pb_counter_amount.length */ 2222 2223 window.et_countdown_timer = function( timer ) { 2224 var end_date = parseInt( timer.attr( 'data-end-timestamp') ), 2225 current_date = new Date().getTime() / 1000, 2226 seconds_left = ( end_date - current_date ); 2227 2228 days = parseInt(seconds_left / 86400); 2229 days = days > 0 ? days : 0; 2230 seconds_left = seconds_left % 86400; 2231 2232 hours = parseInt(seconds_left / 3600); 2233 hours = hours > 0 ? hours : 0; 2234 2235 seconds_left = seconds_left % 3600; 2236 2237 minutes = parseInt(seconds_left / 60); 2238 minutes = minutes > 0 ? minutes : 0; 2239 2240 seconds = parseInt(seconds_left % 60); 2241 seconds = seconds > 0 ? seconds : 0; 2242 2243 var $days_section = timer.find('.days > .value').parent('.section'), 2244 $hours_section = timer.find('.hours > .value').parent('.section'), 2245 $minutes_section = timer.find('.minutes > .value').parent('.section'), 2246 $seconds_section = timer.find('.seconds > .value').parent('.section'); 2247 2248 2249 if ( days == 0 ) { 2250 if ( ! $days_section.hasClass('zero') ) { 2251 timer.find('.days > .value').html( '000' ).parent('.section').addClass('zero').next().addClass('zero'); 2252 } 2253 } else { 2254 days_slice = days.toString().length >= 3 ? days.toString().length : 3; 2255 timer.find('.days > .value').html( ('000' + days).slice(-days_slice) ); 2256 2257 if ( $days_section.hasClass('zero') ) { 2258 $days_section.removeClass('zero').next().removeClass('zero'); 2259 } 2260 } 2261 2262 if ( days == 0 && hours == 0 ) { 2263 if ( ! $hours_section.hasClass('zero') ) { 2264 timer.find('.hours > .value').html('00').parent('.section').addClass('zero').next().addClass('zero'); 2265 } 2266 } else { 2267 timer.find('.hours > .value').html( ( '0' + hours ).slice(-2) ); 2268 2269 if ( $hours_section.hasClass('zero') ) { 2270 $hours_section.removeClass('zero').next().removeClass('zero'); 2271 } 2272 } 2273 2274 if ( days == 0 && hours == 0 && minutes == 0 ) { 2275 if ( ! $minutes_section.hasClass('zero') ) { 2276 timer.find('.minutes > .value').html('00').parent('.section').addClass('zero').next().addClass('zero'); 2277 } 2278 } else { 2279 timer.find('.minutes > .value').html( ( '0' + minutes ).slice(-2) ); 2280 2281 if ( $minutes_section.hasClass('zero') ) { 2282 $minutes_section.removeClass('zero').next().removeClass('zero'); 2283 } 2284 } 2285 2286 if ( days == 0 && hours == 0 && minutes == 0 && seconds == 0 ) { 2287 if ( ! $seconds_section.hasClass('zero') ) { 2288 timer.find('.seconds > .value').html('00').parent('.section').addClass('zero'); 2289 } 2290 } else { 2291 timer.find('.seconds > .value').html( ( '0' + seconds ).slice(-2) ); 2292 2293 if ( $seconds_section.hasClass('zero') ) { 2294 $seconds_section.removeClass('zero').next().removeClass('zero'); 2295 } 2296 } 2297 } 2298 2299 window.et_countdown_timer_labels = function( timer ) { 2300 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 ) {
2301 timer.find('.days .label').html( timer.find('.days').data('short') ); 2302 timer.find('.hours .label').html( timer.find('.hours').data('short') ); 2303 timer.find('.minutes .label').html( timer.find('.minutes').data('short') ); 2304 timer.find('.seconds .label').html( timer.find('.seconds').data('short') ); 2305 } else { 2306 timer.find('.days .label').html( timer.find('.days').data('full') ); 2307 timer.find('.hours .label').html( timer.find('.hours').data('full') ); 2308 timer.find('.minutes .label').html( timer.find('.minutes').data('full') ); 2309 timer.find('.seconds .label').html( timer.find('.seconds').data('full') ); 2310 } 2311 } 2312 2313 if ( $et_pb_countdown_timer.length || is_frontend_builder ) { 2314 window.et_pb_countdown_timer_init = function( $et_pb_countdown_timer ) { 2315 $et_pb_countdown_timer.each(function(){ 2316 var timer = $(this); 2317 et_countdown_timer_labels( timer ); 2318 et_countdown_timer( timer ); 2319 setInterval(function(){ 2320 et_countdown_timer( timer ); 2321 }, 1000); 2322 }); 2323 } 2324 et_pb_countdown_timer_init( $et_pb_countdown_timer ); 2325 } 2326 2327 if ( $et_pb_tabs.length || is_frontend_builder ) { 2328 window.et_pb_tabs_init = function( $et_pb_tabs ) { 2329 var $et_pb_tabs_li = $et_pb_tabs.find( '.et_pb_tabs_controls li' ); 2330 2331 $et_pb_tabs.et_pb_simple_slider( { 2332 use_controls : false, 2333 use_arrows : false, 2334 slide : '.et_pb_all_tabs > div', 2335 tabs_animation : true 2336 } ).on('et_hashchange', function( event ){ 2337 var params = event.params; 2338 var $the_tabs = $( '#' + event.target.id ); 2339 var active_tab = params[0]; 2340 if ( !$the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).hasClass('et_pb_tab_active') ) { 2341 $the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).click(); 2342 } 2343 }); 2344 2345 $et_pb_tabs_li.click( function() { 2346 var $this_el = $(this), 2347 $tabs_container = $this_el.closest( '.et_pb_tabs' ).data('et_pb_simple_slider'); 2348 2349 if ( $tabs_container.et_animation_running ) return false; 2350 2351 $this_el.addClass( 'et_pb_tab_active' ).siblings().removeClass( 'et_pb_tab_active' ); 2352 2353 $tabs_container.data('et_pb_simple_slider').et_slider_move_to( $this_el.index() ); 2354 2355 if ( $this_el.closest( '.et_pb_tabs' ).attr('id') ) { 2356 var tab_state = []; 2357 tab_state.push( $this_el.closest( '.et_pb_tabs' ).attr('id') ); 2358 tab_state.push( $this_el.index() ); 2359 tab_state = tab_state.join( et_hash_module_param_seperator ); 2360 et_set_hash( tab_state ); 2361 } 2362 2363 return false; 2364 } ); 2365 } 2366 window.et_pb_tabs_init( $et_pb_tabs ); 2367 } 2368 2369 if ( $et_pb_map.length || is_frontend_builder ) { 2370 function et_pb_init_maps() { 2371 $et_pb_map.each(function(){ 2372 et_pb_map_init( $(this) ); 2373 }); 2374 } 2375 2376 window.et_pb_map_init = function( $this_map_container ) { 2377 if (typeof google === 'undefined') { 2378 return; 2379 } 2380 2381 var $this_map = $this_map_container.children('.et_pb_map'), 2382 this_map_grayscale = $this_map_container.attr( 'data-grayscale' ) || 0, 2383 is_draggable = ( et_is_mobile_device && $this_map.data('mobile-dragging') !== 'off' ) || ! et_is_mobile_device, 2384 infowindow_active; 2385 2386 if ( this_map_grayscale !== 0 ) { 2387 this_map_grayscale = '-' + this_map_grayscale.toString(); 2388 } 2389 2390 $this_map_container.data('map', new google.maps.Map( $this_map[0], { 2391 zoom: parseInt( $this_map.attr('data-zoom') ), 2392 center: new google.maps.LatLng( parseFloat( $this_map.attr('data-center-lat') ) , parseFloat( $this_map.attr('data-center-lng') )), 2393 mapTypeId: google.maps.MapTypeId.ROADMAP, 2394 scrollwheel: $this_map.attr('data-mouse-wheel') == 'on' ? true : false, 2395 draggable: is_draggable, 2396 panControlOptions: { 2397 position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP 2398 }, 2399 zoomControlOptions: { 2400 position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP 2401 }, 2402 styles: [ { 2403 stylers: [ 2404 { saturation: parseInt( this_map_grayscale ) } 2405 ] 2406 } ] 2407 })); 2408 2409 $this_map_container.find('.et_pb_map_pin').each(function(){ 2410 var $this_marker = $(this); 2411 2412 var marker = new google.maps.Marker({ 2413 position: new google.maps.LatLng( parseFloat( $this_marker.attr('data-lat') ) , parseFloat( $this_marker.attr('data-lng') ) ), 2414 map: $this_map_container.data('map'), 2415 title: $this_marker.attr('data-title'), 2416 icon: { url: et_pb_custom.builder_images_uri + '/marker.png', size: new google.maps.Size( 46, 43 ), anchor: new google.maps.Point( 16, 43 ) }, 2417 shape: { coord: [1, 1, 46, 43], type: 'rect' }, 2418 anchorPoint: new google.maps.Point(0, -45) 2419 }); 2420 2421 if ( $this_marker.find('.infowindow').length ) { 2422 var infowindow = new google.maps.InfoWindow({ 2423 content: $this_marker.html() 2424 }); 2425 2426 google.maps.event.addListener( $this_map_container.data('map'), 'click', function() { 2427 infowindow.close(); 2428 }); 2429 2430 google.maps.event.addListener(marker, 'click', function() { 2431 if( infowindow_active ) { 2432 infowindow_active.close(); 2433 } 2434 infowindow_active = infowindow; 2435 2436 infowindow.open( $this_map_container.data('map'), marker ); 2437 }); 2438 } 2439 }); 2440 } 2441 2442 if ( window.et_load_event_fired ) { 2443 et_pb_init_maps(); 2444 } else { 2445 if ( typeof google !== 'undefined' ) { 2446 google.maps.event.addDomListener(window, 'load', function() { 2447 et_pb_init_maps(); 2448 } ); 2449 } 2450 } 2451 } 2452 2453 if ( $et_pb_shop.length ) { 2454 $et_pb_shop.each( function() { 2455 var $this_el = $(this), 2456 icon = $this_el.data('icon') || ''; 2457 2458 if ( icon === '' ) { 2459 return true; 2460 } 2461 2462 $this_el.find( '.et_overlay' ) 2463 .attr( 'data-icon', icon ) 2464 .addClass( 'et_pb_inline_icon' ); 2465 } ); 2466 } 2467 2468 if ( $et_pb_circle_counter.length || is_frontend_builder ) { 2469 2470 window.et_pb_circle_counter_init = function($the_counter, animate) { 2471 if ( 0 === $the_counter.width() ) { 2472 return; 2473 } 2474 2475 $the_counter.easyPieChart({ 2476 animate: { 2477 duration: 1800, 2478 enabled: true 2479 }, 2480 size: 0 !== $the_counter.width() ? $the_counter.width() : 10, // set the width to 10 if actual width is 0 to avoid js errors 2481 barColor: $the_counter.data( 'bar-bg-color' ), 2482 trackColor: $the_counter.data( 'color' ) || '#000000', 2483 trackAlpha: $the_counter.data( 'alpha' ) || '0.1', 2484 scaleColor: false, 2485 lineWidth: 5, 2486 onStart: function() { 2487 $(this.el).find('.percent p').css({ 'visibility' : 'visible' }); 2488 }, 2489 onStep: function(from, to, percent) { 2490 $(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) ); 2491 }, 2492 onStop: function(from, to) { 2493 $(this.el).find('.percent-value').text( $(this.el).data('number-value') ); 2494 } 2495 }); 2496 } 2497 2498 window.et_pb_reinit_circle_counters = function( $et_pb_circle_counter ) { 2499 $et_pb_circle_counter.each(function(){ 2500 var $the_counter = $(this); 2501 window.et_pb_circle_counter_init($the_counter, false); 2502 2503 $the_counter.on('containerWidthChanged', function( event ){ 2504 $the_counter = $( event.target ); 2505 $the_counter.find('canvas').remove(); 2506 $the_counter.removeData('easyPieChart' ); 2507 window.et_pb_circle_counter_init($the_counter, true); 2508 }); 2509 2510 }); 2511 } 2512 window.et_pb_reinit_circle_counters( $et_pb_circle_counter ); 2513 } 2514 2515 if ( $et_pb_number_counter.length || is_frontend_builder ) { 2516 window.et_pb_reinit_number_counters = function( $et_pb_number_counter ) { 2517 if ( $.fn.fitText ) { 2518 $et_pb_number_counter.find( '.percent p' ).fitText( 0.3 ); 2519 } 2520 2521 $et_pb_number_counter.each(function(){ 2522 var $this_counter = $(this); 2523 $this_counter.easyPieChart({ 2524 animate: { 2525 duration: 1800, 2526 enabled: true 2527 }, 2528 size: 0, 2529 trackColor: false, 2530 scaleColor: false, 2531 lineWidth: 0, 2532 onStart: function() { 2533 $(this.el).find('.percent p').css({ 'visibility' : 'visible' }); 2534 }, 2535 onStep: function(from, to, percent) { 2536 if ( percent != to ) 2537 $(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) ); 2538 }, 2539 onStop: function(from, to) { 2540 $(this.el).find('.percent-value').text( $(this.el).data('number-value') ); 2541 } 2542 }); 2543 }); 2544 } 2545 window.et_pb_reinit_number_counters( $et_pb_number_counter ); 2546 } 2547 2548 window.et_apply_parallax = function() { 2549 if ( ! $(this).length || typeof $(this) === 'undefined' || typeof $(this).offset() === 'undefined') { 2550 return; 2551 } 2552 2553 var $this = $(this), 2554 element_top = $this.offset().top, 2555 window_top = $et_window.scrollTop(), 2556 y_pos = ( ( ( window_top + $et_window.height() ) - element_top ) * 0.3 ), 2557 main_position; 2558 2559 main_position = 'translate(0, ' + y_pos + 'px)'; 2560 2561 $this.find('.et_parallax_bg').css( { 2562 '-webkit-transform' : main_position, 2563 '-moz-transform' : main_position, 2564 '-ms-transform' : main_position, 2565 'transform' : main_position 2566 } ); 2567 } 2568 2569 window.et_parallax_set_height = function() { 2570 var $this = $(this), 2571 bg_height; 2572 2573 bg_height = ( $et_window.height() * 0.3 + $this.innerHeight() ); 2574 2575 $this.find('.et_parallax_bg').css( { 'height' : bg_height } ); 2576 } 2577 2578 function et_toggle_animation_callback( initial_toggle_state, $module, $section ) { 2579 if ( 'closed' === initial_toggle_state ) { 2580 $module.removeClass('et_pb_toggle_close').addClass('et_pb_toggle_open'); 2581 } else { 2582 $module.removeClass('et_pb_toggle_open').addClass('et_pb_toggle_close'); 2583 } 2584 2585 if ( $section.hasClass( 'et_pb_section_parallax' ) && !$section.children().hasClass( 'et_pb_parallax_css') ) { 2586 $.proxy( et_parallax_set_height, $section )(); 2587 } 2588 } 2589 2590 $( '.et_pb_section' ).on( 'click', '.et_pb_toggle_title', function() { 2591 var $this_heading = $(this), 2592 $module = $this_heading.closest('.et_pb_toggle'), 2593 $section = $module.parents( '.et_pb_section' ), 2594 $content = $module.find('.et_pb_toggle_content'), 2595 $accordion = $module.closest( '.et_pb_accordion' ), 2596 is_accordion = $accordion.length, 2597 is_accordion_toggling = $accordion.hasClass( 'et_pb_accordion_toggling' ), 2598 window_offset_top = $(window).scrollTop(), 2599 fixed_header_height = 0, 2600 initial_toggle_state = $module.hasClass( 'et_pb_toggle_close' ) ? 'closed' : 'opened', 2601 $accordion_active_toggle, 2602 module_offset; 2603 2604 if ( is_accordion ) { 2605 if ( $module.hasClass('et_pb_toggle_open') || is_accordion_toggling ) { 2606 return false;
2607 } 2608 2609 $accordion.addClass( 'et_pb_accordion_toggling' ); 2610 $accordion_active_toggle = $module.siblings('.et_pb_toggle_open'); 2611 } 2612 2613 if ( $content.is( ':animated' ) ) { 2614 return; 2615 } 2616 2617 if ( $('body').hasClass('safari') ) { 2618 $content.fadeToggle( 700, function() { 2619 et_toggle_animation_callback( initial_toggle_state, $module, $section ); 2620 } ); 2621 } else { 2622 $content.slideToggle( 700, function() { 2623 et_toggle_animation_callback( initial_toggle_state, $module, $section ); 2624 } ); 2625 } 2626 2627 if ( is_accordion ) { 2628 $accordion_active_toggle.find('.et_pb_toggle_content').slideToggle( 700, function() { 2629 $accordion_active_toggle.removeClass( 'et_pb_toggle_open' ).addClass('et_pb_toggle_close'); 2630 $accordion.removeClass( 'et_pb_accordion_toggling' ); 2631 2632 module_offset = $module.offset(); 2633 2634 // Calculate height of fixed nav 2635 if ( $('#wpadminbar').length ) { 2636 fixed_header_height += $('#wpadminbar').height(); 2637 } 2638 2639 if ( $('#top-header').length ) { 2640 fixed_header_height += $('#top-header').height(); 2641 } 2642 2643 if ( $('#main-header').length && ! et_is_vertical_nav ) { 2644 fixed_header_height += $('#main-header').height(); 2645 } 2646 2647 // Compare accordion offset against window's offset and adjust accordingly 2648 if ( ( window_offset_top + fixed_header_height ) > module_offset.top ) { 2649 $('html, body').animate({ scrollTop : ( module_offset.top - fixed_header_height - 50 ) }); 2650 } 2651 } ); 2652 } 2653 } ); 2654 2655 var $et_contact_container = $( '.et_pb_contact_form_container' ); 2656 2657 if ( $et_contact_container.length ) { 2658 $et_contact_container.each( function() { 2659 var $this_contact_container = $( this ), 2660 $et_contact_form = $this_contact_container.find( 'form' ), 2661 $et_contact_submit = $this_contact_container.find( 'input.et_pb_contact_submit' ),
2662 $et_inputs = $et_contact_form.find( 'input[type=text],textarea' ), 2663 et_email_reg = /^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$/, 2664 redirect_url = typeof $this_contact_container.data( 'redirect_url' ) !== 'undefined' ? $this_contact_container.data( 'redirect_url' ) : ''; 2665 2666 $et_inputs.live( 'focus', function() { 2667 if ( $( this ).val() === $( this ).siblings('label').text() ) { 2668 $( this ).val(''); 2669 } 2670 }).live( 'blur', function() { 2671 if ( '' === $( this ).val() ) { 2672 $( this ).val( $( this ).siblings( 'label' ).text() ); 2673 } 2674 }); 2675 2676 $et_contact_form.on( 'submit', function( event ) { 2677 var $this_contact_form = $( this ), 2678 $this_inputs = $this_contact_form.find( 'input[type=text],textarea' ), 2679 this_et_contact_error = false, 2680 $et_contact_message = $this_contact_form.closest( '.et_pb_contact_form_container' ).find( '.et-pb-contact-message' ), 2681 et_message = '', 2682 et_fields_message = '', 2683 $this_contact_container = $this_contact_form.closest( '.et_pb_contact_form_container' ), 2684 $captcha_field = $this_contact_form.find( '.et_pb_contact_captcha' ), 2685 form_unique_id = typeof $this_contact_container.data( 'form_unique_num' ) !== 'undefined' ? $this_contact_container.data( 'form_unique_num' ) : 0, 2686 inputs_list = []; 2687 et_message = '<ul>'; 2688 2689 $this_inputs.removeClass( 'et_contact_error' ); 2690 2691 $this_inputs.each( function(){ 2692 var $this_el = $( this ), 2693 this_val = $this_el.val(), 2694 this_label = $this_el.siblings( 'label' ).text(), 2695 field_type = typeof $this_el.data( 'field_type' ) !== 'undefined' ? $this_el.data( 'field_type' ) : 'text', 2696 required_mark = typeof $this_el.data( 'required_mark' ) !== 'undefined' ? $this_el.data( 'required_mark' ) : 'not_required', 2697 original_id = typeof $this_el.data( 'original_id' ) !== 'undefined' ? $this_el.data( 'original_id' ) : '', 2698 default_value; 2699 2700 // add current field data into array of inputs 2701 if ( typeof $this_el.attr( 'id' ) !== 'undefined' ) { 2702 inputs_list.push( { 'field_id' : $this_el.attr( 'id' ), 'original_id' : original_id, 'required_mark' : required_mark, 'field_type' : field_type, 'field_label' : this_label } ); 2703 } 2704 2705 // add error message for the field if it is required and empty 2706 if ( 'required' === required_mark && ( '' === this_val || this_label === this_val ) ) { 2707 $this_el.addClass( 'et_contact_error' ); 2708 this_et_contact_error = true; 2709 2710 default_value = this_label; 2711 2712 if ( '' === default_value ) { 2713 default_value = et_pb_custom.captcha; 2714 } 2715 2716 et_fields_message += '<li>' + default_value + '</li>'; 2717 } 2718 2719 // add error message if email field is not empty and fails the email validation 2720 if ( 'email' === field_type && '' !== this_val && this_label !== this_val && ! et_email_reg.test( this_val ) ) { 2721 $this_el.addClass( 'et_contact_error' ); 2722 this_et_contact_error = true; 2723 2724 if ( ! et_email_reg.test( this_val ) ) { 2725 et_message += '<li>' + et_pb_custom.invalid + '</li>'; 2726 } 2727 } 2728 }); 2729 2730 // check the captcha value if required for current form 2731 if ( $captcha_field.length && '' !== $captcha_field.val() ) { 2732 var first_digit = parseInt( $captcha_field.data( 'first_digit' ) ), 2733 second_digit = parseInt( $captcha_field.data( 'second_digit' ) ); 2734 2735 if ( parseInt( $captcha_field.val() ) !== first_digit + second_digit ) { 2736 2737 et_message += '<li>' + et_pb_custom.wrong_captcha + '</li>'; 2738 this_et_contact_error = true; 2739 2740 // generate new digits for captcha 2741 first_digit = Math.floor( ( Math.random() * 15 ) + 1 ); 2742 second_digit = Math.floor( ( Math.random() * 15 ) + 1 ); 2743 2744 // set new digits for captcha 2745 $captcha_field.data( 'first_digit', first_digit ); 2746 $captcha_field.data( 'second_digit', second_digit ); 2747 2748 // regenerate captcha on page 2749 $this_contact_form.find( '.et_pb_contact_captcha_question' ).empty().append( first_digit + ' + ' + second_digit ); 2750 } 2751 2752 } 2753 2754 if ( ! this_et_contact_error ) { 2755 var $href = $( this ).attr( 'action' ), 2756 form_data = $( this ).serializeArray(); 2757 2758 form_data.push( { 'name': 'et_pb_contact_email_fields_' + form_unique_id, 'value' : JSON.stringify( inputs_list ) } ); 2759 2760 $this_contact_container.fadeTo( 'fast', 0.2 ).load( $href + ' #' + $this_contact_form.closest( '.et_pb_contact_form_container' ).attr( 'id' ), form_data, function( responseText ) { 2761 if ( ! $( responseText ).find( '.et_pb_contact_error_text').length ) { 2762 2763 et_pb_maybe_log_event( $this_contact_container, 'con_goal' ); 2764 2765 // redirect if redirect URL is not empty and no errors in contact form
2766 if ( '' !== redirect_url ) { 2767 window.location.href = redirect_url; 2768 } 2769 } 2770 2771 $this_contact_container.fadeTo( 'fast', 1 ); 2772 } ); 2773 } 2774 2775 et_message += '</ul>'; 2776 2777 if ( '' !== et_fields_message ) { 2778 if ( et_message != '<ul></ul>' ) { 2779 et_message = '<p class="et_normal_padding">' + et_pb_custom.contact_error_message + '</p>' + et_message; 2780 } 2781 2782 et_fields_message = '<ul>' + et_fields_message + '</ul>'; 2783 2784 et_fields_message = '<p>' + et_pb_custom.fill_message + '</p>' + et_fields_message; 2785 2786 et_message = et_fields_message + et_message; 2787 } 2788 2789 if ( et_message != '<ul></ul>' ) { 2790 $et_contact_message.html( et_message ); 2791 2792 // If parent of this contact form uses parallax 2793 if ( $this_contact_container.parents('.et_pb_section_parallax').length ) { 2794 $this_contact_container.parents('.et_pb_section_parallax').each(function() { 2795 var $parallax_element = $(this), 2796 $parallax = $parallax_element.children('.et_parallax_bg'), 2797 is_true_parallax = ( ! $parallax.hasClass( 'et_pb_parallax_css' ) ); 2798 2799 if ( is_true_parallax ) { 2800 $et_window.trigger( 'resize' ); 2801 } 2802 }); 2803 } 2804 } 2805 2806 event.preventDefault(); 2807 }); 2808 }); 2809 } 2810 2811 window.et_pb_play_overlayed_video = function( $play_video ) { 2812 var $this = $play_video, 2813 $video_image = $this.closest('.et_pb_video_overlay'), 2814 $wrapper = $this.closest('.et_pb_video, .et_main_video_container'), 2815 $video_iframe = $wrapper.find('iframe'), 2816 is_embedded = $video_iframe.length ? true : false, 2817 video_iframe_src, 2818 video_iframe_src_splitted, 2819 video_iframe_src_autoplay; 2820 2821 if (is_embedded) { 2822 // Add autoplay parameter to automatically play embedded content when overlay is clicked 2823 video_iframe_src = $video_iframe.attr('src'); 2824 video_iframe_src_splitted = video_iframe_src.split("?"); 2825 2826 if (video_iframe_src.indexOf('autoplay=') !== -1) { 2827 return; 2828 } 2829 2830 if (typeof video_iframe_src_splitted[1] !== 'undefined') { 2831 video_iframe_src_autoplay = video_iframe_src_splitted[0] + "?autoplay=1&" + video_iframe_src_splitted[1]; 2832 } else { 2833 video_iframe_src_autoplay = video_iframe_src_splitted[0] + "?autoplay=1"; 2834 } 2835 2836 $video_iframe.attr({ 2837 'src': video_iframe_src_autoplay 2838 }); 2839 } else { 2840 $wrapper.find('video').get(0).play(); 2841 } 2842 2843 2844 $video_image.fadeTo( 500, 0, function() { 2845 var $image = $(this); 2846 2847 $image.css( 'display', 'none' ); 2848 } ); 2849 } 2850 2851 $( '.et_pb_post .et_pb_video_overlay, .et_pb_video .et_pb_video_overlay, .et_pb_video_wrap .et_pb_video_overlay' ).click( function() { 2852 var $this = $(this); 2853 2854 et_pb_play_overlayed_video( $this ); 2855 2856 return false; 2857 } ); 2858 2859 window.et_pb_resize_section_video_bg = function( $video ) { 2860 $element = typeof $video !== 'undefined' ? $video.closest( '.et_pb_section_video_bg' ) : $( '.et_pb_section_video_bg' ); 2861 2862 $element.each( function() { 2863 var $this_el = $(this), 2864 ratio = ( typeof $this_el.attr( 'data-ratio' ) !== 'undefined' ) && ! is_frontend_builder 2865 ? $this_el.attr( 'data-ratio' ) 2866 : $this_el.find('video').attr( 'width' ) / $this_el.find('video').attr( 'height' ), 2867 $video_elements = $this_el.find( '.mejs-video, video, object' ).css( 'margin', 0 ), 2868 $container = $this_el.closest( '.et_pb_section_video' ).length 2869 ? $this_el.closest( '.et_pb_section_video' ) 2870 : $this_el.closest( '.et_pb_slides' ), 2871 body_width = $container.innerWidth(), 2872 container_height = $container.innerHeight(), 2873 width, height; 2874 if ( typeof $this_el.attr( 'data-ratio' ) == 'undefined' && !isNaN(ratio) ) { 2875 $this_el.attr( 'data-ratio', ratio ); 2876 } 2877 2878 if ( body_width / container_height < ratio ) { 2879 width = container_height * ratio; 2880 height = container_height; 2881 } else { 2882 width = body_width; 2883 height = body_width / ratio; 2884 } 2885 2886 $video_elements.width( width ).height( height ); 2887 2888 // need to re-set the values to make it work correctly in Frontend builder 2889 if ( is_frontend_builder ) { 2890 setTimeout( function() { 2891 $video_elements.width( width ).height( height ); 2892 }, 0 ); 2893 } 2894 } ); 2895 } 2896 2897 window.et_pb_center_video = function( $video ) { 2898 $element = typeof $video !== 'undefined' ? $video : $( '.et_pb_section_video_bg .mejs-video' ); 2899 2900 $element.each( function() { 2901 var $this_el = $(this); 2902 var $video_width = $this_el.width() / 2; 2903 var $video_width_negative = 0 - $video_width; 2904 $this_el.css("margin-left",$video_width_negative ); 2905 2906 // need to re-calculate the values in Frontend builder 2907 if ( is_frontend_builder ) { 2908 setTimeout( function() { 2909 var $video_width = $this_el.width() / 2; 2910 var $video_width_negative = 0 - $video_width; 2911 $this_el.css("margin-left",$video_width_negative ); 2912 }, 0 ); 2913 } 2914 2915 if ( typeof $video !== 'undefined' ) { 2916 if ( $video.closest( '.et_pb_slider' ).length && ! $video.closest( '.et_pb_first_video' ).length ) { 2917 return false;
2918 } 2919 } 2920 } ); 2921 } 2922 2923 window.et_fix_slider_height = function( $slider ) { 2924 var $this_slider = typeof $slider !== 'undefined' ? $slider : $et_pb_slider; 2925 if ( ! $this_slider.length ) return; 2926 2927 $this_slider.each( function() { 2928 var $slide_section = $(this).parent( '.et_pb_section' ), 2929 $slide = $(this).find( '.et_pb_slide' ), 2930 $slide_container = $slide.find( '.et_pb_container' ), 2931 max_height = 0; 2932 2933 // If this is appears at the first section benath transparent nav, skip it 2934 // leave it to et_fix_page_container_position() 2935 if ( $slide_section.is( '.et_pb_section_first' ) ){ 2936 return true; 2937 } 2938 2939 $slide_container.css( 'min-height', 0 ); 2940 2941 $slide.each( function() { 2942 var $this_el = $(this), 2943 height = $this_el.innerHeight(); 2944 2945 if ( max_height < height ) 2946 max_height = height; 2947 } ); 2948 2949 $slide_container.css( 'min-height', max_height ); 2950 } ); 2951 } 2952 2953 /** 2954 * Add conditional class to prevent unwanted dropdown nav 2955 */ 2956 function et_fix_nav_direction() { 2957 window_width = $(window).width(); 2958 $('.nav li.et-reverse-direction-nav').removeClass( 'et-reverse-direction-nav' ); 2959 $('.nav li li ul').each(function(){ 2960 var $dropdown = $(this), 2961 dropdown_width = $dropdown.width(), 2962 dropdown_offset = $dropdown.offset(), 2963 $parents = $dropdown.parents('.nav > li'); 2964 2965 if ( dropdown_offset.left > ( window_width - dropdown_width ) ) { 2966 $parents.addClass( 'et-reverse-direction-nav' ); 2967 } 2968 }); 2969 } 2970 et_fix_nav_direction(); 2971 2972 et_pb_form_placeholders_init( $( '.et_pb_newsletter_form' ) ); 2973 2974 $('.et_pb_fullwidth_menu ul.nav').each(function(i) { 2975 i++; 2976 et_duplicate_menu( $(this), $(this).parents('.et_pb_row').find('div .mobile_nav'), 'mobile_menu' + i, 'et_mobile_menu' ); 2977 }); 2978 2979 $('.et_pb_fullwidth_menu').each(function() { 2980 var this_menu = $( this ), 2981 bg_color = this_menu.data( 'bg_color' ); 2982 if ( bg_color ) { 2983 this_menu.find( 'ul' ).css( { 'background-color' : bg_color } ); 2984 } 2985 }); 2986 2987 $et_pb_newsletter_button.click( function( event ) { 2988 et_pb_submit_newsletter( $(this), event ); 2989 } ); 2990 2991 window.et_pb_submit_newsletter = function( $submit, event ) { 2992 if ( $submit.closest( '.et_pb_login_form' ).length || $submit.closest( '.et_pb_feedburner_form' ).length ) { 2993 et_pb_maybe_log_event( $submit.closest( '.et_pb_newsletter' ), 'con_goal' ); 2994 return; 2995 } 2996 2997 if ( typeof event !== 'undefined' ) { 2998 event.preventDefault(); 2999 } 3000 3001 var $newsletter_container = $submit.closest( '.et_pb_newsletter' ), 3002 $firstname = $newsletter_container.find( 'input[name="et_pb_signup_firstname"]' ), 3003 $lastname = $newsletter_container.find( 'input[name="et_pb_signup_lastname"]' ), 3004 $email = $newsletter_container.find( 'input[name="et_pb_signup_email"]' ), 3005 list_id = $newsletter_container.find( 'input[name="et_pb_signup_list_id"]' ).val(), 3006 $result = $newsletter_container.find( '.et_pb_newsletter_result' ).hide(), 3007 service = $submit.closest( '.et_pb_newsletter_form' ).data( 'service' ) || 'mailchimp'; 3008 3009 $firstname.removeClass( 'et_pb_signup_error' ); 3010 $lastname.removeClass( 'et_pb_signup_error' ); 3011 $email.removeClass( 'et_pb_signup_error' ); 3012 3013 et_pb_remove_placeholder_text( $submit.closest( '.et_pb_newsletter_form' ) ); 3014 3015 if ( $firstname.val() == '' || $email.val() == '' || list_id === '' ) { 3016 if ( $firstname.val() == '' ) $firstname.addClass( 'et_pb_signup_error' ); 3017 3018 if ( $email.val() == '' ) $email.addClass( 'et_pb_signup_error' ); 3019 3020 if ( $firstname.val() == '' ) 3021 $firstname.val( $firstname.siblings( '.et_pb_contact_form_label' ).text() ); 3022 3023 if ( $lastname.val() == '' ) 3024 $lastname.val( $lastname.siblings( '.et_pb_contact_form_label' ).text() ); 3025 3026 if ( $email.val() == '' ) 3027 $email.val( $email.siblings( '.et_pb_contact_form_label' ).text() ); 3028 3029 return; 3030 } 3031 3032 $.ajax( { 3033 type: "POST", 3034 url: et_pb_custom.ajaxurl, 3035 dataType: "json", 3036 data: 3037 { 3038 action : 'et_pb_submit_subscribe_form', 3039 et_frontend_nonce : et_pb_custom.et_frontend_nonce, 3040 et_list_id : list_id, 3041 et_firstname : $firstname.val(), 3042 et_lastname : $lastname.val(), 3043 et_email : $email.val(), 3044 et_service : service 3045 }, 3046 beforeSend: function() { 3047 $newsletter_container 3048 .find( '.et_pb_newsletter_button' ) 3049 .addClass( 'et_pb_button_text_loading' ) 3050 .find('.et_subscribe_loader') 3051 .show(); 3052 }, 3053 complete: function(){ 3054 $newsletter_container 3055 .find( '.et_pb_newsletter_button' ) 3056 .removeClass( 'et_pb_button_text_loading' ) 3057 .find('.et_subscribe_loader') 3058 .hide(); 3059 }, 3060 success: function( data ){ 3061 if ( data ) { 3062 if ( data.error ) { 3063 $result.html( data.error ).show(); 3064 } 3065 if ( data.success ) { 3066 $newsletter_container.find( '.et_pb_newsletter_form > p' ).hide(); 3067 $result.html( data.success ).show(); 3068 3069 et_pb_maybe_log_event( $newsletter_container, 'con_goal' ); 3070 } 3071 } else { 3072 $result.html( et_pb_custom.subscription_failed ).show(); 3073 } 3074 } 3075 } ); 3076 } 3077 3078 window.et_fix_testimonial_inner_width = function() { 3079 var window_width = $( window ).width(); 3080 3081 if( window_width > 767 ){ 3082 $( '.et_pb_testimonial' ).each( function() { 3083 if ( ! $(this).is(':visible') ) { 3084 return; 3085 } 3086 3087 var $testimonial = $(this), 3088 testimonial_width = $testimonial.width(), 3089 $portrait = $testimonial.find( '.et_pb_testimonial_portrait' ), 3090 portrait_width = $portrait.width(), 3091 $testimonial_inner= $testimonial.find( '.et_pb_testimonial_description_inner' ), 3092 $outer_column = $testimonial.closest( '.et_pb_column' ), 3093 testimonial_inner_width = testimonial_width, 3094 subtract = ! ( $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 + 31 : 0; 3095 3096 $testimonial_inner.width( testimonial_inner_width - subtract ); 3097 } ); 3098 } else { 3099 $( '.et_pb_testimonial_description_inner' ).removeAttr( 'style' ); 3100 } 3101 } 3102 window.et_fix_testimonial_inner_width(); 3103 3104 window.et_pb_video_background_init = function( $this_video_background, this_video_background ) { 3105 var $video_background_wrapper = $this_video_background.closest( '.et_pb_section_video_bg' ), 3106 this_video_player = this_video_background.player; 3107 3108 // Entering video's top viewport 3109 $video_background_wrapper.waypoint({ 3110 offset: '100%', 3111 handler : function( direction ) { 3112 if ( $this_video_background.is(':visible') && direction === 'down' ) { 3113 this_video_player.play(); 3114 } else if ( $this_video_background.is(':visible') && direction === 'up' ) { 3115 this_video_player.pause(); 3116 } 3117 } 3118 }); 3119 3120 // Entering video's bottom viewport 3121 $video_background_wrapper.waypoint({ 3122 offset: '-50%', 3123 handler : function( direction ) { 3124 if ( $this_video_background.is(':visible') && direction === 'up' ) { 3125 this_video_player.play(); 3126 } else if ( $this_video_background.is(':visible') && direction === 'down' ) { 3127 this_video_player.pause(); 3128 } 3129 } 3130 }); 3131 } 3132 3133 window.et_reinit_waypoint_modules = et_pb_debounce( function() { 3134 if ( $.fn.waypoint ) { 3135 var $et_pb_circle_counter = $( '.et_pb_circle_counter' ), 3136 $et_pb_number_counter = $( '.et_pb_number_counter' ), 3137 $et_pb_video_background = $( '.et_pb_section_video_bg video' ); 3138 3139 $( '.et_pb_counter_container, .et-waypoint' ).waypoint( { 3140 offset: '75%', 3141 handler: function() { 3142 $(this.element).addClass( 'et-animated' ); 3143 } 3144 } ); 3145 3146 // fallback to 'bottom-in-view' offset, to make sure element become visible when it's on the bottom of page and other offsets are not triggered 3147 $( '.et_pb_counter_container, .et-waypoint' ).waypoint( { 3148 offset: 'bottom-in-view', 3149 handler: function() { 3150 $(this.element).addClass( 'et-animated' ); 3151 } 3152 } ); 3153 3154 if ( $et_pb_circle_counter.length ) { 3155 $et_pb_circle_counter.each(function(){ 3156 var $this_counter = $(this); 3157 if ( ! $this_counter.is( ':visible' ) ) { 3158 return; 3159 } 3160 $this_counter.waypoint({ 3161 offset: '65%', 3162 handler: function() { 3163 if ( $this_counter.data( 'PieChartHasLoaded' ) ) { 3164 return; 3165 } 3166 3167 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 3168 3169 $this_counter.data( 'PieChartHasLoaded', true ); 3170 } 3171 }); 3172 3173 // 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 3174 $this_counter.waypoint({ 3175 offset: 'bottom-in-view', 3176 handler: function() { 3177 if ( $this_counter.data( 'PieChartHasLoaded' ) ) { 3178 return; 3179 } 3180 3181 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 3182 3183 $this_counter.data( 'PieChartHasLoaded', true ); 3184 } 3185 }); 3186 }); 3187 } 3188 3189 if ( $et_pb_number_counter.length ) { 3190 $et_pb_number_counter.each(function(){ 3191 var $this_counter = $(this); 3192 $this_counter.waypoint({ 3193 offset: '75%', 3194 handler: function() { 3195 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 3196 } 3197 }); 3198 3199 // 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 3200 $this_counter.waypoint({ 3201 offset: 'bottom-in-view', 3202 handler: function() { 3203 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 3204 } 3205 }); 3206 }); 3207 } 3208 3209 if ( $( '.et_pb_ab_goal' ).length ) { 3210 var $et_pb_ab_goal = $( '.et_pb_ab_goal' ); 3211 3212 $et_pb_ab_goal.waypoint({ 3213 offset: '80%', 3214 handler: function() { 3215 if ( et_pb_ab_logged_status['read_goal'] || ! $et_pb_ab_goal.length || ! $et_pb_ab_goal.visible( true ) ) { 3216 return; 3217 } 3218 3219 // log the goal_read if goal is still visible after 3 seconds. 3220 setTimeout( function() { 3221 if ( $et_pb_ab_goal.length && $et_pb_ab_goal.visible( true ) && ! et_pb_ab_logged_status['read_goal'] ) { 3222 et_pb_ab_update_stats( 'read_goal' ); 3223 } 3224 }, 3000 ); 3225 3226 et_pb_maybe_log_event( $et_pb_ab_goal, 'view_goal' ); 3227 } 3228 }); 3229 } 3230 3231 if ( $et_pb_video_background.length ) { 3232 $et_pb_video_background.each( function(){ 3233 var $this_video_background = $(this); 3234 3235 et_pb_video_background_init( $this_video_background, this ); 3236 }); 3237 } 3238 } 3239 }, 100 ); 3240 3241 function et_pb_init_ab_test() { 3242 var $et_pb_ab_goal = $( '.et_pb_ab_goal' ), 3243 et_ab_subject_id = et_pb_get_subject_id(); 3244 3245 $.each( et_pb_ab_logged_status, function( key, value ) { 3246 var cookie_subject = 'click_goal' === key || 'con_short' === key ? '' : et_ab_subject_id; 3247 3248 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' ); 3249 3250 }); 3251 3252 // log the page read event if user stays on page long enough and if not logged for current subject 3253 if ( ! et_pb_ab_logged_status['read_page'] ) { 3254 setTimeout( function() { 3255 et_pb_ab_update_stats( 'read_page' ); 3256 }, et_pb_ab_bounce_rate ); 3257 } 3258 3259 // add the cookies for shortcode tracking, if enabled 3260 if ( 'on' === et_pb_custom.is_shortcode_tracking && ! et_pb_ab_logged_status['con_short'] ) { 3261 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 ); 3262 } 3263 3264 if ( $et_pb_ab_goal.length ) { 3265 // if goal is a module and has a button then track the conversions, otherwise track clicks 3266 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 ) ) { 3267 // Log con_goal if current goal doesn't require any specific conversion calculation 3268 if ( ! $et_pb_ab_goal.hasClass( 'et_pb_contact_form_container' ) && ! $et_pb_ab_goal.hasClass( 'et_pb_newsletter' ) ) { 3269 var $goal_button = $et_pb_ab_goal.hasClass( 'et_pb_button' ) ? $et_pb_ab_goal : $et_pb_ab_goal.find( '.et_pb_button' ); 3270 3271 if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) ) { 3272 var page_url = window.location.href, 3273 comment_submitted = -1 !== page_url.indexOf( '#comment-' ) ? true : false, 3274 log_conversion = et_pb_check_cookie_value( 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id, 'true' ); 3275 3276 if ( comment_submitted && log_conversion ) { 3277 et_pb_ab_update_stats( 'con_goal' ); 3278 et_pb_set_cookie( 0, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' ); 3279 } 3280 } 3281 3282 $goal_button.click( function(){ 3283 if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) && ! et_pb_ab_logged_status['con_goal'] ) { 3284 et_pb_set_cookie( 365, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' ); 3285 return; 3286 } 3287 3288 et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' ); 3289 }); 3290 } 3291 } else { 3292 $et_pb_ab_goal.click( function() { 3293 if ( $et_pb_ab_goal.hasClass( 'et_pb_shop' ) && ! et_pb_ab_logged_status['con_goal'] ) { 3294 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 ); 3295 } 3296 3297 et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' ); 3298 }); 3299 } 3300 } 3301 } 3302 3303 function et_pb_maybe_log_event( $goal_container, event ) { 3304 var log_event = typeof event === 'undefined' ? 'con_goal' : event; 3305 3306 if ( ! $goal_container.hasClass( 'et_pb_ab_goal' ) || et_pb_ab_logged_status[ log_event ] ) { 3307 return; 3308 } 3309 3310 // log the event if it's not logged for current user 3311 et_pb_ab_update_stats( log_event ); 3312 } 3313 3314 function et_pb_ab_update_stats( record_type, set_page_id, set_subject_id, set_test_id ) { 3315 var subject_id = typeof set_subject_id === 'undefined' ? et_pb_get_subject_id() : set_subject_id, 3316 page_id = typeof set_page_id === 'undefined' ? et_pb_custom.page_id : set_page_id, 3317 test_id = typeof set_test_id === 'undefined' ? et_pb_custom.unique_test_id : set_test_id, 3318 stats_data = JSON.stringify({ 'test_id' : page_id, 'subject_id' : subject_id, 'record_type' : record_type }),
3319 cookie_subject = 'click_goal' === record_type || 'con_short' === record_type ? '' : subject_id; 3320 3321 et_pb_set_cookie( 365, 'et_pb_ab_' + record_type + '_' + page_id + test_id + cookie_subject + '=true' ); 3322 3323 et_pb_ab_logged_status[record_type] = true; 3324 3325 $.ajax({ 3326 type: 'POST', 3327 url: et_pb_custom.ajaxurl, 3328 data: { 3329 action : 'et_pb_update_stats_table', 3330 stats_data_array : stats_data, 3331 et_ab_log_nonce : et_pb_custom.et_ab_log_nonce 3332 } 3333 }); 3334 } 3335 3336 function et_pb_get_subject_id() { 3337 var subject_id_raw = $( '.et_pb_ab_subject' ).attr( 'class' ).split( 'et_pb_ab_subject_id-' )[1], 3338 subject_id_clean = subject_id_raw.split( ' ' )[0], 3339 subject_id_separated = subject_id_clean.split( '_' ), 3340 subject_id = subject_id_separated[1]; 3341 3342 return subject_id; 3343 } 3344 3345 function et_pb_set_cookie_expire( days ) { 3346 var ms = days*24*60*60*1000; 3347 3348 var date = new Date(); 3349 date.setTime( date.getTime() + ms ); 3350 3351 return "; expires=" + date.toUTCString(); 3352 } 3353 3354 function et_pb_check_cookie_value( cookie_name, value ) { 3355 return et_pb_get_cookie_value( cookie_name ) == value; 3356 } 3357 3358 function et_pb_get_cookie_value( cookie_name ) { 3359 return et_pb_parse_cookies()[cookie_name]; 3360 } 3361 3362 function et_pb_parse_cookies() { 3363 var cookies = document.cookie.split( '; ' ); 3364 3365 var ret = {}; 3366 for ( var i = cookies.length - 1; i >= 0; i-- ) { 3367 var el = cookies[i].split( '=' ); 3368 ret[el[0]] = el[1]; 3369 } 3370 return ret; 3371 } 3372 3373 function et_pb_set_cookie( expire, cookie_content ) { 3374 cookie_expire = et_pb_set_cookie_expire( expire ); 3375 document.cookie = cookie_content + cookie_expire + "; path=/"; 3376 } 3377 3378 window.et_calc_fullscreen_section = function() { 3379 var $et_window = $(window), 3380 $body = $( 'body' ), 3381 $wpadminbar = $( '#wpadminbar' ), 3382 et_is_vertical_nav = $body.hasClass( 'et_vertical_nav' ), 3383 $this_section = $(this), 3384 this_section_index = $this_section.index('.et_pb_fullwidth_header'), 3385 $header = $this_section.children('.et_pb_fullwidth_header_container'), 3386 $header_content = $header.children('.header-content-container'), 3387 $header_image = $header.children('.header-image-container'), 3388 sectionHeight = $et_window.height(), 3389 $wpadminbar = $('#wpadminbar'), 3390 $top_header = $('#top-header'), 3391 $main_header = $('#main-header'), 3392 et_header_height, 3393 secondary_nav_height; 3394 3395 secondary_nav_height = $top_header.length && $top_header.is( ':visible' ) ? $top_header.innerHeight() : 0; 3396 et_header_height = $main_header.length ? $main_header.innerHeight() + secondary_nav_height : 0; 3397 3398 var calc_header_offset = ( $wpadminbar.length ) ? et_header_height + $wpadminbar.innerHeight() - 1 : et_header_height - 1; 3399 3400 // Section height adjustment differs in vertical and horizontal nav 3401 if ( $body.hasClass('et_vertical_nav') ) { 3402 if ( $et_window.width() >= 980 && $top_header.length ) { 3403 sectionHeight -= $top_header.height(); 3404 } 3405 3406 if ( $wpadminbar.length ) { 3407 sectionHeight -= $wpadminbar.height(); 3408 } 3409 } else { 3410 if ( $body.hasClass('et_hide_nav' ) ) { 3411 // If user is logged in and hide navigation is in use, adjust the section height 3412 if ( $wpadminbar.length ) { 3413 sectionHeight -= $wpadminbar.height(); 3414 } 3415 3416 // In mobile, header always appears. Adjust the section height 3417 if ( $et_window.width() < 981 && ! $body.hasClass('et_transparent_nav') ) { 3418 sectionHeight -= $('#main-header').height(); 3419 } 3420 } else { 3421 if ( $this_section.offset().top <= calc_header_offset + 3 ) { 3422 if ( et_is_vertical_nav ) { 3423 var $top_header = $('#top-header'), 3424 top_header_height = ( $top_header.length && 0 === $this_section.index( '.et_pb_fullscreen' ) ) ? $top_header.height() : 0, 3425 wpadminbar_height = ( $wpadminbar.length && 0 === $this_section.index( '.et_pb_fullscreen' ) ) ? $wpadminbar.height() : 0, 3426 calc_header_offset_vertical = wpadminbar_height + top_header_height; 3427 3428 sectionHeight -= calc_header_offset_vertical; 3429 } else { 3430 sectionHeight -= calc_header_offset; 3431 } 3432 } 3433 } 3434 } 3435 3436 // If the transparent primary nav + hide nav until scroll is being used, 3437 // cancel automatic padding-top added by transparent nav mechanism 3438 if ( $body.hasClass('et_transparent_nav') && $body.hasClass( 'et_hide_nav' ) && 0 === this_section_index ) { 3439 $this_section.css( 'padding-top', '' ); 3440 } 3441 3442 $this_section.css('min-height', sectionHeight + 'px' ); 3443 $header.css('min-height', sectionHeight + 'px' ); 3444 3445 if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('bottom') ) { 3446 $header.addClass('bottom-bottom'); 3447 } 3448 3449 if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('center') ) { 3450 $header.addClass('center-center'); 3451 } 3452 3453 if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('bottom') ) { 3454 $header.addClass('center-bottom'); 3455 3456 var contentHeight = sectionHeight - $header_image.outerHeight( true ); 3457 3458 if ( contentHeight > 0 ) { 3459 $header_content.css('min-height', contentHeight + 'px' ); 3460 } 3461 } 3462 3463 if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('center') ) { 3464 $header.addClass('bottom-center'); 3465 } 3466 3467 if ( ( $header.hasClass('left') || $header.hasClass('right') ) && !$header_content.length && $header_image.length ) { 3468 $header.css('justify-content', 'flex-end'); 3469 } 3470 3471 if ( $header.hasClass('center') && $header_content.hasClass('bottom') && !$header_image.length ) { 3472 $header_content.find('.header-content').css( 'margin-bottom', 80 + 'px' ); 3473 } 3474 3475 if ( $header_content.hasClass('bottom') && $header_image.hasClass('center') ) { 3476 $header_image.find('.header-image').css( 'margin-bottom', 80 + 'px' ); 3477 $header_image.css('align-self', 'flex-end'); 3478 } 3479 } 3480 3481 window.et_pb_parallax_init = function( $this_parallax ) { 3482 if ( $this_parallax.hasClass('et_pb_parallax_css') ) { 3483 return; 3484 } 3485 3486 var $this_parent = $this_parallax.parent(); 3487 3488 $.proxy( et_parallax_set_height, $this_parent )(); 3489 3490 $.proxy( et_apply_parallax, $this_parent )(); 3491 3492 $et_window.on( 'scroll', $.proxy( et_apply_parallax, $this_parent ) ); 3493 3494 $et_window.on( 'resize', $.proxy( et_parallax_set_height, $this_parent ) ); 3495 3496 $et_window.on( 'resize', $.proxy( et_apply_parallax, $this_parent ) ); 3497 3498 $this_parent.find('.et-learn-more .heading-more').click( function() { 3499 setTimeout(function(){ 3500 $.proxy( et_parallax_set_height, $this_parent )(); 3501 }, 300 ); 3502 }); 3503 } 3504 3505 $( window ).resize( function(){ 3506 var window_width = $et_window.width(),
3507 et_container_css_width = $et_container.css( 'width' ), 3508 et_container_width_in_pixel = ( typeof et_container_css_width !== 'undefined' ) ? et_container_css_width.substr( -1, 1 ) !== '%' : '', 3509 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 3510 containerWidthChanged = et_container_width !== et_container_actual_width; 3511 3512 et_pb_resize_section_video_bg(); 3513 et_pb_center_video(); 3514 et_fix_slider_height(); 3515 et_fix_nav_direction(); 3516 3517 $et_pb_fullwidth_portfolio.each(function(){ 3518 set_container_height = $(this).hasClass('et_pb_fullwidth_portfolio_carousel') ? true : false; 3519 set_fullwidth_portfolio_columns( $(this), set_container_height ); 3520 }); 3521 3522 if ( containerWidthChanged ) { 3523 $('.container-width-change-notify').trigger('containerWidthChanged'); 3524 3525 setTimeout( function() { 3526 $et_pb_filterable_portfolio.each(function(){ 3527 set_filterable_grid_items( $(this) ); 3528 }); 3529 $et_pb_gallery.each(function(){ 3530 if ( $(this).hasClass( 'et_pb_gallery_grid' ) ) { 3531 set_gallery_grid_items( $(this) ); 3532 } 3533 }); 3534 }, 100 ); 3535 3536 et_container_width = et_container_actual_width; 3537 3538 etRecalculateOffset = true; 3539 3540 if ( $et_pb_circle_counter.length ) { 3541 $et_pb_circle_counter.each(function(){ 3542 var $this_counter = $(this); 3543 if ( ! $this_counter.is( ':visible' ) ) { 3544 return; 3545 } 3546 3547 $this_counter.data('easyPieChart').update( $this_counter.data('number-value') ); 3548 }); 3549 } 3550 if ( $et_pb_countdown_timer.length ) { 3551 $et_pb_countdown_timer.each(function(){ 3552 var timer = $(this); 3553 et_countdown_timer_labels( timer ); 3554 } ); 3555 } 3556 } 3557 3558 window.et_fix_testimonial_inner_width(); 3559 3560 et_audio_module_set(); 3561 } ); 3562 3563 $( window ).ready( function(){ 3564 if ( $.fn.fitVids ) { 3565 $( '.et_pb_slide_video' ).fitVids(); 3566 $( '.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']"} ); 3567 } 3568 3569 et_fix_video_wmode('.fluid-width-video-wrapper'); 3570 3571 et_fix_slider_height(); 3572 3573 // calculate fullscreen section sizes on $( window ).ready to avoid jumping in some cases 3574 $( 'section.et_pb_fullscreen' ).each( function(){ 3575 var $this_section = $( this ); 3576 3577 $.proxy( et_calc_fullscreen_section, $this_section )(); 3578 3579 $et_window.on( 'resize', $.proxy( et_calc_fullscreen_section, $this_section ) ); 3580 }); 3581 } ); 3582 3583 window.et_pb_fullwidth_header_scroll = function( event ) { 3584 event.preventDefault(); 3585 3586 var $this_section = $(this).parents( 'section' ), 3587 is_next_fullscreen = $this_section.next().hasClass( 'et_pb_fullscreen' ), 3588 $wpadminbar = $('#wpadminbar'), 3589 wpadminbar_height = ( $wpadminbar.length && ! is_next_fullscreen ) ? $wpadminbar.height() : 0, 3590 main_header_height = is_next_fullscreen || ! et_is_fixed_nav ? 0 : $main_header.height(), 3591 top_header_height = is_next_fullscreen || ! et_is_fixed_nav ? 0 : $top_header.height(), 3592 section_bottom = $this_section.offset().top + $this_section.outerHeight( true ) - ( wpadminbar_height + top_header_height + main_header_height ); 3593 3594 // Fixed menu is turned off on 980px below screen 3595 if ( 980 > $et_window.width() ) { 3596 section_bottom += main_header_height;
3597 section_bottom += top_header_height; 3598 } 3599 3600 // Admin bar is sticked to the top of page on 600px screen below 3601 if ( 600 > $et_window.width() ) { 3602 section_bottom += wpadminbar_height; 3603 } 3604 3605 if ( $this_section.length ) { 3606 $( 'html, body' ).animate( { scrollTop : section_bottom }, 800 ); 3607 3608 if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && $( window ).width() > 980 ) { 3609 setTimeout(function(){ 3610 var section_offset_top = $this_section.offset().top, 3611 section_height = $this_section.outerHeight( true ), 3612 main_header_height = is_next_fullscreen ? 0 : $main_header.height(), 3613 section_bottom = section_offset_top + section_height - ( main_header_height + top_header_height + wpadminbar_height); 3614 3615 $( 'html, body' ).animate( { scrollTop : section_bottom }, 280, 'linear' ); 3616 }, 780 ); 3617 } 3618 } 3619 } 3620 3621 function et_pb_window_load_scripts() { 3622 et_fix_fullscreen_section(); 3623 3624 // recalculate fullscreen section sizes on load 3625 $( 'section.et_pb_fullscreen' ).each( function(){ 3626 var $this_section = $( this ); 3627 3628 $.proxy( et_calc_fullscreen_section, $this_section )(); 3629 }); 3630 3631 $( '.et_pb_fullwidth_header_scroll' ).on('click', 'a', et_pb_fullwidth_header_scroll ); 3632 3633 setTimeout( function() { 3634 $( '.et_pb_preload' ).removeClass( 'et_pb_preload' ); 3635 }, 500 ); 3636 3637 if ( $.fn.hashchange ) { 3638 $(window).hashchange( function(){ 3639 var hash = window.location.hash.substring(1); 3640 process_et_hashchange( hash ); 3641 }); 3642 $(window).hashchange(); 3643 } 3644 3645 if ( $et_pb_parallax.length && !et_is_mobile_device ) { 3646 $et_pb_parallax.each(function(){ 3647 et_pb_parallax_init( $(this) ); 3648 }); 3649 } 3650 3651 et_audio_module_set(); 3652 3653 window.et_reinit_waypoint_modules(); 3654 3655 if ( $( '.et_audio_content' ).length ) { 3656 $( window ).trigger( 'resize' ); 3657 } 3658 } 3659 3660 if ( window.et_load_event_fired ) { 3661 et_pb_window_load_scripts(); 3662 } else { 3663 $( window ).load( function() { 3664 et_pb_window_load_scripts(); 3665 } ); 3666 } 3667 3668 if ( $( '.et_section_specialty' ).length ) { 3669 $( '.et_section_specialty' ).each( function() { 3670 var this_row = $( this ).find( '.et_pb_row' ); 3671 3672 this_row.find( '>.et_pb_column:not(.et_pb_specialty_column)' ).addClass( 'et_pb_column_single' ); 3673 }); 3674 } 3675 3676 /** 3677 * In particular browser, map + parallax doesn't play well due the use of CSS 3D transform 3678 */ 3679 if ( $('.et_pb_section_parallax').length && $('.et_pb_map').length ) { 3680 $('body').addClass( 'parallax-map-support' ); 3681 } 3682 3683 /** 3684 * Add conditional class for search widget in sidebar module 3685 */ 3686 $('.et_pb_widget_area ' + et_pb_custom.widget_search_selector ).each( function() { 3687 var $search_wrap = $(this), 3688 $search_input_submit = $search_wrap.find('input[type="submit"]'), 3689 search_input_submit_text = $search_input_submit.attr( 'value' ), 3690 $search_button = $search_wrap.find('button'), 3691 search_button_text = $search_button.text(), 3692 has_submit_button = $search_input_submit.length || $search_button.length ? true : false, 3693 min_column_width = 150; 3694 3695 if ( ! $search_wrap.find( 'input[type="text"]' ).length && ! $search_wrap.find( 'input[type="search"]' ).length ) { 3696 return; 3697 } 3698 3699 // Mark no button state 3700 if ( ! has_submit_button ) { 3701 $search_wrap.addClass( 'et-no-submit-button' ); 3702 } 3703 3704 // Mark narrow state 3705 if ( $search_wrap.width() < 150 ) { 3706 $search_wrap.addClass( 'et-narrow-wrapper' ); 3707 } 3708 3709 // Fixes issue where theme's search button has no text: treat it as non-existent 3710 if ( $search_input_submit.length && ( typeof search_input_submit_text == 'undefined' || search_input_submit_text === '' ) ) { 3711 $search_input_submit.remove(); 3712 $search_wrap.addClass( 'et-no-submit-button' ); 3713 } 3714 3715 if ( $search_button.length && ( typeof search_button_text == 'undefined' || search_button_text === '' ) ) { 3716 $search_button.remove(); 3717 $search_wrap.addClass( 'et-no-submit-button' ); 3718 } 3719 3720 } ); 3721 3722 if ( $( '.et_pb_search' ).length ) { 3723 $( '.et_pb_search' ).each( function() { 3724 var $this_module = $( this ), 3725 $input_field = $this_module.find( '.et_pb_s' ), 3726 $button = $this_module.find( '.et_pb_searchsubmit' ), 3727 input_padding = $this_module.hasClass( 'et_pb_text_align_right' ) ? 'paddingLeft' : 'paddingRight', 3728 disabled_button = $this_module.hasClass( 'et_pb_hide_search_button' ); 3729 3730 if ( $button.innerHeight() > $input_field.innerHeight() ) { 3731 $input_field.height( $button.innerHeight() ); 3732 } 3733 3734 if ( ! disabled_button ) { 3735 $input_field.css( input_padding, $button.innerWidth() + 10 ); 3736 } 3737 }); 3738 } 3739 3740 // apply required classes for the Reply buttons in Comments Module 3741 if ( $( '.et_pb_comments_module' ).length ) { 3742 $( '.et_pb_comments_module' ).each( function() { 3743 var $comments_module = $( this ), 3744 $comments_module_button = $comments_module.find( '.comment-reply-link' ); 3745 3746 if ( $comments_module_button.length ) { 3747 $comments_module_button.addClass( 'et_pb_button' ); 3748 3749 if ( typeof $comments_module.data( 'icon' ) !== 'undefined' ) { 3750 $comments_module_button.attr( 'data-icon', $comments_module.data( 'icon' ) ); 3751 $comments_module_button.addClass( 'et_pb_custom_button_icon' ); 3752 } 3753 } 3754 }); 3755 } 3756 3757 /** 3758 * Provide event listener for plugins to hook up to 3759 */ 3760 $(document).trigger('et_pb_after_init_modules'); 3761 }); 3762 } 3763 3764 // Modification of underscore's _.debounce() 3765 // Underscore.js 1.8.3 3766 // http://underscorejs.org
3767 // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 3768 // Underscore may be freely distributed under the MIT license. 3769 window.et_pb_debounce = function(func, wait, immediate) { 3770 var timeout, args, context, timestamp, result; 3771 3772 var now = Date.now || new Date().getTime(); 3773 3774 var later = function() { 3775 var last = now - timestamp; 3776 3777 if (last < wait && last >= 0) { 3778 timeout = setTimeout(later, wait - last); 3779 } else { 3780 timeout = null; 3781 if (!immediate) { 3782 result = func.apply(context, args); 3783 if (!timeout) context = args = null; 3784 } 3785 } 3786 }; 3787 3788 return function() { 3789 context = this; 3790 args = arguments; 3791 timestamp = now; 3792 var callNow = immediate && !timeout; 3793 if (!timeout) timeout = setTimeout(later, wait); 3794 if (callNow) { 3795 result = func.apply(context, args); 3796 context = args = null; 3797 } 3798 3799 return result; 3800 }; 3801 }; 3802 3803 if ( et_pb_custom.is_ab_testing_active && 'yes' === et_pb_custom.is_cache_plugin_active ) { 3804 // update the window.et_load_event_fired variable to initiate the scripts properly 3805 $( window ).load( function() { 3806 window.et_load_event_fired = true; 3807 }); 3808 3809 // get the subject id for current visitor and display it 3810 // this ajax request performed only if split testing is enabled and cache plugin active 3811 $.ajax( { 3812 type: "POST", 3813 url: et_pb_custom.ajaxurl, 3814 dataType: "json", 3815 data: 3816 { 3817 action : 'et_pb_ab_get_subject_id', 3818 et_frontend_nonce : et_pb_custom.et_frontend_nonce, 3819 et_pb_ab_test_id : et_pb_custom.page_id 3820 }, 3821 success: function( subject_data ) { 3822 if ( subject_data ) { 3823 // append the subject content to appropriate placeholder 3824 $( '.et_pb_subject_placeholder_id_' + subject_data.id ).after( subject_data.content ); 3825 // remove all other placeholders from the DOM 3826 $( '.et_pb_subject_placeholder' ).remove(); 3827 3828 // init all scripts once the subject loaded 3829 window.et_pb_init_modules(); 3830 $( 'body' ).trigger( 'et_pb_ab_subject_ready' ); 3831 } 3832 } 3833 }); 3834 } else { 3835 window.et_pb_init_modules(); 3836 } 3837})(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.