mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 02:10:45 +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">
|
<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
Block a user