Add upstream
This commit is contained in:
@@ -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 );
|
||||
27
wp-content/plugins/jetpack/modules/shortcodes/js/gist.js
Normal file
27
wp-content/plugins/jetpack/modules/shortcodes/js/gist.js
Normal file
@@ -0,0 +1,27 @@
|
||||
( function( $, undefined ) {
|
||||
var gistStylesheetLoaded = false,
|
||||
gistEmbed = function() {
|
||||
$( '.gist-oembed' ).each( function( i, el ) {
|
||||
var url = 'https://gist.github.com/' + $( el ).data( 'gist' );
|
||||
|
||||
$.ajax( {
|
||||
url: url,
|
||||
dataType: 'jsonp',
|
||||
} ).done( function( response ) {
|
||||
$( el ).replaceWith( response.div );
|
||||
|
||||
if ( ! gistStylesheetLoaded ) {
|
||||
var stylesheet =
|
||||
'<link rel="stylesheet" href="' + response.stylesheet + '" type="text/css" />';
|
||||
|
||||
$( 'head' ).append( stylesheet );
|
||||
|
||||
gistStylesheetLoaded = true;
|
||||
}
|
||||
} );
|
||||
} );
|
||||
};
|
||||
|
||||
$( document ).ready( gistEmbed );
|
||||
$( 'body' ).on( 'post-load', gistEmbed );
|
||||
} )( jQuery );
|
||||
@@ -0,0 +1,25 @@
|
||||
/* global window */
|
||||
|
||||
( function() {
|
||||
var instagramEmbed = function() {
|
||||
if (
|
||||
'undefined' !== typeof window.instgrm &&
|
||||
window.instgrm.Embeds &&
|
||||
'function' === typeof window.instgrm.Embeds.process
|
||||
) {
|
||||
window.instgrm.Embeds.process();
|
||||
} else {
|
||||
var s = document.createElement( 'script' );
|
||||
s.async = true;
|
||||
s.defer = true;
|
||||
s.src = '//platform.instagram.com/en_US/embeds.js';
|
||||
document.getElementsByTagName( 'body' )[ 0 ].appendChild( s );
|
||||
}
|
||||
};
|
||||
|
||||
if ( 'undefined' !== typeof jQuery && 'undefined' !== typeof infiniteScroll ) {
|
||||
jQuery( document.body ).on( 'post-load', instagramEmbed );
|
||||
}
|
||||
|
||||
instagramEmbed();
|
||||
} )();
|
||||
2897
wp-content/plugins/jetpack/modules/shortcodes/js/jmpress.js
Normal file
2897
wp-content/plugins/jetpack/modules/shortcodes/js/jmpress.js
Normal file
File diff suppressed because it is too large
Load Diff
9
wp-content/plugins/jetpack/modules/shortcodes/js/jquery.cycle.min.js
vendored
Normal file
9
wp-content/plugins/jetpack/modules/shortcodes/js/jquery.cycle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
258
wp-content/plugins/jetpack/modules/shortcodes/js/main.js
Normal file
258
wp-content/plugins/jetpack/modules/shortcodes/js/main.js
Normal file
@@ -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;
|
||||
},
|
||||
} );
|
||||
|
||||
$( document ).ready( function() {
|
||||
$( '.presentation-wrapper' ).map( function() {
|
||||
new Presentation( this );
|
||||
} );
|
||||
} );
|
||||
} )( jQuery );
|
||||
67
wp-content/plugins/jetpack/modules/shortcodes/js/quiz.js
Normal file
67
wp-content/plugins/jetpack/modules/shortcodes/js/quiz.js
Normal file
@@ -0,0 +1,67 @@
|
||||
( 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 );
|
||||
} );
|
||||
} );
|
||||
@@ -0,0 +1,294 @@
|
||||
// jshint ignore: start
|
||||
/*
|
||||
* printThis v1.9.0
|
||||
* @desc Printing plug-in for jQuery
|
||||
* @author Jason Day
|
||||
*
|
||||
* Resources (based on) :
|
||||
* jPrintArea: http://plugins.jquery.com/project/jPrintArea
|
||||
* jqPrint: https://github.com/permanenttourist/jquery.jqprint
|
||||
* Ben Nadal: http://www.bennadel.com/blog/1591-Ask-Ben-Print-Part-Of-A-Web-Page-With-jQuery.htm
|
||||
*
|
||||
* Licensed under the MIT licence:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* (c) Jason Day 2015
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* $("#mySelector").printThis({
|
||||
* debug: false, * show the iframe for debugging
|
||||
* importCSS: true, * import page CSS
|
||||
* importStyle: false, * import style tags
|
||||
* printContainer: true, * grab outer container as well as the contents of the selector
|
||||
* loadCSS: "path/to/my.css", * path to additional css file - us an array [] for multiple
|
||||
* pageTitle: "", * add title to print page
|
||||
* removeInline: false, * remove all inline styles from print elements
|
||||
* printDelay: 333, * variable print delay
|
||||
* header: null, * prefix to html
|
||||
* footer: null, * postfix to html
|
||||
* base: false, * preserve the BASE tag, or accept a string for the URL
|
||||
* formValues: true * preserve input/form values
|
||||
* canvas: false * copy canvas elements (experimental)
|
||||
* doctypeString: '...' * enter a different doctype for older markup
|
||||
* });
|
||||
*
|
||||
* Notes:
|
||||
* - the loadCSS will load additional css (with or without @media print) into the iframe, adjusting layout
|
||||
*
|
||||
* jshint onevar: false, smarttabs: true, devel: true
|
||||
*/
|
||||
( function( $ ) {
|
||||
var opt;
|
||||
$.fn.printThis = function( options ) {
|
||||
opt = $.extend( {}, $.fn.printThis.defaults, options );
|
||||
var $element = this instanceof jQuery ? this : $( this );
|
||||
|
||||
var strFrameName = 'printThis-' + new Date().getTime();
|
||||
|
||||
if ( window.location.hostname !== document.domain && navigator.userAgent.match( /msie/i ) ) {
|
||||
// Ugly IE hacks due to IE not inheriting document.domain from parent
|
||||
// checks if document.domain is set by comparing the host name against document.domain
|
||||
var iframeSrc =
|
||||
'javascript:document.write("<head><script>document.domain=\\"' +
|
||||
document.domain +
|
||||
'\\";</s' +
|
||||
'cript></head><body></body>")';
|
||||
var printI = document.createElement( 'iframe' );
|
||||
printI.name = 'printIframe';
|
||||
printI.id = strFrameName;
|
||||
printI.className = 'MSIE';
|
||||
document.body.appendChild( printI );
|
||||
printI.src = iframeSrc;
|
||||
} else {
|
||||
// other browsers inherit document.domain, and IE works if document.domain is not explicitly set
|
||||
var $frame = $( "<iframe id='" + strFrameName + "' name='printIframe' />" );
|
||||
$frame.appendTo( 'body' );
|
||||
}
|
||||
|
||||
var $iframe = $( '#' + strFrameName );
|
||||
|
||||
// show frame if in debug mode
|
||||
if ( ! opt.debug )
|
||||
$iframe.css( {
|
||||
position: 'absolute',
|
||||
width: '0px',
|
||||
height: '0px',
|
||||
left: '-600px',
|
||||
top: '-600px',
|
||||
} );
|
||||
|
||||
// $iframe.ready() and $iframe.load were inconsistent between browsers
|
||||
setTimeout( function() {
|
||||
// Add doctype to fix the style difference between printing and render
|
||||
function setDocType( $iframe, doctype ) {
|
||||
var win, doc;
|
||||
win = $iframe.get( 0 );
|
||||
win = win.contentWindow || win.contentDocument || win;
|
||||
doc = win.document || win.contentDocument || win;
|
||||
doc.open();
|
||||
doc.write( doctype );
|
||||
doc.close();
|
||||
}
|
||||
if ( opt.doctypeString ) {
|
||||
setDocType( $iframe, opt.doctypeString );
|
||||
}
|
||||
|
||||
var $doc = $iframe.contents(),
|
||||
$head = $doc.find( 'head' ),
|
||||
$body = $doc.find( 'body' ),
|
||||
$base = $( 'base' ),
|
||||
baseURL;
|
||||
|
||||
// add base tag to ensure elements use the parent domain
|
||||
if ( opt.base === true && $base.length > 0 ) {
|
||||
// take the base tag from the original page
|
||||
baseURL = $base.attr( 'href' );
|
||||
} else if ( typeof opt.base === 'string' ) {
|
||||
// An exact base string is provided
|
||||
baseURL = opt.base;
|
||||
} else {
|
||||
// Use the page URL as the base
|
||||
baseURL = document.location.protocol + '//' + document.location.host;
|
||||
}
|
||||
|
||||
$head.append( '<base href="' + baseURL + '">' );
|
||||
|
||||
// import page stylesheets
|
||||
if ( opt.importCSS )
|
||||
$( 'link[rel=stylesheet]' ).each( function() {
|
||||
var href = $( this ).attr( 'href' );
|
||||
if ( href ) {
|
||||
var media = $( this ).attr( 'media' ) || 'all';
|
||||
$head.append(
|
||||
"<link type='text/css' rel='stylesheet' href='" + href + "' media='" + media + "'>"
|
||||
);
|
||||
}
|
||||
} );
|
||||
|
||||
// import style tags
|
||||
if ( opt.importStyle )
|
||||
$( 'style' ).each( function() {
|
||||
$( this )
|
||||
.clone()
|
||||
.appendTo( $head );
|
||||
} );
|
||||
|
||||
// add title of the page
|
||||
if ( opt.pageTitle ) $head.append( '<title>' + opt.pageTitle + '</title>' );
|
||||
|
||||
// import additional stylesheet(s)
|
||||
if ( opt.loadCSS ) {
|
||||
if ( $.isArray( opt.loadCSS ) ) {
|
||||
jQuery.each( opt.loadCSS, function( index, value ) {
|
||||
$head.append( "<link type='text/css' rel='stylesheet' href='" + this + "'>" );
|
||||
} );
|
||||
} else {
|
||||
$head.append( "<link type='text/css' rel='stylesheet' href='" + opt.loadCSS + "'>" );
|
||||
}
|
||||
}
|
||||
|
||||
// print header
|
||||
if ( opt.header ) $body.append( opt.header );
|
||||
|
||||
if ( opt.canvas ) {
|
||||
// add canvas data-ids for easy access after the cloning.
|
||||
var canvasId = 0;
|
||||
$element.find( 'canvas' ).each( function() {
|
||||
$( this ).attr( 'data-printthis', canvasId++ );
|
||||
} );
|
||||
}
|
||||
|
||||
// grab $.selector as container
|
||||
if ( opt.printContainer ) $body.append( $element.outer() );
|
||||
// otherwise just print interior elements of container
|
||||
else
|
||||
$element.each( function() {
|
||||
$body.append( $( this ).html() );
|
||||
} );
|
||||
|
||||
if ( opt.canvas ) {
|
||||
// Re-draw new canvases by referencing the originals
|
||||
$body.find( 'canvas' ).each( function() {
|
||||
var cid = $( this ).data( 'printthis' ),
|
||||
$src = $( '[data-printthis="' + cid + '"]' );
|
||||
|
||||
this.getContext( '2d' ).drawImage( $src[ 0 ], 0, 0 );
|
||||
|
||||
// Remove the mark-up from the original
|
||||
$src.removeData( 'printthis' );
|
||||
} );
|
||||
}
|
||||
|
||||
// capture form/field values
|
||||
if ( opt.formValues ) {
|
||||
// loop through inputs
|
||||
var $input = $element.find( 'input' );
|
||||
if ( $input.length ) {
|
||||
$input.each( function() {
|
||||
var $this = $( this ),
|
||||
$name = $( this ).attr( 'name' ),
|
||||
$checker = $this.is( ':checkbox' ) || $this.is( ':radio' ),
|
||||
$iframeInput = $doc.find( 'input[name="' + $name + '"]' ),
|
||||
$value = $this.val();
|
||||
|
||||
// order matters here
|
||||
if ( ! $checker ) {
|
||||
$iframeInput.val( $value );
|
||||
} else if ( $this.is( ':checked' ) ) {
|
||||
if ( $this.is( ':checkbox' ) ) {
|
||||
$iframeInput.attr( 'checked', 'checked' );
|
||||
} else if ( $this.is( ':radio' ) ) {
|
||||
$doc
|
||||
.find( 'input[name="' + $name + '"][value="' + $value + '"]' )
|
||||
.attr( 'checked', 'checked' );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
// loop through selects
|
||||
var $select = $element.find( 'select' );
|
||||
if ( $select.length ) {
|
||||
$select.each( function() {
|
||||
var $this = $( this ),
|
||||
$name = $( this ).attr( 'name' ),
|
||||
$value = $this.val();
|
||||
$doc.find( 'select[name="' + $name + '"]' ).val( $value );
|
||||
} );
|
||||
}
|
||||
|
||||
// loop through textareas
|
||||
var $textarea = $element.find( 'textarea' );
|
||||
if ( $textarea.length ) {
|
||||
$textarea.each( function() {
|
||||
var $this = $( this ),
|
||||
$name = $( this ).attr( 'name' ),
|
||||
$value = $this.val();
|
||||
$doc.find( 'textarea[name="' + $name + '"]' ).val( $value );
|
||||
} );
|
||||
}
|
||||
} // end capture form/field values
|
||||
|
||||
// remove inline styles
|
||||
if ( opt.removeInline ) {
|
||||
// $.removeAttr available jQuery 1.7+
|
||||
if ( $.isFunction( $.removeAttr ) ) {
|
||||
$doc.find( 'body *' ).removeAttr( 'style' );
|
||||
} else {
|
||||
$doc.find( 'body *' ).attr( 'style', '' );
|
||||
}
|
||||
}
|
||||
|
||||
// print "footer"
|
||||
if ( opt.footer ) $body.append( opt.footer );
|
||||
|
||||
setTimeout( function() {
|
||||
if ( $iframe.hasClass( 'MSIE' ) ) {
|
||||
// check if the iframe was created with the ugly hack
|
||||
// and perform another ugly hack out of neccessity
|
||||
window.frames[ 'printIframe' ].focus();
|
||||
$head.append( '<script> window.print(); </s' + 'cript>' );
|
||||
} else {
|
||||
// proper method
|
||||
if ( document.queryCommandSupported( 'print' ) ) {
|
||||
$iframe[ 0 ].contentWindow.document.execCommand( 'print', false, null );
|
||||
} else {
|
||||
$iframe[ 0 ].contentWindow.focus();
|
||||
$iframe[ 0 ].contentWindow.print();
|
||||
}
|
||||
}
|
||||
|
||||
// remove iframe after print
|
||||
if ( ! opt.debug ) {
|
||||
setTimeout( function() {
|
||||
$iframe.remove();
|
||||
}, 1000 );
|
||||
}
|
||||
}, opt.printDelay );
|
||||
}, 333 );
|
||||
};
|
||||
|
||||
// defaults
|
||||
$.fn.printThis.defaults = {
|
||||
debug: false, // show the iframe for debugging
|
||||
importCSS: true, // import parent page css
|
||||
importStyle: false, // import style tags
|
||||
printContainer: true, // print outer container/$.selector
|
||||
loadCSS: '', // load an additional css file - load multiple stylesheets with an array []
|
||||
pageTitle: '', // add title to print page
|
||||
removeInline: false, // remove all inline styles
|
||||
printDelay: 333, // variable print delay
|
||||
header: null, // prefix to html
|
||||
footer: null, // postfix to html
|
||||
formValues: true, // preserve input/form values
|
||||
canvas: false, // Copy canvas content (experimental)
|
||||
base: false, // preserve the BASE tag, or accept a string for the URL
|
||||
doctypeString: '<!DOCTYPE html>', // html doctype
|
||||
};
|
||||
|
||||
// $.selector container
|
||||
jQuery.fn.outer = function() {
|
||||
return $( $( '<div></div>' ).html( this.clone() ) ).html();
|
||||
};
|
||||
} )( jQuery );
|
||||
16
wp-content/plugins/jetpack/modules/shortcodes/js/recipes.js
Normal file
16
wp-content/plugins/jetpack/modules/shortcodes/js/recipes.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/* 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,205 @@
|
||||
/* jshint onevar:false, loopfunc:true */
|
||||
/* global jetpackSlideshowSettings, escape */
|
||||
|
||||
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 = '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.align = 'middle';
|
||||
img.setAttribute( 'itemprop', 'image' );
|
||||
img.nopin = 'nopin';
|
||||
var caption = document.createElement( 'div' );
|
||||
caption.className = 'slideshow-slide-caption';
|
||||
caption.setAttribute( 'itemprop', 'caption description' );
|
||||
caption.innerHTML = imageInfo.caption;
|
||||
var container = document.createElement( 'div' );
|
||||
container.className = '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 {
|
||||
jQuery( img ).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 = '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 = ' ';
|
||||
}
|
||||
return emptySpan;
|
||||
};
|
||||
|
||||
JetpackSlideshow.prototype.finishInit_ = function() {
|
||||
this.showLoadingImage( false );
|
||||
this.renderControls_();
|
||||
|
||||
var self = this;
|
||||
if ( this.images.length > 1 ) {
|
||||
// Initialize Cycle instance.
|
||||
this.element.cycle( {
|
||||
fx: this.transition,
|
||||
prev: this.controls.prev,
|
||||
next: this.controls.next,
|
||||
timeout: jetpackSlideshowSettings.speed,
|
||||
slideExpr: '.slideshow-slide',
|
||||
onPrevNextEvent: function() {
|
||||
return self.onCyclePrevNextClick_.apply( self, arguments );
|
||||
},
|
||||
} );
|
||||
|
||||
var slideshow = this.element;
|
||||
|
||||
if ( ! this.autostart ) {
|
||||
slideshow.cycle( 'pause' );
|
||||
jQuery( this.controls.stop ).removeClass( 'running' );
|
||||
jQuery( this.controls.stop ).addClass( 'paused' );
|
||||
}
|
||||
|
||||
jQuery( this.controls.stop ).click( function() {
|
||||
var button = jQuery( this );
|
||||
if ( ! button.hasClass( 'paused' ) ) {
|
||||
slideshow.cycle( 'pause' );
|
||||
button.removeClass( 'running' );
|
||||
button.addClass( 'paused' );
|
||||
} else {
|
||||
button.addClass( 'running' );
|
||||
button.removeClass( 'paused' );
|
||||
slideshow.cycle( 'resume', true );
|
||||
}
|
||||
return false;
|
||||
} );
|
||||
} else {
|
||||
this.element.children( ':first' ).show();
|
||||
this.element.css( 'position', 'relative' );
|
||||
}
|
||||
this.initialized_ = true;
|
||||
};
|
||||
|
||||
JetpackSlideshow.prototype.renderControls_ = function() {
|
||||
if ( this.controlsDiv_ ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var controlsDiv = document.createElement( 'div' );
|
||||
controlsDiv.className = 'slideshow-controls';
|
||||
|
||||
var controls = [ 'prev', 'stop', 'next' ];
|
||||
for ( var i = 0; i < controls.length; i++ ) {
|
||||
var controlName = controls[ i ];
|
||||
var a = document.createElement( 'a' );
|
||||
a.href = '#';
|
||||
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=' +
|
||||
escape( document.location.host ) +
|
||||
'&rand=' +
|
||||
Math.random() +
|
||||
'&blog=' +
|
||||
jetpackSlideshowSettings.blog_id +
|
||||
'&subd=' +
|
||||
jetpackSlideshowSettings.blog_subdomain +
|
||||
'&user_id=' +
|
||||
jetpackSlideshowSettings.user_id +
|
||||
'&post=' +
|
||||
postid +
|
||||
'&ref=' +
|
||||
escape( document.location );
|
||||
};
|
||||
|
||||
( function( $ ) {
|
||||
function jetpack_slideshow_init() {
|
||||
$( '.jetpack-slideshow-noscript' ).remove();
|
||||
|
||||
$( '.jetpack-slideshow' ).each( function() {
|
||||
var container = $( this );
|
||||
|
||||
if ( container.data( 'processed' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var slideshow = new JetpackSlideshow(
|
||||
container,
|
||||
container.data( 'trans' ),
|
||||
container.data( 'autostart' )
|
||||
);
|
||||
slideshow.images = container.data( 'gallery' );
|
||||
slideshow.init();
|
||||
|
||||
container.data( 'processed', true );
|
||||
} );
|
||||
}
|
||||
|
||||
$( document ).ready( jetpack_slideshow_init );
|
||||
$( 'body' ).on( 'post-load', jetpack_slideshow_init );
|
||||
} )( jQuery );
|
||||
Reference in New Issue
Block a user