2013-11-14 23:42:09 -05:00
|
|
|
var addComment = {
|
2015-11-09 19:43:26 -05:00
|
|
|
moveForm: function( commId, parentId, respondId, postId ) {
|
2015-11-18 14:15:28 -05:00
|
|
|
var div, element, style, cssHidden,
|
2015-11-09 19:43:26 -05:00
|
|
|
t = this,
|
|
|
|
comm = t.I( commId ),
|
|
|
|
respond = t.I( respondId ),
|
|
|
|
cancel = t.I( 'cancel-comment-reply-link' ),
|
|
|
|
parent = t.I( 'comment_parent' ),
|
|
|
|
post = t.I( 'comment_post_ID' ),
|
|
|
|
commentForm = respond.getElementsByTagName( 'form' )[0];
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2015-11-09 19:43:26 -05:00
|
|
|
if ( ! comm || ! respond || ! cancel || ! parent || ! commentForm ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
return;
|
2015-11-09 19:43:26 -05:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
t.respondId = respondId;
|
|
|
|
postId = postId || false;
|
|
|
|
|
2015-11-09 19:43:26 -05:00
|
|
|
if ( ! t.I( 'wp-temp-form-div' ) ) {
|
|
|
|
div = document.createElement( 'div' );
|
2012-08-22 20:04:18 -04:00
|
|
|
div.id = 'wp-temp-form-div';
|
|
|
|
div.style.display = 'none';
|
2015-11-09 19:43:26 -05:00
|
|
|
respond.parentNode.insertBefore( div, respond );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2015-11-09 19:43:26 -05:00
|
|
|
comm.parentNode.insertBefore( respond, comm.nextSibling );
|
|
|
|
if ( post && postId ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
post.value = postId;
|
2015-11-09 19:43:26 -05:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
parent.value = parentId;
|
|
|
|
cancel.style.display = '';
|
|
|
|
|
|
|
|
cancel.onclick = function() {
|
2015-11-09 19:43:26 -05:00
|
|
|
var t = addComment,
|
|
|
|
temp = t.I( 'wp-temp-form-div' ),
|
|
|
|
respond = t.I( t.respondId );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2015-11-09 19:43:26 -05:00
|
|
|
if ( ! temp || ! respond ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
return;
|
2015-11-09 19:43:26 -05:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2015-11-09 19:43:26 -05:00
|
|
|
t.I( 'comment_parent' ).value = '0';
|
|
|
|
temp.parentNode.insertBefore( respond, temp );
|
|
|
|
temp.parentNode.removeChild( temp );
|
2012-08-22 20:04:18 -04:00
|
|
|
this.style.display = 'none';
|
|
|
|
this.onclick = null;
|
|
|
|
return false;
|
2013-11-14 23:42:09 -05:00
|
|
|
};
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2015-11-18 14:15:28 -05:00
|
|
|
/*
|
|
|
|
* Set initial focus to the first form focusable element.
|
|
|
|
* Try/catch used just to avoid errors in IE 7- which return visibility
|
|
|
|
* 'inherit' when the visibility value is inherited from an ancestor.
|
|
|
|
*/
|
2015-11-09 19:43:26 -05:00
|
|
|
try {
|
|
|
|
for ( var i = 0; i < commentForm.elements.length; i++ ) {
|
|
|
|
element = commentForm.elements[i];
|
2015-11-18 14:15:28 -05:00
|
|
|
cssHidden = false;
|
2015-11-09 19:43:26 -05:00
|
|
|
|
2015-11-18 14:15:28 -05:00
|
|
|
// Modern browsers.
|
2015-11-09 19:43:26 -05:00
|
|
|
if ( 'getComputedStyle' in window ) {
|
2015-11-18 14:15:28 -05:00
|
|
|
style = window.getComputedStyle( element );
|
|
|
|
// IE 8.
|
|
|
|
} else if ( document.documentElement.currentStyle ) {
|
|
|
|
style = element.currentStyle;
|
|
|
|
}
|
2015-11-09 19:43:26 -05:00
|
|
|
|
2015-11-18 14:15:28 -05:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
2015-11-09 19:43:26 -05:00
|
|
|
|
2015-11-18 14:15:28 -05:00
|
|
|
// Skip form elements that are hidden or disabled.
|
|
|
|
if ( 'hidden' === element.type || element.disabled || cssHidden ) {
|
|
|
|
continue;
|
2015-11-09 19:43:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
element.focus();
|
|
|
|
// Stop after the first focusable element.
|
|
|
|
break;
|
|
|
|
}
|
2015-11-18 14:15:28 -05:00
|
|
|
|
2015-11-09 19:43:26 -05:00
|
|
|
} catch( er ) {}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2015-11-09 19:43:26 -05:00
|
|
|
I: function( id ) {
|
|
|
|
return document.getElementById( id );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
2013-11-14 23:42:09 -05:00
|
|
|
};
|