diff --git a/src/wp-admin/js/nav-menu.js b/src/wp-admin/js/nav-menu.js index 535aaf12af..bcce09a5dd 100644 --- a/src/wp-admin/js/nav-menu.js +++ b/src/wp-admin/js/nav-menu.js @@ -1003,21 +1003,33 @@ var wpNavMenu; }, /** - * Process the add menu item request response into menu list item. + * Process the add menu item request response into menu list item. Appends to menu. * - * @param string menuMarkup The text server response of menu item markup. - * @param object req The request arguments. + * @param {string} menuMarkup The text server response of menu item markup. + * + * @fires document#menu-item-added Passes menuMarkup as a jQuery object. */ addMenuItemToBottom : function( menuMarkup ) { - $(menuMarkup).hideAdvancedMenuItemFields().appendTo( api.targetList ); + var $menuMarkup = $( menuMarkup ); + $menuMarkup.hideAdvancedMenuItemFields().appendTo( api.targetList ); api.refreshKeyboardAccessibility(); api.refreshAdvancedAccessibility(); + $( document ).trigger( 'menu-item-added', [ $menuMarkup ] ); }, + /** + * Process the add menu item request response into menu list item. Prepends to menu. + * + * @param {string} menuMarkup The text server response of menu item markup. + * + * @fires document#menu-item-added Passes menuMarkup as a jQuery object. + */ addMenuItemToTop : function( menuMarkup ) { - $(menuMarkup).hideAdvancedMenuItemFields().prependTo( api.targetList ); + var $menuMarkup = $( menuMarkup ); + $menuMarkup.hideAdvancedMenuItemFields().prependTo( api.targetList ); api.refreshKeyboardAccessibility(); api.refreshAdvancedAccessibility(); + $( document ).trigger( 'menu-item-added', [ $menuMarkup ] ); }, attachUnsavedChangesListener : function() { @@ -1243,9 +1255,16 @@ var wpNavMenu; 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 diff --git a/tests/qunit/index.html b/tests/qunit/index.html index 9a17ec23b8..58591e4860 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -66,6 +66,7 @@ +