/**
* Polyfill for older browsers https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
*
* @since 4.8
* @return boolean
*/
if ( ! Array.isArray )
{
Array.isArray = function( arg )
{
return Object.prototype.toString.call( arg ) === '[object Array]';
};
}
/**
* hack to catch and reroute jQuery custom events (default browser events seem to work even when triggered with jQuery)
* As events with '-' cannot be monotored with on.... we rename them to avoid possible conflicts
*
* https://stackoverflow.com/questions/11132553/how-to-catch-the-jquery-event-trigger
* https://stackoverflow.com/questions/36914912/how-to-get-jquery-to-trigger-a-native-custom-event-handler
* https://stackoverflow.com/questions/40915156/listen-for-jquery-event-with-vanilla-js
*
* @since 5.6
*/
(function($)
{
"use strict";
const opt = {
'bubbles': true,
'cancelable': true
};
// event is always bound to window
$( window ).on( 'av-height-change', function( e )
{
const event = new CustomEvent( 'avia_height_change', opt );
window.dispatchEvent( event );
});
// event is always bound to window
$( 'body' ).on( 'av_resize_finished', function( e )
{
const event = new CustomEvent( 'avia_resize_finished', opt );
document.body.dispatchEvent( event );
});
})( jQuery );
(function($)
{
"use strict";
$( function()
{
$.avia_utilities = $.avia_utilities || {};
AviaBrowserDetection( 'html' );
AviaDeviceDetection( 'html' );
//show scroll top but1ton
avia_scroll_top_fade();
//calculate width of content
aviaCalcContentWidth();
//creates search tooltip
new $.AviaTooltip({
"class": 'avia-search-tooltip',
data: 'avia-search-tooltip',
event: 'click',
position: 'bottom',
scope: "body",
attach: 'element',
within_screen: true,
close_keys: 27
});
//creates relate posts tooltip
new $.AviaTooltip({
"class": 'avia-related-tooltip',
data: 'avia-related-tooltip',
scope: ".related_posts, .av-share-box",
attach: 'element',
delay: 0
});
//creates ajax search
new $.AviaAjaxSearch({scope:'#header, .avia_search_element'});
// actiavte portfolio sorting
if( $.fn.avia_iso_sort )
{
$('.grid-sort-container').avia_iso_sort();
}
// Checks height of content and sidebar and applies shadow class to the higher one
AviaSidebarShadowHelper();
$.avia_utilities.avia_ajax_call();
// Add single post/portfolio swipe support (in BETA since 5.5)
$.avia_utilities.postSwipeSupport();
});
$.avia_utilities = $.avia_utilities || {};
$.avia_utilities.postSwipeSupport = function()
{
if( ! $.fn.avia_swipe_trigger )
{
return;
}
const body = document.getElementsByTagName( 'body' ),
methods = {};
methods.beforeTrigger = function( slider, direction )
{
const loader = $.avia_utilities.loading();
loader.show();
};
methods.afterTrigger = function( slider, direction )
{
let body = document.getElementsByTagName( 'body' );
if( ! body.length )
{
return;
}
let dir = direction == 'prev' ? 'swiped-ltr' : 'swiped-rtl';
body[0].classList.add( 'av-post-swiped-overlay', dir );
};
if( ! body.length || ! body[0].classList.contains( 'avia-post-nav-swipe-enabled' ) )
{
return;
}
/**
* Add swipe to posts and portfolio
*
* @since 5.5
*/
let single = document.querySelector( '.single #main' );
if( single == null )
{
return;
}
let prev = document.querySelector( '#wrap_all .avia-post-nav.avia-post-prev' ),
next = document.querySelector( '#wrap_all .avia-post-nav.avia-post-next' ),
param = {
prev: prev,
next: next,
delay_trigger: true,
event: {
prev: 'native_click',
next: 'native_click'
},
beforeTrigger: methods.beforeTrigger,
afterTrigger: methods.afterTrigger
};
$( single ).avia_swipe_trigger( param );
};
$.avia_utilities.avia_ajax_call = function(container)
{
if( typeof container == 'undefined' )
{
container = 'body';
};
$('a.avianolink').on('click', function(e){ e.preventDefault(); });
$('a.aviablank').attr('target', '_blank');
//activates the prettyphoto lightbox
if($.fn.avia_activate_lightbox)
{
$(container).avia_activate_lightbox();
}
//scrollspy for main menu. must be located before smoothscrolling
if( $.fn.avia_scrollspy )
{
if(container == 'body')
{
$('body').avia_scrollspy({target:'.main_menu .menu li > a'});
}
else
{
$('body').avia_scrollspy('refresh');
}
}
//smooth scrooling
if( $.fn.avia_smoothscroll )
{
$('a[href*="#"]', container).avia_smoothscroll(container);
}
avia_small_fixes(container);
avia_hover_effect(container);
avia_iframe_fix(container);
//activate html5 video player
if( $.fn.avia_html5_activation && $.fn.mediaelementplayer )
{
$(".avia_video, .avia_audio", container).avia_html5_activation({ratio:'16:9'});
}
};
// -------------------------------------------------------------------------------------------
// Error log helper
// -------------------------------------------------------------------------------------------
$.avia_utilities.log = function( text, type, extra )
{
if( typeof console == 'undefined' )
{
return;
}
if( typeof type == 'undefined' )
{
type = "log";
}
type = "AVIA-" + type.toUpperCase();
console.log( "["+type+"] "+text );
if( typeof extra != 'undefined' )
{
console.log( extra );
}
};
// -------------------------------------------------------------------------------------------
// keep track of the browser and content width
// -------------------------------------------------------------------------------------------
function aviaCalcContentWidth()
{
var win = $(window),
width_select= $('html').is('.html_header_sidebar') ? "#main" : "#header",
outer = $(width_select),
outerParent = outer.parents('div').eq( 0 ),
the_main = $(width_select + ' .container').first(),
css_block = "",
calc_dimensions = function()
{
var css = "",
w_12 = Math.round( the_main.width() ),
w_outer = Math.round( outer.width() ),
w_inner = Math.round( outerParent.width() );
//css rules for mega menu
css += " #header .three.units{width:" + ( w_12 * 0.25)+ "px;}";
css += " #header .six.units{width:" + ( w_12 * 0.50)+ "px;}";
css += " #header .nine.units{width:" + ( w_12 * 0.75)+ "px;}";
css += " #header .twelve.units{width:" +( w_12 ) + "px;}";
//css rules for tab sections
css += " .av-framed-box .av-layout-tab-inner .container{width:" +( w_inner )+ "px;}";
css += " .html_header_sidebar .av-layout-tab-inner .container{width:" +( w_outer )+ "px;}";
css += " .boxed .av-layout-tab-inner .container{width:" +( w_outer )+ "px;}";
//css rules for submenu container
css += " .av-framed-box#top .av-submenu-container{width:" +( w_inner )+ "px;}";
//ie8 needs different insert method
try{
css_block.text(css);
}
catch(err){
css_block.remove();
var headFirst = $( 'head' ).first();
css_block = $("").appendTo( headFirst );
}
};
if($('.avia_mega_div').length > 0 || $('.av-layout-tab-inner').length > 0 || $('.av-submenu-container').length > 0)
{
var headFirst = $( 'head' ).first();
css_block = $("").appendTo( headFirst );
win.on( 'debouncedresize', calc_dimensions);
calc_dimensions();
}
}
// -------------------------------------------------------------------------------------------
// Tiny helper for sidebar shadow
// -------------------------------------------------------------------------------------------
function AviaSidebarShadowHelper()
{
var $sidebar_container = $('.sidebar_shadow#top #main .sidebar');
var $content_container = $('.sidebar_shadow .content');
if( $sidebar_container.height() >= $content_container.height() )
{
$sidebar_container.addClass('av-enable-shadow');
}
else
{
$content_container.addClass('av-enable-shadow');
}
}
// -------------------------------------------------------------------------------------------
// modified SCROLLSPY by bootstrap
// -------------------------------------------------------------------------------------------
function AviaScrollSpy(element, options)
{
var self = this;
var process = self.process.bind( self ),
refresh = self.refresh.bind( self ),
$element = $(element).is('body') ? $(window) : $(element),
href;
self.$body = $('body');
self.$win = $(window);
self.options = $.extend({}, $.fn.avia_scrollspy.defaults, options);
self.selector = (self.options.target
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|| '');
self.activation_true = false;
if(self.$body.find(self.selector + "[href*='#']").length)
{
self.$scrollElement = $element.on('scroll.scroll-spy.data-api', process);
self.$win.on('av-height-change', refresh);
self.$body.on('av_resize_finished', refresh);
self.activation_true = true;
self.checkFirst();
setTimeout(function()
{
self.refresh();
self.process();
},100);
}
}
AviaScrollSpy.prototype = {
constructor: AviaScrollSpy
, checkFirst: function () {
var current = window.location.href.split('#')[0],
matching_link = this.$body.find(this.selector + "[href='"+current+"']").attr('href',current+'#top');
}
, refresh: function () {
if(!this.activation_true) return;
var self = this
, $targets;
this.offsets = $([]);
this.targets = $([]);
$targets = this.$body
.find(this.selector)
.map(function () {
var $el = $(this)
, href = $el.data('target') || $el.attr('href')
, hash = this.hash
, hash = hash.replace(/\//g, "")
, $href = /^#\w/.test(hash) && $(hash);
// $.isWindow deprecated 3.3 https://api.jquery.com/jquery.iswindow/
var obj = self.$scrollElement.get(0);
var isWindow = obj != null && obj === obj.window;
return ( $href
&& $href.length
&& [[ $href.position().top + ( ! isWindow && self.$scrollElement.scrollTop() ), href ]] ) || null;
})
.sort(function (a, b) { return a[0] - b[0]; })
.each(function () {
self.offsets.push(this[0]);
self.targets.push(this[1]);
});
}
, process: function () {
if(!this.offsets) return;
if(isNaN(this.options.offset)) this.options.offset = 0;
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
, scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
, maxScroll = scrollHeight - this.$scrollElement.height()
, offsets = this.offsets
, targets = this.targets
, activeTarget = this.activeTarget
, i;
if (scrollTop >= maxScroll) {
return activeTarget != (i = targets.last()[0])
&& this.activate ( i );
}
for (i = offsets.length; i--;) {
activeTarget != targets[i]
&& scrollTop >= offsets[i]
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
&& this.activate( targets[i] );
}
}
, activate: function (target) {
var active
, selector;
this.activeTarget = target;
$(this.selector)
.parent('.' + this.options.applyClass)
.removeClass(this.options.applyClass);
selector = this.selector
+ '[data-target="' + target + '"],'
+ this.selector + '[href="' + target + '"]';
active = $(selector)
.parent('li')
.addClass(this.options.applyClass);
if (active.parent('.sub-menu').length) {
active = active.closest('li.dropdown_ul_available').addClass(this.options.applyClass);
}
active.trigger('activate');
}
};
/* AviaScrollSpy PLUGIN DEFINITION
* =========================== */
$.fn.avia_scrollspy = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('scrollspy')
, options = typeof option == 'object' && option;
if (!data) $this.data('scrollspy', (data = new AviaScrollSpy(this, options)));
if (typeof option == 'string') data[option]();
});
};
$.fn.avia_scrollspy.Constructor = AviaScrollSpy;
$.fn.avia_scrollspy.calc_offset = function()
{
var offset_1 = (parseInt($('.html_header_sticky #main').data('scroll-offset'), 10)) || 0,
offset_2 = ($(".html_header_sticky:not(.html_top_nav_header) #header_main_alternate").outerHeight()) || 0,
offset_3 = ($(".html_header_sticky.html_header_unstick_top_disabled #header_meta").outerHeight()) || 0,
offset_4 = 1,
offset_5 = parseInt($('html').css('margin-top'),10) || 0,
offset_6 = parseInt($('.av-frame-top ').outerHeight(),10) || 0;
return offset_1 + offset_2 + offset_3 + offset_4 + offset_5 + offset_6;
};
$.fn.avia_scrollspy.defaults =
{
offset: $.fn.avia_scrollspy.calc_offset(),
applyClass: 'current-menu-item'
};
// -------------------------------------------------------------------------------------------
// detect browser and add class to body
// -------------------------------------------------------------------------------------------
function AviaBrowserDetection(outputClassElement)
{
//code from the old jquery migrate plugin
var current_browser = {},
uaMatch = function( ua )
{
ua = ua.toLowerCase();
var match = /(edge)\/([\w.]+)/.exec( ua ) ||
/(opr)[\/]([\w.]+)/.exec( ua ) ||
/(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(iemobile)[\/]([\w.]+)/.exec( ua ) ||
/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
return {
browser: match[ 5 ] || match[ 3 ] || match[ 1 ] || "",
version: match[ 2 ] || match[ 4 ] || "0",
versionNumber: match[ 4 ] || match[ 2 ] || "0"
};
};
var matched = uaMatch( navigator.userAgent );
if( matched.browser )
{
current_browser.browser = matched.browser;
current_browser[ matched.browser ] = true;
current_browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if ( current_browser.chrome ) {
current_browser.webkit = true;
} else if ( current_browser.webkit ) {
current_browser.safari = true;
}
if(typeof(current_browser) !== 'undefined')
{
var bodyclass = '',
version = current_browser.version ? parseInt(current_browser.version) : "";
if(current_browser.msie || current_browser.rv || current_browser.iemobile){
bodyclass += 'avia-msie';
}else if(current_browser.webkit){
bodyclass += 'avia-webkit';
}else if(current_browser.mozilla){
bodyclass += 'avia-mozilla';
}
if(current_browser.version) bodyclass += ' ' + bodyclass + '-' + version + ' ';
if(current_browser.browser) bodyclass += ' avia-' + current_browser.browser + ' avia-' +current_browser.browser +'-' + version + ' ';
}
if( outputClassElement )
{
$(outputClassElement).addClass( bodyclass );
}
return bodyclass;
}
/**
* Detect device features and add a class to body
*/
function AviaDeviceDetection( outputClassElement )
{
var classes = [];
// https://stackoverflow.com/questions/14439903/how-can-i-detect-device-touch-support-in-javascript
$.avia_utilities.isTouchDevice = 'ontouchstart' in window ||
window.DocumentTouch && document instanceof window.DocumentTouch ||
navigator.maxTouchPoints > 0 ||
window.navigator.msMaxTouchPoints > 0;
classes.push( $.avia_utilities.isTouchDevice ? 'touch-device' : 'no-touch-device' );
$.avia_utilities.pointerDevices = [];
// https://stackdiary.com/detect-mobile-browser-javascript/
if( typeof window.matchMedia != 'function' )
{
$.avia_utilities.pointerDevices.push( 'undefined' );
classes.push( 'pointer-device-undefined' );
}
else
{
var pointer_fine = false;
if( window.matchMedia( '(any-pointer: fine)' ) )
{
classes.push( 'pointer-device-fine' );
$.avia_utilities.pointerDevices.push( 'fine' );
pointer_fine = true;
}
if( window.matchMedia( '(any-pointer: coarse)' ) )
{
classes.push( 'pointer-device-coarse' );
$.avia_utilities.pointerDevices.push( 'coarse' );
if( ! pointer_fine )
{
classes.push( 'pointer-device-coarse-only' );
}
}
if( ! $.avia_utilities.pointerDevices.length )
{
classes.push( 'pointer-device-none' );
$.avia_utilities.pointerDevices.push( 'none' );
}
}
if( 'undefined' == typeof $.avia_utilities.isMobile )
{
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement)
{
$.avia_utilities.isMobile = true;
}
else
{
$.avia_utilities.isMobile = false;
}
}
$( outputClassElement ).addClass( classes.join( ' ') );
}
// -------------------------------------------------------------------------------------------
// html 5 videos
// -------------------------------------------------------------------------------------------
$.fn.avia_html5_activation = function( options )
{
var defaults =
{
ratio: '16:9'
};
var options = $.extend( defaults, options );
// isMobile = $.avia_utilities.isMobile;
// if(isMobile) return;
this.each( function()
{
var fv = $(this),
id_to_apply = '#' + fv.attr('id'),
posterImg = fv.attr('poster'),
features = [ 'playpause', 'progress', 'current', 'duration', 'tracks', 'volume' ],
container = fv.closest( '.avia-video' );
if( container.length > 0 && container.hasClass( 'av-html5-fullscreen-btn' ) )
{
features.push( 'fullscreen' );
}
/*
* Hide controls
* https://kriesi.at/support/topic/video-not-appearing-properly-as-color-section-background/#post-1429866
*
* @since 5.6.10
*/
if( ! $(this).prop('controls') )
{
features = [];
}
fv.mediaelementplayer(
{
// if the