/* Detect-zoom
* -----------
* Cross Browser Zoom and Pixel Ratio Detector
* Version 1.0.4 | Apr 1 2013
* dual-licensed under the WTFPL and MIT license
* Maintained by https://github/tombigel
* Original developer https://github.com/yonran
*/
//AMD and CommonJS initialization copied from https://github.com/zohararad/audio5js
(function (root, ns, factory) {
"use strict";
if (typeof (module) !== 'undefined' && module.exports) { // CommonJS
module.exports = factory(ns, root);
} else if (typeof (define) === 'function' && define.amd) { // AMD
define("factory", function () {
return factory(ns, root);
});
} else {
root[ns] = factory(ns, root);
}
}(window, 'detectZoom', function () {
/**
* Use devicePixelRatio if supported by the browser
* @return {Number}
* @private
*/
var devicePixelRatio = function () {
return window.devicePixelRatio || 1;
};
/**
* Fallback function to set default values
* @return {Object}
* @private
*/
var fallback = function () {
return {
zoom: 1,
devicePxPerCssPx: 1
};
};
/**
* IE 8 and 9: no trick needed!
* TODO: Test on IE10 and Windows 8 RT
* @return {Object}
* @private
**/
var ie8 = function () {
var zoom = Math.round((screen.deviceXDPI / screen.logicalXDPI) * 100) / 100;
return {
zoom: zoom,
devicePxPerCssPx: zoom * devicePixelRatio()
};
};
/**
* For IE10 we need to change our technique again...
* thanks https://github.com/stefanvanburen
* @return {Object}
* @private
*/
var ie10 = function () {
var zoom = Math.round((document.documentElement.offsetHeight / window.innerHeight) * 100) / 100;
return {
zoom: zoom,
devicePxPerCssPx: zoom * devicePixelRatio()
};
};
/**
* Mobile WebKit
* the trick: window.innerWIdth is in CSS pixels, while
* screen.width and screen.height are in system pixels.
* And there are no scrollbars to mess up the measurement.
* @return {Object}
* @private
*/
var webkitMobile = function () {
var deviceWidth = (Math.abs(window.orientation) == 90) ? screen.height : screen.width;
var zoom = deviceWidth / window.innerWidth;
return {
zoom: zoom,
devicePxPerCssPx: zoom * devicePixelRatio()
};
};
/**
* Desktop Webkit
* the trick: an element's clientHeight is in CSS pixels, while you can
* set its line-height in system pixels using font-size and
* -webkit-text-size-adjust:none.
* device-pixel-ratio: http://www.webkit.org/blog/55/high-dpi-web-sites/
*
* Previous trick (used before http://trac.webkit.org/changeset/100847):
* documentElement.scrollWidth is in CSS pixels, while
* document.width was in system pixels. Note that this is the
* layout width of the document, which is slightly different from viewport
* because document width does not include scrollbars and might be wider
* due to big elements.
* @return {Object}
* @private
*/
var webkit = function () {
var important = function (str) {
return str.replace(/;/g, " !important;");
};
var div = document.createElement('div');
div.innerHTML = "1
2
3
4
5
6
7
8
9
0";
div.setAttribute('style', important('font: 100px/1em sans-serif; -webkit-text-size-adjust: none; text-size-adjust: none; height: auto; width: 1em; padding: 0; overflow: visible;'));
// The container exists so that the div will be laid out in its own flow
// while not impacting the layout, viewport size, or display of the
// webpage as a whole.
// Add !important and relevant CSS rule resets
// so that other rules cannot affect the results.
var container = document.createElement('div');
container.setAttribute('style', important('width:0; height:0; overflow:hidden; visibility:hidden; position: absolute;'));
container.appendChild(div);
document.body.appendChild(container);
var zoom = 1000 / div.clientHeight;
zoom = Math.round(zoom * 100) / 100;
document.body.removeChild(container);
return{
zoom: zoom,
devicePxPerCssPx: zoom * devicePixelRatio()
};
};
/**
* no real trick; device-pixel-ratio is the ratio of device dpi / css dpi.
* (Note that this is a different interpretation than Webkit's device
* pixel ratio, which is the ratio device dpi / system dpi).
*
* Also, for Mozilla, there is no difference between the zoom factor and the device ratio.
*
* @return {Object}
* @private
*/
var firefox4 = function () {
var zoom = mediaQueryBinarySearch('min--moz-device-pixel-ratio', '', 0, 10, 20, 0.0001);
zoom = Math.round(zoom * 100) / 100;
return {
zoom: zoom,
devicePxPerCssPx: zoom
};
};
/**
* Firefox 18.x
* Mozilla added support for devicePixelRatio to Firefox 18,
* but it is affected by the zoom level, so, like in older
* Firefox we can't tell if we are in zoom mode or in a device
* with a different pixel ratio
* @return {Object}
* @private
*/
var firefox18 = function () {
return {
zoom: firefox4().zoom,
devicePxPerCssPx: devicePixelRatio()
};
};
/**
* works starting Opera 11.11
* the trick: outerWidth is the viewport width including scrollbars in
* system px, while innerWidth is the viewport width including scrollbars
* in CSS px
* @return {Object}
* @private
*/
var opera11 = function () {
var zoom = window.top.outerWidth / window.top.innerWidth;
zoom = Math.round(zoom * 100) / 100;
return {
zoom: zoom,
devicePxPerCssPx: zoom * devicePixelRatio()
};
};
/**
* Use a binary search through media queries to find zoom level in Firefox
* @param property
* @param unit
* @param a
* @param b
* @param maxIter
* @param epsilon
* @return {Number}
*/
var mediaQueryBinarySearch = function (property, unit, a, b, maxIter, epsilon) {
var matchMedia;
var head, style, div;
if (window.matchMedia) {
matchMedia = window.matchMedia;
} else {
head = document.getElementsByTagName('head')[0];
style = document.createElement('style');
head.appendChild(style);
div = document.createElement('div');
div.className = 'mediaQueryBinarySearch';
div.style.display = 'none';
document.body.appendChild(div);
matchMedia = function (query) {
style.sheet.insertRule('@media ' + query + '{.mediaQueryBinarySearch ' + '{text-decoration: underline} }', 0);
var matched = getComputedStyle(div, null).textDecoration == 'underline';
style.sheet.deleteRule(0);
return {matches: matched};
};
}
var ratio = binarySearch(a, b, maxIter);
if (div) {
head.removeChild(style);
document.body.removeChild(div);
}
return ratio;
function binarySearch(a, b, maxIter) {
var mid = (a + b) / 2;
if (maxIter <= 0 || b - a < epsilon) {
return mid;
}
var query = "(" + property + ":" + mid + unit + ")";
if (matchMedia(query).matches) {
return binarySearch(mid, b, maxIter - 1);
} else {
return binarySearch(a, mid, maxIter - 1);
}
}
};
/**
* Generate detection function
* @private
*/
var detectFunction = (function () {
var func = fallback;
//IE8+
if (!isNaN(screen.logicalXDPI) && !isNaN(screen.systemXDPI)) {
func = ie8;
}
// IE10+ / Touch
else if (window.navigator.msMaxTouchPoints) {
func = ie10;
}
//Mobile Webkit
else if ('orientation' in window && typeof document.body.style.webkitMarquee === 'string') {
func = webkitMobile;
}
//WebKit
else if (typeof document.body.style.webkitMarquee === 'string') {
func = webkit;
}
//Opera
else if (navigator.userAgent.indexOf('Opera') >= 0) {
func = opera11;
}
//Last one is Firefox
//FF 18.x
else if (window.devicePixelRatio) {
func = firefox18;
}
//FF 4.0 - 17.x
else if (firefox4().zoom > 0.001) {
func = firefox4;
}
return func;
}());
return ({
/**
* Ratios.zoom shorthand
* @return {Number} Zoom level
*/
zoom: function () {
return detectFunction().zoom;
},
/**
* Ratios.devicePxPerCssPx shorthand
* @return {Number} devicePxPerCssPx level
*/
device: function () {
return detectFunction().devicePxPerCssPx;
}
});
}));
var wpcom_img_zoomer = {
clientHintSupport: {
gravatar: false,
files: false,
photon: false,
mshots: false,
staticAssets: false,
latex: false,
imgpress: false,
},
useHints: false,
zoomed: false,
timer: null,
interval: 1000, // zoom polling interval in millisecond
// Should we apply width/height attributes to control the image size?
imgNeedsSizeAtts: function( img ) {
// Do not overwrite existing width/height attributes.
if ( img.getAttribute('width') !== null || img.getAttribute('height') !== null )
return false;
// Do not apply the attributes if the image is already constrained by a parent element.
if ( img.width < img.naturalWidth || img.height < img.naturalHeight )
return false;
return true;
},
hintsFor: function( service ) {
if ( this.useHints === false ) {
return false;
}
if ( this.hints() === false ) {
return false;
}
if ( typeof this.clientHintSupport[service] === "undefined" ) {
return false;
}
if ( this.clientHintSupport[service] === true ) {
return true;
}
return false;
},
hints: function() {
try {
var chrome = window.navigator.userAgent.match(/\sChrome\/([0-9]+)\.[.0-9]+\s/)
if (chrome !== null) {
var version = parseInt(chrome[1], 10)
if (isNaN(version) === false && version >= 46) {
return true
}
}
} catch (e) {
return false
}
return false
},
init: function() {
var t = this;
try{
t.zoomImages();
t.timer = setInterval( function() { t.zoomImages(); }, t.interval );
}
catch(e){
}
},
stop: function() {
if ( this.timer )
clearInterval( this.timer );
},
getScale: function() {
var scale = detectZoom.device();
// Round up to 1.5 or the next integer below the cap.
if ( scale <= 1.0 ) scale = 1.0;
else if ( scale <= 1.5 ) scale = 1.5;
else if ( scale <= 2.0 ) scale = 2.0;
else if ( scale <= 3.0 ) scale = 3.0;
else if ( scale <= 4.0 ) scale = 4.0;
else scale = 5.0;
return scale;
},
shouldZoom: function( scale ) {
var t = this;
// Do not operate on hidden frames.
if ( "innerWidth" in window && !window.innerWidth )
return false;
// Don't do anything until scale > 1
if ( scale == 1.0 && t.zoomed == false )
return false;
return true;
},
zoomImages: function() {
var t = this;
var scale = t.getScale();
if ( ! t.shouldZoom( scale ) ){
return;
}
t.zoomed = true;
// Loop through all the elements on the page.
var imgs = document.getElementsByTagName("img");
for ( var i = 0; i < imgs.length; i++ ) {
// Wait for original images to load
if ( "complete" in imgs[i] && ! imgs[i].complete )
continue;
// Skip images that have srcset attributes.
if ( imgs[i].hasAttribute('srcset') ) {
continue;
}
// Skip images that don't need processing.
var imgScale = imgs[i].getAttribute("scale");
if ( imgScale == scale || imgScale == "0" )
continue;
// Skip images that have already failed at this scale
var scaleFail = imgs[i].getAttribute("scale-fail");
if ( scaleFail && scaleFail <= scale )
continue;
// Skip images that have no dimensions yet.
if ( ! ( imgs[i].width && imgs[i].height ) )
continue;
// Skip images from Lazy Load plugins
if ( ! imgScale && imgs[i].getAttribute("data-lazy-src") && (imgs[i].getAttribute("data-lazy-src") !== imgs[i].getAttribute("src")))
continue;
if ( t.scaleImage( imgs[i], scale ) ) {
// Mark the img as having been processed at this scale.
imgs[i].setAttribute("scale", scale);
}
else {
// Set the flag to skip this image.
imgs[i].setAttribute("scale", "0");
}
}
},
scaleImage: function( img, scale ) {
var t = this;
var newSrc = img.src;
var isFiles = false;
var isLatex = false;
var isPhoton = false;
// Skip slideshow images
if ( img.parentNode.className.match(/slideshow-slide/) )
return false;
// Skip CoBlocks Lightbox images
if ( img.parentNode.className.match(/coblocks-lightbox__image/) )
return false;
// Scale gravatars that have ?s= or ?size=
if ( img.src.match( /^https?:\/\/([^\/]*\.)?gravatar\.com\/.+[?&](s|size)=/ ) ) {
if ( this.hintsFor( "gravatar" ) === true ) {
return false;
}
newSrc = img.src.replace( /([?&](s|size)=)(\d+)/, function( $0, $1, $2, $3 ) {
// Stash the original size
var originalAtt = "originals",
originalSize = img.getAttribute(originalAtt);
if ( originalSize === null ) {
originalSize = $3;
img.setAttribute(originalAtt, originalSize);
if ( t.imgNeedsSizeAtts( img ) ) {
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
}
}
// Get the width/height of the image in CSS pixels
var size = img.clientWidth;
// Convert CSS pixels to device pixels
var targetSize = Math.ceil(img.clientWidth * scale);
// Don't go smaller than the original size
targetSize = Math.max( targetSize, originalSize );
// Don't go larger than the service supports
targetSize = Math.min( targetSize, 512 );
return $1 + targetSize;
});
}
// Scale mshots that have width
else if ( img.src.match(/^https?:\/\/([^\/]+\.)*(wordpress|wp)\.com\/mshots\/.+[?&]w=\d+/) ) {
if ( this.hintsFor( "mshots" ) === true ) {
return false;
}
newSrc = img.src.replace( /([?&]w=)(\d+)/, function($0, $1, $2) {
// Stash the original size
var originalAtt = 'originalw', originalSize = img.getAttribute(originalAtt);
if ( originalSize === null ) {
originalSize = $2;
img.setAttribute(originalAtt, originalSize);
if ( t.imgNeedsSizeAtts( img ) ) {
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
}
}
// Get the width of the image in CSS pixels
var size = img.clientWidth;
// Convert CSS pixels to device pixels
var targetSize = Math.ceil(size * scale);
// Don't go smaller than the original size
targetSize = Math.max( targetSize, originalSize );
// Don't go bigger unless the current one is actually lacking
if ( scale > img.getAttribute("scale") && targetSize <= img.naturalWidth )
targetSize = $2;
if ( $2 != targetSize )
return $1 + targetSize;
return $0;
});
// Update height attribute to match width
newSrc = newSrc.replace( /([?&]h=)(\d+)/, function($0, $1, $2) {
if ( newSrc == img.src ) {
return $0;
}
// Stash the original size
var originalAtt = 'originalh', originalSize = img.getAttribute(originalAtt);
if ( originalSize === null ) {
originalSize = $2;
img.setAttribute(originalAtt, originalSize);
}
// Get the height of the image in CSS pixels
var size = img.clientHeight;
// Convert CSS pixels to device pixels
var targetSize = Math.ceil(size * scale);
// Don't go smaller than the original size
targetSize = Math.max( targetSize, originalSize );
// Don't go bigger unless the current one is actually lacking
if ( scale > img.getAttribute("scale") && targetSize <= img.naturalHeight )
targetSize = $2;
if ( $2 != targetSize )
return $1 + targetSize;
return $0;
});
}
// Scale simple imgpress queries (s0.wp.com) that only specify w/h/fit
else if ( img.src.match(/^https?:\/\/([^\/.]+\.)*(wp|wordpress)\.com\/imgpress\?(.+)/) ) {
if ( this.hintsFor( "imgpress" ) === true ) {
return false;
}
var imgpressSafeFunctions = ["zoom", "url", "h", "w", "fit", "filter", "brightness", "contrast", "colorize", "smooth", "unsharpmask"];
// Search the query string for unsupported functions.
var qs = RegExp.$3.split('&');
for ( var q in qs ) {
q = qs[q].split('=')[0];
if ( imgpressSafeFunctions.indexOf(q) == -1 ) {
return false;
}
}
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
// Compute new src
if ( scale == 1 )
newSrc = img.src.replace(/\?(zoom=[^&]+&)?/, '?');
else
newSrc = img.src.replace(/\?(zoom=[^&]+&)?/, '?zoom=' + scale + '&');
}
// Scale files.wordpress.com, LaTeX, or Photon images (i#.wp.com)
else if (
( isFiles = img.src.match(/^https?:\/\/([^\/]+)\.files\.wordpress\.com\/.+[?&][wh]=/) ) ||
( isLatex = img.src.match(/^https?:\/\/([^\/.]+\.)*(wp|wordpress)\.com\/latex\.php\?(latex|zoom)=(.+)/) ) ||
( isPhoton = img.src.match(/^https?:\/\/i[\d]{1}\.wp\.com\/(.+)/) )
) {
if ( false !== isFiles && this.hintsFor( "files" ) === true ) {
return false
}
if ( false !== isLatex && this.hintsFor( "latex" ) === true ) {
return false
}
if ( false !== isPhoton && this.hintsFor( "photon" ) === true ) {
return false
}
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
// Compute new src
if ( scale == 1 ) {
newSrc = img.src.replace(/\?(zoom=[^&]+&)?/, '?');
} else {
newSrc = img.src;
var url_var = newSrc.match( /([?&]w=)(\d+)/ );
if ( url_var !== null && url_var[2] ) {
newSrc = newSrc.replace( url_var[0], url_var[1] + img.width );
}
url_var = newSrc.match( /([?&]h=)(\d+)/ );
if ( url_var !== null && url_var[2] ) {
newSrc = newSrc.replace( url_var[0], url_var[1] + img.height );
}
var zoom_arg = '&zoom=2';
if ( !newSrc.match( /\?/ ) ) {
zoom_arg = '?zoom=2';
}
img.setAttribute( 'srcset', newSrc + zoom_arg + ' ' + scale + 'x' );
}
}
// Scale static assets that have a name matching *-1x.png or *@1x.png
else if ( img.src.match(/^https?:\/\/[^\/]+\/.*[-@]([12])x\.(gif|jpeg|jpg|png)(\?|$)/) ) {
if ( this.hintsFor( "staticAssets" ) === true ) {
return false;
}
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
var currentSize = RegExp.$1, newSize = currentSize;
if ( scale <= 1 )
newSize = 1;
else
newSize = 2;
if ( currentSize != newSize )
newSrc = img.src.replace(/([-@])[12]x\.(gif|jpeg|jpg|png)(\?|$)/, '$1'+newSize+'x.$2$3');
}
else {
return false;
}
// Don't set img.src unless it has changed. This avoids unnecessary reloads.
if ( newSrc != img.src ) {
// Store the original img.src
var prevSrc, origSrc = img.getAttribute("src-orig");
if ( !origSrc ) {
origSrc = img.src;
img.setAttribute("src-orig", origSrc);
}
// In case of error, revert img.src
prevSrc = img.src;
img.onerror = function(){
img.src = prevSrc;
if ( img.getAttribute("scale-fail") < scale )
img.setAttribute("scale-fail", scale);
img.onerror = null;
};
// Finally load the new image
img.src = newSrc;
}
return true;
}
};
wpcom_img_zoomer.init();
;
/**
* Comment Likes - JavaScript
*
* This handles liking and unliking comments, as well as viewing who has
* liked a particular comment.
*
* @dependency Swipe (dynamically loaded when needed)
*
* @package Comment_Likes
* @subpackage JavaScript
*/
(function () {
function init() {
let extWin;
let extWinCheck;
let commentLikeEvent;
// Only run once.
if (window.comment_likes_loaded) {
return;
}
window.comment_likes_loaded = true;
// Client-side cache of who liked a particular comment to avoid
// having to hit the server multiple times for the same data.
const commentLikeCache = {};
let swipeLibPromise;
// Load the Swipe library, if it's not already loaded.
function swipeLibLoader() {
if (!swipeLibPromise) {
swipeLibPromise = new Promise((resolve, reject) => {
if (window.Swipe) {
resolve(window.Swipe);
} else {
const swipeScript = document.createElement('script');
swipeScript.src = comment_like_text.swipeUrl;
swipeScript.async = true;
document.body.appendChild(swipeScript);
swipeScript.addEventListener('load', () => resolve(window.Swipe));
swipeScript.addEventListener('error', error => reject(error));
}
});
}
return swipeLibPromise;
}
/**
* Parse the comment ID from a comment like link.
*/
function getCommentId(link) {
const commentId =
link && link.getAttribute('href') && link.getAttribute('href').split('like_comment=');
return commentId[1].split('&_wpnonce=')[0];
}
/**
* Handle an ajax action on the comment like link.
*/
function handleLinkAction(link, action, commentId, callback) {
const nonce =
link && link.getAttribute('href') && link.getAttribute('href').split('_wpnonce=')[1];
fetch('/wp-admin/admin-ajax.php', {
method: 'POST',
body: new URLSearchParams({
action: action,
_wpnonce: nonce,
like_comment: commentId,
blog_id: Number(link.dataset.blog),
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With': 'XMLHttpRequest',
Accept: 'application/json',
'cache-control': 'no-cache',
pragma: 'no-cache',
},
})
.then(response => response.json())
.then(callback);
}
function startPolling() {
// Append cookie polling login iframe to this window to wait for user to finish logging in (or cancel)
const loginIframe = document.createElement('iframe');
loginIframe.id = 'wp-login-polling-iframe';
loginIframe.src = 'https://wordpress.com/public.api/connect/?iframe=true';
document.body.appendChild(loginIframe);
loginIframe.style.display = 'none';
}
function stopPolling() {
const iframe = document.querySelector('#wp-login-polling-iframe');
if (iframe) {
iframe.remove();
}
}
function hide(el) {
if (el && el.style) {
el.style.display = 'none';
}
}
function show(el) {
if (el && el.style) {
el.style.removeProperty('display');
}
}
// Overlay used for displaying comment like info.
class Overlay {
constructor() {
// Overlay element.
this.el = document.createElement('div');
this.el.classList.add('comment-likes-overlay');
document.body.appendChild(this.el);
hide(this.el);
this.el.addEventListener('mouseenter', () => {
// Don't hide the overlay if the user is mousing over it.
overlay.cancelHide();
});
this.el.addEventListener('mouseleave', () => overlay.requestHide());
// Inner contents of overlay.
this.innerEl = null;
// Instance of the Swipe library.
this.swipe = null;
// Timeout used for hiding the overlay.
this.hideTimeout = null;
}
// Initialise the overlay for use, removing any old content.
clear() {
// Unload any previous instance of Swipe (to avoid leaking a global
// event handler). This is done before clearing the contents of the
// overlay because Swipe expects the slides to still be present.
if (this.swipe) {
this.swipe.kill();
this.swipe = null;
}
this.el.innerHTML = '';
this.innerEl = document.createElement('div');
this.innerEl.classList.add('inner');
this.el.appendChild(this.innerEl);
}
/**
* Construct a list (
) of user (gravatar, name) details.
*
* @param data liker data returned from the server
* @param klass CSS class to apply to the element
* @param start index of user to start at
* @param length number of users to include in the list
*
* @return A container element with the list
*/
getUserBits(data, klass, start, length) {
start = start || 0;
let last = start + (length || data.length);
last = last > data.length ? data.length : last;
const container = document.createElement('div');
container.classList.add('liker-list');
let html = `';
container.innerHTML = html;
return container;
}
/**
* Render the display of who has liked this comment. The type of
* display depends on how many people have liked the comment.
* If more than 10 people have liked the comment, this function
* renders navigation controls and sets up the Swipe library for
* changing between pages.
*
* @param link the element over which the user is hovering
* @param data the results retrieved from the server
*/
showLikes(link, data) {
this.clear();
link.dataset.likeCount = data.length;
if (data.length === 0) {
// No likers after all.
hide(this.el);
return;
}
this.innerEl.style.padding = '12px';
if (data.length < 6) {
// Only one column needed.
this.innerEl.style.maxWidth = '200px';
this.innerEl.innerHTML = '';
this.innerEl.appendChild(this.getUserBits(data, 'single'));
this.setPosition(link);
} else if (data.length < 11) {
// Two columns, but only one page.
this.innerEl.innerHTML = '';
this.innerEl.appendChild(this.getUserBits(data, 'double'));
this.setPosition(link);
} else {
// Multiple pages.
this.renderLikesWithPagination(data, link);
}
}
/**
* Render multiple pages of likes with pagination controls.
* This function is intended to be called by `showLikes` above.
*
* @param data the results retrieved from the server
*/
renderLikesWithPagination(data, link) {
swipeLibLoader().then(() => {
const page_count = Math.ceil(data.length / 10);
// Swipe requires two nested containers.
const swipe = document.createElement('div');
swipe.classList.add('swipe');
this.innerEl.appendChild(swipe);
const wrap = document.createElement('div');
wrap.classList.add('swipe-wrap');
swipe.appendChild(wrap);
for (let i = 0; i < page_count; ++i) {
wrap.appendChild(this.getUserBits(data, 'double', i * 10, 10));
}
/**
* Navigation controls.
* This is based on the Newdash controls found in
* reader/recommendations-templates.php
*/
const nav = document.createElement('nav');
nav.classList.add('slider-nav');
let navContents = `
`;
for (let i = 0; i < page_count; ++i) {
navContents += `•`;
}
navContents += `
`;
this.innerEl.appendChild(nav);
nav.innerHTML = navContents;
/** Set up Swipe. **/
// Swipe cannot be set up successfully unless its container
// is visible, so we show it now.
show(this.el);
this.setPosition(link);
this.swipe = new Swipe(swipe, {
callback: function (pos) {
// Update the pagination indicators.
//
// If there are exactly two pages, Swipe has a weird
// special case where it duplicates both pages and
// can return index 2 and 3 even though those aren't
// real pages (see swipe.js, line 47). To deal with
// this, we use the expression `pos % page_count`.
pos = pos % page_count;
nav.querySelectorAll('em').forEach(em => {
const page = Number(em.dataset.page);
em.setAttribute('class', pos === page ? 'on' : '');
});
},
});
nav.querySelectorAll('em').forEach(em => {
em.addEventListener('click', e => {
// Go to the page corresponding to the indicator clicked.
this.swipe.slide(Number(em.dataset.page));
e.preventDefault();
});
});
// Previous and next buttons.
nav.querySelector('.prev').addEventListener('click', e => {
this.swipe.prev();
e.preventDefault();
});
nav.querySelector('.next').addEventListener('click', e => {
this.swipe.next();
e.preventDefault();
});
});
}
/**
* Open the overlay and show a loading message.
*/
showLoadingMessage(link) {
this.clear();
this.innerEl.textContent = comment_like_text.loading;
this.setPosition(link);
}
/**
* Position the overlay near the current comment.
*
* @param link element near which to position the overlay
*/
setPosition(link) {
// Prepare a down arrow icon for the bottom of the overlay.
const icon = document.createElement('span');
this.el.appendChild(icon);
icon.classList.add('icon', 'noticon', 'noticon-downarrow');
icon.style.textShadow = '0px 1px 1px rgb(223, 223, 223)';
const rect = link.getBoundingClientRect();
const win = document.defaultView;
const offset = {
top: rect.top + win.scrollY,
left: rect.left + win.scrollX,
};
// Take measurements with the element fully visible.
show(this.el);
let left = offset.left - (this.el.offsetWidth - link.offsetWidth) / 2;
left = left < 5 ? 5 : left;
let top = offset.top - this.el.offsetHeight + 5;
hide(this.el);
const adminBar = document.querySelector('#wpadminbar');
// Check if the overlay would appear off the screen.
if (top < win.scrollY + ((adminBar && adminBar.offsetHeight) || 0)) {
// We'll display the overlay beneath the link instead.
top = offset.top + link.offsetHeight;
// Instead of using the down arrow icon, use an up arrow.
icon.remove();
this.el.prepend(icon);
icon.classList.remove('noticon-downarrow');
icon.classList.add('noticon-uparrow');
icon.style.textShadow = '0px -1px 1px rgb(223, 223, 223)';
icon.style.verticalAlign = 'bottom';
}
this.el.style.left = `${left}px`;
this.el.style.top = `${top}px`;
show(this.el);
// The height of the arrow icon differs slightly between browsers,
// so we compute the margin here to make sure it isn't disjointed
// from the overlay.
icon.style.marginTop = `${icon.scrollHeight - 26}px`;
icon.style.marginBottom = `${20 - icon.scrollHeight}px`;
// Position the arrow to be horizontally centred on the link.
icon.style.paddingLeft = `${
offset.left - left + (link.offsetWidth - icon.scrollWidth) / 2
}px`;
}
/**
* Return whether the overlay is visible.
*/
isVisible() {
return this.el.style.getPropertyValue('display') !== 'none';
}
/**
* Request that the overlay be hidden after a short delay.
*/
requestHide() {
if (this.hideTimeout !== null) {
return;
}
this.hideTimeout = setTimeout(() => {
hide(this.el);
this.clear();
}, 300);
}
/**
* Cancel a request to hide the overlay.
*/
cancelHide() {
if (this.hideTimeout !== null) {
clearTimeout(this.hideTimeout);
this.hideTimeout = null;
}
}
}
// Overlay used for displaying comment like info.
const overlay = new Overlay();
// The most recent comment for which the user has requested to see
// who liked it.
var relevantComment;
// Precache after this timeout.
var precacheTimeout = null;
/**
* Fetch the like data for a particular comment.
*/
function fetchLikeData(link, commentId) {
commentLikeCache[commentId] = null;
const container = link && link.parentElement && link.parentElement.parentElement;
const star = container.querySelector('a.comment-like-link');
star &&
handleLinkAction(star, 'view_comment_likes', commentId, data => {
// Populate the cache.
commentLikeCache[commentId] = data;
// Only show the overlay if the user is interested.
if (overlay.isVisible() && relevantComment === commentId) {
overlay.showLikes(link, data);
}
});
}
function readCookie(c) {
const nameEQ = c + '=';
const cookieStrings = document.cookie.split(';');
for (let i = 0; i < cookieStrings.length; i++) {
let cookieString = cookieStrings[i];
while (cookieString.charAt(0) === ' ') {
cookieString = cookieString.substring(1, cookieString.length);
}
if (cookieString.indexOf(nameEQ) === 0) {
const chunk = cookieString.substring(nameEQ.length, cookieString.length);
const pairs = chunk.split('&');
const cookieData = {};
for (let num = pairs.length - 1; num >= 0; num--) {
const pair = pairs[num].split('=');
cookieData[pair[0]] = decodeURIComponent(pair[1]);
}
return cookieData;
}
}
return null;
}
function getServiceData() {
const data = readCookie('wpc_wpc');
if (data === null || typeof data.access_token === 'undefined' || !data.access_token) {
return false;
}
return data;
}
function readMessage(msg) {
const event = msg.data;
if (typeof event.event === 'undefined') {
return;
}
if (event.event === 'login' && event.success) {
extWinCheck = setInterval(function () {
if (!extWin || extWin.closed) {
clearInterval(extWinCheck);
if (getServiceData()) {
// Load page in an iframe to get the current comment nonce
const nonceIframe = document.createElement('iframe');
nonceIframe.id = 'wp-login-comment-nonce-iframe';
nonceIframe.style.display = 'none';
nonceIframe.src = commentLikeEvent + '';
document.body.appendChild(nonceIframe);
const commentLikeId = (commentLikeEvent + '')
.split('like_comment=')[1]
.split('&_wpnonce=')[0];
let c;
// Set a 5 second timeout to redirect to the comment page without doing the Like as a fallback
const commentLikeTimeout = setTimeout(() => {
window.location = commentLikeEvent;
}, 5000);
// Check for a new nonced redirect and use that if available before timing out
const commentLikeCheck = setInterval(() => {
const iframe = document.querySelector('#wp-login-comment-nonce-iframe');
if (iframe) {
c = iframe.querySelector(`#comment-like-${commentLikeId} .comment-like-link`);
}
if (c && typeof c.href !== 'undefined') {
clearTimeout(commentLikeTimeout);
clearInterval(commentLikeCheck);
window.location = c.href;
}
}, 100);
}
}
}, 100);
if (extWin) {
if (!extWin.closed) {
extWin.close();
}
extWin = false;
}
stopPolling();
}
}
if (typeof window.postMessage !== 'undefined') {
window.addEventListener('message', e => {
let message = e && e.data;
if (typeof message === 'string') {
try {
message = JSON.parse(message);
} catch (err) {
return;
}
}
const type = message && message.type;
if (type === 'loginMessage') {
readMessage(message);
}
});
}
document.body.addEventListener('click', e => {
let target = e.target;
// Don't do anything when clicking on the "X people" link.
if (target.matches('p.comment-likes a.view-likers')) {
e.preventDefault();
return;
}
// Retrieve the surrounding paragraph to the star, if it hasn't been liked.
const notLikedPar = target.closest('p.comment-not-liked');
// Return if not clicking on star or surrounding paragraph.
if (!target.matches('a.comment-like-link') && !notLikedPar) {
return;
}
// When a comment hasn't been liked, make the text clickable, too.
if (notLikedPar) {
target = notLikedPar.querySelector('a.comment-like-link');
if (!target) {
return;
}
}
if (target.classList.contains('needs-login')) {
e.preventDefault();
commentLikeEvent = target;
if (extWin) {
if (!extWin.closed) {
extWin.close();
}
extWin = false;
}
stopPolling();
const url = 'https://wordpress.com/public.api/connect/?action=request&service=wordpress';
extWin = window.open(
url,
'likeconn',
'status=0,toolbar=0,location=1,menubar=0,directories=0,resizable=1,scrollbars=1,height=560,width=500'
);
startPolling();
return false;
}
// Record that the user likes or does not like this comment.
const commentId = getCommentId(target);
target.classList.add('loading');
let commentEl = document.querySelector(`p#comment-like-${commentId}`);
// Determine whether to like or unlike based on whether the comment is
// currently liked.
const action =
commentEl && commentEl.dataset.liked === 'comment-liked'
? 'unlike_comment'
: 'like_comment';
handleLinkAction(target, action, commentId, data => {
// Invalidate the like cache for this comment.
delete commentLikeCache[commentId];
const countEl = document.querySelector(`#comment-like-count-${data.context}`);
if (countEl) {
countEl.innerHTML = data.display;
}
commentEl = document.querySelector(`p#comment-like-${data.context}`);
if (action === 'like_comment') {
commentEl.classList.remove('comment-not-liked');
commentEl.classList.add('comment-liked');
commentEl.dataset.liked = 'comment-liked';
} else {
commentEl.classList.remove('comment-liked');
commentEl.classList.add('comment-not-liked');
commentEl.dataset.liked = 'comment-not-liked';
}
// Prefetch new data for this comment (if there are likers left).
const parent = target.closest('.comment-likes');
const link = parent && parent.querySelector('a.view-likers');
if (link) {
fetchLikeData(link, commentId);
}
target.classList.remove('loading');
});
e.preventDefault();
e.stopPropagation();
});
document.body.addEventListener(
'mouseenter',
function (e) {
if (!e.target.matches('p.comment-likes a.view-likers')) {
return;
}
// Show the user a list of who has liked this comment.
const link = e.target;
if (Number(link.dataset.likeCount || 0) === 0) {
// No one has liked this comment.
return;
}
// Don't hide the overlay.
overlay.cancelHide();
// Get the comment ID.
const container = link.parentElement && link.parentElement.parentElement;
const star = container && container.querySelector('a.comment-like-link');
const commentId = star && getCommentId(star);
relevantComment = commentId;
// Check if the list of likes for this comment is already in
// the cache.
if (commentId in commentLikeCache) {
const entry = commentLikeCache[commentId];
// Only display the likes if the ajax request is
// actually done.
if (entry !== null) {
overlay.showLikes(link, entry);
} else {
// Make sure the overlay is visible (in case
// the user moved the mouse away while loading
// but then came back before it finished
// loading).
overlay.showLoadingMessage(link);
}
return;
}
// Position the "Loading..." overlay.
overlay.showLoadingMessage(link);
// Fetch the data.
fetchLikeData(link, commentId);
},
true
);
document.body.addEventListener(
'mouseleave',
e => {
if (!e.target.matches('p.comment-likes a.view-likers')) {
return;
}
// User has moved cursor away - hide the overlay.
overlay.requestHide();
},
true
);
document.body.addEventListener(
'mouseenter',
e => {
if (!e.target.matches('.comment') || !e.target.querySelector('a.comment-like-link')) {
return;
}
// User is moving over a comment - precache the comment like data.
if (precacheTimeout !== null) {
clearTimeout(precacheTimeout);
precacheTimeout = null;
}
const star = e.target.querySelector('a.comment-like-link');
const parent = star.closest('.comment-likes');
const link = parent && parent.querySelector('a.view-likers');
if (!link || Number(link.dataset.likeCount || 0) === 0) {
// No likes.
return;
}
const commentId = getCommentId(star);
if (commentId in commentLikeCache) {
// Already in cache.
return;
}
precacheTimeout = setTimeout(() => {
precacheTimeout = null;
if (commentId in commentLikeCache) {
// Was cached in the interim.
return;
}
fetchLikeData(link, commentId);
}, 1000);
},
true
);
}
if (document.readyState !== 'loading') {
init();
} else {
document.addEventListener('DOMContentLoaded', init);
}
})();
;
/**
* File primary-navigation.js.
*
* This files only gets added to themes that support the mobile nav on side
*/
( function() {
/**
* Menu Toggle Behaviors
*
* @param {Element} element
*/
var navMenu = function ( buttonId, inputId ) {
var wrapper = document.body;
var toggleButton = document.getElementById( buttonId );
var toggleInput = document.getElementById( inputId );
if ( toggleButton ) {
toggleButton.onclick = function() {
if ( true == toggleInput.checked ) {
wrapper.classList.remove( 'lock-scrolling' );
} else {
wrapper.classList.add( 'lock-scrolling' );
}
toggleButton.focus();
}
}
document.addEventListener( 'click', function( event ) {
// If target onclick is with # within the href attribute
if ( event.target.hash && event.target.hash.includes( '#' ) ) {
wrapper.classList.remove( 'lock-scrolling' );
if (toggleInput) {
toggleInput.checked = false;
}
// Wait 550 and scroll to the anchor.
setTimeout(function () {
var anchor = document.getElementById(event.target.hash.slice(1));
anchor.scrollIntoView();
}, 550);
}
} );
}
window.addEventListener( 'load', function() {
navMenu( 'toggle-menu', 'toggle' );
navMenu( 'toggle-cart', 'woocommerce-toggle' );
} );
} )();;
!function(){"use strict";var e,t,n={998:function(e,t,n){n.d(t,{B$:function(){return f},Qf:function(){return r},Uq:function(){return u},a3:function(){return l},d6:function(){return c},hA:function(){return a},j4:function(){return s},pM:function(){return o},zq:function(){return i}});var o={NOTICE:"notice",SETTINGS:"settings",HIDDEN:""},r={PURPOSE:"purpose",VENDOR:"vendor"},i=258,l={1:!0,2:!0,3:!0,4:!0,7:!0,9:!0,10:!0},a={2:!0,3:!0,4:!0,7:!0,9:!0,10:!0},c={UI_SHOWN:"cmpuishown",LOADED:"tcloaded",USER_ACTION_COMPLETE:"useractioncomplete"},u={VISIBLE:"visible",HIDDEN:"hidden",DISABLED:"disabled"},s={STUB:"stub",LOADED:"loaded",ERROR:"error"},f="euconsent-v2"},748:function(e,t,n){n.d(t,{n4:function(){return S},Vo:function(){return O}});var o,r,i=n(400),l=[],a=i.YM.__b,c=i.YM.__r,u=i.YM.diffed,s=i.YM.__c,f=i.YM.unmount;function _(){for(var e;e=l.shift();)if(e.__P)try{e.__H.__h.forEach(p),e.__H.__h.forEach(h),e.__H.__h=[]}catch(t){e.__H.__h=[],i.YM.__e(t,e.__v)}}i.YM.__b=function(e){o=null,a&&a(e)},i.YM.__r=function(e){c&&c(e),0;var t=(o=e.__c).__H;t&&(t.__h.forEach(p),t.__h.forEach(h),t.__h=[])},i.YM.diffed=function(e){u&&u(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==l.push(t)&&r===i.YM.requestAnimationFrame||((r=i.YM.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(o),d&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,100);d&&(t=requestAnimationFrame(n))})(_)),o=null},i.YM.__c=function(e,t){t.some((function(e){try{e.__h.forEach(p),e.__h=e.__h.filter((function(e){return!e.__||h(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],i.YM.__e(n,e.__v)}})),s&&s(e,t)},i.YM.unmount=function(e){f&&f(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{p(e)}catch(e){t=e}})),t&&i.YM.__e(t,n.__v))};var d="function"==typeof requestAnimationFrame;function p(e){var t=o,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),o=t}function h(e){var t=o;e.__c=e.__(),o=t}function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var o in t)if("__source"!==o&&e[o]!==t[o])return!0;return!1}function m(e){this.props=e}(m.prototype=new i.wA).isPureReactComponent=!0,m.prototype.shouldComponentUpdate=function(e,t){return y(this.props,e)||y(this.state,t)};var b=i.YM.__b;i.YM.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),b&&b(e)};"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var g=function(e,t){return null==e?null:(0,i.bR)((0,i.bR)(e).map(t))},k=(i.bR,i.YM.__e);i.YM.__e=function(e,t,n,o){if(e.then)for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t);k(e,t,n,o)};var w=i.YM.unmount;function S(){this.__u=0,this.t=null,this.__b=null}function C(e){var t=e.__.__c;return t&&t.__e&&t.__e(e)}function O(e){var t,n,o;function r(r){if(t||(t=e()).then((function(e){n=e.default||e}),(function(e){o=e})),o)throw o;if(!n)throw t;return(0,i.az)(n,r)}return r.displayName="Lazy",r.__f=!0,r}function A(){this.u=null,this.o=null}i.YM.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&!0===e.__h&&(e.type=null),w&&w(e)},(S.prototype=new i.wA).__c=function(e,t){var n=t.__c,o=this;null==o.t&&(o.t=[]),o.t.push(n);var r=C(o.__v),i=!1,l=function(){i||(i=!0,n.__R=null,r?r(a):a())};n.__R=l;var a=function(){if(!--o.__u){if(o.state.__e){var e=o.state.__e;o.__v.__k[0]=function e(t,n,o){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map((function(t){return e(t,n,o)})),t.__c&&t.__c.__P===n&&(t.__e&&o.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=o)),t}(e,e.__c.__P,e.__c.__O)}var t;for(o.setState({__e:o.__b=null});t=o.t.pop();)t.forceUpdate()}},c=!0===t.__h;o.__u++||c||o.setState({__e:o.__b=o.__v.__k[0]}),e.then(l,l)},S.prototype.componentWillUnmount=function(){this.t=[]},S.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=function e(t,n,o){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach((function(e){"function"==typeof e.__c&&e.__c()})),t.__c.__H=null),null!=(t=v({},t)).__c&&(t.__c.__P===o&&(t.__c.__P=n),t.__c=null),t.__k=t.__k&&t.__k.map((function(t){return e(t,n,o)}))),t}(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__e&&(0,i.az)(i.HY,null,e.fallback);return r&&(r.__h=null),[(0,i.az)(i.HY,null,t.__e?null:e.children),r]};var P=function(e,t,n){if(++n[1]===n[0]&&e.o.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.o.size))for(n=e.u;n;){for(;n.length>3;)n.pop()();if(n[1]2&&(a.children=arguments.length>3?o.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(l in e.defaultProps)void 0===a[l]&&(a[l]=e.defaultProps[l]);return v(e,a,r,i,null)}function v(e,t,n,o,l){var a={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==l?++i:l};return null==l&&null!=r.vnode&&r.vnode(a),a}function y(){return{current:null}}function m(e){return e.children}function b(e,t){this.props=e,this.context=t}function g(e,t){if(null==t)return e.__?g(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t0?v(h.type,h.props,h.key,null,h.__v):h)){if(h.__=n,h.__b=n.__b+1,null===(p=w[_])||p&&h.key==p.key&&h.type===p.type)w[_]=void 0;else for(d=0;d2&&(a.children=arguments.length>3?o.call(arguments,2):n),v(e.type,a,r||e.key,i||e.ref,null)}function R(e,t){var n={__c:t="__cC"+u++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var n,o;return this.getChildContext||(n=[],(o={})[t]=this,this.getChildContext=function(){return o},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&n.some(w)},this.sub=function(e){n.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n.splice(n.indexOf(e),1),t&&t.call(e)}}),e.children}};return n.Provider.__=n.Consumer.contextType=n}o=f.slice,r={__e:function(e,t,n,o){for(var r,i,l;t=t.__;)if((r=t.__c)&&!r.__)try{if((i=r.constructor)&&null!=i.getDerivedStateFromError&&(r.setState(i.getDerivedStateFromError(e)),l=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,o||{}),l=r.__d),l)return r.__E=r}catch(t){e=t}throw e}},i=0,b.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=d({},this.state),"function"==typeof e&&(e=e(d({},n),this.props)),e&&d(n,e),null!=e&&this.__v&&(t&&this.__h.push(t),w(this))},b.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),w(this))},b.prototype.render=m,l=[],a="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,S.__r=0,u=0}},o={};function r(e){var t=o[e];if(void 0!==t)return t.exports;var i=o[e]={id:e,exports:{}};return n[e](i,i.exports,r),i.exports}r.m=n,r.amdO={},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.f={},r.e=function(e){return Promise.all(Object.keys(r.f).reduce((function(t,n){return r.f[n](e,t),t}),[]))},r.u=function(e){return{143:"app",571:"settings",664:"notice"}[e]+".bundle.js?id="+{143:"432ca0b0e43c55bb1713",571:"2a75c4392d80f27a77ce",664:"580b1f18df005471bb6a"}[e]},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e={},t="a8c-cmp:",r.l=function(n,o,i,l){if(e[n])e[n].push(o);else{var a,c;if(void 0!==i)for(var u=document.getElementsByTagName("script"),s=0;se.length)&&(t=e.length);for(var n=0,o=new Array(t);n1&&void 0!==arguments[1]&&arguments[1],i=(0,t.Vo)((function(){return r.e(143).then(r.bind(r,972))}));(0,e.sY)((0,e.h)(t.n4,null,(0,e.h)(i,{model:this.model,acceptAll:this.acceptAllHandler,rejectAll:this.rejectAllHandler,save:this.saveHandler,fetchGlobalVendorList:this.fetchGlobalVendorListHandler,path:this.config.modulePath,_:this.config._,mode:n,noticeAsModal:this.config.noticeAsModal,closable:o,closed:this.closeHandler})),this.getAppContainer())}},{key:"showUi",value:function(){this.displayStatus!==A.Uq.VISIBLE&&(this.renderApp(A.pM.SETTINGS,!0),this.bumpStat("wordads_cmp_view","cookie"),this.eventStatus=A.d6.UI_SHOWN,this.displayStatus=A.Uq.VISIBLE,this.notify())}},{key:"bumpStat",value:function(e,t){var n={};n["x_"+e]=t,window._stq=window._stq||[],window._stq.push(["extra",n])}},{key:"setConsentCookie",value:function(e){var t;if(!this.config.skipConsentSave){var n=new XMLHttpRequest;n.open("POST","/wp-admin/admin-ajax.php",!0),n.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),(e=null!==(t=e)&&void 0!==t?t:{}).action="gdpr_set_consent",e.security=this.config.ajaxNonce,e.consent=C.serialize(this.model);var o=Object.keys(e).map((function(t){return t+"="+encodeURIComponent(e[t])})).join("&");n.send(o)}}},{key:"fetchGlobalVendorListHandler",value:function(){var e=this,t=new XMLHttpRequest;return new Promise((function(n,o){t.onreadystatechange=function(){4===t.readyState&&(200===this.status?n(JSON.parse(this.response)):o({status:t.status,statusText:t.statusText}))},t.open("GET",e.config.gvlPath,!0),t.send()}))}},{key:"acceptAllHandler",value:function(){this.model.vendorListVersion=this.config.gvlVersion,this.model.created=E.getUTCDay(new Date),this.model.lastUpdated=this.model.created,this.model.purpose={consents:A.a3,legitimateInterests:A.hA},this.model.vendor={consents:this.config.vendorsAll,legitimateInterests:this.config.vendorsLegInterest},this.model.nonIABVendor={consents:this.config.nonIABVendorsAll||{}},this.eventStatus=A.d6.USER_ACTION_COMPLETE,this.displayStatus=A.Uq.HIDDEN,this.notify(),this.setConsentCookie({type:"accept_all"})}},{key:"rejectAllHandler",value:function(){this.model.vendorListVersion=this.config.gvlVersion,this.model.created=E.getUTCDay(new Date),this.model.lastUpdated=this.model.created,this.model.purpose={consents:{},legitimateInterests:A.hA},this.model.vendor={consents:{},legitimateInterests:this.config.vendorsLegInterest},this.model.nonIABVendor={consents:{}},this.eventStatus=A.d6.USER_ACTION_COMPLETE,this.displayStatus=A.Uq.HIDDEN,this.notify(),this.setConsentCookie({type:"reject_all"})}},{key:"saveHandler",value:function(e){this.model=e,this.model.vendorListVersion=this.config.gvlVersion,this.model.created=E.getUTCDay(new Date),this.model.lastUpdated=this.model.created,this.eventStatus=A.d6.USER_ACTION_COMPLETE,this.displayStatus=A.Uq.HIDDEN,this.notify(),this.setConsentCookie({type:"custom"})}},{key:"closeHandler",value:function(){this.displayStatus=A.Uq.HIDDEN}},{key:"getTCData",value:function(){return{tcString:C.serialize(this.model),tcfPolicyVersion:this.model.tcfPolicyVersion,cmpId:this.model.cmpId,cmpVersion:this.model.cmpVersion,gdprApplies:!0,eventStatus:this.eventStatus,cmpStatus:this.cmpStatus,isServiceSpecific:this.model.isServiceSpecific,useNonStandardStacks:this.model.useNonStandardStacks,publisherCC:this.model.publisherCC,purposeOneTreatment:this.model.purposeOneTreatment,purpose:this.model.purpose,vendor:this.model.vendor,specialFeatureOptIns:this.model.specialFeatureOptIns}}},{key:"getNonIABVendorConsents",value:function(){return{gdprApplies:!0,nonIabVendorConsents:this.model.nonIABVendor.consents}}},{key:"notify",value:function(){var e=this.getTCData();this.listeners.forEach((function(t){e.listenerId=t.listenerId,t.callback(e,!0)}))}},{key:"addListener",value:function(e){var t=Math.floor(999999*Math.random()),n={listenerId:t,callback:e};return this.listeners.push(n),t}},{key:"removeListener",value:function(e){this.listeners=this.listeners.filter((function(t){return t.listenerId!==e}))}},{key:"commandHandler",value:function(){var e=arguments.length<=0?void 0:arguments[0],t=arguments.length<=2?void 0:arguments[2],n=arguments.length<=3?void 0:arguments[3];if("ping"===e){var o={gdprApplies:!0,cmpLoaded:!0,cmpStatus:this.cmpStatus,displayStatus:this.displayStatus,apiVersion:"2",cmpVersion:this.model.cmpVersion,cmpId:this.model.cmpId,gvlVersion:this.model.vendorListVersion,tcfPolicyVersion:this.model.tcfPolicyVersion};"function"==typeof t&&t(o,!0)}else if("addEventListener"===e){var r=this.addListener(t);t(M(M({},this.getTCData()),{},{listenerId:r}),!0)}else"removeEventListener"===e?(this.removeListener(n),t(!0)):"getTCData"===e?"function"==typeof t&&t(this.getTCData(),!0):"getNonIABVendorConsents"===e?"function"==typeof t&&t(this.getNonIABVendorConsents(),!0):"showUi"!==e&&"displayConsentUi"!==e||this.showUi()}}],l&&D(i.prototype,l),a&&D(i,a),Object.defineProperty(i,"prototype",{writable:!1}),n}();new V}()}();;
!function(){"use strict";var e,t={noop:function(){},texturize:function(e){return(e=(e=(e=(e+="").replace(/'/g,"’").replace(/'/g,"’")).replace(/"/g,"”").replace(/"/g,"”").replace(/"/g,"”").replace(/[\u201D]/g,"”")).replace(/([\w]+)=[\d]+;(.+?)[\d]+;/g,'$1="$2"')).trim()},applyReplacements:function(e,t){if(e)return t?e.replace(/{(\d+)}/g,(function(e,r){return void 0!==t[r]?t[r]:e})):e},getBackgroundImage:function(e){var t=document.createElement("canvas"),r=t.getContext&&t.getContext("2d");if(e){r.filter="blur(20px) ",r.drawImage(e,0,0);var o=t.toDataURL("image/png");return t=null,o}}},r=function(){function e(e,t){return Element.prototype.matches?e.matches(t):Element.prototype.msMatchesSelector?e.msMatchesSelector(t):void 0}function r(e,t,r,o){if(!e)return o();e.style.removeProperty("display"),e.style.opacity=t,e.style.transition="opacity 0.2s",e.style.pointerEvents="none";var a=function(t){t.target===e&&"opacity"===t.propertyName&&(e.style.removeProperty("transition"),e.style.removeProperty("opacity"),e.style.removeProperty("pointer-events"),e.removeEventListener("transitionend",a),e.removeEventListener("transitioncancel",a),o())};requestAnimationFrame((function(){requestAnimationFrame((function(){e.addEventListener("transitionend",a),e.addEventListener("transitioncancel",a),e.style.opacity=r}))}))}return{closest:function(t,r){if(t.closest)return t.closest(r);var o=t;do{if(e(o,r))return o;o=o.parentElement||o.parentNode}while(null!==o&&1===o.nodeType);return null},matches:e,hide:function(e){e&&(e.style.display="none")},show:function(e){e&&(e.style.display="block")},fadeIn:function(e,o){r(e,"0","1",o=o||t.noop)},fadeOut:function(e,o){o=o||t.noop,r(e,"1","0",(function(){e&&(e.style.display="none"),o()}))},scrollToElement:function(e,t,r){if(!e||!t)return r?r():void 0;var o=t.querySelector(".jp-carousel-info-extra");o&&(o.style.minHeight=window.innerHeight-64+"px");var a=!0,i=Date.now(),n=t.scrollTop,l=Math.max(0,e.offsetTop-Math.max(0,window.innerHeight-function(e){var t=e.querySelector(".jp-carousel-info-footer"),r=e.querySelector(".jp-carousel-info-extra"),o=e.querySelector(".jp-carousel-info-content-wrapper");if(t&&r&&o){var a=window.getComputedStyle(r),i=parseInt(a.paddingTop,10)+parseInt(a.paddingBottom,10);return i=isNaN(i)?0:i,o.offsetHeight+t.offsetHeight+i}return 0}(t)))-t.scrollTop;function s(){a=!1}l=Math.min(l,t.scrollHeight-window.innerHeight),t.addEventListener("wheel",s),function e(){var c,u=Date.now(),d=(c=(u-i)/300)<.5?2*c*c:1-Math.pow(-2*c+2,2)/2,p=(d=d>1?1:d)*l;if(t.scrollTop=n+p,u<=i+300&&a)return requestAnimationFrame(e);r&&r(),o&&(o.style.minHeight=""),a=!1,t.removeEventListener("wheel",s)}()},getJSONAttribute:function(e,t){if(e&&e.hasAttribute(t))try{return JSON.parse(e.getAttribute(t))}catch(e){return}},convertToPlainText:function(e){var t=document.createElement("div");return t.textContent=e,t.innerHTML},stripHTML:function(e){return e.replace(/<[^>]*>?/gm,"")},emitEvent:function(e,t,r){var o;try{o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r||null})}catch(e){(o=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,r||null)}e.dispatchEvent(o)},isTouch:function(){return"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch}}}();function o(){var o,a,i,n,l="",s=!1,c="div.gallery, div.tiled-gallery, ul.wp-block-gallery, ul.blocks-gallery-grid, figure.wp-block-gallery.has-nested-images, div.wp-block-jetpack-tiled-gallery, a.single-image-gallery",u=".gallery-item, .tiled-gallery-item, .blocks-gallery-item, .tiled-gallery__item",d=u+", .wp-block-image",p={},m="undefined"!=typeof wpcom&&wpcom.carousel&&wpcom.carousel.stat?wpcom.carousel.stat:t.noop,g="undefined"!=typeof wpcom&&wpcom.carousel&&wpcom.carousel.pageview?wpcom.carousel.pageview:t.noop;function h(t){if(!s)switch(t.which){case 38:t.preventDefault(),p.overlay.scrollTop-=100;break;case 40:t.preventDefault(),p.overlay.scrollTop+=100;break;case 39:t.preventDefault(),e.slideNext();break;case 37:case 8:t.preventDefault(),e.slidePrev();break;case 27:t.preventDefault(),b()}}function f(){s=!0}function v(){s=!1}function y(){p.overlay||(p.overlay=document.querySelector(".jp-carousel-overlay"),p.container=p.overlay.querySelector(".jp-carousel-wrap"),p.gallery=p.container.querySelector(".jp-carousel"),p.info=p.overlay.querySelector(".jp-carousel-info"),p.caption=p.info.querySelector(".jp-carousel-caption"),p.commentField=p.overlay.querySelector("#jp-carousel-comment-form-comment-field"),p.emailField=p.overlay.querySelector("#jp-carousel-comment-form-email-field"),p.authorField=p.overlay.querySelector("#jp-carousel-comment-form-author-field"),p.urlField=p.overlay.querySelector("#jp-carousel-comment-form-url-field"),window.innerWidth<=760&&Math.round(window.innerWidth/760*110)<40&&r.isTouch(),[p.commentField,p.emailField,p.authorField,p.urlField].forEach((function(e){e&&(e.addEventListener("focus",f),e.addEventListener("blur",v))})),p.overlay.addEventListener("click",(function(e){var t,o,a=e.target,i=!!r.closest(a,".jp-carousel-close-hint"),n=!!window.matchMedia("(max-device-width: 760px)").matches;if(a===p.overlay){if(n)return;b()}else if(i)b();else if(a.classList.contains("jp-carousel-image-download"))m("download_original_click");else if(a.classList.contains("jp-carousel-comment-login"))t=p.currentSlide,o=t?t.attrs.attachmentId:"0",window.location.href=jetpackCarouselStrings.login_url+"%23jp-carousel-"+o;else if(r.closest(a,"#jp-carousel-comment-form-container"))!function(e){var t=e.target,o=r.getJSONAttribute(p.container,"data-carousel-extra")||{},a=p.currentSlide.attrs.attachmentId,i=document.querySelector("#jp-carousel-comment-form-submit-and-info-wrapper"),n=document.querySelector("#jp-carousel-comment-form-spinner"),l=document.querySelector("#jp-carousel-comment-form-button-submit"),s=document.querySelector("#jp-carousel-comment-form");if(p.commentField&&p.commentField.getAttribute("id")===t.getAttribute("id"))f(),r.show(i);else if(r.matches(t,'input[type="submit"]')){e.preventDefault(),e.stopPropagation(),r.show(n),s.classList.add("jp-carousel-is-disabled");var c={action:"post_attachment_comment",nonce:jetpackCarouselStrings.nonce,blog_id:o.blog_id,id:a,comment:p.commentField.value};if(!c.comment.length)return void w(jetpackCarouselStrings.no_comment_text,!1);if(1!==Number(jetpackCarouselStrings.is_logged_in)&&(c.email=p.emailField.value,c.author=p.authorField.value,c.url=p.urlField.value,1===Number(jetpackCarouselStrings.require_name_email))){if(!c.email.length||!c.email.match("@"))return void w(jetpackCarouselStrings.no_comment_email,!1);if(!c.author.length)return void w(jetpackCarouselStrings.no_comment_author,!1)}var u=new XMLHttpRequest;u.open("POST",jetpackCarouselStrings.ajaxurl,!0),u.setRequestHeader("X-Requested-With","XMLHttpRequest"),u.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),u.onreadystatechange=function(){if(this.readyState===XMLHttpRequest.DONE&&this.status>=200&&this.status<300){var e;try{e=JSON.parse(this.response)}catch(e){return void w(jetpackCarouselStrings.comment_post_error,!1)}"approved"===e.comment_status?w(jetpackCarouselStrings.comment_approved,!0):"unapproved"===e.comment_status?w(jetpackCarouselStrings.comment_unapproved,!0):w(jetpackCarouselStrings.comment_post_error,!1),E(),q(a),l.value=jetpackCarouselStrings.post_comment,r.hide(n),s.classList.remove("jp-carousel-is-disabled")}else w(jetpackCarouselStrings.comment_post_error,!1)};var d=[];for(var m in c)if(m){var g=encodeURIComponent(m)+"="+encodeURIComponent(c[m]);d.push(g.replace(/%20/g,"+"))}var h=d.join("&");u.send(h)}}(e);else if(r.closest(a,".jp-carousel-photo-icons-container")||a.classList.contains("jp-carousel-photo-title"))!function(e){e.preventDefault();var t=e.target,o=p.info.querySelector(".jp-carousel-info-extra"),a=p.info.querySelector(".jp-carousel-image-meta"),i=p.info.querySelector(".jp-carousel-comments-wrapper"),n=p.info.querySelector(".jp-carousel-icon-info"),l=p.info.querySelector(".jp-carousel-icon-comments");function s(){l&&l.classList.remove("jp-carousel-selected"),n.classList.toggle("jp-carousel-selected"),i&&i.classList.remove("jp-carousel-show"),a&&(a.classList.toggle("jp-carousel-show"),a.classList.contains("jp-carousel-show")?o.classList.add("jp-carousel-show"):o.classList.remove("jp-carousel-show"))}function c(){n&&n.classList.remove("jp-carousel-selected"),l.classList.toggle("jp-carousel-selected"),a&&a.classList.remove("jp-carousel-show"),i&&(i.classList.toggle("jp-carousel-show"),i.classList.contains("jp-carousel-show")?o.classList.add("jp-carousel-show"):o.classList.remove("jp-carousel-show"))}(r.closest(t,".jp-carousel-icon-info")||t.classList.contains("jp-carousel-photo-title"))&&(a&&a.classList.contains("jp-carousel-show")?r.scrollToElement(p.overlay,p.overlay,s):(s(),r.scrollToElement(p.info,p.overlay))),r.closest(t,".jp-carousel-icon-comments")&&(i&&i.classList.contains("jp-carousel-show")?r.scrollToElement(p.overlay,p.overlay,c):(c(),r.scrollToElement(p.info,p.overlay)))}(e);else if(!r.closest(a,".jp-carousel-info"))return})),window.addEventListener("keydown",h),p.overlay.addEventListener("jp_carousel.afterOpen",(function(){v(),p.slides.length<=1||(p.slides.length<=5?r.show(p.info.querySelector(".jp-swiper-pagination")):r.show(p.info.querySelector(".jp-carousel-pagination")))})),p.overlay.addEventListener("jp_carousel.beforeClose",(function(){f(),document.documentElement.style.removeProperty("height"),e&&e.enable(),r.hide(p.info.querySelector(".jp-swiper-pagination")),r.hide(p.info.querySelector(".jp-carousel-pagination"))})),p.overlay.addEventListener("jp_carousel.afterClose",(function(){window.history.pushState?history.pushState("",document.title,window.location.pathname+window.location.search):window.location.href="",l="",p.isOpen=!1})),p.overlay.addEventListener("touchstart",(function(e){e.touches.length>1&&e.preventDefault()})))}function w(e,t){var o=p.overlay.querySelector("#jp-carousel-comment-post-results"),a="jp-carousel-comment-post-"+(t?"success":"error");o.innerHTML=''+e+"",r.hide(p.overlay.querySelector("#jp-carousel-comment-form-spinner")),p.overlay.querySelector("#jp-carousel-comment-form").classList.remove("jp-carousel-is-disabled"),r.show(o)}function j(){var e=document.querySelectorAll("a img[data-attachment-id]");Array.prototype.forEach.call(e,(function(e){var t=e.parentElement,o=t.parentElement;if(!o.classList.contains("gallery-icon")&&!r.closest(o,u)&&t.hasAttribute("href")){var a=!1;t.getAttribute("href").split("?")[0]===e.getAttribute("data-orig-file").split("?")[0]&&1===Number(jetpackCarouselStrings.single_image_gallery_media_file)&&(a=!0),t.getAttribute("href")===e.getAttribute("data-permalink")&&(a=!0),a&&(t.classList.add("single-image-gallery"),t.setAttribute("data-carousel-extra",JSON.stringify({blog_id:Number(jetpackCarouselStrings.blog_id)})))}}))}function S(o){(!o||o<0||o>p.slides.length)&&(o=0),p.currentSlide=p.slides[o];var a,i,n=p.currentSlide,s=n.attrs.attachmentId;!function(e){var t=e.el,r=e.attrs,o=t.querySelector("img");if(!o.hasAttribute("data-loaded")){var a=!!r.previewImage,i=r.thumbSize;!a||i&&t.offsetWidth>i.width?o.src=r.src:o.src=r.previewImage,o.setAttribute("itemprop","image"),o.setAttribute("data-loaded",1)}}(p.slides[o]),1!==Number(jetpackCarouselStrings.display_background_image)||p.slides[o].backgroundImage||function(t){var r=t.el;e&&e.slides&&(r=e.slides[e.activeIndex]);var o=t.attrs.originalElement;o.complete&&0!==o.naturalHeight?A(t,r,o):o.onload=function(){A(t,r,o)}}(p.slides[o]),r.hide(p.caption),function(e){var t,o,a,i,n="",l="",s="";if(t=p.overlay.querySelector(".jp-carousel-photo-caption"),o=p.overlay.querySelector(".jp-carousel-caption"),a=p.overlay.querySelector(".jp-carousel-photo-title"),i=p.overlay.querySelector(".jp-carousel-photo-description"),r.hide(t),r.hide(o),r.hide(a),r.hide(i),n=k(e.caption)||"",l=k(e.title)||"",s=k(e.desc)||"",(n||l||s)&&(n&&(t.innerHTML=n,o.innerHTML=n,r.show(t),r.show(o)),r.stripHTML(n)===r.stripHTML(l)&&(l=""),r.stripHTML(n)===r.stripHTML(s)&&(s=""),r.stripHTML(l)===r.stripHTML(s)&&(s=""),s&&(i.innerHTML=s,r.show(i),l||n||(t.innerHTML=r.stripHTML(s),r.show(t))),l)){var c=r.stripHTML(l);a.innerHTML=c,n||(t.innerHTML=c,o.innerHTML=c,r.show(t)),r.show(a)}}({caption:n.attrs.caption,title:n.attrs.title,desc:n.attrs.desc}),function(e){if(!e||1!==Number(jetpackCarouselStrings.display_exif))return!1;var t=p.info.querySelector(".jp-carousel-image-meta ul.jp-carousel-image-exif"),r="";for(var o in e){var a=e[o],i=jetpackCarouselStrings.meta_data||[];if(0!==parseFloat(a)&&a.length&&-1!==i.indexOf(o)){switch(o){case"focal_length":a+="mm";break;case"shutter_speed":a=x(a);break;case"aperture":a="f/"+a}r+=""+jetpackCarouselStrings[o]+"
"+a+" "}}t.innerHTML=r,t.style.removeProperty("display")}(p.slides[o].attrs.imageMeta),function(e){if(!e)return!1;var r,o=[e.attrs.origWidth,e.attrs.origHeight],a=document.createElement("a");a.href=e.attrs.src.replace(/\?.+$/,""),r=null!==a.hostname.match(/^i[\d]{1}\.wp\.com$/i)?a.href:e.attrs.origFile.replace(/\?.+$/,"");var i=p.info.querySelector(".jp-carousel-download-text"),n=p.info.querySelector(".jp-carousel-image-download");i.innerHTML=t.applyReplacements(jetpackCarouselStrings.download_original,o),n.setAttribute("href",r),n.style.removeProperty("display")}(n),1===Number(jetpackCarouselStrings.display_comments)&&(a=p.slides[o].attrs.commentsOpened,i=p.container.querySelector(".jp-carousel-comment-form-container"),1===parseInt(a,10)?r.fadeIn(i):r.fadeOut(i),q(s),r.hide(p.info.querySelector("#jp-carousel-comment-post-results")));var c=p.info.querySelector(".jp-carousel-pagination");if(c&&p.slides.length>5){var u=o+1;c.innerHTML=""+u+" / "+p.slides.length+""}jetpackCarouselStrings.stats&&((new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?"+jetpackCarouselStrings.stats+"&post="+encodeURIComponent(s)+"&rand="+Math.random()),g(s),window.location.hash=l="#jp-carousel-"+s}function b(){document.body.style.overflow=a,document.documentElement.style.overflow=i,E(),f(),r.emitEvent(p.overlay,"jp_carousel.beforeClose"),window.scrollTo(window.scrollX||window.pageXOffset||0,n||0),e.destroy(),p.isOpen=!1,p.slides=[],p.currentSlide=void 0,p.gallery.innerHTML="",r.fadeOut(p.overlay,(function(){r.emitEvent(p.overlay,"jp_carousel.afterClose")}))}function L(e,t,r){var o=r?e.replace(/.*=([\d]+%2C[\d]+).*$/,"$1"):e.replace(/.*-([\d]+x[\d]+)\..+$/,"$1"),a=o!==e?r?o.split("%2C"):o.split("x"):[t,0];return"9999"===a[0]&&(a[0]="0"),"9999"===a[1]&&(a[1]="0"),a}function x(e){return e>=1?Math.round(10*e)/10+"s":"1/"+Math.round(1/e)+"s"}function k(e){return!e.match(" ")&&e.match("_")?"":e}function q(e,t){var a=void 0===t,i=p.info.querySelector(".jp-carousel-icon-comments .jp-carousel-has-comments-indicator");if(i.classList.remove("jp-carousel-show"),clearInterval(o),e){(!t||t<1)&&(t=0);var n=p.info.querySelector(".jp-carousel-comments"),l=p.info.querySelector("#jp-carousel-comments-loading");r.show(l),a&&(r.hide(n),n.innerHTML="");var s=new XMLHttpRequest,c=jetpackCarouselStrings.ajaxurl+"?action=get_attachment_comments&nonce="+jetpackCarouselStrings.nonce+"&id="+e+"&offset="+t;s.open("GET",c),s.setRequestHeader("X-Requested-With","XMLHttpRequest");var u=function(){r.fadeIn(n),r.fadeOut(l)};s.onload=function(){if(p.currentSlide&&p.currentSlide.attrs.attachmentId===e){var c,d=s.status>=200&&s.status<300;try{c=JSON.parse(s.responseText)}catch(e){}if(!d||!c||!Array.isArray(c))return u();a&&(n.innerHTML="");for(var m=0;m