init commit

This commit is contained in:
2023-07-04 11:21:47 -07:00
commit ce48e96737
105 changed files with 28651 additions and 0 deletions

42
assets/js/customizer.js Normal file
View File

@@ -0,0 +1,42 @@
/**
* File customizer.js.
*
* Theme Customizer enhancements for a better user experience.
*
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
*/
( function( $ ) {
// Site title and description.
wp.customize( 'blogname', function( value ) {
value.bind( function( to ) {
$( '.site-title a' ).text( to );
} );
} );
wp.customize( 'blogdescription', function( value ) {
value.bind( function( to ) {
$( '.site-description' ).text( to );
} );
} );
// Header text color.
wp.customize( 'header_textcolor', function( value ) {
value.bind( function( to ) {
if ( 'blank' === to ) {
$( '.site-title, .site-description' ).css( {
'clip': 'rect(1px, 1px, 1px, 1px)',
'position': 'absolute'
} );
} else {
$( '.site-title, .site-description' ).css( {
'clip': 'auto',
'position': 'relative'
} );
$( '.site-title a, .site-description' ).css( {
'color': to
} );
}
} );
} );
} )( jQuery );

View File

@@ -0,0 +1,73 @@
/**
* Image up-loader functions
*/
var mtSelector;
function upload_media_image(mtSelector){
// ADD IMAGE LINK
jQuery('body').on( 'click', mtSelector , function( event ){
event.preventDefault();
var imgContainer = jQuery(this).closest('.attachment-media-view').find( '.thumbnail-image'),
placeholder = jQuery(this).closest('.attachment-media-view').find( '.placeholder'),
imgIdInput = jQuery(this).siblings('.upload-id');
// Create a new media frame
frame = wp.media({
title: 'Select or Upload Image',
button: {
text: 'Use Image'
},
multiple: false // Set to true to allow multiple files to be selected
});
// When an image is selected in the media frame...
frame.on( 'select', function() {
// Get media attachment details from the frame state
var attachment = frame.state().get('selection').first().toJSON();
// Send the attachment URL to our custom image input field.
imgContainer.html( '<img src="'+attachment.url+'" style="max-width:100%;"/>' );
placeholder.addClass('hidden');
imgIdInput.val( attachment.url ).trigger('change');
});
// Finally, open the modal on click
frame.open();
});
}
function delete_media_image(mtSelector){
// DELETE IMAGE LINK
jQuery('body').on( 'click', mtSelector, function( event ){
event.preventDefault();
var imgContainer = jQuery(this).closest('.attachment-media-view').find( '.thumbnail-image'),
placeholder = jQuery(this).closest('.attachment-media-view').find( '.placeholder'),
imgIdInput = jQuery(this).siblings('.upload-id');
// Clear out the preview image
imgContainer.find('img').remove();
placeholder.removeClass('hidden');
// Delete the image id from the hidden input
imgIdInput.val( '' ).trigger('change');
});
}
jQuery(document).ready(function($){
"use strict";
/**
* Radio Image control in metabox
*/
$( '.mt-meta-options-wrap .buttonset' ).buttonset();
/**
* Image up-loader
*/
upload_media_image('.mt-upload-button');
delete_media_image('.mt-delete-button');
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,199 @@
jQuery(document).ready(function($) {
"use strict";
/**
* Sophia After Dark Preloader
*/
if($('#preloader-background').length > 0) {
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, {
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 ) {
$(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 );
})
}
});
/**
* Focus trap in popup.
*/
var 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();
}
}
}
}
$('.mt-form-wrap .mt-form-close').click(function() {
$('.mt-form-wrap').toggleClass('search-activate');
$(this).parents('.mt-menu-search').find('.mt-search-icon a').focus();
});
/**
* Close popups on escape key.
*/
$( 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' );
}
});
/**
* Settings about WOW animation
*/
var wowOption = sophia_after_darkObject.wow_effect;
if( wowOption === '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});
}
}
/**
* Scroll To Top
*/
$(window).scroll(function() {
if ($(this).scrollTop() > 1000) {
$('#mt-scrollup').fadeIn('slow');
} else {
$('#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,
});
/**
* 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 ) {
$(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 );
}
})
}
});
/**
* 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).children('.fa-angle-right').first().toggleClass('fa-angle-down');
});
/**
* Slider Section dynamic height script
*/
$(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);
});
}
});
});

View File

