Edit File by line
/home/zeestwma/ceyloniy.../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
.find( '.search-box' )
[120] Fix | Delete
.append( $.parseHTML( '<label for="wp-filter-search-input">' + l10n.search + '</label>' ) )
[121] Fix | Delete
.append( view.el );
[122] Fix | Delete
[123] Fix | Delete
this.searchContainer.on( 'submit', function( event ) {
[124] Fix | Delete
event.preventDefault();
[125] Fix | Delete
});
[126] Fix | Delete
},
[127] Fix | Delete
[128] Fix | Delete
// Checks when the user gets close to the bottom
[129] Fix | Delete
// of the mage and triggers a theme:scroll event.
[130] Fix | Delete
scroller: function() {
[131] Fix | Delete
var self = this,
[132] Fix | Delete
bottom, threshold;
[133] Fix | Delete
[134] Fix | Delete
bottom = this.window.scrollTop() + self.window.height();
[135] Fix | Delete
threshold = self.$el.offset().top + self.$el.outerHeight( false ) - self.window.height();
[136] Fix | Delete
threshold = Math.round( threshold * 0.9 );
[137] Fix | Delete
[138] Fix | Delete
if ( bottom > threshold ) {
[139] Fix | Delete
this.trigger( 'theme:scroll' );
[140] Fix | Delete
}
[141] Fix | Delete
}
[142] Fix | Delete
});
[143] Fix | Delete
[144] Fix | Delete
// Set up the Collection for our theme data.
[145] Fix | Delete
// @has 'id' 'name' 'screenshot' 'author' 'authorURI' 'version' 'active' ...
[146] Fix | Delete
themes.Collection = Backbone.Collection.extend({
[147] Fix | Delete
[148] Fix | Delete
model: themes.Model,
[149] Fix | Delete
[150] Fix | Delete
// Search terms.
[151] Fix | Delete
terms: '',
[152] Fix | Delete
[153] Fix | Delete
// Controls searching on the current theme collection
[154] Fix | Delete
// and triggers an update event.
[155] Fix | Delete
doSearch: function( value ) {
[156] Fix | Delete
[157] Fix | Delete
// Don't do anything if we've already done this search.
[158] Fix | Delete
// Useful because the Search handler fires multiple times per keystroke.
[159] Fix | Delete
if ( this.terms === value ) {
[160] Fix | Delete
return;
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
// Updates terms with the value passed.
[164] Fix | Delete
this.terms = value;
[165] Fix | Delete
[166] Fix | Delete
// If we have terms, run a search...
[167] Fix | Delete
if ( this.terms.length > 0 ) {
[168] Fix | Delete
this.search( this.terms );
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
// If search is blank, show all themes.
[172] Fix | Delete
// Useful for resetting the views when you clean the input.
[173] Fix | Delete
if ( this.terms === '' ) {
[174] Fix | Delete
this.reset( themes.data.themes );
[175] Fix | Delete
$( 'body' ).removeClass( 'no-results' );
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
// Trigger a 'themes:update' event.
[179] Fix | Delete
this.trigger( 'themes:update' );
[180] Fix | Delete
},
[181] Fix | Delete
[182] Fix | Delete
/**
[183] Fix | Delete
* Performs a search within the collection.
[184] Fix | Delete
*
[185] Fix | Delete
* @uses RegExp
[186] Fix | Delete
*/
[187] Fix | Delete
search: function( term ) {
[188] Fix | Delete
var match, results, haystack, name, description, author;
[189] Fix | Delete
[190] Fix | Delete
// Start with a full collection.
[191] Fix | Delete
this.reset( themes.data.themes, { silent: true } );
[192] Fix | Delete
[193] Fix | Delete
// Trim the term.
[194] Fix | Delete
term = term.trim();
[195] Fix | Delete
[196] Fix | Delete
// Escape the term string for RegExp meta characters.
[197] Fix | Delete
term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' );
[198] Fix | Delete
[199] Fix | Delete
// Consider spaces as word delimiters and match the whole string
[200] Fix | Delete
// so matching terms can be combined.
[201] Fix | Delete
term = term.replace( / /g, ')(?=.*' );
[202] Fix | Delete
match = new RegExp( '^(?=.*' + term + ').+', 'i' );
[203] Fix | Delete
[204] Fix | Delete
// Find results.
[205] Fix | Delete
// _.filter() and .test().
[206] Fix | Delete
results = this.filter( function( data ) {
[207] Fix | Delete
name = data.get( 'name' ).replace( /(<([^>]+)>)/ig, '' );
[208] Fix | Delete
description = data.get( 'description' ).replace( /(<([^>]+)>)/ig, '' );
[209] Fix | Delete
author = data.get( 'author' ).replace( /(<([^>]+)>)/ig, '' );
[210] Fix | Delete
[211] Fix | Delete
haystack = _.union( [ name, data.get( 'id' ), description, author, data.get( 'tags' ) ] );
[212] Fix | Delete
[213] Fix | Delete
if ( match.test( data.get( 'author' ) ) && term.length > 2 ) {
[214] Fix | Delete
data.set( 'displayAuthor', true );
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
return match.test( haystack );
[218] Fix | Delete
});
[219] Fix | Delete
[220] Fix | Delete
if ( results.length === 0 ) {
[221] Fix | Delete
this.trigger( 'query:empty' );
[222] Fix | Delete
} else {
[223] Fix | Delete
$( 'body' ).removeClass( 'no-results' );
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
this.reset( results );
[227] Fix | Delete
},
[228] Fix | Delete
[229] Fix | Delete
// Paginates the collection with a helper method
[230] Fix | Delete
// that slices the collection.
[231] Fix | Delete
paginate: function( instance ) {
[232] Fix | Delete
var collection = this;
[233] Fix | Delete
instance = instance || 0;
[234] Fix | Delete
[235] Fix | Delete
// Themes per instance are set at 20.
[236] Fix | Delete
collection = _( collection.rest( 20 * instance ) );
[237] Fix | Delete
collection = _( collection.first( 20 ) );
[238] Fix | Delete
[239] Fix | Delete
return collection;
[240] Fix | Delete
},
[241] Fix | Delete
[242] Fix | Delete
count: false,
[243] Fix | Delete
[244] Fix | Delete
/*
[245] Fix | Delete
* Handles requests for more themes and caches results.
[246] Fix | Delete
*
[247] Fix | Delete
*
[248] Fix | Delete
* When we are missing a cache object we fire an apiCall()
[249] Fix | Delete
* which triggers events of `query:success` or `query:fail`.
[250] Fix | Delete
*/
[251] Fix | Delete
query: function( request ) {
[252] Fix | Delete
/**
[253] Fix | Delete
* @static
[254] Fix | Delete
* @type Array
[255] Fix | Delete
*/
[256] Fix | Delete
var queries = this.queries,
[257] Fix | Delete
self = this,
[258] Fix | Delete
query, isPaginated, count;
[259] Fix | Delete
[260] Fix | Delete
// Store current query request args
[261] Fix | Delete
// for later use with the event `theme:end`.
[262] Fix | Delete
this.currentQuery.request = request;
[263] Fix | Delete
[264] Fix | Delete
// Search the query cache for matches.
[265] Fix | Delete
query = _.find( queries, function( query ) {
[266] Fix | Delete
return _.isEqual( query.request, request );
[267] Fix | Delete
});
[268] Fix | Delete
[269] Fix | Delete
// If the request matches the stored currentQuery.request
[270] Fix | Delete
// it means we have a paginated request.
[271] Fix | Delete
isPaginated = _.has( request, 'page' );
[272] Fix | Delete
[273] Fix | Delete
// Reset the internal api page counter for non-paginated queries.
[274] Fix | Delete
if ( ! isPaginated ) {
[275] Fix | Delete
this.currentQuery.page = 1;
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
// Otherwise, send a new API call and add it to the cache.
[279] Fix | Delete
if ( ! query && ! isPaginated ) {
[280] Fix | Delete
query = this.apiCall( request ).done( function( data ) {
[281] Fix | Delete
[282] Fix | Delete
// Update the collection with the queried data.
[283] Fix | Delete
if ( data.themes ) {
[284] Fix | Delete
self.reset( data.themes );
[285] Fix | Delete
count = data.info.results;
[286] Fix | Delete
// Store the results and the query request.
[287] Fix | Delete
queries.push( { themes: data.themes, request: request, total: count } );
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
// Trigger a collection refresh event
[291] Fix | Delete
// and a `query:success` event with a `count` argument.
[292] Fix | Delete
self.trigger( 'themes:update' );
[293] Fix | Delete
self.trigger( 'query:success', count );
[294] Fix | Delete
[295] Fix | Delete
if ( data.themes && data.themes.length === 0 ) {
[296] Fix | Delete
self.trigger( 'query:empty' );
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
}).fail( function() {
[300] Fix | Delete
self.trigger( 'query:fail' );
[301] Fix | Delete
});
[302] Fix | Delete
} else {
[303] Fix | Delete
// If it's a paginated request we need to fetch more themes...
[304] Fix | Delete
if ( isPaginated ) {
[305] Fix | Delete
return this.apiCall( request, isPaginated ).done( function( data ) {
[306] Fix | Delete
// Add the new themes to the current collection.
[307] Fix | Delete
// @todo Update counter.
[308] Fix | Delete
self.add( data.themes );
[309] Fix | Delete
self.trigger( 'query:success' );
[310] Fix | Delete
[311] Fix | Delete
// We are done loading themes for now.
[312] Fix | Delete
self.loadingThemes = false;
[313] Fix | Delete
[314] Fix | Delete
}).fail( function() {
[315] Fix | Delete
self.trigger( 'query:fail' );
[316] Fix | Delete
});
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
if ( query.themes.length === 0 ) {
[320] Fix | Delete
self.trigger( 'query:empty' );
[321] Fix | Delete
} else {
[322] Fix | Delete
$( 'body' ).removeClass( 'no-results' );
[323] Fix | Delete
}
[324] Fix | Delete
[325] Fix | Delete
// Only trigger an update event since we already have the themes
[326] Fix | Delete
// on our cached object.
[327] Fix | Delete
if ( _.isNumber( query.total ) ) {
[328] Fix | Delete
this.count = query.total;
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
this.reset( query.themes );
[332] Fix | Delete
if ( ! query.total ) {
[333] Fix | Delete
this.count = this.length;
[334] Fix | Delete
}
[335] Fix | Delete
[336] Fix | Delete
this.trigger( 'themes:update' );
[337] Fix | Delete
this.trigger( 'query:success', this.count );
[338] Fix | Delete
}
[339] Fix | Delete
},
[340] Fix | Delete
[341] Fix | Delete
// Local cache array for API queries.
[342] Fix | Delete
queries: [],
[343] Fix | Delete
[344] Fix | Delete
// Keep track of current query so we can handle pagination.
[345] Fix | Delete
currentQuery: {
[346] Fix | Delete
page: 1,
[347] Fix | Delete
request: {}
[348] Fix | Delete
},
[349] Fix | Delete
[350] Fix | Delete
// Send request to api.wordpress.org/themes.
[351] Fix | Delete
apiCall: function( request, paginated ) {
[352] Fix | Delete
return wp.ajax.send( 'query-themes', {
[353] Fix | Delete
data: {
[354] Fix | Delete
// Request data.
[355] Fix | Delete
request: _.extend({
[356] Fix | Delete
per_page: 100
[357] Fix | Delete
}, request)
[358] Fix | Delete
},
[359] Fix | Delete
[360] Fix | Delete
beforeSend: function() {
[361] Fix | Delete
if ( ! paginated ) {
[362] Fix | Delete
// Spin it.
[363] Fix | Delete
$( 'body' ).addClass( 'loading-content' ).removeClass( 'no-results' );
[364] Fix | Delete
}
[365] Fix | Delete
}
[366] Fix | Delete
});
[367] Fix | Delete
},
[368] Fix | Delete
[369] Fix | Delete
// Static status controller for when we are loading themes.
[370] Fix | Delete
loadingThemes: false
[371] Fix | Delete
});
[372] Fix | Delete
[373] Fix | Delete
// This is the view that controls each theme item
[374] Fix | Delete
// that will be displayed on the screen.
[375] Fix | Delete
themes.view.Theme = wp.Backbone.View.extend({
[376] Fix | Delete
[377] Fix | Delete
// Wrap theme data on a div.theme element.
[378] Fix | Delete
className: 'theme',
[379] Fix | Delete
[380] Fix | Delete
// Reflects which theme view we have.
[381] Fix | Delete
// 'grid' (default) or 'detail'.
[382] Fix | Delete
state: 'grid',
[383] Fix | Delete
[384] Fix | Delete
// The HTML template for each element to be rendered.
[385] Fix | Delete
html: themes.template( 'theme' ),
[386] Fix | Delete
[387] Fix | Delete
events: {
[388] Fix | Delete
'click': themes.isInstall ? 'preview': 'expand',
[389] Fix | Delete
'keydown': themes.isInstall ? 'preview': 'expand',
[390] Fix | Delete
'touchend': themes.isInstall ? 'preview': 'expand',
[391] Fix | Delete
'keyup': 'addFocus',
[392] Fix | Delete
'touchmove': 'preventExpand',
[393] Fix | Delete
'click .theme-install': 'installTheme',
[394] Fix | Delete
'click .update-message': 'updateTheme'
[395] Fix | Delete
},
[396] Fix | Delete
[397] Fix | Delete
touchDrag: false,
[398] Fix | Delete
[399] Fix | Delete
initialize: function() {
[400] Fix | Delete
this.model.on( 'change', this.render, this );
[401] Fix | Delete
},
[402] Fix | Delete
[403] Fix | Delete
render: function() {
[404] Fix | Delete
var data = this.model.toJSON();
[405] Fix | Delete
[406] Fix | Delete
// Render themes using the html template.
[407] Fix | Delete
this.$el.html( this.html( data ) ).attr( 'data-slug', data.id );
[408] Fix | Delete
[409] Fix | Delete
// Renders active theme styles.
[410] Fix | Delete
this.activeTheme();
[411] Fix | Delete
[412] Fix | Delete
if ( this.model.get( 'displayAuthor' ) ) {
[413] Fix | Delete
this.$el.addClass( 'display-author' );
[414] Fix | Delete
}
[415] Fix | Delete
},
[416] Fix | Delete
[417] Fix | Delete
// Adds a class to the currently active theme
[418] Fix | Delete
// and to the overlay in detailed view mode.
[419] Fix | Delete
activeTheme: function() {
[420] Fix | Delete
if ( this.model.get( 'active' ) ) {
[421] Fix | Delete
this.$el.addClass( 'active' );
[422] Fix | Delete
}
[423] Fix | Delete
},
[424] Fix | Delete
[425] Fix | Delete
// Add class of focus to the theme we are focused on.
[426] Fix | Delete
addFocus: function() {
[427] Fix | Delete
var $themeToFocus = ( $( ':focus' ).hasClass( 'theme' ) ) ? $( ':focus' ) : $(':focus').parents('.theme');
[428] Fix | Delete
[429] Fix | Delete
$('.theme.focus').removeClass('focus');
[430] Fix | Delete
$themeToFocus.addClass('focus');
[431] Fix | Delete
},
[432] Fix | Delete
[433] Fix | Delete
// Single theme overlay screen.
[434] Fix | Delete
// It's shown when clicking a theme.
[435] Fix | Delete
expand: function( event ) {
[436] Fix | Delete
var self = this;
[437] Fix | Delete
[438] Fix | Delete
event = event || window.event;
[439] Fix | Delete
[440] Fix | Delete
// 'Enter' and 'Space' keys expand the details view when a theme is :focused.
[441] Fix | Delete
if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) {
[442] Fix | Delete
return;
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
// Bail if the user scrolled on a touch device.
[446] Fix | Delete
if ( this.touchDrag === true ) {
[447] Fix | Delete
return this.touchDrag = false;
[448] Fix | Delete
}
[449] Fix | Delete
[450] Fix | Delete
// Prevent the modal from showing when the user clicks
[451] Fix | Delete
// one of the direct action buttons.
[452] Fix | Delete
if ( $( event.target ).is( '.theme-actions a' ) ) {
[453] Fix | Delete
return;
[454] Fix | Delete
}
[455] Fix | Delete
[456] Fix | Delete
// Prevent the modal from showing when the user clicks one of the direct action buttons.
[457] Fix | Delete
if ( $( event.target ).is( '.theme-actions a, .update-message, .button-link, .notice-dismiss' ) ) {
[458] Fix | Delete
return;
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
// Set focused theme to current element.
[462] Fix | Delete
themes.focusedTheme = this.$el;
[463] Fix | Delete
[464] Fix | Delete
this.trigger( 'theme:expand', self.model.cid );
[465] Fix | Delete
},
[466] Fix | Delete
[467] Fix | Delete
preventExpand: function() {
[468] Fix | Delete
this.touchDrag = true;
[469] Fix | Delete
},
[470] Fix | Delete
[471] Fix | Delete
preview: function( event ) {
[472] Fix | Delete
var self = this,
[473] Fix | Delete
current, preview;
[474] Fix | Delete
[475] Fix | Delete
event = event || window.event;
[476] Fix | Delete
[477] Fix | Delete
// Bail if the user scrolled on a touch device.
[478] Fix | Delete
if ( this.touchDrag === true ) {
[479] Fix | Delete
return this.touchDrag = false;
[480] Fix | Delete
}
[481] Fix | Delete
[482] Fix | Delete
// Allow direct link path to installing a theme.
[483] Fix | Delete
if ( $( event.target ).not( '.install-theme-preview' ).parents( '.theme-actions' ).length ) {
[484] Fix | Delete
return;
[485] Fix | Delete
}
[486] Fix | Delete
[487] Fix | Delete
// 'Enter' and 'Space' keys expand the details view when a theme is :focused.
[488] Fix | Delete
if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) {
[489] Fix | Delete
return;
[490] Fix | Delete
}
[491] Fix | Delete
[492] Fix | Delete
// Pressing Enter while focused on the buttons shouldn't open the preview.
[493] Fix | Delete
if ( event.type === 'keydown' && event.which !== 13 && $( ':focus' ).hasClass( 'button' ) ) {
[494] Fix | Delete
return;
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
event.preventDefault();
[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