" );
}
var pad = $.extend( {
top: 0,
bottom: 0
}, options.padding || {} );
var $pin = $this.parent(),
pt = parseInt( $pin.parent().css( 'padding-top' ) ), pb = parseInt( $pin.parent().css( 'padding-bottom' ) );
if ( options.autoInit ) {
if ( $( '#header' ).hasClass( 'header-side' ) ) {
pad.top = theme.adminBarHeight();
/*if ($('.page-top.fixed-pos').length) {
pad.top += $('.page-top.fixed-pos').height();
}*/
} else {
pad.top = theme.adminBarHeight();
if ( $( '#header > .main-menu-wrap' ).length || !$( '#header' ).hasClass( 'sticky-menu-header' ) ) {
pad.top += theme.StickyHeader.sticky_height;
}
}
if ( typeof options.paddingOffsetTop != 'undefined' ) {
pad.top += parseInt( options.paddingOffsetTop, 10 );
} else {
pad.top += 18;
}
if ( typeof options.paddingOffsetBottom != 'undefined' ) {
pad.bottom = parseInt( options.paddingOffsetBottom, 10 );
} else {
pad.bottom = 0;
}
}
var bb = $this.css( 'border-bottom' ), h = $this.outerHeight();
$this.css( 'border-bottom', '1px solid transparent' );
var o_h = $this.outerHeight() - h - 1;
$this.css( 'border-bottom', bb );
$this.css( { width: $this.outerWidth() <= $pin.width() ? $this.outerWidth() : $pin.width() } );
$pin.css( "height", $this.outerHeight() + o_h );
if ( ( !options.autoFit && !options.fitToBottom ) || $this.outerHeight() <= $window.height() ) {
$this.data( "themePin", {
pad: pad,
from: ( options.containerSelector ? containerOffset.top : offset.top ) - pad.top + pt,
pb: pb,
parentTop: parentOffset.top - pt,
offset: o_h
} );
} else {
$this.data( "themePin", {
pad: pad,
fromFitTop: ( options.containerSelector ? containerOffset.top : offset.top ) - pad.top + pt,
from: ( options.containerSelector ? containerOffset.top : offset.top ) + $this.outerHeight() - window.innerHeight + pt,
pb: pb,
parentTop: parentOffset.top - pt,
offset: o_h
} );
}
}
};
var onScroll = function () {
if ( disabled ) { return; }
scrollY = $window.scrollTop();
var window_height = window.innerHeight || $window.height();
for ( var i = 0, len = elements.length; i < len; i++ ) {
var $this = $( elements[ i ] ),
data = $this.data( "themePin" ),
sidebarTop;
if ( !data ) { // Removed element
continue;
}
var $container = options.containerSelector ? ( $this.closest( options.containerSelector ).length ? $this.closest( options.containerSelector ) : $( options.containerSelector ) ) : $( document.body ),
isFitToTop = ( !options.autoFit && !options.fitToBottom ) || ( $this.outerHeight() + data.pad.top ) <= window_height;
data.end = $container.offset().top + $container.height();
if ( isFitToTop ) {
data.to = $container.offset().top + $container.height() - $this.outerHeight() - data.pad.bottom - data.pb;
} else {
data.to = $container.offset().top + $container.height() - window_height - data.pb;
data.to2 = $container.height() - $this.outerHeight() - data.pad.bottom - data.pb;
}
if ( prevDataTo[ i ] === 0 ) {
prevDataTo[ i ] = data.to;
}
if ( isFitToTop ) {
var from = data.from - data.pad.bottom,
to = data.to - data.pad.top - data.offset;
if ( typeof data.fromFitTop != 'undefined' && data.fromFitTop ) {
from = data.fromFitTop - data.pad.bottom;
}
if ( from + $this.outerHeight() > data.end || from >= to ) {
$this.css( { position: "", top: "", left: "" } );
if ( options.activeClass ) { $this.removeClass( options.activeClass ); }
$this.removeClass( 'sticky-transition' );
$this.removeClass( 'sticky-absolute' );
continue;
}
if ( scrollY > from && scrollY < to ) {
!( $this.css( "position" ) == "fixed" ) && $this.css( {
left: $this.offset().left,
top: data.pad.top
} ).css( "position", "fixed" );
if ( options.activeClass ) { $this.addClass( options.activeClass ); }
$this.removeClass( 'sticky-transition' );
$this.removeClass( 'sticky-absolute' );
} else if ( scrollY >= to ) {
$this.css( {
left: "",
top: to - data.parentTop + data.pad.top
} ).css( "position", "absolute" );
if ( options.activeClass ) { $this.addClass( options.activeClass ); }
if ( $this.hasClass( 'sticky-absolute' ) ) $this.addClass( 'sticky-transition' );
$this.addClass( 'sticky-absolute' );
} else {
$this.css( { position: "", top: "", left: "" } );
if ( options.activeClass ) { $this.removeClass( options.activeClass ); }
$this.removeClass( 'sticky-transition' );
$this.removeClass( 'sticky-absolute' );
}
} else if ( options.fitToBottom ) {
var from = data.from,
to = data.to;
if ( data.from + window_height > data.end || data.from >= to ) {
$this.css( { position: "", top: "", bottom: "", left: "" } );
if ( options.activeClass ) { $this.removeClass( options.activeClass ); }
$this.removeClass( 'sticky-transition' );
$this.removeClass( 'sticky-absolute' );
continue;
}
if ( scrollY > from && scrollY < to ) {
!( $this.css( "position" ) == "fixed" ) && $this.css( {
left: $this.offset().left,
bottom: data.pad.bottom,
top: ""
} ).css( "position", "fixed" );
if ( options.activeClass ) { $this.addClass( options.activeClass ); }
$this.removeClass( 'sticky-transition' );
$this.removeClass( 'sticky-absolute' );
} else if ( scrollY >= to ) {
$this.css( {
left: "",
top: data.to2,
bottom: ""
} ).css( "position", "absolute" );
if ( options.activeClass ) { $this.addClass( options.activeClass ); }
if ( $this.hasClass( 'sticky-absolute' ) ) $this.addClass( 'sticky-transition' );
$this.addClass( 'sticky-absolute' );
} else {
$this.css( { position: "", top: "", bottom: "", left: "" } );
if ( options.activeClass ) { $this.removeClass( options.activeClass ); }
$this.removeClass( 'sticky-transition' );
$this.removeClass( 'sticky-absolute' );
}
} else { // auto fit
var this_height = $this.outerHeight()
if ( prevDataTo[ i ] != data.to ) {
if ( fixedSideBottom[ i ] && this_height + $this.offset().top + data.pad.bottom < scrollY + window_height ) {
fixedSideBottom[ i ] = false;
}
}
if ( ( this_height + data.pad.top + data.pad.bottom ) > window_height || fixedSideTop[ i ] || fixedSideBottom[ i ] ) {
var padTop = parseInt( $this.parent().parent().css( 'padding-top' ) );
// Reset the sideSortables style when scrolling to the top.
if ( scrollY + data.pad.top - padTop <= data.parentTop ) {
$this.css( { position: "", top: "", bottom: "", left: "" } );
fixedSideTop[ i ] = fixedSideBottom[ i ] = false;
if ( options.activeClass ) { $this.removeClass( options.activeClass ); }
} else if ( scrollY >= data.to ) {
$this.css( {
left: "",
top: data.to2,
bottom: ""
} ).css( "position", "absolute" );
if ( options.activeClass ) { $this.addClass( options.activeClass ); }
} else {
// When scrolling down.
if ( scrollY >= lastScrollY ) {
if ( fixedSideTop[ i ] ) {
// Let it scroll.
fixedSideTop[ i ] = false;
sidebarTop = $this.offset().top - data.parentTop;
$this.css( {
left: "",
top: sidebarTop,
bottom: ""
} ).css( "position", "absolute" );
if ( options.activeClass ) { $this.addClass( options.activeClass ); }
} else if ( !fixedSideBottom[ i ] && this_height + $this.offset().top + data.pad.bottom < scrollY + window_height ) {
// Pin the bottom.
fixedSideBottom[ i ] = true;
!( $this.css( "position" ) == "fixed" ) && $this.css( {
left: $this.offset().left,
bottom: data.pad.bottom,
top: ""
} ).css( "position", "fixed" );
if ( options.activeClass ) { $this.addClass( options.activeClass ); }
}
// When scrolling up.
} else if ( scrollY < lastScrollY ) {
if ( fixedSideBottom[ i ] ) {
// Let it scroll.
fixedSideBottom[ i ] = false;
sidebarTop = $this.offset().top - data.parentTop;
/*if ($this.css('position') == 'absolute' && sidebarTop > data.to2) {
sidebarTop = data.to2;
}*/
$this.css( {
left: "",
top: sidebarTop,
bottom: ""
} ).css( "position", "absolute" );
if ( options.activeClass ) { $this.addClass( options.activeClass ); }
} else if ( !fixedSideTop[ i ] && $this.offset().top >= scrollY + data.pad.top ) {
// Pin the top.
fixedSideTop[ i ] = true;
!( $this.css( "position" ) == "fixed" ) && $this.css( {
left: $this.offset().left,
top: data.pad.top,
bottom: ''
} ).css( "position", "fixed" );
if ( options.activeClass ) { $this.addClass( options.activeClass ); }
} else if ( !fixedSideBottom[ i ] && fixedSideTop[ i ] && $this.css( 'position' ) == 'absolute' && $this.offset().top >= scrollY + data.pad.top ) {
fixedSideTop[ i ] = false;
}
}
}
} else {
// If the sidebar container is smaller than the viewport, then pin/unpin the top when scrolling.
if ( scrollY >= ( data.parentTop - data.pad.top ) ) {
$this.css( {
position: 'fixed',
top: data.pad.top
} );
} else {
$this.css( { position: "", top: "", bottom: "", left: "" } );
if ( options.activeClass ) { $this.removeClass( options.activeClass ); }
}
fixedSideTop[ i ] = fixedSideBottom[ i ] = false;
}
}
prevDataTo[ i ] = data.to;
}
lastScrollY = scrollY;
};
var update = function () { recalculateLimits(); onScroll(); },
r_timer = null;
this.each( function () {
var $this = $( this ),
data = $( this ).data( 'themePin' ) || {};
if ( data && data.update ) { return; }
elements.push( $this );
$( "img", this ).one( "load", function () {
if ( r_timer ) {
theme.deleteTimeout( r_timer );
}
r_timer = theme.requestFrame( recalculateLimits );
} );
data.update = update;
$( this ).data( 'themePin', data );
fixedSideTop.push( false );
fixedSideBottom.push( false );
prevDataTo.push( 0 );
} );
$window.on( 'touchmove scroll', onScroll );
recalculateLimits();
$window.on( 'load', update );
$( this ).on( 'recalc.pin', function () {
recalculateLimits();
onScroll();
} );
return this;
};
theme = theme || {};
var instanceName = '__sticky';
var Sticky = function ( $el, opts ) {
return this.initialize( $el, opts );
};
Sticky.defaults = {
autoInit: false,
minWidth: 767,
activeClass: 'sticky-active',
padding: {
top: 0,
bottom: 0
},
offsetTop: 0,
offsetBottom: 0,
autoFit: false,
fitToBottom: false
};
Sticky.prototype = {
initialize: function ( $el, opts ) {
if ( $el.data( instanceName ) ) {
return this;
}
this.$el = $el;
this
.setData()
.setOptions( opts )
.build();
return this;
},
setData: function () {
this.$el.data( instanceName, this );
return this;
},
setOptions: function ( opts ) {
this.options = $.extend( true, {}, Sticky.defaults, opts, {
wrapper: this.$el
} );
return this;
},
build: function () {
if ( !( $.isFunction( $.fn.themePin ) ) ) {
return this;
}
var self = this,
$el = this.options.wrapper,
stickyResizeTrigger;
if ( $el.hasClass( 'porto-sticky-nav' ) ) {
this.options.padding.top = theme.StickyHeader.sticky_height + theme.adminBarHeight();
this.options.activeClass = 'sticky-active';
this.options.containerSelector = '.main-content-wrap';
theme.sticky_nav_height = $el.outerHeight();
if ( this.options.minWidth > window.innerWidth )
theme.sticky_nav_height = 0;
}
$el.themePin( this.options );
$( window ).smartresize( function () {
if ( stickyResizeTrigger ) {
clearTimeout( stickyResizeTrigger );
}
stickyResizeTrigger = setTimeout( function () {
$el.trigger( 'recalc.pin' );
}, 800 );
var $parent = $el.parent();
$el.outerWidth( $parent.width() );
if ( $el.css( 'position' ) == 'fixed' ) {
$el.css( 'left', $parent.offset().left );
}
if ( $el.hasClass( 'porto-sticky-nav' ) ) {
theme.sticky_nav_height = $el.outerHeight();
if ( self.options.minWidth > window.innerWidth )
theme.sticky_nav_height = 0;
}
} );
return this;
}
};
// expose to scope
$.extend( theme, {
Sticky: Sticky
} );
// jquery plugin
$.fn.themeSticky = function ( opts ) {
return this.map( function () {
var $this = $( this );
if ( $this.data( instanceName ) ) {
$this.trigger( 'recalc.pin' );
setTimeout( function () {
$this.trigger( 'recalc.pin' );
}, 800 );
return $this.data( instanceName );
} else {
return new theme.Sticky( $this, opts );
}
} );
}
} ).apply( this, [ window.theme, jQuery ] );
// Mobile Panel
( function ( theme, $ ) {
'use strict';
$( function () {
$( document.body ).on( 'click', '.mobile-toggle', function ( e ) {
var $nav_panel = $( '#nav-panel' );
if ( $nav_panel.length > 0 ) {
if ( $( this ).closest( '.header-main' ).length && $nav_panel.closest( '.header-builder-p' ).length && !$nav_panel.parent( '.header-main' ).length ) {
$nav_panel.appendTo( $( this ).closest( '.header-main' ) );
}
if ( $nav_panel.is( ':visible' ) && $( '#header' ).hasClass( 'sticky-header' ) ) {
var h_h = $( '#header' ).height(), p_h = $nav_panel.outerHeight();
if ( h_h > p_h + 30 ) {
$( '#header' ).css( 'height', h_h - p_h );
}
}
$nav_panel.stop().slideToggle();
} else if ( $( '#side-nav-panel' ).length > 0 ) {
$( 'html' ).toggleClass( 'panel-opened' );
$( '.panel-overlay' ).toggleClass( 'active' );
}
if ( $( '#nav-panel .skeleton-body, #side-nav-panel .skeleton-body' ).length ) {
theme.lazyload_menu( 1, 'mobile_menu' );
}
e.preventDefault();
} );
$( document.body ).on( 'click', '.panel-overlay', function () {
$( 'html' ).css( 'transition', 'margin .3s' ).removeClass( 'panel-opened' );
theme.requestTimeout( function () {
$( 'html' ).css( 'transition', '' );
}, 260 );
$( this ).removeClass( 'active' );
} );
$( document.body ).on( 'click', '#side-nav-panel .side-nav-panel-close', function ( e ) {
e.preventDefault();
$( '.panel-overlay' ).trigger('click');
} );
$( window ).on( 'resize', function () {
if ( window.innerWidth > 991 && $( 'html' ).hasClass( 'panel-opened' ) ) {
$( '#nav-panel' ).hide();
$( '.panel-overlay' ).trigger('click');
}
} );
} );
} ).apply( this, [ window.theme, jQuery ] );
// Portfolio Like
( function ( theme, $ ) {
'use strict';
$( function () {
$( document ).on( 'click', '.portfolio-like', function ( e ) {
e.preventDefault();
var $this = $( this ),
$parent = $this.parent(),
portfolio_id = $this.attr( 'data-id' );
$.post(
theme.ajax_url, {
portfolio_id: portfolio_id,
action: 'porto_portfolio-like',
nonce: js_porto_vars.porto_nonce
},
function ( data ) {
if ( data ) {
$this.remove();
$parent.html( data );
$parent.find( "data-tooltip" ).tooltip();
}
}
);
return false;
} );
} );
} ).apply( this, [ window.theme, jQuery ] );
// Blog Like
( function ( theme, $ ) {
'use strict';
$( function () {
$( document ).on( 'click', '.blog-like', function ( e ) {
e.preventDefault();
var $this = $( this ),
$parent = $this.parent(),
blog_id = $this.attr( 'data-id' );
if ( $this.hasClass( 'updating' ) ) {
return false;
}
$this.addClass( 'updating' ).text( '...' );
$.post(
theme.ajax_url, {
blog_id: blog_id,
action: 'porto_blog-like',
nonce: js_porto_vars.porto_nonce
},
function ( data ) {
if ( data ) {
$this.remove();
$parent.html( data );
$parent.find( "data-tooltip" ).tooltip();
}
}
);
return false;
} );
} );
} ).apply( this, [ window.theme, jQuery ] );
// Scroll to Top
//** jQuery Scroll to Top Control script- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
//** Available/ usage terms at http://www.dynamicdrive.com (March 30th, 09')
//** v1.1 (April 7th, 09'):
//** 1) Adds ability to scroll to an absolute position (from top of page) or specific element on the page instead.
//** 2) Fixes scroll animation not working in Opera.
var scrolltotop = {
//startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
//scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
setting: { startline: 100, scrollto: 0, scrollduration: 1000, fadeduration: [ 500, 100 ] },
controlHTML: '

', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
controlattrs: { offsetx: 10, offsety: 10 }, //offset of control relative to right/ bottom of window corner
anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links
state: { isvisible: false, shouldvisible: false },
scrollup: function () {
if ( !this.cssfixedsupport ) //if control is positioned using JavaScript
this.$control.css( { opacity: 0 } ); //hide control immediately after clicking it
var dest = isNaN( this.setting.scrollto ) ? this.setting.scrollto : parseInt( this.setting.scrollto );
if ( typeof dest == "string" && jQuery( '#' + dest ).length == 1 ) //check element set by string exists
dest = jQuery( '#' + dest ).offset().top;
else
dest = 0;
this.$body.stop().animate( { scrollTop: dest }, this.setting.scrollduration );
},
keepfixed: function () {
var $window = jQuery( window );
var controlx = $window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx;
var controly = $window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety;
this.$control.css( { left: controlx + 'px', top: controly + 'px' } );
},
togglecontrol: function () {
var scrolltop = jQuery( window ).scrollTop();
if ( !this.cssfixedsupport )
this.keepfixed();
this.state.shouldvisible = ( scrolltop >= this.setting.startline ) ? true : false;
if ( this.state.shouldvisible && !this.state.isvisible ) {
this.$control.stop().animate( { opacity: 1 }, this.setting.fadeduration[ 0 ] );
this.state.isvisible = true;
}
else if ( this.state.shouldvisible == false && this.state.isvisible ) {
this.$control.stop().animate( { opacity: 0 }, this.setting.fadeduration[ 1 ] );
this.state.isvisible = false;
}
},
init: function () {
jQuery( document ).ready( function ( $ ) {
var mainobj = scrolltotop;
var iebrws = document.all;
mainobj.cssfixedsupport = !iebrws || iebrws && document.compatMode == "CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
mainobj.$body = ( window.opera ) ? ( document.compatMode == "CSS1Compat" ? $( 'html' ) : $( 'body' ) ) : $( 'html,body' );
mainobj.$control = $( '
' + mainobj.controlHTML + '
' )
.css( { position: mainobj.cssfixedsupport ? 'fixed' : 'absolute', bottom: mainobj.controlattrs.offsety, opacity: 0, cursor: 'pointer' } )
.attr( { title: '' } )
.click( function () { mainobj.scrollup(); return false; } )
.appendTo( 'body' );
if ( document.all && !window.XMLHttpRequest && mainobj.$control.text() != '' ) //loose check for IE6 and below, plus whether control contains any text
mainobj.$control.css( { width: mainobj.$control.width() } ); //IE6- seems to require an explicit width on a DIV containing text
mainobj.togglecontrol();
$( 'a[href="' + mainobj.anchorkeyword + '"]' ).click( function () {
mainobj.scrollup();
return false;
} );
$( window ).on( 'scroll resize', function ( e ) {
mainobj.togglecontrol();
} );
} );
}
};
//scrolltotop.init()
( function ( theme, $ ) {
'use strict';
theme = theme || {};
$.extend( theme, {
ScrollToTop: {
defaults: {
html: '
',
offsetx: 10,
offsety: 0
},
initialize: function ( html, offsetx, offsety ) {
if ( $( '#topcontrol' ).length ) {
return this;
}
this.html = ( html || this.defaults.html );
this.offsetx = ( offsetx || this.defaults.offsetx );
this.offsety = ( offsety || this.defaults.offsety );
this.build();
return this;
},
build: function () {
var self = this;
if ( typeof scrolltotop !== 'undefined' ) {
// scroll top control
scrolltotop.controlHTML = self.html;
scrolltotop.controlattrs = { offsetx: self.offsetx, offsety: self.offsety };
scrolltotop.init();
}
return self;
}
}
} );
} ).apply( this, [ window.theme, jQuery ] );
// Mega Menu
( function ( theme, $ ) {
'use strict';
theme = theme || {};
$.extend( theme, {
MegaMenu: {
defaults: {
menu: $( '.mega-menu' )
},
initialize: function ( $menu ) {
this.$menu = ( $menu || this.defaults.menu );
this.build()
.events();
return this;
},
popupWidth: function () {
var winWidth = window.innerWidth,
popupWidth = window.innerWidth - theme.getScrollbarWidth() - theme.grid_gutter_width * 2;
if ( !$( 'body' ).hasClass( 'wide' ) ) {
if ( winWidth >= theme.container_width + theme.grid_gutter_width - 1 )
popupWidth = theme.container_width - theme.grid_gutter_width;
else if ( winWidth >= 992 )
popupWidth = 960 - theme.grid_gutter_width;
else if ( winWidth >= 768 )
popupWidth = 720 - theme.grid_gutter_width;
}
return popupWidth;
},
calcMenuPosition: function ( menu_obj ) {
var menu = menu_obj,
$header_container = $( "#header .header-main .container-fluid" ).length ? $( "#header .header-main .container-fluid" ) : ( $( "#header .header-main .container" ).length ? $( "#header .header-main .container" ) : null );
if ( null === $header_container ) {
return;
}
var menuContainerWidth = $header_container.outerWidth() - parseInt( $header_container.css( 'padding-left' ) ) - parseInt( $header_container.css( 'padding-right' ) );
if ( menuContainerWidth < 900 ) return;
if ( menu.parent().hasClass( 'pos-fullwidth' ) ) {
menu.get( 0 ).style.width = menuContainerWidth + 'px';
}
var browserWidth = Math.max( document.documentElement.clientWidth, window.innerWidth || 0 ) - theme.getScrollbarWidth(),
menuLeftPos = menu.offset().left - ( browserWidth - menuContainerWidth ) / 2;
if ( window.theme.rtl ) {
menuLeftPos = window.innerWidth - theme.getScrollbarWidth() - ( menu.offset().left + menu.outerWidth() ) - ( browserWidth - menuContainerWidth ) / 2;
}
var menuWidth = menu.width(),
remainWidth = menuContainerWidth - ( menuLeftPos + menuWidth ),
l = false;
if ( menuLeftPos > remainWidth && menuLeftPos < menuWidth ) {
l = ( menuLeftPos + remainWidth ) / 3;
}
if ( remainWidth < 0 ) {
l = -remainWidth;
}
return l;
},
build: function ( $menu ) {
var self = this;
if ( !$menu ) {
$menu = self.$menu;
}
$menu.each( function () {
var $menu = $( this ),
$menu_container = $menu.closest( '.container' ),
container_width = self.popupWidth();
if ( $menu.closest( '.porto-popup-menu' ).length ) {
return false;
}
var $menu_items = $menu.children( 'li.has-sub' );
$menu_items.each( function () {
var $menu_item = $( this ),
$popup = $menu_item.children( '.popup' );
if ( $popup.length ) {
var popup_obj = $popup.get( 0 );
popup_obj.style.display = 'block';
if ( $menu_item.hasClass( 'wide' ) ) {
popup_obj.style.left = 0;
var padding = parseInt( $popup.css( 'padding-left' ) ) + parseInt( $popup.css( 'padding-right' ) ) +
parseInt( $popup.find( '> .inner' ).css( 'padding-left' ) ) + parseInt( $popup.find( '> .inner' ).css( 'padding-right' ) );
var row_number = 4;
if ( $menu_item.hasClass( 'col-2' ) ) row_number = 2;
if ( $menu_item.hasClass( 'col-3' ) ) row_number = 3;
if ( $menu_item.hasClass( 'col-4' ) ) row_number = 4;
if ( $menu_item.hasClass( 'col-5' ) ) row_number = 5;
if ( $menu_item.hasClass( 'col-6' ) ) row_number = 6;
if ( window.innerWidth < 992 )
row_number = 1;
var col_length = 0;
$popup.find( '> .inner > ul > li' ).each( function () {
var cols = parseFloat( $( this ).attr( 'data-cols' ) );
if ( cols <= 0 || !cols )
cols = 1;
if ( cols > row_number )
cols = row_number;
col_length += cols;
} );
if ( col_length > row_number ) col_length = row_number;
var popup_max_width = $popup.data( 'popup-mw' ) ? $popup.data( 'popup-mw' ) : $popup.find( '.inner' ).css( 'max-width' ),
col_width = container_width / row_number;
if ( 'none' !== popup_max_width && popup_max_width < container_width ) {
col_width = parseInt( popup_max_width ) / row_number;
}
$popup.find( '> .inner > ul > li' ).each( function () {
var cols = parseFloat( $( this ).data( 'cols' ) );
if ( cols <= 0 )
cols = 1;
if ( cols > row_number )
cols = row_number;
if ( $menu_item.hasClass( 'pos-center' ) || $menu_item.hasClass( 'pos-left' ) || $menu_item.hasClass( 'pos-right' ) )
this.style.width = ( 100 / col_length * cols ) + '%';
else
this.style.width = ( 100 / row_number * cols ) + '%';
} );
if ( $menu_item.hasClass( 'pos-center' ) ) { // position center
$popup.find( '> .inner > ul' ).get( 0 ).style.width = ( col_width * col_length - padding ) + 'px';
var left_position = $popup.offset().left - ( window.innerWidth - theme.getScrollbarWidth() - col_width * col_length ) / 2;
popup_obj.style.left = '-' + left_position + 'px';
} else if ( $menu_item.hasClass( 'pos-left' ) ) { // position left
$popup.find( '> .inner > ul' ).get( 0 ).style.width = ( col_width * col_length - padding ) + 'px';
popup_obj.style.left = '-15px';
} else if ( $menu_item.hasClass( 'pos-right' ) ) { // position right
$popup.find( '> .inner > ul' ).get( 0 ).style.width = ( col_width * col_length - padding ) + 'px';
popup_obj.style.right = '-15px';
popup_obj.style.left = 'auto';
} else { // position justify
if ( !$menu_item.hasClass( 'pos-fullwidth' ) ) {
$popup.find( '> .inner > ul' ).get( 0 ).style.width = ( container_width - padding ) + 'px';
}
if ( theme.rtl ) {
popup_obj.style.right = 0;
popup_obj.style.left = 'auto';
}
var left_position = self.calcMenuPosition( $popup );
if ( theme.rtl ) {
popup_obj.style.right = '-15px';
popup_obj.style.left = 'auto';
if ( left_position ) {
popup_obj.style.right = '-' + left_position + 'px';
}
} else {
popup_obj.style.left = '-15px';
popup_obj.style.right = 'auto';
if ( left_position ) {
popup_obj.style.left = '-' + left_position + 'px';
}
}
}
}
$menu_item.addClass( 'sub-ready' );
}
} );
} );
return self;
},
events: function () {
var self = this;
$( window ).smartresize( function () {
self.build();
} );
$( window ).on( 'load', function () {
theme.requestFrame( function () {
self.build();
} );
} );
return self;
}
}
} );
} ).apply( this, [ window.theme, jQuery ] );
// Sidebar Menu
( function ( theme, $ ) {
'use strict';
theme = theme || {};
$.extend( theme, {
SidebarMenu: {
defaults: {
menu: $( '.sidebar-menu:not(.side-menu-accordion)' ),
toggle: $( '.widget_sidebar_menu .widget-title .toggle' ),
menu_toggle: $( '#main-toggle-menu .menu-title' )
},
rtl: theme.rtl,
initialize: function ( $menu, $toggle, $menu_toggle ) {
if ( this.$menu && this.$menu.length && $menu && $menu.length ) {
this.$menu = $.unique( $.merge( this.$menu, $menu ) );
this.build();
return this;
}
this.$menu = ( $menu || this.defaults.menu );
if ( !this.$menu.length ) {
return this;
}
this.$toggle = ( $toggle || this.defaults.toggle );
this.$menu_toggle = ( $menu_toggle || this.defaults.menu_toggle );
this.build()
.events();
return this;
},
isRightSidebar: function ( $menu ) {
var flag = false;
if ( this.rtl ) {
flag = !( $( '#main' ).hasClass( 'column2-right-sidebar' ) || $( '#main' ).hasClass( 'column2-wide-right-sidebar' ) );
} else {
flag = $( '#main' ).hasClass( 'column2-right-sidebar' ) || $( '#main' ).hasClass( 'column2-wide-right-sidebar' );
}
if ( $menu.closest( '#main-toggle-menu' ).length ) {
if ( this.rtl ) {
flag = true;
} else {
flag = false;
}
}
var $header_wrapper = $menu.closest( '.header-wrapper' );
if ( $header_wrapper.length && $header_wrapper.hasClass( 'header-side-nav' ) ) {
if ( this.rtl ) {
flag = true;
} else {
flag = false;
}
if ( $( '.page-wrapper' ).hasClass( 'side-nav-right' ) ) {
if ( this.rtl ) {
flag = false;
} else {
flag = true;
}
}
}
return flag;
},
popupWidth: function () {
var winWidth = window.innerWidth,
popupWidth = winWidth - theme.getScrollbarWidth() - theme.grid_gutter_width * 2;
if ( !$( 'body' ).hasClass( 'wide' ) ) {
if ( winWidth >= theme.container_width + theme.grid_gutter_width - 1 )
popupWidth = theme.container_width - theme.grid_gutter_width;
else if ( winWidth >= 992 )
popupWidth = 960 - theme.grid_gutter_width;
else if ( winWidth >= 768 )
popupWidth = 720 - theme.grid_gutter_width;
}
return popupWidth;
},
build: function ( $menus ) {
var self = this;
if ( !$menus ) {
$menus = self.$menu;
}
if ( !$menus.length ) {
return;
}
var $parent_toggle_wrap = $menus.parent( '.toggle-menu-wrap' ),
parent_toogle_wrap = null;
if ( $parent_toggle_wrap.length && $parent_toggle_wrap.is( ':hidden' ) ) {
parent_toogle_wrap = $parent_toggle_wrap.get( 0 );
parent_toogle_wrap.style.display = 'block';
parent_toogle_wrap.style.visibility = 'hidden';
}
$menus.each( function () {
var $menu = $( this ), container_width;
if ( $menu.hasClass( 'side-menu-slide' ) ) {
return;
}
if ( window.innerWidth < 992 )
container_width = self.popupWidth();
else {
var menu_width = this.offsetWidth ? this.offsetWidth : $menu.width();
container_width = self.popupWidth() - menu_width - 45;
}
var is_right_sidebar = self.isRightSidebar( $menu ),
$menu_items = $menu.children( 'li' );
$menu_items.each( function () {
var $menu_item = $( this ),
$popup = $menu_item.children( '.popup' );
if ( $popup.length ) {
var popup_obj = $popup.get( 0 ),
is_opened = false;
if ( $popup.is( ':visible' ) ) {
is_opened = true;
} else {
popup_obj.style.display = 'block';
}
if ( $menu_item.hasClass( 'wide' ) ) {
if ( !$menu.hasClass( 'side-menu-columns' ) ) {
popup_obj.style.left = 0;
}
var row_number = 4;
if ( $menu_item.hasClass( 'col-2' ) ) row_number = 2;
if ( $menu_item.hasClass( 'col-3' ) ) row_number = 3;
if ( $menu_item.hasClass( 'col-4' ) ) row_number = 4;
if ( $menu_item.hasClass( 'col-5' ) ) row_number = 5;
if ( $menu_item.hasClass( 'col-6' ) ) row_number = 6;
if ( window.innerWidth < 992 )
row_number = 1;
var col_length = 0;
$popup.find( '> .inner > ul > li' ).each( function () {
var cols = parseFloat( $( this ).data( 'cols' ) );
if ( !cols || cols <= 0 )
cols = 1;
if ( cols > row_number )
cols = row_number;
col_length += cols;
} );
if ( col_length > row_number ) col_length = row_number;
var popup_max_width = $popup.data( 'popup-mw' ) ? $popup.data( 'popup-mw' ) : $popup.find( '.inner' ).css( 'max-width' ),
col_width = container_width / row_number;
if ( 'none' !== popup_max_width && popup_max_width < container_width ) {
col_width = parseInt( popup_max_width ) / row_number;
}
$popup.find( '> .inner > ul > li' ).each( function () {
var cols = parseFloat( $( this ).data( 'cols' ) );
if ( cols <= 0 )
cols = 1;
if ( cols > row_number )
cols = row_number;
if ( $menu_item.hasClass( 'pos-center' ) || $menu_item.hasClass( 'pos-left' ) || $menu_item.hasClass( 'pos-right' ) )
this.style.width = ( 100 / col_length * cols ) + '%';
else
this.style.width = ( 100 / row_number * cols ) + '%';
} );
popup_obj.children[ 0 ].children[ 0 ].style.width = col_width * col_length + 1 + 'px';
if ( !$menu.hasClass( 'side-menu-columns' ) ) {
if ( is_right_sidebar ) {
popup_obj.style.left = 'auto';
popup_obj.style.right = ( this.offsetWidth ? this.offsetWidth : $( this ).width() ) + 'px';
} else {
popup_obj.style.left = ( this.offsetWidth ? this.offsetWidth : $( this ).width() ) + 'px';
popup_obj.style.right = 'auto';
}
}
}
if ( !is_opened ) {
popup_obj.style.display = 'none';
}
if ( $menu.hasClass( 'side-menu-accordion' ) ) {
} else if ( $menu.hasClass( 'side-menu-slide' ) ) {
} else if ( !$menu_item.hasClass( 'sub-ready' ) ) {
$menu_item.hover( function () {
$menu_items.find( '.popup' ).hide();
$popup.show();
$popup.parent().addClass( 'open' );
$( document.body ).trigger( 'appear_refresh' );
}, function () {
$popup.hide();
$popup.parent().removeClass( 'open' );
} );
$menu_item.addClass( 'sub-ready' );
}
}
} );
} );
// slide menu
if ( $menus.hasClass( 'side-menu-slide' ) ) {
var slideNavigation = {
$mainNav: $menus,
$mainNavItem: $menus.find( 'li' ),
build: function () {
var self = this;
self.menuNav();
},
menuNav: function () {
var self = this;
self.$mainNav.find( '.menu-item-has-children > a.nolink' ).removeClass( 'nolink' ).attr( 'href', '' );
self.$mainNav.find( '.menu-item-has-children > a:not(.go-back)' ).off( 'click' ).on( 'click', function ( e ) {
e.stopImmediatePropagation();
e.preventDefault();
var currentMenu = $( this ).closest( 'ul' ),
nextMenu = $( this ).parent().find( 'ul' ).first();
if ( nextMenu.children( '.menu-item' ).children( '.go-back' ).length < 1 ) {
nextMenu.prepend( '' );
}
var nextMenuHeightDiff = nextMenu.find( '> li' ).length * nextMenu.find( '> li' ).outerHeight() - nextMenu.outerHeight();
currentMenu.addClass( 'next-menu' );
nextMenu.addClass( 'visible' );
currentMenu.css( {
overflow: 'visible',
'overflow-y': 'visible'
} );
if ( nextMenuHeightDiff > 0 ) {
nextMenu.css( {
overflow: 'hidden',
'overflow-y': 'scroll'
} );
}
//for (i = 0; i < nextMenu.find('> li').length; i++) {
if ( nextMenu.outerHeight() < ( nextMenu.closest( '.header-main' ).outerHeight() - 100 ) ) {
nextMenu.css( {
height: nextMenu.outerHeight() + nextMenu.find( '> li' ).outerHeight()
} );
}
// }
nextMenu.css( {
'padding-top': nextMenuHeightDiff + 'px'
} );
} );
}
};
slideNavigation.build();
}
if ( parent_toogle_wrap ) {
parent_toogle_wrap.style.display = '';
parent_toogle_wrap.style.visibility = '';
}
return self;
},
events: function () {
var self = this;
self.$toggle.on( 'click', function () {
var $widget = $( this ).parent().parent();
var $this = $( this );
if ( $this.hasClass( 'closed' ) ) {
$this.removeClass( 'closed' );
$widget.removeClass( 'closed' );
$widget.find( '.sidebar-menu-wrap' ).stop().slideDown( 400, function () {
$( this ).attr( 'style', '' ).show();
self.build();
} );
} else {
$this.addClass( 'closed' );
$widget.addClass( 'closed' );
$widget.find( '.sidebar-menu-wrap' ).stop().slideUp( 400, function () {
$( this ).attr( 'style', '' ).hide();
} );
}
} );
this.$menu_toggle.on( 'click', function () {
var $toggle_menu = $( this ).parent();
if ( $toggle_menu.hasClass( 'show-always' ) || $toggle_menu.hasClass( 'show-hover' ) ) {
return;
}
var $this = $( this );
if ( $this.hasClass( 'closed' ) ) {
$this.removeClass( 'closed' );
$toggle_menu.removeClass( 'closed' );
$toggle_menu.find( '.toggle-menu-wrap' ).stop().slideDown( 400, function () {
$( this ).attr( 'style', '' ).show();
} );
self.build();
} else {
$this.addClass( 'closed' );
$toggle_menu.addClass( 'closed' );
$toggle_menu.find( '.toggle-menu-wrap' ).stop().slideUp( 400, function () {
$( this ).attr( 'style', '' ).hide();
} );
}
} );
if ( self.$menu.hasClass( 'side-menu-slide' ) ) {
self.$menu.on( 'click', '.go-back', function ( e ) {
e.preventDefault();
var prevMenu = $( this ).closest( '.next-menu' ),
prevMenuHeightDiff = 0;
if ( prevMenu.length && prevMenu.find( '> li' ).length ) {
prevMenuHeightDiff = prevMenu.find( '> li' ).length * prevMenu.find( '> li' ).outerHeight() - prevMenu.outerHeight();
}
prevMenu.removeClass( 'next-menu' );
$( this ).closest( 'ul' ).removeClass( 'visible' );
if ( prevMenuHeightDiff > 0 ) {
prevMenu.css( {
overflow: 'hidden',
'overflow-y': 'scroll'
} );
}
} );
}
if ( $( '.sidebar-menu:not(.side-menu-accordion)' ).closest( '[data-plugin-sticky]' ).length ) {
var sidebarRefreshTimer;
$( window ).smartresize( function () {
if ( sidebarRefreshTimer ) {
clearTimeout( sidebarRefreshTimer );
}
sidebarRefreshTimer = setTimeout( function () {
self.build();
}, 800 );
} );
} else {
$( window ).smartresize( function () {
self.build();
} );
}
setTimeout( function () {
self.build();
}, 400 );
return self;
}
}
} );
} ).apply( this, [ window.theme, jQuery ] );
// Sticky Header
( function ( theme, $ ) {
'use strict';
theme = theme || {};
$.extend( theme, {
StickyHeader: {
defaults: {
header: $( '#header' )
},
initialize: function ( $header ) {
this.$header = ( $header || this.defaults.header );
this.sticky_height = 0;
this.sticky_pos = 0;
this.change_logo = theme.change_logo;
if ( !theme.show_sticky_header || !this.$header.length || $( '.side-header-narrow-bar' ).length )
return this;
var self = this;
var $menu_wrap = self.$header.find( '> .main-menu-wrap' );
if ( $menu_wrap.length ) {
self.$menu_wrap = $menu_wrap;
self.menu_height = $menu_wrap.height();
} else {
self.$menu_wrap = false;
}
self.$header_main = self.$header.find( '.header-main' );
// fix compatibility issue with Elementor pro header builder
if ( !self.$header_main.length && self.$header.children( '.elementor-location-header' ).length ) {
self.$header_main = self.$header.children( '.elementor-location-header' ).last().addClass( 'header-main' );
}
if ( !self.$header_main.length ) {
return this;
}
self.reveal = self.$header.parents( '.header-wrapper' ).hasClass( 'header-reveal' );
self.is_sticky = false;
self.reset()
.build()
.events();
return self;
},
build: function () {
var self = this;
if ( !self.is_sticky && ( window.innerHeight + self.header_height + theme.adminBarHeight() + parseInt( self.$header.css( 'border-top-width' ) ) >= $( document ).height() ) ) {
return self;
}
if ( window.innerHeight > $( document.body ).height() )
window.scrollTo( 0, 0 );
var scroll_top = $( window ).scrollTop();
if ( self.$menu_wrap && !theme.isTablet() ) {
self.$header_main.stop().css( 'top', 0 );
if ( self.$header.parent().hasClass( 'fixed-header' ) )
self.$header.parent().attr( 'style', '' );
if ( scroll_top > self.sticky_pos ) {
if ( !self.$header.hasClass( 'sticky-header' ) ) {
var header_height = self.$header.outerHeight();
self.$header.addClass( 'sticky-header' ).css( 'height', header_height );
self.$menu_wrap.stop().css( 'top', theme.adminBarHeight() );
var selectric = self.$header.find( '.header-main .searchform select' ).data( 'selectric' );
if ( selectric && typeof selectric.close != 'undefined' )
selectric.close();
if ( self.$header.parent().hasClass( 'fixed-header' ) ) {
self.$header_main.hide();
self.$header.css( 'height', '' );
}
if ( !self.init_toggle_menu ) {
self.init_toggle_menu = true;
theme.MegaMenu.build();
if ( $( '#main-toggle-menu' ).length ) {
if ( $( '#main-toggle-menu' ).hasClass( 'show-always' ) ) {
$( '#main-toggle-menu' ).data( 'show-always', true );
$( '#main-toggle-menu' ).removeClass( 'show-always' );
}
$( '#main-toggle-menu' ).addClass( 'closed' );
$( '#main-toggle-menu .menu-title' ).addClass( 'closed' );
$( '#main-toggle-menu .toggle-menu-wrap' ).attr( 'style', '' );
}
}
self.is_sticky = true;
}
} else {
if ( self.$header.hasClass( 'sticky-header' ) ) {
self.$header.removeClass( 'sticky-header' );
self.$header.css( 'height', '' );
self.$menu_wrap.stop().css( 'top', 0 );
self.$header_main.show();
var selectric = self.$header.find( '.main-menu-wrap .searchform select' ).data( 'selectric' );
if ( selectric && typeof selectric.close != 'undefined' )
selectric.close();
if ( self.init_toggle_menu ) {
self.init_toggle_menu = false;
theme.MegaMenu.build();
if ( $( '#main-toggle-menu' ).length ) {
if ( $( '#main-toggle-menu' ).data( 'show-always' ) ) {
$( '#main-toggle-menu' ).addClass( 'show-always' );
$( '#main-toggle-menu' ).removeClass( 'closed' );
$( '#main-toggle-menu .menu-title' ).removeClass( 'closed' );
$( '#main-toggle-menu .toggle-menu-wrap' ).attr( 'style', '' );
}
}
}
self.is_sticky = false;
}
}
} else {
self.$header_main.show();
if ( self.$header.parent().hasClass( 'fixed-header' ) && $( '#wpadminbar' ).length && $( '#wpadminbar' ).css( 'position' ) == 'absolute' ) {
self.$header.parent().css( 'top', ( $( '#wpadminbar' ).height() - scroll_top ) < 0 ? -$( '#wpadminbar' ).height() : -scroll_top );
} else if ( self.$header.parent().hasClass( 'fixed-header' ) ) {
self.$header.parent().attr( 'style', '' );
} else {
if ( self.$header.parent().hasClass( 'fixed-header' ) )
self.$header.parent().attr( 'style', '' );
}
if ( self.$header.hasClass( 'sticky-menu-header' ) && !theme.isTablet() ) {
self.$header_main.stop().css( 'top', 0 );
if ( self.change_logo ) self.$header_main.removeClass( 'change-logo' );
self.$header_main.removeClass( 'sticky' );
self.$header.removeClass( 'sticky-header' );
self.is_sticky = false;
self.sticky_height = 0;
} else {
if ( self.$menu_wrap )
self.$menu_wrap.stop().css( 'top', 0 );
if ( scroll_top > self.sticky_pos && ( !theme.isTablet() || ( theme.isTablet() && ( !theme.isMobile() && theme.show_sticky_header_tablet ) || ( theme.isMobile() && theme.show_sticky_header_tablet && theme.show_sticky_header_mobile ) ) ) ) {
if ( !self.$header.hasClass( 'sticky-header' ) ) {
var header_height = self.$header.outerHeight();
self.$header.addClass( 'sticky-header' ).css( 'height', header_height );
self.$header_main.addClass( 'sticky' );
if ( self.change_logo ) self.$header_main.addClass( 'change-logo' );
self.$header_main.stop().css( 'top', theme.adminBarHeight() );
if ( !self.init_toggle_menu ) {
self.init_toggle_menu = true;
theme.MegaMenu.build();
if ( $( '#main-toggle-menu' ).length ) {
if ( $( '#main-toggle-menu' ).hasClass( 'show-always' ) ) {
$( '#main-toggle-menu' ).data( 'show-always', true );
$( '#main-toggle-menu' ).removeClass( 'show-always' );
}
$( '#main-toggle-menu' ).addClass( 'closed' );
$( '#main-toggle-menu .menu-title' ).addClass( 'closed' );
$( '#main-toggle-menu .toggle-menu-wrap' ).attr( 'style', '' );
}
}
self.is_sticky = true;
}
} else {
if ( self.$header.hasClass( 'sticky-header' ) ) {
if ( self.change_logo ) self.$header_main.removeClass( 'change-logo' );
self.$header_main.removeClass( 'sticky' );
self.$header.removeClass( 'sticky-header' );
self.$header.css( 'height', '' );
self.$header_main.stop().css( 'top', 0 );
if ( self.init_toggle_menu ) {
self.init_toggle_menu = false;
theme.MegaMenu.build();
if ( $( '#main-toggle-menu' ).length ) {
if ( $( '#main-toggle-menu' ).data( 'show-always' ) ) {
$( '#main-toggle-menu' ).addClass( 'show-always' );
$( '#main-toggle-menu' ).removeClass( 'closed' );
$( '#main-toggle-menu .menu-title' ).removeClass( 'closed' );
$( '#main-toggle-menu .toggle-menu-wrap' ).attr( 'style', '' );
}
}
}
self.is_sticky = false;
}
}
}
}
if ( !self.$header.hasClass( 'header-loaded' ) )
self.$header.addClass( 'header-loaded' );
if ( !self.$header.find( '.logo' ).hasClass( 'logo-transition' ) )
self.$header.find( '.logo' ).addClass( 'logo-transition' );
if ( self.$header.find( '.overlay-logo' ).get( 0 ) && !self.$header.find( '.overlay-logo' ).hasClass( 'overlay-logo-transition' ) )
self.$header.find( '.overlay-logo' ).addClass( 'overlay-logo-transition' );
return self;
},
reset: function () {
var self = this;
if ( self.$header.find( '.logo' ).hasClass( 'logo-transition' ) )
self.$header.find( '.logo' ).removeClass( 'logo-transition' );
if ( self.$header.find( '.overlay-logo' ).get( 0 ) && self.$header.find( '.overlay-logo' ).hasClass( 'overlay-logo-transition' ) )
self.$header.find( '.overlay-logo' ).removeClass( 'overlay-logo-transition' );
if ( self.$menu_wrap && !theme.isTablet() ) {
// show main menu
self.$header.addClass( 'sticky-header sticky-header-calc' );
self.$header_main.addClass( 'sticky' );
if ( self.change_logo ) self.$header_main.addClass( 'change-logo' );
self.sticky_height = self.$menu_wrap.height() + parseInt( self.$menu_wrap.css( 'padding-top' ) ) + parseInt( self.$menu_wrap.css( 'padding-bottom' ) );
if ( self.change_logo ) self.$header_main.removeClass( 'change-logo' );
self.$header_main.removeClass( 'sticky' );
self.$header.removeClass( 'sticky-header sticky-header-calc' );
self.header_height = self.$header.height() + parseInt( self.$header.css( 'margin-top' ) );
self.menu_height = self.$menu_wrap.height() + parseInt( self.$menu_wrap.css( 'padding-top' ) ) + parseInt( self.$menu_wrap.css( 'padding-bottom' ) );
self.sticky_pos = ( self.header_height - self.sticky_height ) + parseInt( $( 'body' ).css( 'padding-top' ) ) + parseInt( self.$header.css( 'border-top-width' ) );
if ( $( '.banner-before-header' ).length ) {
self.sticky_pos += $( '.banner-before-header' ).height();
}
if ( $( '.porto-block-html-top' ).length ) {
self.sticky_pos += $( '.porto-block-html-top' ).height();
}
} else {
// show header main
self.$header.addClass( 'sticky-header sticky-header-calc' );
self.$header_main.addClass( 'sticky' );
if ( self.change_logo ) self.$header_main.addClass( 'change-logo' );
self.sticky_height = self.$header_main.outerHeight();
if ( self.change_logo ) self.$header_main.removeClass( 'change-logo' );
self.$header_main.removeClass( 'sticky' );
self.$header.removeClass( 'sticky-header sticky-header-calc' );
self.header_height = self.$header.height() + parseInt( self.$header.css( 'margin-top' ) );
self.main_height = self.$header_main.height();
if ( !( !theme.isTablet() || ( theme.isTablet() && !theme.isMobile() && theme.show_sticky_header_tablet ) || ( theme.isMobile() && theme.show_sticky_header_tablet && theme.show_sticky_header_mobile ) ) ) {
self.sticky_height = 0;
}
/*if (self.$header_main.length && self.$header.length) {
self.sticky_pos = self.$header_main.offset().top - self.$header.offset().top + $('.banner-before-header').height() + parseInt($('body').css('padding-top')) + parseInt(self.$header.css('border-top-width'));
} else {
self.sticky_pos = $('.banner-before-header').height() + parseInt($('body').css('padding-top')) + parseInt(self.$header.css('border-top-width'));
}
if (theme.adminBarHeight() && self.$header.offset().top > theme.adminBarHeight()) {
self.sticky_pos -= theme.adminBarHeight();
}
self.sticky_pos = (self.header_height - self.sticky_height) + $('.banner-before-header').height() + $('.porto-block-html-top').height() + parseInt($('body').css('padding-top')) + parseInt(self.$header.css('border-top-width'));*/
self.sticky_pos = self.$header.offset().top + self.header_height - self.sticky_height - theme.adminBarHeight() + parseInt( self.$header.css( 'border-top-width' ) );
}
if ( self.reveal ) {
if ( self.menu_height ) {
self.sticky_pos += self.menu_height + 30;
} else {
self.sticky_pos += 30;
}
}
if ( self.sticky_pos < 0 ) {
self.sticky_pos = 0;
}
self.init_toggle_menu = false;
self.$header_main.removeAttr( 'style' );
if ( !theme.isTablet() && self.$header.hasClass( 'header-side' ) && typeof self.$header.attr( 'data-plugin-sticky' ) != 'undefined' ) {
self.$header.css( 'height', '' );
} else {
self.$header.removeAttr( 'style' );
}
return self;
},
events: function () {
var self = this, win_width = 0;
$( window ).smartresize( function () {
if ( win_width != window.innerWidth ) {
self.reset().build();
win_width = window.innerWidth;
}
} );
window.addEventListener( 'scroll', function () {
theme.requestFrame( function () {
self.build();
} );
}, { passive: true } );
return self;
}
}
} );
} ).apply( this, [ window.theme, jQuery ] );
// Side Nav
( function ( theme, $ ) {
'use strict';
theme = theme || {};
$.extend( theme, {
SideNav: {
defaults: {
side_nav: $( '.header-side-nav #header' )
},
bc_pos_top: 0,
initialize: function ( $side_nav ) {
this.$side_nav = ( $side_nav || this.defaults.side_nav );
if ( !this.$side_nav.length )
return this;
var self = this;
self.$side_nav.addClass( 'initialize' );
self.reset()
.build()
.events();
return self;
},
build: function () {
var self = this;
var $page_top = $( '.page-top' ),
$main = $( '#main' );
if ( theme.isTablet() ) {
//self.$side_nav.removeClass("fixed-bottom");
$page_top.removeClass( "fixed-pos" );
$page_top.attr( 'style', '' );
$main.attr( 'style', '' );
} else {
//var side_height = self.$side_nav.innerHeight();
//var window_height = window.innerHeight;
var scroll_top = $( window ).scrollTop();
/*if (side_height - window_height + theme.adminBarHeight() < scroll_top) {
if (!self.$side_nav.hasClass("fixed-bottom"))
self.$side_nav.addClass("fixed-bottom");
} else {
if (self.$side_nav.hasClass("fixed-bottom"))
self.$side_nav.removeClass("fixed-bottom");
}*/
if ( $page_top.length && $page_top.outerHeight() < 100 && !$( '.side-header-narrow-bar-top' ).length ) {
if ( self.page_top_offset == theme.adminBarHeight() || self.page_top_offset <= scroll_top ) {
if ( !$page_top.hasClass( "fixed-pos" ) ) {
$page_top.addClass( "fixed-pos" );
$page_top.css( 'top', theme.adminBarHeight() );
$main.css( 'padding-top', $page_top.outerHeight() );
}
} else {
if ( $page_top.hasClass( "fixed-pos" ) ) {
$page_top.removeClass( "fixed-pos" );
$page_top.attr( 'style', '' );
$main.attr( 'style', '' );
}
}
}
$main.css( 'min-height', window.innerHeight - theme.adminBarHeight() - $( '.page-top:not(.fixed-pos)' ).height() - $( '.footer-wrapper' ).height() );
}
return self;
},
reset: function () {
var self = this;
if ( theme.isTablet() ) {
self.$side_nav.attr( 'style', '' );
} else {
var w_h = window.innerHeight,
$side_bottom = self.$side_nav.find( '.side-bottom' );
self.$side_nav.css( {
'min-height': w_h - theme.adminBarHeight(),
'padding-bottom': $side_bottom.length ? $side_bottom.height() + parseInt( $side_bottom.css( 'margin-top' ) ) + parseInt( $side_bottom.css( 'margin-bottom' ) ) : ''
} );
var appVersion = navigator.appVersion;
var webkitVersion_positionStart = appVersion.indexOf( "AppleWebKit/" ) + 12;
var webkitVersion_positionEnd = webkitVersion_positionStart + 3;
var webkitVersion = appVersion.slice( webkitVersion_positionStart, webkitVersion_positionEnd );
if ( webkitVersion < 537 ) {
self.$side_nav.css( '-webkit-backface-visibility', 'hidden' );
self.$side_nav.css( '-webkit-perspective', '1000' );
}
}
var $page_top = $( '.page-top' ),
$main = $( '#main' );
if ( $page_top.length ) {
$page_top.removeClass( "fixed-pos" );
$page_top.attr( 'style', '' );
$main.attr( 'style', '' );
self.page_top_offset = $page_top.offset().top;
}
return self;
},
events: function () {
var self = this;
$( window ).on( 'resize', function () {
self.reset()
.build();
} );
window.addEventListener( 'scroll', function () {
self.build();
}, { passive: true } );
if ( $( '.side-header-narrow-bar-top' ).length ) {
if ( $( window ).scrollTop() > theme.adminBarHeight() + $( '.side-header-narrow-bar-top' ).height() ) {
$( '.side-header-narrow-bar-top' ).addClass( 'side-header-narrow-bar-sticky' );
}
window.addEventListener( 'scroll', function () {
var scroll_top = $( this ).scrollTop();
if ( scroll_top > theme.adminBarHeight() + $( '.side-header-narrow-bar-top' ).height() ) {
$( '.side-header-narrow-bar-top' ).addClass( 'side-header-narrow-bar-sticky' );
} else {
$( '.side-header-narrow-bar-top' ).removeClass( 'side-header-narrow-bar-sticky' );
}
}, { passive: true } );
}
// Side Narrow Bar
$( '.side-header-narrow-bar .hamburguer-btn' ).on( 'click', function () {
$( this ).toggleClass( 'active' );
$( '#header' ).toggleClass( 'side-header-visible' );
if ( $( this ).closest( '.side-header-narrow-bar-top' ).length && !$( '#header > .hamburguer-btn' ).length ) {
$( this ).closest( '.side-header-narrow-bar-top' ).toggle();
}
} );
$( '.hamburguer-close' ).on( 'click', function () {
$( '.side-header-narrow-bar .hamburguer-btn' ).trigger( 'click' );
} );
return self;
}
}
} );
} ).apply( this, [ window.theme, jQuery ] );
// Search
( function ( theme, $ ) {
'use strict';
theme = theme || {};
$.extend( theme, {
Search: {
defaults: {
popup: $( '.searchform-popup' ),
form: $( '.searchform' )
},
initialize: function ( $popup, $form ) {
this.$popup = ( $popup || this.defaults.popup );
this.$form = ( $form || this.defaults.form );
this.build()
.events();
return this;
},
build: function () {
var self = this;
/* Change search form values */
var $search_form_texts = self.$form.find( '.text input' ),
$search_form_cats = self.$form.find( '.cat' );
if ( $( '.header-wrapper .searchform .cat' ).get( 0 ) && $.fn.selectric ) {
$( '.header-wrapper .searchform .cat' ).selectric( {
arrowButtonMarkup: '',
expandToItemText: true,
maxHeight: 240
} );
}
$search_form_texts.on( 'change', function () {
var $this = $( this ),
val = $this.val();
$search_form_texts.each( function () {
if ( $this != $( this ) ) $( this ).val( val );
} );
} );
$search_form_cats.on( 'change', function () {
var $this = $( this ),
val = $this.val();
$search_form_cats.each( function () {
if ( $this != $( this ) ) $( this ).val( val );
} );
} );
return this;
},
events: function () {
var self = this;
self.$popup.on( 'click', function ( e ) {
e.stopPropagation();
} );
self.$popup.find( '.search-toggle' ).on( 'click', function ( e ) {
$( this ).toggleClass( 'opened' );
$( this ).next().toggle();
if ( $( this ).hasClass( 'opened' ) ) {
$( '#mini-cart.open' ).removeClass( 'open' );
$( this ).next().find( 'input[type="text"]' ).focus();
if ( self.$popup.find( '.btn-close-search-form' ).length ) {
self.$popup.parent().addClass( 'position-static' );
}
}
e.stopPropagation();
} );
$( 'html,body' ).on( 'click', function () {
self.removeFormStyle();
} );
if ( !( 'ontouchstart' in document ) ) {
$( window ).on( 'resize', function () {
self.removeFormStyle();
} );
$( '.btn-close-search-form' ).on( 'click', function ( e ) {
e.preventDefault();
self.removeFormStyle();
} );
}
return self;
},
removeFormStyle: function () {
this.$form.removeAttr( 'style' );
this.$popup.find( '.search-toggle' ).removeClass( 'opened' );
if ( this.$popup.find( '.btn-close-search-form' ).length ) {
this.$popup.parent().removeClass( 'position-static' );
}
}
}
} );
} ).apply( this, [ window.theme, jQuery ] );
// Hash Scroll
( function ( theme, $ ) {
'use strict';
theme = theme || {};
$.extend( theme, {
HashScroll: {
initialize: function () {
this.build()
.events();
return this;
},
build: function () {
var self = this;
try {
var hash = window.location.hash;
var target = $( hash );
if ( target.length && !( hash == '#review_form' || hash == '#reviews' || hash.indexOf( '#comment-' ) != -1 ) ) {
$( 'html, body' ).delay( 600 ).stop().animate( {
scrollTop: target.offset().top - theme.StickyHeader.sticky_height - theme.adminBarHeight() - theme.sticky_nav_height + 1
}, 600, 'easeOutQuad' );
}
return self;
} catch ( err ) {
return self;
}
},
getTarget: function ( href ) {
if ( '#' == href || href.endsWith( '#' ) ) {
return false;
}
var target;
if ( href.indexOf( '#' ) == 0 ) {
target = $( href );
} else {
var url = window.location.href;
url = url.substring( url.indexOf( '://' ) + 3 );
if ( url.indexOf( '#' ) != -1 )
url = url.substring( 0, url.indexOf( '#' ) );
href = href.substring( href.indexOf( '://' ) + 3 );
href = href.substring( href.indexOf( url ) + url.length );
if ( href.indexOf( '#' ) == 0 ) {
target = $( href );
}
}
return target;
},
activeMenuItem: function () {
var self = this;
var scroll_pos = $( window ).scrollTop();
var $menu_items = $( '.menu-item > a[href*="#"], .porto-sticky-nav .nav > li > a[href*="#"]' );
if ( $menu_items.length ) {
$menu_items.each( function () {
var $this = $( this ),
href = $this.attr( 'href' ),
target = self.getTarget( href );
if ( target && target.get( 0 ) ) {
if ( $this.parent().is( ':last-child' ) && scroll_pos + window.innerHeight >= target.offset().top + target.outerHeight() ) {
$this.parent().siblings().removeClass( 'active' );
$this.parent().addClass( 'active' );
} else {
var scroll_to = target.offset().top - theme.StickyHeader.sticky_height - theme.adminBarHeight() - theme.sticky_nav_height + 1,
$parent = $this.parent();
//if (scroll_to <= theme.StickyHeader.sticky_pos + theme.sticky_nav_height) {
//scroll_to = theme.StickyHeader.sticky_pos + theme.sticky_nav_height + 1;
//}
if ( scroll_to <= scroll_pos + 5 ) {
$parent.siblings().removeClass( 'active' );
$parent.addClass( 'active' );
if ( $parent.closest( '.secondary-menu' ).length ) {
$parent.closest( '#header' ).find( '.main-menu' ).eq( 0 ).children( '.menu-item.active' ).removeClass( 'active' );
}
} else {
$parent.removeClass( 'active' );
}
}
}
} );
}
return self;
},
events: function () {
var self = this;
$( '.menu-item > a[href*="#"], .porto-sticky-nav .nav > li > a[href*="#"], a[href*="#"].hash-scroll, .hash-scroll-wrap a[href*="#"]' ).on( 'click', function ( e ) {
e.preventDefault();
var $this = $( this ),
href = $this.attr( 'href' ),
target = self.getTarget( href );
if ( target && target.get( 0 ) ) {
var $parent = $this.parent();
var scroll_to = target.offset().top - theme.StickyHeader.sticky_height - theme.adminBarHeight() - theme.sticky_nav_height + 1;
// if (scroll_to <= theme.StickyHeader.sticky_pos + theme.sticky_nav_height) {
// scroll_to = theme.StickyHeader.sticky_pos + theme.sticky_nav_height + 1;
// }
$( 'html, body' ).stop().animate( {
scrollTop: scroll_to
}, 600, 'easeOutQuad', function () {
//self.activeMenuItem();
$parent.siblings().removeClass( 'active' );
$parent.addClass( 'active' );
} );
if ( $this.closest( '.porto-popup-menu.opened' ).length ) {
$this.closest( '.porto-popup-menu.opened' ).children( '.hamburguer-btn' ).trigger( 'click' );
}
} else if ( ( '#' != href || !$this.closest( '.porto-popup-menu.opened' ).length ) && !$this.hasClass( 'nolink' ) ) {
window.location.href = $this.attr( 'href' );
}
} );
/*window.addEventListener( 'scroll', function () {
self.activeMenuItem();
}, { passive: true } );*/
var $menu_items = $( '.menu-item > a[href*="#"], .porto-sticky-nav .nav > li > a[href*="#"]' );
$menu_items.each(function() {
var rootMargin = '-20% 0px -80% 0px',
isLast = $(this).parent().is(':last-child');
if (isLast) {
var obj = document.getElementById(this.hash.replace('#', ''));
if (obj && document.body.offsetHeight - obj.offsetTop < window.innerHeight) {
var ratio = (window.innerHeight - document.body.offsetHeight + obj.offsetTop) / window.innerHeight * 0.8;
ratio = Math.round(ratio * 100);
rootMargin = '-' + (20 + ratio) + '% 0px -' + (80 - ratio) + '% 0px';
}
}
var callback = function() {
if (this && typeof this[0] != 'undefined' && this[0].id) {
$('.menu-item > a[href*="#' + this[0].id + '"], .porto-sticky-nav .nav > li > a[href*="#' + this[0].id + '"]').parent().addClass('active').siblings().removeClass('active');
}
};
self.scrollSpyIntObs( this.hash, callback, {
rootMargin: rootMargin,
threshold: 0
}, true, isLast, true, $menu_items, $(this).parent().index());
});
//self.activeMenuItem();
return self;
},
scrollSpyIntObs: function(selector, functionName, intObsOptions, alwaysObserve, isLast, firstLoad, $allItems, index) {
if (typeof IntersectionObserver == 'undefined') {
return this;
}
var obj = document.getElementById(selector.replace('#', ''));
if (!obj) {
return this;
}
var self = this;
var intersectionObserverOptions = {
rootMargin: '0px 0px 200px 0px'
}
if( Object.keys(intObsOptions).length ) {
intersectionObserverOptions = $.extend(intersectionObserverOptions, intObsOptions);
}
var observer = new IntersectionObserver(function(entries) {
for(var i=0; i < entries.length; i++) {
var entry = entries[i];
if (entry.intersectionRatio > 0 ) {
if( typeof functionName === 'string' ) {
var func = Function( 'return ' + functionName )();
} else {
var callback = functionName;
callback.call( $(entry.target) );
}
} else {
if ( firstLoad == false ) {
if ( isLast ) {
$allItems.filter('[href*="' + entry.target.id + '"]').parent().prev().addClass('active').siblings().removeClass('active');
}
}
firstLoad = false;
}
}
}, intersectionObserverOptions);
observer.observe(obj);
return this;
}
}
} );
} ).apply( this, [ window.theme, jQuery ] );
// Sort Filter
( function ( theme, $ ) {
'use strict';
theme = theme || {};
$.extend( theme, {
SortFilter: {
defaults: {
filters: '.porto-sort-filters ul',
elements: '.porto-sort-container .row'
},
initialize: function ( $elements, $filters ) {
this.$elements = ( $elements || $( this.defaults.elements ) );
this.$filters = ( $filters || $( this.defaults.filters ) );
this.build();
return this;
},
build: function () {
var self = this;
self.$elements.each( function () {
var $this = $( this );
$this.isotope( {
itemSelector: '.porto-sort-item',
layoutMode: 'masonry',
getSortData: {
popular: '[data-popular] parseInt'
},
sortBy: 'popular',
isOriginLeft: !theme.rtl
} );
$this.isotope( 'on', 'layoutComplete', function () {
$this.find( '.porto-lazyload:not(.lazy-load-loaded)' ).trigger( 'appear' );
} );
$this.waitForImages( function () {
if ( $this.data( 'isotope' ) ) {
$this.isotope( 'layout' );
}
} );
} );
self.$filters.each( function () {
var $this = $( this );
var id = $this.attr( 'data-sort-id' );
var $container = $( '#' + id );
if ( $container.length ) {
$this.on( 'click', 'li', function ( e ) {
e.preventDefault();
var $that = $( this );
$this.find( 'li' ).removeClass( 'active' );
$that.addClass( "active" );
var sortByValue = $that.attr( 'data-sort-by' );
$container.isotope( { sortBy: sortByValue } );
var filterByValue = $that.attr( 'data-filter-by' );
if ( filterByValue ) {
$container.isotope( { filter: filterByValue } );
} else {
$container.isotope( { filter: '.porto-sort-item' } );
}
theme.refreshVCContent();
} );
$this.find( 'li[data-active]' ).click();
}
} );
return self;
}
}
} );
} ).apply( this, [ window.theme, jQuery ] );
/*
* Footer Reveal
*/
( function ( $ ) {
var $footerReveal = {
$wrapper: $( '.footer-reveal' ),
init: function () {
var self = this;
self.build();
self.events();
},
build: function () {
var self = this,
footer_height = self.$wrapper.outerHeight( true ),
window_height = window.innerHeight - theme.adminBarHeight();
if ( $( '#header .header-main' ).length ) {
window_height -= $( '#header .header-main' ).height();
}
if ( footer_height > window_height ) {
$( '.footer-wrapper' ).removeClass( 'footer-reveal' );
$( '.page-wrapper' ).css( 'margin-bottom', 0 );
} else {
$( '.footer-wrapper' ).addClass( 'footer-reveal' );
$( '.page-wrapper' ).css( 'margin-bottom', footer_height );
if (document.body.offsetHeight < window.innerHeight) {
document.body.style.paddingBottom = '0.1px';
}
}
},
events: function () {
var self = this,
$window = $( window );
$window.smartresize( function () {
self.build();
} );
}
}
if ( $( '.footer-reveal' ).get( 0 ) ) {
$footerReveal.init();
}
} )( jQuery );
// Float Element
( function ( theme, $ ) {
'use strict';
theme = theme || {};
var instanceName = '__floatElement';
var PluginFloatElement = function ( $el, opts ) {
return this.initialize( $el, opts );
};
PluginFloatElement.defaults = {
startPos: 'top',
speed: 3,
horizontal: false,
transition: false,
transitionDelay: 0,
transitionDuration: 500
};
PluginFloatElement.prototype = {
initialize: function ( $el, opts ) {
if ( $el.data( instanceName ) ) {
return this;
}
this.$el = $el;
this
.setData()
.setOptions( opts )
.build();
return this;
},
setData: function () {
this.$el.data( instanceName, this );
return this;
},
setOptions: function ( opts ) {
this.options = $.extend( true, {}, PluginFloatElement.defaults, opts, {
wrapper: this.$el
} );
return this;
},
build: function () {
var self = this,
$el = this.options.wrapper,
$window = $( window ),
minus;
if ( self.options.style ) {
$el.attr( 'style', self.options.style );
}
if ( $window.width() > 767 ) {
// Set Start Position
if ( self.options.startPos == 'none' ) {
minus = '';
} else if ( self.options.startPos == 'top' ) {
$el.css( {
top: 0
} );
minus = '';
} else {
$el.css( {
bottom: 0
} );
minus = '-';
}
// Set Transition
if ( self.options.transition ) {
$el.css( {
transition: 'ease-out transform ' + self.options.transitionDuration + 'ms ' + self.options.transitionDelay + 'ms'
} );
}
// First Load
self.movement( minus );
// Scroll
window.addEventListener( 'scroll', function () {
self.movement( minus );
}, { passive: true } );
}
return this;
},
movement: function ( minus ) {
var self = this,
$el = this.options.wrapper,
$window = $( window ),
scrollTop = $window.scrollTop(),
elementOffset = $el.offset().top,
currentElementOffset = ( elementOffset - scrollTop );
var scrollPercent = 100 * currentElementOffset / ( $window.height() );
if ( $el.visible( true ) ) {
if ( !self.options.horizontal ) {
$el.css( {
transform: 'translate3d(0, ' + minus + scrollPercent / self.options.speed + '%, 0)'
} );
} else {
$el.css( {
transform: 'translate3d(' + minus + scrollPercent / self.options.speed + '%, ' + minus + scrollPercent / self.options.speed + '%, 0)'
} );
}
}
}
};
// expose to scope
$.extend( theme, {
PluginFloatElement: PluginFloatElement
} );
// jquery plugin
$.fn.themePluginFloatElement = function ( opts ) {
return this.map( function () {
var $this = $( this );
if ( $this.data( instanceName ) ) {
return $this.data( instanceName );
} else {
return new PluginFloatElement( $this, opts );
}
} );
}
} ).apply( this, [ window.theme, jQuery ] );
// Init Theme
function porto_init( $wrap ) {
'use strict';
jQuery( window ).on( 'touchstart', function () { } );
if ( !$wrap ) {
$wrap = jQuery( document.body );
}
$wrap.trigger( 'porto_init_start' );
( function ( $ ) {
// Accordion
if ( $.isFunction( $.fn.themeAccordion ) ) {
$( function () {
$wrap.find( '.accordion:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themeAccordion( opts );
} );
} );
}
// Accordion Menu
if ( $.isFunction( $.fn.themeAccordionMenu ) ) {
$( function () {
$wrap.find( '.accordion-menu:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themeAccordionMenu( opts );
} );
} );
}
// Animate
if ( $.isFunction( $.fn.themeAnimate ) ) {
$( function () {
$wrap.find( '[data-plugin-animate], [data-appear-animation]' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions ) {
if ( typeof pluginOptions == 'string' ) {
opts = JSON.parse( pluginOptions.replace( /'/g, '"' ).replace( ';', '' ) );
} else {
opts = pluginOptions;
}
}
$this.themeAnimate( opts );
} );
} );
}
// Animated Letters
if ($.isFunction($.fn.themePluginAnimatedLetters) && ( $('[data-plugin-animated-letters]').length || $('.animated-letters').length )) {
$( function () {
$wrap.find( '[data-plugin-animated-letters]:not(.manual), .animated-letters' ).each( function () {
theme.appear( $( this ).get(0), function() {
var opts;
var pluginOptions = $( this ).data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$( this ).themePluginAnimatedLetters( opts );
}, {
accX: 0,
accY: -50
});
} );
} );
}
// Carousel
if ( $.isFunction( $.fn.themeCarousel ) ) {
$( function () {
// Carousel Lazyload images
var portoCarouselInit = function ( e ) {
var $this = $( e.currentTarget );
if ( $this.find( '.owl-item.cloned' ).length ) {
$this.find( '.porto-lazyload:not(.lazy-load-loaded)' ).themePluginLazyLoad( { effect: 'fadeIn', effect_speed: 400 } );
$this.find( '.appear-animation' ).themeAnimate();
}
setTimeout( function () {
var $hiddenItems = $this.find( '.owl-item:not(.active)' );
if ( !$( 'html' ).hasClass( 'no-csstransitions' ) && window.innerWidth > 767 ) {
$hiddenItems.find( '.appear-animation' ).removeClass( 'appear-animation-visible' );
$hiddenItems.find( '.appear-animation' ).each( function () {
var $el = $( this ),
delay = Math.abs( $el.data( 'appear-animation-delay' ) ? $el.data( 'appear-animation-delay' ) : 0 );
if ( delay > 1 ) {
this.style.animationDelay = delay + 'ms';
}
var duration = Math.abs( $el.data( 'appear-animation-duration' ) ? $el.data( 'appear-animation-duration' ) : 1000 );
if ( 1000 != duration ) {
this.style.animationDuration = duration + 'ms';
}
} );
}
if ( window.innerWidth >= 1200 ) {
$hiddenItems.find( '[data-vce-animate]' ).removeAttr( 'data-vcv-o-animated' );
}
}, 300 );
};
var portoCarouselTranslated = function ( e ) {
var $this = $( e.currentTarget );
if ( window.innerWidth > 767 ) {
if ( $this.find( '.owl-item.cloned' ).length && $this.find( '.appear-animation:not(.appear-animation-visible)' ).length ) {
$( document.body ).trigger( 'appear_refresh' );
}
}
var $active = $this.find( '.owl-item.active' );
if ( $active.hasClass( 'translating' ) ) {
$active.removeClass( 'translating' );
return;
}
$this.find( '.owl-item.translating' ).removeClass( 'translating' );
// Animated Letters
$this.find('[data-plugin-animated-letters]').removeClass('invisible');
$this.find('.owl-item.active [data-plugin-animated-letters]').trigger('animated.letters.initialize');
if ( window.innerWidth > 767 ) {
// WPBakery
$this.find( '.appear-animation' ).removeClass( 'appear-animation-visible' );
$active.find( '.appear-animation' ).each( function () {
var $animation_item = $( this ),
anim_name = $animation_item.data( 'appear-animation' );
$animation_item.addClass( anim_name + ' appear-animation-visible' );
} );
}
// Elementor
$active.find( '.slide-animate' ).each( function () {
var $animation_item = $( this ),
settings = $animation_item.data( 'settings' );
if ( settings && ( settings._animation || settings.animation ) ) {
var animation = settings._animation || settings.animation,
delay = settings._animation_delay || settings.animation_delay || 0;
theme.requestTimeout( function () {
$animation_item.removeClass( 'elementor-invisible' ).addClass( 'animated ' + animation );
}, delay );
}
} );
// Visual Composer
if ( window.innerWidth >= 1200 ) {
$this.find( '[data-vce-animate]' ).removeAttr( 'data-vcv-o-animated' ).removeAttr( 'data-vcv-o-animated-fully' );
$active.find( '[data-vce-animate]' ).each( function () {
var $animation_item = $( this );
if ( $animation_item.data( 'porto-origin-anim' ) ) {
var anim_name = $animation_item.data( 'porto-origin-anim' );
$animation_item.attr( 'data-vce-animate', anim_name ).attr( 'data-vcv-o-animated', true );
var duration = parseFloat( window.getComputedStyle( this )[ 'animationDuration' ] ) * 1000,
delay = parseFloat( window.getComputedStyle( this )[ 'animationDelay' ] ) * 1000;
window.setTimeout( function () {
$animation_item.attr( 'data-vcv-o-animated-fully', true );
}, delay + duration + 5 );
}
} );
}
};
var portoCarouselTranslateVC = function ( e ) {
var $this = $( e.currentTarget );
$this.find( '.owl-item.active' ).addClass( 'translating' );
if ( window.innerWidth >= 1200 ) {
$this.find( '[data-vce-animate]' ).each( function () {
var $animation_item = $( this );
$animation_item.data( 'porto-origin-anim', $animation_item.data( 'vce-animate' ) ).attr( 'data-vce-animate', '' );
} );
}
};
var portoCarouselTranslateElementor = function ( e ) {
var $this = $( e.currentTarget );
$this.find( '.owl-item.active' ).addClass( 'translating' );
$this.find( '.owl-item:not(.active) .slide-animate' ).addClass( 'elementor-invisible' );
$this.find( '.slide-animate' ).each( function () {
var $animation_item = $( this ),
settings = $animation_item.data( 'settings' );
if ( settings._animation || settings.animation ) {
$animation_item.removeClass( settings._animation || settings.animation );
}
} );
};
var portoCarouselTranslateWPB = function ( e ) {
if ( window.innerWidth > 767 ) {
var $this = $( e.currentTarget );
$this.find( '.owl-item.active' ).addClass( 'translating' );
$this.find( '.appear-animation' ).each( function () {
var $animation_item = $( this );
$animation_item.removeClass( $animation_item.data( 'appear-animation' ) );
} );
}
};
var carouselItems = $wrap.find( '.owl-carousel:not(.manual)' );
carouselItems.on( 'initialized.owl.carousel refreshed.owl.carousel', portoCarouselInit ).on( 'translated.owl.carousel', portoCarouselTranslated );
carouselItems.on( 'translate.owl.carousel', function() {
// Hide elements inside carousel
$(this).find('[data-plugin-animated-letters]').addClass('invisible');
// Animated Letters
$(this).find('[data-plugin-animated-letters]').trigger('animated.letters.destroy');
});
carouselItems.filter( function () {
if ( $( this ).find( '[data-vce-animate]' ).length ) {
return true;
}
return false;
} ).on( 'translate.owl.carousel', portoCarouselTranslateVC );
carouselItems.filter( function () {
var $anim_obj = $( this ).find( '.elementor-invisible' );
if ( $anim_obj.length ) {
$anim_obj.addClass( 'slide-animate' );
return true;
}
return false;
} ).on( 'translate.owl.carousel', portoCarouselTranslateElementor );
carouselItems.filter( function () {
if ( $( this ).find( '.appear-animation' ).length ) {
return true;
}
return false;
} ).on( 'translate.owl.carousel', portoCarouselTranslateWPB );
$wrap.find( '[data-plugin-carousel]:not(.manual), .porto-carousel:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themeCarousel( opts );
} );
} );
}
// Chart.Circular
if ( $.isFunction( $.fn.themeChartCircular ) ) {
$( function () {
$wrap.find( '[data-plugin-chart-circular]:not(.manual), .circular-bar-chart:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themeChartCircular( opts );
} );
} );
}
// Fit Video
if ( $.isFunction( $.fn.themeFitVideo ) ) {
$( function () {
$wrap.find( '.fit-video:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themeFitVideo( opts );
} );
} );
}
// Video Background
if ( $.isFunction( $.fn.themePluginVideoBackground ) ) {
$( function () {
$wrap.find( '[data-plugin-video-background]:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = JSON.parse( $this.data( 'plugin-options' ).replace( /'/g, '"' ).replace( ';', '' ) );
if ( pluginOptions )
opts = pluginOptions;
$this.themePluginVideoBackground( opts );
} );
} );
}
// Flickr Zoom
if ( $.isFunction( $.fn.themeFlickrZoom ) ) {
$( function () {
$wrap.find( '.wpb_flickr_widget:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themeFlickrZoom( opts );
} );
} );
}
// Lazy Load
if ( $.isFunction( $.fn.themePluginLazyLoad ) ) {
$( function () {
$wrap.find( '[data-plugin-lazyload]:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themePluginLazyLoad( opts );
} );
$wrap.find( '.porto-lazyload' ).filter( function () {
if ( $( this ).data( '__lazyload' ) || ( $( this ).closest( '.owl-carousel' ).length && $( this ).closest( '.owl-carousel' ).find( '.owl-item.cloned' ).length ) ) {
return false;
}
return true;
} ).themePluginLazyLoad( { effect: 'fadeIn', effect_speed: 400 } );
if ( $wrap.find( '.porto-lazyload' ).closest( '.nivoSlider' ).length ) {
theme.requestTimeout( function () {
$wrap.find( '.nivoSlider' ).each( function () {
if ( $( this ).find( '.porto-lazyload' ).length ) {
$( this ).closest( '.nivoSlider' ).find( '.nivo-main-image' ).attr( 'src', $( this ).closest( '.nivoSlider' ).find( '.porto-lazyload' ).eq( 0 ).attr( 'src' ) );
}
} );
}, 100 );
}
if ( $wrap.find( '.porto-lazyload' ).closest( '.porto-carousel-wrapper' ).length ) {
theme.requestTimeout( function () {
$wrap.find( '.porto-carousel-wrapper' ).each( function () {
if ( $( this ).find( '.porto-lazyload:not(.lazy-load-loaded)' ).length ) {
$( this ).find( '.slick-list' ).css( 'height', 'auto' );
$( this ).find( '.porto-lazyload:not(.lazy-load-loaded)' ).trigger( 'appear' );
}
} );
}, 100 );
}
} );
}
// Masonry
if ( $.isFunction( $.fn.themeMasonry ) ) {
$( function () {
$wrap.find( '[data-plugin-masonry]:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
if ( $this.hasClass( 'elementor-row' ) ) {
$this.children( '.elementor-column' ).addClass( 'porto-grid-item' );
}
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themeMasonry( opts );
} );
$wrap.find( '.posts-masonry .posts-container:not(.manual)' ).each( function () {
var pluginOptions = $( this ).data( 'plugin-options' );
if ( !pluginOptions ) {
pluginOptions = {};
}
pluginOptions.itemSelector = '.post';
$( this ).themeMasonry( pluginOptions );
} );
$wrap.find( '.page-portfolios .portfolio-row:not(.manual)' ).each( function () {
if ( $( this ).closest( '.porto-grid-container' ).length > 0 || typeof $( this ).attr( 'data-plugin-masonry' ) != 'undefined' ) {
return;
}
var $parent = $( this ).parent(), layoutMode = 'masonry', options, columnWidth = '.portfolio:not(.w2)', timer = null;
if ( $parent.hasClass( 'portfolios-grid' ) ) {
//layoutMode = 'fitRows';
} else if ( $parent.hasClass( 'portfolios-masonry' ) ) {
$parent.append( '
' );
}
options = {
itemSelector: '.portfolio',
layoutMode: layoutMode,
callback: function () {
timer && clearTimeout( timer );
timer = setTimeout( function () {
if ( typeof theme.FilterZoom !== 'undefined' ) {
theme.FilterZoom.initialize( $( '.page-portfolios' ) );
}
$parent.addClass( 'portfolio-iso-active' );
}, 400 );
}
};
if ( layoutMode == 'masonry' ) {
if ( !$parent.find( '.portfolio:not(.w2)' ).length )
columnWidth = '.portfolio';
options = $.extend( true, {}, options, {
masonry: { columnWidth: columnWidth }
} );
}
$( this ).themeMasonry( options );
} );
$wrap.find( '.page-members .member-row:not(.manual)' ).each( function () {
$( this ).themeMasonry( {
itemSelector: '.member',
//layoutMode: 'fitRows',
callback: function () {
setTimeout( function () {
if ( typeof theme.FilterZoom !== 'undefined' ) {
theme.FilterZoom.initialize( $( '.page-members' ) );
}
}, 400 );
}
} );
} );
} );
}
// Preview Image
if ( $.isFunction( $.fn.themePreviewImage ) ) {
$( function () {
$wrap.find( '.thumb-info-preview .thumb-info-image:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themePreviewImage( opts );
} );
} );
}
// Refresh Video Size
if ( $.isFunction( $.fn.themeRefreshVideoSize ) ) {
$( function () {
$wrap.find( '.video-cover:not(.manual) .upb_video-bg' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themeRefreshVideoSize( opts );
} );
} );
}
// Toggle
if ( $.isFunction( $.fn.themeToggle ) ) {
$( function () {
$wrap.find( 'section.toggle:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themeToggle( opts );
} );
} );
}
// Parallax
if ( $.isFunction( $.fn.themeParallax ) ) {
$( function () {
$wrap.find( '[data-plugin-parallax]:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
$this.themeParallax( opts );
} );
} );
}
// Sticky
if ( $.isFunction( $.fn.themeSticky ) ) {
$( function () {
$wrap.find( '[data-plugin-sticky]:not(.manual), .porto-sticky:not(.manual), .porto-sticky-nav:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
if ( $this.is( ':visible' ) ) {
$this.themeSticky( opts );
}
} );
} );
}
// Float Element
if ( $.isFunction( $.fn[ 'themePluginFloatElement' ] ) ) {
$( function () {
$wrap.find( '[data-plugin-float-element]:not(.manual)' ).each( function () {
var $this = $( this ),
opts;
var pluginOptions = $this.data( 'plugin-options' );
if ( pluginOptions )
opts = pluginOptions;
if ( typeof opts == 'string' ) {
try {
opts = JSON.parse( opts.replace( /'/g, '"' ).replace( ';', '' ) );
} catch ( e ) { }
}
$this.themePluginFloatElement( opts );
} );
} );
}
/* Common */
// Tooltip
if ( $.isFunction( $.fn.tooltip ) ) {
$wrap.find( "[data-tooltip]:not(.manual), [data-toggle='tooltip']:not(.manual), .star-rating:not(.manual)" ).tooltip();
}
// bootstrap popover
//$("[data-toggle='popover']").popover();
// Tabs
$wrap.find( 'a[data-toggle="tab"]' ).off( 'shown.bs.tab' ).on( 'shown.bs.tab', function ( e ) {
$( this ).parents( '.nav-tabs' ).find( '.active' ).removeClass( 'active' );
$( this ).addClass( 'active' ).parent().addClass( 'active' );
} );
if ( $.fn.vcwaypoint ) {
// Progress bar tooltip
$wrap.find( '.vc_progress_bar' ).each( function () {
var $this = $( this );
if ( !$this.find( '.progress-bar-tooltip' ).length ) {
return;
}
$this.vcwaypoint( function () {
var $tooltips = $this.find( '.progress-bar-tooltip' ),
index = 0,
count = $tooltips.length;
function loop() {
theme.requestTimeout( function () {
$tooltips.animate( {
opacity: 1
} );
}, 200 );
index++;
if ( index < count ) {
loop();
}
}
loop();
}, {
offset: '85%'
} );
} );
}
// Fixed video
$wrap.find( '.video-fixed' ).each( function () {
var $this = $( this ),
$video = $this.find( 'video, iframe' );
if ( $video.length ) {
window.addEventListener( 'scroll', function () {
var offset = $( window ).scrollTop() - $this.position().top + theme.adminBarHeight();
$video.css( "cssText", "top: " + offset + "px !important;" );
}, { passive: true } );
}
} );
// Thumb Gallery
$wrap.find( '.thumb-gallery-thumbs' ).each( function () {
var $thumbs = $( this ),
$detail = $thumbs.parent().find( '.thumb-gallery-detail' ),
flag = false,
duration = 300;
if ( $thumbs.data( 'initThumbs' ) )
return;
$detail.on( 'changed.owl.carousel', function ( e ) {
if ( !flag ) {
flag = true;
var len = $detail.find( '.owl-item' ).length,
cloned = $detail.find( '.cloned' ).length;
if ( len ) {
$thumbs.trigger( 'to.owl.carousel', [ ( e.item.index - cloned / 2 - 1 ) % len, duration, true ] );
}
flag = false;
}
} );
$thumbs.on( 'changed.owl.carousel', function ( e ) {
if ( !flag ) {
flag = true;
var len = $thumbs.find( '.owl-item' ).length,
cloned = $thumbs.find( '.cloned' ).length;
if ( len ) {
$detail.trigger( 'to.owl.carousel', [ ( e.item.index - cloned / 2 ) % len, duration, true ] );
}
flag = false;
}
} ).on( 'click', '.owl-item', function () {
if ( !flag ) {
flag = true;
var len = $thumbs.find( '.owl-item' ).length,
cloned = $thumbs.find( '.cloned' ).length;
if ( len ) {
$detail.trigger( 'to.owl.carousel', [ ( $( this ).index() - cloned / 2 ) % len, duration, true ] );
}
flag = false;
}
} ).data( 'initThumbs', true );
} );
} )( jQuery );
jQuery( document.body ).trigger( 'porto_init', [ $wrap ] );
}
( function ( theme, $ ) {
'use strict';
$( document ).ready( function () {
if ( typeof window.innerWidth == 'undefined' ) {
window.innerWidth = $( window ).width() + theme.getScrollbarWidth();
window.innerHeight = $( window ).height();
$( window ).on( 'resize', function () {
window.innerWidth = $( window ).width() + theme.getScrollbarWidth();
window.innerHeight = $( window ).height();
} );
}
// Init Porto Theme
porto_init();
// Scroll to Top
if ( typeof theme.ScrollToTop !== 'undefined' ) {
theme.ScrollToTop.initialize();
}
// Mega Menu
if ( typeof theme.MegaMenu !== 'undefined' ) {
theme.MegaMenu.initialize();
}
// Sidebar Menu
if ( typeof theme.SidebarMenu !== 'undefined' ) {
theme.SidebarMenu.initialize();
$( '.sidebar-menu.side-menu-accordion' ).themeAccordionMenu( { 'open_one': true } );
}
// Overlay Menu
if ( $( '.porto-popup-menu' ).length ) {
$( '.porto-popup-menu .hamburguer-btn' ).on( 'click', function ( e ) {
e.preventDefault();
var $this = $( this );
if ( $( '.porto-popup-menu-spacer' ).length ) {
$( '.porto-popup-menu-spacer' ).remove();
} else {
$( '' ).insertBefore( $this.parent() );
$( '.porto-popup-menu-spacer' ).width( $this.parent().width() );
}
$this.parent().toggleClass( 'opened' );
theme.requestFrame( function () {
$this.toggleClass( 'active' );
} );
} );
$( '.porto-popup-menu .main-menu' ).scrollbar();
$( '.porto-popup-menu li.menu-item-has-children > a' ).on( 'click', function ( e ) {
e.preventDefault();
$( this ).parent().siblings( 'li.menu-item-has-children.opened' ).removeClass( 'opened' );
$( this ).parent().toggleClass( 'opened' );
} );
}
// Lazy load Menu
if ( js_porto_vars.lazyload_menu ) {
var menu_type, $menu_obj, porto_menu_loaded = false;
if ( $( '.secondary-menu.mega-menu' ).length ) {
menu_type = 'secondary_menu';
$menu_obj = $( '.mega-menu.main-menu' );
} else if ( $( '.mega-menu.main-menu' ).length ) {
menu_type = 'main_menu';
$menu_obj = $( '.mega-menu.main-menu' );
} else if ( $( '.toggle-menu-wrap .sidebar-menu' ).length ) {
menu_type = 'toggle_menu';
$menu_obj = $( '.toggle-menu-wrap .sidebar-menu' );
} else if ( $( '.main-sidebar-menu .sidebar-menu' ).length ) {
menu_type = 'sidebar_menu';
$menu_obj = $( '.main-sidebar-menu .sidebar-menu' );
} else if ( $( '.header-side-nav .sidebar-menu' ).length ) {
menu_type = 'header_side_menu';
$menu_obj = $( '.header-side-nav .sidebar-menu' );
}
if ( 'pageload' == js_porto_vars.lazyload_menu ) {
theme.lazyload_menu( $menu_obj, menu_type );
} else if ( 'firsthover' == js_porto_vars.lazyload_menu ) {
$menu_obj.one( 'mouseenter', 'li.menu-item-has-children', function () {
if ( porto_menu_loaded ) {
return true;
}
theme.lazyload_menu( $menu_obj, menu_type );
porto_menu_loaded = true;
} );
}
}
// Side Navigation
if ( typeof theme.SideNav !== 'undefined' ) {
theme.SideNav.initialize();
}
// Sticky Header
if ( typeof theme.StickyHeader !== 'undefined' ) {
theme.StickyHeader.initialize();
}
// Search
if ( typeof theme.Search !== 'undefined' ) {
theme.Search.initialize();
}
// Hash Scroll
if ( typeof theme.HashScroll !== 'undefined' ) {
theme.HashScroll.initialize();
}
// Sort Filter
if ( typeof theme.SortFilter !== 'undefined' ) {
theme.SortFilter.initialize();
}
// Mobile Sidebar
// filter popup events
$( document ).on( 'click', '.sidebar-toggle', function ( e ) {
e.preventDefault();
var $html = $( 'html' );
if ( $( this ).siblings( '.porto-product-filters' ).length ) {
if ( $html.hasClass( 'filter-sidebar-opened' ) ) {
$html.removeClass( 'filter-sidebar-opened' );
$( '.sidebar-overlay' ).removeClass( 'active' );
} else {
$html.removeClass( 'sidebar-opened' );
$html.addClass( 'filter-sidebar-opened' );
$( '.sidebar-overlay' ).addClass( 'active' );
}
} else {
if ( $html.hasClass( 'sidebar-opened' ) ) {
$html.removeClass( 'sidebar-opened' );
$( '.sidebar-overlay' ).removeClass( 'active' );
} else {
$html.addClass( 'sidebar-opened' );
$( '.sidebar-overlay' ).addClass( 'active' );
$( '.mobile-sidebar' ).find( '.porto-lazyload:not(.lazy-load-loaded)' ).trigger( 'appear' );
}
}
} );
$( '.minicart-offcanvas .cart-head' ).on( 'click', function () {
$(this).closest('.minicart-offcanvas').toggleClass( 'minicart-opened' );
} );
$( '.minicart-offcanvas .minicart-overlay' ).on( 'click', function () {
$(this).closest('.minicart-offcanvas').removeClass( 'minicart-opened' );
} );
$( document.body ).on( 'click', '.sidebar-overlay', function () {
$( 'html' ).removeClass( 'sidebar-opened' );
$( 'html' ).removeClass( 'filter-sidebar-opened' );
$( this ).removeClass( 'active' );
} );
$( window ).on( 'resize', function (e) {
if ( e.originalEvent && window.innerWidth > 991 && $( 'html' ).hasClass( 'sidebar-opened' ) ) {
$( '.sidebar-overlay' ).trigger('click');
}
} );
// Common
// Match Height
if ( $.isFunction( $.fn.matchHeight ) ) {
$( '.tabs-simple .featured-box .box-content' ).matchHeight();
$( '.porto-content-box .featured-box .box-content' ).matchHeight();
$( '.vc_general.vc_cta3' ).matchHeight();
$( '.match-height' ).matchHeight();
}
// WhatsApp Sharing
if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ) ) {
$( '.share-whatsapp' ).css( 'display', 'inline-block' );
}
$( document ).ajaxComplete( function ( event, xhr, options ) {
if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ) ) {
$( '.share-whatsapp' ).css( 'display', 'inline-block' );
}
} );
// Add Ege Browser Class
var ua = window.navigator.userAgent,
ie12 = ua.indexOf( 'Edge/' ) > 0;
if ( ie12 ) $( 'html' ).addClass( 'ie12' );
// Portfolio Link Lightbox
$( document ).on( 'click', '.portfolios-lightbox a.portfolio-link', function ( e ) {
$( this ).find( '.thumb-info-zoom' ).click();
return false;
} );
// Posts Shortcode Pagination
$( document ).on( 'click', '.porto-portfolios .pagination:not(.load-more) a, .porto-members .pagination a, .porto-faqs .pagination a', function ( e ) {
var $this = $( this ),
post_type = $this.closest( '.porto-portfolios' ).length ? 'portfolio' : ( $this.closest( '.porto-members' ).length ? 'member' : 'faq' ),
url = $this.attr( 'href' ),
shortcode_id = $this.closest( '.porto-' + post_type + 's' ).find( '.shortcode-id' ).val(),
$container = $this.closest( '.porto-' + post_type + 's' + shortcode_id );
if ( url && $container.length ) {
e.preventDefault();
$container.addClass( 'porto-ajax-loading' );
if ( !$container.children( '.porto-loading-icon' ).length ) {
$container.append( '
' );
}
theme.requestTimeout( function () {
$( 'html, body' ).stop().animate( {
scrollTop: $container.offset().top - theme.StickyHeader.sticky_height - theme.adminBarHeight() - theme.sticky_nav_height - 14
}, 600, 'easeOutQuad' );
}, 160 );
$.ajax( {
type: 'post',
url: url,
success: function ( response ) {
var $response_container = $( '
' + response + '
' ).find( '.porto-' + post_type + 's' + shortcode_id );
$container.html( $response_container.html() );
if ( 'faq' != post_type ) {
theme[ 'portfolio' == post_type ? 'PortfolioAjaxPage' : 'MemberAjaxPage' ].initialize( $container.find( '.page-' + post_type + 's' ) );
theme.PostAjaxModal.initialize( $container.find( '.page-' + post_type + 's' ) );
}
porto_init( $container );
theme.PostFilter.initialize( $container.find( '.' + post_type + '-filter' ), post_type );
}
} ).always( function () {
$container.removeClass( 'porto-ajax-loading' );
} );
return false;
}
} );
$( '.porto-faqs' ).each( function () {
if ( $( this ).find( '.faq .toggle.active' ).length < 1 ) {
$( this ).find( '.faq' ).eq( 0 ).find( '.toggle' ).addClass( 'active' );
$( this ).find( '.faq' ).eq( 0 ).find( '.toggle-content' ).show();
}
} );
// refresh wpb content
$( document ).on( 'shown.bs.collapse', '.collapse', function () {
var panel = $( this );
theme.refreshVCContent( panel );
} );
$( document ).on( 'shown.bs.tab', 'a[data-toggle="tab"]', function ( e ) {
var panel = $( $( e.target ).attr( 'href' ) );
theme.refreshVCContent( panel );
} );
// porto tooltip for header, footer
$( '.porto-tooltip .tooltip-icon' ).on( 'click', function () {
if ( $( this ).parent().children( ".tooltip-popup" ).css( "display" ) == "none" ) {
$( this ).parent().children( ".tooltip-popup" ).fadeIn( 200 );
} else {
$( this ).parent().children( ".tooltip-popup" ).fadeOut( 200 );
}
} );
$( '.porto-tooltip .tooltip-close' ).on( 'click', function () {
$( this ).parent().fadeOut( 200 );
} );
// skeleton screens
if ( js_porto_vars.use_skeleton_screen.length > 0 && $( '.skeleton-loading' ).length ) {
var dclFired = false,
dclPromise = ( function () {
var deferred = $.Deferred();
$( function () {
deferred.resolve();
dclFired = true;
} );
return deferred.promise();
} )(),
observer = false,
NativeMutationObserver = window.MutationObserver || window.WebkitMutationObserver || window.MozMutationObserver;
if ( typeof NativeMutationObserver != 'undefined' ) {
observer = new NativeMutationObserver( function ( mutationsList, observer ) {
for ( var i in mutationsList ) {
var mutation = mutationsList[ i ];
if ( mutation.type == 'childList' ) {
$( mutation.target ).trigger( 'skeleton:initialised' );
}
}
} );
}
var killObserverTrigger = setTimeout( function () {
if ( observer ) {
observer.disconnect();
observer = undefined;
}
}, 4000 );
var skeletonTimer;
$( '.skeleton-loading' ).each( function ( e ) {
var $this = $( this ),
skeletonInitialisedPromise = ( function () {
var deferred = $.Deferred();
$this.on( 'skeleton:initialised', function ( evt ) {
if ( evt.target.classList.contains( 'skeleton-loading' ) ) {
deferred.resolve( evt );
}
} );
return deferred.promise();
} )(),
resourcesLoadedPromise = ( function () {
return $.Deferred().resolve().promise();
} )();
$.when( skeletonInitialisedPromise, resourcesLoadedPromise, dclPromise ).done( function ( e ) {
var $real = $( e.target ),
$placeholder = $real.siblings( '.skeleton-body' );
if ( !$placeholder.length ) {
$placeholder = $real.parent().parent().parent().find( '[class="' + $real.attr( 'class' ).replace( 'skeleton-loading', 'skeleton-body' ) + '"]' );
}
porto_init( $real );
if ( $real.find( '.sidebar-menu:not(.side-menu-accordion)' ).length ) {
theme.SidebarMenu.initialize( $real.find( '.sidebar-menu:not(.side-menu-accordion)' ) );
}
if ( skeletonTimer ) {
theme.deleteTimeout( skeletonTimer );
}
$real.trigger( 'skeleton-loaded' );
theme.requestTimeout( function () {
if ( $placeholder.length ) {
// fix YITH Products Filters compatibility issue
if ( $placeholder.parent().hasClass( 'yit-wcan-container' ) ) {
$placeholder.parent().remove();
} else {
$placeholder.remove();
}
}
$real.removeClass( 'skeleton-loading' );
if ( $real.closest( '.skeleton-loading-wrap' ) ) {
$real.closest( '.skeleton-loading-wrap' ).removeClass( 'skeleton-loading-wrap' );
}
if ( $( document.body ).hasClass( 'elementor-default' ) || $( document.body ).hasClass( 'elementor-page' ) ) {
$( window ).trigger( 'resize' );
}
theme.refreshStickySidebar( false );
}, 100 );
if ( !$( '.skeleton-loading' ).length ) {
clearTimeout( killObserverTrigger );
observer.disconnect();
observer = undefined;
}
} );
if ( $this.children( 'script[type="text/template"]' ).length ) {
var content = $( JSON.parse( $this.children( 'script[type="text/template"]' ).eq( 0 ).html() ) );
$this.children( 'script[type="text/template"]' ).eq( 0 ).remove();
if ( observer ) {
observer.observe( this, { childList: true, subtree: false } );
}
$this.append( content );
if ( !observer ) {
$this.trigger( 'skeleton:initialised' );
}
}
} );
}
$( document ).trigger( 'porto_theme_init' );
} );
} ).apply( this, [ window.theme, jQuery ] );
( function ( theme, $, undefined ) {
"use strict";
$( document ).ready( function () {
$( window ).on( 'vc_reload', function () {
porto_init();
$( '.type-post' ).addClass( 'post' );
$( '.type-portfolio' ).addClass( 'portfolio' );
$( '.type-member' ).addClass( 'member' );
$( '.type-block' ).addClass( 'block' );
} );
} );
// Portfolios Load More
$( document ).on( 'click', '.porto-portfolios .pagination.load-more a', function ( e ) {
var $this = $( this ),
url = $this.attr( 'href' ),
shortcode_id = $this.closest( '.porto-portfolios' ).find( '.shortcode-id' ).val(),
$container = $this.closest( '.porto-portfolios' + shortcode_id ),
$loader = $container.find( '.pagination-wrap.load-more .bounce-loader' ),
$btn = $container.find( '.pagination.load-more a.next' );
if ( url ) {
e.preventDefault();
$btn.hide();
$loader.show();
$.ajax( {
type: 'post',
url: url,
success: function ( response ) {
var $response_container = $( '
' + response + '
' ).find( '.porto-portfolios' + shortcode_id ),
$portfolio_thumbs = $response_container.find( '.porto-portfolios-lighbox-thumbnails .owl-carousel' ).html(),
$next_posts = $response_container.find( '.portfolio-row' ).children( 'article.portfolio' );
$container.find( '.pagination-wrap' ).replaceWith( $response_container.find( '.pagination-wrap' ) );
$container.find( '.porto-portfolios-lighbox-thumbnails .owl-carousel' ).append( $portfolio_thumbs );
if ( $next_posts.length ) {
var $iso = $container.find( '.page-portfolios' ).find( '.portfolio-row' );
$iso.isotope( 'insert', $next_posts );
$iso.waitForImages( function () {
$iso.isotope( 'layout' );
} );
} else if ( $response_container.find( '.portfolios-timeline' ).length ) { // timeline
$next_posts = $response_container.find( '.portfolios-timeline .timeline-body' );
var $first_timeline_date = $next_posts.children( '.timeline-date:first-child' ),
$last_date = $container.find( '.timeline-body' ).children( '.timeline-date' ).last();
if ( $last_date.length && $first_timeline_date.length && $last_date.html() == $first_timeline_date.html() ) {
$next_posts.children( '.timeline-date:first-child' ).remove();
}
$container.find( '.timeline-body' ).append( $next_posts.children() );
}
theme.PortfolioAjaxPage.initialize( $( '.page-portfolios' ) );
theme.PostAjaxModal.initialize( $( '.page-portfolios' ) );
porto_init( $container );
theme.PostFilter.initialize( $( '.portfolio-filter' ), 'portfolio' );
$container.find( '.porto-lazyload:not(.lazy-load-loaded)' ).trigger( 'appear' );
}
} ).always( function () {
$loader.hide();
} );
return false;
}
} );
/*
* Experience Timeline
*/
var timelineHeightAdjust = {
$timeline: $( '#exp-timeline' ),
$timelineBar: $( '#exp-timeline .timeline-bar' ),
$firstTimelineItem: $( '#exp-timeline .timeline-box' ).first(),
$lastTimelineItem: $( '#exp-timeline .timeline-box' ).last(),
build: function () {
var self = this;
self.adjustHeight();
},
adjustHeight: function () {
var self = this,
calcFirstItemHeight = ( self.$firstTimelineItem.outerHeight( true ) / 2 ) + 5,
calcLastItemHeight = ( self.$lastTimelineItem.outerHeight( true ) / 2 ) + 5;
// Set Timeline Bar Top and Bottom
self.$timelineBar.css( {
top: calcFirstItemHeight,
bottom: calcLastItemHeight
} );
}
}
if ( $( '#exp-timeline' ).get( 0 ) ) {
// Adjust Timeline Height On Resize
var timeline_timer = null;
$( window ).smartresize( function () {
if ( timeline_timer ) {
clearTimeout( timeline_timer );
}
timeline_timer = setTimeout( function () {
timelineHeightAdjust.build();
}, 800 );
} );
timelineHeightAdjust.build();
}
$( '.custom-view-our-location' ).on( 'click', function ( e ) {
e.preventDefault();
var this_ = $( this );
$( '.custom-googlemap' ).slideDown( '1000', function () {
this_.delay( 700 ).hide();
} );
} );
} )( window.theme, jQuery );
// Porto 4.0 extra shortcodes
( function ( theme, $, undefined ) {
'use strict';
// porto ultimate heading
function porto_headings_init() {
$( '.porto-u-heading' ).each( function () {
var align = $( this ).attr( 'data-halign' ),
spacer = $( this ).attr( 'data-hspacer' );
if ( spacer == 'line_only' ) {
if ( align == 'right' || align == 'left' ) {
if ( $( this ).find( '.porto-u-heading-spacer' ).find( '.porto-u-headings-line' )[ 0 ].style.width != 'auto' ) {
$( this ).find( '.porto-u-heading-spacer' ).find( '.porto-u-headings-line' ).css( { 'float': align } );
}
} else {
$( this ).find( '.porto-u-heading-spacer' ).find( '.porto-u-headings-line' ).css( { 'margin': '0 auto' } );
}
}
} );
}
$( document ).ready( function () {
porto_headings_init();
if ( typeof elementorFrontend != 'undefined' ) {
// fix Elementor ScrollTop
$( window ).on( 'elementor/frontend/init', function () {
elementorFrontend.hooks.addFilter( 'frontend/handlers/menu_anchor/scroll_top_distance', function ( scrollTop ) {
if ( theme && theme.StickyHeader && typeof theme.sticky_nav_height != 'undefined' ) {
if ( elementorFrontend.elements.$wpAdminBar.length ) {
scrollTop += elementorFrontend.elements.$wpAdminBar.height();
}
scrollTop = scrollTop - theme.adminBarHeight() - theme.StickyHeader.sticky_height - theme.sticky_nav_height + 1;
}
return scrollTop;
} );
} );
}
if ( js_porto_vars.user_edit_pages && $.fn.tooltip ) {
var porto_init_builder_tooltip = function ( $obj ) {
$obj.find( '.pb-edit-link' ).each( function () {
var $this = $( this ),
title = $this.data( 'title' );
$this.next( '.porto-block' ).addClass( 'has-pb-edit' ).tooltip( {
html: true,
template: '
',
trigger: 'manual',
title: '
' + title + '',
delay: 300
} );
var tooltipData = $this.next( '.porto-block' ).data( 'bs.tooltip' );
if ( tooltipData ) {
$( tooltipData.element ).on( 'mouseenter.bs.tooltip', function ( e ) {
tooltipData._enter( e );
} );
$( tooltipData.element ).on( 'mouseleave.bs.tooltip', function ( e ) {
tooltipData._leave( e );
} );
}
} );
};
porto_init_builder_tooltip( $( document.body ) );
$( '.skeleton-loading' ).on( 'skeleton-loaded', function () {
porto_init_builder_tooltip( $( this ) );
} );
$( document.body ).on( 'mouseenter mouseleave', '.tooltip[role="tooltip"]', function ( e ) {
var $element = $( '.porto-block[aria-describedby="' + $( this ).attr( 'id' ) + '"]' );
if ( $element.length && $element.data( 'bs.tooltip' ) ) {
var fn_name = 'mouseenter' == e.type ? '_enter' : '_leave';
$element.data( 'bs.tooltip' )[ fn_name ]( false, $element.data( 'bs.tooltip' ) );
}
} );
}
} );
/* Advanced Buttons */
$( '.porto-btn[data-hover]' ).on( 'mouseenter', function () {
var hoverColor = $( this ).data( 'hover' ),
hover_border_color = $( this ).data( 'border-hover' );
if ( hoverColor ) {
$( this ).data( 'originalColor', $( this ).css( 'color' ) );
$( this ).css( 'color', hoverColor );
}
if ( hover_border_color ) {
$( this ).data( 'originalBorderColor', $( this ).css( 'border-color' ) );
$( this ).css( 'border-color', hover_border_color );
}
} ).on( 'mouseleave', function () {
var originalColor = $( this ).data( 'originalColor' ),
original_border_color = $( this ).data( 'originalBorderColor' );
if ( originalColor ) {
$( this ).css( 'color', originalColor );
}
if ( original_border_color ) {
$( this ).css( 'border-color', original_border_color );
}
} );
// widget wysija
$( '#footer .widget_wysija .wysija-submit:not(.btn)' ).addClass( 'btn btn-default' );
// fixed visual compoer issue which has owl carousel
if ( $( '[data-vc-parallax] .owl-carousel' ).length ) {
theme.requestTimeout( function () { if ( typeof window.vcParallaxSkroll == 'object' ) { window.vcParallaxSkroll.refresh(); } }, 200 );
}
$( '.wpcf7-form .wpcf7-submit' ).on( 'click', function ( e ) {
if ( $( this ).closest( 'form' ).hasClass( 'processing' ) ) {
e.preventDefault();
return false;
}
$( this ).closest( 'form' ).addClass( "processing" );
} );
$( document ).ajaxComplete( function ( t, e, i ) {
$( '.wpcf7-form.processing' ).removeClass( 'processing' );
} );
if ( $( '.page-content > .alignfull, .post-content > .alignfull' ).length ) {
var initAlignFull = function () {
$( '.page-content > .alignfull, .post-content > .alignfull' ).each( function () {
$( this ).css( 'left', -1 * $( this ).parent().offset().left ).css( 'right', -1 * $( this ).parent().offset().left ).css( 'width', $( 'body' ).width() - ( parseInt( $( this ).css( 'margin-left' ), 10 ) + parseInt( $( this ).css( 'margin-right' ), 10 ) ) );
} );
};
initAlignFull();
$( window ).smartresize( function () {
initAlignFull();
} );
}
} )( window.theme, jQuery );
// Porto Sticky icon bar on mobile
( function ( theme, $ ) {
'use strict';
var $header_main = $( '#header .header-main' );
var $menu_wrap = $( '#header .main-menu-wrap' );
if ( $( '.porto-sticky-navbar' ).length > 0 ) {
window.addEventListener( 'scroll', function () {
if ( window.innerWidth < 576 ) {
var headerOffset = -1;
var scrollTop = $( window ).scrollTop();
if ( $header_main.length ) {
headerOffset = Math.max( $header_main.scrollTop() + $header_main.height(), headerOffset );
}
if ( $menu_wrap.length ) {
headerOffset = Math.max( $menu_wrap.scrollTop() + $menu_wrap.height(), headerOffset );
}
if ( headerOffset <= 0 ) {
if ( $( '#header' ).length > 0 && $( '#header' ).height() > 10 ) headerOffset = $( '#header' ).scrollTop() + $( '#header' ).height();
else headerOffset = 100;
}
if ( headerOffset <= scrollTop ) {
$( '.porto-sticky-navbar' ).addClass( 'fixed' );
} else {
$( '.porto-sticky-navbar' ).removeClass( 'fixed' );
}
}
}, { passive: true } );
}
} )( window.theme, jQuery );