Customize: Let edit shortcuts be persistently visible when controls pane is expanded, hidden when collapsed, and always visible in mobile preview. Remove initial flash of edit shortcuts.

Props westonruter, sirbrillig.
Fixes #27403.


git-svn-id: https://develop.svn.wordpress.org/trunk@39131 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2016-11-03 22:22:43 +00:00
parent fb9b3819de
commit a981b22e15
3 changed files with 16 additions and 17 deletions

View File

@ -5207,7 +5207,7 @@
expandedPanel( false );
expandedSection( false );
previewerAlive( true );
editShortcutVisibility( 'initial' );
editShortcutVisibility( 'visible' );
api.bind( 'change', function() {
state('saved').set( false );
@ -5813,6 +5813,21 @@
});
// Update the edit shortcut visibility state.
api.state( 'paneVisible' ).bind( function( isPaneVisible ) {
var isMobileScreen;
if ( window.matchMedia ) {
isMobileScreen = window.matchMedia( 'screen and ( max-width: 640px )' ).matches;
} else {
isMobileScreen = $( window ).width() <= 640;
}
api.state( 'editShortcutVisibility' ).set( isPaneVisible || isMobileScreen ? 'visible' : 'hidden' );
} );
if ( window.matchMedia ) {
window.matchMedia( 'screen and ( max-width: 640px )' ).addListener( function() {
var state = api.state( 'paneVisible' );
state.callbacks.fireWith( state, [ state.get(), state.get() ] );
} );
}
api.previewer.bind( 'edit-shortcut-visibility', function( visibility ) {
api.state( 'editShortcutVisibility' ).set( visibility );
} );

View File

@ -80,13 +80,6 @@ body.customize-partial-edit-shortcuts-hidden .customize-partial-edit-shortcut:be
pointer-events: none;
}
body.customize-partial-edit-shortcuts-flash .customize-partial-edit-shortcut:before {
animation-duration: 1.5s;
animation-delay: 0.4s;
animation-name: customize-partial-edit-shortcut-bounce-disappear;
pointer-events: none;
}
.page-sidebar-collapsed .customize-partial-edit-shortcut:before,
.customize-partial-edit-shortcut-hidden:before {
visibility: hidden;

View File

@ -996,7 +996,6 @@ wp.customize.selectiveRefresh = ( function( $, api ) {
shouldAnimateHide = ( 'hidden' === visibility && body.hasClass( 'customize-partial-edit-shortcuts-shown' ) && ! body.hasClass( 'customize-partial-edit-shortcuts-hidden' ) );
body.toggleClass( 'customize-partial-edit-shortcuts-hidden', shouldAnimateHide );
body.toggleClass( 'customize-partial-edit-shortcuts-shown', 'visible' === visibility );
body.toggleClass( 'customize-partial-edit-shortcuts-flash', 'initial' === visibility );
} );
api.preview.bind( 'active', function() {
@ -1022,14 +1021,6 @@ wp.customize.selectiveRefresh = ( function( $, api ) {
self.partial.bind( 'add', function( partial ) {
partial.deferred.ready.resolve();
} );
body.on( 'click', function( event ) {
if ( event.shiftKey || $( event.target ).is( '.customize-partial-edit-shortcut, :input, button *, a[href], a[href] *, object, object *, [tabindex], [tabindex] *' ) ) {
return; // Don't toggle shortcuts on shift-clicks or clicks on (or in) interactive elements.
}
api.selectiveRefresh.editShortcutVisibility.set( 'visible' === api.selectiveRefresh.editShortcutVisibility.get() ? 'hidden' : 'visible' );
api.preview.send( 'edit-shortcut-visibility', api.selectiveRefresh.editShortcutVisibility.get() );
} );
} );
} );