Comments: in `comment_form()` when replying to a comment ensure to set focus on the first focusable form element, regardless of what that form element is.
Props azaozz. See #29974. Built from https://develop.svn.wordpress.org/trunk@35593 git-svn-id: http://core.svn.wordpress.org/trunk@35557 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c98b62c452
commit
e6e4496822
|
@ -1,47 +1,92 @@
|
|||
var addComment = {
|
||||
moveForm : function(commId, parentId, respondId, postId) {
|
||||
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');
|
||||
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];
|
||||
|
||||
if ( ! comm || ! respond || ! cancel || ! parent )
|
||||
if ( ! comm || ! respond || ! cancel || ! parent || ! commentForm ) {
|
||||
return;
|
||||
}
|
||||
|
||||
t.respondId = respondId;
|
||||
postId = postId || false;
|
||||
|
||||
if ( ! t.I('wp-temp-form-div') ) {
|
||||
div = document.createElement('div');
|
||||
if ( ! t.I( 'wp-temp-form-div' ) ) {
|
||||
div = document.createElement( 'div' );
|
||||
div.id = 'wp-temp-form-div';
|
||||
div.style.display = 'none';
|
||||
respond.parentNode.insertBefore(div, respond);
|
||||
respond.parentNode.insertBefore( div, respond );
|
||||
}
|
||||
|
||||
comm.parentNode.insertBefore(respond, comm.nextSibling);
|
||||
if ( post && postId )
|
||||
comm.parentNode.insertBefore( respond, comm.nextSibling );
|
||||
if ( post && postId ) {
|
||||
post.value = postId;
|
||||
}
|
||||
parent.value = parentId;
|
||||
cancel.style.display = '';
|
||||
|
||||
cancel.onclick = function() {
|
||||
var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);
|
||||
var t = addComment,
|
||||
temp = t.I( 'wp-temp-form-div' ),
|
||||
respond = t.I( t.respondId );
|
||||
|
||||
if ( ! temp || ! respond )
|
||||
if ( ! temp || ! respond ) {
|
||||
return;
|
||||
}
|
||||
|
||||
t.I('comment_parent').value = '0';
|
||||
temp.parentNode.insertBefore(respond, temp);
|
||||
temp.parentNode.removeChild(temp);
|
||||
t.I( 'comment_parent' ).value = '0';
|
||||
temp.parentNode.insertBefore( respond, temp );
|
||||
temp.parentNode.removeChild( temp );
|
||||
this.style.display = 'none';
|
||||
this.onclick = null;
|
||||
return false;
|
||||
};
|
||||
|
||||
try { t.I('comment').focus(); }
|
||||
catch(e) {}
|
||||
// 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 ) {}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
I : function(e) {
|
||||
return document.getElementById(e);
|
||||
I: function( id ) {
|
||||
return document.getElementById( id );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1 +1 @@
|
|||
var addComment={moveForm:function(a,b,c,d){var e,f=this,g=f.I(a),h=f.I(c),i=f.I("cancel-comment-reply-link"),j=f.I("comment_parent"),k=f.I("comment_post_ID");if(g&&h&&i&&j){f.respondId=c,d=d||!1,f.I("wp-temp-form-div")||(e=document.createElement("div"),e.id="wp-temp-form-div",e.style.display="none",h.parentNode.insertBefore(e,h)),g.parentNode.insertBefore(h,g.nextSibling),k&&d&&(k.value=d),j.value=b,i.style.display="",i.onclick=function(){var a=addComment,b=a.I("wp-temp-form-div"),c=a.I(a.respondId);if(b&&c)return a.I("comment_parent").value="0",b.parentNode.insertBefore(c,b),b.parentNode.removeChild(b),this.style.display="none",this.onclick=null,!1};try{f.I("comment").focus()}catch(l){}return!1}},I:function(a){return document.getElementById(a)}};
|
||||
var addComment={moveForm:function(a,b,c,d){var e,f,g,h,i,j=this,k=j.I(a),l=j.I(c),m=j.I("cancel-comment-reply-link"),n=j.I("comment_parent"),o=j.I("comment_post_ID"),p=l.getElementsByTagName("form")[0];if(k&&l&&m&&n&&p){j.respondId=c,d=d||!1,j.I("wp-temp-form-div")||(e=document.createElement("div"),e.id="wp-temp-form-div",e.style.display="none",l.parentNode.insertBefore(e,l)),k.parentNode.insertBefore(l,k.nextSibling),o&&d&&(o.value=d),n.value=b,m.style.display="",m.onclick=function(){var a=addComment,b=a.I("wp-temp-form-div"),c=a.I(a.respondId);if(b&&c)return a.I("comment_parent").value="0",b.parentNode.insertBefore(c,b),b.parentNode.removeChild(b),this.style.display="none",this.onclick=null,!1};try{for(var q=0;q<p.elements.length;q++)if(f=p.elements[q],"hidden"!==f.type&&!f.hasAttribute("disabled")){if("getComputedStyle"in window){for(g=f,i=!1;g.parentNode;){if(h=window.getComputedStyle(g),"none"===h.display||"hidden"===h.visibility){i=!0;break}g=g.parentNode}if(i)continue}f.focus();break}}catch(r){}return!1}},I:function(a){return document.getElementById(a)}};
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-beta3-35592';
|
||||
$wp_version = '4.4-beta3-35593';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue