diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
index 739b962..0e8d27b 100644
|
|
|
|
| 68 | 68 | params = params || {}; |
| 69 | 69 | focus = function () { |
| 70 | 70 | var focusContainer; |
| 71 | | if ( construct.extended( api.Panel ) && construct.expanded() ) { |
| 72 | | focusContainer = construct.container.find( '.control-panel-content:first' ); |
| | 71 | if ( construct.expanded && construct.expanded() ) { |
| | 72 | focusContainer = construct.container.find( 'ul:first' ); |
| 73 | 73 | } else { |
| 74 | 74 | focusContainer = construct.container; |
| 75 | 75 | } |
| 76 | | focusContainer.find( ':focusable:first' ).focus(); |
| 77 | | focusContainer[0].scrollIntoView( true ); |
| | 76 | |
| | 77 | // Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583 |
| | 78 | focusContainer.find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' ).first().focus(); |
| 78 | 79 | }; |
| 79 | 80 | if ( params.completeCallback ) { |
| 80 | 81 | completeCallback = params.completeCallback; |
| … |
… |
|
| 580 | 581 | * @param {Object} args |
| 581 | 582 | */ |
| 582 | 583 | onChangeExpanded: function ( expanded, args ) { |
| 583 | | var position, scroll, section = this, |
| | 584 | var section = this, |
| 584 | 585 | container = section.container.closest( '.wp-full-overlay-sidebar-content' ), |
| 585 | 586 | content = section.container.find( '.accordion-section-content' ), |
| 586 | 587 | overlay = section.container.closest( '.wp-full-overlay' ), |
| 587 | 588 | backBtn = section.container.find( '.customize-section-back' ), |
| 588 | 589 | sectionTitle = section.container.find( '.accordion-section-title' ).first(), |
| 589 | | expand; |
| | 590 | actions = $( '#customize-header-actions' ).height(), |
| | 591 | sizing, expand, position, scroll; |
| 590 | 592 | |
| 591 | 593 | if ( expanded && ! section.container.hasClass( 'open' ) ) { |
| 592 | 594 | |
| … |
… |
|
| 594 | 596 | expand = args.completeCallback; |
| 595 | 597 | } else { |
| 596 | 598 | container.scrollTop( 0 ); |
| 597 | | expand = function () { |
| | 599 | sizing = function() { |
| 598 | 600 | var matchMedia, offset; |
| 599 | 601 | matchMedia = window.matchMedia || window.msMatchMedia; |
| 600 | 602 | offset = 90; // 45px for customize header actions + 45px for footer actions. |
| … |
… |
|
| 603 | 605 | if ( matchMedia && matchMedia( '(max-width: 640px)' ).matches ) { |
| 604 | 606 | offset = 45; |
| 605 | 607 | } |
| 606 | | |
| | 608 | content.css( 'height', ( window.innerHeight - offset ) ); |
| | 609 | }; |
| | 610 | expand = function() { |
| 607 | 611 | section.container.addClass( 'open' ); |
| 608 | 612 | overlay.addClass( 'section-open' ); |
| 609 | 613 | position = content.offset().top; |
| 610 | 614 | scroll = container.scrollTop(); |
| 611 | | content.css( 'margin-top', ( 45 - position - scroll ) ); |
| 612 | | content.css( 'height', ( window.innerHeight - offset ) ); |
| | 615 | content.css( 'margin-top', ( actions - position - scroll ) ); |
| | 616 | sizing(); |
| 613 | 617 | sectionTitle.attr( 'tabindex', '-1' ); |
| 614 | 618 | backBtn.attr( 'tabindex', '0' ); |
| 615 | 619 | backBtn.focus(); |
| 616 | 620 | if ( args.completeCallback ) { |
| 617 | 621 | args.completeCallback(); |
| 618 | 622 | } |
| | 623 | |
| | 624 | // Fix the height after browser resize. |
| | 625 | $( window ).on( 'resize.customizer-section', _.debounce( sizing, 100 ) ); |
| | 626 | |
| | 627 | // Fix the top margin after reflow. |
| | 628 | api.bind( 'pane-contents-reflowed', _.debounce( function() { |
| | 629 | var offset = ( content.offset().top - actions ); |
| | 630 | if ( 0 < offset ) { |
| | 631 | content.css( 'margin-top', ( parseInt( content.css( 'margin-top' ), 10 ) - offset ) ); |
| | 632 | } |
| | 633 | }, 100 ) ); |
| 619 | 634 | }; |
| 620 | 635 | } |
| 621 | 636 | |
| … |
… |
|
| 639 | 654 | } else if ( ! expanded && section.container.hasClass( 'open' ) ) { |
| 640 | 655 | section.container.removeClass( 'open' ); |
| 641 | 656 | overlay.removeClass( 'section-open' ); |
| 642 | | content.css( 'margin-top', 'inherit' ); |
| | 657 | content.css( 'margin-top', '' ); |
| 643 | 658 | container.scrollTop( 0 ); |
| 644 | 659 | backBtn.attr( 'tabindex', '-1' ); |
| 645 | 660 | sectionTitle.attr( 'tabindex', '0' ); |
| … |
… |
|
| 647 | 662 | if ( args.completeCallback ) { |
| 648 | 663 | args.completeCallback(); |
| 649 | 664 | } |
| | 665 | $( window ).off( 'resize.customizer-section' ); |
| 650 | 666 | } else { |
| 651 | 667 | if ( args.completeCallback ) { |
| 652 | 668 | args.completeCallback(); |
| … |
… |
|
| 1234 | 1250 | topPanel = overlay.find( '#customize-theme-controls > ul > .accordion-section > .accordion-section-title' ), |
| 1235 | 1251 | backBtn = section.find( '.customize-panel-back' ), |
| 1236 | 1252 | panelTitle = section.find( '.accordion-section-title' ).first(), |
| 1237 | | content = section.find( '.control-panel-content' ); |
| | 1253 | content = section.find( '.control-panel-content' ), |
| | 1254 | actions = $( '#customize-header-actions' ).height(); |
| 1238 | 1255 | |
| 1239 | 1256 | if ( expanded ) { |
| 1240 | 1257 | |
| … |
… |
|
| 1254 | 1271 | content.parent().show(); |
| 1255 | 1272 | position = content.offset().top; |
| 1256 | 1273 | scroll = container.scrollTop(); |
| 1257 | | content.css( 'margin-top', ( $( '#customize-header-actions' ).height() - position - scroll ) ); |
| | 1274 | content.css( 'margin-top', ( actions - position - scroll ) ); |
| 1258 | 1275 | section.addClass( 'current-panel' ); |
| 1259 | 1276 | overlay.addClass( 'in-sub-panel' ); |
| 1260 | 1277 | container.scrollTop( 0 ); |
| … |
… |
|
| 1265 | 1282 | topPanel.attr( 'tabindex', '-1' ); |
| 1266 | 1283 | backBtn.attr( 'tabindex', '0' ); |
| 1267 | 1284 | backBtn.focus(); |
| | 1285 | |
| | 1286 | // Fix the top margin after reflow. |
| | 1287 | api.bind( 'pane-contents-reflowed', _.debounce( function() { |
| | 1288 | content.css( 'margin-top', ( parseInt( content.css( 'margin-top' ), 10 ) - ( content.offset().top - actions ) ) ); |
| | 1289 | }, 100 ) ); |
| 1268 | 1290 | } else { |
| 1269 | 1291 | siblings.removeClass( 'open' ); |
| 1270 | 1292 | section.removeClass( 'current-panel' ); |
| … |
… |
|
| 2602 | 2624 | _( constructs ).each( function ( activeConstructs, type ) { |
| 2603 | 2625 | api[ type ].each( function ( construct, id ) { |
| 2604 | 2626 | var active = !! ( activeConstructs && activeConstructs[ id ] ); |
| 2605 | | construct.active( active ); |
| | 2627 | if ( active ) { |
| | 2628 | construct.activate(); |
| | 2629 | } else { |
| | 2630 | construct.deactivate(); |
| | 2631 | } |
| 2606 | 2632 | } ); |
| 2607 | 2633 | } ); |
| 2608 | 2634 | } ); |