Customize: Fix regression in ability to hide fields for advanced menu properties in nav menu item controls.

Props westonruter, celloexpressions.
See #34391.
Fixes #38952.


git-svn-id: https://develop.svn.wordpress.org/trunk@39378 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2016-11-30 18:00:53 +00:00
parent 1c893a5b46
commit 30a9cc4884
2 changed files with 51 additions and 34 deletions

View File

@ -301,19 +301,19 @@
text-decoration: none !important; text-decoration: none !important;
} }
#accordion-panel-nav_menus .field-link-target, .control-section-nav_menu .field-link-target,
#accordion-panel-nav_menus .field-title-attribute, .control-section-nav_menu .field-title-attribute,
#accordion-panel-nav_menus .field-css-classes, .control-section-nav_menu .field-css-classes,
#accordion-panel-nav_menus .field-xfn, .control-section-nav_menu .field-xfn,
#accordion-panel-nav_menus .field-description { .control-section-nav_menu .field-description {
display: none; display: none;
} }
#accordion-panel-nav_menus.field-link-target-active .field-link-target, .control-section-nav_menu.field-link-target-active .field-link-target,
#accordion-panel-nav_menus.field-title-attribute-active .field-title-attribute, .control-section-nav_menu.field-title-attribute-active .field-title-attribute,
#accordion-panel-nav_menus.field-css-classes-active .field-css-classes, .control-section-nav_menu.field-css-classes-active .field-css-classes,
#accordion-panel-nav_menus.field-xfn-active .field-xfn, .control-section-nav_menu.field-xfn-active .field-xfn,
#accordion-panel-nav_menus.field-description-active .field-description { .control-section-nav_menu.field-description-active .field-description {
display: block; display: block;
} }

View File

@ -786,30 +786,23 @@
}, },
/** /**
* Show/hide/save screen options (columns). From common.js. * Update field visibility when clicking on the field toggles.
*/ */
ready: function() { ready: function() {
var panel = this; var panel = this;
this.container.find( '.hide-column-tog' ).click( function() { panel.container.find( '.hide-column-tog' ).click( function() {
var $t = $( this ), column = $t.val();
if ( $t.prop( 'checked' ) ) {
panel.checked( column );
} else {
panel.unchecked( column );
}
panel.saveManageColumnsState(); panel.saveManageColumnsState();
}); });
this.container.find( '.hide-column-tog' ).each( function() {
var $t = $( this ), column = $t.val();
if ( $t.prop( 'checked' ) ) {
panel.checked( column );
} else {
panel.unchecked( column );
}
});
}, },
/**
* Save hidden column states.
*
* @since 4.3.0
* @private
*
* @returns {void}
*/
saveManageColumnsState: _.debounce( function() { saveManageColumnsState: _.debounce( function() {
var panel = this; var panel = this;
if ( panel._updateHiddenColumnsRequest ) { if ( panel._updateHiddenColumnsRequest ) {
@ -826,14 +819,24 @@
} ); } );
}, 2000 ), }, 2000 ),
checked: function( column ) { /**
this.container.addClass( 'field-' + column + '-active' ); * @deprecated Since 4.7.0 now that the nav_menu sections are responsible for toggling the classes on their own containers.
}, */
checked: function() {},
unchecked: function( column ) { /**
this.container.removeClass( 'field-' + column + '-active' ); * @deprecated Since 4.7.0 now that the nav_menu sections are responsible for toggling the classes on their own containers.
}, */
unchecked: function() {},
/**
* Get hidden fields.
*
* @since 4.3.0
* @private
*
* @returns {Array} Fields (columns) that are hidden.
*/
hidden: function() { hidden: function() {
return $( '.hide-column-tog' ).not( ':checked' ).map( function() { return $( '.hide-column-tog' ).not( ':checked' ).map( function() {
var id = this.id; var id = this.id;
@ -871,7 +874,7 @@
* Ready. * Ready.
*/ */
ready: function() { ready: function() {
var section = this; var section = this, fieldActiveToggles, handleFieldActiveToggle;
if ( 'undefined' === typeof section.params.menu_id ) { if ( 'undefined' === typeof section.params.menu_id ) {
throw new Error( 'params.menu_id was not defined' ); throw new Error( 'params.menu_id was not defined' );
@ -923,6 +926,20 @@
section.container.find( '.menu-item.move-left-disabled .menus-move-left' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' }); section.container.find( '.menu-item.move-left-disabled .menus-move-left' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' });
section.container.find( '.menu-item.move-right-disabled .menus-move-right' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' }); section.container.find( '.menu-item.move-right-disabled .menus-move-right' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' });
} ); } );
/**
* Update the active field class for the content container for a given checkbox toggle.
*
* @this {jQuery}
* @returns {void}
*/
handleFieldActiveToggle = function() {
var className = 'field-' + $( this ).val() + '-active';
section.contentContainer.toggleClass( className, $( this ).prop( 'checked' ) );
};
fieldActiveToggles = api.panel( 'nav_menus' ).contentContainer.find( '.metabox-prefs:first' ).find( '.hide-column-tog' );
fieldActiveToggles.each( handleFieldActiveToggle );
fieldActiveToggles.on( 'click', handleFieldActiveToggle );
}, },
populateControls: function() { populateControls: function() {