1 // Interim login dialog
6 var parent = $('#wp-auth-check'), form = $('#wp-auth-check-form'), noframe = wrap.find('.wp-auth-fallback-expired'), frame, loaded = false;
9 // Add unload confirmation to counter (frame-busting) JS redirects
10 $(window).on( 'beforeunload.wp-auth-check', function(e) {
11 e.originalEvent.returnValue = window.authcheckL10n.beforeunload;
14 frame = $('<iframe id="wp-auth-check-frame" frameborder="0">').attr( 'title', noframe.text() );
15 frame.load( function(e) {
21 body = $(this).contents().find('body');
22 height = body.height();
24 wrap.addClass('fallback');
25 parent.css( 'max-height', '' );
32 if ( body && body.hasClass('interim-login-success') )
35 parent.css( 'max-height', height + 40 + 'px' );
36 } else if ( ! body || ! body.length ) {
37 // Catch "silent" iframe origin exceptions in WebKit after another page is loaded in the iframe
38 wrap.addClass('fallback');
39 parent.css( 'max-height', '' );
43 }).attr( 'src', form.data('src') );
45 $('#wp-auth-check-form').append( frame );
48 wrap.removeClass('hidden');
52 // WebKit doesn't throw an error if the iframe fails to load because of "X-Frame-Options: DENY" header.
53 // Wait for 10 sec. and switch to the fallback text.
54 setTimeout( function() {
56 wrap.addClass('fallback');
67 $(window).off( 'beforeunload.wp-auth-check' );
69 // When on the Edit Post screen, speed up heartbeat after the user logs in to quickly refresh nonces
70 if ( typeof adminpage != 'undefined' && ( adminpage == 'post-php' || adminpage == 'post-new-php' )
71 && typeof wp != 'undefined' && wp.heartbeat ) {
73 wp.heartbeat.interval( 'fast', 1 );
76 wrap.fadeOut( 200, function() {
77 wrap.addClass('hidden').css('display', '');
78 $('#wp-auth-check-frame').remove();
83 var interval = parseInt( window.authcheckL10n.interval, 10 ) || 180; // in seconds, default 3 min.
84 next = ( new Date() ).getTime() + ( interval * 1000 );
87 $( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
88 if ( 'wp-auth-check' in data ) {
90 if ( ! data['wp-auth-check'] && wrap.hasClass('hidden') )
92 else if ( data['wp-auth-check'] && ! wrap.hasClass('hidden') )
95 }).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
96 if ( ( new Date() ).getTime() > next )
97 data['wp-auth-check'] = true;
98 }).ready( function() {
100 wrap = $('#wp-auth-check-wrap');
101 wrap.find('.wp-auth-check-close').on( 'click', function(e) {