first commit
This commit is contained in:
48
wp-content/themes/aac/js/blog-loadmore.js
Normal file
48
wp-content/themes/aac/js/blog-loadmore.js
Normal file
@@ -0,0 +1,48 @@
|
||||
jQuery(function ($) {
|
||||
let paged = 1
|
||||
const cat = aac_loadmore_params.cat || 0
|
||||
const $btn = $('#load-more')
|
||||
const $container = $('#blog-posts')
|
||||
|
||||
$btn.on('click', function () {
|
||||
$btn.prop('disabled', true).text('Ładowanie...')
|
||||
|
||||
$.ajax({
|
||||
url: aac_loadmore_params.ajax_url,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: 'load_more_posts',
|
||||
paged: paged,
|
||||
cat: cat,
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.success) {
|
||||
const $newItems = $(res.data.html).addClass('is-new')
|
||||
$container.append($newItems)
|
||||
|
||||
setTimeout(() => {
|
||||
$newItems.each(function (i, el) {
|
||||
setTimeout(() => {
|
||||
$(el).removeClass('is-new')
|
||||
}, i * 100)
|
||||
})
|
||||
}, 50)
|
||||
|
||||
paged = res.data.paged
|
||||
|
||||
if (paged < res.data.max) {
|
||||
$btn.prop('disabled', false).text('Wczytaj więcej')
|
||||
} else {
|
||||
$btn.fadeOut()
|
||||
}
|
||||
} else {
|
||||
$btn.fadeOut()
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$btn.text('Błąd ładowania')
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
42
wp-content/themes/aac/js/custom.js
Normal file
42
wp-content/themes/aac/js/custom.js
Normal file
@@ -0,0 +1,42 @@
|
||||
jQuery(function ($) {
|
||||
$('body').on('click', '.c-tabs .c-tabs--nav li', function (e) {
|
||||
e.preventDefault()
|
||||
|
||||
let tabId = $(this).attr('tab_id')
|
||||
|
||||
$(this)
|
||||
.closest('.c-tabs')
|
||||
.find('.c-tabs--nav li')
|
||||
.not(this)
|
||||
.removeClass('active')
|
||||
$(this).addClass('active')
|
||||
|
||||
$(this)
|
||||
.closest('.c-tabs')
|
||||
.find('.c-tabs--content [tab_id]')
|
||||
.not('[tab_id=' + tabId + ']')
|
||||
.hide()
|
||||
$(this)
|
||||
.closest('.c-tabs')
|
||||
.find('.c-tabs--content [tab_id=' + $(this).attr('tab_id') + ']')
|
||||
.show()
|
||||
})
|
||||
$('.c-tabs .c-tabs--nav li:first-child').trigger('click')
|
||||
})
|
||||
|
||||
jQuery(function ($) {
|
||||
$('body').on(
|
||||
'click',
|
||||
'.modules-tiles .module-tile .module-tile--btn',
|
||||
function (e) {
|
||||
e.preventDefault()
|
||||
|
||||
let $tile = $(this).closest('.module-tile')
|
||||
$tile.toggleClass('active')
|
||||
$(this).toggleClass('active')
|
||||
$('.module-tile--content', $tile).slideToggle()
|
||||
$('.text-more', this).toggle()
|
||||
$('.text-less', this).toggle()
|
||||
}
|
||||
)
|
||||
})
|
||||
42
wp-content/themes/aac/js/customizer.js
Normal file
42
wp-content/themes/aac/js/customizer.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/* global wp, jQuery */
|
||||
/**
|
||||
* 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 ) );
|
||||
142
wp-content/themes/aac/js/navigation.js
Normal file
142
wp-content/themes/aac/js/navigation.js
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* File navigation.js.
|
||||
*
|
||||
* Handles toggling the navigation menu for small screens and enables TAB key
|
||||
* navigation support for dropdown menus.
|
||||
*/
|
||||
( function() {
|
||||
const siteNavigation = document.getElementById( 'site-navigation' );
|
||||
|
||||
// Return early if the navigation doesn't exist.
|
||||
if ( ! siteNavigation ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const button = siteNavigation.getElementsByTagName( 'button' )[ 0 ];
|
||||
|
||||
// Return early if the button doesn't exist.
|
||||
if ( 'undefined' === typeof button ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const menu = siteNavigation.getElementsByTagName( 'ul' )[ 0 ];
|
||||
|
||||
// Hide menu toggle button if menu is empty and return early.
|
||||
if ( 'undefined' === typeof menu ) {
|
||||
button.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! menu.classList.contains( 'nav-menu' ) ) {
|
||||
menu.classList.add( 'nav-menu' );
|
||||
}
|
||||
|
||||
// Toggle the .toggled class and the aria-expanded value each time the button is clicked.
|
||||
button.addEventListener( 'click', function() {
|
||||
siteNavigation.classList.toggle( 'toggled' );
|
||||
|
||||
let menuContainer = siteNavigation.querySelector('.menu-menu-container');
|
||||
|
||||
if (menuContainer) {
|
||||
slideToggle(menuContainer, 300);
|
||||
}
|
||||
|
||||
if ( button.getAttribute( 'aria-expanded' ) === 'true' ) {
|
||||
button.setAttribute( 'aria-expanded', 'false' );
|
||||
} else {
|
||||
button.setAttribute( 'aria-expanded', 'true' );
|
||||
}
|
||||
} );
|
||||
|
||||
// Remove the .toggled class and set aria-expanded to false when the user clicks outside the navigation.
|
||||
document.addEventListener( 'click', function( event ) {
|
||||
const isClickInside = siteNavigation.contains( event.target );
|
||||
|
||||
if ( ! isClickInside ) {
|
||||
siteNavigation.classList.remove( 'toggled' );
|
||||
button.setAttribute( 'aria-expanded', 'false' );
|
||||
}
|
||||
} );
|
||||
|
||||
// Get all the link elements within the menu.
|
||||
const links = menu.getElementsByTagName( 'a' );
|
||||
|
||||
// Get all the link elements with children within the menu.
|
||||
const linksWithChildren = menu.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
|
||||
|
||||
// Toggle focus each time a menu link is focused or blurred.
|
||||
for ( const link of links ) {
|
||||
link.addEventListener( 'focus', toggleFocus, true );
|
||||
link.addEventListener( 'blur', toggleFocus, true );
|
||||
}
|
||||
|
||||
// Toggle focus each time a menu link with children receive a touch event.
|
||||
for ( const link of linksWithChildren ) {
|
||||
link.addEventListener( 'touchstart', toggleFocus, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or removes .focus class on an element.
|
||||
*/
|
||||
function toggleFocus() {
|
||||
if ( event.type === 'focus' || event.type === 'blur' ) {
|
||||
let self = this;
|
||||
// Move up through the ancestors of the current link until we hit .nav-menu.
|
||||
while ( ! self.classList.contains( 'nav-menu' ) ) {
|
||||
// On li elements toggle the class .focus.
|
||||
if ( 'li' === self.tagName.toLowerCase() ) {
|
||||
self.classList.toggle( 'focus' );
|
||||
}
|
||||
self = self.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
if ( event.type === 'touchstart' ) {
|
||||
const menuItem = this.parentNode;
|
||||
event.preventDefault();
|
||||
for ( const link of menuItem.parentNode.children ) {
|
||||
if ( menuItem !== link ) {
|
||||
link.classList.remove( 'focus' );
|
||||
}
|
||||
}
|
||||
menuItem.classList.toggle( 'focus' );
|
||||
}
|
||||
}
|
||||
|
||||
function slideToggle(element, duration = 300) {
|
||||
if (window.getComputedStyle(element).display === 'none') {
|
||||
// slideDown
|
||||
element.style.removeProperty('display');
|
||||
let display = window.getComputedStyle(element).display;
|
||||
if (display === 'none') display = 'block';
|
||||
element.style.display = display;
|
||||
|
||||
let height = element.offsetHeight;
|
||||
element.style.overflow = 'hidden';
|
||||
element.style.height = '0px';
|
||||
element.offsetHeight; // force reflow
|
||||
element.style.transition = `height ${duration}ms ease`;
|
||||
element.style.height = height + 'px';
|
||||
|
||||
setTimeout(() => {
|
||||
element.style.removeProperty('height');
|
||||
element.style.removeProperty('overflow');
|
||||
element.style.removeProperty('transition');
|
||||
}, duration);
|
||||
} else {
|
||||
// slideUp
|
||||
element.style.height = element.offsetHeight + 'px';
|
||||
element.offsetHeight; // force reflow
|
||||
element.style.transition = `height ${duration}ms ease`;
|
||||
element.style.height = '0px';
|
||||
element.style.overflow = 'hidden';
|
||||
|
||||
setTimeout(() => {
|
||||
element.style.display = 'none';
|
||||
element.style.removeProperty('height');
|
||||
element.style.removeProperty('overflow');
|
||||
element.style.removeProperty('transition');
|
||||
}, duration);
|
||||
}
|
||||
}
|
||||
}() );
|
||||
48
wp-content/themes/aac/js/podcasts-loadmore.js
Normal file
48
wp-content/themes/aac/js/podcasts-loadmore.js
Normal file
@@ -0,0 +1,48 @@
|
||||
jQuery(function ($) {
|
||||
let paged = 1
|
||||
const cat = aac_loadmore_params.cat || 0
|
||||
const $btn = $('#load-more-podcasts')
|
||||
const $container = $('#podcasty-list')
|
||||
|
||||
$btn.on('click', function () {
|
||||
$btn.prop('disabled', true).text('Ładowanie...')
|
||||
|
||||
$.ajax({
|
||||
url: aac_loadmore_params.ajax_url,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: 'load_more_podcasts',
|
||||
paged: paged,
|
||||
cat: cat,
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.success) {
|
||||
const $newItems = $(res.data.html).addClass('is-new')
|
||||
$container.append($newItems)
|
||||
|
||||
setTimeout(() => {
|
||||
$newItems.each(function (i, el) {
|
||||
setTimeout(() => {
|
||||
$(el).removeClass('is-new')
|
||||
}, i * 100)
|
||||
})
|
||||
}, 50)
|
||||
|
||||
paged = res.data.paged
|
||||
|
||||
if (paged < res.data.max) {
|
||||
$btn.prop('disabled', false).text('Wczytaj więcej')
|
||||
} else {
|
||||
$btn.fadeOut()
|
||||
}
|
||||
} else {
|
||||
$btn.fadeOut()
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$btn.text('Błąd ładowania')
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user