alerts0.1.3 • Public • Published
Simple and straigtforward notifications for the browser.
Alerts stack up. You dismiss them with a click (and also get them dismissed by themselves after some time by setting the
Source is only 2 KB. No dependencies.
Use with browserify, gluejs, etc.
npm install alerts
If used in good old
<script> tag, it attaches itself to the
window object as
Objectan Alert instance
NumberTime in miliseconds after which the alert is dismissed
StringCustom class name to be added to each alert element
FunctionTo be called when alert gets shown, with the alert element as context plus the options object as first argument, so anything you pass in is there
FunctionTo be called just before the alert gets dismissed, with the Alert instance (the element is about to be removed from the DOM) as context and options object as first argument
var alert = ;;
Passing in some options.
var alerted =;// The HTML element is available at alerted.el
This is the least CSS you need to get it working. (Set
z-index to something reasonable according to the rest of your stylesheet.)
And this is a copy/paste example more like in the screenshot above.
If you want to use CSS transitions to either fade alerts in and out or swap them from right to left and viceversa, you can. Just set the
alert.transitionTime property to the transition duration in miliseconds.
alerttransitionTime = 200;
And then get creative with your CSS.
You also have the
Alert constructor plus the
container element at your disposal.
// The constructorvar alerted = 'Foo';// The elementalertcontainerstylebackgroundColor = 'lime';
This code should work everywhere.
Copyright (c) 2013 Arturo Castillo Delgado firstname.lastname@example.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.