I agree this does look sweet, however this is not a replacement for alert. window.alert() is a blocking function, it prevents further code to be interpreted while the alert or prompt is open.
I met the most interesting guy once. He was a professor at Columbia and a consultant for Wall Street, helping design UIs for traders.<p>He explained how we process and prioritize visual cues -- how, if an element expands equally to the left AND right of our field of vision, it gets highest priority because it resembles an object heading toward our face.<p>For that reason, he avoided this design for everything except the highest-priority events.<p>Not crapping on your library -- it looks really nice :) But in general, I think it's worth considering if it's necessary to demand users' attention all over the place. I think information overload isn't solely in the content we consume but how it's presented.
I've been seeing a few of these libs pop up on HN lately. Apparently there's some sort of need here that people are trying to fill, it's just not clear to me what it is.<p>There are legitamite suggestions that blocking UI paradigms are bad, but they're very useful at times. I'm not arguing either, as I think each has their place (although I tend to avoid blocking personally if I can)<p>My real question is why now?
It would be nice if it was possible to select / copy the message in the box. Sometimes you get a message that you want to copy / paste to someone (email, chat, etc) and it's annoying to have to type it out again.
Nice style, and I appreciate that I can hit Esc to dismiss most of the dialogs, though unfortunately not all of them.<p>As another commenter said, I do wish that clicking outside of it had the same effect, but that may have more to do with what sites typically abuse these kinds of boxes for ("Alert! Sign up to our..." (no go away)).<p>One issue I noticed: there's a race condition in the second-to-last example ('...and by passing a parameter, you can execute something else for "Cancel".'), where if you hit escape quickly enough as the box gets launched, the cancellation handler does not run.
This really needs to be added to <a href="http://jsdelivr.com" rel="nofollow">http://jsdelivr.com</a> so we can package it in with existing CDN calls.<p>There seem to be very sparse examples of how to deploy the library properly, only to implement it.<p>Visually great. Cool how there's the ability to catch responses and work in the same modal further.
swal("Here's a message!") !== alert("Here's a message!")<p>Am i wrong or is a replacement not something which replace the original function? (beside the blocking aspect of an alert). Looks beautiful anyway :)
Looks cool. I'd like to see [esc] to close dialog. And is it a safe default to have [enter] perform the action especially on warning and danger? (just a thought)
This is an eerily similar project to something posted a few weeks ago here. Most notably, the exact same "success" animation.<p><a href="https://news.ycombinator.com/item?id=8420902" rel="nofollow">https://news.ycombinator.com/item?id=8420902</a><p><a href="https://github.com/t4t5/sweetalert" rel="nofollow">https://github.com/t4t5/sweetalert</a>