Make WordPress Core


Ignore:
Timestamp:
11/20/2012 07:46:38 PM (12 years ago)
Author:
azaozz
Message:

Don't load autosave.js on the attachment editing screen, add simple AYS on unload if there are changes, props helenyhou, fixes #22491

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r22719 r22725  
    419419</script>
    420420<?php endif; ?>
     421
     422<?php if ( 'attachment' == $post_type ) { ?>
     423<script type="text/javascript">
     424(function($){
     425    function getFieldsContent() {
     426        return ($('#title').val() || '') + ($('#attachment_caption').val() || '') +
     427        ($('#attachment_alt').val() || '') + ($('#attachment_content').val() || '') + ($('#post_name').val() || '');
     428    }
     429
     430    var initial = getFieldsContent();
     431
     432    window.onbeforeunload = function() {
     433        if ( initial != getFieldsContent() )
     434            return '<?php _e('The changes you made will be lost if you navigate away from this page.'); ?>';
     435    };
     436})(jQuery);
     437</script>
     438<?php } ?>
Note: See TracChangeset for help on using the changeset viewer.