Make WordPress Core

Ticket #33220: 33220.3.diff

File 33220.3.diff, 2.9 KB (added by valendesigns, 10 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..00bd99d 100644
     
    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 ) );
    619623                                        };
    620624                                }
    621625
     
    639643                        } else if ( ! expanded && section.container.hasClass( 'open' ) ) {
    640644                                section.container.removeClass( 'open' );
    641645                                overlay.removeClass( 'section-open' );
    642                                 content.css( 'margin-top', 'inherit' );
     646                                content.css( 'margin-top', '' );
    643647                                container.scrollTop( 0 );
    644648                                backBtn.attr( 'tabindex', '-1' );
    645649                                sectionTitle.attr( 'tabindex', '0' );
     
    647651                                if ( args.completeCallback ) {
    648652                                        args.completeCallback();
    649653                                }
     654                                $( window ).off( 'resize.customizer-section' );
    650655                        } else {
    651656                                if ( args.completeCallback ) {
    652657                                        args.completeCallback();