@@ -0,0 +1,222 @@
( function( api ) {
api.sectionConstructor['mt-upsell'] = api.Section.extend( {
// No events for this type of section.
attachEvents: function () {},
// Always make the section active.
isContextuallyActive: function () {
return true;
}
} );
} )( wp.customize );
wp.customize.controlConstructor['mt-toggle'] = wp.customize.Control.extend({
ready: function(){
'use strict';
var control = this,
checkboxValue = control.setting._value;
// Toggle checkbox
// Save the value
this.container.on( 'change', 'input', function() {
checkboxValue = ( jQuery( this ).is( ':checked' ) ) ? true : false;
control.setting.set( checkboxValue );
});
}
});
jQuery(document).ready(function($) {
"use strict";
/**
* Function for repeater field
*/
function sophia_after_dark_refresh_repeater_values(){
$(".mt-repeater-field-control-wrap").each(function(){
var values = [];
var $this = $(this);
$this.find(".mt-repeater-field-control").each(function(){
var valueToPush = {};
$(this).find('[data-name]').each(function(){
var dataName = $(this).attr('data-name');
var dataValue = $(this).val();
valueToPush[dataName] = dataValue;
});
values.push(valueToPush);
});
$this.next('.mt-repeater-collector').val(JSON.stringify(values)).trigger('change');
});
}
$('#customize-theme-controls').on('click','.mt-repeater-field-title',function(){
$(this).next().slideToggle();
$(this).closest('.mt-repeater-field-control').toggleClass('expanded');
});
$('#customize-theme-controls').on('click', '.mt-repeater-field-close', function(){
$(this).closest('.mt-repeater-fields').slideUp();;
$(this).closest('.mt-repeater-field-control').toggleClass('expanded');
});
$("body").on("click",'.mt-repeater-add-control-field', function(){
var fLimit = $(this).parent().find('.field-limit').val();
var fCount = $(this).parent().find('.field-count').val();
if( fCount < fLimit ) {
fCount++;
$(this).parent().find('.field-count').val(fCount);
} else {
$(this).before('<span class="mt-limit-msg"><em>Only '+fLimit+' repeater field will be permitted.</em></span>');
return;
}
var $this = $(this).parent();
if(typeof $this != 'undefined') {
var field = $this.find(".mt-repeater-field-control:first").clone();
if(typeof field != 'undefined'){
field.find("input[type='text'][data-name]").each(function(){
var defaultValue = $(this).attr('data-default');
$(this).val(defaultValue);
});
field.find("textarea[data-name]").each(function(){
var defaultValue = $(this).attr('data-default');
$(this).val(defaultValue);
});
field.find("select[data-name]").each(function(){
var defaultValue = $(this).attr('data-default');
$(this).val(defaultValue);
});
field.find(".attachment-media-view").each(function(){
var defaultValue = $(this).find('input[data-name]').attr('data-default');
$(this).find('input[data-name]').val(defaultValue);
if(defaultValue){
$(this).find(".thumbnail-image").html('<img src="'+defaultValue+'"/>').prev('.placeholder').addClass('hidden');
}else{
$(this).find(".thumbnail-image").html('').prev('.placeholder').removeClass('hidden');
}
});
field.find(".mt-repeater-icon-list").each(function(){
var defaultValue = $(this).next('input[data-name]').attr('data-default');
$(this).next('input[data-name]').val(defaultValue);
$(this).prev('.mt-repeater-selected-icon').children('i').attr('class','').addClass(defaultValue);
$(this).find('li').each(function(){
var icon_class = $(this).find('i').attr('class');
if(defaultValue == icon_class ){
$(this).addClass('icon-active');
}else{
$(this).removeClass('icon-active');
}
});
});
field.find('.mt-repeater-fields').show();
$this.find('.mt-repeater-field-control-wrap').append(field);
field.addClass('expanded').find('.mt-repeater-fields').show();
$('.accordion-section-content').animate({ scrollTop: $this.height() }, 1000);
sophia_after_dark_refresh_repeater_values();
}
}
return false;
});
$("#customize-theme-controls").on("click", ".mt-repeater-field-remove",function(){
if( typeof $(this).parent() != 'undefined'){
$(this).closest('.mt-repeater-field-control').slideUp('normal', function(){
$(this).remove();
sophia_after_dark_refresh_repeater_values();
});
}
return false;
});
$("#customize-theme-controls").on('keyup change', '[data-name]',function(){
sophia_after_dark_refresh_repeater_values();
return false;
});
/**
* Drag and drop to change order
*/
$(".mt-repeater-field-control-wrap").sortable({
orientation: "vertical",
update: function( event, ui ) {
sophia_after_dark_refresh_repeater_values();
}
});
/**
* Image upload
*/
var mtFrame;
//Add image
$('.customize-control-mt-repeater').on( 'click', '.mt-upload-button', function( event ){
event.preventDefault();
var imgContainer = $(this).closest('.mt-fields-wrap').find( '.thumbnail-image'),
placeholder = $(this).closest('.mt-fields-wrap').find( '.placeholder'),
imgIdInput = $(this).siblings('.upload-id');
mtFrame = wp.media({
title: 'Select or Upload Image',
button: {
text: 'Use Image'
},
multiple: false // Set to true to allow multiple files to be selected
});
mtFrame.on( 'select', function() {
var attachment = frame.state().get('selection').first().toJSON();
imgContainer.html( '<img src="'+attachment.url+'" style="max-width:100%;"/>' );
placeholder.addClass('hidden');
imgIdInput.val( attachment.url ).trigger('change');
});
mtFrame.open();
});
// DELETE IMAGE LINK
$('.customize-control-mt-repeater').on( 'click', '.mt-delete-button', function( event ){
event.preventDefault();
var imgContainer = $(this).closest('.mt-fields-wrap').find( '.thumbnail-image'),
placeholder = $(this).closest('.mt-fields-wrap').find( '.placeholder'),
imgIdInput = $(this).siblings('.upload-id');
imgContainer.find('img').remove();
placeholder.removeClass('hidden');
imgIdInput.val( '' ).trigger('change');
});
/**
* Repeater icon selector
*/
$('body').on('click', '.mt-repeater-icon-list li', function(){
var icon_class = $(this).find('i').attr('class');
$(this).addClass('icon-active').siblings().removeClass('icon-active');
$(this).parent('.mt-repeater-icon-list').prev('.mt-repeater-selected-icon').children('i').attr('class','').addClass(icon_class);
$(this).parent('.mt-repeater-icon-list').next('input').val(icon_class).trigger('change');
sophia_after_dark_refresh_repeater_values();
});
$('body').on('click', '.mt-repeater-selected-icon', function(){
$(this).next().slideToggle();
});
});

