This commit is contained in:
2026-07-02 15:54:39 -06:00
commit 9883323161
17470 changed files with 4470592 additions and 0 deletions
@@ -0,0 +1,29 @@
/* global brightcove, brightcoveData */
( function ( $ ) {
var script = document.createElement( 'script' ),
tld = 'co.jp' === brightcoveData.tld ? 'co.jp' : 'com',
timer = false;
// Load Brightcove script
script.src = 'https://sadmin.brightcove.' + tld + '/js/BrightcoveExperiences.js';
script.type = 'text/javascript';
script.language = 'JavaScript';
document.head.appendChild( script );
// Start detection for Brightcove script loading in its object
try_brightcove();
// Detect if Brightcove script has loaded and bind some events once loaded
function try_brightcove() {
clearTimeout( timer );
if ( 'object' === typeof brightcove ) {
$( document ).ready( brightcove.createExperiences );
$( 'body' ).on( 'post-load', brightcove.createExperiences );
brightcove.createExperiences();
} else {
timer = setTimeout( try_brightcove, 100 );
}
}
} )( jQuery );
@@ -0,0 +1,3 @@
import 'jquery-cycle';
import 'print-this';
import 'jmpress';
@@ -0,0 +1,258 @@
( function ( $ ) {
var jmpressOpts = {
fullscreen: false,
hash: { use: false },
mouse: { clickSelects: false },
keyboard: { use: true },
animation: { transitionDuration: '1s' },
presentationMode: false,
stepSelector: '.step',
duration: {
defaultValue: 0,
},
};
/**
* Presentation constructor
*/
function Presentation( wrapper ) {
var _self, duration, new_css, ie_regex, matches;
_self = this;
_self.wrapper = $( wrapper ); // The wrapper for toggling fullscreen
_self.slideshow = $( '.presentation', wrapper ); // Holds the slides for jmpress
_self.navLeft = $( '.nav-arrow-left', wrapper );
_self.navRight = $( '.nav-arrow-right', wrapper );
_self.expandButton = $( '.nav-fullscreen-button', wrapper );
_self.overlay = $( '.autoplay-overlay', wrapper );
_self.fullscreen = false;
_self.autoPlaying = false;
_self.autoplayTime = parseFloat( _self.slideshow.attr( 'data-autoplay' ), 10 ) || 0;
// The wrapper is scaled to the contents' size so that its border wraps tightly
_self.wrapper.css( {
width: _self.slideshow.width(),
height: _self.slideshow.height(),
} );
duration = _self.slideshow.attr( 'duration' ) || '1s';
jmpressOpts.animation.transitionDuration = duration;
// Compensate for transition times
if ( _self.autoplayTime ) {
_self.autoplayTime += parseFloat( duration, 10 ) * 1000;
}
// Set the opacity transition duration
// as it is delegated by css and not jmpress
duration = 'opacity ' + duration;
new_css = {
width: _self.slideshow.width(),
height: _self.slideshow.height(),
'-webkit-transition': duration,
'-moz-transition': duration,
'-ms-transition': duration,
'-o-transition': duration,
transition: duration,
};
$( '.step', _self.slideshow ).each( function ( i, step ) {
$( step ).css( new_css );
} );
// Apply attribute to allow fading individual bullets here,
// otherwise wp_kses will strip the attribute out
$( '.step.fadebullets li', _self.slideshow ).each( function ( i, step ) {
$( step ).attr( 'data-jmpress', 'fade' );
} );
// Register resizing to window when fullscreen
$( window ).resize( function () {
if ( _self.fullscreen ) {
_self.resizePresentation();
}
} );
// Register the nav bars to move the slides
_self.navLeft.on( 'click', function () {
_self.slideshow.jmpress( 'prev' );
_self.overlay.css( 'opacity', 0 );
return false;
} );
_self.navRight.on( 'click', function () {
_self.slideshow.jmpress( 'next' );
_self.overlay.css( 'opacity', 0 );
return false;
} );
_self.slideshow.on( 'click', function () {
_self.setAutoplay( true );
return false;
} );
_self.slideshow.on( 'focusout', function () {
_self.setAutoplay( false );
} );
// Register toggling fullscreen except for IE 9 or lower
ie_regex = /MSIE\s(\d+)\.\d+/;
matches = ie_regex.exec( navigator.userAgent );
if ( matches && parseInt( matches[ 1 ], 10 ) < 10 ) {
_self.expandButton.remove();
_self.expandButton = null;
} else {
_self.expandButton.on( 'click', function () {
_self.setFullscreen( ! _self.fullscreen );
return false;
} );
}
// Register ESC key to exit fullscreen
$( window ).on( 'keydown', function ( event ) {
if ( event.which === 27 ) {
_self.setFullscreen( false );
}
} );
// Start the presentation
_self.slideshow.jmpress( jmpressOpts );
// Make content visible and remove error message on jmpress success
if ( _self.slideshow.jmpress( 'initialized' ) ) {
_self.slideshow.css( 'display', '' );
_self.overlay.css( 'display', '' );
$( '.not-supported-msg', _self.wrapper ).remove();
}
// A bug in Firefox causes issues with the nav arrows appearing
// on hover in presentation mode. Explicitly disabling fullscreen
// on init seems to fix the issue
_self.setFullscreen( false );
}
$.extend( Presentation.prototype, {
resizePresentation: function () {
var scale, duration, settings, new_css, widthScale, heightScale;
// Set the animation duration to 0 during resizing
// so that there isn't an animation delay when scaling
// up the slide contents
settings = this.slideshow.jmpress( 'settings' );
duration = settings.animation.transitionDuration;
settings.animation.transitionDuration = '0s';
this.slideshow.jmpress( 'reselect' );
scale = 1;
new_css = {
top: 0,
left: 0,
zoom: 1,
};
// Expand the presentation to fill the lesser of the max width or height
// This avoids content moving past the window for certain window sizes
if ( this.fullscreen ) {
widthScale = $( window ).width() / this.slideshow.width();
heightScale = $( window ).height() / this.slideshow.height();
scale = Math.min( widthScale, heightScale );
new_css.top = ( $( window ).height() - scale * this.slideshow.height() ) / 2;
new_css.left = ( $( window ).width() - scale * this.slideshow.width() ) / 2;
}
// Firefox does not support the zoom property; IE does, but it does not work
// well like in webkit, so we manually transform and position the slideshow
if ( this.slideshow.css( '-moz-transform' ) || this.slideshow.css( '-ms-transform' ) ) {
// Firefox keeps the center of the element in place and expands outward
// so we must shift everything to compensate
new_css.top += ( ( scale - 1 ) * this.slideshow.height() ) / 2;
new_css.left += ( ( scale - 1 ) * this.slideshow.width() ) / 2;
scale = 'scale(' + scale + ')';
$.extend( new_css, {
'-moz-transform': scale,
'-ms-transform': scale,
transform: scale,
} );
} else {
// webkit scales everything with zoom so we need to offset the right amount
// so that the content is vertically centered after scaling effects
new_css.top /= scale;
new_css.left /= scale;
new_css.zoom = scale;
}
this.slideshow.css( new_css );
settings.animation.transitionDuration = duration;
this.slideshow.jmpress( 'reselect' );
},
setFullscreen: function ( on ) {
this.fullscreen = on;
this.setAutoplay( false );
// Save the scroll positions before going into fullscreen mode
if ( on ) {
this.scrollVert = $( window ).scrollTop();
this.scrollHoriz = $( window ).scrollLeft();
// Chrome Bug: Force scroll to be at top
// otherwise the presentation can end up offscreen
$( window ).scrollTop( 0 );
$( window ).scrollLeft( 0 );
}
$( 'html' ).toggleClass( 'presentation-global-fullscreen', on );
$( 'body' ).toggleClass( 'presentation-global-fullscreen', on );
this.wrapper.toggleClass( 'presentation-wrapper-fullscreen', on );
this.wrapper.parents().each( function ( i, e ) {
$( e ).toggleClass( 'presentation-wrapper-fullscreen-parent', on );
} );
this.resizePresentation();
// Reset the scroll positions after exiting fullscreen mode
if ( ! on ) {
$( window ).scrollTop( this.scrollVert );
$( window ).scrollLeft( this.scrollHoriz );
}
},
setAutoplay: function ( on ) {
var _self = this,
newAutoplayTime;
if ( _self.autoPlaying === on ) {
return;
}
newAutoplayTime = on && _self.autoplayTime > 0 ? _self.autoplayTime : 0;
_self.slideshow.jmpress( 'settings' ).duration.defaultValue = newAutoplayTime;
// Move to the next slide when activating autoplay
if ( newAutoplayTime ) {
_self.slideshow.jmpress( 'next' );
_self.overlay.css( 'opacity', 0 );
} else {
_self.slideshow.jmpress( 'reselect' );
}
_self.autoPlaying = on;
},
} );
addEventListener( 'DOMContentLoaded', () => {
document.querySelectorAll( '.presentation-wrapper' ).forEach( el => {
new Presentation( el );
} );
} );
} )( jQuery );
@@ -0,0 +1,92 @@
( function ( $ ) {
$.fn.shuffleQuiz = function () {
var allElems = this.get(),
getRandom = function ( max ) {
return Math.floor( Math.random() * max );
},
shuffled = $.map( allElems, function () {
var random = getRandom( allElems.length ),
randEl = $( allElems[ random ] ).clone( true )[ 0 ];
allElems.splice( random, 1 );
return randEl;
} );
this.each( function ( i ) {
$( this ).replaceWith( $( shuffled[ i ] ) );
} );
return $( shuffled );
};
} )( jQuery );
jQuery( function ( $ ) {
$( '.jetpack-quiz' ).each( function () {
var quiz = $( this );
quiz.find( 'div.jetpack-quiz-answer' ).shuffleQuiz();
quiz.find( 'div[data-correct]' ).removeAttr( 'data-correct' ).data( 'correct', 1 );
quiz.find( 'div.jetpack-quiz-answer:last' ).addClass( 'last' );
} );
$( 'div.jetpack-quiz' ).on( 'click', 'div.jetpack-quiz-answer', function () {
var trackid,
answer = $( this ),
quiz = answer.closest( 'div.jetpack-quiz' );
if ( quiz.data( 'a8ctraining' ) ) {
new Image().src =
'//pixel.wp.com/b.gif?v=wpcom-no-pv&x_trainingchaos-' +
quiz.data( 'username' ) +
'=' +
quiz.data( 'a8ctraining' ) +
'&rand=' +
Math.random();
quiz.data( 'a8ctraining', false );
quiz.data( 'trackid', false );
}
trackid = quiz.data( 'trackid' );
if ( answer.data( 'correct' ) ) {
answer.addClass( 'correct' );
if ( trackid ) {
new Image().src =
'//pixel.wp.com/b.gif?v=wpcom-no-pv&x_quiz-' + trackid + '=correct&rand=' + Math.random();
}
} else {
answer.addClass( 'wrong' );
if ( trackid ) {
new Image().src =
'//pixel.wp.com/b.gif?v=wpcom-no-pv&x_quiz-' + trackid + '=wrong&rand=' + Math.random();
}
}
// only track the first answer
quiz.data( 'trackid', false );
} );
} );
document.querySelectorAll( '.jetpack-quiz-wrapper' ).forEach( function ( quiz ) {
quiz.childNodes.forEach( function ( element, number ) {
element.style.display = 'none';
element.setAttribute( 'quiz-number', number );
element.querySelector( '.jetpack-quiz-count' ).innerHTML =
number + 1 + '/' + quiz.childElementCount;
} );
quiz.childNodes[ 0 ].style.display = 'block';
} );
document.querySelectorAll( '.jetpack-quiz-option-button' ).forEach( function ( element ) {
element.addEventListener( 'click', function () {
var currentQuiz = element.parentElement.parentElement;
currentQuiz.style.display = 'none';
var switchNumber = element.getAttribute( 'data-quiz-option' ) === 'next' ? 1 : -1;
var newQuiz =
currentQuiz.parentElement.childNodes[
parseInt( currentQuiz.getAttribute( 'quiz-number' ) ) + switchNumber
];
newQuiz.style.display = 'block';
var newQuizQuestionEl = newQuiz.querySelector( '.jetpack-quiz-question' );
if ( newQuizQuestionEl ) {
newQuizQuestionEl.focus();
}
} );
} );
@@ -0,0 +1,14 @@
/* global jetpack_recipes_vars */
( function ( $ ) {
$( window ).load( function () {
$( '.jetpack-recipe-print a' ).click( function ( event ) {
event.preventDefault();
// Print the DIV.
$( this ).closest( '.jetpack-recipe' ).printThis( {
pageTitle: jetpack_recipes_vars.pageTitle,
loadCSS: jetpack_recipes_vars.loadCSS,
} );
} );
} );
} )( jQuery );
@@ -0,0 +1,214 @@
/* global jetpackSlideshowSettings */
function JetpackSlideshow( element, transition, autostart ) {
this.element = element;
this.images = [];
this.controls = {};
this.transition = transition || 'fade';
this.autostart = autostart;
}
JetpackSlideshow.prototype.showLoadingImage = function ( toggle ) {
if ( toggle ) {
this.loadingImage_ = document.createElement( 'div' );
this.loadingImage_.className = 'jetpack-slideshow-loading';
var img = document.createElement( 'img' );
img.src = jetpackSlideshowSettings.spinner;
this.loadingImage_.appendChild( img );
this.loadingImage_.appendChild( this.makeZeroWidthSpan() );
this.element.append( this.loadingImage_ );
} else if ( this.loadingImage_ ) {
this.loadingImage_.parentNode.removeChild( this.loadingImage_ );
this.loadingImage_ = null;
}
};
JetpackSlideshow.prototype.init = function () {
this.showLoadingImage( true );
var self = this;
// Set up DOM.
for ( var i = 0; i < this.images.length; i++ ) {
var imageInfo = this.images[ i ];
var img = document.createElement( 'img' );
img.src = imageInfo.src;
img.title = typeof imageInfo.title !== 'undefined' ? imageInfo.title : '';
img.alt = typeof imageInfo.alt !== 'undefined' ? imageInfo.alt : '';
img.setAttribute( 'itemprop', 'image' );
img.nopin = 'nopin';
var caption = document.createElement( 'div' );
caption.className = 'jetpack-slideshow-slide-caption';
caption.setAttribute( 'itemprop', 'caption description' );
caption.innerHTML = imageInfo.caption;
var container = document.createElement( 'div' );
container.className = 'jetpack-slideshow-slide';
container.setAttribute( 'itemprop', 'associatedMedia' );
container.setAttribute( 'itemscope', '' );
container.setAttribute( 'itemtype', 'https://schema.org/ImageObject' );
// Hide loading image once first image has loaded.
if ( i === 0 ) {
if ( img.complete ) {
// IE, image in cache
setTimeout( function () {
self.finishInit_();
}, 1 );
} else {
img.addEventListener( 'load', function () {
self.finishInit_();
} );
}
}
container.appendChild( img );
// I'm not sure where these were coming from, but IE adds
// bad values for width/height for portrait-mode images
img.removeAttribute( 'width' );
img.removeAttribute( 'height' );
container.appendChild( this.makeZeroWidthSpan() );
container.appendChild( caption );
this.element.append( container );
}
};
JetpackSlideshow.prototype.makeZeroWidthSpan = function () {
var emptySpan = document.createElement( 'span' );
emptySpan.className = 'jetpack-slideshow-line-height-hack';
// Having a NBSP makes IE act weird during transitions, but other
// browsers ignore a text node with a space in it as whitespace.
if ( -1 !== window.navigator.userAgent.indexOf( 'MSIE ' ) ) {
emptySpan.appendChild( document.createTextNode( ' ' ) );
} else {
emptySpan.innerHTML = '&nbsp;';
}
return emptySpan;
};
JetpackSlideshow.prototype.finishInit_ = function () {
this.showLoadingImage( false );
var self = this;
if ( this.images.length > 1 ) {
this.renderControls_();
// Initialize Cycle instance.
jQuery( this.element ).cycle( {
fx: this.transition,
prev: this.controls.prev,
next: this.controls.next,
timeout: jetpackSlideshowSettings.speed,
slideExpr: '.jetpack-slideshow-slide',
onPrevNextEvent: function () {
return self.onCyclePrevNextClick_.apply( self, arguments );
},
} );
var slideshow = this.element;
if ( ! this.autostart ) {
jQuery( slideshow ).cycle( 'pause' );
this.controls.stop.classList.remove( 'running' );
this.controls.stop.classList.add( 'paused' );
}
this.controls.stop.addEventListener( 'click', function ( event ) {
var button = event.currentTarget;
if ( button === event.target ) {
event.preventDefault();
if ( ! button.classList.contains( 'paused' ) ) {
jQuery( slideshow ).cycle( 'pause' );
button.classList.remove( 'running' );
button.classList.add( 'paused' );
} else {
button.classList.add( 'running' );
button.classList.remove( 'paused' );
jQuery( slideshow ).cycle( 'resume', true );
}
}
} );
} else if ( this.element.children.length ) {
this.element.children[ 0 ].style.display = 'block';
this.element.style.position = 'relative';
}
this.initialized_ = true;
};
JetpackSlideshow.prototype.renderControls_ = function () {
if ( this.controlsDiv_ ) {
return;
}
var controlsDiv = document.createElement( 'div' );
controlsDiv.className = 'jetpack-slideshow-controls';
var controls = [ 'prev', 'stop', 'next' ];
for ( var i = 0; i < controls.length; i++ ) {
var controlName = controls[ i ];
var label_name = 'label_' + controlName;
var a = document.createElement( 'a' );
a.href = '#';
a.className = 'button-' + controlName;
a.setAttribute( 'aria-label', jetpackSlideshowSettings[ label_name ] );
a.setAttribute( 'role', 'button' );
controlsDiv.appendChild( a );
this.controls[ controlName ] = a;
}
this.element.append( controlsDiv );
this.controlsDiv_ = controlsDiv;
};
JetpackSlideshow.prototype.onCyclePrevNextClick_ = function ( isNext, i /*, slideElement*/ ) {
// If blog_id not present don't track page views
if ( ! jetpackSlideshowSettings.blog_id ) {
return;
}
var postid = this.images[ i ].id;
var stats = new Image();
stats.src =
document.location.protocol +
'//pixel.wp.com/g.gif?host=' +
encodeURIComponent( document.location.host ) +
'&rand=' +
Math.random() +
'&blog=' +
jetpackSlideshowSettings.blog_id +
'&subd=' +
jetpackSlideshowSettings.blog_subdomain +
'&user_id=' +
jetpackSlideshowSettings.user_id +
'&post=' +
postid +
'&ref=' +
encodeURIComponent( document.location );
};
( function () {
function jetpack_slideshow_init() {
document.querySelectorAll( '.jetpack-slideshow-noscript' ).forEach( function ( element ) {
element.remove();
} );
document.querySelectorAll( '.jetpack-slideshow' ).forEach( function ( container ) {
if ( container.dataset.processed === 'true' ) {
return;
}
// Extract data attributes manually
var transition = container.dataset.trans;
var autostart = container.dataset.autostart === 'true';
var gallery = JSON.parse( container.dataset.gallery || '[]' );
var slideshow = new JetpackSlideshow( container, transition, autostart );
slideshow.images = gallery;
slideshow.init();
container.dataset.processed = 'true';
} );
}
document.addEventListener( 'DOMContentLoaded', jetpack_slideshow_init );
document.body.addEventListener( 'post-load', jetpack_slideshow_init );
} )();