5
|
1 |
/* global tinymce, wpCookies, autosaveL10n, switchEditors */ |
|
2 |
// Back-compat |
|
3 |
window.autosave = function() { |
|
4 |
return true; |
|
5 |
}; |
0
|
6 |
|
5
|
7 |
( function( $, window ) { |
|
8 |
function autosave() { |
|
9 |
var initialCompareString, |
|
10 |
lastTriggerSave = 0, |
|
11 |
$document = $(document); |
0
|
12 |
|
5
|
13 |
/** |
|
14 |
* Returns the data saved in both local and remote autosave |
|
15 |
* |
|
16 |
* @return object Object containing the post data |
|
17 |
*/ |
|
18 |
function getPostData( type ) { |
|
19 |
var post_name, parent_id, data, |
|
20 |
time = ( new Date() ).getTime(), |
|
21 |
cats = [], |
|
22 |
editor = typeof tinymce !== 'undefined' && tinymce.get('content'); |
0
|
23 |
|
5
|
24 |
// Don't run editor.save() more often than every 3 sec. |
|
25 |
// It is resource intensive and might slow down typing in long posts on slow devices. |
|
26 |
if ( editor && ! editor.isHidden() && time - 3000 > lastTriggerSave ) { |
|
27 |
editor.save(); |
|
28 |
lastTriggerSave = time; |
|
29 |
} |
0
|
30 |
|
5
|
31 |
data = { |
|
32 |
post_id: $( '#post_ID' ).val() || 0, |
|
33 |
post_type: $( '#post_type' ).val() || '', |
|
34 |
post_author: $( '#post_author' ).val() || '', |
|
35 |
post_title: $( '#title' ).val() || '', |
|
36 |
content: $( '#content' ).val() || '', |
|
37 |
excerpt: $( '#excerpt' ).val() || '' |
|
38 |
}; |
|
39 |
|
|
40 |
if ( type === 'local' ) { |
|
41 |
return data; |
0
|
42 |
} |
|
43 |
|
5
|
44 |
$( 'input[id^="in-category-"]:checked' ).each( function() { |
|
45 |
cats.push( this.value ); |
|
46 |
}); |
|
47 |
data.catslist = cats.join(','); |
0
|
48 |
|
5
|
49 |
if ( post_name = $( '#post_name' ).val() ) { |
|
50 |
data.post_name = post_name; |
|
51 |
} |
0
|
52 |
|
5
|
53 |
if ( parent_id = $( '#parent_id' ).val() ) { |
|
54 |
data.parent_id = parent_id; |
|
55 |
} |
0
|
56 |
|
5
|
57 |
if ( $( '#comment_status' ).prop( 'checked' ) ) { |
|
58 |
data.comment_status = 'open'; |
|
59 |
} |
|
60 |
|
|
61 |
if ( $( '#ping_status' ).prop( 'checked' ) ) { |
|
62 |
data.ping_status = 'open'; |
0
|
63 |
} |
|
64 |
|
5
|
65 |
if ( $( '#auto_draft' ).val() === '1' ) { |
|
66 |
data.auto_draft = '1'; |
|
67 |
} |
|
68 |
|
|
69 |
return data; |
0
|
70 |
} |
|
71 |
|
5
|
72 |
// Concatenate title, content and excerpt. Used to track changes when auto-saving. |
|
73 |
function getCompareString( postData ) { |
|
74 |
if ( typeof postData === 'object' ) { |
|
75 |
return ( postData.post_title || '' ) + '::' + ( postData.content || '' ) + '::' + ( postData.excerpt || '' ); |
|
76 |
} |
|
77 |
|
|
78 |
return ( $('#title').val() || '' ) + '::' + ( $('#content').val() || '' ) + '::' + ( $('#excerpt').val() || '' ); |
|
79 |
} |
0
|
80 |
|
5
|
81 |
function disableButtons() { |
|
82 |
$document.trigger('autosave-disable-buttons'); |
|
83 |
// Re-enable 5 sec later. Just gives autosave a head start to avoid collisions. |
|
84 |
setTimeout( enableButtons, 5000 ); |
|
85 |
} |
|
86 |
|
|
87 |
function enableButtons() { |
|
88 |
$document.trigger( 'autosave-enable-buttons' ); |
0
|
89 |
} |
|
90 |
|
5
|
91 |
// Autosave in localStorage |
|
92 |
function autosaveLocal() { |
|
93 |
var restorePostData, undoPostData, blog_id, post_id, hasStorage, intervalTimer, |
|
94 |
lastCompareString, |
|
95 |
isSuspended = false; |
|
96 |
|
|
97 |
// Check if the browser supports sessionStorage and it's not disabled |
|
98 |
function checkStorage() { |
|
99 |
var test = Math.random().toString(), |
|
100 |
result = false; |
0
|
101 |
|
5
|
102 |
try { |
|
103 |
window.sessionStorage.setItem( 'wp-test', test ); |
|
104 |
result = window.sessionStorage.getItem( 'wp-test' ) === test; |
|
105 |
window.sessionStorage.removeItem( 'wp-test' ); |
|
106 |
} catch(e) {} |
|
107 |
|
|
108 |
hasStorage = result; |
|
109 |
return result; |
|
110 |
} |
0
|
111 |
|
5
|
112 |
/** |
|
113 |
* Initialize the local storage |
|
114 |
* |
|
115 |
* @return mixed False if no sessionStorage in the browser or an Object containing all postData for this blog |
|
116 |
*/ |
|
117 |
function getStorage() { |
|
118 |
var stored_obj = false; |
|
119 |
// Separate local storage containers for each blog_id |
|
120 |
if ( hasStorage && blog_id ) { |
|
121 |
stored_obj = sessionStorage.getItem( 'wp-autosave-' + blog_id ); |
0
|
122 |
|
5
|
123 |
if ( stored_obj ) { |
|
124 |
stored_obj = JSON.parse( stored_obj ); |
|
125 |
} else { |
|
126 |
stored_obj = {}; |
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
return stored_obj; |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Set the storage for this blog |
|
135 |
* |
|
136 |
* Confirms that the data was saved successfully. |
|
137 |
* |
|
138 |
* @return bool |
|
139 |
*/ |
|
140 |
function setStorage( stored_obj ) { |
|
141 |
var key; |
0
|
142 |
|
5
|
143 |
if ( hasStorage && blog_id ) { |
|
144 |
key = 'wp-autosave-' + blog_id; |
|
145 |
sessionStorage.setItem( key, JSON.stringify( stored_obj ) ); |
|
146 |
return sessionStorage.getItem( key ) !== null; |
|
147 |
} |
|
148 |
|
|
149 |
return false; |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* Get the saved post data for the current post |
|
154 |
* |
|
155 |
* @return mixed False if no storage or no data or the postData as an Object |
|
156 |
*/ |
|
157 |
function getSavedPostData() { |
|
158 |
var stored = getStorage(); |
|
159 |
|
|
160 |
if ( ! stored || ! post_id ) { |
|
161 |
return false; |
|
162 |
} |
|
163 |
|
|
164 |
return stored[ 'post_' + post_id ] || false; |
0
|
165 |
} |
|
166 |
|
5
|
167 |
/** |
|
168 |
* Set (save or delete) post data in the storage. |
|
169 |
* |
|
170 |
* If stored_data evaluates to 'false' the storage key for the current post will be removed |
|
171 |
* |
|
172 |
* $param stored_data The post data to store or null/false/empty to delete the key |
|
173 |
* @return bool |
|
174 |
*/ |
|
175 |
function setData( stored_data ) { |
|
176 |
var stored = getStorage(); |
0
|
177 |
|
5
|
178 |
if ( ! stored || ! post_id ) { |
|
179 |
return false; |
|
180 |
} |
0
|
181 |
|
5
|
182 |
if ( stored_data ) { |
|
183 |
stored[ 'post_' + post_id ] = stored_data; |
|
184 |
} else if ( stored.hasOwnProperty( 'post_' + post_id ) ) { |
|
185 |
delete stored[ 'post_' + post_id ]; |
|
186 |
} else { |
|
187 |
return false; |
|
188 |
} |
|
189 |
|
|
190 |
return setStorage( stored ); |
|
191 |
} |
|
192 |
|
|
193 |
function suspend() { |
|
194 |
isSuspended = true; |
0
|
195 |
} |
|
196 |
|
5
|
197 |
function resume() { |
|
198 |
isSuspended = false; |
|
199 |
} |
0
|
200 |
|
5
|
201 |
/** |
|
202 |
* Save post data for the current post |
|
203 |
* |
|
204 |
* Runs on a 15 sec. interval, saves when there are differences in the post title or content. |
|
205 |
* When the optional data is provided, updates the last saved post data. |
|
206 |
* |
|
207 |
* $param data optional Object The post data for saving, minimum 'post_title' and 'content' |
|
208 |
* @return bool |
|
209 |
*/ |
|
210 |
function save( data ) { |
|
211 |
var postData, compareString, |
|
212 |
result = false; |
0
|
213 |
|
5
|
214 |
if ( isSuspended || ! hasStorage ) { |
|
215 |
return false; |
|
216 |
} |
0
|
217 |
|
5
|
218 |
if ( data ) { |
|
219 |
postData = getSavedPostData() || {}; |
|
220 |
$.extend( postData, data ); |
|
221 |
} else { |
|
222 |
postData = getPostData('local'); |
|
223 |
} |
|
224 |
|
|
225 |
compareString = getCompareString( postData ); |
0
|
226 |
|
5
|
227 |
if ( typeof lastCompareString === 'undefined' ) { |
|
228 |
lastCompareString = initialCompareString; |
|
229 |
} |
0
|
230 |
|
5
|
231 |
// If the content, title and excerpt did not change since the last save, don't save again |
|
232 |
if ( compareString === lastCompareString ) { |
|
233 |
return false; |
|
234 |
} |
0
|
235 |
|
5
|
236 |
postData.save_time = ( new Date() ).getTime(); |
|
237 |
postData.status = $( '#post_status' ).val() || ''; |
|
238 |
result = setData( postData ); |
0
|
239 |
|
5
|
240 |
if ( result ) { |
|
241 |
lastCompareString = compareString; |
|
242 |
} |
0
|
243 |
|
5
|
244 |
return result; |
|
245 |
} |
0
|
246 |
|
5
|
247 |
// Run on DOM ready |
|
248 |
function run() { |
|
249 |
post_id = $('#post_ID').val() || 0; |
0
|
250 |
|
5
|
251 |
// Check if the local post data is different than the loaded post data. |
|
252 |
if ( $( '#wp-content-wrap' ).hasClass( 'tmce-active' ) ) { |
|
253 |
// If TinyMCE loads first, check the post 1.5 sec. after it is ready. |
|
254 |
// By this time the content has been loaded in the editor and 'saved' to the textarea. |
|
255 |
// This prevents false positives. |
|
256 |
$document.on( 'tinymce-editor-init.autosave', function() { |
|
257 |
window.setTimeout( function() { |
|
258 |
checkPost(); |
|
259 |
}, 1500 ); |
|
260 |
}); |
|
261 |
} else { |
|
262 |
checkPost(); |
|
263 |
} |
|
264 |
|
|
265 |
// Save every 15 sec. |
|
266 |
intervalTimer = window.setInterval( save, 15000 ); |
0
|
267 |
|
5
|
268 |
$( 'form#post' ).on( 'submit.autosave-local', function() { |
|
269 |
var editor = typeof tinymce !== 'undefined' && tinymce.get('content'), |
|
270 |
post_id = $('#post_ID').val() || 0; |
|
271 |
|
|
272 |
if ( editor && ! editor.isHidden() ) { |
|
273 |
// Last onSubmit event in the editor, needs to run after the content has been moved to the textarea. |
|
274 |
editor.on( 'submit', function() { |
|
275 |
save({ |
|
276 |
post_title: $( '#title' ).val() || '', |
|
277 |
content: $( '#content' ).val() || '', |
|
278 |
excerpt: $( '#excerpt' ).val() || '' |
|
279 |
}); |
|
280 |
}); |
|
281 |
} else { |
|
282 |
save({ |
|
283 |
post_title: $( '#title' ).val() || '', |
|
284 |
content: $( '#content' ).val() || '', |
|
285 |
excerpt: $( '#excerpt' ).val() || '' |
0
|
286 |
}); |
|
287 |
} |
|
288 |
|
5
|
289 |
wpCookies.set( 'wp-saving-post', post_id + '-check', 24 * 60 * 60 ); |
0
|
290 |
}); |
|
291 |
} |
|
292 |
|
5
|
293 |
// Strip whitespace and compare two strings |
|
294 |
function compare( str1, str2 ) { |
|
295 |
function removeSpaces( string ) { |
|
296 |
return string.toString().replace(/[\x20\t\r\n\f]+/g, ''); |
|
297 |
} |
|
298 |
|
|
299 |
return ( removeSpaces( str1 || '' ) === removeSpaces( str2 || '' ) ); |
|
300 |
} |
0
|
301 |
|
5
|
302 |
/** |
|
303 |
* Check if the saved data for the current post (if any) is different than the loaded post data on the screen |
|
304 |
* |
|
305 |
* Shows a standard message letting the user restore the post data if different. |
|
306 |
* |
|
307 |
* @return void |
|
308 |
*/ |
|
309 |
function checkPost() { |
|
310 |
var content, post_title, excerpt, $notice, |
|
311 |
postData = getSavedPostData(), |
|
312 |
cookie = wpCookies.get( 'wp-saving-post' ); |
|
313 |
|
|
314 |
if ( cookie === post_id + '-saved' ) { |
|
315 |
wpCookies.remove( 'wp-saving-post' ); |
|
316 |
// The post was saved properly, remove old data and bail |
|
317 |
setData( false ); |
|
318 |
return; |
|
319 |
} |
0
|
320 |
|
5
|
321 |
if ( ! postData ) { |
|
322 |
return; |
|
323 |
} |
|
324 |
|
|
325 |
// There is a newer autosave. Don't show two "restore" notices at the same time. |
|
326 |
if ( $( '#has-newer-autosave' ).length ) { |
|
327 |
return; |
|
328 |
} |
|
329 |
|
|
330 |
content = $( '#content' ).val() || ''; |
|
331 |
post_title = $( '#title' ).val() || ''; |
|
332 |
excerpt = $( '#excerpt' ).val() || ''; |
|
333 |
|
|
334 |
if ( compare( content, postData.content ) && compare( post_title, postData.post_title ) && |
|
335 |
compare( excerpt, postData.excerpt ) ) { |
0
|
336 |
|
5
|
337 |
return; |
|
338 |
} |
|
339 |
|
|
340 |
restorePostData = postData; |
|
341 |
undoPostData = { |
|
342 |
content: content, |
|
343 |
post_title: post_title, |
|
344 |
excerpt: excerpt |
|
345 |
}; |
|
346 |
|
|
347 |
$notice = $( '#local-storage-notice' ); |
|
348 |
$('.wrap h2').first().after( $notice.addClass( 'notice-warning' ).show() ); |
|
349 |
|
|
350 |
$notice.on( 'click.autosave-local', function( event ) { |
|
351 |
var $target = $( event.target ); |
0
|
352 |
|
5
|
353 |
if ( $target.hasClass( 'restore-backup' ) ) { |
|
354 |
restorePost( restorePostData ); |
|
355 |
$target.parent().hide(); |
|
356 |
$(this).find( 'p.undo-restore' ).show(); |
|
357 |
$notice.removeClass( 'notice-warning' ).addClass( 'notice-success' ); |
|
358 |
} else if ( $target.hasClass( 'undo-restore-backup' ) ) { |
|
359 |
restorePost( undoPostData ); |
|
360 |
$target.parent().hide(); |
|
361 |
$(this).find( 'p.local-restore' ).show(); |
|
362 |
$notice.removeClass( 'notice-success' ).addClass( 'notice-warning' ); |
|
363 |
} |
0
|
364 |
|
5
|
365 |
event.preventDefault(); |
|
366 |
}); |
0
|
367 |
} |
5
|
368 |
|
|
369 |
// Restore the current title, content and excerpt from postData. |
|
370 |
function restorePost( postData ) { |
|
371 |
var editor; |
|
372 |
|
|
373 |
if ( postData ) { |
|
374 |
// Set the last saved data |
|
375 |
lastCompareString = getCompareString( postData ); |
|
376 |
|
|
377 |
if ( $( '#title' ).val() !== postData.post_title ) { |
|
378 |
$( '#title' ).focus().val( postData.post_title || '' ); |
|
379 |
} |
|
380 |
|
|
381 |
$( '#excerpt' ).val( postData.excerpt || '' ); |
|
382 |
editor = typeof tinymce !== 'undefined' && tinymce.get('content'); |
0
|
383 |
|
5
|
384 |
if ( editor && ! editor.isHidden() && typeof switchEditors !== 'undefined' ) { |
|
385 |
// Make sure there's an undo level in the editor |
|
386 |
editor.undoManager.add(); |
|
387 |
editor.setContent( postData.content ? switchEditors.wpautop( postData.content ) : '' ); |
|
388 |
} else { |
|
389 |
// Make sure the Text editor is selected |
|
390 |
$( '#content-html' ).click(); |
|
391 |
$( '#content' ).val( postData.content ); |
|
392 |
} |
|
393 |
|
|
394 |
return true; |
|
395 |
} |
|
396 |
|
|
397 |
return false; |
|
398 |
} |
0
|
399 |
|
5
|
400 |
blog_id = typeof window.autosaveL10n !== 'undefined' && window.autosaveL10n.blog_id; |
0
|
401 |
|
5
|
402 |
// Check if the browser supports sessionStorage and it's not disabled, |
|
403 |
// then initialize and run checkPost(). |
|
404 |
// Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'. |
|
405 |
if ( checkStorage() && blog_id && ( $('#content').length || $('#excerpt').length ) ) { |
|
406 |
$document.ready( run ); |
|
407 |
} |
0
|
408 |
|
5
|
409 |
return { |
|
410 |
hasStorage: hasStorage, |
|
411 |
getSavedPostData: getSavedPostData, |
|
412 |
save: save, |
|
413 |
suspend: suspend, |
|
414 |
resume: resume |
|
415 |
}; |
0
|
416 |
} |
|
417 |
|
5
|
418 |
// Autosave on the server |
|
419 |
function autosaveServer() { |
|
420 |
var _blockSave, _blockSaveTimer, previousCompareString, lastCompareString, |
|
421 |
nextRun = 0, |
|
422 |
isSuspended = false; |
|
423 |
|
|
424 |
// Block saving for the next 10 sec. |
|
425 |
function tempBlockSave() { |
|
426 |
_blockSave = true; |
|
427 |
window.clearTimeout( _blockSaveTimer ); |
0
|
428 |
|
5
|
429 |
_blockSaveTimer = window.setTimeout( function() { |
|
430 |
_blockSave = false; |
|
431 |
}, 10000 ); |
|
432 |
} |
|
433 |
|
|
434 |
function suspend() { |
|
435 |
isSuspended = true; |
|
436 |
} |
|
437 |
|
|
438 |
function resume() { |
|
439 |
isSuspended = false; |
|
440 |
} |
|
441 |
|
|
442 |
// Runs on heartbeat-response |
|
443 |
function response( data ) { |
|
444 |
_schedule(); |
|
445 |
_blockSave = false; |
|
446 |
lastCompareString = previousCompareString; |
|
447 |
previousCompareString = ''; |
0
|
448 |
|
5
|
449 |
$document.trigger( 'after-autosave', [data] ); |
|
450 |
enableButtons(); |
|
451 |
|
|
452 |
if ( data.success ) { |
|
453 |
// No longer an auto-draft |
|
454 |
$( '#auto_draft' ).val(''); |
|
455 |
} |
|
456 |
} |
0
|
457 |
|
5
|
458 |
/** |
|
459 |
* Save immediately |
|
460 |
* |
|
461 |
* Resets the timing and tells heartbeat to connect now |
|
462 |
* |
|
463 |
* @return void |
|
464 |
*/ |
|
465 |
function triggerSave() { |
|
466 |
nextRun = 0; |
|
467 |
wp.heartbeat.connectNow(); |
|
468 |
} |
|
469 |
|
|
470 |
/** |
|
471 |
* Checks if the post content in the textarea has changed since page load. |
|
472 |
* |
|
473 |
* This also happens when TinyMCE is active and editor.save() is triggered by |
|
474 |
* wp.autosave.getPostData(). |
|
475 |
* |
|
476 |
* @return bool |
|
477 |
*/ |
|
478 |
function postChanged() { |
|
479 |
return getCompareString() !== initialCompareString; |
0
|
480 |
} |
|
481 |
|
5
|
482 |
// Runs on 'heartbeat-send' |
|
483 |
function save() { |
|
484 |
var postData, compareString; |
0
|
485 |
|
5
|
486 |
// window.autosave() used for back-compat |
|
487 |
if ( isSuspended || _blockSave || ! window.autosave() ) { |
|
488 |
return false; |
|
489 |
} |
0
|
490 |
|
5
|
491 |
if ( ( new Date() ).getTime() < nextRun ) { |
|
492 |
return false; |
|
493 |
} |
|
494 |
|
|
495 |
postData = getPostData(); |
|
496 |
compareString = getCompareString( postData ); |
0
|
497 |
|
5
|
498 |
// First check |
|
499 |
if ( typeof lastCompareString === 'undefined' ) { |
|
500 |
lastCompareString = initialCompareString; |
|
501 |
} |
0
|
502 |
|
5
|
503 |
// No change |
|
504 |
if ( compareString === lastCompareString ) { |
|
505 |
return false; |
|
506 |
} |
0
|
507 |
|
5
|
508 |
previousCompareString = compareString; |
|
509 |
tempBlockSave(); |
|
510 |
disableButtons(); |
|
511 |
|
|
512 |
$document.trigger( 'wpcountwords', [ postData.content ] ) |
|
513 |
.trigger( 'before-autosave', [ postData ] ); |
|
514 |
|
|
515 |
postData._wpnonce = $( '#_wpnonce' ).val() || ''; |
|
516 |
|
|
517 |
return postData; |
|
518 |
} |
|
519 |
|
|
520 |
function _schedule() { |
|
521 |
nextRun = ( new Date() ).getTime() + ( autosaveL10n.autosaveInterval * 1000 ) || 60000; |
0
|
522 |
} |
|
523 |
|
5
|
524 |
$document.on( 'heartbeat-send.autosave', function( event, data ) { |
|
525 |
var autosaveData = save(); |
|
526 |
|
|
527 |
if ( autosaveData ) { |
|
528 |
data.wp_autosave = autosaveData; |
|
529 |
} |
|
530 |
}).on( 'heartbeat-tick.autosave', function( event, data ) { |
|
531 |
if ( data.wp_autosave ) { |
|
532 |
response( data.wp_autosave ); |
|
533 |
} |
|
534 |
}).on( 'heartbeat-connection-lost.autosave', function( event, error, status ) { |
|
535 |
// When connection is lost, keep user from submitting changes. |
|
536 |
if ( 'timeout' === error || 603 === status ) { |
|
537 |
var $notice = $('#lost-connection-notice'); |
|
538 |
|
|
539 |
if ( ! wp.autosave.local.hasStorage ) { |
|
540 |
$notice.find('.hide-if-no-sessionstorage').hide(); |
|
541 |
} |
|
542 |
|
|
543 |
$notice.show(); |
|
544 |
disableButtons(); |
|
545 |
} |
|
546 |
}).on( 'heartbeat-connection-restored.autosave', function() { |
|
547 |
$('#lost-connection-notice').hide(); |
|
548 |
enableButtons(); |
|
549 |
}).ready( function() { |
|
550 |
_schedule(); |
|
551 |
}); |
|
552 |
|
|
553 |
return { |
|
554 |
tempBlockSave: tempBlockSave, |
|
555 |
triggerSave: triggerSave, |
|
556 |
postChanged: postChanged, |
|
557 |
suspend: suspend, |
|
558 |
resume: resume |
|
559 |
}; |
0
|
560 |
} |
|
561 |
|
5
|
562 |
// Wait for TinyMCE to initialize plus 1 sec. for any external css to finish loading, |
|
563 |
// then 'save' to the textarea before setting initialCompareString. |
|
564 |
// This avoids any insignificant differences between the initial textarea content and the content |
|
565 |
// extracted from the editor. |
|
566 |
$document.on( 'tinymce-editor-init.autosave', function( event, editor ) { |
|
567 |
if ( editor.id === 'content' ) { |
|
568 |
window.setTimeout( function() { |
|
569 |
editor.save(); |
|
570 |
initialCompareString = getCompareString(); |
|
571 |
}, 1000 ); |
|
572 |
} |
|
573 |
}).ready( function() { |
|
574 |
// Set the initial compare string in case TinyMCE is not used or not loaded first |
|
575 |
initialCompareString = getCompareString(); |
|
576 |
}); |
0
|
577 |
|
5
|
578 |
return { |
|
579 |
getPostData: getPostData, |
|
580 |
getCompareString: getCompareString, |
|
581 |
disableButtons: disableButtons, |
|
582 |
enableButtons: enableButtons, |
|
583 |
local: autosaveLocal(), |
|
584 |
server: autosaveServer() |
|
585 |
}; |
|
586 |
} |
0
|
587 |
|
5
|
588 |
window.wp = window.wp || {}; |
|
589 |
window.wp.autosave = autosave(); |
|
590 |
|
|
591 |
}( jQuery, window )); |