2013-11-14 23:42:09 -05:00
|
|
|
var addComment = {
|
2015-11-09 19:43:26 -05:00
|
|
|
moveForm: function( commId, parentId, respondId, postId ) {
|
|
|
|
var div, element, node, style, cssHidden,
|
|
|
|
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-09 19:43:26 -05:00
|
|
|
// Set initial focus to the first form focusable element.
|
|
|
|
try {
|
|
|
|
for ( var i = 0; i < commentForm.elements.length; i++ ) {
|
|
|
|
element = commentForm.elements[i];
|
|
|
|
|
|
|
|
// Skip form elements that are hidden or disabled.
|
|
|
|
if ( 'hidden' === element.type || element.hasAttribute( 'disabled' ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( 'getComputedStyle' in window ) {
|
|
|
|
node = element;
|
|
|
|
cssHidden = false;
|
|
|
|
|
|
|
|
while( node.parentNode ) {
|
|
|
|
style = window.getComputedStyle( node );
|
|
|
|
|
|
|
|
if ( style.display === 'none' || style.visibility === 'hidden' ) {
|
|
|
|
cssHidden = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
node = node.parentNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( cssHidden ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
element.focus();
|
|
|
|
// Stop after the first focusable element.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} 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
|
|
|
};
|