2 // Interim login dialog
7 var parent = $('#wp-auth-check'),
8 form = $('#wp-auth-check-form'),
9 noframe = wrap.find('.wp-auth-fallback-expired'),
10 frame, loaded = false;
13 // Add unload confirmation to counter (frame-busting) JS redirects
14 $(window).on( 'beforeunload.wp-auth-check', function(e) {
15 e.originalEvent.returnValue = window.authcheckL10n.beforeunload;
18 frame = $('<iframe id="wp-auth-check-frame" frameborder="0">').attr( 'title', noframe.text() );
19 frame.on( 'load', function() {
23 // Remove the spinner to avoid unnecessary CPU/GPU usage.
24 form.removeClass( 'loading' );
27 body = $(this).contents().find('body');
28 height = body.height();
30 wrap.addClass('fallback');
31 parent.css( 'max-height', '' );
38 if ( body && body.hasClass('interim-login-success') )
41 parent.css( 'max-height', height + 40 + 'px' );
42 } else if ( ! body || ! body.length ) {
43 // Catch "silent" iframe origin exceptions in WebKit after another page is loaded in the iframe
44 wrap.addClass('fallback');
45 parent.css( 'max-height', '' );
49 }).attr( 'src', form.data('src') );
54 $( 'body' ).addClass( 'modal-open' );
55 wrap.removeClass('hidden');
59 // WebKit doesn't throw an error if the iframe fails to load because of "X-Frame-Options: DENY" header.
60 // Wait for 10 sec. and switch to the fallback text.
61 setTimeout( function() {
63 wrap.addClass('fallback');
74 $(window).off( 'beforeunload.wp-auth-check' );
76 // When on the Edit Post screen, speed up heartbeat after the user logs in to quickly refresh nonces
77 if ( typeof adminpage !== 'undefined' && ( adminpage === 'post-php' || adminpage === 'post-new-php' ) &&
78 typeof wp !== 'undefined' && wp.heartbeat ) {
80 $(document).off( 'heartbeat-tick.wp-auth-check' );
81 wp.heartbeat.connectNow();
84 wrap.fadeOut( 200, function() {
85 wrap.addClass('hidden').css('display', '');
86 $('#wp-auth-check-frame').remove();
87 $( 'body' ).removeClass( 'modal-open' );
92 var interval = parseInt( window.authcheckL10n.interval, 10 ) || 180; // in seconds, default 3 min.
93 next = ( new Date() ).getTime() + ( interval * 1000 );
96 $( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
97 if ( 'wp-auth-check' in data ) {
99 if ( ! data['wp-auth-check'] && wrap.hasClass('hidden') ) {
101 } else if ( data['wp-auth-check'] && ! wrap.hasClass('hidden') ) {
105 }).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
106 if ( ( new Date() ).getTime() > next ) {
107 data['wp-auth-check'] = true;
109 }).ready( function() {
111 wrap = $('#wp-auth-check-wrap');
112 wrap.find('.wp-auth-check-close').on( 'click', function() {