Live update the menu item title when the user is editing the "Navigation Label" field.

Props celloexpressions.
See #23076.


git-svn-id: https://develop.svn.wordpress.org/trunk@28707 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-06-09 18:38:29 +00:00
parent 12e325582a
commit faf208de38
3 changed files with 23 additions and 1 deletions

View File

@ -507,6 +507,10 @@ ul.add-menu-item-tabs li {
margin-right: 13em; margin-right: 13em;
} }
.menu-item-handle .menu-item-title.no-title {
color: #999;
}
/* Sortables */ /* Sortables */
li.menu-item.ui-sortable-helper dl { li.menu-item.ui-sortable-helper dl {
margin-top: 0; margin-top: 0;

View File

@ -57,6 +57,8 @@ var wpNavMenu;
this.initAccessibility(); this.initAccessibility();
this.initToggles(); this.initToggles();
this.initPreviewing();
}, },
jQueryExtensions : function() { jQueryExtensions : function() {
@ -530,6 +532,21 @@ var wpNavMenu;
}); });
}, },
initPreviewing : function() {
// Update the item handle title when the navigation label is changed.
$( 'body' ).on( 'input', '.edit-menu-item-title', function(e) {
var input = $( e.currentTarget ), title, titleEl;
title = input.val();
titleEl = input.closest( '.menu-item' ).find( '.menu-item-title' );
// Don't update to empty title.
if ( title ) {
titleEl.text( title ).removeClass( 'no-title' );
} else {
titleEl.text( navMenuL10n.untitled ).addClass( 'no-title' );
}
} );
},
initToggles : function() { initToggles : function() {
// init postboxes // init postboxes
postboxes.add_postbox_toggles('nav-menus'); postboxes.add_postbox_toggles('nav-menus');

View File

@ -530,7 +530,8 @@ function wp_default_scripts( &$scripts ) {
did_action( 'init' ) && $scripts->localize( 'nav-menu', 'navMenuL10n', array( did_action( 'init' ) && $scripts->localize( 'nav-menu', 'navMenuL10n', array(
'noResultsFound' => _x('No results found.', 'search results'), 'noResultsFound' => _x('No results found.', 'search results'),
'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ), 'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
'saveAlert' => __('The changes you made will be lost if you navigate away from this page.') 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
'untitled' => _x('(no label)', 'missing menu item navigation label')
) ); ) );
$scripts->add( 'custom-header', "/wp-admin/js/custom-header.js", array( 'jquery-masonry' ), false, 1 ); $scripts->add( 'custom-header', "/wp-admin/js/custom-header.js", array( 'jquery-masonry' ), false, 1 );