2 moveForm: function( commId, parentId, respondId, postId ) {
3 var div, element, style, cssHidden,
6 respond = t.I( respondId ),
7 cancel = t.I( 'cancel-comment-reply-link' ),
8 parent = t.I( 'comment_parent' ),
9 post = t.I( 'comment_post_ID' ),
10 commentForm = respond.getElementsByTagName( 'form' )[0];
12 if ( ! comm || ! respond || ! cancel || ! parent || ! commentForm ) {
16 t.respondId = respondId;
17 postId = postId || false;
19 if ( ! t.I( 'wp-temp-form-div' ) ) {
20 div = document.createElement( 'div' );
21 div.id = 'wp-temp-form-div';
22 div.style.display = 'none';
23 respond.parentNode.insertBefore( div, respond );
26 comm.parentNode.insertBefore( respond, comm.nextSibling );
27 if ( post && postId ) {
30 parent.value = parentId;
31 cancel.style.display = '';
33 cancel.onclick = function() {
35 temp = t.I( 'wp-temp-form-div' ),
36 respond = t.I( t.respondId );
38 if ( ! temp || ! respond ) {
42 t.I( 'comment_parent' ).value = '0';
43 temp.parentNode.insertBefore( respond, temp );
44 temp.parentNode.removeChild( temp );
45 this.style.display = 'none';
51 * Set initial focus to the first form focusable element.
52 * Try/catch used just to avoid errors in IE 7- which return visibility
53 * 'inherit' when the visibility value is inherited from an ancestor.
56 for ( var i = 0; i < commentForm.elements.length; i++ ) {
57 element = commentForm.elements[i];
61 if ( 'getComputedStyle' in window ) {
62 style = window.getComputedStyle( element );
64 } else if ( document.documentElement.currentStyle ) {
65 style = element.currentStyle;
69 * For display none, do the same thing jQuery does. For visibility,
70 * check the element computed style since browsers are already doing
71 * the job for us. In fact, the visibility computed style is the actual
72 * computed value and already takes into account the element ancestors.
74 if ( ( element.offsetWidth <= 0 && element.offsetHeight <= 0 ) || style.visibility === 'hidden' ) {
78 // Skip form elements that are hidden or disabled.
79 if ( 'hidden' === element.type || element.disabled || cssHidden ) {
84 // Stop after the first focusable element.
94 return document.getElementById( id );