WordPress.org

Make WordPress Core

Changeset 28707


Ignore:
Timestamp:
06/09/2014 06:38:29 PM (7 years ago)
Author:
wonderboymusic
Message:

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

Props celloexpressions.
See #23076.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/nav-menus.css

    r27229 r28707  
    506506    display: block;
    507507    margin-right: 13em;
     508}
     509
     510.menu-item-handle .menu-item-title.no-title {
     511    color: #999;
    508512}
    509513
  • trunk/src/wp-admin/js/nav-menu.js

    r26623 r28707  
    5858
    5959            this.initToggles();
     60
     61            this.initPreviewing();
    6062        },
    6163
     
    531533        },
    532534
     535        initPreviewing : function() {
     536            // Update the item handle title when the navigation label is changed.
     537            $( 'body' ).on( 'input', '.edit-menu-item-title', function(e) {
     538                var input = $( e.currentTarget ), title, titleEl;
     539                title = input.val();
     540                titleEl = input.closest( '.menu-item' ).find( '.menu-item-title' );
     541                // Don't update to empty title.
     542                if ( title ) {
     543                    titleEl.text( title ).removeClass( 'no-title' );
     544                } else {
     545                    titleEl.text( navMenuL10n.untitled ).addClass( 'no-title' );
     546                }
     547            } );
     548        },
     549
    533550        initToggles : function() {
    534551            // init postboxes
  • trunk/src/wp-includes/script-loader.php

    r28479 r28707  
    531531            'noResultsFound' => _x('No results found.', 'search results'),
    532532            'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
    533             'saveAlert' => __('The changes you made will be lost if you navigate away from this page.')
     533            'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
     534            'untitled' => _x('(no label)', 'missing menu item navigation label')
    534535        ) );
    535536
Note: See TracChangeset for help on using the changeset viewer.