Fix some js errors, see diff
set sophia_after_dark_enable_top_header always to false, as it would a a bar to the top of the page below the admin bar also did some general fixing on php :)
This commit is contained in:
@ -5,60 +5,54 @@ jQuery(document).ready(function($) {
|
||||
/**
|
||||
* Sophia After Dark Preloader
|
||||
*/
|
||||
if($('#preloader-background').length > 0) {
|
||||
setTimeout(function(){$('#preloader-background').hide();}, 600);
|
||||
if ($('#preloader-background').length) {
|
||||
setTimeout(function() {
|
||||
$('#preloader-background').hide();
|
||||
}, 600);
|
||||
}
|
||||
|
||||
var grid = document.querySelector(
|
||||
'.sophia-after-dark-content-masonry'
|
||||
),
|
||||
masonry;
|
||||
|
||||
if (
|
||||
grid &&
|
||||
typeof Masonry !== undefined &&
|
||||
typeof imagesLoaded !== undefined
|
||||
) {
|
||||
imagesLoaded( grid, function( instance ) {
|
||||
masonry = new Masonry( grid, {
|
||||
/**
|
||||
* Masonry grid initialization
|
||||
*/
|
||||
const grid = document.querySelector('.sophia-after-dark-content-masonry');
|
||||
if (grid && typeof Masonry !== 'undefined' && typeof imagesLoaded !== 'undefined') {
|
||||
imagesLoaded(grid, function() {
|
||||
new Masonry(grid, {
|
||||
itemSelector: '.hentry'
|
||||
} );
|
||||
} );
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Header Search script
|
||||
*/
|
||||
$('.mt-menu-search .mt-search-icon').click(function() {
|
||||
$('.mt-form-wrap').toggleClass('search-activate');
|
||||
$('.mt-form-wrap .search-field').focus();
|
||||
var element = document.querySelector( '.mt-form-wrap.search-activate' );
|
||||
if( element ) {
|
||||
const $searchIcon = $('.mt-menu-search .mt-search-icon');
|
||||
$searchIcon.click(function() {
|
||||
$('.mt-form-wrap').toggleClass('search-activate').find('.search-field').focus();
|
||||
const $element = $('.mt-form-wrap.search-activate');
|
||||
if ($element.length) {
|
||||
$(document).on('keydown', function(e) {
|
||||
var focusable = element.querySelectorAll( 'input, button, [href], select, textarea, [tabindex]:not([tabindex="-1"])');
|
||||
var firstFocusable = focusable[0];
|
||||
var lastFocusable = focusable[focusable.length - 1];
|
||||
sophia_after_dark_focus_trap( firstFocusable, lastFocusable, e );
|
||||
})
|
||||
const focusable = $element.find('input, button, [href], select, textarea, [tabindex]:not([tabindex="-1"])');
|
||||
const firstFocusable = focusable[0];
|
||||
const lastFocusable = focusable[focusable.length - 1];
|
||||
sophia_after_dark_focus_trap(firstFocusable, lastFocusable, e);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Focus trap in popup.
|
||||
*/
|
||||
var KEYCODE_TAB = 9;
|
||||
function sophia_after_dark_focus_trap( firstFocusable, lastFocusable, e ) {
|
||||
const KEYCODE_TAB = 9;
|
||||
|
||||
function sophia_after_dark_focus_trap(firstFocusable, lastFocusable, e) {
|
||||
if (e.key === 'Tab' || e.keyCode === KEYCODE_TAB) {
|
||||
if ( e.shiftKey ) /* shift + tab */ {
|
||||
if (document.activeElement === firstFocusable) {
|
||||
lastFocusable.focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
} else /* tab */ {
|
||||
if ( document.activeElement === lastFocusable ) {
|
||||
firstFocusable.focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
if (e.shiftKey && document.activeElement === firstFocusable) {
|
||||
lastFocusable.focus();
|
||||
e.preventDefault();
|
||||
} else if (!e.shiftKey && document.activeElement === lastFocusable) {
|
||||
firstFocusable.focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,40 +65,30 @@ jQuery(document).ready(function($) {
|
||||
/**
|
||||
* Close popups on escape key.
|
||||
*/
|
||||
$( document ).on( 'keydown', function( event ) {
|
||||
if ( event.keyCode === 27 ) {
|
||||
$(document).on('keydown', function(event) {
|
||||
if (event.keyCode === 27) {
|
||||
event.preventDefault();
|
||||
//$( '.primary-menu-wrap' ).removeClass( 'menu-active' );
|
||||
$( '.mt-menu-search .mt-form-wrap' ).removeClass( 'search-activate' );
|
||||
$('.mt-menu-search .mt-form-wrap').removeClass('search-activate');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Settings about WOW animation
|
||||
*/
|
||||
var wowOption = sophia_after_darkObject.wow_effect;
|
||||
if( wowOption === 'on' ) {
|
||||
if (sophia_after_darkObject.wow_effect === 'on') {
|
||||
new WOW().init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings about sticky menu
|
||||
*/
|
||||
var stickyOption = sophia_after_darkObject.menu_sticky;
|
||||
if( stickyOption === 'on' ) {
|
||||
var windowWidth = $( window ).width();
|
||||
if( windowWidth < 500 ) {
|
||||
var wpAdminBar = 0;
|
||||
} else {
|
||||
var wpAdminBar = $('#wpadminbar');
|
||||
}
|
||||
if ( wpAdminBar.length ) {
|
||||
$(".mt-social-menu-wrapper").sticky({topSpacing:wpAdminBar.height()});
|
||||
} else {
|
||||
$(".mt-social-menu-wrapper").sticky({topSpacing:0});
|
||||
}
|
||||
if (sophia_after_darkObject.menu_sticky === 'on') {
|
||||
const wpAdminBar = $('#wpadminbar').length ? $('#wpadminbar') : 0;
|
||||
$(".mt-social-menu-wrapper").sticky({
|
||||
topSpacing: wpAdminBar.length ? wpAdminBar.height() : 0
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scroll To Top
|
||||
*/
|
||||
@ -115,71 +99,63 @@ jQuery(document).ready(function($) {
|
||||
$('#mt-scrollup').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
|
||||
$('#mt-scrollup').click(function() {
|
||||
$("html, body").animate({
|
||||
scrollTop: 0
|
||||
}, 600);
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Slider scripts
|
||||
*/
|
||||
$('.front-slider').lightSlider({
|
||||
pager: false,
|
||||
auto: false,
|
||||
loop: true,
|
||||
item: 1,
|
||||
controls: true,
|
||||
slideMargin:0,
|
||||
rtl:true,
|
||||
nextHtml: '<span class="icon-prev"><i class="fa fa-angle-left"></i></span>',
|
||||
prevHtml: '<span class="icon-next"><i class="fa fa-angle-right"></i></span>',
|
||||
|
||||
onSliderLoad: function() {
|
||||
$('.front-slider').removeClass('cS-hidden');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Slider scripts
|
||||
*/
|
||||
$('.mt-gallery-slider').lightSlider({
|
||||
pager: false,
|
||||
auto: false,
|
||||
loop: true,
|
||||
item: 1,
|
||||
controls: true,
|
||||
});
|
||||
function initializeSlider(selector, rtl = true) {
|
||||
$(selector).lightSlider({
|
||||
pager: false,
|
||||
auto: false,
|
||||
loop: true,
|
||||
item: 1,
|
||||
controls: true,
|
||||
slideMargin: 0,
|
||||
rtl: rtl,
|
||||
nextHtml: '<span class="icon-prev"><i class="fa fa-angle-left"></i></span>',
|
||||
prevHtml: '<span class="icon-next"><i class="fa fa-angle-right"></i></span>',
|
||||
onSliderLoad: function() {
|
||||
$(selector).removeClass('cS-hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
initializeSlider('.front-slider');
|
||||
initializeSlider('.mt-gallery-slider', false);
|
||||
|
||||
/**
|
||||
* Responsive menu
|
||||
*/
|
||||
|
||||
$('.mt-social-menu-wrapper .menu-toggle').click(function(event) {
|
||||
$('.mt-social-menu-wrapper #site-navigation').toggleClass( 'isActive' ).slideToggle('slow');
|
||||
var element = document.querySelector( '.mt-header-menu-wrap' );
|
||||
if( element ) {
|
||||
$('.mt-social-menu-wrapper .menu-toggle').click(function() {
|
||||
$('#site-navigation').toggleClass('isActive').slideToggle('slow');
|
||||
const $element = $('.mt-header-menu-wrap');
|
||||
if ($element.length) {
|
||||
$(document).on('keydown', function(e) {
|
||||
if( element.querySelectorAll( '.mt-social-menu-wrapper #site-navigation.isActive' ).length === 1 ) {
|
||||
var focusable = element.querySelectorAll( 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
||||
var firstFocusable = focusable[0];
|
||||
var lastFocusable = focusable[focusable.length - 1];
|
||||
sophia_after_dark_focus_trap( firstFocusable, lastFocusable, e );
|
||||
if ($('#site-navigation.isActive').length) {
|
||||
const focusable = $element.find('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
||||
const firstFocusable = focusable[0];
|
||||
const lastFocusable = focusable[focusable.length - 1];
|
||||
sophia_after_dark_focus_trap(firstFocusable, lastFocusable, e);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* responsive sub menu toggle
|
||||
* Responsive sub menu toggle
|
||||
*/
|
||||
$('<a href="javascript:void(0);" class="sub-toggle"><i class="fa fa-angle-right"></i></a>').insertAfter('#site-navigation .menu-item-has-children>a, #site-navigation .page_item_has_children>a');
|
||||
|
||||
$('#site-navigation .sub-toggle').click(function() {
|
||||
$(this).parent('.menu-item-has-children').children('ul.sub-menu').first().slideToggle('1000');
|
||||
jQuery(this).parent('.page_item_has_children').children('ul.children').first().slideToggle('1000');
|
||||
$(this).parent('.menu-item-has-children').children('ul.sub-menu').first().slideToggle(1000);
|
||||
$(this).parent('.page_item_has_children').children('ul.children').first().slideToggle(1000);
|
||||
$(this).children('.fa-angle-right').first().toggleClass('fa-angle-down');
|
||||
});
|
||||
|
||||
@ -189,9 +165,8 @@ jQuery(document).ready(function($) {
|
||||
$(window).on('load', function() {
|
||||
if ($(window).width() > 839) {
|
||||
$(".front-slider-wrapper").each(function() {
|
||||
var imageHeight = $(this).height();
|
||||
$(this).find(".slider-post-wrap").css('height', imageHeight);
|
||||
$(this).find(".front-slider ").css('height', imageHeight);
|
||||
const imageHeight = $(this).height();
|
||||
$(this).find(".slider-post-wrap, .front-slider").css('height', imageHeight);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user