Make WordPress Core

Changeset 22795


Ignore:
Timestamp:
11/21/2012 09:11:21 PM (12 years ago)
Author:
azaozz
Message:

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

File:
1 edited

Legend:

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

    r22742 r22795  
    424424(function($){
    425425    function getFieldsContent() {
    426         return ($('#title').val() || '') + ($('#attachment_caption').val() || '') +
    427         ($('#attachment_alt').val() || '') + ($('#attachment_content').val() || '') + ($('#post_name').val() || '');
     426        return [ $('#title').val() || '',
     427            $('#attachment_caption').val() || '',
     428            $('#attachment_alt').val() || '',
     429            $('#attachment_content').val() || '',
     430            $('#post_name').val() || '' ];
    428431    }
    429432
     
    431434
    432435    window.onbeforeunload = function() {
    433         if ( initial != getFieldsContent() )
     436        var i, changed, current = getFieldsContent();
     437        for ( var i = 0; i < initial.length; i++ ) {
     438            if ( changed = ( inital[i] !== current[i]) )
     439                break;
     440        }
     441        if ( changed )
    434442            return '<?php _e('The changes you made will be lost if you navigate away from this page.'); ?>';
    435443    };
Note: See TracChangeset for help on using the changeset viewer.