287 focusableElements.first().focus(); |
287 focusableElements.first().focus(); |
288 } else { |
288 } else { |
289 collection.focusContainer.focus(); |
289 collection.focusContainer.focus(); |
290 } |
290 } |
291 } else if ( collection.previousActiveElement ) { |
291 } else if ( collection.previousActiveElement ) { |
292 $( collection.previousActiveElement ).focus(); |
292 $( collection.previousActiveElement ).trigger( 'focus' ); |
293 collection.previousActiveElement = null; |
293 collection.previousActiveElement = null; |
294 } |
294 } |
295 |
295 |
296 collection.previousNotifications = notifications; |
296 collection.previousNotifications = notifications; |
297 collection.previousContainer = collection.container; |
297 collection.previousContainer = collection.container; |
1340 template = wp.template( container.templateSelector ); |
1340 template = wp.template( container.templateSelector ); |
1341 } else { |
1341 } else { |
1342 template = wp.template( 'customize-' + container.containerType + '-default' ); |
1342 template = wp.template( 'customize-' + container.containerType + '-default' ); |
1343 } |
1343 } |
1344 if ( template && container.container ) { |
1344 if ( template && container.container ) { |
1345 return $.trim( template( _.extend( |
1345 return template( _.extend( |
1346 { id: container.id }, |
1346 { id: container.id }, |
1347 container.params |
1347 container.params |
1348 ) ) ); |
1348 ) ).toString().trim(); |
1349 } |
1349 } |
1350 |
1350 |
1351 return '<li></li>'; |
1351 return '<li></li>'; |
1352 }, |
1352 }, |
1353 |
1353 |
1590 if ( expanded && ! content.hasClass( 'open' ) ) { |
1590 if ( expanded && ! content.hasClass( 'open' ) ) { |
1591 |
1591 |
1592 if ( args.unchanged ) { |
1592 if ( args.unchanged ) { |
1593 expand = args.completeCallback; |
1593 expand = args.completeCallback; |
1594 } else { |
1594 } else { |
1595 expand = $.proxy( function() { |
1595 expand = function() { |
1596 section._animateChangeExpanded( function() { |
1596 section._animateChangeExpanded( function() { |
1597 sectionTitle.attr( 'tabindex', '-1' ); |
1597 sectionTitle.attr( 'tabindex', '-1' ); |
1598 backBtn.attr( 'tabindex', '0' ); |
1598 backBtn.attr( 'tabindex', '0' ); |
1599 |
1599 |
1600 backBtn.focus(); |
1600 backBtn.trigger( 'focus' ); |
1601 content.css( 'top', '' ); |
1601 content.css( 'top', '' ); |
1602 container.scrollTop( 0 ); |
1602 container.scrollTop( 0 ); |
1603 |
1603 |
1604 if ( args.completeCallback ) { |
1604 if ( args.completeCallback ) { |
1605 args.completeCallback(); |
1605 args.completeCallback(); |
1607 } ); |
1607 } ); |
1608 |
1608 |
1609 content.addClass( 'open' ); |
1609 content.addClass( 'open' ); |
1610 overlay.addClass( 'section-open' ); |
1610 overlay.addClass( 'section-open' ); |
1611 api.state( 'expandedSection' ).set( section ); |
1611 api.state( 'expandedSection' ).set( section ); |
1612 }, this ); |
1612 }.bind( this ); |
1613 } |
1613 } |
1614 |
1614 |
1615 if ( ! args.allowMultiple ) { |
1615 if ( ! args.allowMultiple ) { |
1616 api.section.each( function ( otherSection ) { |
1616 api.section.each( function ( otherSection ) { |
1617 if ( otherSection !== section ) { |
1617 if ( otherSection !== section ) { |
1643 } |
1643 } |
1644 section._animateChangeExpanded( function() { |
1644 section._animateChangeExpanded( function() { |
1645 backBtn.attr( 'tabindex', '-1' ); |
1645 backBtn.attr( 'tabindex', '-1' ); |
1646 sectionTitle.attr( 'tabindex', '0' ); |
1646 sectionTitle.attr( 'tabindex', '0' ); |
1647 |
1647 |
1648 sectionTitle.focus(); |
1648 sectionTitle.trigger( 'focus' ); |
1649 content.css( 'top', '' ); |
1649 content.css( 'top', '' ); |
1650 |
1650 |
1651 if ( args.completeCallback ) { |
1651 if ( args.completeCallback ) { |
1652 args.completeCallback(); |
1652 args.completeCallback(); |
1653 } |
1653 } |
2694 if ( expanded && ! content.hasClass( 'open' ) ) { |
2694 if ( expanded && ! content.hasClass( 'open' ) ) { |
2695 |
2695 |
2696 if ( args.unchanged ) { |
2696 if ( args.unchanged ) { |
2697 expand = args.completeCallback; |
2697 expand = args.completeCallback; |
2698 } else { |
2698 } else { |
2699 expand = $.proxy( function() { |
2699 expand = function() { |
2700 section._animateChangeExpanded( function() { |
2700 section._animateChangeExpanded( function() { |
2701 sectionTitle.attr( 'tabindex', '-1' ); |
2701 sectionTitle.attr( 'tabindex', '-1' ); |
2702 backBtn.attr( 'tabindex', '0' ); |
2702 backBtn.attr( 'tabindex', '0' ); |
2703 |
2703 |
2704 backBtn.focus(); |
2704 backBtn.trigger( 'focus' ); |
2705 content.css( 'top', '' ); |
2705 content.css( 'top', '' ); |
2706 container.scrollTop( 0 ); |
2706 container.scrollTop( 0 ); |
2707 |
2707 |
2708 if ( args.completeCallback ) { |
2708 if ( args.completeCallback ) { |
2709 args.completeCallback(); |
2709 args.completeCallback(); |
2710 } |
2710 } |
2711 } ); |
2711 } ); |
2712 |
2712 |
2713 content.addClass( 'open' ); |
2713 content.addClass( 'open' ); |
2714 }, this ); |
2714 }.bind( this ); |
2715 } |
2715 } |
2716 |
2716 |
2717 if ( section.panel() ) { |
2717 if ( section.panel() ) { |
2718 api.panel( section.panel() ).expand({ |
2718 api.panel( section.panel() ).expand({ |
2719 duration: args.duration, |
2719 duration: args.duration, |
2732 } |
2732 } |
2733 section._animateChangeExpanded( function() { |
2733 section._animateChangeExpanded( function() { |
2734 backBtn.attr( 'tabindex', '-1' ); |
2734 backBtn.attr( 'tabindex', '-1' ); |
2735 sectionTitle.attr( 'tabindex', '0' ); |
2735 sectionTitle.attr( 'tabindex', '0' ); |
2736 |
2736 |
2737 sectionTitle.focus(); |
2737 sectionTitle.trigger( 'focus' ); |
2738 content.css( 'top', '' ); |
2738 content.css( 'top', '' ); |
2739 |
2739 |
2740 if ( args.completeCallback ) { |
2740 if ( args.completeCallback ) { |
2741 args.completeCallback(); |
2741 args.completeCallback(); |
2742 } |
2742 } |
2954 } else { |
2954 } else { |
2955 panel._animateChangeExpanded( function() { |
2955 panel._animateChangeExpanded( function() { |
2956 topPanel.attr( 'tabindex', '-1' ); |
2956 topPanel.attr( 'tabindex', '-1' ); |
2957 backBtn.attr( 'tabindex', '0' ); |
2957 backBtn.attr( 'tabindex', '0' ); |
2958 |
2958 |
2959 backBtn.focus(); |
2959 backBtn.trigger( 'focus' ); |
2960 accordionSection.css( 'top', '' ); |
2960 accordionSection.css( 'top', '' ); |
2961 container.scrollTop( 0 ); |
2961 container.scrollTop( 0 ); |
2962 |
2962 |
2963 if ( args.completeCallback ) { |
2963 if ( args.completeCallback ) { |
2964 args.completeCallback(); |
2964 args.completeCallback(); |
3698 // Wait for the section to be ready/initialized. |
3698 // Wait for the section to be ready/initialized. |
3699 section.deferred.embedded.done( function () { |
3699 section.deferred.embedded.done( function () { |
3700 parentContainer = ( section.contentContainer.is( 'ul' ) ) ? section.contentContainer : section.contentContainer.find( 'ul:first' ); |
3700 parentContainer = ( section.contentContainer.is( 'ul' ) ) ? section.contentContainer : section.contentContainer.find( 'ul:first' ); |
3701 if ( ! control.container.parent().is( parentContainer ) ) { |
3701 if ( ! control.container.parent().is( parentContainer ) ) { |
3702 parentContainer.append( control.container ); |
3702 parentContainer.append( control.container ); |
3703 control.renderContent(); |
|
3704 } |
3703 } |
|
3704 control.renderContent(); |
3705 control.deferred.embedded.resolve(); |
3705 control.deferred.embedded.resolve(); |
3706 }); |
3706 }); |
3707 }); |
3707 }); |
3708 }; |
3708 }; |
3709 control.section.bind( inject ); |
3709 control.section.bind( inject ); |
3872 control.notificationsTemplate = wp.template( 'customize-control-notifications' ); |
3872 control.notificationsTemplate = wp.template( 'customize-control-notifications' ); |
3873 } |
3873 } |
3874 |
3874 |
3875 control.container.toggleClass( 'has-notifications', 0 !== notifications.length ); |
3875 control.container.toggleClass( 'has-notifications', 0 !== notifications.length ); |
3876 control.container.toggleClass( 'has-error', hasError ); |
3876 control.container.toggleClass( 'has-error', hasError ); |
3877 container.empty().append( $.trim( |
3877 container.empty().append( |
3878 control.notificationsTemplate( { notifications: notifications, altNotice: Boolean( control.altNotice ) } ) |
3878 control.notificationsTemplate( { notifications: notifications, altNotice: Boolean( control.altNotice ) } ).trim() |
3879 ) ); |
3879 ); |
3880 }, |
3880 }, |
3881 |
3881 |
3882 /** |
3882 /** |
3883 * Normal controls do not expand, so just expand its parent |
3883 * Normal controls do not expand, so just expand its parent |
3884 * |
3884 * |
4483 var x, y, radioInput, inputValue; |
4483 var x, y, radioInput, inputValue; |
4484 x = control.settings.x.get(); |
4484 x = control.settings.x.get(); |
4485 y = control.settings.y.get(); |
4485 y = control.settings.y.get(); |
4486 inputValue = String( x ) + ' ' + String( y ); |
4486 inputValue = String( x ) + ' ' + String( y ); |
4487 radioInput = control.container.find( 'input[name="background-position"][value="' + inputValue + '"]' ); |
4487 radioInput = control.container.find( 'input[name="background-position"][value="' + inputValue + '"]' ); |
4488 radioInput.click(); |
4488 radioInput.trigger( 'click' ); |
4489 } ); |
4489 } ); |
4490 control.settings.x.bind( updateRadios ); |
4490 control.settings.x.bind( updateRadios ); |
4491 control.settings.y.bind( updateRadios ); |
4491 control.settings.y.bind( updateRadios ); |
4492 |
4492 |
4493 updateRadios(); // Set initial UI. |
4493 updateRadios(); // Set initial UI. |
5450 var control = this, controls, controlIndex, section; |
5450 var control = this, controls, controlIndex, section; |
5451 section = api.section( control.section() ); |
5451 section = api.section( control.section() ); |
5452 controls = section.controls(); |
5452 controls = section.controls(); |
5453 controlIndex = controls.indexOf( control ); |
5453 controlIndex = controls.indexOf( control ); |
5454 if ( controls.length === controlIndex + 1 ) { |
5454 if ( controls.length === controlIndex + 1 ) { |
5455 $( '#customize-footer-actions .collapse-sidebar' ).focus(); |
5455 $( '#customize-footer-actions .collapse-sidebar' ).trigger( 'focus' ); |
5456 } else { |
5456 } else { |
5457 controls[ controlIndex + 1 ].container.find( ':focusable:first' ).focus(); |
5457 controls[ controlIndex + 1 ].container.find( ':focusable:first' ).focus(); |
5458 } |
5458 } |
5459 }, |
5459 }, |
5460 |
5460 |
6334 name: key, |
6334 name: key, |
6335 value: value |
6335 value: value |
6336 } ) ); |
6336 } ) ); |
6337 } ); |
6337 } ); |
6338 previewFrame.container.append( form ); |
6338 previewFrame.container.append( form ); |
6339 form.submit(); |
6339 form.trigger( 'submit' ); |
6340 form.remove(); // No need to keep the form around after submitted. |
6340 form.remove(); // No need to keep the form around after submitted. |
6341 } |
6341 } |
6342 |
6342 |
6343 previewFrame.bind( 'iframe-loading-error', function( error ) { |
6343 previewFrame.bind( 'iframe-loading-error', function( error ) { |
6344 previewFrame.iframe.remove(); |
6344 previewFrame.iframe.remove(); |
7079 section.active.callbacks.fireWith( section.active, [ value, value ] ); |
7079 section.active.callbacks.fireWith( section.active, [ value, value ] ); |
7080 } ); |
7080 } ); |
7081 |
7081 |
7082 // Restore focus if there was a reflow and there was an active (focused) element. |
7082 // Restore focus if there was a reflow and there was an active (focused) element. |
7083 if ( wasReflowed && activeElement ) { |
7083 if ( wasReflowed && activeElement ) { |
7084 activeElement.focus(); |
7084 activeElement.trigger( 'focus' ); |
7085 } |
7085 } |
7086 api.trigger( 'pane-contents-reflowed' ); |
7086 api.trigger( 'pane-contents-reflowed' ); |
7087 }, api ); |
7087 }, api ); |
7088 |
7088 |
7089 // Define state values. |
7089 // Define state values. |
8395 } else { |
8395 } else { |
8396 api.previewer.previewUrl( api.settings.url.home ); |
8396 api.previewer.previewUrl( api.settings.url.home ); |
8397 } |
8397 } |
8398 |
8398 |
8399 // Button bindings. |
8399 // Button bindings. |
8400 saveBtn.click( function( event ) { |
8400 saveBtn.on( 'click', function( event ) { |
8401 api.previewer.save(); |
8401 api.previewer.save(); |
8402 event.preventDefault(); |
8402 event.preventDefault(); |
8403 }).keydown( function( event ) { |
8403 }).on( 'keydown', function( event ) { |
8404 if ( 9 === event.which ) { // Tab. |
8404 if ( 9 === event.which ) { // Tab. |
8405 return; |
8405 return; |
8406 } |
8406 } |
8407 if ( 13 === event.which ) { // Enter. |
8407 if ( 13 === event.which ) { // Enter. |
8408 api.previewer.save(); |
8408 api.previewer.save(); |
8409 } |
8409 } |
8410 event.preventDefault(); |
8410 event.preventDefault(); |
8411 }); |
8411 }); |
8412 |
8412 |
8413 closeBtn.keydown( function( event ) { |
8413 closeBtn.on( 'keydown', function( event ) { |
8414 if ( 9 === event.which ) { // Tab. |
8414 if ( 9 === event.which ) { // Tab. |
8415 return; |
8415 return; |
8416 } |
8416 } |
8417 if ( 13 === event.which ) { // Enter. |
8417 if ( 13 === event.which ) { // Enter. |
8418 this.click(); |
8418 this.click(); |
8447 /* |
8447 /* |
8448 * Abort if the event target is not the body (the default) and not inside of #customize-controls. |
8448 * Abort if the event target is not the body (the default) and not inside of #customize-controls. |
8449 * This ensures that ESC meant to collapse a modal dialog or a TinyMCE toolbar won't collapse something else. |
8449 * This ensures that ESC meant to collapse a modal dialog or a TinyMCE toolbar won't collapse something else. |
8450 */ |
8450 */ |
8451 if ( ! $( event.target ).is( 'body' ) && ! $.contains( $( '#customize-controls' )[0], event.target ) ) { |
8451 if ( ! $( event.target ).is( 'body' ) && ! $.contains( $( '#customize-controls' )[0], event.target ) ) { |
|
8452 return; |
|
8453 } |
|
8454 |
|
8455 // Abort if we're inside of a block editor instance. |
|
8456 if ( event.target.closest( '.block-editor-writing-flow' ) !== null || |
|
8457 event.target.closest( '.block-editor-block-list__block-popover' ) !== null |
|
8458 ) { |
8452 return; |
8459 return; |
8453 } |
8460 } |
8454 |
8461 |
8455 // Check for expanded expandable controls (e.g. widgets and nav menus items), sections, and panels. |
8462 // Check for expanded expandable controls (e.g. widgets and nav menus items), sections, and panels. |
8456 api.control.each( function( control ) { |
8463 api.control.each( function( control ) { |
8750 |
8757 |
8751 // Bind site title display to the corresponding field. |
8758 // Bind site title display to the corresponding field. |
8752 if ( title.length ) { |
8759 if ( title.length ) { |
8753 api( 'blogname', function( setting ) { |
8760 api( 'blogname', function( setting ) { |
8754 var updateTitle = function() { |
8761 var updateTitle = function() { |
8755 title.text( $.trim( setting() ) || api.l10n.untitledBlogName ); |
8762 var blogTitle = setting() || ''; |
|
8763 title.text( blogTitle.toString().trim() || api.l10n.untitledBlogName ); |
8756 }; |
8764 }; |
8757 setting.bind( updateTitle ); |
8765 setting.bind( updateTitle ); |
8758 updateTitle(); |
8766 updateTitle(); |
8759 } ); |
8767 } ); |
8760 } |
8768 } |