function preload_images( images, complete_callback ) {
var id = 'test-'+( new Date().getTime() );
jQuery( 'body').append( '
' );
jQuery.each( images, function( index, src ){
var img = jQuery( '
' );
img.attr( 'alt', '' );
img.attr( 'class', 'image__preload' );
img.css( 'display', 'none' );
img.attr( 'src', src );
jQuery( '#'+id ).append( img );
} );
jQuery( '#'+id ).imagesLoaded( function() {
if ( complete_callback ) {
complete_callback();
}
setTimeout( function(){
jQuery( '#'+id ).remove();
}, 5000 );
});
}
function _to_number( string ) {
if ( typeof string === 'number' ) {
return string;
}
var n = string.match(/\d+$/);
if ( n ) {
return parseFloat( n[0] );
} else {
return 0;
}
}
function _to_bool( v ) {
if ( typeof v === 'boolean' ){
return v;
}
if ( typeof v === 'number' ){
return v === 0 ? false : true;
}
if ( typeof v === 'string' ) {
if ( v === 'true' || v === '1' ) {
return true;
} else {
return false;
}
}
return false;
}
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
/**
* skip-link-focus-fix.js
*
* Helps with accessibility for keyboard only users.
*
* Learn more: https://github.com/Automattic/OnePress/pull/136
*/
( function() {
var is_webkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1,
is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1,
is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1;
if ( ( is_webkit || is_opera || is_ie ) && document.getElementById && window.addEventListener ) {
window.addEventListener( 'hashchange', function() {
var id = location.hash.substring( 1 ),
element;
if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
return;
}
element = document.getElementById( id );
if ( element ) {
if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
element.tabIndex = -1;
}
element.focus();
}
}, false );
}
})();
/**
* Sticky header when scroll.
*/
( function( $ ) {
if ( onepress_js_settings.onepress_disable_sticky_header != '1' ) {
var is_top_header = $( '#page > .site-header').length ? true : false;
var p_to_top;
$('.site-header').eq(0).wrap( '