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:
parent
2b0d2a17fb
commit
f1cdbe4224
|
@ -423,14 +423,22 @@ try{document.post.title.focus();}catch(e){}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function($){
|
(function($){
|
||||||
function getFieldsContent() {
|
function getFieldsContent() {
|
||||||
return ($('#title').val() || '') + ($('#attachment_caption').val() || '') +
|
return [ $('#title').val() || '',
|
||||||
($('#attachment_alt').val() || '') + ($('#attachment_content').val() || '') + ($('#post_name').val() || '');
|
$('#attachment_caption').val() || '',
|
||||||
|
$('#attachment_alt').val() || '',
|
||||||
|
$('#attachment_content').val() || '',
|
||||||
|
$('#post_name').val() || '' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
var initial = getFieldsContent();
|
var initial = getFieldsContent();
|
||||||
|
|
||||||
window.onbeforeunload = function() {
|
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.'); ?>';
|
return '<?php _e('The changes you made will be lost if you navigate away from this page.'); ?>';
|
||||||
};
|
};
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
Loading…
Reference in New Issue