-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new file: joomla.asset.json new file: js/functions.js modified: pankybrowsertitle.php modified: pankybrowsertitle.xml
- Loading branch information
Showing
4 changed files
with
83 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json", | ||
"name": "pankybrowsertitle", | ||
"version": "1.0.0", | ||
"description": "Browser Tab Title Change plugin", | ||
"license": "GPL-3.0-or-later", | ||
"assets": [ | ||
{ | ||
"name": "pankybrowsertitle", | ||
"description": "Browser title change JavaScript", | ||
"type": "script", | ||
"uri": "plg_system_pankybrowsertitle/functions.js", | ||
"dependencies": [ | ||
"core" | ||
], | ||
"attributes": { | ||
"defer": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
window.onload = function() { | ||
|
||
var pageTitle = document.title; | ||
var attentionMessage = document.title; | ||
var meta = document.querySelector('meta[name="browserTabMsg"]'); | ||
|
||
if (meta) { | ||
var attentionMessage = meta.getAttribute('content'); | ||
} | ||
|
||
var blinkEvent = null; | ||
var currentDomain = window.location.hostname; | ||
|
||
document.addEventListener('visibilitychange', function(e) { | ||
var isPageActive = !document.hidden; | ||
|
||
if (!isPageActive) { | ||
blink(); | ||
} else { | ||
document.title = pageTitle; | ||
clearInterval(blinkEvent); | ||
} | ||
}); | ||
|
||
function blink() { | ||
blinkEvent = setInterval(function() { | ||
if (document.title === attentionMessage) { | ||
document.title = pageTitle; | ||
} else { | ||
document.title = attentionMessage; | ||
} | ||
}, 100); | ||
} | ||
|
||
window.addEventListener('blur', function() { | ||
// Save the current domain name when the user switches to a new tab | ||
currentDomain = window.location.hostname; | ||
}); | ||
|
||
window.addEventListener('focus', function() { | ||
// Check if the user switched to a new site when the tab regained focus | ||
if (window.location.hostname !== currentDomain) { | ||
document.title = attentionMessage; | ||
blink(); | ||
} else { | ||
document.title = pageTitle; | ||
clearInterval(blinkEvent); | ||
} | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters