Menus: trigger an event when menu items are added or removed.
Fire a `menu-item-added` event after a menu item is added to the DOM. Fire a `menu-removing-item` event before a menu item is removed from the DOM. Enables hooking into and responding to menu changes. Props welcher, adamsilverstein. Fixes #31218. Built from https://develop.svn.wordpress.org/trunk@39928 git-svn-id: http://core.svn.wordpress.org/trunk@39865 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0b338e2f58
commit
8d8f5616b7
|
@ -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
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.8-alpha-39927';
|
||||
$wp_version = '4.8-alpha-39928';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue