2015-07-20 19:39:24 -04:00
|
|
|
/* global JSON, _wpCustomizePreviewNavMenusExports */
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
( function( $, _, wp ) {
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
'use strict';
|
2015-07-21 13:40:25 -04:00
|
|
|
|
|
|
|
if ( ! wp || ! wp.customize ) { return; }
|
|
|
|
|
|
|
|
var api = wp.customize,
|
|
|
|
currentRefreshDebounced = {},
|
2015-07-21 12:14:24 -04:00
|
|
|
refreshDebounceDelay = 200,
|
|
|
|
settings = {},
|
|
|
|
defaultSettings = {
|
|
|
|
renderQueryVar: null,
|
|
|
|
renderNonceValue: null,
|
|
|
|
renderNoncePostKey: null,
|
|
|
|
previewCustomizeNonce: null,
|
|
|
|
requestUri: '/',
|
|
|
|
theme: {
|
|
|
|
active: false,
|
|
|
|
stylesheet: ''
|
|
|
|
},
|
|
|
|
navMenuInstanceArgs: {}
|
2015-07-21 13:40:25 -04:00
|
|
|
};
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
api.MenusCustomizerPreview = {
|
|
|
|
/**
|
|
|
|
* Bootstrap functionality.
|
|
|
|
*/
|
|
|
|
init : function() {
|
|
|
|
var self = this, initializedSettings = {};
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
settings = _.extend( {}, defaultSettings );
|
|
|
|
if ( 'undefined' !== typeof _wpCustomizePreviewNavMenusExports ) {
|
|
|
|
_.extend( settings, _wpCustomizePreviewNavMenusExports );
|
|
|
|
}
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
api.each( function( setting, id ) {
|
|
|
|
setting.id = id;
|
|
|
|
initializedSettings[ setting.id ] = true;
|
|
|
|
self.bindListener( setting );
|
|
|
|
} );
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
api.preview.bind( 'setting', function( args ) {
|
|
|
|
var id, value, setting;
|
|
|
|
args = args.slice();
|
|
|
|
id = args.shift();
|
|
|
|
value = args.shift();
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
setting = api( id );
|
|
|
|
if ( ! setting ) {
|
|
|
|
// Currently customize-preview.js is not creating settings for dynamically-created settings in the pane, so we have to do it.
|
|
|
|
setting = api.create( id, value ); // @todo This should be in core
|
|
|
|
}
|
|
|
|
if ( ! setting.id ) {
|
|
|
|
// Currently customize-preview.js doesn't set the id property for each setting, like customize-controls.js does.
|
|
|
|
setting.id = id;
|
|
|
|
}
|
2015-07-20 03:44:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
if ( ! initializedSettings[ setting.id ] ) {
|
|
|
|
initializedSettings[ setting.id ] = true;
|
|
|
|
if ( self.bindListener( setting ) ) {
|
|
|
|
setting.callbacks.fireWith( setting, [ setting(), null ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {wp.customize.Value} setting
|
|
|
|
* @returns {boolean} Whether the setting was bound.
|
|
|
|
*/
|
|
|
|
bindListener : function( setting ) {
|
|
|
|
var matches, themeLocation;
|
|
|
|
|
|
|
|
matches = setting.id.match( /^nav_menu\[(-?\d+)]$/ );
|
|
|
|
if ( matches ) {
|
|
|
|
setting.navMenuId = parseInt( matches[1], 10 );
|
|
|
|
setting.bind( this.onChangeNavMenuSetting );
|
|
|
|
return true;
|
2015-07-20 03:44:26 -04:00
|
|
|
}
|
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
matches = setting.id.match( /^nav_menu_item\[(-?\d+)]$/ );
|
|
|
|
if ( matches ) {
|
|
|
|
setting.navMenuItemId = parseInt( matches[1], 10 );
|
|
|
|
setting.bind( this.onChangeNavMenuItemSetting );
|
|
|
|
return true;
|
2015-07-08 16:42:24 -04:00
|
|
|
}
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
matches = setting.id.match( /^nav_menu_locations\[(.+?)]/ );
|
|
|
|
if ( matches ) {
|
|
|
|
themeLocation = matches[1];
|
|
|
|
setting.bind( _.bind( function() {
|
|
|
|
this.refreshMenuLocation( themeLocation );
|
|
|
|
}, this ) );
|
|
|
|
return true;
|
|
|
|
}
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
return false;
|
|
|
|
},
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
/**
|
|
|
|
* Handle changing of a nav_menu setting.
|
|
|
|
*
|
|
|
|
* @this {wp.customize.Setting}
|
|
|
|
*/
|
|
|
|
onChangeNavMenuSetting : function() {
|
|
|
|
var setting = this;
|
|
|
|
if ( ! setting.navMenuId ) {
|
|
|
|
throw new Error( 'Expected navMenuId property to be set.' );
|
|
|
|
}
|
|
|
|
api.MenusCustomizerPreview.refreshMenu( setting.navMenuId );
|
|
|
|
},
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
/**
|
|
|
|
* Handle changing of a nav_menu_item setting.
|
|
|
|
*
|
|
|
|
* @this {wp.customize.Setting}
|
|
|
|
* @param {object} to
|
|
|
|
* @param {object} from
|
|
|
|
*/
|
|
|
|
onChangeNavMenuItemSetting : function( to, from ) {
|
|
|
|
if ( from && from.nav_menu_term_id && ( ! to || from.nav_menu_term_id !== to.nav_menu_term_id ) ) {
|
|
|
|
api.MenusCustomizerPreview.refreshMenu( from.nav_menu_term_id );
|
|
|
|
}
|
|
|
|
if ( to && to.nav_menu_term_id ) {
|
|
|
|
api.MenusCustomizerPreview.refreshMenu( to.nav_menu_term_id );
|
|
|
|
}
|
|
|
|
},
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
/**
|
|
|
|
* Update a given menu rendered in the preview.
|
|
|
|
*
|
|
|
|
* @param {int} menuId
|
|
|
|
*/
|
|
|
|
refreshMenu : function( menuId ) {
|
|
|
|
var assignedLocations = [];
|
|
|
|
|
|
|
|
api.each(function( setting, id ) {
|
|
|
|
var matches = id.match( /^nav_menu_locations\[(.+?)]/ );
|
|
|
|
if ( matches && menuId === setting() ) {
|
|
|
|
assignedLocations.push( matches[1] );
|
|
|
|
}
|
|
|
|
});
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
_.each( settings.navMenuInstanceArgs, function( navMenuArgs, instanceNumber ) {
|
|
|
|
if ( menuId === navMenuArgs.menu || -1 !== _.indexOf( assignedLocations, navMenuArgs.theme_location ) ) {
|
|
|
|
this.refreshMenuInstanceDebounced( instanceNumber );
|
|
|
|
}
|
|
|
|
}, this );
|
|
|
|
},
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
/**
|
|
|
|
* Refresh the menu(s) associated with a given nav menu location.
|
|
|
|
*
|
|
|
|
* @param {string} location
|
|
|
|
*/
|
|
|
|
refreshMenuLocation : function( location ) {
|
|
|
|
var foundInstance = false;
|
|
|
|
_.each( settings.navMenuInstanceArgs, function( navMenuArgs, instanceNumber ) {
|
|
|
|
if ( location === navMenuArgs.theme_location ) {
|
|
|
|
this.refreshMenuInstanceDebounced( instanceNumber );
|
|
|
|
foundInstance = true;
|
|
|
|
}
|
|
|
|
}, this );
|
|
|
|
if ( ! foundInstance ) {
|
|
|
|
api.preview.send( 'refresh' );
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
}
|
2015-07-21 13:40:25 -04:00
|
|
|
},
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
/**
|
|
|
|
* Update a specific instance of a given menu on the page.
|
|
|
|
*
|
|
|
|
* @param {int} instanceNumber
|
|
|
|
*/
|
|
|
|
refreshMenuInstance : function( instanceNumber ) {
|
2015-07-29 14:13:24 -04:00
|
|
|
var data, menuId, customized, container, request, wpNavMenuArgs, instance, containerInstanceClassName;
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
if ( ! settings.navMenuInstanceArgs[ instanceNumber ] ) {
|
|
|
|
throw new Error( 'unknown_instance_number' );
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
}
|
2015-07-21 13:40:25 -04:00
|
|
|
instance = settings.navMenuInstanceArgs[ instanceNumber ];
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
containerInstanceClassName = 'partial-refreshable-nav-menu-' + String( instanceNumber );
|
|
|
|
container = $( '.' + containerInstanceClassName );
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
if ( _.isNumber( instance.menu ) ) {
|
|
|
|
menuId = instance.menu;
|
|
|
|
} else if ( instance.theme_location && api.has( 'nav_menu_locations[' + instance.theme_location + ']' ) ) {
|
|
|
|
menuId = api( 'nav_menu_locations[' + instance.theme_location + ']' ).get();
|
|
|
|
}
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
if ( ! menuId || ! instance.can_partial_refresh || 0 === container.length ) {
|
|
|
|
api.preview.send( 'refresh' );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
menuId = parseInt( menuId, 10 );
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
data = {
|
|
|
|
nonce: settings.previewCustomizeNonce, // for Customize Preview
|
|
|
|
wp_customize: 'on'
|
|
|
|
};
|
|
|
|
if ( ! settings.theme.active ) {
|
|
|
|
data.theme = settings.theme.stylesheet;
|
|
|
|
}
|
|
|
|
data[ settings.renderQueryVar ] = '1';
|
2015-07-08 17:30:24 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
// Gather settings to send in partial refresh request.
|
|
|
|
customized = {};
|
|
|
|
api.each( function( setting, id ) {
|
|
|
|
var value = setting.get(), shouldSend = false;
|
|
|
|
// @todo Core should propagate the dirty state into the Preview as well so we can use that here.
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
// Send setting if it is a nav_menu_locations[] setting.
|
|
|
|
shouldSend = shouldSend || /^nav_menu_locations\[/.test( id );
|
2015-07-20 03:44:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
// Send setting if it is the setting for this menu.
|
|
|
|
shouldSend = shouldSend || id === 'nav_menu[' + String( menuId ) + ']';
|
2015-07-20 03:44:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
// Send setting if it is one that is associated with this menu, or it is deleted.
|
|
|
|
shouldSend = shouldSend || ( /^nav_menu_item\[/.test( id ) && ( false === value || menuId === value.nav_menu_term_id ) );
|
2015-07-20 03:44:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
if ( shouldSend ) {
|
|
|
|
customized[ id ] = value;
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
data.customized = JSON.stringify( customized );
|
|
|
|
data[ settings.renderNoncePostKey ] = settings.renderNonceValue;
|
2015-07-20 03:44:26 -04:00
|
|
|
|
2015-07-29 14:13:24 -04:00
|
|
|
wpNavMenuArgs = $.extend( {}, instance );
|
|
|
|
data.wp_nav_menu_args_hash = wpNavMenuArgs.args_hash;
|
|
|
|
delete wpNavMenuArgs.args_hash;
|
|
|
|
data.wp_nav_menu_args = JSON.stringify( wpNavMenuArgs );
|
2015-07-20 03:44:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
container.addClass( 'customize-partial-refreshing' );
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
request = wp.ajax.send( null, {
|
|
|
|
data: data,
|
|
|
|
url: settings.requestUri
|
|
|
|
} );
|
|
|
|
request.done( function( data ) {
|
|
|
|
// If the menu is now not visible, refresh since the page layout may have changed.
|
|
|
|
if ( false === data ) {
|
|
|
|
api.preview.send( 'refresh' );
|
|
|
|
return;
|
|
|
|
}
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
var eventParam, previousContainer = container;
|
|
|
|
container = $( data );
|
|
|
|
container.addClass( containerInstanceClassName );
|
|
|
|
container.addClass( 'partial-refreshable-nav-menu customize-partial-refreshing' );
|
|
|
|
previousContainer.replaceWith( container );
|
|
|
|
eventParam = {
|
|
|
|
instanceNumber: instanceNumber,
|
2015-07-29 14:13:24 -04:00
|
|
|
wpNavArgs: wpNavMenuArgs, // @deprecated
|
|
|
|
wpNavMenuArgs: wpNavMenuArgs,
|
2015-07-21 13:40:25 -04:00
|
|
|
oldContainer: previousContainer,
|
|
|
|
newContainer: container
|
|
|
|
};
|
|
|
|
container.removeClass( 'customize-partial-refreshing' );
|
|
|
|
$( document ).trigger( 'customize-preview-menu-refreshed', [ eventParam ] );
|
|
|
|
} );
|
|
|
|
},
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
refreshMenuInstanceDebounced : function( instanceNumber ) {
|
|
|
|
if ( currentRefreshDebounced[ instanceNumber ] ) {
|
|
|
|
clearTimeout( currentRefreshDebounced[ instanceNumber ] );
|
2015-07-08 17:30:24 -04:00
|
|
|
}
|
2015-07-21 13:40:25 -04:00
|
|
|
currentRefreshDebounced[ instanceNumber ] = setTimeout(
|
|
|
|
_.bind( function() {
|
|
|
|
this.refreshMenuInstance( instanceNumber );
|
|
|
|
}, this ),
|
|
|
|
refreshDebounceDelay
|
|
|
|
);
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
api.bind( 'preview-ready', function() {
|
|
|
|
api.preview.bind( 'active', function() {
|
|
|
|
api.MenusCustomizerPreview.init();
|
|
|
|
} );
|
|
|
|
} );
|
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 18:08:26 -04:00
|
|
|
|
2015-07-21 13:40:25 -04:00
|
|
|
}( jQuery, _, wp ) );
|