vanillatoasts
Advanced tools
Comparing version 1.2.0 to 1.3.0
{ | ||
"name": "vanillatoasts", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Agnostic Javascript Library for Website Notifications", | ||
@@ -5,0 +5,0 @@ "main": "vanillatoasts.js", |
@@ -8,11 +8,5 @@ ![VanillaToasts](http://puu.sh/iwxpd/eeee838c88.png) | ||
##Installing | ||
# Installing | ||
Bower | ||
``` | ||
$ bower install vanillatoasts | ||
``` | ||
NPM | ||
``` | ||
$ npm install vanillatoasts | ||
@@ -25,10 +19,11 @@ | ||
``` | ||
<link rel="stylesheet" href="/bower_components/vanillatoasts/vanillatoasts.css"> | ||
<link rel="stylesheet" href="/path/to/vanillatoasts/vanillatoasts.css"> | ||
``` | ||
##Usage | ||
# Usage | ||
``` | ||
VanillaToasts.create({ | ||
// Create a toast | ||
let toast = VanillaToasts.create({ | ||
title: 'Welcome to my site', | ||
@@ -41,2 +36,9 @@ text: 'This toast will hide after 5000ms or when you click it', | ||
}); | ||
// Hides the toast instantly | ||
toast.hide() | ||
// Timeout a toast at a later time | ||
VanillaToasts.setTimeout(toast.id, 1000); | ||
``` |
@@ -30,3 +30,11 @@ (function(root, factory) { | ||
].join('\n')) | ||
} | ||
}, | ||
//function to manually set timeout after create | ||
setTimeout: function() { | ||
console.error([ | ||
'DOM has not finished loading.', | ||
'\tInvoke create method when DOM\s readyState is complete' | ||
].join('\n')) | ||
}, | ||
toasts: {} //store toasts to modify later | ||
}; | ||
@@ -99,7 +107,23 @@ var autoincrement = 0; | ||
document.getElementById('vanillatoasts-container').removeChild(toast); | ||
delete VanillaToasts.toasts[toast.id]; //remove toast from object | ||
} | ||
document.getElementById('vanillatoasts-container').appendChild(toast); | ||
//add toast to object so its easily gettable by its id | ||
VanillaToasts.toasts[toast.id] = toast; | ||
return toast; | ||
} | ||
/* | ||
custom function to manually initiate timeout of | ||
the toast. Useful if toast is created as persistant | ||
because we don't want it to start to timeout until | ||
we tell it to | ||
*/ | ||
VanillaToasts.setTimeout = function(toastid, val) { | ||
if(VanillaToasts.toasts[toastid]){ | ||
setTimeout(VanillaToasts.toasts[toastid].hide, val); | ||
} | ||
} | ||
@@ -106,0 +130,0 @@ } |
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
15428
227
42