Ticket #29974: 29974.6.patch
File 29974.6.patch, 3.4 KB (added by , 9 years ago) |
---|
-
src/wp-includes/js/comment-reply.js
1 1 var addComment = { 2 moveForm : function(commId, parentId, respondId, postId) { 3 var t = this, div, 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'); 2 moveForm: function( commId, parentId, respondId, postId ) { 3 var div, element, node, style, cssHidden, 4 t = this, 5 comm = t.I( commId ), 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]; 4 11 5 if ( ! comm || ! respond || ! cancel || ! parent )12 if ( ! comm || ! respond || ! cancel || ! parent || ! commentForm ) { 6 13 return; 14 } 7 15 8 16 t.respondId = respondId; 9 17 postId = postId || false; 10 18 11 if ( ! t.I( 'wp-temp-form-div') ) {12 div = document.createElement( 'div');19 if ( ! t.I( 'wp-temp-form-div' ) ) { 20 div = document.createElement( 'div' ); 13 21 div.id = 'wp-temp-form-div'; 14 22 div.style.display = 'none'; 15 respond.parentNode.insertBefore( div, respond);23 respond.parentNode.insertBefore( div, respond ); 16 24 } 17 25 18 comm.parentNode.insertBefore( respond, comm.nextSibling);19 if ( post && postId ) 26 comm.parentNode.insertBefore( respond, comm.nextSibling ); 27 if ( post && postId ) { 20 28 post.value = postId; 29 } 21 30 parent.value = parentId; 22 31 cancel.style.display = ''; 23 32 24 33 cancel.onclick = function() { 25 var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId); 34 var t = addComment, 35 temp = t.I( 'wp-temp-form-div' ), 36 respond = t.I( t.respondId ); 26 37 27 if ( ! temp || ! respond ) 38 if ( ! temp || ! respond ) { 28 39 return; 40 } 29 41 30 t.I( 'comment_parent').value = '0';31 temp.parentNode.insertBefore( respond, temp);32 temp.parentNode.removeChild( temp);42 t.I( 'comment_parent' ).value = '0'; 43 temp.parentNode.insertBefore( respond, temp ); 44 temp.parentNode.removeChild( temp ); 33 45 this.style.display = 'none'; 34 46 this.onclick = null; 35 47 return false; 36 48 }; 37 49 38 try { t.I('comment').focus(); } 39 catch(e) {} 50 // Set initial focus to the first form focusable element. 51 try { 52 for ( var i = 0; i < commentForm.elements.length; i++ ) { 53 element = commentForm.elements[i]; 40 54 55 // Skip form elements that are hidden, disabled, readonly. 56 if ( 'hidden' === element.type || element.hasAttribute( 'disabled' ) || element.hasAttribute( 'readonly' ) ) { 57 continue; 58 } 59 60 if ( 'getComputedStyle' in window ) { 61 node = element; 62 cssHidden = false; 63 64 while( node.parentNode ) { 65 style = window.getComputedStyle( node ); 66 67 if ( style.display === 'none' || style.visibility === 'hidden' ) { 68 cssHidden = true; 69 break; 70 } 71 72 node = node.parentNode; 73 } 74 75 if ( cssHidden ) { 76 continue; 77 } 78 } 79 80 element.focus(); 81 // Stop after the first focusable element. 82 break; 83 } 84 } catch( er ) {} 85 41 86 return false; 42 87 }, 43 88 44 I : function(e) {45 return document.getElementById( e);89 I: function( id ) { 90 return document.getElementById( id ); 46 91 } 47 92 };