toastify-js
Advanced tools
Comparing version 1.0.1 to 1.1.0
# Changelog | ||
All the changes made to toastify-js library. | ||
## [1.1.0] - 2018-02-18 | ||
- Browser support extended to IE10+ without any polyfills | ||
## [1.0.0] - 2018-02-17 | ||
@@ -5,0 +8,0 @@ - Support for modules |
@@ -7,2 +7,20 @@ var bgColors = [ | ||
Toastify({ | ||
text: "Hi", | ||
duration: 4500, | ||
destination: 'https://github.com/apvarun/toastify-js', | ||
newWindow: true, | ||
gravity: "top", | ||
positionLeft: true | ||
}).showToast(); | ||
setTimeout(function () { | ||
Toastify({ | ||
text: "Simple JavaScript Toasts", | ||
gravity: "top", | ||
positionLeft: true, | ||
backgroundColor: "#0f3443" | ||
}).showToast(); | ||
}, 1000); | ||
// Options for the toast | ||
@@ -13,3 +31,3 @@ var options = { | ||
callback: function () { | ||
this.remove(); | ||
console.log("Toast hidden"); | ||
Toastify.reposition(); | ||
@@ -27,3 +45,3 @@ }, | ||
myToast.showToast(); | ||
}, 3000); | ||
}, 4500); | ||
@@ -38,28 +56,13 @@ setTimeout(function () { | ||
}).showToast(); | ||
}, 2000); | ||
}, 3000); | ||
Toastify({ | ||
text: "Time to get started!", | ||
duration: 4500, | ||
destination: 'https://github.com/apvarun/toastify-js', | ||
newWindow: true, | ||
gravity: "top", | ||
positionLeft: true, | ||
}).showToast(); | ||
Toastify({ | ||
text: "Pure JavaScript Toasts", | ||
gravity: "bottom", | ||
positionLeft: false, | ||
backgroundColor: "#0f3443" | ||
}).showToast(); | ||
// Displaying toast on manual action `Try` | ||
document.getElementById('new-toast').addEventListener('click', function () { | ||
Toastify({ | ||
text: "This is a toast", | ||
text: "I am a toast", | ||
duration: 3000, | ||
backgroundColor: bgColors[i] | ||
close: i%3 ? true: false, | ||
backgroundColor: bgColors[i%2] | ||
}).showToast(); | ||
i = i ? 0 : 1; | ||
i++; | ||
}); |
{ | ||
"name": "toastify-js", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Toastify is a lightweight, vanilla JS toast notification library.", | ||
@@ -5,0 +5,0 @@ "main": "./src/toastify.js", |
@@ -6,3 +6,3 @@ # Toastify | ||
[![toastify-js](https://img.shields.io/badge/toastify--js-1.0.0-brightgreen.svg)](https://www.npmjs.com/package/toastify-js) | ||
[![toastify-js](https://img.shields.io/badge/toastify--js-1.1.0-brightgreen.svg)](https://www.npmjs.com/package/toastify-js) | ||
@@ -15,2 +15,16 @@ Toastify is a lightweight, vanilla JS toast notification library. | ||
## Features | ||
- Multiple stacked notifications | ||
- Customizable | ||
- No blocking of execution thread | ||
### Customization options | ||
- Notification Text | ||
- Duration | ||
- Toast background color | ||
- Close icon display | ||
- Display position | ||
## Installation | ||
@@ -20,2 +34,3 @@ | ||
- Run the below command to add toastify-js to your exisitng or new project. | ||
``` | ||
@@ -29,4 +44,9 @@ npm install --save toastify-js | ||
#### Using Toastify using the traditional method | ||
- Import toastify-js into your module to start using it. | ||
``` | ||
import Toastify from 'toastify-js' | ||
``` | ||
#### Adding ToastifyJs to HTML page using the traditional method | ||
To start using **Toastify**, add the following CSS on to your page. | ||
@@ -43,2 +63,3 @@ | ||
``` | ||
> Files are delivered via the CDN service provided by [jsdeliver](https://www.jsdelivr.com/) | ||
@@ -64,4 +85,10 @@ ## Documentation | ||
## Browsers support | ||
| [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/edge.png" alt="IE / Edge" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)<br />IE / Edge | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/firefox.png" alt="Firefox" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)<br />Firefox | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/chrome.png" alt="Chrome" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)<br />Chrome | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/safari.png" alt="Safari" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)<br />Safari | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/opera.png" alt="Opera" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)<br />Opera | | ||
| --------- | --------- | --------- | --------- | --------- | | ||
| IE10, IE11, Edge| last 10 versions| last 10 versions| last 10 versions| last 10 versions | ||
## License | ||
MIT © [Varun A P](https://github.com/apvarun) |
/*! | ||
* Toastify js 1.0.0 | ||
* Toastify js 1.1.0 | ||
* https://github.com/apvarun/toastify-js | ||
@@ -25,3 +25,3 @@ * @license MIT licensed | ||
// Library version | ||
version = "1.0.0"; | ||
version = "1.1.0"; | ||
@@ -104,3 +104,3 @@ // Defining the prototype of the object | ||
// Adding close icon on the right of content | ||
divElement.prepend(avatarElement); | ||
divElement.insertAdjacentElement('beforeend', avatarElement); | ||
@@ -123,2 +123,3 @@ } | ||
this.removeElement(event.target.parentElement); | ||
window.clearTimeout(event.target.parentElement.timeOutValue); | ||
@@ -135,3 +136,3 @@ }.bind(this)); | ||
// Adding close icon on the left of content | ||
divElement.prepend(closeElement); | ||
divElement.insertAdjacentElement('afterbegin', closeElement); | ||
@@ -212,3 +213,3 @@ } else { | ||
window.setTimeout(function () { | ||
toastElement.timeOutValue = window.setTimeout(function () { | ||
@@ -229,3 +230,4 @@ // Remove the toast from DOM | ||
// Hiding the element | ||
toastElement.classList.remove("on"); | ||
// toastElement.classList.remove("on"); | ||
toastElement.className = toastElement.className.replace(" on",""); | ||
@@ -236,3 +238,3 @@ // Removing the element from DOM after transition end | ||
// Remove the elemenf from the DOM | ||
toastElement.remove(); | ||
toastElement.parentNode.removeChild(toastElement); | ||
@@ -277,3 +279,3 @@ // Calling the callback function | ||
// Getting the applied gravity | ||
if (allToasts[i].classList.contains('top') === true) { | ||
if (containsClass(allToasts[i], 'top') === true) { | ||
classUsed = "top"; | ||
@@ -301,3 +303,3 @@ } else { | ||
if (allToasts[i].classList.contains('left') === true) { | ||
if (containsClass(allToasts[i], 'left') === true) { | ||
@@ -325,2 +327,12 @@ // Setting the position | ||
function containsClass(elem, yourClass) { | ||
if(!elem || typeof yourClass !== 'string') { | ||
return false; | ||
} else if(elem.className && elem.className.trim().split(/\s+/gi).indexOf(yourClass) > -1) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
// Setting up the prototype for the init object | ||
@@ -327,0 +339,0 @@ Toastify.lib.init.prototype = Toastify.lib; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46566
11
439
89