Make WordPress Core

Ticket #33220: 33220.6.diff

File 33220.6.diff, 3.7 KB (added by valendesigns, 9 years ago)
  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index 739b962..9782161 100644
     
    6868                params = params || {};
    6969                focus = function () {
    7070                        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' );
    7373                        } else {
    7474                                focusContainer = construct.container;
    7575                        }
    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();
    7879                };
    7980                if ( params.completeCallback ) {
    8081                        completeCallback = params.completeCallback;
     
    586587                                overlay = section.container.closest( '.wp-full-overlay' ),
    587588                                backBtn = section.container.find( '.customize-section-back' ),
    588589                                sectionTitle = section.container.find( '.accordion-section-title' ).first(),
    589                                 expand;
     590                                expand, sizing;
    590591
    591592                        if ( expanded && ! section.container.hasClass( 'open' ) ) {
    592593
     
    594595                                        expand = args.completeCallback;
    595596                                } else {
    596597                                        container.scrollTop( 0 );
    597                                         expand = function () {
     598                                        sizing = function() {
    598599                                                var matchMedia, offset;
    599600                                                matchMedia = window.matchMedia || window.msMatchMedia;
    600601                                                offset = 90; // 45px for customize header actions + 45px for footer actions.
     
    603604                                                if ( matchMedia && matchMedia( '(max-width: 640px)' ).matches ) {
    604605                                                        offset = 45;
    605606                                                }
    606 
    607                                                 section.container.addClass( 'open' );
    608                                                 overlay.addClass( 'section-open' );
    609607                                                position = content.offset().top;
    610608                                                scroll = container.scrollTop();
    611                                                 content.css( 'margin-top', ( 45 - position - scroll ) );
     609                                                content.css( 'margin-top', ( $( '#customize-header-actions' ).height() - position - scroll ) );
    612610                                                content.css( 'height', ( window.innerHeight - offset ) );
     611                                        };
     612                                        expand = function () {
     613                                                section.container.addClass( 'open' );
     614                                                overlay.addClass( 'section-open' );
    613615                                                sectionTitle.attr( 'tabindex', '-1' );
    614616                                                backBtn.attr( 'tabindex', '0' );
     617                                                sizing();
    615618                                                backBtn.focus();
    616619                                                if ( args.completeCallback ) {
    617620                                                        args.completeCallback();
    618621                                                }
     622                                                $( window ).on( 'resize.customizer-section', _.debounce( sizing, 100 ) );
     623                                                api.bind( 'pane-contents-reflowed', sizing );
    619624                                        };
    620625                                }
    621626
     
    639644                        } else if ( ! expanded && section.container.hasClass( 'open' ) ) {
    640645                                section.container.removeClass( 'open' );
    641646                                overlay.removeClass( 'section-open' );
    642                                 content.css( 'margin-top', 'inherit' );
     647                                content.css( 'margin-top', '' );
    643648                                container.scrollTop( 0 );
    644649                                backBtn.attr( 'tabindex', '-1' );
    645650                                sectionTitle.attr( 'tabindex', '0' );
     
    647652                                if ( args.completeCallback ) {
    648653                                        args.completeCallback();
    649654                                }
     655                                $( window ).off( 'resize.customizer-section' );
    650656                        } else {
    651657                                if ( args.completeCallback ) {
    652658                                        args.completeCallback();
     
    26022608                                _( constructs ).each( function ( activeConstructs, type ) {
    26032609                                        api[ type ].each( function ( construct, id ) {
    26042610                                                var active = !! ( activeConstructs && activeConstructs[ id ] );
    2605                                                 construct.active( active );
     2611                                                if ( active ) {
     2612                                                        construct.activate();
     2613                                                } else {
     2614                                                        construct.deactivate();
     2615                                                }
    26062616                                        } );
    26072617                                } );
    26082618                        } );