Skip to content

Commit 3aa79dc

Browse files
committed
first
0 parents  commit 3aa79dc

File tree

69 files changed

+11449
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+11449
-0
lines changed
Binary file not shown.
Binary file not shown.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* File customizer.js.
3+
*
4+
* Theme Customizer enhancements for a better user experience.
5+
*
6+
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
7+
*/
8+
9+
(function() {
10+
11+
wp.customize.bind( 'ready', function() {
12+
13+
// Only show the color hue control when there's a custom primary color.
14+
wp.customize( 'primary_color', function( setting ) {
15+
wp.customize.control( 'primary_color_hue', function( control ) {
16+
var visibility = function() {
17+
if ( 'custom' === setting.get() ) {
18+
control.container.slideDown( 180 );
19+
} else {
20+
control.container.slideUp( 180 );
21+
}
22+
};
23+
24+
visibility();
25+
setting.bind( visibility );
26+
});
27+
});
28+
});
29+
30+
})( jQuery );
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* File customizer.js.
3+
*
4+
* Theme Customizer enhancements for a better user experience.
5+
*
6+
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
7+
*/
8+
9+
(function( $ ) {
10+
11+
// Primary color.
12+
wp.customize( 'primary_color', function( value ) {
13+
value.bind( function( to ) {
14+
// Update custom color CSS.
15+
var style = $( '#custom-theme-colors' ),
16+
hue = style.data( 'hue' ),
17+
css = style.html(),
18+
color;
19+
20+
if( 'custom' === to ){
21+
// If a custom primary color is selected, use the currently set primary_color_hue
22+
color = wp.customize.get().primary_color_hue;
23+
} else {
24+
// If the "default" option is selected, get the default primary_color_hue
25+
color = 199;
26+
}
27+
28+
// Equivalent to css.replaceAll, with hue followed by comma to prevent values with units from being changed.
29+
css = css.split( hue + ',' ).join( color + ',' );
30+
style.html( css ).data( 'hue', color );
31+
});
32+
});
33+
34+
// Primary color hue.
35+
wp.customize( 'primary_color_hue', function( value ) {
36+
value.bind( function( to ) {
37+
38+
// Update custom color CSS.
39+
var style = $( '#custom-theme-colors' ),
40+
hue = style.data( 'hue' ),
41+
css = style.html();
42+
43+
// Equivalent to css.replaceAll, with hue followed by comma to prevent values with units from being changed.
44+
css = css.split( hue + ',' ).join( to + ',' );
45+
style.html( css ).data( 'hue', to );
46+
});
47+
});
48+
49+
// Image filter.
50+
wp.customize( 'image_filter', function( value ) {
51+
value.bind( function( to ) {
52+
if ( to ) {
53+
$( 'body' ).addClass( 'image-filters-enabled' );
54+
} else {
55+
$( 'body' ).removeClass( 'image-filters-enabled' );
56+
}
57+
} );
58+
} );
59+
60+
})( jQuery );
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
(function() {
2+
3+
/**
4+
* Debounce
5+
*
6+
* @param {Function} func
7+
* @param {number} wait
8+
* @param {boolean} immediate
9+
*/
10+
function debounce(func, wait, immediate) {
11+
'use strict';
12+
13+
var timeout;
14+
wait = (typeof wait !== 'undefined') ? wait : 20;
15+
immediate = (typeof immediate !== 'undefined') ? immediate : true;
16+
17+
return function() {
18+
19+
var context = this, args = arguments;
20+
var later = function() {
21+
timeout = null;
22+
23+
if (!immediate) {
24+
func.apply(context, args);
25+
}
26+
};
27+
28+
var callNow = immediate && !timeout;
29+
30+
clearTimeout(timeout);
31+
timeout = setTimeout(later, wait);
32+
33+
if (callNow) {
34+
func.apply(context, args);
35+
}
36+
};
37+
}
38+
39+
/**
40+
* Prepends an element to a container.
41+
*
42+
* @param {Element} container
43+
* @param {Element} element
44+
*/
45+
function prependElement(container, element) {
46+
if (container.firstChild.nextSibling) {
47+
return container.insertBefore(element, container.firstChild.nextSibling);
48+
} else {
49+
return container.appendChild(element);
50+
}
51+
}
52+
53+
/**
54+
* Shows an element by adding a hidden className.
55+
*
56+
* @param {Element} element
57+
*/
58+
function showButton(element) {
59+
// classList.remove is not supported in IE11
60+
element.className = element.className.replace('is-empty', '');
61+
}
62+
63+
/**
64+
* Hides an element by removing the hidden className.
65+
*
66+
* @param {Element} element
67+
*/
68+
function hideButton(element) {
69+
// classList.add is not supported in IE11
70+
if (!element.classList.contains('is-empty')) {
71+
element.className += ' is-empty';
72+
}
73+
}
74+
75+
/**
76+
* Returns the currently available space in the menu container.
77+
*
78+
* @returns {number} Available space
79+
*/
80+
function getAvailableSpace( button, container ) {
81+
return container.offsetWidth - button.offsetWidth - 22;
82+
}
83+
84+
/**
85+
* Returns whether the current menu is overflowing or not.
86+
*
87+
* @returns {boolean} Is overflowing
88+
*/
89+
function isOverflowingNavivation( list, button, container ) {
90+
return list.offsetWidth > getAvailableSpace( button, container );
91+
}
92+
93+
/**
94+
* Set menu container variable
95+
*/
96+
var navContainer = document.querySelector('.main-navigation');
97+
var breaks = [];
98+
99+
/**
100+
* Let’s bail if we our menu doesn't exist
101+
*/
102+
if ( ! navContainer ) {
103+
return;
104+
}
105+
106+
/**
107+
* Refreshes the list item from the menu depending on the menu size
108+
*/
109+
function updateNavigationMenu( container ) {
110+
111+
/**
112+
* Let’s bail if our menu is empty
113+
*/
114+
if ( ! container.parentNode.querySelector('.main-menu[id]') ) {
115+
return;
116+
}
117+
118+
// Adds the necessary UI to operate the menu.
119+
var visibleList = container.parentNode.querySelector('.main-menu[id]');
120+
var hiddenList = visibleList.parentNode.nextElementSibling.querySelector('.hidden-links');
121+
var toggleButton = visibleList.parentNode.nextElementSibling.querySelector('.main-menu-more-toggle');
122+
123+
if ( isOverflowingNavivation( visibleList, toggleButton, container ) ) {
124+
125+
// Record the width of the list
126+
breaks.push( visibleList.offsetWidth );
127+
// Move last item to the hidden list
128+
prependElement( hiddenList, ! visibleList.lastChild || null === visibleList.lastChild ? visibleList.previousElementSibling : visibleList.lastChild );
129+
// Show the toggle button
130+
showButton( toggleButton );
131+
132+
} else {
133+
134+
// There is space for another item in the nav
135+
if ( getAvailableSpace( toggleButton, container ) > breaks[breaks.length - 1] ) {
136+
// Move the item to the visible list
137+
visibleList.appendChild( hiddenList.firstChild.nextSibling );
138+
breaks.pop();
139+
}
140+
141+
// Hide the dropdown btn if hidden list is empty
142+
if (breaks.length < 2) {
143+
hideButton( toggleButton );
144+
}
145+
}
146+
147+
// Recur if the visible list is still overflowing the nav
148+
if ( isOverflowingNavivation( visibleList, toggleButton, container ) ) {
149+
updateNavigationMenu( container );
150+
}
151+
}
152+
153+
/**
154+
* Run our priority+ function as soon as the document is `ready`
155+
*/
156+
document.addEventListener( 'DOMContentLoaded', function() {
157+
158+
updateNavigationMenu( navContainer );
159+
160+
// Also, run our priority+ function on selective refresh in the customizer
161+
var hasSelectiveRefresh = (
162+
'undefined' !== typeof wp &&
163+
wp.customize &&
164+
wp.customize.selectiveRefresh &&
165+
wp.customize.navMenusPreview.NavMenuInstancePartial
166+
);
167+
168+
if ( hasSelectiveRefresh ) {
169+
// Re-run our priority+ function on Nav Menu partial refreshes
170+
wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function ( placement ) {
171+
172+
var isNewNavMenu = (
173+
placement &&
174+
placement.partial.id.includes( 'nav_menu_instance' ) &&
175+
'null' !== placement.container[0].parentNode &&
176+
placement.container[0].parentNode.classList.contains( 'main-navigation' )
177+
);
178+
179+
if ( isNewNavMenu ) {
180+
updateNavigationMenu( placement.container[0].parentNode );
181+
}
182+
});
183+
}
184+
});
185+
186+
/**
187+
* Run our priority+ function on load
188+
*/
189+
window.addEventListener( 'load', function() {
190+
updateNavigationMenu( navContainer );
191+
});
192+
193+
/**
194+
* Run our priority+ function every time the window resizes
195+
*/
196+
var isResizing = false;
197+
window.addEventListener( 'resize',
198+
debounce( function() {
199+
if ( isResizing ) {
200+
return;
201+
}
202+
203+
isResizing = true;
204+
setTimeout( function() {
205+
updateNavigationMenu( navContainer );
206+
isResizing = false;
207+
}, 150 );
208+
} )
209+
);
210+
211+
/**
212+
* Run our priority+ function
213+
*/
214+
updateNavigationMenu( navContainer );
215+
216+
})();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* File skip-link-focus-fix.js.
3+
*
4+
* Helps with accessibility for keyboard only users.
5+
*
6+
* This is the source file for what is minified in the twentynineteen_skip_link_focus_fix() PHP function.
7+
*
8+
* Learn more: https://git.io/vWdr2
9+
*/
10+
( function() {
11+
var isIe = /(trident|msie)/i.test( navigator.userAgent );
12+
13+
if ( isIe && document.getElementById && window.addEventListener ) {
14+
window.addEventListener( 'hashchange', function() {
15+
var id = location.hash.substring( 1 ),
16+
element;
17+
18+
if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
19+
return;
20+
}
21+
22+
element = document.getElementById( id );
23+
24+
if ( element ) {
25+
if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
26+
element.tabIndex = -1;
27+
}
28+
29+
element.focus();
30+
}
31+
}, false );
32+
}
33+
} )();

0 commit comments

Comments
 (0)