Autosave:
- Move the 'Saving post' and 'Draft saved at...' strings from autosaveL10n to postL10n as they are used only there. - Use the custom jQuery events 'before-autosave' and 'after-autosave' to show these messages. - Separate autosave.suspend() for local and server so local autosaves can continue while server autosaves are suspended. - Remove the recently added autosave.server.disable() and use autosave.server.suspend() instead. - Bring back .button.disabled, button-primary.disabled and use .disabled to prevent multiple form submissions. See #25272. Built from https://develop.svn.wordpress.org/trunk@27038 git-svn-id: http://core.svn.wordpress.org/trunk@26914 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ced6e2a428
commit
864ab9ae56
|
@ -1,10 +1,12 @@
|
||||||
/* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting, getUserSetting, setUserSetting */
|
/* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting */
|
||||||
/* global theList:true, theExtraList:true, autosave:true */
|
/* global theList:true, theExtraList:true, getUserSetting, setUserSetting */
|
||||||
|
|
||||||
var tagBox, commentsBox, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint;
|
var tagBox, commentsBox, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint, makeSlugeditClickable, editPermalink;
|
||||||
// Back-compat: prevent fatal errors
|
// Back-compat: prevent fatal errors
|
||||||
makeSlugeditClickable = editPermalink = function(){};
|
makeSlugeditClickable = editPermalink = function(){};
|
||||||
|
|
||||||
|
window.wp = window.wp || {};
|
||||||
|
|
||||||
// return an array with any duplicate, whitespace or values removed
|
// return an array with any duplicate, whitespace or values removed
|
||||||
function array_unique_noempty(a) {
|
function array_unique_noempty(a) {
|
||||||
var out = [];
|
var out = [];
|
||||||
|
@ -283,10 +285,10 @@ $(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
|
||||||
wrap = $('#post-lock-dialog');
|
wrap = $('#post-lock-dialog');
|
||||||
|
|
||||||
if ( wrap.length && ! wrap.is(':visible') ) {
|
if ( wrap.length && ! wrap.is(':visible') ) {
|
||||||
if ( typeof wp != 'undefined' && wp.autosave ) {
|
if ( wp.autosave ) {
|
||||||
// Save the latest changes and disable
|
// Save the latest changes and disable
|
||||||
$(document).one( 'heartbeat-tick', function() {
|
$(document).one( 'heartbeat-tick', function() {
|
||||||
wp.autosave.server.disable();
|
wp.autosave.server.suspend();
|
||||||
wrap.removeClass('saving').addClass('saved');
|
wrap.removeClass('saving').addClass('saved');
|
||||||
$(window).off( 'beforeunload.edit-post' );
|
$(window).off( 'beforeunload.edit-post' );
|
||||||
});
|
});
|
||||||
|
@ -313,7 +315,7 @@ $(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
|
||||||
$.post( ajaxurl, {
|
$.post( ajaxurl, {
|
||||||
action: 'sample-permalink',
|
action: 'sample-permalink',
|
||||||
post_id: $('#post_ID').val(),
|
post_id: $('#post_ID').val(),
|
||||||
new_title: typeof fullscreen != 'undefined' && fullscreen.settings.visible ? $('#wp-fullscreen-title').val() : $('#title').val(),
|
new_title: $('#title').val(),
|
||||||
samplepermalinknonce: $('#samplepermalinknonce').val()
|
samplepermalinknonce: $('#samplepermalinknonce').val()
|
||||||
},
|
},
|
||||||
function( data ) {
|
function( data ) {
|
||||||
|
@ -368,7 +370,7 @@ $(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
|
||||||
jQuery(document).ready( function($) {
|
jQuery(document).ready( function($) {
|
||||||
var stamp, visibility, $submitButtons,
|
var stamp, visibility, $submitButtons, updateVisibility, updateText,
|
||||||
sticky = '',
|
sticky = '',
|
||||||
last = 0,
|
last = 0,
|
||||||
co = $('#content'),
|
co = $('#content'),
|
||||||
|
@ -399,7 +401,7 @@ jQuery(document).ready( function($) {
|
||||||
}).filter(':visible').find('.wp-tab-first').focus();
|
}).filter(':visible').find('.wp-tab-first').focus();
|
||||||
|
|
||||||
// Set the heartbeat interval to 15 sec. if post lock dialogs are enabled
|
// Set the heartbeat interval to 15 sec. if post lock dialogs are enabled
|
||||||
if ( typeof wp !== 'undefined' && wp.heartbeat && $('#post-lock-dialog').length ) {
|
if ( wp.heartbeat && $('#post-lock-dialog').length ) {
|
||||||
wp.heartbeat.interval( 15 );
|
wp.heartbeat.interval( 15 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +409,7 @@ jQuery(document).ready( function($) {
|
||||||
$submitButtons = $submitpost.find( ':button, :submit, a.submitdelete, #post-preview' ).on( 'click.edit-post', function( event ) {
|
$submitButtons = $submitpost.find( ':button, :submit, a.submitdelete, #post-preview' ).on( 'click.edit-post', function( event ) {
|
||||||
var $button = $(this);
|
var $button = $(this);
|
||||||
|
|
||||||
if ( $button.hasClass('button-disabled') ) {
|
if ( $button.hasClass('disabled') ) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -423,14 +425,15 @@ jQuery(document).ready( function($) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( typeof wp != 'undefined' && wp.autosave ) {
|
// Stop autosave
|
||||||
wp.autosave.server.disable();
|
if ( wp.autosave ) {
|
||||||
|
wp.autosave.server.suspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseLock = false;
|
releaseLock = false;
|
||||||
$(window).off( 'beforeunload.edit-post' );
|
$(window).off( 'beforeunload.edit-post' );
|
||||||
|
|
||||||
$submitButtons.addClass( 'button-disabled' );
|
$submitButtons.addClass( 'disabled' );
|
||||||
|
|
||||||
if ( $button.attr('id') === 'publish' ) {
|
if ( $button.attr('id') === 'publish' ) {
|
||||||
$submitpost.find('#major-publishing-actions .spinner').show();
|
$submitpost.find('#major-publishing-actions .spinner').show();
|
||||||
|
@ -450,11 +453,11 @@ jQuery(document).ready( function($) {
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if ( $this.prop('disabled') ) {
|
if ( $this.hasClass('disabled') ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( typeof wp != 'undefined' && wp.autosave ) {
|
if ( wp.autosave ) {
|
||||||
wp.autosave.server.tempBlockSave();
|
wp.autosave.server.tempBlockSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,27 +499,31 @@ jQuery(document).ready( function($) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( typeof wp != 'undefined' && wp.autosave ) {
|
if ( wp.autosave ) {
|
||||||
wp.autosave.server.triggerSave();
|
wp.autosave.server.triggerSave();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on( 'autosave-disable-buttons.edit-post', function() {
|
$(document).on( 'autosave-disable-buttons.edit-post', function() {
|
||||||
$submitButtons.addClass( 'button-disabled' );
|
$submitButtons.addClass( 'disabled' );
|
||||||
}).on( 'autosave-enable-buttons.edit-post', function() {
|
}).on( 'autosave-enable-buttons.edit-post', function() {
|
||||||
if ( ! window.wp || ! window.wp.heartbeat || ! window.wp.heartbeat.hasConnectionError() ) {
|
if ( ! wp.heartbeat || ! wp.heartbeat.hasConnectionError() ) {
|
||||||
$submitButtons.removeClass( 'button-disabled' );
|
$submitButtons.removeClass( 'disabled' );
|
||||||
}
|
}
|
||||||
|
}).on( 'before-autosave.edit-post', function() {
|
||||||
|
$( '.autosave-message' ).text( postL10n.savingText );
|
||||||
|
}).on( 'after-autosave.edit-post', function( event, data ) {
|
||||||
|
$( '.autosave-message' ).text( data.message );
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on( 'beforeunload.edit-post', function() {
|
$(window).on( 'beforeunload.edit-post', function() {
|
||||||
var editor = typeof tinymce !== 'undefined' && tinymce.get('content');
|
var editor = typeof tinymce !== 'undefined' && tinymce.get('content');
|
||||||
|
|
||||||
if ( ( editor && ! editor.isHidden() && editor.isDirty() ) ||
|
if ( ( editor && ! editor.isHidden() && editor.isDirty() ) ||
|
||||||
( typeof wp !== 'undefined' && wp.autosave && wp.autosave.server.postChanged() ) ) {
|
( wp.autosave && wp.autosave.server.postChanged() ) ) {
|
||||||
|
|
||||||
return autosaveL10n.saveAlert;
|
return postL10n.saveAlert;
|
||||||
}
|
}
|
||||||
}).on( 'unload.edit-post', function( event ) {
|
}).on( 'unload.edit-post', function( event ) {
|
||||||
if ( ! releaseLock ) {
|
if ( ! releaseLock ) {
|
||||||
|
@ -817,7 +824,7 @@ jQuery(document).ready( function($) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$timestampdiv.show();
|
$timestampdiv.show();
|
||||||
|
|
||||||
if ( typeof wp !== 'undefined' && wp.autosave ) {
|
if ( wp.autosave ) {
|
||||||
wp.autosave.enableButtons();
|
wp.autosave.enableButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,70 +855,76 @@ jQuery(document).ready( function($) {
|
||||||
} // end submitdiv
|
} // end submitdiv
|
||||||
|
|
||||||
// permalink
|
// permalink
|
||||||
if ( $editSlugWrap.length ) {
|
function editPermalink() {
|
||||||
function editPermalink() {
|
var i, slug_value,
|
||||||
var i, c = 0, e = $('#editable-post-name'), revert_e = e.html(), real_slug = $('#post_name'),
|
c = 0,
|
||||||
revert_slug = real_slug.val(), b = $('#edit-slug-buttons'), revert_b = b.html(),
|
e = $('#editable-post-name'),
|
||||||
full = $('#editable-post-name-full').html();
|
revert_e = e.html(),
|
||||||
|
real_slug = $('#post_name'),
|
||||||
|
revert_slug = real_slug.val(),
|
||||||
|
b = $('#edit-slug-buttons'),
|
||||||
|
revert_b = b.html(),
|
||||||
|
full = $('#editable-post-name-full').html();
|
||||||
|
|
||||||
$('#view-post-btn').hide();
|
$('#view-post-btn').hide();
|
||||||
b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>');
|
b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>');
|
||||||
b.children('.save').click(function() {
|
b.children('.save').click(function() {
|
||||||
var new_slug = e.children('input').val();
|
var new_slug = e.children('input').val();
|
||||||
if ( new_slug == $('#editable-post-name-full').text() ) {
|
if ( new_slug == $('#editable-post-name-full').text() ) {
|
||||||
return $('#edit-slug-buttons .cancel').click();
|
return $('#edit-slug-buttons .cancel').click();
|
||||||
}
|
|
||||||
$.post(ajaxurl, {
|
|
||||||
action: 'sample-permalink',
|
|
||||||
post_id: postId,
|
|
||||||
new_slug: new_slug,
|
|
||||||
new_title: $('#title').val(),
|
|
||||||
samplepermalinknonce: $('#samplepermalinknonce').val()
|
|
||||||
}, function(data) {
|
|
||||||
var box = $('#edit-slug-box');
|
|
||||||
box.html(data);
|
|
||||||
if (box.hasClass('hidden')) {
|
|
||||||
box.fadeIn('fast', function () {
|
|
||||||
box.removeClass('hidden');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
b.html(revert_b);
|
|
||||||
real_slug.val(new_slug);
|
|
||||||
$('#view-post-btn').show();
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#edit-slug-buttons .cancel').click(function() {
|
|
||||||
$('#view-post-btn').show();
|
|
||||||
e.html(revert_e);
|
|
||||||
b.html(revert_b);
|
|
||||||
real_slug.val(revert_slug);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
for ( i = 0; i < full.length; ++i ) {
|
|
||||||
if ( '%' == full.charAt(i) )
|
|
||||||
c++;
|
|
||||||
}
|
}
|
||||||
|
$.post(ajaxurl, {
|
||||||
slug_value = ( c > full.length / 4 ) ? '' : full;
|
action: 'sample-permalink',
|
||||||
e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e) {
|
post_id: postId,
|
||||||
var key = e.keyCode || 0;
|
new_slug: new_slug,
|
||||||
// on enter, just save the new slug, don't save the post
|
new_title: $('#title').val(),
|
||||||
if ( 13 == key ) {
|
samplepermalinknonce: $('#samplepermalinknonce').val()
|
||||||
b.children('.save').click();
|
}, function(data) {
|
||||||
return false;
|
var box = $('#edit-slug-box');
|
||||||
|
box.html(data);
|
||||||
|
if (box.hasClass('hidden')) {
|
||||||
|
box.fadeIn('fast', function () {
|
||||||
|
box.removeClass('hidden');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if ( 27 == key ) {
|
b.html(revert_b);
|
||||||
b.children('.cancel').click();
|
real_slug.val(new_slug);
|
||||||
return false;
|
$('#view-post-btn').show();
|
||||||
}
|
});
|
||||||
} ).keyup( function() {
|
return false;
|
||||||
real_slug.val(this.value);
|
});
|
||||||
}).focus();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
$('#edit-slug-buttons .cancel').click(function() {
|
||||||
|
$('#view-post-btn').show();
|
||||||
|
e.html(revert_e);
|
||||||
|
b.html(revert_b);
|
||||||
|
real_slug.val(revert_slug);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
for ( i = 0; i < full.length; ++i ) {
|
||||||
|
if ( '%' == full.charAt(i) )
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
|
||||||
|
slug_value = ( c > full.length / 4 ) ? '' : full;
|
||||||
|
e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e) {
|
||||||
|
var key = e.keyCode || 0;
|
||||||
|
// on enter, just save the new slug, don't save the post
|
||||||
|
if ( 13 == key ) {
|
||||||
|
b.children('.save').click();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( 27 == key ) {
|
||||||
|
b.children('.cancel').click();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} ).keyup( function() {
|
||||||
|
real_slug.val(this.value);
|
||||||
|
}).focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $editSlugWrap.length ) {
|
||||||
$editSlugWrap.on( 'click', function( event ) {
|
$editSlugWrap.on( 'click', function( event ) {
|
||||||
var $target = $( event.target );
|
var $target = $( event.target );
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -165,8 +165,10 @@ TABLE OF CONTENTS:
|
||||||
|
|
||||||
.wp-core-ui .button[disabled],
|
.wp-core-ui .button[disabled],
|
||||||
.wp-core-ui .button:disabled,
|
.wp-core-ui .button:disabled,
|
||||||
|
.wp-core-ui .button.disabled,
|
||||||
.wp-core-ui .button-secondary[disabled],
|
.wp-core-ui .button-secondary[disabled],
|
||||||
.wp-core-ui .button-secondary:disabled,
|
.wp-core-ui .button-secondary:disabled,
|
||||||
|
.wp-core-ui .button-secondary.disabled,
|
||||||
.wp-core-ui .button-disabled {
|
.wp-core-ui .button-disabled {
|
||||||
color: #aaa !important;
|
color: #aaa !important;
|
||||||
border-color: #ddd !important;
|
border-color: #ddd !important;
|
||||||
|
@ -221,7 +223,8 @@ TABLE OF CONTENTS:
|
||||||
|
|
||||||
.wp-core-ui .button-primary[disabled],
|
.wp-core-ui .button-primary[disabled],
|
||||||
.wp-core-ui .button-primary:disabled,
|
.wp-core-ui .button-primary:disabled,
|
||||||
.wp-core-ui .button-primary-disabled {
|
.wp-core-ui .button-primary-disabled,
|
||||||
|
.wp-core-ui .button-primary.disabled {
|
||||||
color: #94cde7 !important;
|
color: #94cde7 !important;
|
||||||
background: #298cba !important;
|
background: #298cba !important;
|
||||||
border-color: #1b607f !important;
|
border-color: #1b607f !important;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -165,8 +165,10 @@ TABLE OF CONTENTS:
|
||||||
|
|
||||||
.wp-core-ui .button[disabled],
|
.wp-core-ui .button[disabled],
|
||||||
.wp-core-ui .button:disabled,
|
.wp-core-ui .button:disabled,
|
||||||
|
.wp-core-ui .button.disabled,
|
||||||
.wp-core-ui .button-secondary[disabled],
|
.wp-core-ui .button-secondary[disabled],
|
||||||
.wp-core-ui .button-secondary:disabled,
|
.wp-core-ui .button-secondary:disabled,
|
||||||
|
.wp-core-ui .button-secondary.disabled,
|
||||||
.wp-core-ui .button-disabled {
|
.wp-core-ui .button-disabled {
|
||||||
color: #aaa !important;
|
color: #aaa !important;
|
||||||
border-color: #ddd !important;
|
border-color: #ddd !important;
|
||||||
|
@ -221,7 +223,8 @@ TABLE OF CONTENTS:
|
||||||
|
|
||||||
.wp-core-ui .button-primary[disabled],
|
.wp-core-ui .button-primary[disabled],
|
||||||
.wp-core-ui .button-primary:disabled,
|
.wp-core-ui .button-primary:disabled,
|
||||||
.wp-core-ui .button-primary-disabled {
|
.wp-core-ui .button-primary-disabled,
|
||||||
|
.wp-core-ui .button-primary.disabled {
|
||||||
color: #94cde7 !important;
|
color: #94cde7 !important;
|
||||||
background: #298cba !important;
|
background: #298cba !important;
|
||||||
border-color: #1b607f !important;
|
border-color: #1b607f !important;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,6 @@ window.autosave = function(){};
|
||||||
function autosave() {
|
function autosave() {
|
||||||
var initialCompareString,
|
var initialCompareString,
|
||||||
lastTriggerSave = 0,
|
lastTriggerSave = 0,
|
||||||
isSuspended = false,
|
|
||||||
$document = $(document);
|
$document = $(document);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,18 +86,11 @@ window.autosave = function(){};
|
||||||
$document.trigger( 'autosave-enable-buttons' );
|
$document.trigger( 'autosave-enable-buttons' );
|
||||||
}
|
}
|
||||||
|
|
||||||
function suspend() {
|
|
||||||
isSuspended = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function resume() {
|
|
||||||
isSuspended = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Autosave in localStorage
|
// Autosave in localStorage
|
||||||
function autosaveLocal() {
|
function autosaveLocal() {
|
||||||
var restorePostData, undoPostData, blog_id, post_id, hasStorage, intervalTimer,
|
var restorePostData, undoPostData, blog_id, post_id, hasStorage, intervalTimer,
|
||||||
lastCompareString;
|
lastCompareString,
|
||||||
|
isSuspended = false;
|
||||||
|
|
||||||
// Check if the browser supports sessionStorage and it's not disabled
|
// Check if the browser supports sessionStorage and it's not disabled
|
||||||
function checkStorage() {
|
function checkStorage() {
|
||||||
|
@ -196,6 +188,14 @@ window.autosave = function(){};
|
||||||
return setStorage( stored );
|
return setStorage( stored );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function suspend() {
|
||||||
|
isSuspended = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resume() {
|
||||||
|
isSuspended = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save post data for the current post
|
* Save post data for the current post
|
||||||
*
|
*
|
||||||
|
@ -415,14 +415,17 @@ window.autosave = function(){};
|
||||||
return {
|
return {
|
||||||
hasStorage: hasStorage,
|
hasStorage: hasStorage,
|
||||||
getSavedPostData: getSavedPostData,
|
getSavedPostData: getSavedPostData,
|
||||||
save: save
|
save: save,
|
||||||
|
suspend: suspend,
|
||||||
|
resume: resume
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Autosave on the server
|
// Autosave on the server
|
||||||
function autosaveServer() {
|
function autosaveServer() {
|
||||||
var _disabled, _blockSave, _blockSaveTimer, previousCompareString, lastCompareString,
|
var _blockSave, _blockSaveTimer, previousCompareString, lastCompareString,
|
||||||
nextRun = 0;
|
nextRun = 0,
|
||||||
|
isSuspended = false;
|
||||||
|
|
||||||
// Block saving for the next 10 sec.
|
// Block saving for the next 10 sec.
|
||||||
function tempBlockSave() {
|
function tempBlockSave() {
|
||||||
|
@ -434,6 +437,14 @@ window.autosave = function(){};
|
||||||
}, 10000 );
|
}, 10000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function suspend() {
|
||||||
|
isSuspended = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resume() {
|
||||||
|
isSuspended = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Runs on heartbeat-response
|
// Runs on heartbeat-response
|
||||||
function response( data ) {
|
function response( data ) {
|
||||||
_schedule();
|
_schedule();
|
||||||
|
@ -442,7 +453,6 @@ window.autosave = function(){};
|
||||||
previousCompareString = '';
|
previousCompareString = '';
|
||||||
|
|
||||||
$document.trigger( 'after-autosave', [data] );
|
$document.trigger( 'after-autosave', [data] );
|
||||||
$( '.autosave-message' ).text( data.message );
|
|
||||||
enableButtons();
|
enableButtons();
|
||||||
|
|
||||||
if ( data.success ) {
|
if ( data.success ) {
|
||||||
|
@ -451,15 +461,6 @@ window.autosave = function(){};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable autosave
|
|
||||||
*
|
|
||||||
* Intended to run on form.submit
|
|
||||||
*/
|
|
||||||
function disable() {
|
|
||||||
_disabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save immediately
|
* Save immediately
|
||||||
*
|
*
|
||||||
|
@ -488,7 +489,7 @@ window.autosave = function(){};
|
||||||
function save() {
|
function save() {
|
||||||
var postData, compareString;
|
var postData, compareString;
|
||||||
|
|
||||||
if ( isSuspended || _disabled || _blockSave ) {
|
if ( isSuspended || _blockSave ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,7 +517,6 @@ window.autosave = function(){};
|
||||||
$document.trigger( 'wpcountwords', [ postData.content ] )
|
$document.trigger( 'wpcountwords', [ postData.content ] )
|
||||||
.trigger( 'before-autosave', [ postData ] );
|
.trigger( 'before-autosave', [ postData ] );
|
||||||
|
|
||||||
$( '.autosave-message' ).text( autosaveL10n.savingText );
|
|
||||||
postData._wpnonce = $( '#_wpnonce' ).val() || '';
|
postData._wpnonce = $( '#_wpnonce' ).val() || '';
|
||||||
|
|
||||||
return postData;
|
return postData;
|
||||||
|
@ -556,10 +556,11 @@ window.autosave = function(){};
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
disable: disable,
|
|
||||||
tempBlockSave: tempBlockSave,
|
tempBlockSave: tempBlockSave,
|
||||||
triggerSave: triggerSave,
|
triggerSave: triggerSave,
|
||||||
postChanged: postChanged
|
postChanged: postChanged,
|
||||||
|
suspend: suspend,
|
||||||
|
resume: resume
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,8 +585,6 @@ window.autosave = function(){};
|
||||||
getCompareString: getCompareString,
|
getCompareString: getCompareString,
|
||||||
disableButtons: disableButtons,
|
disableButtons: disableButtons,
|
||||||
enableButtons: enableButtons,
|
enableButtons: enableButtons,
|
||||||
suspend: suspend,
|
|
||||||
resume: resume,
|
|
||||||
local: autosaveLocal(),
|
local: autosaveLocal(),
|
||||||
server: autosaveServer()
|
server: autosaveServer()
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -430,6 +430,8 @@ function wp_default_scripts( &$scripts ) {
|
||||||
'privatelyPublished' => __('Privately Published'),
|
'privatelyPublished' => __('Privately Published'),
|
||||||
'published' => __('Published'),
|
'published' => __('Published'),
|
||||||
'comma' => _x( ',', 'tag delimiter' ),
|
'comma' => _x( ',', 'tag delimiter' ),
|
||||||
|
'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
|
||||||
|
'savingText' => __('Saving Draft…'),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
|
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
|
||||||
|
@ -653,8 +655,6 @@ function wp_just_in_time_script_localization() {
|
||||||
|
|
||||||
wp_localize_script( 'autosave', 'autosaveL10n', array(
|
wp_localize_script( 'autosave', 'autosaveL10n', array(
|
||||||
'autosaveInterval' => AUTOSAVE_INTERVAL,
|
'autosaveInterval' => AUTOSAVE_INTERVAL,
|
||||||
'savingText' => __('Saving Draft…'),
|
|
||||||
'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
|
|
||||||
'blog_id' => get_current_blog_id(),
|
'blog_id' => get_current_blog_id(),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue