EDIT: Care to explain why I'm getting downvoted? Said nothing offensive, and I'm clearly on-topic.
EDIT: Care to explain why I'm getting downvoted? Said nothing offensive, and I'm clearly on-topic.
I used to work in applications that require you to do -as much as possible- to keep the window open. This isn't for spam reasons, it is because we did assessment and you really, really didn't want someone closing half-way through an assessment, especially one that is timed. You also don't want to freeze the timer because you might leave the user an opportunity to cheat (close window, research, relaunch assessment, repeat).
So this was real example of something that really should be single-execution. However, even with all the popups, checks, refresh-push-forward, launch-window-on-exit hacks we tried we STILL got users lost out of the system. Not only that but we wound up annoying/angering/confusing 1000 users for every 1 user it helped.
shrug
YMMV, but I believe 99.999% of all issues can be solved with user/session caches and clear wording over blocking the execution thread.
But I guess in some circumstances having a UI-updating callback called when a modal dialog is up might be a little confusing for the user. And setting (and checking!) a global everywhere is rather messy. So I see your pain.
Ha, one way I just thought of to get frozen behavior is to take a snapshot of the screen, then overlay a canvas element with that image. As an added bonus you can do some transform on the image to make the effect look more native. When the dialog box goes away, the canvas goes away, and your updated state is presented as if it just executed.
The last thing you want is a UI blocking popup like alert() that, at least in browsers like Firefox and IE, effectively lock the entire browser from doing anything, which is a terrible anti-pattern in multi-tabbed browsers. Chrome did it right, at least with the HTTP authentication prompt, to make the UI block on a per-tab basis and have the prompt window not be a top-level-window-manager-managed-block-the-entire-app modal dialog.
I think a case can be made to have functionality that shows a dialog that is modal within the context of the page it is on, not modal for the entire browser. The former would be useful for the cases you outline, the latter is the bane of users everywhere.
(forgive me if I'm misrepresenting the current state of browsers other than Chrome when it comes to modal dialogs like alert(), I don't use them much; I think everyone can get what I'm saying despite that)
confirm("Are you sure you want to leave?");I like the localStorage solution for drafts much better.
In fact, the HTML5 spec permits browsers to disregard the normal blocking behavior of alert()/confirm()/prompt() (making them no-ops) while this event is being handled: https://developer.mozilla.org/en-US/docs/DOM/window.onbefore... the dialog box is open
When they execute, they run a callback with the input provided. Inside that callback, do whatever you need to do that requires some input.
All I'm trying to say is that allowing custom defined objects to have the ability to block execution can be very handy in certain instances. I by no means was criticizing the alertify.js library
async.waterfall([ function getInput(){...}, function checkInput(){...}, function submitInput(){...}, ], function finally(){})
Each of the functions takes a callback, and returns err (if any) and output. If a callback returns err, it jumps to finally where you say what failed.
This is odd when you first get started with async, but it's really easy to visualize.
Think of a production line, with a number of different workers doing different stuff. If one of them gets a dud part, it throws it away.
https://developer.mozilla.org/en-US/docs/DOM/window.showModa...