Ticket #29974: 29974.5.patch
File 29974.5.patch, 3.0 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 t = this, 4 div, 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 // Skip form elements with `hidden` type attribute and disabled ones. 54 // @todo Consider to skip also readonly elements and elements hidden with CSS? 55 if ( 'hidden' === commentForm.elements[i].type || true === commentForm.elements[i].disabled ) { 56 continue; 57 } 58 commentForm.elements[i].focus(); 59 respond.scrollIntoView(); 60 // Stop after the first focusable element. 61 break; 62 } 63 } catch( er ) {} 40 64 41 65 return false; 42 66 }, 43 67 44 I : function(e) {45 return document.getElementById( e);68 I: function( el ) { 69 return document.getElementById( el ); 46 70 } 47 71 };