diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
index 6d48967..1e5103a 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 | } |
… |
… |
|
581 | 581 | * @param {Object} args |
582 | 582 | */ |
583 | 583 | onChangeExpanded: function ( expanded, args ) { |
584 | | var position, scroll, section = this, |
| 584 | var section = this, |
585 | 585 | container = section.container.closest( '.wp-full-overlay-sidebar-content' ), |
586 | 586 | content = section.container.find( '.accordion-section-content' ), |
587 | 587 | overlay = section.container.closest( '.wp-full-overlay' ), |
588 | 588 | backBtn = section.container.find( '.customize-section-back' ), |
589 | 589 | sectionTitle = section.container.find( '.accordion-section-title' ).first(), |
590 | | expand; |
| 590 | headerActionsHeight = $( '#customize-header-actions' ).height(), |
| 591 | resizeContentHeight, expand, position, scroll; |
591 | 592 | |
592 | 593 | if ( expanded && ! section.container.hasClass( 'open' ) ) { |
593 | 594 | |
… |
… |
|
595 | 596 | expand = args.completeCallback; |
596 | 597 | } else { |
597 | 598 | container.scrollTop( 0 ); |
598 | | expand = function () { |
| 599 | resizeContentHeight = function() { |
599 | 600 | var matchMedia, offset; |
600 | 601 | matchMedia = window.matchMedia || window.msMatchMedia; |
601 | 602 | offset = 90; // 45px for customize header actions + 45px for footer actions. |
… |
… |
|
604 | 605 | if ( matchMedia && matchMedia( '(max-width: 640px)' ).matches ) { |
605 | 606 | offset = 45; |
606 | 607 | } |
607 | | |
| 608 | content.css( 'height', ( window.innerHeight - offset ) ); |
| 609 | }; |
| 610 | expand = function() { |
608 | 611 | section.container.addClass( 'open' ); |
609 | 612 | overlay.addClass( 'section-open' ); |
610 | 613 | position = content.offset().top; |
611 | 614 | scroll = container.scrollTop(); |
612 | | content.css( 'margin-top', ( 45 - position - scroll ) ); |
613 | | content.css( 'height', ( window.innerHeight - offset ) ); |
| 615 | content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); |
| 616 | resizeContentHeight(); |
614 | 617 | sectionTitle.attr( 'tabindex', '-1' ); |
615 | 618 | backBtn.attr( 'tabindex', '0' ); |
616 | 619 | backBtn.focus(); |
617 | 620 | if ( args.completeCallback ) { |
618 | 621 | args.completeCallback(); |
619 | 622 | } |
| 623 | |
| 624 | // Fix the height after browser resize. |
| 625 | $( window ).on( 'resize.customizer-section', _.debounce( resizeContentHeight, 100 ) ); |
| 626 | |
| 627 | // Fix the top margin after reflow. |
| 628 | api.bind( 'pane-contents-reflowed', _.debounce( function() { |
| 629 | var offset = ( content.offset().top - headerActionsHeight ); |
| 630 | if ( 0 < offset ) { |
| 631 | content.css( 'margin-top', ( parseInt( content.css( 'margin-top' ), 10 ) - offset ) ); |
| 632 | } |
| 633 | }, 100 ) ); |
620 | 634 | }; |
621 | 635 | } |
622 | 636 | |
… |
… |
|
640 | 654 | } else if ( ! expanded && section.container.hasClass( 'open' ) ) { |
641 | 655 | section.container.removeClass( 'open' ); |
642 | 656 | overlay.removeClass( 'section-open' ); |
643 | | content.css( 'margin-top', 'inherit' ); |
| 657 | content.css( 'margin-top', '' ); |
644 | 658 | container.scrollTop( 0 ); |
645 | 659 | backBtn.attr( 'tabindex', '-1' ); |
646 | 660 | sectionTitle.attr( 'tabindex', '0' ); |
… |
… |
|
648 | 662 | if ( args.completeCallback ) { |
649 | 663 | args.completeCallback(); |
650 | 664 | } |
| 665 | $( window ).off( 'resize.customizer-section' ); |
651 | 666 | } else { |
652 | 667 | if ( args.completeCallback ) { |
653 | 668 | args.completeCallback(); |
… |
… |
|
1235 | 1250 | topPanel = overlay.find( '#customize-theme-controls > ul > .accordion-section > .accordion-section-title' ), |
1236 | 1251 | backBtn = section.find( '.customize-panel-back' ), |
1237 | 1252 | panelTitle = section.find( '.accordion-section-title' ).first(), |
1238 | | content = section.find( '.control-panel-content' ); |
| 1253 | content = section.find( '.control-panel-content' ), |
| 1254 | headerActionsHeight = $( '#customize-header-actions' ).height(); |
1239 | 1255 | |
1240 | 1256 | if ( expanded ) { |
1241 | 1257 | |
… |
… |
|
1255 | 1271 | content.parent().show(); |
1256 | 1272 | position = content.offset().top; |
1257 | 1273 | scroll = container.scrollTop(); |
1258 | | content.css( 'margin-top', ( $( '#customize-header-actions' ).height() - position - scroll ) ); |
| 1274 | content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); |
1259 | 1275 | section.addClass( 'current-panel' ); |
1260 | 1276 | overlay.addClass( 'in-sub-panel' ); |
1261 | 1277 | container.scrollTop( 0 ); |
… |
… |
|
1266 | 1282 | topPanel.attr( 'tabindex', '-1' ); |
1267 | 1283 | backBtn.attr( 'tabindex', '0' ); |
1268 | 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 - headerActionsHeight ) ) ); |
| 1289 | }, 100 ) ); |
1269 | 1290 | } else { |
1270 | 1291 | siblings.removeClass( 'open' ); |
1271 | 1292 | section.removeClass( 'current-panel' ); |
… |
… |
|
2603 | 2624 | _( constructs ).each( function ( activeConstructs, type ) { |
2604 | 2625 | api[ type ].each( function ( construct, id ) { |
2605 | 2626 | var active = !! ( activeConstructs && activeConstructs[ id ] ); |
2606 | | construct.active( active ); |
| 2627 | if ( active ) { |
| 2628 | construct.activate(); |
| 2629 | } else { |
| 2630 | construct.deactivate(); |
| 2631 | } |
2607 | 2632 | } ); |
2608 | 2633 | } ); |
2609 | 2634 | } ); |