mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-09 18:08:09 +01:00
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:
parent
2764315403
commit
6e56dce7dd
@ -890,22 +890,25 @@ var wpNavMenu;
|
|||||||
* @param jQuery panel The tabs panel we're searching in.
|
* @param jQuery panel The tabs panel we're searching in.
|
||||||
*/
|
*/
|
||||||
processQuickSearchQueryResponse : function(resp, req, panel) {
|
processQuickSearchQueryResponse : function(resp, req, panel) {
|
||||||
var i, matched, newID,
|
var matched, newID,
|
||||||
takenIDs = {},
|
takenIDs = {},
|
||||||
form = document.getElementById('nav-menu-meta'),
|
form = document.getElementById('nav-menu-meta'),
|
||||||
pattern = new RegExp('menu-item\\[(\[^\\]\]*)', 'g'),
|
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>' );
|
$('.categorychecklist', panel).html( '<li><p>' + navMenuL10n.noResultsFound + '</p></li>' );
|
||||||
$('img.waiting', panel).hide();
|
$('img.waiting', panel).hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = items.length;
|
$items.each(function(){
|
||||||
while( i-- ) {
|
$item = $(this);
|
||||||
|
|
||||||
// make a unique DB ID number
|
// make a unique DB ID number
|
||||||
matched = pattern.exec(items[i]);
|
matched = pattern.exec($item.html());
|
||||||
|
|
||||||
if ( matched && matched[1] ) {
|
if ( matched && matched[1] ) {
|
||||||
newID = matched[1];
|
newID = matched[1];
|
||||||
while( form.elements['menu-item[' + newID + '][menu-item-type]'] || takenIDs[ newID ] ) {
|
while( form.elements['menu-item[' + newID + '][menu-item-type]'] || takenIDs[ newID ] ) {
|
||||||
@ -914,12 +917,15 @@ var wpNavMenu;
|
|||||||
|
|
||||||
takenIDs[newID] = true;
|
takenIDs[newID] = true;
|
||||||
if ( newID != matched[1] ) {
|
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();
|
$('img.waiting', panel).hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -399,7 +399,7 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
) );
|
) );
|
||||||
|
|
||||||
// Navigation Menus
|
// 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(
|
$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." ),
|
||||||
|
Loading…
Reference in New Issue
Block a user