Improve AYS comparison on the Edit Attachment screen, props nacin, fixes #22491

git-svn-id: https://develop.svn.wordpress.org/trunk@22795 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2012-11-21 21:11:21 +00:00
parent 2b0d2a17fb
commit f1cdbe4224
1 changed files with 11 additions and 3 deletions

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