Ticket #33220: 33220.7.diff
File 33220.7.diff, 3.7 KB (added by , 10 years ago) |
---|
-
wp-admin/js/customize-controls.js
68 68 params = params || {}; 69 69 focus = function () { 70 70 var focusContainer; 71 if ( construct.ex tended( 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 } 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(); 78 79 }; 79 80 if ( params.completeCallback ) { 80 81 completeCallback = params.completeCallback; … … 586 587 overlay = section.container.closest( '.wp-full-overlay' ), 587 588 backBtn = section.container.find( '.customize-section-back' ), 588 589 sectionTitle = section.container.find( '.accordion-section-title' ).first(), 589 expand ;590 expand, sizing; 590 591 591 592 if ( expanded && ! section.container.hasClass( 'open' ) ) { 592 593 … … 594 595 expand = args.completeCallback; 595 596 } else { 596 597 container.scrollTop( 0 ); 597 expand = function() {598 sizing = function() { 598 599 var matchMedia, offset; 599 600 matchMedia = window.matchMedia || window.msMatchMedia; 600 601 offset = 90; // 45px for customize header actions + 45px for footer actions. … … 603 604 if ( matchMedia && matchMedia( '(max-width: 640px)' ).matches ) { 604 605 offset = 45; 605 606 } 606 607 content.css( 'height', ( window.innerHeight - offset ) ); 608 }; 609 expand = function () { 607 610 section.container.addClass( 'open' ); 608 611 overlay.addClass( 'section-open' ); 612 sectionTitle.attr( 'tabindex', '-1' ); 613 backBtn.attr( 'tabindex', '0' ); 609 614 position = content.offset().top; 610 615 scroll = container.scrollTop(); 611 content.css( 'margin-top', ( 45 - position - scroll ) ); 612 content.css( 'height', ( window.innerHeight - offset ) ); 613 sectionTitle.attr( 'tabindex', '-1' ); 614 backBtn.attr( 'tabindex', '0' ); 616 content.css( 'margin-top', ( $( '#customize-header-actions' ).height() - position - scroll ) ); 617 sizing(); 615 618 backBtn.focus(); 616 619 if ( args.completeCallback ) { 617 620 args.completeCallback(); 618 621 } 622 $( window ).on( 'resize.customizer-section', _.debounce( sizing, 100 ) ); 623 api.bind( 'pane-contents-reflowed', sizing ); 619 624 }; 620 625 } 621 626 … … 639 644 } else if ( ! expanded && section.container.hasClass( 'open' ) ) { 640 645 section.container.removeClass( 'open' ); 641 646 overlay.removeClass( 'section-open' ); 642 content.css( 'margin-top', ' inherit' );647 content.css( 'margin-top', '' ); 643 648 container.scrollTop( 0 ); 644 649 backBtn.attr( 'tabindex', '-1' ); 645 650 sectionTitle.attr( 'tabindex', '0' ); … … 647 652 if ( args.completeCallback ) { 648 653 args.completeCallback(); 649 654 } 655 $( window ).off( 'resize.customizer-section' ); 650 656 } else { 651 657 if ( args.completeCallback ) { 652 658 args.completeCallback(); … … 2602 2608 _( constructs ).each( function ( activeConstructs, type ) { 2603 2609 api[ type ].each( function ( construct, id ) { 2604 2610 var active = !! ( activeConstructs && activeConstructs[ id ] ); 2605 construct.active( active ); 2611 if ( active ) { 2612 construct.activate(); 2613 } else { 2614 construct.deactivate(); 2615 } 2606 2616 } ); 2607 2617 } ); 2608 2618 } );