Fix menu box search. Fixes #14335

git-svn-id: http://svn.automattic.com/wordpress/trunk@15709 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-10-04 14:17:34 +00:00
parent 2764315403
commit 6e56dce7dd
3 changed files with 17 additions and 11 deletions

View File

@ -890,22 +890,25 @@ var wpNavMenu;
* @param jQuery panel The tabs panel we're searching in.
*/
processQuickSearchQueryResponse : function(resp, req, panel) {
var i, matched, newID,
var matched, newID,
takenIDs = {},
form = document.getElementById('nav-menu-meta'),
pattern = new RegExp('menu-item\\[(\[^\\]\]*)', 'g'),
items = resp.match(/<li>.*<\/li>/g);
$items = $('<div>').html(resp).find('li'),
$item;
if( ! items ) {
if( ! $items.length ) {
$('.categorychecklist', panel).html( '<li><p>' + navMenuL10n.noResultsFound + '</p></li>' );
$('img.waiting', panel).hide();
return;
}
i = items.length;
while( i-- ) {
$items.each(function(){
$item = $(this);
// make a unique DB ID number
matched = pattern.exec(items[i]);
matched = pattern.exec($item.html());
if ( matched && matched[1] ) {
newID = matched[1];
while( form.elements['menu-item[' + newID + '][menu-item-type]'] || takenIDs[ newID ] ) {
@ -914,12 +917,15 @@ var wpNavMenu;
takenIDs[newID] = true;
if ( newID != matched[1] ) {
items[i] = items[i].replace(new RegExp('menu-item\\[' + matched[1] + '\\]', 'g'), 'menu-item[' + newID + ']');
$item.html( $item.html().replace(new RegExp(
'menu-item\\[' + matched[1] + '\\]', 'g'),
'menu-item[' + newID + ']'
) );
}
}
}
});
$('.categorychecklist', panel).html( items.join('') );
$('.categorychecklist', panel).html( $items );
$('img.waiting', panel).hide();
},

File diff suppressed because one or more lines are too long

View File

@ -399,7 +399,7 @@ function wp_default_scripts( &$scripts ) {
) );
// Navigation Menus
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100611' );
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100814' );
$scripts->localize( 'nav-menu', 'navMenuL10n', array(
'noResultsFound' => _x('No results found.', 'search results'),
'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),