Make WordPress Core

Ticket #33220: 33220.diff

File 33220.diff, 3.2 KB (added by mattwiebe, 10 years ago)
  • wp-admin/js/customize-controls.js

     
    6161         *
    6262         * @param {Object}   [params]
    6363         * @param {Callback} [params.completeCallback]
     64         * @param {noScroll} [params.noScroll]
    6465         */
    6566        focus = function ( params ) {
    6667                var construct, completeCallback, focus;
     
    7475                                focusContainer = construct.container;
    7576                        }
    7677                        focusContainer.find( ':focusable:first' ).focus();
    77                         focusContainer[0].scrollIntoView( true );
     78                        if ( ! params.noScroll ) {
     79                                focusContainer[0].scrollIntoView( true );
     80                        }
    7881                };
    7982                if ( params.completeCallback ) {
    8083                        completeCallback = params.completeCallback;
     
    586589                                overlay = section.container.closest( '.wp-full-overlay' ),
    587590                                backBtn = section.container.find( '.customize-section-back' ),
    588591                                sectionTitle = section.container.find( '.accordion-section-title' ).first(),
    589                                 expand;
     592                                expand, sizing;
    590593
    591594                        if ( expanded && ! section.container.hasClass( 'open' ) ) {
    592595
     
    594597                                        expand = args.completeCallback;
    595598                                } else {
    596599                                        container.scrollTop( 0 );
    597                                         expand = function () {
     600                                        sizing = function() {
    598601                                                var matchMedia, offset;
    599602                                                matchMedia = window.matchMedia || window.msMatchMedia;
    600603                                                offset = 90; // 45px for customize header actions + 45px for footer actions.
     
    603606                                                if ( matchMedia && matchMedia( '(max-width: 640px)' ).matches ) {
    604607                                                        offset = 45;
    605608                                                }
    606 
     609                                                content.css( 'height', ( window.innerHeight - offset ) );
     610                                        };
     611                                        expand = function () {
    607612                                                section.container.addClass( 'open' );
    608613                                                overlay.addClass( 'section-open' );
     614                                                sectionTitle.attr( 'tabindex', '-1' );
     615                                                backBtn.attr( 'tabindex', '0' );
     616                                                sizing();
    609617                                                position = content.offset().top;
    610618                                                scroll = container.scrollTop();
    611619                                                content.css( 'margin-top', ( 45 - position - scroll ) );
    612                                                 content.css( 'height', ( window.innerHeight - offset ) );
    613                                                 sectionTitle.attr( 'tabindex', '-1' );
    614                                                 backBtn.attr( 'tabindex', '0' );
    615620                                                backBtn.focus();
    616621                                                if ( args.completeCallback ) {
    617622                                                        args.completeCallback();
    618623                                                }
     624                                                $( window ).on( 'resize.customizer-section', _.debounce( sizing, 100 ) );
    619625                                        };
    620626                                }
    621627
     
    639645                        } else if ( ! expanded && section.container.hasClass( 'open' ) ) {
    640646                                section.container.removeClass( 'open' );
    641647                                overlay.removeClass( 'section-open' );
    642                                 content.css( 'margin-top', 'inherit' );
     648                                content.css( 'margin-top', '' );
    643649                                container.scrollTop( 0 );
    644650                                backBtn.attr( 'tabindex', '-1' );
    645651                                sectionTitle.attr( 'tabindex', '0' );
     
    647653                                if ( args.completeCallback ) {
    648654                                        args.completeCallback();
    649655                                }
     656                                $( window ).off( 'resize.customizer-section' );
    650657                        } else {
    651658                                if ( args.completeCallback ) {
    652659                                        args.completeCallback();
     
    32393246                                instance.deferred.embedded.done( function () {
    32403247                                        // Wait until the preview has activated and so active panels, sections, controls have been set
    32413248                                        api.previewer.deferred.active.done( function () {
    3242                                                 instance.focus();
     3249                                                instance.focus({
     3250                                                        noScroll: true
     3251                                                });
    32433252                                        });
    32443253                                });
    32453254                        }