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:
Andrew Ozz 2012-11-21 21:11:21 +00:00
parent a962e6f58b
commit 522376a1f1

View File

@ -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);