Ticket #22237: 22237.3.diff
File 22237.3.diff, 4.7 KB (added by , 9 years ago) |
---|
-
src/wp-admin/js/customize-controls.js
3628 3628 overlay.toggleClass( 'collapsed' ).toggleClass( 'expanded' ); 3629 3629 }); 3630 3630 3631 // Keyboard shortcuts - esc to exit section/panel. 3632 $( 'body' ).on( 'keydown', function( event ) { 3633 var collapsedObject, expandedControls = [], expandedSections = [], expandedPanels = []; 3634 3635 if ( 27 !== event.which ) { // Esc. 3636 return; 3637 } 3638 3639 // Check for expanded expandable controls (e.g. widgets and nav menus items), sections, and panels. 3640 api.control.each( function( control ) { 3641 if ( control.expanded && control.expanded() && _.isFunction( control.collapse ) ) { 3642 expandedControls.push( control ); 3643 } 3644 }); 3645 api.section.each( function( section ) { 3646 if ( section.expanded() ) { 3647 expandedSections.push( section ); 3648 } 3649 }); 3650 api.panel.each( function( panel ) { 3651 if ( panel.expanded() ) { 3652 expandedPanels.push( panel ); 3653 } 3654 }); 3655 3656 // Skip collapsing expanded controls if there are no expanded sections. 3657 if ( expandedControls.length > 0 && 0 === expandedSections.length ) { 3658 expandedControls.length = 0; 3659 } 3660 3661 // Collapse the most granular expanded object. 3662 collapsedObject = expandedControls[0] || expandedSections[0] || expandedPanels[0]; 3663 if ( collapsedObject ) { 3664 collapsedObject.collapse(); 3665 event.preventDefault(); 3666 } 3667 }); 3668 3631 3669 $( '.customize-controls-preview-toggle' ).on( 'click', function() { 3632 3670 overlay.toggleClass( 'preview-only' ); 3633 3671 }); -
src/wp-admin/js/customize-nav-menus.js
993 993 */ 994 994 initialize: function( id, options ) { 995 995 var control = this; 996 control.expanded = new api.Value( false ); 997 control.expandedArgumentsQueue = []; 998 control.expanded.bind( function( expanded ) { 999 var args = control.expandedArgumentsQueue.shift(); 1000 args = $.extend( {}, control.defaultExpandedArguments, args ); 1001 control.onChangeExpanded( expanded, args ); 1002 }); 996 1003 api.Control.prototype.initialize.call( control, id, options ); 997 1004 control.active.validate = function() { 998 1005 var value, section = api.section( control.section() ); … … 1370 1377 }, 1371 1378 1372 1379 /** 1380 * @since 4.6.0 1381 * 1382 * @param {Boolean} expanded 1383 * @param {Object} [params] 1384 * @returns {Boolean} false if state already applied 1385 */ 1386 _toggleExpanded: api.Section.prototype._toggleExpanded, 1387 1388 /** 1389 * @since 4.6.0 1390 * 1391 * @param {Object} [params] 1392 * @returns {Boolean} false if already expanded 1393 */ 1394 expand: api.Section.prototype.expand, 1395 1396 /** 1373 1397 * Expand the menu item form control. 1374 1398 * 1375 1399 * @since 4.5.0 Added params.completeCallback. … … 1378 1402 * @param {Function} [params.completeCallback] - Function to call when the form toggle has finished animating. 1379 1403 */ 1380 1404 expandForm: function( params ) { 1381 this. toggleForm( true,params );1405 this.expand( params ); 1382 1406 }, 1383 1407 1384 1408 /** 1409 * @since 4.6.0 1410 * 1411 * @param {Object} [params] 1412 * @returns {Boolean} false if already collapsed 1413 */ 1414 collapse: api.Section.prototype.collapse, 1415 1416 /** 1385 1417 * Collapse the menu item form control. 1386 1418 * 1387 1419 * @since 4.5.0 Added params.completeCallback. … … 1390 1422 * @param {Function} [params.completeCallback] - Function to call when the form toggle has finished animating. 1391 1423 */ 1392 1424 collapseForm: function( params ) { 1393 this. toggleForm( false,params );1425 this.collapse( params ); 1394 1426 }, 1395 1427 1396 1428 /** 1397 1429 * Expand or collapse the menu item control. 1398 1430 * 1399 * @ since 4.5.0 Added params.completeCallback.1431 * @deprecated this is poor naming, and it is better to directly set control.expanded( showOrHide ) 1400 1432 * 1433 * @param {boolean|undefined} [showOrHide] If not supplied, will be inverse of current visibility 1434 */ 1435 toggleForm: function( showOrHide ) { 1436 if ( typeof showOrHide === 'undefined' ) { 1437 showOrHide = ! this.expanded(); 1438 } 1439 this.expanded( showOrHide ); 1440 }, 1441 1442 /** 1443 * Expand or collapse the menu item control. 1444 * 1445 * @since 4.6.0 1401 1446 * @param {boolean} [showOrHide] - If not supplied, will be inverse of current visibility 1402 1447 * @param {Object} [params] - Optional params. 1403 1448 * @param {Function} [params.completeCallback] - Function to call when the form toggle has finished animating. 1404 1449 */ 1405 toggleForm: function( showOrHide, params ) {1450 onChangeExpanded: function( showOrHide, params ) { 1406 1451 var self = this, $menuitem, $inside, complete; 1407 1452 1408 1453 $menuitem = this.container;