Ticket #33220: 33220.diff
File 33220.diff, 3.2 KB (added by , 10 years ago) |
---|
-
wp-admin/js/customize-controls.js
61 61 * 62 62 * @param {Object} [params] 63 63 * @param {Callback} [params.completeCallback] 64 * @param {noScroll} [params.noScroll] 64 65 */ 65 66 focus = function ( params ) { 66 67 var construct, completeCallback, focus; … … 74 75 focusContainer = construct.container; 75 76 } 76 77 focusContainer.find( ':focusable:first' ).focus(); 77 focusContainer[0].scrollIntoView( true ); 78 if ( ! params.noScroll ) { 79 focusContainer[0].scrollIntoView( true ); 80 } 78 81 }; 79 82 if ( params.completeCallback ) { 80 83 completeCallback = params.completeCallback; … … 586 589 overlay = section.container.closest( '.wp-full-overlay' ), 587 590 backBtn = section.container.find( '.customize-section-back' ), 588 591 sectionTitle = section.container.find( '.accordion-section-title' ).first(), 589 expand ;592 expand, sizing; 590 593 591 594 if ( expanded && ! section.container.hasClass( 'open' ) ) { 592 595 … … 594 597 expand = args.completeCallback; 595 598 } else { 596 599 container.scrollTop( 0 ); 597 expand = function() {600 sizing = function() { 598 601 var matchMedia, offset; 599 602 matchMedia = window.matchMedia || window.msMatchMedia; 600 603 offset = 90; // 45px for customize header actions + 45px for footer actions. … … 603 606 if ( matchMedia && matchMedia( '(max-width: 640px)' ).matches ) { 604 607 offset = 45; 605 608 } 606 609 content.css( 'height', ( window.innerHeight - offset ) ); 610 }; 611 expand = function () { 607 612 section.container.addClass( 'open' ); 608 613 overlay.addClass( 'section-open' ); 614 sectionTitle.attr( 'tabindex', '-1' ); 615 backBtn.attr( 'tabindex', '0' ); 616 sizing(); 609 617 position = content.offset().top; 610 618 scroll = container.scrollTop(); 611 619 content.css( 'margin-top', ( 45 - position - scroll ) ); 612 content.css( 'height', ( window.innerHeight - offset ) );613 sectionTitle.attr( 'tabindex', '-1' );614 backBtn.attr( 'tabindex', '0' );615 620 backBtn.focus(); 616 621 if ( args.completeCallback ) { 617 622 args.completeCallback(); 618 623 } 624 $( window ).on( 'resize.customizer-section', _.debounce( sizing, 100 ) ); 619 625 }; 620 626 } 621 627 … … 639 645 } else if ( ! expanded && section.container.hasClass( 'open' ) ) { 640 646 section.container.removeClass( 'open' ); 641 647 overlay.removeClass( 'section-open' ); 642 content.css( 'margin-top', ' inherit' );648 content.css( 'margin-top', '' ); 643 649 container.scrollTop( 0 ); 644 650 backBtn.attr( 'tabindex', '-1' ); 645 651 sectionTitle.attr( 'tabindex', '0' ); … … 647 653 if ( args.completeCallback ) { 648 654 args.completeCallback(); 649 655 } 656 $( window ).off( 'resize.customizer-section' ); 650 657 } else { 651 658 if ( args.completeCallback ) { 652 659 args.completeCallback(); … … 3239 3246 instance.deferred.embedded.done( function () { 3240 3247 // Wait until the preview has activated and so active panels, sections, controls have been set 3241 3248 api.previewer.deferred.active.done( function () { 3242 instance.focus(); 3249 instance.focus({ 3250 noScroll: true 3251 }); 3243 3252 }); 3244 3253 }); 3245 3254 }