ac4759d057
Rewrites existing jQuery code as vanila, IE11-compatible ES5. The only exception is the customizer code, which is only used in wp-admin. Sites that are not making use of other jQuery-dependent functionality should see a nice reduction in the amount of loaded JS.
33 lines
773 B
JavaScript
33 lines
773 B
JavaScript
/**
|
|
* script-wpcom.js
|
|
*
|
|
* Handles toggling of body class name to help WordPress.com custom colors target color changes at different window sizes.
|
|
* The Custom Colors plugin does not support media queries.
|
|
*/
|
|
( function() {
|
|
function checkWidth( init ) {
|
|
// If browser is resized, check width again
|
|
if ( window.innerWidth > 992 ) {
|
|
document.body.classList.add( 'tablet-desktop' );
|
|
}
|
|
else {
|
|
if ( ! init ) {
|
|
document.body.classList.remove( 'tablet-desktop' );
|
|
}
|
|
}
|
|
}
|
|
|
|
function init() {
|
|
checkWidth( true );
|
|
window.addEventListener( 'resize', function() {
|
|
checkWidth( false);
|
|
} );
|
|
}
|
|
|
|
// After DOM is ready.
|
|
if ( document.readyState !== 'loading' ) {
|
|
init();
|
|
} else {
|
|
document.addEventListener( 'DOMContentLoaded', init );
|
|
}
|
|
} )();
|