mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-10 02:18:58 +01:00
Theme installer keyboard fixes. Updates [28033] and [28036].
props matveb. see #27521. Built from https://develop.svn.wordpress.org/trunk@28049 git-svn-id: http://core.svn.wordpress.org/trunk@27879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2c963a82f7
commit
b631825414
@ -1077,23 +1077,15 @@ body.folded .theme-overlay .theme-wrap {
|
|||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* Already installed theme */
|
/* Already installed theme */
|
||||||
.theme-browser .theme.is-installed {
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
.theme-browser .theme .theme-installed {
|
.theme-browser .theme .theme-installed {
|
||||||
background: #0074a2;
|
background: #0074a2;
|
||||||
}
|
}
|
||||||
.theme-browser .theme .theme-installed:before {
|
.theme-browser .theme .theme-installed:before {
|
||||||
content: '\f147';
|
content: '\f147';
|
||||||
}
|
}
|
||||||
.theme-browser .theme.is-installed .theme-actions .button-primary,
|
.theme-browser .theme.is-installed .theme-actions .button-primary {
|
||||||
.theme-browser.rendered .theme.is-installed .more-details {
|
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
.theme-browser.rendered .theme.is-installed:hover .theme-screenshot img,
|
|
||||||
.theme-browser.rendered .theme.is-installed:focus .theme-screenshot img {
|
|
||||||
opacity: 1 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-navigation {
|
.theme-navigation {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
@ -1077,23 +1077,15 @@ body.folded .theme-overlay .theme-wrap {
|
|||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* Already installed theme */
|
/* Already installed theme */
|
||||||
.theme-browser .theme.is-installed {
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
.theme-browser .theme .theme-installed {
|
.theme-browser .theme .theme-installed {
|
||||||
background: #0074a2;
|
background: #0074a2;
|
||||||
}
|
}
|
||||||
.theme-browser .theme .theme-installed:before {
|
.theme-browser .theme .theme-installed:before {
|
||||||
content: '\f147';
|
content: '\f147';
|
||||||
}
|
}
|
||||||
.theme-browser .theme.is-installed .theme-actions .button-primary,
|
.theme-browser .theme.is-installed .theme-actions .button-primary {
|
||||||
.theme-browser.rendered .theme.is-installed .more-details {
|
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
.theme-browser.rendered .theme.is-installed:hover .theme-screenshot img,
|
|
||||||
.theme-browser.rendered .theme.is-installed:focus .theme-screenshot img {
|
|
||||||
opacity: 1 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-navigation {
|
.theme-navigation {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
2
wp-admin/css/wp-admin-rtl.min.css
vendored
2
wp-admin/css/wp-admin-rtl.min.css
vendored
File diff suppressed because one or more lines are too long
2
wp-admin/css/wp-admin.min.css
vendored
2
wp-admin/css/wp-admin.min.css
vendored
File diff suppressed because one or more lines are too long
@ -442,22 +442,6 @@ themes.view.Theme = wp.Backbone.View.extend({
|
|||||||
this.touchDrag = true;
|
this.touchDrag = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Handles .disabled classes for previous/next buttons in theme installer preview
|
|
||||||
setNavButtonsState: function() {
|
|
||||||
var $themeInstaller = $( '.theme-install-overlay' ),
|
|
||||||
current = _.isUndefined( this.current ) ? this.model : this.current;
|
|
||||||
|
|
||||||
// Disable previous at the zero position
|
|
||||||
if ( 0 === this.model.collection.indexOf( current ) ) {
|
|
||||||
$themeInstaller.find( '.previous-theme' ).addClass( 'disabled' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable next if the next model is undefined
|
|
||||||
if ( _.isUndefined( this.model.collection.at( this.model.collection.indexOf( current ) + 1 ) ) ) {
|
|
||||||
$themeInstaller.find( '.next-theme' ).addClass( 'disabled' );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
preview: function( event ) {
|
preview: function( event ) {
|
||||||
var self = this,
|
var self = this,
|
||||||
current, preview;
|
current, preview;
|
||||||
@ -496,6 +480,7 @@ themes.view.Theme = wp.Backbone.View.extend({
|
|||||||
|
|
||||||
// Render the view and append it.
|
// Render the view and append it.
|
||||||
preview.render();
|
preview.render();
|
||||||
|
this.setNavButtonsState();
|
||||||
$( 'div.wrap' ).append( preview.el );
|
$( 'div.wrap' ).append( preview.el );
|
||||||
|
|
||||||
// Listen to our preview object
|
// Listen to our preview object
|
||||||
@ -535,6 +520,11 @@ themes.view.Theme = wp.Backbone.View.extend({
|
|||||||
// Keep track of current theme model.
|
// Keep track of current theme model.
|
||||||
current = self.model;
|
current = self.model;
|
||||||
|
|
||||||
|
// Bail early if we are at the beginning of the collection
|
||||||
|
if ( self.model.collection.indexOf( self.current ) === 0 ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If we have ventured away from current model update the current model position.
|
// If we have ventured away from current model update the current model position.
|
||||||
if ( ! _.isUndefined( self.current ) ) {
|
if ( ! _.isUndefined( self.current ) ) {
|
||||||
current = self.current;
|
current = self.current;
|
||||||
@ -559,7 +549,26 @@ themes.view.Theme = wp.Backbone.View.extend({
|
|||||||
$( 'div.wrap' ).append( preview.el );
|
$( 'div.wrap' ).append( preview.el );
|
||||||
$( '.previous-theme' ).focus();
|
$( '.previous-theme' ).focus();
|
||||||
});
|
});
|
||||||
self.setNavButtonsState();
|
|
||||||
|
this.listenTo( preview, 'preview:close', function() {
|
||||||
|
self.current = self.model
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// Handles .disabled classes for previous/next buttons in theme installer preview
|
||||||
|
setNavButtonsState: function() {
|
||||||
|
var $themeInstaller = $( '.theme-install-overlay' ),
|
||||||
|
current = _.isUndefined( this.current ) ? this.model : this.current;
|
||||||
|
|
||||||
|
// Disable previous at the zero position
|
||||||
|
if ( 0 === this.model.collection.indexOf( current ) ) {
|
||||||
|
$themeInstaller.find( '.previous-theme' ).addClass( 'disabled' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable next if the next model is undefined
|
||||||
|
if ( _.isUndefined( this.model.collection.at( this.model.collection.indexOf( current ) + 1 ) ) ) {
|
||||||
|
$themeInstaller.find( '.next-theme' ).addClass( 'disabled' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -738,7 +747,8 @@ themes.view.Preview = themes.view.Details.extend({
|
|||||||
'click .close-full-overlay': 'close',
|
'click .close-full-overlay': 'close',
|
||||||
'click .collapse-sidebar': 'collapse',
|
'click .collapse-sidebar': 'collapse',
|
||||||
'click .previous-theme': 'previousTheme',
|
'click .previous-theme': 'previousTheme',
|
||||||
'click .next-theme': 'nextTheme'
|
'click .next-theme': 'nextTheme',
|
||||||
|
'keyup': 'keyEvent'
|
||||||
},
|
},
|
||||||
|
|
||||||
// The HTML template for the theme preview
|
// The HTML template for the theme preview
|
||||||
@ -752,30 +762,14 @@ themes.view.Preview = themes.view.Details.extend({
|
|||||||
themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.get( 'id' ) ), { replace: true } );
|
themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.get( 'id' ) ), { replace: true } );
|
||||||
|
|
||||||
this.$el.fadeIn( 200, function() {
|
this.$el.fadeIn( 200, function() {
|
||||||
$( 'body' )
|
$( 'body' ).addClass( 'theme-installer-active full-overlay-active' );
|
||||||
.addClass( 'theme-installer-active full-overlay-active' )
|
|
||||||
.on( 'keyup.overlay', function( event ) {
|
|
||||||
// The escape key closes the preview
|
|
||||||
if ( event.keyCode === 27 ) {
|
|
||||||
self.close();
|
|
||||||
}
|
|
||||||
// The right arrow key, next theme
|
|
||||||
if ( event.keyCode === 39 ) {
|
|
||||||
self.nextTheme();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The left arrow key, previous theme
|
|
||||||
if ( event.keyCode === 37 ) {
|
|
||||||
self.previousTheme();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$( '.close-full-overlay' ).focus();
|
$( '.close-full-overlay' ).focus();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
close: function() {
|
close: function() {
|
||||||
this.$el.fadeOut( 200, function() {
|
this.$el.fadeOut( 200, function() {
|
||||||
$( 'body' ).removeClass( 'theme-installer-active full-overlay-active' ).off( 'keyup.overlay' );
|
$( 'body' ).removeClass( 'theme-installer-active full-overlay-active' );
|
||||||
|
|
||||||
// Return focus to the theme div
|
// Return focus to the theme div
|
||||||
if ( themes.focusedTheme ) {
|
if ( themes.focusedTheme ) {
|
||||||
@ -784,6 +778,7 @@ themes.view.Preview = themes.view.Details.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
themes.router.navigate( themes.router.baseUrl( '' ) );
|
themes.router.navigate( themes.router.baseUrl( '' ) );
|
||||||
|
this.trigger( 'preview:close' );
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -791,6 +786,23 @@ themes.view.Preview = themes.view.Details.extend({
|
|||||||
|
|
||||||
this.$el.toggleClass( 'collapsed' ).toggleClass( 'expanded' );
|
this.$el.toggleClass( 'collapsed' ).toggleClass( 'expanded' );
|
||||||
return false;
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
keyEvent: function( event ) {
|
||||||
|
// The escape key closes the preview
|
||||||
|
if ( event.keyCode === 27 ) {
|
||||||
|
this.undelegateEvents();
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
// The right arrow key, next theme
|
||||||
|
if ( event.keyCode === 39 ) {
|
||||||
|
_.once( this.nextTheme() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// The left arrow key, previous theme
|
||||||
|
if ( event.keyCode === 37 ) {
|
||||||
|
this.previousTheme();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
2
wp-admin/js/theme.min.js
vendored
2
wp-admin/js/theme.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user