Logged out warnings: by default run the logged-out check every 3 min. Tag along if something else is using heartbeat. See #23295
git-svn-id: https://develop.svn.wordpress.org/trunk@24271 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d217792ffb
commit
16f9ab52d5
|
@ -1,6 +1,6 @@
|
||||||
// Interim login dialog
|
// Interim login dialog
|
||||||
(function($){
|
(function($){
|
||||||
var wrap;
|
var wrap, check, timeout;
|
||||||
|
|
||||||
function show() {
|
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;
|
||||||
|
@ -69,19 +69,41 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function schedule() {
|
||||||
|
check = false;
|
||||||
|
window.clearTimeout( timeout );
|
||||||
|
timeout = window.setTimeout( function(){ check = true; }, 180000 ); // 3 min.
|
||||||
|
}
|
||||||
|
|
||||||
$( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
|
$( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
|
||||||
|
if ( check )
|
||||||
|
schedule();
|
||||||
|
|
||||||
if ( data['wp-auth-check'] && wrap.hasClass('hidden') ) {
|
if ( data['wp-auth-check'] && wrap.hasClass('hidden') ) {
|
||||||
show();
|
show();
|
||||||
} else if ( ! data['wp-auth-check'] && ! wrap.hasClass('hidden') && ! wrap.data('logged-in') ) {
|
} else if ( ! data['wp-auth-check'] && ! wrap.hasClass('hidden') && ! wrap.data('logged-in') ) {
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
}).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
|
|
||||||
data['wp-auth-check'] = 1;
|
|
||||||
}).ready( function() {
|
}).ready( function() {
|
||||||
wrap = $('#wp-auth-check-wrap').data('logged-in', 0);
|
schedule();
|
||||||
|
wrap = $('#wp-auth-check-wrap').data( 'logged-in', 0 );
|
||||||
wrap.find('.wp-auth-check-close').on( 'click', function(e) {
|
wrap.find('.wp-auth-check-close').on( 'click', function(e) {
|
||||||
hide();
|
hide();
|
||||||
});
|
});
|
||||||
|
// Bind later
|
||||||
|
$( document ).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
|
||||||
|
var i, empty = true;
|
||||||
|
// Check if something is using heartbeat. If yes, trigger the logged out check too.
|
||||||
|
for ( i in data ) {
|
||||||
|
if ( data.hasOwnProperty( i ) ) {
|
||||||
|
empty = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( check || ! empty )
|
||||||
|
data['wp-auth-check'] = 1;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
|
Loading…
Reference in New Issue