--- a/wp/wp-includes/js/autosave.js Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/js/autosave.js Tue Dec 15 13:49:49 2020 +0100
@@ -3,7 +3,7 @@
*/
/* global tinymce, wpCookies, autosaveL10n, switchEditors */
-// Back-compat
+// Back-compat.
window.autosave = function() {
return true;
};
@@ -23,7 +23,7 @@
*
* @since 3.9.0
*
- * @returns {Object}
+ * @return {Object}
* {{
* getPostData: getPostData,
* getCompareString: getCompareString,
@@ -46,7 +46,7 @@
*
* @param {string} type The type of autosave either local or remote.
*
- * @returns {Object} Object containing the post data.
+ * @return {Object} Object containing the post data.
*/
function getPostData( type ) {
var post_name, parent_id, data,
@@ -110,7 +110,7 @@
*
* @param {Object} postData The object containing the post data.
*
- * @returns {string} A concatenated string with title, content and excerpt.
+ * @return {string} A concatenated string with title, content and excerpt.
*/
function getCompareString( postData ) {
if ( typeof postData === 'object' ) {
@@ -125,7 +125,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function disableButtons() {
$document.trigger('autosave-disable-buttons');
@@ -139,7 +139,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function enableButtons() {
$document.trigger( 'autosave-enable-buttons' );
@@ -150,8 +150,8 @@
*
* @since 4.6.0
*
- * @returns {boolean|*} Returns either false if the editor is undefined,
- * or the instance of the content editor.
+ * @return {boolean|*} Returns either false if the editor is undefined,
+ * or the instance of the content editor.
*/
function getEditor() {
return typeof tinymce !== 'undefined' && tinymce.get('content');
@@ -162,7 +162,7 @@
*
* @since 3.9.0
*
- * @returns {
+ * @return {
* {
* hasStorage: *,
* getSavedPostData: getSavedPostData,
@@ -183,7 +183,7 @@
*
* @since 3.9.0
*
- * @returns {boolean} True if the sessionStorage is supported and enabled.
+ * @return {boolean} True if the sessionStorage is supported and enabled.
*/
function checkStorage() {
var test = Math.random().toString(),
@@ -204,12 +204,12 @@
*
* @since 3.9.0
*
- * @returns {boolean|Object} False if no sessionStorage in the browser or an Object
- * containing all postData for this blog.
+ * @return {boolean|Object} False if no sessionStorage in the browser or an Object
+ * containing all postData for this blog.
*/
function getStorage() {
var stored_obj = false;
- // Separate local storage containers for each blog_id
+ // Separate local storage containers for each blog_id.
if ( hasStorage && blog_id ) {
stored_obj = sessionStorage.getItem( 'wp-autosave-' + blog_id );
@@ -229,7 +229,7 @@
*
* @since 3.9.0
*
- * @returns {boolean} True if the data was saved successfully, false if it wasn't saved.
+ * @return {boolean} True if the data was saved successfully, false if it wasn't saved.
*/
function setStorage( stored_obj ) {
var key;
@@ -248,7 +248,7 @@
*
* @since 3.9.0
*
- * @returns {boolean|Object} False if no storage or no data or the postData as an Object.
+ * @return {boolean|Object} False if no storage or no data or the postData as an Object.
*/
function getSavedPostData() {
var stored = getStorage();
@@ -269,7 +269,7 @@
*
* @param {Object|boolean|null} stored_data The post data to store or null/false/empty to delete the key.
*
- * @returns {boolean} True if data is stored, false if data was removed.
+ * @return {boolean} True if data is stored, false if data was removed.
*/
function setData( stored_data ) {
var stored = getStorage();
@@ -294,7 +294,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function suspend() {
isSuspended = true;
@@ -305,7 +305,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function resume() {
isSuspended = false;
@@ -314,14 +314,14 @@
/**
* Saves post data for the current post.
*
- * Runs on a 15 sec. interval, saves when there are differences in the post title or content.
+ * Runs on a 15 seconds interval, saves when there are differences in the post title or content.
* When the optional data is provided, updates the last saved post data.
*
* @since 3.9.0
*
* @param {Object} data The post data for saving, minimum 'post_title' and 'content'.
*
- * @returns {boolean} Returns true when data has been saved, otherwise it returns false.
+ * @return {boolean} Returns true when data has been saved, otherwise it returns false.
*/
function save( data ) {
var postData, compareString,
@@ -370,7 +370,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function run() {
post_id = $('#post_ID').val() || 0;
@@ -378,9 +378,11 @@
// Check if the local post data is different than the loaded post data.
if ( $( '#wp-content-wrap' ).hasClass( 'tmce-active' ) ) {
- // If TinyMCE loads first, check the post 1.5 sec. after it is ready.
- // By this time the content has been loaded in the editor and 'saved' to the textarea.
- // This prevents false positives.
+ /*
+ * If TinyMCE loads first, check the post 1.5 seconds after it is ready.
+ * By this time the content has been loaded in the editor and 'saved' to the textarea.
+ * This prevents false positives.
+ */
$document.on( 'tinymce-editor-init.autosave', function() {
window.setTimeout( function() {
checkPost();
@@ -390,7 +392,7 @@
checkPost();
}
- // Save every 15 sec.
+ // Save every 15 seconds.
intervalTimer = window.setInterval( save, 15000 );
$( 'form#post' ).on( 'submit.autosave-local', function() {
@@ -427,7 +429,7 @@
*
* @param {string} str1 The first string.
* @param {string} str2 The second string.
- * @returns {boolean} True if the strings are the same.
+ * @return {boolean} True if the strings are the same.
*/
function compare( str1, str2 ) {
function removeSpaces( string ) {
@@ -445,7 +447,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function checkPost() {
var content, post_title, excerpt, $notice,
@@ -456,7 +458,7 @@
if ( cookie === post_id + '-saved' ) {
wpCookies.remove( 'wp-saving-post' );
- // The post was saved properly, remove old data and bail
+ // The post was saved properly, remove old data and bail.
setData( false );
return;
}
@@ -513,13 +515,13 @@
*
* @param {Object} postData The object containing all post data.
*
- * @returns {boolean} True if the post is restored.
+ * @return {boolean} True if the post is restored.
*/
function restorePost( postData ) {
var editor;
if ( postData ) {
- // Set the last saved data
+ // Set the last saved data.
lastCompareString = getCompareString( postData );
if ( $( '#title' ).val() !== postData.post_title ) {
@@ -534,14 +536,14 @@
postData.content = switchEditors.wpautop( postData.content );
}
- // Make sure there's an undo level in the editor
+ // Make sure there's an undo level in the editor.
editor.undoManager.transact( function() {
editor.setContent( postData.content || '' );
editor.nodeChanged();
});
} else {
- // Make sure the Text editor is selected
+ // Make sure the Text editor is selected.
$( '#content-html' ).click();
$( '#content' ).focus();
@@ -558,9 +560,11 @@
blog_id = typeof window.autosaveL10n !== 'undefined' && window.autosaveL10n.blog_id;
- // Check if the browser supports sessionStorage and it's not disabled,
- // then initialize and run checkPost().
- // Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'.
+ /*
+ * Check if the browser supports sessionStorage and it's not disabled,
+ * then initialize and run checkPost().
+ * Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'.
+ */
if ( checkStorage() && blog_id && ( $('#content').length || $('#excerpt').length ) ) {
$document.ready( run );
}
@@ -579,7 +583,7 @@
*
* @since 3.9.0
*
- * @returns {Object} {
+ * @return {Object} {
* {
* tempBlockSave: tempBlockSave,
* triggerSave: triggerSave,
@@ -600,7 +604,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function tempBlockSave() {
_blockSave = true;
@@ -616,7 +620,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function suspend() {
isSuspended = true;
@@ -627,7 +631,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function resume() {
isSuspended = false;
@@ -640,7 +644,7 @@
*
* @param {Object} data The post data.
*
- * @returns {void}
+ * @return {void}
*/
function response( data ) {
_schedule();
@@ -652,7 +656,7 @@
enableButtons();
if ( data.success ) {
- // No longer an auto-draft
+ // No longer an auto-draft.
$( '#auto_draft' ).val('');
}
}
@@ -664,7 +668,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function triggerSave() {
nextRun = 0;
@@ -693,12 +697,12 @@
*
* @since 3.9.0
*
- * @returns {Object} Returns the post data.
+ * @return {Object} Returns the post data.
*/
function save() {
var postData, compareString;
- // window.autosave() used for back-compat
+ // window.autosave() used for back-compat.
if ( isSuspended || _blockSave || ! window.autosave() ) {
return false;
}
@@ -710,12 +714,12 @@
postData = getPostData();
compareString = getCompareString( postData );
- // First check
+ // First check.
if ( typeof lastCompareString === 'undefined' ) {
lastCompareString = initialCompareString;
}
- // No change
+ // No change.
if ( compareString === lastCompareString ) {
return false;
}
@@ -739,7 +743,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
function _schedule() {
nextRun = ( new Date() ).getTime() + ( autosaveL10n.autosaveInterval * 1000 ) || 60000;
@@ -750,7 +754,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
$document.on( 'heartbeat-send.autosave', function( event, data ) {
var autosaveData = save();
@@ -765,7 +769,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
}).on( 'heartbeat-tick.autosave', function( event, data ) {
if ( data.wp_autosave ) {
@@ -776,7 +780,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
}).on( 'heartbeat-connection-lost.autosave', function( event, error, status ) {
@@ -797,7 +801,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
}).on( 'heartbeat-connection-restored.autosave', function() {
$('#lost-connection-notice').hide();
@@ -825,7 +829,7 @@
*
* @since 3.9.0
*
- * @returns {void}
+ * @return {void}
*/
$document.on( 'tinymce-editor-init.autosave', function( event, editor ) {
if ( editor.id === 'content' ) {
@@ -836,7 +840,7 @@
}
}).ready( function() {
- // Set the initial compare string in case TinyMCE is not used or not loaded first
+ // Set the initial compare string in case TinyMCE is not used or not loaded first.
initialCompareString = getCompareString();
});