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.load( function() {
25
body = $(this).contents().find('body');
26
height = body.height();
28
wrap.addClass('fallback');
29
parent.css( 'max-height', '' );
36
if ( body && body.hasClass('interim-login-success') )
39
parent.css( 'max-height', height + 40 + 'px' );
40
} else if ( ! body || ! body.length ) {
41
// Catch "silent" iframe origin exceptions in WebKit after another page is loaded in the iframe
42
wrap.addClass('fallback');
43
parent.css( 'max-height', '' );
47
}).attr( 'src', form.data('src') );
49
$('#wp-auth-check-form').append( frame );
52
wrap.removeClass('hidden');
56
// WebKit doesn't throw an error if the iframe fails to load because of "X-Frame-Options: DENY" header.
57
// Wait for 10 sec. and switch to the fallback text.
58
setTimeout( function() {
60
wrap.addClass('fallback');
71
$(window).off( 'beforeunload.wp-auth-check' );
73
// When on the Edit Post screen, speed up heartbeat after the user logs in to quickly refresh nonces
74
if ( typeof adminpage !== 'undefined' && ( adminpage === 'post-php' || adminpage === 'post-new-php' ) &&
75
typeof wp !== 'undefined' && wp.heartbeat ) {
77
wp.heartbeat.connectNow();
80
wrap.fadeOut( 200, function() {
81
wrap.addClass('hidden').css('display', '');
82
$('#wp-auth-check-frame').remove();
87
var interval = parseInt( window.authcheckL10n.interval, 10 ) || 180; // in seconds, default 3 min.
88
next = ( new Date() ).getTime() + ( interval * 1000 );
91
$( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
92
if ( 'wp-auth-check' in data ) {
94
if ( ! data['wp-auth-check'] && wrap.hasClass('hidden') ) {
96
} else if ( data['wp-auth-check'] && ! wrap.hasClass('hidden') ) {
100
}).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
101
if ( ( new Date() ).getTime() > next ) {
102
data['wp-auth-check'] = true;
104
}).ready( function() {
106
wrap = $('#wp-auth-check-wrap');
107
wrap.find('.wp-auth-check-close').on( 'click', function() {