equal
deleted
inserted
replaced
96 * @param {Object} options.params |
96 * @param {Object} options.params |
97 * @param {Object} options.params.navMenuArgs |
97 * @param {Object} options.params.navMenuArgs |
98 * @param {string} options.params.navMenuArgs.args_hmac |
98 * @param {string} options.params.navMenuArgs.args_hmac |
99 * @param {string} [options.params.navMenuArgs.theme_location] |
99 * @param {string} [options.params.navMenuArgs.theme_location] |
100 * @param {number} [options.params.navMenuArgs.menu] |
100 * @param {number} [options.params.navMenuArgs.menu] |
101 * @param {object} [options.constructingContainerContext] |
101 * @param {Object} [options.constructingContainerContext] |
102 */ |
102 */ |
103 initialize: function( id, options ) { |
103 initialize: function( id, options ) { |
104 var partial = this, matches, argsHmac; |
104 var partial = this, matches, argsHmac; |
105 matches = id.match( /^nav_menu_instance\[([0-9a-f]{32})]$/ ); |
105 matches = id.match( /^nav_menu_instance\[([0-9a-f]{32})]$/ ); |
106 if ( ! matches ) { |
106 if ( ! matches ) { |
130 /** |
130 /** |
131 * Return whether the setting is related to this partial. |
131 * Return whether the setting is related to this partial. |
132 * |
132 * |
133 * @since 4.5.0 |
133 * @since 4.5.0 |
134 * @param {wp.customize.Value|string} setting - Object or ID. |
134 * @param {wp.customize.Value|string} setting - Object or ID. |
135 * @param {number|object|false|null} newValue - New value, or null if the setting was just removed. |
135 * @param {number|Object|false|null} newValue - New value, or null if the setting was just removed. |
136 * @param {number|object|false|null} oldValue - Old value, or null if the setting was just added. |
136 * @param {number|Object|false|null} oldValue - Old value, or null if the setting was just added. |
137 * @returns {boolean} |
137 * @return {boolean} |
138 */ |
138 */ |
139 isRelatedSetting: function( setting, newValue, oldValue ) { |
139 isRelatedSetting: function( setting, newValue, oldValue ) { |
140 var partial = this, navMenuLocationSetting, navMenuId, isNavMenuItemSetting, _newValue, _oldValue, urlParser; |
140 var partial = this, navMenuLocationSetting, navMenuId, isNavMenuItemSetting, _newValue, _oldValue, urlParser; |
141 if ( _.isString( setting ) ) { |
141 if ( _.isString( setting ) ) { |
142 setting = api( setting ); |
142 setting = api( setting ); |
208 /** |
208 /** |
209 * Make sure that partial fallback behavior is invoked if there is no associated menu. |
209 * Make sure that partial fallback behavior is invoked if there is no associated menu. |
210 * |
210 * |
211 * @since 4.5.0 |
211 * @since 4.5.0 |
212 * |
212 * |
213 * @returns {Promise} |
213 * @return {Promise} |
214 */ |
214 */ |
215 refresh: function() { |
215 refresh: function() { |
216 var partial = this, menuId, deferred = $.Deferred(); |
216 var partial = this, menuId, deferred = $.Deferred(); |
217 |
217 |
218 // Make sure the fallback behavior is invoked when the partial is no longer associated with a menu. |
218 // Make sure the fallback behavior is invoked when the partial is no longer associated with a menu. |
261 api.selectiveRefresh.partialConstructor.nav_menu_instance = self.NavMenuInstancePartial; |
261 api.selectiveRefresh.partialConstructor.nav_menu_instance = self.NavMenuInstancePartial; |
262 |
262 |
263 /** |
263 /** |
264 * Request full refresh if there are nav menu instances that lack partials which also match the supplied args. |
264 * Request full refresh if there are nav menu instances that lack partials which also match the supplied args. |
265 * |
265 * |
266 * @param {object} navMenuInstanceArgs |
266 * @param {Object} navMenuInstanceArgs |
267 */ |
267 */ |
268 self.handleUnplacedNavMenuInstances = function( navMenuInstanceArgs ) { |
268 self.handleUnplacedNavMenuInstances = function( navMenuInstanceArgs ) { |
269 var unplacedNavMenuInstances; |
269 var unplacedNavMenuInstances; |
270 unplacedNavMenuInstances = _.filter( _.values( self.data.navMenuInstanceArgs ), function( args ) { |
270 unplacedNavMenuInstances = _.filter( _.values( self.data.navMenuInstanceArgs ), function( args ) { |
271 return ! api.selectiveRefresh.partial.has( 'nav_menu_instance[' + args.args_hmac + ']' ); |
271 return ! api.selectiveRefresh.partial.has( 'nav_menu_instance[' + args.args_hmac + ']' ); |
281 * Add change listener for a nav_menu[], nav_menu_item[], or nav_menu_locations[] setting. |
281 * Add change listener for a nav_menu[], nav_menu_item[], or nav_menu_locations[] setting. |
282 * |
282 * |
283 * @since 4.5.0 |
283 * @since 4.5.0 |
284 * |
284 * |
285 * @param {wp.customize.Value} setting |
285 * @param {wp.customize.Value} setting |
286 * @param {object} [options] |
286 * @param {Object} [options] |
287 * @param {boolean} options.fire Whether to invoke the callback after binding. |
287 * @param {boolean} options.fire Whether to invoke the callback after binding. |
288 * This is used when a dynamic setting is added. |
288 * This is used when a dynamic setting is added. |
289 * @return {boolean} Whether the setting was bound. |
289 * @return {boolean} Whether the setting was bound. |
290 */ |
290 */ |
291 self.bindSettingListener = function( setting, options ) { |
291 self.bindSettingListener = function( setting, options ) { |
368 /** |
368 /** |
369 * Handle change for nav_menu_item[] setting for nav menu instances lacking partials. |
369 * Handle change for nav_menu_item[] setting for nav menu instances lacking partials. |
370 * |
370 * |
371 * @since 4.5.0 |
371 * @since 4.5.0 |
372 * |
372 * |
373 * @param {object} newItem New value for nav_menu_item[] setting. |
373 * @param {Object} newItem New value for nav_menu_item[] setting. |
374 * @param {object} oldItem Old value for nav_menu_item[] setting. |
374 * @param {Object} oldItem Old value for nav_menu_item[] setting. |
375 * @this {wp.customize.Value} |
375 * @this {wp.customize.Value} |
376 */ |
376 */ |
377 self.onChangeNavMenuItemSetting = function( newItem, oldItem ) { |
377 self.onChangeNavMenuItemSetting = function( newItem, oldItem ) { |
378 var item = newItem || oldItem, navMenuSetting; |
378 var item = newItem || oldItem, navMenuSetting; |
379 navMenuSetting = api( 'nav_menu[' + String( item.nav_menu_term_id ) + ']' ); |
379 navMenuSetting = api( 'nav_menu[' + String( item.nav_menu_term_id ) + ']' ); |