').insertBefore( $active_carousel_group );
$prev_carousel_group.css({ 'left': '-' + $active_carousel_group.innerWidth(), 'width': $active_carousel_group.innerWidth() }).show();
// this is an endless loop, so it can decide internally when to break out, so that next_position
// can get filled up, even to the extent of an element having both and current_ and next_ position
for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) {
if ( total <= active_items_start && total >= active_items_end ) {
$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
$( items[x] ).data('current_position', current_position );
current_position--;
}
if ( total <= prev_items_start && total >= prev_items_end ) {
$( items[x] ).data('prev_position', prev_position );
$( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position );
if ( !$( items[x] ).hasClass( 'current_position' ) ) {
$( items[x] ).addClass('container_append');
} else {
$( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
$( items[x] ).addClass('delayed_container_append');
}
prev_position--;
}
if ( prev_position <= 0 ) {
break;
}
if ( x == 0 ) {
x = items.length;
}
}
sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
var el_a_position = parseInt( $(a).data('prev_position') );
var el_b_position = parseInt( $(b).data('prev_position') );
return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
});
$( sorted ).show().appendTo( $prev_carousel_group );
$prev_carousel_group.children().each(function(){
$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) });
});
$active_carousel_group.animate({
left: '100%'
}, {
duration: slide_duration,
complete: function() {
$portfolio_items.find('.delayed_container_append').reverse().each(function(){
$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) });
$(this).prependTo( $prev_carousel_group );
});
$active_carousel_group.removeClass('active');
$active_carousel_group.children().each(function(){
position = $(this).data('position');
current_position = $(this).data('current_position');
$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
$(this).data('position', '');
$(this).data('current_position', '');
$(this).hide();
$(this).css({'position': '', 'width': '', 'left': ''});
$(this).appendTo( $portfolio_items );
});
$active_carousel_group.remove();
}
} );
$prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '-100%'});
$prev_carousel_group.animate({
left: '0%'
}, {
duration: slide_duration,
complete: function(){
setTimeout(function(){
$prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
$prev_carousel_group.find('.delayed_container_append_dup').remove();
$prev_carousel_group.find('.changing_position').each(function( index ){
position = $(this).data('position');
current_position = $(this).data('current_position');
prev_position = $(this).data('prev_position');
$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position );
$(this).data('current_position', '');
$(this).data('prev_position', '');
position = index + 1;
$(this).data('position', position );
$(this).addClass('position_' + position );
});
$prev_carousel_group.children().css({'position': '', 'width': original_item_width, 'left': ''});
$the_portfolio.data('carouseling', false);
}, 100 );
}
} );
}
}
function set_fullwidth_portfolio_columns( $the_portfolio, carousel_mode ) {
var columns,
$portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'),
portfolio_items_width = $portfolio_items.width(),
$the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'),
portfolio_item_count = $the_portfolio_items.length;
if ('undefined' === typeof $the_portfolio_items) {
return;
}
// calculate column breakpoints
if ( portfolio_items_width >= 1600 ) {
columns = 5;
} else if ( portfolio_items_width >= 1024 ) {
columns = 4;
} else if ( portfolio_items_width >= 768 ) {
columns = 3;
} else if ( portfolio_items_width >= 480 ) {
columns = 2;
} else {
columns = 1;
}
// set height of items
portfolio_item_width = portfolio_items_width / columns;
portfolio_item_height = portfolio_item_width * .75;
if ( carousel_mode ) {
$portfolio_items.css({ 'height' : portfolio_item_height });
}
$the_portfolio_items.css({ 'height' : portfolio_item_height });
if ( columns === $portfolio_items.data('portfolio-columns') ) {
return;
}
if ( $the_portfolio.data('columns_setting_up') ) {
return;
}
$the_portfolio.data('columns_setting_up', true );
var portfolio_item_width_percentage = ( 100 / columns ) + '%';
$the_portfolio_items.css({ 'width' : portfolio_item_width_percentage });
// store last setup column
$portfolio_items.removeClass('columns-' + $portfolio_items.data('portfolio-columns') );
$portfolio_items.addClass('columns-' + columns );
$portfolio_items.data('portfolio-columns', columns );
if ( !carousel_mode ) {
return $the_portfolio.data('columns_setting_up', false );
}
// kill all previous groups to get ready to re-group
if ( $portfolio_items.find('.et_pb_carousel_group').length ) {
$the_portfolio_items.appendTo( $portfolio_items );
$portfolio_items.find('.et_pb_carousel_group').remove();
}
// setup the grouping
var the_portfolio_items = $portfolio_items.data('items' ),
$carousel_group = $('
').appendTo( $portfolio_items );
if ('undefined' === typeof the_portfolio_items) {
return;
}
$the_portfolio_items.data('position', '');
if ( the_portfolio_items.length <= columns ) {
$portfolio_items.find('.et-pb-slider-arrows').hide();
} else {
$portfolio_items.find('.et-pb-slider-arrows').show();
}
for ( position = 1, x=0 ;x < the_portfolio_items.length; x++, position++ ) {
if ( x < columns ) {
$( the_portfolio_items[x] ).show();
$( the_portfolio_items[x] ).appendTo( $carousel_group );
$( the_portfolio_items[x] ).data('position', position );
$( the_portfolio_items[x] ).addClass('position_' + position );
} else {
position = $( the_portfolio_items[x] ).data('position');
$( the_portfolio_items[x] ).removeClass('position_' + position );
$( the_portfolio_items[x] ).data('position', '' );
$( the_portfolio_items[x] ).hide();
}
}
$the_portfolio.data('columns_setting_up', false );
}
function et_carousel_auto_rotate( $carousel ) {
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' ) ) {
et_carousel_timer = setTimeout( function() {
fullwidth_portfolio_carousel_slide( $carousel.find('.et-pb-arrow-next') );
}, $carousel.data('auto-rotate-speed') );
$carousel.data('et_carousel_timer', et_carousel_timer);
}
}
$et_pb_fullwidth_portfolio.each(function(){
et_fullwidth_portfolio_init( $(this) );
});
}
function et_audio_module_set() {
if ( $( '.et_pb_audio_module .mejs-audio' ).length || $( '.et_audio_content .mejs-audio' ).length ) {
$( '.et_audio_container' ).each( function(){
et_pb_audio_module_init( $(this) );
});
}
}
window.et_pb_audio_module_init = function( $audio_container ) {
var $this_player = $audio_container,
$time_rail = $this_player.find( '.mejs-time-rail' ),
$time_slider = $this_player.find( '.mejs-time-slider' );
// remove previously added width and min-width attributes to calculate the new sizes accurately
$time_rail.removeAttr( 'style' );
$time_slider.removeAttr( 'style' );
var $count_timer = $this_player.find( 'div.mejs-currenttime-container' ),
$count_timer_width_container = $this_player.find( '.mejs-duration-container' ).length ? $this_player.find( '.mejs-duration-container' ) : $this_player.find( '.mejs-currenttime-container' ),
player_width = $this_player.width(),
controls_play_width = $this_player.find( '.mejs-play' ).outerWidth(),
time_width = $count_timer_width_container.outerWidth(),
volume_icon_width = $this_player.find( '.mejs-volume-button' ).outerWidth(),
volume_bar_width = $this_player.find( '.mejs-horizontal-volume-slider' ).outerWidth(),
new_time_rail_width;
$count_timer.addClass( 'custom' );
$this_player.find( '.mejs-controls div.mejs-duration-container' ).replaceWith( $count_timer );
new_time_rail_width = player_width - ( controls_play_width + time_width + volume_icon_width + volume_bar_width + 65 );
if ( 0 < new_time_rail_width ) {
$time_rail.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' );
$time_slider.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' );
}
}
if ( $('.et_pb_section_video').length ) {
window._wpmejsSettings.pauseOtherPlayers = false;
}
if ( $et_pb_filterable_portfolio.length || is_frontend_builder ) {
window.et_pb_filterable_portfolio_init = function( $selector ) {
if ( typeof $selector !== 'undefined' ){
set_filterable_portfolio_init( $selector );
} else {
$et_pb_filterable_portfolio.each(function(){
set_filterable_portfolio_init( $(this) )
});
}
}
window.set_filterable_portfolio_init = function( $the_portfolio ) {
var $the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'),
$left_orientatation = true == $the_portfolio.data( 'rtl' ) ? false : true,
all_portfolio_items = $the_portfolio_items.clone(); // cache for all the portfolio items
$the_portfolio.show();
set_filterable_grid_items( $the_portfolio );
$the_portfolio.on('click', '.et_pb_portfolio_filter a', function(e){
e.preventDefault();
var category_slug = $(this).data('category-slug');
$the_portfolio_items = $(this).parents('.et_pb_filterable_portfolio').find('.et_pb_portfolio_items');
if ( 'all' == category_slug ) {
$the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active');
$the_portfolio.find('.et_pb_portfolio_filter_all a').addClass('active');
// remove all items from the portfolio items container
$the_portfolio_items.empty();
// fill the portfolio items container with cached items from memory
$the_portfolio_items.append( all_portfolio_items.find( '.et_pb_portfolio_item' ).clone() );
$the_portfolio.find('.et_pb_portfolio_item').addClass('active');
} else {
$the_portfolio.find('.et_pb_portfolio_filter_all').removeClass('active');
$the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active');
$the_portfolio.find('.et_pb_portfolio_filter_all a').removeClass('active');
$(this).addClass('active');
// remove all items from the portfolio items container
$the_portfolio_items.empty();
// fill the portfolio items container with cached items from memory
$the_portfolio_items.append( all_portfolio_items.find( '.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).clone() );
$the_portfolio_items.find('.et_pb_portfolio_item').removeClass('active');
$the_portfolio_items.find('.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).addClass('active').removeClass( 'inactive' );
}
set_filterable_grid_items( $the_portfolio );
setTimeout(function(){
set_filterable_portfolio_hash( $the_portfolio );
}, 500 );
});
$the_portfolio.on('click', '.et_pb_portofolio_pagination a', function(e){
e.preventDefault();
var to_page = $(this).data('page'),
$the_portfolio = $(this).parents('.et_pb_filterable_portfolio'),
$the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items');
et_pb_smooth_scroll( $the_portfolio, false, 800 );
if ( $(this).hasClass('page-prev') ) {
to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1;
} else if ( $(this).hasClass('page-next') ) {
to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1;
}
$(this).parents('ul').find('a').removeClass('active');
$(this).parents('ul').find('a.page-' + to_page ).addClass('active');
var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(),
total_pages = $(this).parents('ul').find('li.page').length;
$(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show();
$(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show();
$(this).parents('ul').find('li.page').each(function(i){
if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) {
if ( i < ( current_index - 3 ) ) {
$(this).hide();
} else if ( i > ( current_index + 1 ) ) {
$(this).hide();
} else {
$(this).show();
}
if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) {
$(this).show();
} else if ( current_index <= 3 && i <= 4 ) {
$(this).show();
}
}
});
if ( to_page > 1 ) {
$(this).parents('ul').find('li.prev').show();
} else {
$(this).parents('ul').find('li.prev').hide();
}
if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) {
$(this).parents('ul').find('li.next').hide();
} else {
$(this).parents('ul').find('li.next').show();
}
$the_portfolio.find('.et_pb_portfolio_item').hide();
$the_portfolio.find('.et_pb_portfolio_item').filter(function( index ) {
return $(this).data('page') === to_page;
}).show();
window.et_pb_set_responsive_grid( $the_portfolio.find( '.et_pb_portfolio_items' ), '.et_pb_portfolio_item' );
setTimeout(function(){
set_filterable_portfolio_hash( $the_portfolio );
}, 500 );
});
$(this).on('et_hashchange', function( event ){
var params = event.params;
$the_portfolio = $( '#' + event.target.id );
if ( !$the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').hasClass('active') ) {
$the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').click();
}
if ( params[1] ) {
setTimeout(function(){
if ( !$the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).hasClass('active') ) {
$the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).addClass('active').click();
}
}, 300 );
}
});
}
// init portfolio if .load event was fired already, wait for the window load otherwise.
if ( window.et_load_event_fired ) {
et_pb_filterable_portfolio_init();
} else {
$(window).load(function(){
et_pb_filterable_portfolio_init();
}); // End $(window).load()
}
function set_filterable_grid_items( $the_portfolio ) {
var active_category = $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug');
window.et_pb_set_responsive_grid( $the_portfolio.find( '.et_pb_portfolio_items' ), '.et_pb_portfolio_item' );
if ( 'all' === active_category ) {
$the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item');
} else {
$the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item.project_category_' + active_category);
}
var visible_grid_items = $the_portfolio_visible_items.length,
posts_number = $the_portfolio.data('posts-number'),
pages = 0 === posts_number ? 1 : Math.ceil( visible_grid_items / posts_number );
set_filterable_grid_pages( $the_portfolio, pages );
var visible_grid_items = 0;
var _page = 1;
$the_portfolio.find('.et_pb_portfolio_item').data('page', '');
$the_portfolio_visible_items.each(function(i){
visible_grid_items++;
if ( 0 === parseInt( visible_grid_items % posts_number ) ) {
$(this).data('page', _page);
_page++;
} else {
$(this).data('page', _page);
}
});
$the_portfolio_visible_items.filter(function() {
return $(this).data('page') == 1;
}).show();
$the_portfolio_visible_items.filter(function() {
return $(this).data('page') != 1;
}).hide();
}
function set_filterable_grid_pages( $the_portfolio, pages ) {
$pagination = $the_portfolio.find('.et_pb_portofolio_pagination');
if ( !$pagination.length ) {
return;
}
$pagination.html('
');
if ( pages <= 1 ) {
return;
}
$pagination_list = $pagination.children('ul');
$pagination_list.append('
' + et_pb_custom.prev + '');
for( var page = 1; page <= pages; page++ ) {
var first_page_class = page === 1 ? ' active' : '',
last_page_class = page === pages ? ' last-page' : '',
hidden_page_class = page >= 5 ? ' style="display:none;"' : '';
$pagination_list.append('
' + page + '');
}
$pagination_list.append('
' + et_pb_custom.next + '');
}
function set_filterable_portfolio_hash( $the_portfolio ) {
if ( !$the_portfolio.attr('id') ) {
return;
}
var this_portfolio_state = [];
this_portfolio_state.push( $the_portfolio.attr('id') );
this_portfolio_state.push( $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug') );
if ( $the_portfolio.find('.et_pb_portofolio_pagination a.active').length ) {
this_portfolio_state.push( $the_portfolio.find('.et_pb_portofolio_pagination a.active').data('page') );
} else {
this_portfolio_state.push( 1 );
}
this_portfolio_state = this_portfolio_state.join( et_hash_module_param_seperator );
et_set_hash( this_portfolio_state );
}
} /* end if ( $et_pb_filterable_portfolio.length ) */
if ( $et_pb_gallery.length || is_frontend_builder ) {
window.set_gallery_grid_items = function( $the_gallery ) {
var $the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'),
$the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item');
var total_grid_items = $the_gallery_items.length,
posts_number_original = parseInt( $the_gallery_items_container.attr('data-per_page') ),
posts_number = isNaN( posts_number_original ) || 0 === posts_number_original ? 4 : posts_number_original,
pages = Math.ceil( total_grid_items / posts_number );
set_gallery_grid_pages( $the_gallery, pages );
var total_grid_items = 0;
var _page = 1;
$the_gallery_items.data('page', '');
$the_gallery_items.each(function(i){
total_grid_items++;
if ( 0 === parseInt( total_grid_items % posts_number ) ) {
$(this).data('page', _page);
_page++;
} else {
$(this).data('page', _page);
}
});
var visible_items = $the_gallery_items.filter(function() {
return $(this).data('page') == 1;
}).show();
$the_gallery_items.filter(function() {
return $(this).data('page') != 1;
}).hide();
}
window.set_gallery_grid_pages = function( $the_gallery, pages ) {
$pagination = $the_gallery.find('.et_pb_gallery_pagination');
if ( !$pagination.length ) {
return;
}
$pagination.html('
');
if ( pages <= 1 ) {
$pagination.hide();
return;
}
$pagination_list = $pagination.children('ul');
$pagination_list.append('
' + et_pb_custom.prev + '');
for( var page = 1; page <= pages; page++ ) {
var first_page_class = page === 1 ? ' active' : '',
last_page_class = page === pages ? ' last-page' : '',
hidden_page_class = page >= 5 ? ' style="display:none;"' : '';
$pagination_list.append('
' + page + '');
}
$pagination_list.append('
' + et_pb_custom.next + '');
}
window.set_gallery_hash = function( $the_gallery ) {
if ( !$the_gallery.attr('id') ) {
return;
}
var this_gallery_state = [];
this_gallery_state.push( $the_gallery.attr('id') );
if ( $the_gallery.find('.et_pb_gallery_pagination a.active').length ) {
this_gallery_state.push( $the_gallery.find('.et_pb_gallery_pagination a.active').data('page') );
} else {
this_gallery_state.push( 1 );
}
this_gallery_state = this_gallery_state.join( et_hash_module_param_seperator );
et_set_hash( this_gallery_state );
}
window.et_pb_gallery_init = function( $the_gallery ) {
if ( $the_gallery.hasClass( 'et_pb_gallery_grid' ) ) {
$the_gallery.show();
set_gallery_grid_items( $the_gallery );
$the_gallery.on('et_hashchange', function( event ){
var params = event.params;
$the_gallery = $( '#' + event.target.id );
if ( page_to = params[0] ) {
if ( !$the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).hasClass('active') ) {
$the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).addClass('active').click();
}
}
});
}
}
$et_pb_gallery.each(function(){
var $the_gallery = $(this);
et_pb_gallery_init( $the_gallery );
});
$et_pb_gallery.data('paginating', false );
window.et_pb_gallery_pagination_nav = function( $the_gallery ) {
$the_gallery.on('click', '.et_pb_gallery_pagination a', function(e){
e.preventDefault();
var to_page = $(this).data('page'),
$the_gallery = $(this).parents('.et_pb_gallery'),
$the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'),
$the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item');
if ( $the_gallery.data('paginating') ) {
return;
}
$the_gallery.data('paginating', true );
if ( $(this).hasClass('page-prev') ) {
to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1;
} else if ( $(this).hasClass('page-next') ) {
to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1;
}
$(this).parents('ul').find('a').removeClass('active');
$(this).parents('ul').find('a.page-' + to_page ).addClass('active');
var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(),
total_pages = $(this).parents('ul').find('li.page').length;
$(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show();
$(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show();
$(this).parents('ul').find('li.page').each(function(i){
if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) {
if ( i < ( current_index - 3 ) ) {
$(this).hide();
} else if ( i > ( current_index + 1 ) ) {
$(this).hide();
} else {
$(this).show();
}
if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) {
$(this).show();
} else if ( current_index <= 3 && i <= 4 ) {
$(this).show();
}
}
});
if ( to_page > 1 ) {
$(this).parents('ul').find('li.prev').show();
} else {
$(this).parents('ul').find('li.prev').hide();
}
if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) {
$(this).parents('ul').find('li.next').hide();
} else {
$(this).parents('ul').find('li.next').show();
}
$the_gallery_items.hide();
var visible_items = $the_gallery_items.filter(function( index ) {
return $(this).data('page') === to_page;
}).show();
$the_gallery.data('paginating', false );
window.et_pb_set_responsive_grid( $the_gallery_items_container, '.et_pb_gallery_item' );
setTimeout(function(){
set_gallery_hash( $the_gallery );
}, 100 );
$( 'html, body' ).animate( { scrollTop : $the_gallery.offset().top - 200 }, 200 );
});
}
et_pb_gallery_pagination_nav( $et_pb_gallery );
// Frontend builder's interface wouldn't be able to use $et_pb_gallery as selector
// due to its react component's nature. Using more global selector works.
if ( is_frontend_builder ) {
et_pb_gallery_pagination_nav( $('#et-fb-app') );
}
} /* end if ( $et_pb_gallery.length ) */
if ( $et_pb_counter_amount.length ) {
$et_pb_counter_amount.each(function(){
window.et_bar_counters_init( $( this ) );
});
} /* $et_pb_counter_amount.length */
window.et_countdown_timer = function( timer ) {
var end_date = parseInt( timer.attr( 'data-end-timestamp') ),
current_date = new Date().getTime() / 1000,
seconds_left = ( end_date - current_date );
days = parseInt(seconds_left / 86400);
days = days > 0 ? days : 0;
seconds_left = seconds_left % 86400;
hours = parseInt(seconds_left / 3600);
hours = hours > 0 ? hours : 0;
seconds_left = seconds_left % 3600;
minutes = parseInt(seconds_left / 60);
minutes = minutes > 0 ? minutes : 0;
seconds = parseInt(seconds_left % 60);
seconds = seconds > 0 ? seconds : 0;
var $days_section = timer.find('.days > .value').parent('.section'),
$hours_section = timer.find('.hours > .value').parent('.section'),
$minutes_section = timer.find('.minutes > .value').parent('.section'),
$seconds_section = timer.find('.seconds > .value').parent('.section');
if ( days == 0 ) {
if ( ! $days_section.hasClass('zero') ) {
timer.find('.days > .value').html( '000' ).parent('.section').addClass('zero').next().addClass('zero');
}
} else {
days_slice = days.toString().length >= 3 ? days.toString().length : 3;
timer.find('.days > .value').html( ('000' + days).slice(-days_slice) );
if ( $days_section.hasClass('zero') ) {
$days_section.removeClass('zero').next().removeClass('zero');
}
}
if ( days == 0 && hours == 0 ) {
if ( ! $hours_section.hasClass('zero') ) {
timer.find('.hours > .value').html('00').parent('.section').addClass('zero').next().addClass('zero');
}
} else {
timer.find('.hours > .value').html( ( '0' + hours ).slice(-2) );
if ( $hours_section.hasClass('zero') ) {
$hours_section.removeClass('zero').next().removeClass('zero');
}
}
if ( days == 0 && hours == 0 && minutes == 0 ) {
if ( ! $minutes_section.hasClass('zero') ) {
timer.find('.minutes > .value').html('00').parent('.section').addClass('zero').next().addClass('zero');
}
} else {
timer.find('.minutes > .value').html( ( '0' + minutes ).slice(-2) );
if ( $minutes_section.hasClass('zero') ) {
$minutes_section.removeClass('zero').next().removeClass('zero');
}
}
if ( days == 0 && hours == 0 && minutes == 0 && seconds == 0 ) {
if ( ! $seconds_section.hasClass('zero') ) {
timer.find('.seconds > .value').html('00').parent('.section').addClass('zero');
}
} else {
timer.find('.seconds > .value').html( ( '0' + seconds ).slice(-2) );
if ( $seconds_section.hasClass('zero') ) {
$seconds_section.removeClass('zero').next().removeClass('zero');
}
}
}
window.et_countdown_timer_labels = function( timer ) {
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 ) {
timer.find('.days .label').html( timer.find('.days').data('short') );
timer.find('.hours .label').html( timer.find('.hours').data('short') );
timer.find('.minutes .label').html( timer.find('.minutes').data('short') );
timer.find('.seconds .label').html( timer.find('.seconds').data('short') );
} else {
timer.find('.days .label').html( timer.find('.days').data('full') );
timer.find('.hours .label').html( timer.find('.hours').data('full') );
timer.find('.minutes .label').html( timer.find('.minutes').data('full') );
timer.find('.seconds .label').html( timer.find('.seconds').data('full') );
}
}
if ( $et_pb_countdown_timer.length || is_frontend_builder ) {
window.et_pb_countdown_timer_init = function( $et_pb_countdown_timer ) {
$et_pb_countdown_timer.each(function(){
var timer = $(this);
et_countdown_timer_labels( timer );
et_countdown_timer( timer );
setInterval(function(){
et_countdown_timer( timer );
}, 1000);
});
}
et_pb_countdown_timer_init( $et_pb_countdown_timer );
}
if ( $et_pb_tabs.length || is_frontend_builder ) {
window.et_pb_tabs_init = function( $et_pb_tabs ) {
var $et_pb_tabs_li = $et_pb_tabs.find( '.et_pb_tabs_controls li' );
$et_pb_tabs.et_pb_simple_slider( {
use_controls : false,
use_arrows : false,
slide : '.et_pb_all_tabs > div',
tabs_animation : true
} ).on('et_hashchange', function( event ){
var params = event.params;
var $the_tabs = $( '#' + event.target.id );
var active_tab = params[0];
if ( !$the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).hasClass('et_pb_tab_active') ) {
$the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).click();
}
});
$et_pb_tabs_li.click( function() {
var $this_el = $(this),
$tabs_container = $this_el.closest( '.et_pb_tabs' ).data('et_pb_simple_slider');
if ( $tabs_container.et_animation_running ) return false;
$this_el.addClass( 'et_pb_tab_active' ).siblings().removeClass( 'et_pb_tab_active' );
$tabs_container.data('et_pb_simple_slider').et_slider_move_to( $this_el.index() );
if ( $this_el.closest( '.et_pb_tabs' ).attr('id') ) {
var tab_state = [];
tab_state.push( $this_el.closest( '.et_pb_tabs' ).attr('id') );
tab_state.push( $this_el.index() );
tab_state = tab_state.join( et_hash_module_param_seperator );
et_set_hash( tab_state );
}
return false;
} );
window.et_pb_set_tabs_height();
}
window.et_pb_tabs_init( $et_pb_tabs );
}
if ( $et_pb_map.length || is_frontend_builder ) {
function et_pb_init_maps() {
$et_pb_map.each(function(){
et_pb_map_init( $(this) );
});
}
window.et_pb_map_init = function( $this_map_container ) {
if (typeof google === 'undefined') {
return;
}
var $this_map = $this_map_container.children('.et_pb_map'),
this_map_grayscale = $this_map_container.attr( 'data-grayscale' ) || 0,
is_draggable = ( et_is_mobile_device && $this_map.data('mobile-dragging') !== 'off' ) || ! et_is_mobile_device,
infowindow_active;
if ( this_map_grayscale !== 0 ) {
this_map_grayscale = '-' + this_map_grayscale.toString();
}
$this_map_container.data('map', new google.maps.Map( $this_map[0], {
zoom: parseInt( $this_map.attr('data-zoom') ),
center: new google.maps.LatLng( parseFloat( $this_map.attr('data-center-lat') ) , parseFloat( $this_map.attr('data-center-lng') )),
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: $this_map.attr('data-mouse-wheel') == 'on' ? true : false,
draggable: is_draggable,
panControlOptions: {
position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP
},
zoomControlOptions: {
position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP
},
styles: [ {
stylers: [
{ saturation: parseInt( this_map_grayscale ) }
]
} ]
}));
$this_map_container.find('.et_pb_map_pin').each(function(){
var $this_marker = $(this);
var marker = new google.maps.Marker({
position: new google.maps.LatLng( parseFloat( $this_marker.attr('data-lat') ) , parseFloat( $this_marker.attr('data-lng') ) ),
map: $this_map_container.data('map'),
title: $this_marker.attr('data-title'),
icon: { url: et_pb_custom.builder_images_uri + '/marker.png', size: new google.maps.Size( 46, 43 ), anchor: new google.maps.Point( 16, 43 ) },
shape: { coord: [1, 1, 46, 43], type: 'rect' },
anchorPoint: new google.maps.Point(0, -45)
});
if ( $this_marker.find('.infowindow').length ) {
var infowindow = new google.maps.InfoWindow({
content: $this_marker.html()
});
google.maps.event.addListener( $this_map_container.data('map'), 'click', function() {
infowindow.close();
});
google.maps.event.addListener(marker, 'click', function() {
if( infowindow_active ) {
infowindow_active.close();
}
infowindow_active = infowindow;
infowindow.open( $this_map_container.data('map'), marker );
});
}
});
}
if ( window.et_load_event_fired ) {
et_pb_init_maps();
} else {
if ( typeof google !== 'undefined' ) {
google.maps.event.addDomListener(window, 'load', function() {
et_pb_init_maps();
} );
}
}
}
if ( $et_pb_shop.length ) {
$et_pb_shop.each( function() {
var $this_el = $(this),
icon = $this_el.data('icon') || '';
if ( icon === '' ) {
return true;
}
$this_el.find( '.et_overlay' )
.attr( 'data-icon', icon )
.addClass( 'et_pb_inline_icon' );
} );
}
if ( $et_pb_circle_counter.length || is_frontend_builder ) {
window.et_pb_circle_counter_init = function($the_counter, animate) {
if ( 0 === $the_counter.width() ) {
return;
}
$the_counter.easyPieChart({
animate: {
duration: 1800,
enabled: true
},
size: 0 !== $the_counter.width() ? $the_counter.width() : 10, // set the width to 10 if actual width is 0 to avoid js errors
barColor: $the_counter.data( 'bar-bg-color' ),
trackColor: $the_counter.data( 'color' ) || '#000000',
trackAlpha: $the_counter.data( 'alpha' ) || '0.1',
scaleColor: false,
lineWidth: 5,
onStart: function() {
$(this.el).find('.percent p').css({ 'visibility' : 'visible' });
},
onStep: function(from, to, percent) {
$(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) );
},
onStop: function(from, to) {
$(this.el).find('.percent-value').text( $(this.el).data('number-value') );
}
});
}
window.et_pb_reinit_circle_counters = function( $et_pb_circle_counter ) {
$et_pb_circle_counter.each(function(){
var $the_counter = $(this);
window.et_pb_circle_counter_init($the_counter, false);
$the_counter.on('containerWidthChanged', function( event ){
$the_counter = $( event.target );
$the_counter.find('canvas').remove();
$the_counter.removeData('easyPieChart' );
window.et_pb_circle_counter_init($the_counter, true);
});
});
}
window.et_pb_reinit_circle_counters( $et_pb_circle_counter );
}
if ( $et_pb_number_counter.length || is_frontend_builder ) {
window.et_pb_reinit_number_counters = function( $et_pb_number_counter ) {
function et_format_number( number_value, separator ) {
return number_value.toString().replace( /\B(?=(\d{3})+(?!\d))/g, separator );
}
if ( $.fn.fitText ) {
$et_pb_number_counter.find( '.percent p' ).fitText( 0.3 );
}
$et_pb_number_counter.each(function(){
var $this_counter = $(this);
var separator = $this_counter.data('number-separator');
$this_counter.easyPieChart({
animate: {
duration: 1800,
enabled: true
},
size: 0,
trackColor: false,
scaleColor: false,
lineWidth: 0,
onStart: function() {
$(this.el).find('.percent p').css({ 'visibility' : 'visible' });
},
onStep: function(from, to, percent) {
if ( percent != to )
$(this.el).find('.percent-value').text( et_format_number( Math.round( parseInt( percent ) ), separator ) );
},
onStop: function(from, to) {
$(this.el).find('.percent-value').text( et_format_number( $(this.el).data('number-value'), separator ) );
}
});
});
}
window.et_pb_reinit_number_counters( $et_pb_number_counter );
}
window.et_apply_parallax = function() {
if ( ! $(this).length || typeof $(this) === 'undefined' || typeof $(this).offset() === 'undefined') {
return;
}
var $this = $(this),
element_top = $this.offset().top,
window_top = $et_window.scrollTop(),
y_pos = ( ( ( window_top + $et_window.height() ) - element_top ) * 0.3 ),
main_position;
main_position = 'translate(0, ' + y_pos + 'px)';
$this.children('.et_parallax_bg').css( {
'-webkit-transform' : main_position,
'-moz-transform' : main_position,
'-ms-transform' : main_position,
'transform' : main_position
} );
}
window.et_parallax_set_height = function() {
var $this = $(this),
bg_height;
bg_height = ( $et_window.height() * 0.3 + $this.innerHeight() );
$this.find('.et_parallax_bg').css( { 'height' : bg_height } );
}
function et_toggle_animation_callback( initial_toggle_state, $module, $section ) {
if ( 'closed' === initial_toggle_state ) {
$module.removeClass('et_pb_toggle_close').addClass('et_pb_toggle_open');
} else {
$module.removeClass('et_pb_toggle_open').addClass('et_pb_toggle_close');
}
if ( $section.hasClass( 'et_pb_section_parallax' ) && !$section.children().hasClass( 'et_pb_parallax_css') ) {
$.proxy( et_parallax_set_height, $section )();
}
}
$( 'body' ).on( 'click', '.et_pb_toggle_title, .et_fb_toggle_overlay', function() {
var $this_heading = $(this),
$module = $this_heading.closest('.et_pb_toggle'),
$section = $module.parents( '.et_pb_section' ),
$content = $module.find('.et_pb_toggle_content'),
$accordion = $module.closest( '.et_pb_accordion' ),
is_accordion = $accordion.length,
is_accordion_toggling = $accordion.hasClass( 'et_pb_accordion_toggling' ),
window_offset_top = $(window).scrollTop(),
fixed_header_height = 0,
initial_toggle_state = $module.hasClass( 'et_pb_toggle_close' ) ? 'closed' : 'opened',
$accordion_active_toggle,
module_offset;
if ( is_accordion ) {
if ( $module.hasClass('et_pb_toggle_open') || is_accordion_toggling ) {
return false;
}
$accordion.addClass( 'et_pb_accordion_toggling' );
$accordion_active_toggle = $module.siblings('.et_pb_toggle_open');
}
if ( $content.is( ':animated' ) ) {
return;
}
if ( $('body').hasClass('safari') ) {
$content.fadeToggle( 700, function() {
et_toggle_animation_callback( initial_toggle_state, $module, $section );
} );
} else {
$content.slideToggle( 700, function() {
et_toggle_animation_callback( initial_toggle_state, $module, $section );
} );
}
if ( is_accordion ) {
$accordion_active_toggle.find('.et_pb_toggle_content').slideToggle( 700, function() {
$accordion_active_toggle.removeClass( 'et_pb_toggle_open' ).addClass('et_pb_toggle_close');
$accordion.removeClass( 'et_pb_accordion_toggling' );
module_offset = $module.offset();
// Calculate height of fixed nav
if ( $('#wpadminbar').length ) {
fixed_header_height += $('#wpadminbar').height();
}
if ( $('#top-header').length ) {
fixed_header_height += $('#top-header').height();
}
if ( $('#main-header').length && ! window.et_is_vertical_nav ) {
fixed_header_height += $('#main-header').height();
}
// Compare accordion offset against window's offset and adjust accordingly
if ( ( window_offset_top + fixed_header_height ) > module_offset.top ) {
$('html, body').animate({ scrollTop : ( module_offset.top - fixed_header_height - 50 ) });
}
} );
}
} );
var $et_contact_container = $( '.et_pb_contact_form_container' );
if ( $et_contact_container.length ) {
$et_contact_container.each( function() {
var $this_contact_container = $( this ),
$et_contact_form = $this_contact_container.find( 'form' ),
$et_contact_submit = $this_contact_container.find( 'input.et_pb_contact_submit' ),
$et_inputs = $et_contact_form.find( 'input[type=text], input[type=radio]:checked, textarea, .et_pb_contact_select' ),
et_email_reg = /^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$/,
redirect_url = typeof $this_contact_container.data( 'redirect_url' ) !== 'undefined' ? $this_contact_container.data( 'redirect_url' ) : '';
$et_contact_form.find( 'input[type=checkbox]' ).on( 'change', function() {
var $checkbox = $(this);
var $checkbox_field = $checkbox.siblings( 'input[type=text]:first' );
var is_checked = $checkbox.prop( 'checked' );
$checkbox_field.val( is_checked ? $checkbox_field.data( 'checked' ) : $checkbox_field.data( 'unchecked' ) );
} );
$et_contact_form.on( 'submit', function( event ) {
var $this_contact_form = $( this ),
$this_inputs = $this_contact_form.find( 'input[type=text], .et_pb_contact_field[data-type="checkbox"], .et_pb_contact_field[data-type="radio"], textarea, select' ),
this_et_contact_error = false,
$et_contact_message = $this_contact_form.closest( '.et_pb_contact_form_container' ).find( '.et-pb-contact-message' ),
et_message = '',
et_fields_message = '',
$this_contact_container = $this_contact_form.closest( '.et_pb_contact_form_container' ),
$captcha_field = $this_contact_form.find( '.et_pb_contact_captcha' ),
form_unique_id = typeof $this_contact_container.data( 'form_unique_num' ) !== 'undefined' ? $this_contact_container.data( 'form_unique_num' ) : 0,
inputs_list = [];
et_message = '
';
$this_inputs.removeClass( 'et_contact_error' );
$this_inputs.each( function(){
var $this_el = $( this );
var $this_wrapper = false;
// Prevent field processing if that field is not visible (conditional logic)
if ( ! $this_el.is(':visible') ) {
return;
}
if ( 'checkbox' === $this_el.data('type') ) {
$this_el = $this_el.find('input[type="checkbox"]');
$this_wrapper = $this_el.parents('.et_pb_contact_field');
}
if ( 'radio' === $this_el.data('type') ) {
$this_el = $this_el.find('input[type="radio"]');
$this_wrapper = $this_el.parents('.et_pb_contact_field');
}
var this_id = $this_el.attr( 'id' );
var this_val = $this_el.val();
var this_label = $this_el.siblings( 'label:first' ).text();
var field_type = typeof $this_el.data( 'field_type' ) !== 'undefined' ? $this_el.data( 'field_type' ) : 'text';
var required_mark = typeof $this_el.data( 'required_mark' ) !== 'undefined' ? $this_el.data( 'required_mark' ) : 'not_required';
var original_id = typeof $this_el.data( 'original_id' ) !== 'undefined' ? $this_el.data( 'original_id' ) : '';
var unchecked = false;
var default_value;
// Escape double quotes in label
this_label = this_label.replace(/"/g, """);
// radio field properties adjustment
if ( 'radio' === field_type ) {
if ( 0 !== $this_wrapper.find( 'input[type="radio"]').length ) {
field_type = 'radio';
var $firstRadio = $this_wrapper.find('input[type="radio"]:first');
required_mark = typeof $firstRadio.data( 'required_mark' ) !== 'undefined' ? $firstRadio.data( 'required_mark' ) : 'not_required';
original_id = typeof $firstRadio.data( 'original_id' ) !== 'undefined' ? $firstRadio.data( 'original_id' ) : '';
this_val = '';
if ( $this_wrapper.find('input[type="radio"]:checked') ) {
this_val = $this_wrapper.find('input[type="radio"]:checked').val();
}
}
this_label = $this_wrapper.find('.et_pb_contact_form_label').text();
this_id = $this_wrapper.find('input[type="radio"]:first').attr('name');
if ( 0 === $this_wrapper.find('input[type="radio"]:checked').length ) {
unchecked = true;
}
}
// checkbox field value adjustment
if ( 'checkbox' === field_type ) {
var $checkbox = $this_el;
var $handle = $checkbox.siblings('[data-checked][data-unchecked]');
this_id = $handle.attr('id');
this_val = $checkbox.prop('checked') ? $handle.data('checked') : $handle.data('unchecked');
unchecked = ! $checkbox.prop('checked');
$handle.val( this_val );
}
// add current field data into array of inputs
if ( typeof this_id !== 'undefined' ) {
inputs_list.push( { 'field_id' : this_id, 'original_id' : original_id, 'required_mark' : required_mark, 'field_type' : field_type, 'field_label' : this_label } );
}
// add error message for the field if it is required and empty
if ( 'required' === required_mark && ( '' === this_val || true === unchecked ) ) {
if ( false === $this_wrapper ) {
$this_el.addClass( 'et_contact_error' );
} else {
$this_wrapper.addClass( 'et_contact_error' );
}
this_et_contact_error = true;
default_value = this_label;
if ( '' === default_value ) {
default_value = et_pb_custom.captcha;
}
et_fields_message += '- ' + default_value + '
';
}
// add error message if email field is not empty and fails the email validation
if ( 'email' === field_type ) {
// remove trailing/leading spaces and convert email to lowercase
var processed_email = this_val.trim().toLowerCase();
var is_valid_email = et_email_reg.test( processed_email );
if ( '' !== processed_email && this_label !== processed_email && ! is_valid_email ) {
$this_el.addClass( 'et_contact_error' );
this_et_contact_error = true;
if ( ! is_valid_email ) {
et_message += '- ' + et_pb_custom.invalid + '
';
}
}
}
});
// check the captcha value if required for current form
if ( $captcha_field.length && '' !== $captcha_field.val() ) {
var first_digit = parseInt( $captcha_field.data( 'first_digit' ) ),
second_digit = parseInt( $captcha_field.data( 'second_digit' ) );
if ( parseInt( $captcha_field.val() ) !== first_digit + second_digit ) {
et_message += '- ' + et_pb_custom.wrong_captcha + '
';
this_et_contact_error = true;
// generate new digits for captcha
first_digit = Math.floor( ( Math.random() * 15 ) + 1 );
second_digit = Math.floor( ( Math.random() * 15 ) + 1 );
// set new digits for captcha
$captcha_field.data( 'first_digit', first_digit );
$captcha_field.data( 'second_digit', second_digit );
// regenerate captcha on page
$this_contact_form.find( '.et_pb_contact_captcha_question' ).empty().append( first_digit + ' + ' + second_digit );
}
}
if ( ! this_et_contact_error ) {
var $href = $( this ).attr( 'action' ),
form_data = $( this ).serializeArray();
form_data.push( { 'name': 'et_pb_contact_email_fields_' + form_unique_id, 'value' : JSON.stringify( inputs_list ) } );
$this_contact_container.fadeTo( 'fast', 0.2 ).load( $href + ' #' + $this_contact_form.closest( '.et_pb_contact_form_container' ).attr( 'id' ), form_data, function( responseText ) {
if ( ! $( responseText ).find( '.et_pb_contact_error_text').length ) {
et_pb_maybe_log_event( $this_contact_container, 'con_goal' );
// redirect if redirect URL is not empty and no errors in contact form
if ( '' !== redirect_url ) {
window.location.href = redirect_url;
}
}
$this_contact_container.fadeTo( 'fast', 1 );
} );
}
et_message += '
';
if ( '' !== et_fields_message ) {
if ( et_message != '
' ) {
et_message = '
' + et_pb_custom.contact_error_message + '
' + et_message;
}
et_fields_message = '
' + et_fields_message + '
';
et_fields_message = '
' + et_pb_custom.fill_message + '
' + et_fields_message;
et_message = et_fields_message + et_message;
}
if ( et_message != '
' ) {
$et_contact_message.html( et_message );
// If parent of this contact form uses parallax
if ( $this_contact_container.parents('.et_pb_section_parallax').length ) {
$this_contact_container.parents('.et_pb_section_parallax').each(function() {
var $parallax_element = $(this),
$parallax = $parallax_element.children('.et_parallax_bg'),
is_true_parallax = ( ! $parallax.hasClass( 'et_pb_parallax_css' ) );
if ( is_true_parallax ) {
$et_window.trigger( 'resize' );
}
});
}
}
event.preventDefault();
});
});
}
window.et_pb_play_overlayed_video = function( $play_video ) {
var $this = $play_video,
$video_image = $this.closest('.et_pb_video_overlay'),
$wrapper = $this.closest('.et_pb_video, .et_main_video_container, .et_pb_video_wrap'),
$video_iframe = $wrapper.find('iframe'),
is_embedded = $video_iframe.length ? true : false,
video_iframe_src,
video_iframe_src_splitted,
video_iframe_src_autoplay;
if (is_embedded) {
// Add autoplay parameter to automatically play embedded content when overlay is clicked
video_iframe_src = $video_iframe.attr('src');
video_iframe_src_splitted = video_iframe_src.split("?");
if (video_iframe_src.indexOf('autoplay=') !== -1) {
return;
}
if (typeof video_iframe_src_splitted[1] !== 'undefined') {
video_iframe_src_autoplay = video_iframe_src_splitted[0] + "?autoplay=1&" + video_iframe_src_splitted[1];
} else {
video_iframe_src_autoplay = video_iframe_src_splitted[0] + "?autoplay=1";
}
$video_iframe.attr({
'src': video_iframe_src_autoplay
});
} else {
$wrapper.find('video').get(0).play();
}
$video_image.fadeTo( 500, 0, function() {
var $image = $(this);
$image.css( 'display', 'none' );
} );
};
$( '.et_pb_post .et_pb_video_overlay, .et_pb_video .et_pb_video_overlay, .et_pb_video_wrap .et_pb_video_overlay' ).click( function() {
var $this = $(this);
et_pb_play_overlayed_video( $this );
return false;
} );
window.et_pb_resize_section_video_bg = function( $video ) {
$element = typeof $video !== 'undefined' ? $video.closest( '.et_pb_section_video_bg' ) : $( '.et_pb_section_video_bg' );
$element.each( function() {
var $this_el = $(this);
if ( is_frontend_builder ) {
$this_el.removeAttr('data-ratio');
$this_el.find('video').removeAttr('style');
}
var el_ratio = parseFloat( $this_el.attr( 'data-ratio' ) );
var el_width = parseInt( $this_el.find( 'video' ).attr( 'width' ) || $this_el.find( 'video' ).width() );
var el_height = parseInt( $this_el.find( 'video' ).attr( 'height' ) || $this_el.find( 'video' ).height() );
var ratio = ( ! isNaN( el_ratio ) ) ? el_ratio : ( el_width / el_height );
var $video_elements = $this_el.find( '.mejs-video, video, object' ).css( 'margin', 0 );
var $container = $this_el.closest( '.et_pb_section_video' ).length
? $this_el.closest( '.et_pb_section_video' )
: $this_el.closest( '.et_pb_slides' );
var body_width = $container.innerWidth();
var container_height = $container.innerHeight();
var width, height;
if ( typeof $this_el.attr( 'data-ratio' ) == 'undefined' && !isNaN(ratio) ) {
$this_el.attr( 'data-ratio', ratio );
}
if ( body_width / container_height < ratio ) {
width = container_height * ratio;
height = container_height;
} else {
width = body_width;
height = body_width / ratio;
}
$video_elements.width( width ).height( height );
// need to re-set the values to make it work correctly in Frontend builder
if ( is_frontend_builder ) {
setTimeout( function() {
$video_elements.width( width ).height( height );
}, 0 );
}
} );
};
window.et_pb_center_video = function( $video ) {
$element = typeof $video !== 'undefined' ? $video : $( '.et_pb_section_video_bg .mejs-video' );
if ( ! $element.length ) {
return;
}
$element.each( function() {
var $this_el = $(this);
et_pb_adjust_video_margin( $this_el );
// need to re-calculate the values in Frontend builder
if ( is_frontend_builder ) {
setTimeout( function() {
et_pb_adjust_video_margin( $this_el );
}, 0 );
}
if ( typeof $video !== 'undefined' ) {
if ( $video.closest( '.et_pb_slider' ).length && ! $video.closest( '.et_pb_first_video' ).length ) {
return false;
}
}
} );
};
window.et_pb_adjust_video_margin = function( $el ) {
var $video_width = $el.width() / 2;
var $video_width_negative = 0 - $video_width;
$el.css("margin-left", $video_width_negative );
}
window.et_fix_slider_height = function( $slider ) {
var $this_slider = $slider || $et_pb_slider;
if ( ! $this_slider || ! $this_slider.length ) {
return;
}
$this_slider.each( function() {
var $slide_section = $(this).parent( '.et_pb_section' ),
$slides = $(this).find( '.et_pb_slide' ),
$slide_containers = $slides.find( '.et_pb_container' ),
max_height = 0,
image_margin = 0,
need_image_margin_top = $(this).hasClass( 'et_pb_post_slider_image_top' ),
need_image_margin_bottom = $(this).hasClass( 'et_pb_post_slider_image_bottom' );
// If this is appears at the first section beneath transparent nav, skip it
// leave it to et_fix_page_container_position()
if ( $slide_section.is( '.et_pb_section_first' ) ){
return true;
}
$slide_containers.css( 'height', 0 );
// make slides visible to calculate the height correctly
$slides.addClass( 'et_pb_temp_slide' );
if ( typeof $(this).data('et_pb_simple_slider') === 'object' ) {
$(this).data('et_pb_simple_slider').et_fix_slider_content_images();
}
$slides.each( function() {
var height = parseFloat( $(this).innerHeight() ),
$slide_image = $(this).find( '.et_pb_slide_image' ),
adjustedHeight = parseFloat( $(this).data( 'adjustedHeight' ) ),
autoTopPadding = isNaN( adjustedHeight ) ? 0 : adjustedHeight;
// reduce the height by autopadding value if slider height was adjusted. This is required in VB.
height = ( autoTopPadding && autoTopPadding < height ) ? ( height - autoTopPadding ) : height;
if ( need_image_margin_top || need_image_margin_bottom ) {
if ( $slide_image.length ) {
// get the margin from slides with image
image_margin = need_image_margin_top ? parseFloat( $slide_image.css( 'margin-top' ) ) : parseFloat( $slide_image.css( 'margin-bottom' ) );
image_margin += 10;
} else {
// add class to slides without image to adjust their height accordingly
$(this).find( '.et_pb_container' ).addClass( 'et_pb_no_image' );
}
}
// mark the slides without content
if ( 0 === Math.abs( parseInt( $(this).find( '.et_pb_slide_description' ).height() ) ) ) {
$(this).find( '.et_pb_container' ).addClass( 'et_pb_empty_slide' );
}
if ( max_height < height ) {
max_height = height;
}
} );
if ( ( max_height + image_margin ) < 1 ) {
// No slides have any content. It's probably being used with background images only.
// Reset the height so that it falls back to the default padding for the content.
$slide_containers.css( 'height', '' );
} else {
$slide_containers.css( 'height', max_height + image_margin );
}
// remove temp class after getting the slider height
$slides.removeClass( 'et_pb_temp_slide' );
// Show the active slide's image (if exists)
$slides.filter('.et-pb-active-slide')
.find( '.et_pb_slide_image' )
.children( 'img' )
.addClass( 'active' );
} );
};
/**
* Add conditional class to prevent unwanted dropdown nav
*/
function et_fix_nav_direction() {
window_width = $(window).width();
$('.nav li.et-reverse-direction-nav').removeClass( 'et-reverse-direction-nav' );
$('.nav li li ul').each(function(){
var $dropdown = $(this),
dropdown_width = $dropdown.width(),
dropdown_offset = $dropdown.offset(),
$parents = $dropdown.parents('.nav > li');
if ( dropdown_offset.left > ( window_width - dropdown_width ) ) {
$parents.addClass( 'et-reverse-direction-nav' );
}
});
}
et_fix_nav_direction();
et_pb_form_placeholders_init( $( '.et_pb_newsletter_form, .et_pb_comments_module #commentform' ) );
$('.et_pb_fullwidth_menu ul.nav').each(function(i) {
i++;
et_duplicate_menu( $(this), $(this).parents('.et_pb_row').find('div .mobile_nav'), 'mobile_menu' + i, 'et_mobile_menu' );
});
$('.et_pb_fullwidth_menu').each(function() {
var this_menu = $( this ),
bg_color = this_menu.data( 'bg_color' );
if ( bg_color ) {
this_menu.find( 'ul' ).css( { 'background-color' : bg_color } );
}
});
$et_pb_newsletter_button.click( function( event ) {
et_pb_submit_newsletter( $(this), event );
} );
window.et_pb_submit_newsletter = function( $submit, event ) {
if ( $submit.closest( '.et_pb_login_form' ).length || $submit.closest( '.et_pb_feedburner_form' ).length ) {
et_pb_maybe_log_event( $submit.closest( '.et_pb_newsletter' ), 'con_goal' );
return;
}
if ( typeof event !== 'undefined' ) {
event.preventDefault();
}
var $newsletter_container = $submit.closest( '.et_pb_newsletter' ),
$firstname = $newsletter_container.find( 'input[name="et_pb_signup_firstname"]' ),
$lastname = $newsletter_container.find( 'input[name="et_pb_signup_lastname"]' ),
$email = $newsletter_container.find( 'input[name="et_pb_signup_email"]' ),
list_id = $newsletter_container.find( 'input[name="et_pb_signup_list_id"]' ).val(),
$result = $newsletter_container.find( '.et_pb_newsletter_result' ).hide(),
service = $submit.closest( '.et_pb_newsletter_form' ).data( 'service' ) || 'mailchimp',
account = $newsletter_container.find( 'input[name="et_pb_signup_account_name"]' ).val();
$firstname.removeClass( 'et_pb_signup_error' );
$lastname.removeClass( 'et_pb_signup_error' );
$email.removeClass( 'et_pb_signup_error' );
et_pb_remove_placeholder_text( $submit.closest( '.et_pb_newsletter_form' ) );
if ( $firstname.val() == '' || $email.val() == '' || list_id === '' ) {
if ( $firstname.val() == '' ) $firstname.addClass( 'et_pb_signup_error' );
if ( $email.val() == '' ) $email.addClass( 'et_pb_signup_error' );
if ( $firstname.val() == '' )
$firstname.val( $firstname.siblings( '.et_pb_contact_form_label' ).text() );
if ( $lastname.val() == '' )
$lastname.val( $lastname.siblings( '.et_pb_contact_form_label' ).text() );
if ( $email.val() == '' )
$email.val( $email.siblings( '.et_pb_contact_form_label' ).text() );
return;
}
$.ajax( {
type: "POST",
url: et_pb_custom.ajaxurl,
dataType: "json",
data:
{
action : 'et_pb_submit_subscribe_form',
et_frontend_nonce : et_pb_custom.et_frontend_nonce,
et_list_id : list_id,
et_firstname : $firstname.val(),
et_lastname : $lastname.val(),
et_email : $email.val(),
et_service : service,
et_account: account
},
beforeSend: function() {
$newsletter_container
.find( '.et_pb_newsletter_button' )
.addClass( 'et_pb_button_text_loading' )
.find('.et_subscribe_loader')
.show();
},
complete: function(){
$newsletter_container
.find( '.et_pb_newsletter_button' )
.removeClass( 'et_pb_button_text_loading' )
.find('.et_subscribe_loader')
.hide();
},
success: function( data ){
if ( data ) {
if ( data.error ) {
$result.html( data.error ).show();
}
if ( data.success ) {
$newsletter_container.find( '.et_pb_newsletter_form > p' ).hide();
$result.html( data.success ).show();
et_pb_maybe_log_event( $newsletter_container, 'con_goal' );
}
} else {
$result.html( et_pb_custom.subscription_failed ).show();
}
}
} );
};
window.et_fix_testimonial_inner_width = function() {
var window_width = $( window ).width();
if ( window_width > 767 ) {
$( '.et_pb_testimonial' ).each( function() {
if ( ! $(this).is( ':visible' ) ) {
return;
}
var $testimonial = $(this);
var testimonial_width = $testimonial.width();
var $portrait = $testimonial.find( '.et_pb_testimonial_portrait' );
var portrait_width = $portrait.outerWidth( true );
var $testimonial_inner = $testimonial.find( '.et_pb_testimonial_description_inner' );
var $outer_column = $testimonial.closest( '.et_pb_column' );
var testimonial_inner_width = testimonial_width;
var 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 : 0;
$testimonial_inner.width( testimonial_inner_width - subtract );
} );
} else {
$( '.et_pb_testimonial_description_inner' ).removeAttr( 'style' );
}
}
window.et_fix_testimonial_inner_width();
window.et_pb_video_background_init = function( $this_video_background, this_video_background ) {
var $video_background_wrapper = $this_video_background.closest( '.et_pb_section_video_bg' );
// Initializing video values
var onplaying = false;
var onpause = true;
// On video playing toggle values
this_video_background.onplaying = function() {
onplaying = true;
onpause = false;
};
// On video pause toggle values
this_video_background.onpause = function() {
onplaying = false;
onpause = true;
};
// Entering video's top viewport
et_waypoint( $video_background_wrapper, {
offset: '100%',
handler : function( direction ) {
if ( $this_video_background.is(':visible') && direction === 'down' ) {
if ( this_video_background.paused && ! onplaying ) {
this_video_background.play();
}
} else if ( $this_video_background.is(':visible') && direction === 'up' ) {
if ( ! this_video_background.paused && ! onpause ) {
this_video_background.pause();
}
}
}
});
// Entering video's bottom viewport
et_waypoint( $video_background_wrapper, {
offset: function() {
var video_height = this.element.clientHeight,
toggle_offset = Math.ceil( window.innerHeight / 2);
if ( video_height > toggle_offset ) {
toggle_offset = video_height;
}
return toggle_offset * (-1);
},
handler : function( direction ) {
if ( $this_video_background.is(':visible') && direction === 'up' ) {
if ( this_video_background.paused && ! onplaying ) {
this_video_background.play();
}
} else if ( $this_video_background.is(':visible') && direction === 'down' ) {
if ( ! this_video_background.paused && ! onpause ) {
this_video_background.pause();
}
}
}
});
};
function et_waypoint( $element, options ) {
if ( ! $element.data( 'et_waypoint' ) ) {
var instances = $element.waypoint( options );
if ( instances && instances.length > 0 ) {
$element.data( 'et_waypoint', instances[0] );
}
} else {
// Reinit existing
$element.data( 'et_waypoint' ).context.refresh();
}
}
window.et_reinit_waypoint_modules = et_pb_debounce( function() {
var $et_pb_circle_counter = $( '.et_pb_circle_counter' ),
$et_pb_number_counter = $( '.et_pb_number_counter' ),
$et_pb_video_background = $( '.et_pb_section_video_bg video' );
if ( $.fn.waypoint && 'yes' !== et_pb_custom.ignore_waypoints ) {
et_waypoint( $( '.et_pb_counter_container, .et-waypoint' ), {
offset: '75%',
handler: function() {
$(this.element).addClass( 'et-animated' );
}
} );
// 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
et_waypoint( $( '.et_pb_counter_container, .et-waypoint' ), {
offset: 'bottom-in-view',
handler: function() {
$(this.element).addClass( 'et-animated' );
}
} );
if ( $et_pb_circle_counter.length ) {
$et_pb_circle_counter.each(function(){
var $this_counter = $(this);
if ( ! $this_counter.is( ':visible' ) ) {
return;
}
et_waypoint( $this_counter, {
offset: '65%',
handler: function() {
if ( $this_counter.data( 'PieChartHasLoaded' ) || typeof $this_counter.data('easyPieChart') === 'undefined' ) {
return;
}
$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
$this_counter.data( 'PieChartHasLoaded', true );
}
});
// 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
et_waypoint( $this_counter, {
offset: 'bottom-in-view',
handler: function() {
if ( $this_counter.data( 'PieChartHasLoaded' ) || typeof $this_counter.data('easyPieChart') === 'undefined' ) {
return;
}
$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
$this_counter.data( 'PieChartHasLoaded', true );
}
});
});
}
if ( $et_pb_number_counter.length ) {
$et_pb_number_counter.each(function(){
var $this_counter = $(this);
et_waypoint( $this_counter, {
offset: '75%',
handler: function() {
$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
}
});
// 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
et_waypoint( $this_counter, {
offset: 'bottom-in-view',
handler: function() {
$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
}
});
});
}
if ( $( '.et_pb_ab_goal' ).length ) {
var $et_pb_ab_goal = $( '.et_pb_ab_goal' );
et_waypoint( $et_pb_ab_goal, {
offset: '80%',
handler: function() {
if ( et_pb_ab_logged_status['read_goal'] || ! $et_pb_ab_goal.length || ! $et_pb_ab_goal.visible( true ) ) {
return;
}
// log the goal_read if goal is still visible after 3 seconds.
setTimeout( function() {
if ( $et_pb_ab_goal.length && $et_pb_ab_goal.visible( true ) && ! et_pb_ab_logged_status['read_goal'] ) {
et_pb_ab_update_stats( 'read_goal' );
}
}, 3000 );
et_pb_maybe_log_event( $et_pb_ab_goal, 'view_goal' );
}
});
}
} else {
// if no waypoints supported then apply all the animations right away
$( '.et_pb_counter_container, .et-waypoint' ).addClass( 'et-animated' );
if ( $et_pb_circle_counter.length ) {
$et_pb_circle_counter.each(function() {
var $this_counter = $(this);
if ( ! $this_counter.is( ':visible' ) ) {
return;
}
if ( $this_counter.data( 'PieChartHasLoaded' ) ) {
return;
}
$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
$this_counter.data( 'PieChartHasLoaded', true );
} );
}
if ( $et_pb_number_counter.length ) {
$et_pb_number_counter.each(function(){
var $this_counter = $(this);
$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
});
}
// log the stats without waypoints
if ( $( '.et_pb_ab_goal' ).length ) {
var $et_pb_ab_goal = $( '.et_pb_ab_goal' );
if ( et_pb_ab_logged_status['read_goal'] || ! $et_pb_ab_goal.length || ! $et_pb_ab_goal.visible( true ) ) {
return;
}
// log the goal_read if goal is still visible after 3 seconds.
setTimeout( function() {
if ( $et_pb_ab_goal.length && $et_pb_ab_goal.visible( true ) && ! et_pb_ab_logged_status['read_goal'] ) {
et_pb_ab_update_stats( 'read_goal' );
}
}, 3000 );
et_pb_maybe_log_event( $et_pb_ab_goal, 'view_goal' );
}
}
if ( $et_pb_video_background.length ) {
$et_pb_video_background.each( function(){
var $this_video_background = $(this);
et_pb_video_background_init( $this_video_background, this );
});
}
}, 100 );
function et_pb_init_ab_test() {
var $et_pb_ab_goal = $( '.et_pb_ab_goal' ),
et_ab_subject_id = et_pb_get_subject_id();
$.each( et_pb_ab_logged_status, function( key, value ) {
var cookie_subject = 'click_goal' === key || 'con_short' === key ? '' : et_ab_subject_id;
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' );
});
// log the page read event if user stays on page long enough and if not logged for current subject
if ( ! et_pb_ab_logged_status['read_page'] ) {
setTimeout( function() {
et_pb_ab_update_stats( 'read_page' );
}, et_pb_ab_bounce_rate );
}
// add the cookies for shortcode tracking, if enabled
if ( 'on' === et_pb_custom.is_shortcode_tracking && ! et_pb_ab_logged_status['con_short'] ) {
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 );
}
if ( $et_pb_ab_goal.length ) {
// if goal is a module and has a button then track the conversions, otherwise track clicks
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 ) ) {
// Log con_goal if current goal doesn't require any specific conversion calculation
if ( ! $et_pb_ab_goal.hasClass( 'et_pb_contact_form_container' ) && ! $et_pb_ab_goal.hasClass( 'et_pb_newsletter' ) ) {
var $goal_button = $et_pb_ab_goal.hasClass( 'et_pb_button' ) ? $et_pb_ab_goal : $et_pb_ab_goal.find( '.et_pb_button' );
if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) ) {
var page_url = window.location.href,
comment_submitted = -1 !== page_url.indexOf( '#comment-' ) ? true : false,
log_conversion = et_pb_check_cookie_value( 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id, 'true' );
if ( comment_submitted && log_conversion ) {
et_pb_ab_update_stats( 'con_goal' );
et_pb_set_cookie( 0, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' );
}
}
$goal_button.click( function(){
if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) && ! et_pb_ab_logged_status['con_goal'] ) {
et_pb_set_cookie( 365, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' );
return;
}
et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' );
});
}
} else {
$et_pb_ab_goal.click( function() {
if ( $et_pb_ab_goal.hasClass( 'et_pb_shop' ) && ! et_pb_ab_logged_status['con_goal'] ) {
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 );
}
et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' );
});
}
}
}
function et_pb_maybe_log_event( $goal_container, event ) {
var log_event = typeof event === 'undefined' ? 'con_goal' : event;
if ( ! $goal_container.hasClass( 'et_pb_ab_goal' ) || et_pb_ab_logged_status[ log_event ] ) {
return;
}
// log the event if it's not logged for current user
et_pb_ab_update_stats( log_event );
}
function et_pb_ab_update_stats( record_type, set_page_id, set_subject_id, set_test_id ) {
var subject_id = typeof set_subject_id === 'undefined' ? et_pb_get_subject_id() : set_subject_id,
page_id = typeof set_page_id === 'undefined' ? et_pb_custom.page_id : set_page_id,
test_id = typeof set_test_id === 'undefined' ? et_pb_custom.unique_test_id : set_test_id,
stats_data = JSON.stringify({ 'test_id' : page_id, 'subject_id' : subject_id, 'record_type' : record_type }),
cookie_subject = 'click_goal' === record_type || 'con_short' === record_type ? '' : subject_id;
et_pb_set_cookie( 365, 'et_pb_ab_' + record_type + '_' + page_id + test_id + cookie_subject + '=true' );
et_pb_ab_logged_status[record_type] = true;
$.ajax({
type: 'POST',
url: et_pb_custom.ajaxurl,
data: {
action : 'et_pb_update_stats_table',
stats_data_array : stats_data,
et_ab_log_nonce : et_pb_custom.et_ab_log_nonce
}
});
}
function et_pb_get_subject_id() {
var $subject = $( '.et_pb_ab_subject' );
// In case no subject found
if ( $subject.length <= 0 ) {
return false;
}
var subject_classname = $subject.attr( 'class' ),
subject_id_raw = subject_classname.split( 'et_pb_ab_subject_id-' )[1],
subject_id_clean = subject_id_raw.split( ' ' )[0],
subject_id_separated = subject_id_clean.split( '_' ),
subject_id = subject_id_separated[1];
return subject_id;
}
function et_pb_set_cookie_expire( days ) {
var ms = days*24*60*60*1000;
var date = new Date();
date.setTime( date.getTime() + ms );
return "; expires=" + date.toUTCString();
}
function et_pb_check_cookie_value( cookie_name, value ) {
return et_pb_get_cookie_value( cookie_name ) == value;
}
function et_pb_get_cookie_value( cookie_name ) {
return et_pb_parse_cookies()[cookie_name];
}
function et_pb_parse_cookies() {
var cookies = document.cookie.split( '; ' );
var ret = {};
for ( var i = cookies.length - 1; i >= 0; i-- ) {
var el = cookies[i].split( '=' );
ret[el[0]] = el[1];
}
return ret;
}
function et_pb_set_cookie( expire, cookie_content ) {
cookie_expire = et_pb_set_cookie_expire( expire );
document.cookie = cookie_content + cookie_expire + "; path=/";
}
function et_pb_get_fixed_main_header_height() {
if ( ! window.et_is_fixed_nav ) {
return 0;
}
var fixed_height_onload = typeof $('#main-header').attr('data-fixed-height-onload') === 'undefined' ? 0 : $('#main-header').attr('data-fixed-height-onload');
return ! window.et_is_fixed_nav ? 0 : parseFloat( fixed_height_onload );
}
var fullscreen_section_width = {};
var fullscreen_section_timeout = {};
window.et_calc_fullscreen_section = function(event) {
var isResizing = typeof event === 'object' && event.type === 'resize',
$et_window = $(window),
$this_section = $(this),
section_index = $this_section.index('.et_pb_fullscreen'),
timeout = isResizing && typeof fullscreen_section_width[section_index] !== 'undefined' && event.target.window_width > fullscreen_section_width[section_index] ? 800 : 0;
fullscreen_section_width[section_index] = $et_window.width();
if ( typeof fullscreen_section_timeout[section_index] !== 'undefined' ) {
clearTimeout( fullscreen_section_timeout[section_index] );
}
fullscreen_section_timeout[section_index] = setTimeout( function() {
var $body = $( 'body' ),
this_section_index = $this_section.index('.et_pb_fullwidth_header'),
this_section_offset = $this_section.offset(),
$header = $this_section.children('.et_pb_fullwidth_header_container'),
$header_content = $header.children('.header-content-container'),
$header_image = $header.children('.header-image-container'),
sectionHeight = window.innerHeight || $et_window.height(),
$wpadminbar = $('#wpadminbar'),
has_wpadminbar = $wpadminbar.length,
wpadminbar_height = has_wpadminbar ? $wpadminbar.height() : 0,
$top_header = $('#top-header'),
has_top_header = $top_header.length,
top_header_height = has_top_header ? $top_header.height() : 0,
$main_header = $('#main-header'),
has_main_header = $main_header.length,
main_header_height = has_main_header ? $main_header.outerHeight() : 0,
fixed_main_header_height = et_pb_get_fixed_main_header_height(),
is_mobile_first_module = this_section_offset.top <= (main_header_height + wpadminbar_height),
is_wp_relative_admin_bar = $et_window.width() < 782,
is_desktop_view = $et_window.width() > 980,
is_tablet_view = $et_window.width() <= 980 && $et_window.width() >= 479,
is_phone_view = $et_window.width() < 479,
overall_header_height = window.et_is_vertical_nav && is_desktop_view ? wpadminbar_height + top_header_height : wpadminbar_height + top_header_height + main_header_height,
is_first_module = this_section_offset.top <= overall_header_height;
// In case theme stored the onload main-header height as data-attribute
if ( $main_header.attr('data-height-onload') ) {
main_header_height = parseFloat( $main_header.attr('data-height-onload') );
}
/**
* WP Admin Bar:
*
* - Desktop fixed: standard
* - WP Mobile relative: less than 782px window
**/
if ( has_wpadminbar ) {
if ( is_wp_relative_admin_bar ) {
if ( is_first_module ) {
sectionHeight -= wpadminbar_height;
}
} else {
sectionHeight -= wpadminbar_height;
}
}
/**
* Divi Top Header:
*
* - Desktop fixed: standard.
* - Desktop fixed BUT first header's height shouldn't be substracted: hide nav until scroll activated
* - Desktop relative: fixed nav bar disabled
* - Desktop relative: vertical nav activated
*/
if ( has_top_header ) {
if ( is_desktop_view ) {
if ( et_hide_nav && ! window.et_is_vertical_nav ) {
if ( ! is_first_module ) {
sectionHeight -= top_header_height;
}
} else if ( ! window.et_is_fixed_nav || window.et_is_vertical_nav ) {
if ( is_first_module ) {
sectionHeight -= top_header_height;
}
} else {
sectionHeight -= top_header_height;
}
}
}
/**
* Divi Main Header:
*
* - Desktop fixed: standard. Initial and 'fixed' header might have different height
* - Desktop relative: fixed nav bar disabled
* - Desktop fixed BUT height should be ignored: vertical nav activated
* - Desktop fixed BUT height should be ignored for first header only: main header uses rgba
* - Desktop fixed BUT first header's height shouldn't be substracted: hide nav until scroll activated
* - Tablet relative: standard. Including vertical header style
* - Phone relative: standard. Including vertical header style
*/
if ( has_main_header ) {
if ( is_desktop_view ) {
if ( et_hide_nav && ! window.et_is_vertical_nav ) {
if ( ! is_first_module ) {
sectionHeight -= fixed_main_header_height;
}
} else if ( window.et_is_fixed_nav && ! window.et_is_vertical_nav ) {
if ( is_first_module ) {
sectionHeight -= main_header_height;
} else {
sectionHeight -= fixed_main_header_height;
}
} else if ( ! window.et_is_fixed_nav && ! window.et_is_vertical_nav ) {
if ( is_first_module ) {
sectionHeight -= main_header_height;
}
}
} else {
if ( is_first_module ) {
sectionHeight -= main_header_height;
}
}
}
// If the transparent primary nav + hide nav until scroll is being used,
// cancel automatic padding-top added by transparent nav mechanism
if ( $body.hasClass('et_transparent_nav') && $body.hasClass( 'et_hide_nav' ) && 0 === this_section_index ) {
$this_section.css( 'padding-top', '' );
}
$this_section.css('min-height', sectionHeight + 'px' );
$header.css('min-height', sectionHeight + 'px' );
if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('bottom') ) {
$header.addClass('bottom-bottom');
}
if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('center') ) {
$header.addClass('center-center');
}
if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('bottom') ) {
$header.addClass('center-bottom');
var contentHeight = sectionHeight - $header_image.outerHeight( true );
if ( contentHeight > 0 ) {
$header_content.css('min-height', contentHeight + 'px' );
}
}
if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('center') ) {
$header.addClass('bottom-center');
}
if ( ( $header.hasClass('left') || $header.hasClass('right') ) && !$header_content.length && $header_image.length ) {
$header.css('justify-content', 'flex-end');
}
if ( $header.hasClass('center') && $header_content.hasClass('bottom') && !$header_image.length ) {
$header_content.find('.header-content').css( 'margin-bottom', 80 + 'px' );
}
if ( $header_content.hasClass('bottom') && $header_image.hasClass('center') ) {
$header_image.find('.header-image').css( 'margin-bottom', 80 + 'px' );
$header_image.css('align-self', 'flex-end');
}
}, timeout );
}
window.et_pb_parallax_init = function( $this_parallax ) {
if ( $this_parallax.hasClass('et_pb_parallax_css') ) {
return;
}
var $this_parent = $this_parallax.parent();
$.proxy( et_parallax_set_height, $this_parent )();
$.proxy( et_apply_parallax, $this_parent )();
$et_window.on( 'scroll', $.proxy( et_apply_parallax, $this_parent ) );
$et_window.on( 'resize', $.proxy( et_parallax_set_height, $this_parent ) );
$et_window.on( 'resize', $.proxy( et_apply_parallax, $this_parent ) );
$this_parent.find('.et-learn-more .heading-more').click( function() {
setTimeout(function(){
$.proxy( et_parallax_set_height, $this_parent )();
}, 300 );
});
}
$( window ).resize( function(){
var window_width = $et_window.width(),
et_container_css_width = $et_container.css( 'width' ),
et_container_width_in_pixel = ( typeof et_container_css_width !== 'undefined' ) ? et_container_css_width.substr( -1, 1 ) !== '%' : '',
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
containerWidthChanged = et_container_width !== et_container_actual_width;
et_pb_resize_section_video_bg();
et_pb_center_video();
et_fix_slider_height();
et_fix_nav_direction();
$et_pb_fullwidth_portfolio.each(function(){
set_container_height = $(this).hasClass('et_pb_fullwidth_portfolio_carousel') ? true : false;
set_fullwidth_portfolio_columns( $(this), set_container_height );
});
if ( containerWidthChanged ) {
$('.container-width-change-notify').trigger('containerWidthChanged');
setTimeout( function() {
$et_pb_filterable_portfolio.each(function(){
set_filterable_grid_items( $(this) );
});
$et_pb_gallery.each(function(){
if ( $(this).hasClass( 'et_pb_gallery_grid' ) ) {
set_gallery_grid_items( $(this) );
}
});
}, 100 );
et_container_width = et_container_actual_width;
etRecalculateOffset = true;
if ( $et_pb_circle_counter.length ) {
$et_pb_circle_counter.each(function(){
var $this_counter = $(this);
if ( ! $this_counter.is( ':visible' ) ) {
return;
}
$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
});
}
if ( $et_pb_countdown_timer.length ) {
$et_pb_countdown_timer.each(function(){
var timer = $(this);
et_countdown_timer_labels( timer );
} );
}
}
window.et_fix_testimonial_inner_width();
et_audio_module_set();
if ( $et_pb_counter_amount.length ) {
$et_pb_counter_amount.each(function(){
window.et_bar_counters_init( $( this ) );
});
} /* $et_pb_counter_amount.length */
} );
$( window ).ready( function(){
if ( $.fn.fitVids ) {
$( '.et_pb_slide_video' ).fitVids();
$( '.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']"} );
}
et_fix_video_wmode('.fluid-width-video-wrapper');
et_fix_slider_height();
// calculate fullscreen section sizes on $( window ).ready to avoid jumping in some cases
$( 'section.et_pb_fullscreen' ).each( function(){
var $this_section = $( this );
$.proxy( et_calc_fullscreen_section, $this_section )();
$et_window.on( 'resize', $.proxy( et_calc_fullscreen_section, $this_section ) );
});
} );
window.et_pb_fullwidth_header_scroll = function( event ) {
event.preventDefault();
var window_width = $et_window.width(),
$body = $('body'),
is_wp_relative_admin_bar = window_width < 782,
is_transparent_main_header = $body.hasClass( 'et_transparent_nav' ),
is_hide_nav = $body.hasClass( 'et_hide_nav' ),
is_desktop_view = window_width > 980,
is_tablet_view = window_width <= 980 && window_width >= 479,
is_phone_view = window_width < 479,
$this_section = $(this).parents( 'section' ),
this_section_offset = $this_section.offset(),
$wpadminbar = $('#wpadminbar'),
$main_header = $('#main-header'),
wpadminbar_height = $wpadminbar.length && ! is_wp_relative_admin_bar ? $wpadminbar.height() : 0,
top_header_height = !window.et_is_fixed_nav || !is_desktop_view ? 0 : $top_header.height(),
data_height_onload = typeof $main_header.attr('data-height-onload') === 'undefined' ? 0 : $main_header.attr('data-height-onload');
initial_fixed_difference = $main_header.height() === et_pb_get_fixed_main_header_height() || ! is_desktop_view || ! window.et_is_fixed_nav || is_transparent_main_header || is_hide_nav ? 0 : et_pb_get_fixed_main_header_height() - parseFloat( data_height_onload ),
section_bottom = ( this_section_offset.top + $this_section.outerHeight( true ) + initial_fixed_difference ) - ( wpadminbar_height + top_header_height + et_pb_get_fixed_main_header_height() ),
animate_modified = false;
if ( $this_section.length ) {
var fullscreen_scroll_duration = 800;
$( 'html, body' ).animate( { scrollTop : section_bottom }, {
duration: fullscreen_scroll_duration
} );
}
}
function et_pb_window_load_scripts() {
et_fix_fullscreen_section();
// recalculate fullscreen section sizes on load
$( 'section.et_pb_fullscreen' ).each( function(){
var $this_section = $( this );
$.proxy( et_calc_fullscreen_section, $this_section )();
});
$( '.et_pb_fullwidth_header_scroll' ).on('click', 'a', et_pb_fullwidth_header_scroll );
setTimeout( function() {
$( '.et_pb_preload' ).removeClass( 'et_pb_preload' );
}, 500 );
if ( $.fn.hashchange ) {
$(window).hashchange( function(){
var hash = window.location.hash.substring(1);
process_et_hashchange( hash );
});
$(window).hashchange();
}
if ( $et_pb_parallax.length && !et_is_mobile_device ) {
$et_pb_parallax.each(function(){
et_pb_parallax_init( $(this) );
});
}
et_audio_module_set();
window.et_reinit_waypoint_modules();
if ( $( '.et_audio_content' ).length ) {
$( window ).trigger( 'resize' );
}
}
if ( window.et_load_event_fired ) {
et_pb_window_load_scripts();
} else {
$( window ).load( function() {
et_pb_window_load_scripts();
} );
}
if ( $( '.et_section_specialty' ).length ) {
$( '.et_section_specialty' ).each( function() {
var this_row = $( this ).find( '.et_pb_row' );
this_row.find( '>.et_pb_column:not(.et_pb_specialty_column)' ).addClass( 'et_pb_column_single' );
});
}
/**
* In particular browser, map + parallax doesn't play well due the use of CSS 3D transform
*/
if ( $('.et_pb_section_parallax').length && $('.et_pb_map').length ) {
$('body').addClass( 'parallax-map-support' );
}
/**
* Add conditional class for search widget in sidebar module
*/
$('.et_pb_widget_area ' + et_pb_custom.widget_search_selector ).each( function() {
var $search_wrap = $(this),
$search_input_submit = $search_wrap.find('input[type="submit"]'),
search_input_submit_text = $search_input_submit.attr( 'value' ),
$search_button = $search_wrap.find('button'),
search_button_text = $search_button.text(),
has_submit_button = $search_input_submit.length || $search_button.length ? true : false,
min_column_width = 150;
if ( ! $search_wrap.find( 'input[type="text"]' ).length && ! $search_wrap.find( 'input[type="search"]' ).length ) {
return;
}
// Mark no button state
if ( ! has_submit_button ) {
$search_wrap.addClass( 'et-no-submit-button' );
}
// Mark narrow state
if ( $search_wrap.width() < 150 ) {
$search_wrap.addClass( 'et-narrow-wrapper' );
}
// Fixes issue where theme's search button has no text: treat it as non-existent
if ( $search_input_submit.length && ( typeof search_input_submit_text == 'undefined' || search_input_submit_text === '' ) ) {
$search_input_submit.remove();
$search_wrap.addClass( 'et-no-submit-button' );
}
if ( $search_button.length && ( typeof search_button_text == 'undefined' || search_button_text === '' ) ) {
$search_button.remove();
$search_wrap.addClass( 'et-no-submit-button' );
}
} );
window.et_pb_search_init = function( $search ) {
var $input_field = $search.find( '.et_pb_s' ),
$button = $search.find( '.et_pb_searchsubmit' ),
input_padding = $search.hasClass( 'et_pb_text_align_right' ) ? 'paddingLeft' : 'paddingRight',
disabled_button = $search.hasClass( 'et_pb_hide_search_button' );
// set the relative button position to get its height correctly
$button.css( { 'position' : 'relative' } );
if ( $button.innerHeight() > $input_field.innerHeight() ) {
$input_field.height( $button.innerHeight() );
}
if ( ! disabled_button ) {
$input_field.css( input_padding, $button.innerWidth() + 10 );
}
// reset the button position back to default
$button.css( { 'position' : '' } );
}
/**
* Fix search module which has percentage based custom margin
*/
window.et_pb_search_percentage_custom_margin_fix = function( $search ) {
var inputMargin = $search.find( '.et_pb_s' ).css( 'margin' ).split(' ');
var inputMarginObj = {};
switch(inputMargin.length) {
case 4:
inputMarginObj = {
top: inputMargin[0],
right: inputMargin[1],
bottom: inputMargin[2],
left: inputMargin[3],
};
break;
case 2:
inputMarginObj = {
top: inputMargin[0],
right: inputMargin[1],
bottom: inputMargin[0],
left: inputMargin[1],
};
break;
default:
inputMarginObj = {
top: inputMargin[0],
right: inputMargin[0],
bottom: inputMargin[0],
left: inputMargin[0],
};
break;
}
var inputRight = 0 - parseFloat(inputMarginObj.left) + 'px';
$search.find('.et_pb_searchsubmit').css({
top: inputMarginObj.top,
right: inputRight,
bottom: inputMarginObj.bottom,
});
}
if ( $( '.et_pb_search' ).length ) {
$( '.et_pb_search' ).each( function() {
var $search = $(this);
if ( $search.is( '.et_pb_search_percentage_custom_margin' ) ) {
et_pb_search_percentage_custom_margin_fix( $search );
}
et_pb_search_init( $search );
});
}
window.et_pb_comments_init = function( $comments_module ) {
var $comments_module_button = $comments_module.find( '.comment-reply-link, .submit' );
if ( $comments_module_button.length ) {
$comments_module_button.addClass( 'et_pb_button' );
if ( typeof $comments_module.attr( 'data-icon' ) !== 'undefined' && $comments_module.attr( 'data-icon' ) !== '' ) {
$comments_module_button.attr( 'data-icon', $comments_module.attr( 'data-icon' ) );
$comments_module_button.addClass( 'et_pb_custom_button_icon' );
}
}
};
// apply required classes for the Reply buttons in Comments Module
if ( $( '.et_pb_comments_module' ).length ) {
$( '.et_pb_comments_module' ).each( function() {
var $comments_module = $( this );
et_pb_comments_init( $comments_module );
});
}
window.et_fix_pricing_currency_position();
$('.et_pb_contact_form_container').each( function() {
var $form = $(this);
/* Listen for any field change */
$form.on( 'change', 'input, textarea, select', function() {
et_conditional_check( $form );
} );
// Conditions may be satisfied on default form state
et_conditional_check( $form );
} );
function et_conditional_check( $form ) {
var $conditionals = $form.find('[data-conditional-logic]');
/* Upon change loop all the fields that have conditional logic */
$conditionals
.hide()
.each( function() {
var $conditional = $(this);
/* jQuery automatically parses the JSON */
var rules = $conditional.data('conditional-logic');
var relation = $conditional.data('conditional-relation');
show_field = false;
/* Loop all the conditional logic rules */
var matched_rules = [];
for ( var i = 0; i < rules.length; i++ ) {
var ruleset = rules[i];
var check_id = ruleset[0];
var check_type = ruleset[1];
var check_value = ruleset[2];
var $wrapper = $form.find('.et_pb_contact_field[data-id="' + check_id + '"]');
var field_id = $wrapper.data('id');
var field_type = $wrapper.data('type');
var field_value;
/* Get the proper compare value based on the field type */
switch( field_type ) {
case 'input':
case 'email':
field_value = $wrapper.find('input').val();
break;
case 'text':
field_value = $wrapper.find('textarea').val();
break;
case 'radio':
field_value = $wrapper.find('input:checked').val() || '';
break;
case 'checkbox':
var $checkbox = $wrapper.find(':checkbox');
var $checkbox_data = $wrapper.find('[data-checked][data-unchecked]');
field_value = true === $checkbox.prop('checked') ? $checkbox_data.data('checked') : $checkbox_data.data('unchecked');
break;
case 'select':
field_value = $wrapper.find('select').val();
break;
}
/*
'is empty' / 'is not empty' are comparing against an empty value so simply
reset the `check_value` and update the condition to 'is' / 'is not'
*/
if ( 'is empty' === check_type || 'is not empty' === check_type ) {
check_type = 'is empty' === check_type ? 'is' : 'is not';
check_value = '';
}
/* Check if the value IS matching (if it has to) */
if ( 'is' === check_type && field_value !== check_value ) {
continue;
}
/* Check if the value IS NOT matching (if it has to) */
if ( 'is not' === check_type && field_value === check_value ) {
continue;
}
/* Create the contains/not contains regular expresion */
var containsRegExp = new RegExp( check_value, 'i' );
/* Check if the value IS containing */
if ( 'contains' === check_type && ! field_value.match( containsRegExp ) ) {
continue;
}
/* Check if the value IS NOT containing */
if ( 'does not contain' === check_type && field_value.match( containsRegExp ) ) {
continue;
}
/* Prepare the values for the 'is greater than' / 'is less than' check */
var maybeNumericValue = parseInt( field_value );
var maybeNumbericCheckValue = parseInt( check_value );
if (
( 'is greater' === check_type || 'is less' === check_type ) &&
( isNaN( maybeNumericValue ) || isNaN( maybeNumbericCheckValue ) )
) {
continue;
}
/* Check if the value is greater than */
if ( 'is greater' === check_type && maybeNumericValue <= maybeNumbericCheckValue) {
continue;
}
/* Check if the value is less than */
if ( 'is less' === check_type && maybeNumericValue >= maybeNumbericCheckValue) {
continue;
}
matched_rules.push( true );
}
// Hide all the conditional fields initially
$conditional.hide();
/*
Input fields may have HTML5 pattern validation which must be ignored
if the field is not visible. In order for the pattern to not be
taken into account the field must have novalidate property and
to not be required (or to not have a pattern attribute)
*/
var $conditional_input = $conditional.find('input[type="text"]');
var conditional_pattern = $conditional_input.attr('pattern');
$conditional_input.attr('novalidate', 'novalidate');
$conditional_input.attr('data-pattern', conditional_pattern);
$conditional_input.removeAttr('pattern');
if ( 'all' === relation && rules.length === matched_rules.length ) {
$conditional.show();
$conditional_input.removeAttr('novalidate');
$conditional_input.attr('pattern', $conditional_input.data('pattern'));
}
if ( 'any' === relation && 0 < matched_rules.length ) {
$conditional.show();
$conditional_input.removeAttr('novalidate');
$conditional_input.attr('pattern', $conditional_input.data('pattern'));
}
} );
}
/**
* Provide event listener for plugins to hook up to
*/
$(document).trigger('et_pb_after_init_modules');
});
}
// Modification of underscore's _.debounce()
// Underscore.js 1.8.3
// http://underscorejs.org
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
window.et_pb_debounce = function(func, wait, immediate) {
var timeout, args, context, timestamp, result;
var now = Date.now || new Date().getTime();
var later = function() {
var last = now - timestamp;
if (last < wait && last >= 0) {
timeout = setTimeout(later, wait - last);
} else {
timeout = null;
if (!immediate) {
result = func.apply(context, args);
if (!timeout) context = args = null;
}
}
};
return function() {
context = this;
args = arguments;
timestamp = now;
var callNow = immediate && !timeout;
if (!timeout) timeout = setTimeout(later, wait);
if (callNow) {
result = func.apply(context, args);
context = args = null;
}
return result;
};
};
if ( et_pb_custom.is_ab_testing_active && 'yes' === et_pb_custom.is_cache_plugin_active ) {
// update the window.et_load_event_fired variable to initiate the scripts properly
$( window ).load( function() {
window.et_load_event_fired = true;
});
// get the subject id for current visitor and display it
// this ajax request performed only if split testing is enabled and cache plugin active
$.ajax( {
type: "POST",
url: et_pb_custom.ajaxurl,
dataType: "json",
data:
{
action : 'et_pb_ab_get_subject_id',
et_frontend_nonce : et_pb_custom.et_frontend_nonce,
et_pb_ab_test_id : et_pb_custom.page_id
},
success: function( subject_data ) {
if ( subject_data ) {
// append the subject content to appropriate placeholder
$( '.et_pb_subject_placeholder_id_' + subject_data.id ).after( subject_data.content );
// remove all other placeholders from the DOM
$( '.et_pb_subject_placeholder' ).remove();
// init all scripts once the subject loaded
window.et_pb_init_modules();
$( 'body' ).trigger( 'et_pb_ab_subject_ready' );
}
}
});
} else {
window.et_pb_init_modules();
}
})(jQuery)