Sample permalink: Improve accessibility of changing the permalink on Edit Post screen.

Props afercia.
Fixes #34255.
Built from https://develop.svn.wordpress.org/trunk@35229


git-svn-id: http://core.svn.wordpress.org/trunk@35195 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2015-10-16 23:02:25 +00:00
parent ac630ba233
commit f98136c1b5
9 changed files with 30 additions and 24 deletions

View File

@@ -741,10 +741,10 @@ jQuery(document).ready( function($) {
$el = $( '#editable-post-name' );
revert_e = $el.html();
buttons.html('<button type="button" class="save button button-small">'+postL10n.ok+'</button> <a class="cancel" href="#">'+postL10n.cancel+'</a>');
buttons.children('.save').click( function( e ) {
buttons.html( '<button type="button" class="save button button-small">' + postL10n.ok + '</button> <button type="button" class="cancel button-link">' + postL10n.cancel + '</button>' );
buttons.children( '.save' ).click( function() {
var new_slug = $el.children( 'input' ).val();
e.preventDefault();
if ( new_slug == $('#editable-post-name-full').text() ) {
buttons.children('.cancel').click();
return;
@@ -768,11 +768,11 @@ jQuery(document).ready( function($) {
permalink.html(permalinkOrig);
real_slug.val(new_slug);
$( '.edit-slug' ).focus();
wp.a11y.speak( postL10n.permalinkSaved );
});
});
buttons.children('.cancel').click( function( e ) {
e.preventDefault();
buttons.children( '.cancel' ).click( function() {
$('#view-post-btn').show();
$el.html(revert_e);
buttons.html(buttonsOrig);
@@ -787,23 +787,22 @@ jQuery(document).ready( function($) {
}
slug_value = ( c > full.length / 4 ) ? '' : full;
$el.html( '<input type="text" id="new-post-slug" value="'+slug_value+'" autocomplete="off" />').children('input').keypress(function(e) {
var key = e.keyCode || 0;
// on enter, just save the new slug, don't save the post
if ( 13 == key ) {
buttons.children('.save').click();
return false;
$el.html( '<input type="text" id="new-post-slug" value="' + slug_value + '" autocomplete="off" />' ).children( 'input' ).keydown( function( e ) {
var key = e.which;
// On enter, just save the new slug, don't save the post.
if ( 13 === key ) {
e.preventDefault();
buttons.children( '.save' ).click();
}
if ( 27 == key ) {
buttons.children('.cancel').click();
return false;
if ( 27 === key ) {
buttons.children( '.cancel' ).click();
}
} ).keyup( function() {
real_slug.val(this.value);
real_slug.val( this.value );
}).focus();
}
$('#edit-slug-box').on( 'click', '.edit-slug', function() {
$( '#titlediv' ).on( 'click', '.edit-slug', function() {
editPermalink();
});

File diff suppressed because one or more lines are too long