WordPress.org

Make WordPress Core

Changeset 22725


Ignore:
Timestamp:
11/20/2012 07:46:38 PM (8 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

Location:
trunk/wp-admin
Files:
3 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 } ?>
  • trunk/wp-admin/post-new.php

    r22291 r22725  
    4444    wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
    4545
    46 wp_enqueue_script('autosave');
     46if ( 'attachment' !== $post_type )
     47    wp_enqueue_script('autosave');
    4748
    4849// Show post form.
  • trunk/wp-admin/post.php

    r21948 r22725  
    170170    } else {
    171171        $active_post_lock = wp_set_post_lock( $post->ID );
    172         wp_enqueue_script('autosave');
     172
     173        if ( 'attachment' !== $post_type )
     174            wp_enqueue_script('autosave');
    173175    }
    174176
Note: See TracChangeset for help on using the changeset viewer.