]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/wp-auth-check.js
Wordpress 4.5.3-scripts
[autoinstalls/wordpress.git] / wp-includes / js / wp-auth-check.js
index 667143de5df4e2f8b8bbc47356bf5a992df70ff8..9448a47ec7f722c1e53a321bbf530adccdcee7cc 100644 (file)
@@ -1,9 +1,13 @@
+/* global adminpage */
 // Interim login dialog
 (function($){
-       var wrap, check, next;
+       var wrap, next;
 
        function show() {
-               var parent = $('#wp-auth-check'), form = $('#wp-auth-check-form'), noframe = wrap.find('.wp-auth-fallback-expired'), frame, loaded = false;
+               var parent = $('#wp-auth-check'),
+                       form = $('#wp-auth-check-form'),
+                       noframe = wrap.find('.wp-auth-fallback-expired'),
+                       frame, loaded = false;
 
                if ( form.length ) {
                        // Add unload confirmation to counter (frame-busting) JS redirects
                        });
 
                        frame = $('<iframe id="wp-auth-check-frame" frameborder="0">').attr( 'title', noframe.text() );
-                       frame.load( function(e) {
+                       frame.on( 'load', function() {
                                var height, body;
 
                                loaded = true;
+                               // Remove the spinner to avoid unnecessary CPU/GPU usage.
+                               form.removeClass( 'loading' );
 
                                try {
                                        body = $(this).contents().find('body');
                                }
                        }).attr( 'src', form.data('src') );
 
-                       $('#wp-auth-check-form').append( frame );
+                       form.append( frame );
                }
 
+               $( 'body' ).addClass( 'modal-open' );
                wrap.removeClass('hidden');
 
                if ( frame ) {
                $(window).off( 'beforeunload.wp-auth-check' );
 
                // When on the Edit Post screen, speed up heartbeat after the user logs in to quickly refresh nonces
-               if ( typeof adminpage != 'undefined' && ( adminpage == 'post-php' || adminpage == 'post-new-php' )
-                        && typeof wp != 'undefined' && wp.heartbeat ) {
+               if ( typeof adminpage !== 'undefined' && ( adminpage === 'post-php' || adminpage === 'post-new-php' ) &&
+                       typeof wp !== 'undefined' && wp.heartbeat ) {
 
-                       wp.heartbeat.interval( 'fast', 1 );
+                       $(document).off( 'heartbeat-tick.wp-auth-check' );
+                       wp.heartbeat.connectNow();
                }
 
                wrap.fadeOut( 200, function() {
                        wrap.addClass('hidden').css('display', '');
                        $('#wp-auth-check-frame').remove();
+                       $( 'body' ).removeClass( 'modal-open' );
                });
        }
 
        $( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
                if ( 'wp-auth-check' in data ) {
                        schedule();
-                       if ( ! data['wp-auth-check'] && wrap.hasClass('hidden') )
+                       if ( ! data['wp-auth-check'] && wrap.hasClass('hidden') ) {
                                show();
-                       else if ( data['wp-auth-check'] && ! wrap.hasClass('hidden') )
+                       } else if ( data['wp-auth-check'] && ! wrap.hasClass('hidden') ) {
                                hide();
+                       }
                }
        }).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
-               if ( ( new Date() ).getTime() > next )
+               if ( ( new Date() ).getTime() > next ) {
                        data['wp-auth-check'] = true;
+               }
        }).ready( function() {
                schedule();
                wrap = $('#wp-auth-check-wrap');
-               wrap.find('.wp-auth-check-close').on( 'click', function(e) {
+               wrap.find('.wp-auth-check-close').on( 'click', function() {
                        hide();
                });
        });