Edit File by line
/home/barbar84/www/wp-admin/js
File: theme.js
/**
[0] Fix | Delete
* @output wp-admin/js/theme.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
/* global _wpThemeSettings, confirm, tb_position */
[4] Fix | Delete
window.wp = window.wp || {};
[5] Fix | Delete
[6] Fix | Delete
( function($) {
[7] Fix | Delete
[8] Fix | Delete
// Set up our namespace...
[9] Fix | Delete
var themes, l10n;
[10] Fix | Delete
themes = wp.themes = wp.themes || {};
[11] Fix | Delete
[12] Fix | Delete
// Store the theme data and settings for organized and quick access.
[13] Fix | Delete
// themes.data.settings, themes.data.themes, themes.data.l10n.
[14] Fix | Delete
themes.data = _wpThemeSettings;
[15] Fix | Delete
l10n = themes.data.l10n;
[16] Fix | Delete
[17] Fix | Delete
// Shortcut for isInstall check.
[18] Fix | Delete
themes.isInstall = !! themes.data.settings.isInstall;
[19] Fix | Delete
[20] Fix | Delete
// Setup app structure.
[21] Fix | Delete
_.extend( themes, { model: {}, view: {}, routes: {}, router: {}, template: wp.template });
[22] Fix | Delete
[23] Fix | Delete
themes.Model = Backbone.Model.extend({
[24] Fix | Delete
// Adds attributes to the default data coming through the .org themes api.
[25] Fix | Delete
// Map `id` to `slug` for shared code.
[26] Fix | Delete
initialize: function() {
[27] Fix | Delete
var description;
[28] Fix | Delete
[29] Fix | Delete
if ( this.get( 'slug' ) ) {
[30] Fix | Delete
// If the theme is already installed, set an attribute.
[31] Fix | Delete
if ( _.indexOf( themes.data.installedThemes, this.get( 'slug' ) ) !== -1 ) {
[32] Fix | Delete
this.set({ installed: true });
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
// If the theme is active, set an attribute.
[36] Fix | Delete
if ( themes.data.activeTheme === this.get( 'slug' ) ) {
[37] Fix | Delete
this.set({ active: true });
[38] Fix | Delete
}
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
// Set the attributes.
[42] Fix | Delete
this.set({
[43] Fix | Delete
// `slug` is for installation, `id` is for existing.
[44] Fix | Delete
id: this.get( 'slug' ) || this.get( 'id' )
[45] Fix | Delete
});
[46] Fix | Delete
[47] Fix | Delete
// Map `section.description` to `description`
[48] Fix | Delete
// as the API sometimes returns it differently.
[49] Fix | Delete
if ( this.has( 'sections' ) ) {
[50] Fix | Delete
description = this.get( 'sections' ).description;
[51] Fix | Delete
this.set({ description: description });
[52] Fix | Delete
}
[53] Fix | Delete
}
[54] Fix | Delete
});
[55] Fix | Delete
[56] Fix | Delete
// Main view controller for themes.php.
[57] Fix | Delete
// Unifies and renders all available views.
[58] Fix | Delete
themes.view.Appearance = wp.Backbone.View.extend({
[59] Fix | Delete
[60] Fix | Delete
el: '#wpbody-content .wrap .theme-browser',
[61] Fix | Delete
[62] Fix | Delete
window: $( window ),
[63] Fix | Delete
// Pagination instance.
[64] Fix | Delete
page: 0,
[65] Fix | Delete
[66] Fix | Delete
// Sets up a throttler for binding to 'scroll'.
[67] Fix | Delete
initialize: function( options ) {
[68] Fix | Delete
// Scroller checks how far the scroll position is.
[69] Fix | Delete
_.bindAll( this, 'scroller' );
[70] Fix | Delete
[71] Fix | Delete
this.SearchView = options.SearchView ? options.SearchView : themes.view.Search;
[72] Fix | Delete
// Bind to the scroll event and throttle
[73] Fix | Delete
// the results from this.scroller.
[74] Fix | Delete
this.window.on( 'scroll', _.throttle( this.scroller, 300 ) );
[75] Fix | Delete
},
[76] Fix | Delete
[77] Fix | Delete
// Main render control.
[78] Fix | Delete
render: function() {
[79] Fix | Delete
// Setup the main theme view
[80] Fix | Delete
// with the current theme collection.
[81] Fix | Delete
this.view = new themes.view.Themes({
[82] Fix | Delete
collection: this.collection,
[83] Fix | Delete
parent: this
[84] Fix | Delete
});
[85] Fix | Delete
[86] Fix | Delete
// Render search form.
[87] Fix | Delete
this.search();
[88] Fix | Delete
[89] Fix | Delete
this.$el.removeClass( 'search-loading' );
[90] Fix | Delete
[91] Fix | Delete
// Render and append.
[92] Fix | Delete
this.view.render();
[93] Fix | Delete
this.$el.empty().append( this.view.el ).addClass( 'rendered' );
[94] Fix | Delete
},
[95] Fix | Delete
[96] Fix | Delete
// Defines search element container.
[97] Fix | Delete
searchContainer: $( '.search-form' ),
[98] Fix | Delete
[99] Fix | Delete
// Search input and view
[100] Fix | Delete
// for current theme collection.
[101] Fix | Delete
search: function() {
[102] Fix | Delete
var view,
[103] Fix | Delete
self = this;
[104] Fix | Delete
[105] Fix | Delete
// Don't render the search if there is only one theme.
[106] Fix | Delete
if ( themes.data.themes.length === 1 ) {
[107] Fix | Delete
return;
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
view = new this.SearchView({
[111] Fix | Delete
collection: self.collection,
[112] Fix | Delete
parent: this
[113] Fix | Delete
});
[114] Fix | Delete
self.SearchView = view;
[115] Fix | Delete
[116] Fix | Delete
// Render and append after screen title.
[117] Fix | Delete
view.render();
[118] Fix | Delete
this.searchContainer
[119] Fix | Delete
.append( $.parseHTML( '<label class="screen-reader-text" for="wp-filter-search-input">' + l10n.search + '</label>' ) )
[120] Fix | Delete
.append( view.el )
[121] Fix | Delete
.on( 'submit', function( event ) {
[122] Fix | Delete
event.preventDefault();
[123] Fix | Delete
});
[124] Fix | Delete
},
[125] Fix | Delete
[126] Fix | Delete
// Checks when the user gets close to the bottom
[127] Fix | Delete
// of the mage and triggers a theme:scroll event.
[128] Fix | Delete
scroller: function() {
[129] Fix | Delete
var self = this,
[130] Fix | Delete
bottom, threshold;
[131] Fix | Delete
[132] Fix | Delete
bottom = this.window.scrollTop() + self.window.height();
[133] Fix | Delete
threshold = self.$el.offset().top + self.$el.outerHeight( false ) - self.window.height();
[134] Fix | Delete
threshold = Math.round( threshold * 0.9 );
[135] Fix | Delete
[136] Fix | Delete
if ( bottom > threshold ) {
[137] Fix | Delete
this.trigger( 'theme:scroll' );
[138] Fix | Delete
}
[139] Fix | Delete
}
[140] Fix | Delete
});
[141] Fix | Delete
[142] Fix | Delete
// Set up the Collection for our theme data.
[143] Fix | Delete
// @has 'id' 'name' 'screenshot' 'author' 'authorURI' 'version' 'active' ...
[144] Fix | Delete
themes.Collection = Backbone.Collection.extend({
[145] Fix | Delete
[146] Fix | Delete
model: themes.Model,
[147] Fix | Delete
[148] Fix | Delete
// Search terms.
[149] Fix | Delete
terms: '',
[150] Fix | Delete
[151] Fix | Delete
// Controls searching on the current theme collection
[152] Fix | Delete
// and triggers an update event.
[153] Fix | Delete
doSearch: function( value ) {
[154] Fix | Delete
[155] Fix | Delete
// Don't do anything if we've already done this search.
[156] Fix | Delete
// Useful because the Search handler fires multiple times per keystroke.
[157] Fix | Delete
if ( this.terms === value ) {
[158] Fix | Delete
return;
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
// Updates terms with the value passed.
[162] Fix | Delete
this.terms = value;
[163] Fix | Delete
[164] Fix | Delete
// If we have terms, run a search...
[165] Fix | Delete
if ( this.terms.length > 0 ) {
[166] Fix | Delete
this.search( this.terms );
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
// If search is blank, show all themes.
[170] Fix | Delete
// Useful for resetting the views when you clean the input.
[171] Fix | Delete
if ( this.terms === '' ) {
[172] Fix | Delete
this.reset( themes.data.themes );
[173] Fix | Delete
$( 'body' ).removeClass( 'no-results' );
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
// Trigger a 'themes:update' event.
[177] Fix | Delete
this.trigger( 'themes:update' );
[178] Fix | Delete
},
[179] Fix | Delete
[180] Fix | Delete
/**
[181] Fix | Delete
* Performs a search within the collection.
[182] Fix | Delete
*
[183] Fix | Delete
* @uses RegExp
[184] Fix | Delete
*/
[185] Fix | Delete
search: function( term ) {
[186] Fix | Delete
var match, results, haystack, name, description, author;
[187] Fix | Delete
[188] Fix | Delete
// Start with a full collection.
[189] Fix | Delete
this.reset( themes.data.themes, { silent: true } );
[190] Fix | Delete
[191] Fix | Delete
// Trim the term.
[192] Fix | Delete
term = term.trim();
[193] Fix | Delete
[194] Fix | Delete
// Escape the term string for RegExp meta characters.
[195] Fix | Delete
term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' );
[196] Fix | Delete
[197] Fix | Delete
// Consider spaces as word delimiters and match the whole string
[198] Fix | Delete
// so matching terms can be combined.
[199] Fix | Delete
term = term.replace( / /g, ')(?=.*' );
[200] Fix | Delete
match = new RegExp( '^(?=.*' + term + ').+', 'i' );
[201] Fix | Delete
[202] Fix | Delete
// Find results.
[203] Fix | Delete
// _.filter() and .test().
[204] Fix | Delete
results = this.filter( function( data ) {
[205] Fix | Delete
name = data.get( 'name' ).replace( /(<([^>]+)>)/ig, '' );
[206] Fix | Delete
description = data.get( 'description' ).replace( /(<([^>]+)>)/ig, '' );
[207] Fix | Delete
author = data.get( 'author' ).replace( /(<([^>]+)>)/ig, '' );
[208] Fix | Delete
[209] Fix | Delete
haystack = _.union( [ name, data.get( 'id' ), description, author, data.get( 'tags' ) ] );
[210] Fix | Delete
[211] Fix | Delete
if ( match.test( data.get( 'author' ) ) && term.length > 2 ) {
[212] Fix | Delete
data.set( 'displayAuthor', true );
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
return match.test( haystack );
[216] Fix | Delete
});
[217] Fix | Delete
[218] Fix | Delete
if ( results.length === 0 ) {
[219] Fix | Delete
this.trigger( 'query:empty' );
[220] Fix | Delete
} else {
[221] Fix | Delete
$( 'body' ).removeClass( 'no-results' );
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
this.reset( results );
[225] Fix | Delete
},
[226] Fix | Delete
[227] Fix | Delete
// Paginates the collection with a helper method
[228] Fix | Delete
// that slices the collection.
[229] Fix | Delete
paginate: function( instance ) {
[230] Fix | Delete
var collection = this;
[231] Fix | Delete
instance = instance || 0;
[232] Fix | Delete
[233] Fix | Delete
// Themes per instance are set at 20.
[234] Fix | Delete
collection = _( collection.rest( 20 * instance ) );
[235] Fix | Delete
collection = _( collection.first( 20 ) );
[236] Fix | Delete
[237] Fix | Delete
return collection;
[238] Fix | Delete
},
[239] Fix | Delete
[240] Fix | Delete
count: false,
[241] Fix | Delete
[242] Fix | Delete
/*
[243] Fix | Delete
* Handles requests for more themes and caches results.
[244] Fix | Delete
*
[245] Fix | Delete
*
[246] Fix | Delete
* When we are missing a cache object we fire an apiCall()
[247] Fix | Delete
* which triggers events of `query:success` or `query:fail`.
[248] Fix | Delete
*/
[249] Fix | Delete
query: function( request ) {
[250] Fix | Delete
/**
[251] Fix | Delete
* @static
[252] Fix | Delete
* @type Array
[253] Fix | Delete
*/
[254] Fix | Delete
var queries = this.queries,
[255] Fix | Delete
self = this,
[256] Fix | Delete
query, isPaginated, count;
[257] Fix | Delete
[258] Fix | Delete
// Store current query request args
[259] Fix | Delete
// for later use with the event `theme:end`.
[260] Fix | Delete
this.currentQuery.request = request;
[261] Fix | Delete
[262] Fix | Delete
// Search the query cache for matches.
[263] Fix | Delete
query = _.find( queries, function( query ) {
[264] Fix | Delete
return _.isEqual( query.request, request );
[265] Fix | Delete
});
[266] Fix | Delete
[267] Fix | Delete
// If the request matches the stored currentQuery.request
[268] Fix | Delete
// it means we have a paginated request.
[269] Fix | Delete
isPaginated = _.has( request, 'page' );
[270] Fix | Delete
[271] Fix | Delete
// Reset the internal api page counter for non-paginated queries.
[272] Fix | Delete
if ( ! isPaginated ) {
[273] Fix | Delete
this.currentQuery.page = 1;
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
// Otherwise, send a new API call and add it to the cache.
[277] Fix | Delete
if ( ! query && ! isPaginated ) {
[278] Fix | Delete
query = this.apiCall( request ).done( function( data ) {
[279] Fix | Delete
[280] Fix | Delete
// Update the collection with the queried data.
[281] Fix | Delete
if ( data.themes ) {
[282] Fix | Delete
self.reset( data.themes );
[283] Fix | Delete
count = data.info.results;
[284] Fix | Delete
// Store the results and the query request.
[285] Fix | Delete
queries.push( { themes: data.themes, request: request, total: count } );
[286] Fix | Delete
}
[287] Fix | Delete
[288] Fix | Delete
// Trigger a collection refresh event
[289] Fix | Delete
// and a `query:success` event with a `count` argument.
[290] Fix | Delete
self.trigger( 'themes:update' );
[291] Fix | Delete
self.trigger( 'query:success', count );
[292] Fix | Delete
[293] Fix | Delete
if ( data.themes && data.themes.length === 0 ) {
[294] Fix | Delete
self.trigger( 'query:empty' );
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
}).fail( function() {
[298] Fix | Delete
self.trigger( 'query:fail' );
[299] Fix | Delete
});
[300] Fix | Delete
} else {
[301] Fix | Delete
// If it's a paginated request we need to fetch more themes...
[302] Fix | Delete
if ( isPaginated ) {
[303] Fix | Delete
return this.apiCall( request, isPaginated ).done( function( data ) {
[304] Fix | Delete
// Add the new themes to the current collection.
[305] Fix | Delete
// @todo Update counter.
[306] Fix | Delete
self.add( data.themes );
[307] Fix | Delete
self.trigger( 'query:success' );
[308] Fix | Delete
[309] Fix | Delete
// We are done loading themes for now.
[310] Fix | Delete
self.loadingThemes = false;
[311] Fix | Delete
[312] Fix | Delete
}).fail( function() {
[313] Fix | Delete
self.trigger( 'query:fail' );
[314] Fix | Delete
});
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
if ( query.themes.length === 0 ) {
[318] Fix | Delete
self.trigger( 'query:empty' );
[319] Fix | Delete
} else {
[320] Fix | Delete
$( 'body' ).removeClass( 'no-results' );
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
// Only trigger an update event since we already have the themes
[324] Fix | Delete
// on our cached object.
[325] Fix | Delete
if ( _.isNumber( query.total ) ) {
[326] Fix | Delete
this.count = query.total;
[327] Fix | Delete
}
[328] Fix | Delete
[329] Fix | Delete
this.reset( query.themes );
[330] Fix | Delete
if ( ! query.total ) {
[331] Fix | Delete
this.count = this.length;
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
this.trigger( 'themes:update' );
[335] Fix | Delete
this.trigger( 'query:success', this.count );
[336] Fix | Delete
}
[337] Fix | Delete
},
[338] Fix | Delete
[339] Fix | Delete
// Local cache array for API queries.
[340] Fix | Delete
queries: [],
[341] Fix | Delete
[342] Fix | Delete
// Keep track of current query so we can handle pagination.
[343] Fix | Delete
currentQuery: {
[344] Fix | Delete
page: 1,
[345] Fix | Delete
request: {}
[346] Fix | Delete
},
[347] Fix | Delete
[348] Fix | Delete
// Send request to api.wordpress.org/themes.
[349] Fix | Delete
apiCall: function( request, paginated ) {
[350] Fix | Delete
return wp.ajax.send( 'query-themes', {
[351] Fix | Delete
data: {
[352] Fix | Delete
// Request data.
[353] Fix | Delete
request: _.extend({
[354] Fix | Delete
per_page: 100
[355] Fix | Delete
}, request)
[356] Fix | Delete
},
[357] Fix | Delete
[358] Fix | Delete
beforeSend: function() {
[359] Fix | Delete
if ( ! paginated ) {
[360] Fix | Delete
// Spin it.
[361] Fix | Delete
$( 'body' ).addClass( 'loading-content' ).removeClass( 'no-results' );
[362] Fix | Delete
}
[363] Fix | Delete
}
[364] Fix | Delete
});
[365] Fix | Delete
},
[366] Fix | Delete
[367] Fix | Delete
// Static status controller for when we are loading themes.
[368] Fix | Delete
loadingThemes: false
[369] Fix | Delete
});
[370] Fix | Delete
[371] Fix | Delete
// This is the view that controls each theme item
[372] Fix | Delete
// that will be displayed on the screen.
[373] Fix | Delete
themes.view.Theme = wp.Backbone.View.extend({
[374] Fix | Delete
[375] Fix | Delete
// Wrap theme data on a div.theme element.
[376] Fix | Delete
className: 'theme',
[377] Fix | Delete
[378] Fix | Delete
// Reflects which theme view we have.
[379] Fix | Delete
// 'grid' (default) or 'detail'.
[380] Fix | Delete
state: 'grid',
[381] Fix | Delete
[382] Fix | Delete
// The HTML template for each element to be rendered.
[383] Fix | Delete
html: themes.template( 'theme' ),
[384] Fix | Delete
[385] Fix | Delete
events: {
[386] Fix | Delete
'click': themes.isInstall ? 'preview': 'expand',
[387] Fix | Delete
'keydown': themes.isInstall ? 'preview': 'expand',
[388] Fix | Delete
'touchend': themes.isInstall ? 'preview': 'expand',
[389] Fix | Delete
'keyup': 'addFocus',
[390] Fix | Delete
'touchmove': 'preventExpand',
[391] Fix | Delete
'click .theme-install': 'installTheme',
[392] Fix | Delete
'click .update-message': 'updateTheme'
[393] Fix | Delete
},
[394] Fix | Delete
[395] Fix | Delete
touchDrag: false,
[396] Fix | Delete
[397] Fix | Delete
initialize: function() {
[398] Fix | Delete
this.model.on( 'change', this.render, this );
[399] Fix | Delete
},
[400] Fix | Delete
[401] Fix | Delete
render: function() {
[402] Fix | Delete
var data = this.model.toJSON();
[403] Fix | Delete
[404] Fix | Delete
// Render themes using the html template.
[405] Fix | Delete
this.$el.html( this.html( data ) ).attr({
[406] Fix | Delete
tabindex: 0,
[407] Fix | Delete
'aria-describedby' : data.id + '-action ' + data.id + '-name',
[408] Fix | Delete
'data-slug': data.id
[409] Fix | Delete
});
[410] Fix | Delete
[411] Fix | Delete
// Renders active theme styles.
[412] Fix | Delete
this.activeTheme();
[413] Fix | Delete
[414] Fix | Delete
if ( this.model.get( 'displayAuthor' ) ) {
[415] Fix | Delete
this.$el.addClass( 'display-author' );
[416] Fix | Delete
}
[417] Fix | Delete
},
[418] Fix | Delete
[419] Fix | Delete
// Adds a class to the currently active theme
[420] Fix | Delete
// and to the overlay in detailed view mode.
[421] Fix | Delete
activeTheme: function() {
[422] Fix | Delete
if ( this.model.get( 'active' ) ) {
[423] Fix | Delete
this.$el.addClass( 'active' );
[424] Fix | Delete
}
[425] Fix | Delete
},
[426] Fix | Delete
[427] Fix | Delete
// Add class of focus to the theme we are focused on.
[428] Fix | Delete
addFocus: function() {
[429] Fix | Delete
var $themeToFocus = ( $( ':focus' ).hasClass( 'theme' ) ) ? $( ':focus' ) : $(':focus').parents('.theme');
[430] Fix | Delete
[431] Fix | Delete
$('.theme.focus').removeClass('focus');
[432] Fix | Delete
$themeToFocus.addClass('focus');
[433] Fix | Delete
},
[434] Fix | Delete
[435] Fix | Delete
// Single theme overlay screen.
[436] Fix | Delete
// It's shown when clicking a theme.
[437] Fix | Delete
expand: function( event ) {
[438] Fix | Delete
var self = this;
[439] Fix | Delete
[440] Fix | Delete
event = event || window.event;
[441] Fix | Delete
[442] Fix | Delete
// 'Enter' and 'Space' keys expand the details view when a theme is :focused.
[443] Fix | Delete
if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) {
[444] Fix | Delete
return;
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
// Bail if the user scrolled on a touch device.
[448] Fix | Delete
if ( this.touchDrag === true ) {
[449] Fix | Delete
return this.touchDrag = false;
[450] Fix | Delete
}
[451] Fix | Delete
[452] Fix | Delete
// Prevent the modal from showing when the user clicks
[453] Fix | Delete
// one of the direct action buttons.
[454] Fix | Delete
if ( $( event.target ).is( '.theme-actions a' ) ) {
[455] Fix | Delete
return;
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
// Prevent the modal from showing when the user clicks one of the direct action buttons.
[459] Fix | Delete
if ( $( event.target ).is( '.theme-actions a, .update-message, .button-link, .notice-dismiss' ) ) {
[460] Fix | Delete
return;
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
// Set focused theme to current element.
[464] Fix | Delete
themes.focusedTheme = this.$el;
[465] Fix | Delete
[466] Fix | Delete
this.trigger( 'theme:expand', self.model.cid );
[467] Fix | Delete
},
[468] Fix | Delete
[469] Fix | Delete
preventExpand: function() {
[470] Fix | Delete
this.touchDrag = true;
[471] Fix | Delete
},
[472] Fix | Delete
[473] Fix | Delete
preview: function( event ) {
[474] Fix | Delete
var self = this,
[475] Fix | Delete
current, preview;
[476] Fix | Delete
[477] Fix | Delete
event = event || window.event;
[478] Fix | Delete
[479] Fix | Delete
// Bail if the user scrolled on a touch device.
[480] Fix | Delete
if ( this.touchDrag === true ) {
[481] Fix | Delete
return this.touchDrag = false;
[482] Fix | Delete
}
[483] Fix | Delete
[484] Fix | Delete
// Allow direct link path to installing a theme.
[485] Fix | Delete
if ( $( event.target ).not( '.install-theme-preview' ).parents( '.theme-actions' ).length ) {
[486] Fix | Delete
return;
[487] Fix | Delete
}
[488] Fix | Delete
[489] Fix | Delete
// 'Enter' and 'Space' keys expand the details view when a theme is :focused.
[490] Fix | Delete
if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) {
[491] Fix | Delete
return;
[492] Fix | Delete
}
[493] Fix | Delete
[494] Fix | Delete
// Pressing Enter while focused on the buttons shouldn't open the preview.
[495] Fix | Delete
if ( event.type === 'keydown' && event.which !== 13 && $( ':focus' ).hasClass( 'button' ) ) {
[496] Fix | Delete
return;
[497] Fix | Delete
}
[498] Fix | Delete
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function