Display AJAX loader favicon only on blur

This commit is contained in:
Jakub Vrana 2011-03-15 12:58:04 +01:00
parent c41c101aa3
commit c708fa1c69

View file

@ -280,7 +280,9 @@ var ajaxState = 0;
*/ */
function ajaxSend(url, data, popState) { function ajaxSend(url, data, popState) {
var currentState = ++ajaxState; var currentState = ++ajaxState;
replaceFavicon('../adminer/static/loader.gif'); onblur = function () {
replaceFavicon('../adminer/static/loader.gif');
};
setHtml('loader', '<img src="../adminer/static/loader.gif" alt="">'); setHtml('loader', '<img src="../adminer/static/loader.gif" alt="">');
return ajax(url, function (xmlhttp) { return ajax(url, function (xmlhttp) {
if (currentState == ajaxState) { if (currentState == ajaxState) {
@ -295,6 +297,7 @@ function ajaxSend(url, data, popState) {
} }
return ajaxSend(redirect); return ajaxSend(redirect);
} }
onblur = function () { };
replaceFavicon('../adminer/static/favicon.ico'); replaceFavicon('../adminer/static/favicon.ico');
if (!xmlhttp.status) { if (!xmlhttp.status) {
setHtml('loader', ''); setHtml('loader', '');
@ -355,7 +358,7 @@ function ajaxMain(url, data, event) {
/** Revive page from history /** Revive page from history
* @param PopStateEvent|history * @param PopStateEvent|history
*/ */
window.onpopstate = function (event) { onpopstate = function (event) {
ajaxSend(location.href, event.state, 1); // 1 - disable pushState ajaxSend(location.href, event.state, 1); // 1 - disable pushState
} }