Change favicon during AJAX

This commit is contained in:
Jakub Vrana 2011-03-11 23:21:54 +01:00
parent e52ac37c3e
commit db40abccc8
3 changed files with 15 additions and 1 deletions

View file

@ -22,7 +22,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta name="robots" content="noindex">
<title><?php echo $title_page; ?></title>
<link rel="shortcut icon" type="image/x-icon" href="../adminer/static/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="../adminer/static/favicon.ico" id="favicon">
<link rel="stylesheet" type="text/css" href="../adminer/static/default.css">
<?php if (file_exists("adminer.css")) { ?>
<link rel="stylesheet" type="text/css" href="adminer.css">

View file

@ -270,6 +270,18 @@ function ajaxSetHtml(url) {
});
}
/** Replace favicon
* @param string
* @return string original href
*/
function replaceFavicon(href) {
var favicon = document.getElementById('favicon');
var orig = favicon.href;
favicon.href = href;
favicon.parentNode.appendChild(favicon); // to replace the icon in Firefox
return orig;
}
var ajaxState = 0;
/** Safely load content to #content
@ -280,9 +292,11 @@ var ajaxState = 0;
*/
function ajaxSend(url, data, popState) {
var currentState = ++ajaxState;
var favicon = replaceFavicon('../adminer/static/loader.gif');
setHtml('loader', '<img src="../adminer/static/loader.gif" alt="">');
return ajax(url, function (text) {
if (currentState == ajaxState) {
replaceFavicon(favicon);
if (text === undefined) {
setHtml('loader', '');
} else {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 673 B