Comparing version 1.0.4 to 1.0.5
@@ -90,22 +90,21 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var setHidden = function setHidden() { | ||
document.title = opts.title; | ||
if (opts.faviconSrc.length) { | ||
favicon.setAttribute('href', opts.faviconSrc); | ||
} | ||
}; | ||
document.addEventListener("visibilitychange", function () { | ||
// Make sure we ignore timeout when coming back | ||
if (document.visibilityState == 'hidden') { | ||
if (opts.timeout > 0) { | ||
setTimeout(onChange, opts.timeout); | ||
setTimeout(setHidden, opts.timeout); | ||
} else { | ||
onChange(); | ||
setHidden(); | ||
} | ||
} else { | ||
document.title = originalTitle; | ||
favicon.setAttribute('href', originalFavicon); | ||
} | ||
}); | ||
var onChange = function onChange() { | ||
// Change the title | ||
document.title = document.hidden ? opts.title : originalTitle; | ||
// Change favicon if enabled | ||
if (opts.faviconSrc.length) { | ||
favicon.setAttribute('href', document.hidden ? opts.faviconSrc : originalFavicon); | ||
} | ||
}; | ||
} | ||
@@ -112,0 +111,0 @@ module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("dontGo",[],t):"object"==typeof exports?exports.dontGo=t():e.dontGo=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t){"use strict";function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={title:"Don't go!",faviconSrc:"",timeout:0},o=Object.assign(t,e),n=document.title,i=void 0,r=void 0,c=void 0;document.querySelectorAll('link[rel$="icon"]').length&&(i=document.querySelector('link[rel$="icon"]'),r=i.getAttribute("href")),o.faviconSrc.length&&(c=new Image,c.src=o.faviconSrc),document.addEventListener("visibilitychange",function(){"hidden"==document.visibilityState&&(o.timeout>0?setTimeout(d,o.timeout):d())});var d=function(){document.title=document.hidden?o.title:n,o.faviconSrc.length&&i.setAttribute("href",document.hidden?o.faviconSrc:r)}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o,e.exports=t["default"]}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("dontGo",[],e):"object"==typeof exports?exports.dontGo=e():t.dontGo=e()}(this,function(){return function(t){function e(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e){"use strict";function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={title:"Don't go!",faviconSrc:"",timeout:0},o=Object.assign(e,t),n=document.title,i=void 0,r=void 0,c=void 0;document.querySelectorAll('link[rel$="icon"]').length&&(i=document.querySelector('link[rel$="icon"]'),r=i.getAttribute("href")),o.faviconSrc.length&&(c=new Image,c.src=o.faviconSrc);var u=function(){document.title=o.title,o.faviconSrc.length&&i.setAttribute("href",o.faviconSrc)};document.addEventListener("visibilitychange",function(){"hidden"==document.visibilityState?o.timeout>0?setTimeout(u,o.timeout):u():(document.title=n,i.setAttribute("href",r))})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=o,t.exports=e["default"]}])}); | ||
//# sourceMappingURL=dont-go.min.js.map |
{ | ||
"name": "dont-go", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Client-side library to change the title and/or favicon of the page when it is inactive", | ||
@@ -5,0 +5,0 @@ "author": "Tiaan <tiaanduplessis@hotmail.com>", |
@@ -34,2 +34,8 @@ <p align="center"> | ||
**Install with yarn** | ||
```sh | ||
$ yarn add dont-go | ||
``` | ||
## Usage | ||
@@ -52,2 +58,2 @@ To use, simply call the function with options. | ||
## License | ||
Created with ♥ by [Tiaan du Plessis](https://github.com/mightyCrow). Licensed under the MIT License. | ||
Created with ♥ by [Tiaan du Plessis](https://github.com/mightyCrow). Licensed under the [MIT License](https://tiaan.mit-license.org/). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
58
20613
6