diff -r c7c34916027a -r 177826044cd9 wp/wp-admin/js/customize-nav-menus.js --- a/wp/wp-admin/js/customize-nav-menus.js Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-admin/js/customize-nav-menus.js Mon Oct 14 18:28:13 2019 +0200 @@ -1,3 +1,7 @@ +/** + * @output wp-admin/js/customize-nav-menus.js + */ + /* global _wpCustomizeNavMenusSettings, wpNavMenu, console */ ( function( api, wp, $ ) { 'use strict'; @@ -13,6 +17,9 @@ this.jQueryExtensions(); }; + /** + * @namespace wp.customize.Menus + */ api.Menus = api.Menus || {}; // Link settings. @@ -35,6 +42,8 @@ * Newly-created Nav Menus and Nav Menu Items have negative integer IDs which * serve as placeholders until Save & Publish happens. * + * @alias wp.customize.Menus.generatePlaceholderAutoIncrementId + * * @return {number} */ api.Menus.generatePlaceholderAutoIncrementId = function() { @@ -46,7 +55,7 @@ * * A single available menu item model. See PHP's WP_Customize_Nav_Menu_Item_Setting class. * - * @constructor + * @class wp.customize.Menus.AvailableItemModel * @augments Backbone.Model */ api.Menus.AvailableItemModel = Backbone.Model.extend( $.extend( @@ -61,10 +70,10 @@ * * Collection for available menu item models. * - * @constructor - * @augments Backbone.Model + * @class wp.customize.Menus.AvailableItemCollection + * @augments Backbone.Collection */ - api.Menus.AvailableItemCollection = Backbone.Collection.extend({ + api.Menus.AvailableItemCollection = Backbone.Collection.extend(/** @lends wp.customize.Menus.AvailableItemCollection.prototype */{ model: api.Menus.AvailableItemModel, sort_key: 'order', @@ -84,7 +93,7 @@ * Insert a new `auto-draft` post. * * @since 4.7.0 - * @access public + * @alias wp.customize.Menus.insertAutoDraftPost * * @param {object} params - Parameters for the draft post to create. * @param {string} params.post_type - Post type to add. @@ -141,22 +150,12 @@ return deferred.promise(); }; - /** - * wp.customize.Menus.AvailableMenuItemsPanelView - * - * View class for the available menu items panel. - * - * @constructor - * @augments wp.Backbone.View - * @augments Backbone.View - */ - api.Menus.AvailableMenuItemsPanelView = wp.Backbone.View.extend({ + api.Menus.AvailableMenuItemsPanelView = wp.Backbone.View.extend(/** @lends wp.customize.Menus.AvailableMenuItemsPanelView.prototype */{ el: '#available-menu-items', events: { 'input #menu-items-search': 'debounceSearch', - 'keyup #menu-items-search': 'debounceSearch', 'focus .menu-item-tpl': 'focus', 'click .menu-item-tpl': '_submit', 'click #custom-menu-item-submit': '_submitLink', @@ -181,6 +180,14 @@ loading: false, addingNew: false, + /** + * wp.customize.Menus.AvailableMenuItemsPanelView + * + * View class for the available menu items panel. + * + * @constructs wp.customize.Menus.AvailableMenuItemsPanelView + * @augments wp.Backbone.View + */ initialize: function() { var self = this; @@ -537,6 +544,7 @@ var menuItem, itemName = $( '#custom-menu-item-name' ), itemUrl = $( '#custom-menu-item-url' ), + url = itemUrl.val().trim(), urlRegex; if ( ! this.currentMenuControl ) { @@ -560,14 +568,14 @@ if ( '' === itemName.val() ) { itemName.addClass( 'invalid' ); return; - } else if ( ! urlRegex.test( itemUrl.val() ) ) { + } else if ( ! urlRegex.test( url ) ) { itemUrl.addClass( 'invalid' ); return; } menuItem = { 'title': itemName.val(), - 'url': itemUrl.val(), + 'url': url, 'type': 'custom', 'type_label': api.Menus.data.l10n.custom_label, 'object': 'custom' @@ -753,10 +761,10 @@ * Customizer panel for menus. This is used only for screen options management. * Note that 'menus' must match the WP_Customize_Menu_Panel::$type. * - * @constructor + * @class wp.customize.Menus.MenusPanel * @augments wp.customize.Panel */ - api.Menus.MenusPanel = api.Panel.extend({ + api.Menus.MenusPanel = api.Panel.extend(/** @lends wp.customize.Menus.MenusPanel.prototype */{ attachEvents: function() { api.Panel.prototype.attachEvents.call( this ); @@ -885,10 +893,10 @@ * Customizer section for menus. This is used only for lazy-loading child controls. * Note that 'nav_menu' must match the WP_Customize_Menu_Section::$type. * - * @constructor + * @class wp.customize.Menus.MenuSection * @augments wp.customize.Section */ - api.Menus.MenuSection = api.Section.extend({ + api.Menus.MenuSection = api.Section.extend(/** @lends wp.customize.Menus.MenuSection.prototype */{ /** * Initialize. @@ -1212,10 +1220,10 @@ * * Customizer section for new menus. * - * @constructor + * @class wp.customize.Menus.NewMenuSection * @augments wp.customize.Section */ - api.Menus.NewMenuSection = api.Section.extend({ + api.Menus.NewMenuSection = api.Section.extend(/** @lends wp.customize.Menus.NewMenuSection.prototype */{ /** * Add behaviors for the accordion section. @@ -1451,10 +1459,10 @@ * Customizer control for menu locations (rendered as a