82
assets/js/navigation.js Normal file
View File

@@ -0,0 +1,82 @@
/**
* File navigation.js.
*
* Handles toggling the navigation menu for small screens and enables TAB key
* navigation support for dropdown menus.
*/
( function() {
var container, button, menu, links, i, len;
container = document.getElementById( 'site-navigation' );
if ( ! container ) {
return;
}
menu = container.getElementsByTagName( 'ul' )[0];
menu.setAttribute( 'aria-expanded', 'false' );
if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
menu.className += ' nav-menu';
}
// Get all the link elements within the menu.
links = menu.getElementsByTagName( 'a' );
// Each time a menu link is focused or blurred, toggle focus.
for ( i = 0, len = links.length; i < len; i++ ) {
links[i].addEventListener( 'focus', toggleFocus, true );
links[i].addEventListener( 'blur', toggleFocus, true );
}
/**
* Sets or removes .focus class on an element.
*/
function toggleFocus() {
var self = this;
// Move up through the ancestors of the current link until we hit .nav-menu.
while ( -1 === self.className.indexOf( 'nav-menu' ) ) {
// On li elements toggle the class .focus.
if ( 'li' === self.tagName.toLowerCase() ) {
if ( -1 !== self.className.indexOf( 'focus' ) ) {
self.className = self.className.replace( ' focus', '' );
} else {
self.className += ' focus';
}
}
self = self.parentElement;
}
}
/**
* Toggles `focus` class to allow submenu access on tablets.
*/
( function( container ) {
var touchStartFn, i,
parentLink = container.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
if ( 'ontouchstart' in window ) {
touchStartFn = function( e ) {
var menuItem = this.parentNode, i;
if ( ! menuItem.classList.contains( 'focus' ) ) {
e.preventDefault();
for ( i = 0; i < menuItem.parentNode.children.length; ++i ) {
if ( menuItem === menuItem.parentNode.children[i] ) {
continue;
}
menuItem.parentNode.children[i].classList.remove( 'focus' );
}
menuItem.classList.add( 'focus' );
} else {
menuItem.classList.remove( 'focus' );
}
};
for ( i = 0; i < parentLink.length; ++i ) {
parentLink[i].addEventListener( 'touchstart', touchStartFn, false );
}
}
}( container ) );
} )();

View File

@@ -0,0 +1,31 @@
/**
* File skip-link-focus-fix.js.
*
* Helps with accessibility for keyboard only users.
*
* Learn more: https://git.io/vWdr2
*/
( function() {
var isIe = /(trident|msie)/i.test( navigator.userAgent );
if ( isIe && 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 );
}
} )();