').html(resp).find('li'),
wrapper = panel.closest( '.accordion-section-content' ),
$item;
if( ! $items.length ) {
$('.categorychecklist', panel).html( '
' + navMenuL10n.noResultsFound + '
' );
$( '.spinner', panel ).removeClass( 'is-active' );
wrapper.addClass( 'has-no-menu-item' );
return;
}
$items.each(function(){
$item = $(this);
// make a unique DB ID number
matched = pattern.exec($item.html());
if ( matched && matched[1] ) {
newID = matched[1];
while( form.elements['menu-item[' + newID + '][menu-item-type]'] || takenIDs[ newID ] ) {
newID--;
}
takenIDs[newID] = true;
if ( newID != matched[1] ) {
$item.html( $item.html().replace(new RegExp(
'menu-item\\[' + matched[1] + '\\]', 'g'),
'menu-item[' + newID + ']'
) );
}
}
});
$('.categorychecklist', panel).html( $items );
$( '.spinner', panel ).removeClass( 'is-active' );
wrapper.removeClass( 'has-no-menu-item' );
},
/**
* Remove a menu item.
* @param {object} el The element to be removed as a jQuery object.
*
* @fires document#menu-removing-item Passes the element to be removed.
*/
removeMenuItem : function(el) {
var children = el.childMenuItems();
$( document ).trigger( 'menu-removing-item', [ el ] );
el.addClass('deleting').animate({
opacity : 0,
height: 0
}, 350, function() {
var ins = $('#menu-instructions');
el.remove();
children.shiftDepthClass( -1 ).updateParentMenuItemDBId();
if ( 0 === $( '#menu-to-edit li' ).length ) {
$( '.drag-instructions' ).hide();
ins.removeClass( 'menu-instructions-inactive' );
}
api.refreshAdvancedAccessibility();
});
},
depthToPx : function(depth) {
return depth * api.options.menuItemDepthPerLevel;
},
pxToDepth : function(px) {
return Math.floor(px / api.options.menuItemDepthPerLevel);
}
};
$(document).ready(function(){ wpNavMenu.init(); });
})(jQuery);