Comparing version 1.0.0 to 1.0.1
@@ -1,1 +0,105 @@ | ||
!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:""},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.querySelectorAll('link[rel$="icon"]')[0],r=i.getAttribute("href")),o.faviconSrc.length&&(c=new Image,c.src=o.faviconSrc),document.addEventListener("visibilitychange",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 webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define("dontGo", [], factory); | ||
else if(typeof exports === 'object') | ||
exports["dontGo"] = factory(); | ||
else | ||
root["dontGo"] = factory(); | ||
})(this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = dontGo; | ||
function dontGo() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var defaults = { | ||
title: 'Don\'t go!', | ||
faviconSrc: '' | ||
}; | ||
var opts = Object.assign(defaults, options); | ||
var originalTitle = document.title; | ||
var favicon = void 0; | ||
var originalFavicon = void 0; | ||
var img = void 0; | ||
// Store the original favicon if it exists | ||
if (document.querySelectorAll('link[rel$="icon"]').length) { | ||
favicon = document.querySelectorAll('link[rel$="icon"]')[0]; | ||
originalFavicon = favicon.getAttribute('href'); | ||
} | ||
// Preload the alternative favicon | ||
if (opts.faviconSrc.length) { | ||
img = new Image(); | ||
img.src = opts.faviconSrc; | ||
} | ||
document.addEventListener("visibilitychange", function () { | ||
// 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); | ||
} | ||
}); | ||
} | ||
module.exports = exports['default']; | ||
/***/ } | ||
/******/ ]) | ||
}); | ||
; | ||
//# sourceMappingURL=dont-go.min.js.map |
{ | ||
"name": "dont-go", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Client-side library to change the title and/or favicon of the page when it is inactive", | ||
"author": "Tiaan <tiaanduplessis@hotmail.com>", | ||
"license": "MIT", | ||
"main": "lib/dont-go.min.js", | ||
"main": "lib/dont-go.js", | ||
"keywords": [ | ||
@@ -20,3 +20,3 @@ "library", | ||
"start": "npm run dev", | ||
"build": "NODE_ENV=production webpack --progress", | ||
"build": "NODE_ENV=development webpack --progress && NODE_ENV=production webpack --progress", | ||
"dev": "NODE_ENV=development webpack --progress --watch", | ||
@@ -46,3 +46,2 @@ "lint": "eslint .", | ||
"babel-preset-stage-0": "^6.3.13", | ||
"clean-webpack-plugin": "^0.1.7", | ||
"eslint": "^1.10.3", | ||
@@ -49,0 +48,0 @@ "eslint-loader": "^1.2.1", |
@@ -6,8 +6,10 @@ <p align="center"> | ||
# dont-go :sob: | ||
[![GitHub version](https://badge.fury.io/gh/mightyCrow%2Fdont-go.svg)](https://badge.fury.io/gh/mightyCrow%2Fdont-go) | ||
[![npm version](https://badge.fury.io/js/dont-go.svg)](https://badge.fury.io/js/dont-go) | ||
[![Bower version](https://badge.fury.io/bo/dont-go.svg)](https://badge.fury.io/bo/dont-go) | ||
[![Build Status](https://travis-ci.org/mightyCrow/dont-go.svg?branch=master)](https://travis-ci.org/mightyCrow/dont-go) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
A small client-side library with zero dependencies to change the title and/or favicon of the page when it is inactive. Minified version weighs in at a [whopping](http://www.dictionary.com/browse/whopping) **1.08 kB**. Note that **You must include a default favicon in your webpage**. | ||
<p align="center"> | ||
<a href=""><img width="100%" src="media/example.png" alt="example"></a> | ||
<a href=""><img width="80%" src="media/example.png" alt="example"></a> | ||
</p> | ||
@@ -41,3 +43,7 @@ | ||
``` | ||
The faviconSrc property is optional and will keep the same icon if not set. | ||
## TODO :memo: | ||
- Add ability to set timeout before title & favicon change. | ||
## Contributing | ||
@@ -44,0 +50,0 @@ All Contributions are welcome! Please open up an issue if you would like to help out. :smile: |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
19316
9
10
217
52
1