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: http://core.svn.wordpress.org/trunk@24271 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2013-05-16 01:50:43 +00:00
parent 7583005842
commit 1114e817c2

View File

@ -1,6 +1,6 @@
// Interim login dialog
(function($){
var wrap;
var wrap, check, timeout;
function show() {
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 ) {
if ( check )
schedule();
if ( data['wp-auth-check'] && wrap.hasClass('hidden') ) {
show();
} else if ( ! data['wp-auth-check'] && ! wrap.hasClass('hidden') && ! wrap.data('logged-in') ) {
hide();
}
}).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
data['wp-auth-check'] = 1;
}).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) {
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));