Permalink
Browse files

Change favicon during AJAX

  • Loading branch information...
vrana committed Mar 11, 2011
1 parent e52ac37 commit db40abccc86ce67591eb5afee7ab24e074c9bdc0
Showing with 15 additions and 1 deletion.
  1. +1 −1 adminer/include/design.inc.php
  2. +14 −0 adminer/static/functions.js
  3. BIN adminer/static/loader.gif
@@ -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">
@@ -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 {
View
Binary file not shown.

0 comments on commit db40abc

Please sign in to comment.