mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-04 18:01:42 +01:00
Improve AYS comparison on the Edit Attachment screen, props nacin, fixes #22491
git-svn-id: http://core.svn.wordpress.org/trunk@22795 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a962e6f58b
commit
522376a1f1
@ -423,14 +423,22 @@ try{document.post.title.focus();}catch(e){}
|
||||
<script type="text/javascript">
|
||||
(function($){
|
||||
function getFieldsContent() {
|
||||
return ($('#title').val() || '') + ($('#attachment_caption').val() || '') +
|
||||
($('#attachment_alt').val() || '') + ($('#attachment_content').val() || '') + ($('#post_name').val() || '');
|
||||
return [ $('#title').val() || '',
|
||||
$('#attachment_caption').val() || '',
|
||||
$('#attachment_alt').val() || '',
|
||||
$('#attachment_content').val() || '',
|
||||
$('#post_name').val() || '' ];
|
||||
}
|
||||
|
||||
var initial = getFieldsContent();
|
||||
|
||||
window.onbeforeunload = function() {
|
||||
if ( initial != getFieldsContent() )
|
||||
var i, changed, current = getFieldsContent();
|
||||
for ( var i = 0; i < initial.length; i++ ) {
|
||||
if ( changed = ( inital[i] !== current[i]) )
|
||||
break;
|
||||
}
|
||||
if ( changed )
|
||||
return '<?php _e('The changes you made will be lost if you navigate away from this page.'); ?>';
|
||||
};
|
||||
})(jQuery);
|
||||
|
Loading…
Reference in New Issue
Block a user