Post locks: when a dialog is shown move focus to the text, see #23697

git-svn-id: https://develop.svn.wordpress.org/trunk@23733 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2013-03-16 20:46:37 +00:00
parent eff3a330f8
commit 66e4fa4d92
2 changed files with 10 additions and 8 deletions

View File

@ -1230,7 +1230,7 @@ function _admin_notice_post_locked() {
?>
<div class="post-locked-message">
<div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div>
<p><?php esc_html_e( sprintf( __( 'This content is currently locked. If you take over, %s will be blocked from continuing to edit.' ), $user->display_name ) ); ?></p>
<p class="currently-editing" tabindex="0"><?php esc_html_e( sprintf( __( 'This content is currently locked. If you take over, %s will be blocked from continuing to edit.' ), $user->display_name ) ); ?></p>
<p>
<a class="button" href="<?php echo esc_url( wp_get_referer() ); ?>"><?php _e('Go back'); ?></a>
<a class="button" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a>
@ -1251,7 +1251,7 @@ function _admin_notice_post_locked() {
?>
<div class="post-taken-over">
<div class="post-locked-avatar"></div>
<p class="currently-editing"></p>
<p class="currently-editing" tabindex="0"></p>
<p><a class="button button-primary" href="<?php echo esc_url( admin_url('edit.php') ); ?>"><?php _e('Go to All Posts'); ?></a></p>
</div>
<?php

View File

@ -265,6 +265,7 @@ $(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
data['wp-refresh-post-lock'] = send;
});
// Post locks: update the lock string or show the dialog if somebody has taken over editing
$(document).on( 'heartbeat-tick.refresh-lock', function( e, data ) {
var received, wrap, avatar;
@ -277,19 +278,17 @@ $(document).on( 'heartbeat-tick.refresh-lock', function( e, data ) {
if ( ! wrap.is(':visible') ) {
autosave();
wrap.find('p.currently-editing').text( received.lock_error.text );
if ( received.lock_error.avatar_src ) {
avatar = $('<img class="avatar avatar-64 photo" width="64" height="64" />').attr( 'src', received.lock_error.avatar_src.replace(/&amp;/g, '&') );
wrap.find('div.post-locked-avatar').empty().append( avatar );
}
wrap.show();
wrap.show().find('p.currently-editing').text( received.lock_error.text ).focus();
}
} else if ( received.new_lock ) {
$('#active_post_lock').val( received.new_lock );
}
if ( received['new_lock'] )
$('#active_post_lock').val( received['new_lock'].replace(/[^0-9:]+/, '') );
}
});
@ -300,6 +299,9 @@ jQuery(document).ready( function($) {
postboxes.add_postbox_toggles(pagenow);
// Post locks: if the Post Locked dialog is shown, focus it.
$('#notification-dialog:visible').find('p.currently-editing').focus();
// multi-taxonomies
if ( $('#tagsdiv-post_tag').length ) {
tagBox.init();