News for hackers. Stuff that matters.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by padolsey on Sunday July 10, 2011 @11:27AM (#2747904)
I like its simplicity.

But, I thought this was dead:

  onClick="javascript:smoke.alert('this is a normal alert');"
... apparently, not.

The 'javascript:' (attempted psuedo protocol), is just acting as a pointless label here.

I also thought we said goodbye to obtrusive JS altogether.

Also, the API isn't great. There's no instance to work with... It doesn't work in IE7 (probably because it doesn't cater for non-W3C events APIs). The source is littered with getElementById calls, and non configurable HTML IDs and classes. And it uses the window's 'load' event to initiate itself, when there's absolutely no need to. There's also 'smoketimeout' polluting the global scope when it could just be a property of the 'smoke' object itself.

Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by JangoSteve on Sunday July 10, 2011 @11:37AM (#2747924)
Most of that is no doubt due to the fact that it's framework-agnostic, meaning it can't rely on all the things frameworks like jquery do to make it easy to create reliable, unobtrusive javascript.

I don't so much have a problem with the getElementById calls, as that really is the best and quickest way to do things. Even jQuery's $('#some-element') selector is simply calling getElementById('some-element') under the hood and then wrapping it in a jQuery object.

And technically the onClick stuff can still be unobtrusive, as long as the link still works as intended with javascript disabled (i.e. it's a normal link and doesn't have something like href="#".

But all technicalities aside, I totally agree with your sentiment. Almost every site I build now is using jQuery or some other framewor; I'd prefer not to use some library that has to re-implement all the bindings and selectors and browser-specific hacks and work-arounds that are already being included elsewhere in my framework.

Furthermore, if my site is so low-level or small that it can't easily include jQuery, I doubt I'll be worried about replacing or trying to spruce up the standard javascript confirm dialog.

Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by oinksoft on Sunday July 10, 2011 @11:54AM (#2747951)

  var listen = function(el, evt, cbk) {
      if (el.addEventListener) {
          el.addEventListener(evt, cbk, false);
      } else {
          el.attachEvent('on' + evt, cbk);
      }
  };
No jQuery or whatever necessary ... if all you're doing is basic event handling and you know how the DOM works for other things, it really isn't much trouble to include this and a couple other small functions in a one-off, and is far preferable to including a hefty all-purpose DOM abstraction library like jQuery or MooTools.

Their example including an ugly onclick attribute doesn't imply that that is the only way to do things, it merely demonstrates the absolute simplest way to use the library. Of course any fool can use a script that includes the function above and locates the element manually.

Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by tripzilch on Sunday July 10, 2011 @02:08PM (#2748223)
> if all you're doing is basic event handling and you know how the DOM works for other things, it really isn't much trouble to include this and a couple other small functions in a one-off, and is far preferable to including a hefty all-purpose DOM abstraction library like jQuery or MooTools.

Why is that far preferable?

So you can throw out all that extra code as soon as your events have to actually do something, and you decide you do need jQuery? :)

To be honest, I do the same thing. It starts off as a small project one-off, and I think nah I don't have to include jQuery for something small if I just code these tiny DOM helper functions.

And there hasn't been a single time, when after an hour or so of coding, I didn't wish I had started out using jQuery right away :)

But sometimes then it's already too far, easier to just kludge along and finish the task than include jQuery and rewrite all the code so far to use it.

So how's this preferable again?

Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by chopsueyar on Sunday July 10, 2011 @01:30PM (#2748129)
What do you mean by 'obtrusive'?
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by strickjb9 on Sunday July 10, 2011 @05:46PM (#2748700)
I believe he means writing scripts inside of HTML attributes.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by rgbrgb on Sunday July 10, 2011 @12:44PM (#2748038)
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by BillSaysThis on Sunday July 10, 2011 @06:31PM (#2748770)
+1 for Apprise
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by wulczer on Sunday July 10, 2011 @10:44AM (#2747841)
Looks useful, but why make smoke.confirm work differently from plain confirm? It uglifies the API for no gain, IMHO.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by georgefox on Sunday July 10, 2011 @10:50AM (#2747849)
How would you make it return true/false immediately when the user has to click OK or Cancel?
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by wulczer on Sunday July 10, 2011 @10:53AM (#2747856)
Oh, good point. I clearly need more caffeine in my system.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by libria on Sunday July 10, 2011 @10:48AM (#2747845)
I feel like the alert and confirm modals should not be allowed to be dismissed by clicking outside. Especially confirm: "Destroy all. Yes, No?" -> click outside...nothing.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by beaumartinez on Sunday July 10, 2011 @01:25PM (#2748113)
It's the "panic" action, akin to a "close dialog" button. Clicking outside (should) default to the "safe" choice, in this case, "no".
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by nitrogen on Sunday July 10, 2011 @09:20PM (#2749111)
I would disagree. If there is a choice to be made, and that choice truly matters, I believe there should be no way to accidentally make the choice.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by chris_engel on Sunday July 10, 2011 @04:29PM (#2748549)
I wouldn't use it, because it doesn't use the main hotkeys for user interaction on the alert box (enter, space) or the confirm box (enter, space, escape).

I also would have liked it better, if the default functions of alert and confirm would have been overwritten, instead of recreated into an object. Overwriting the existent functions would have been made it a snap to integrate smoke.js into existing projects.

Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by frankil on Sunday July 10, 2011 @06:05PM (#2748722)
To my knowledge, you can't overwrite the existent confirm function because you can't pause the running of JS like the standard function does.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by chime on Sunday July 10, 2011 @11:57PM (#2749428)
I wish it also did prompt(). That would save a lot of work when you just want to input one field or want to let users copy-paste a URL to the page.

Edit: rgbrgb posted http://news.ycombinator.com/item?id=2748038 about Apprise. It does what smoke.js does and then some. Thanks

Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by consultutah on Sunday July 10, 2011 @10:50AM (#2747848)
Doesn't work on ipad
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by workhorse on Monday July 11, 2011 @01:57AM (#2749639)
Doesn't work on the iPhone either.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by beaumartinez on Sunday July 10, 2011 @01:28PM (#2748124)
Fly.

On the usability tip, why don't you allow making the dialog appear near the user's mouse? Having to move it from the link (or wherever the user's mouse is at the time) to the action buttons is unnecessary.

Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by nitrogen on Sunday July 10, 2011 @09:19PM (#2749110)
A counterpoint: I don't like things that appear near my mouse. My mouse is rarely positioned where I'm looking, and anything that appears under my mouse when I'm about to click on something interferes with (and occasionally "steals") normal clicks. The worst is when a dialog pops up with important information, and the OK or Cancel button right under the mouse, just as I was halfway through clicking on something else.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by taitems on Sunday July 10, 2011 @08:38PM (#2749042)
Show stopper for me is that it breaks the convention of disabling clicking with alerts and confirms.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by feydr on Sunday July 10, 2011 @01:43PM (#2748160)
want to get the gold star? make it to where I can have a styled confirmation box when onbeforeunload gets fired and make it have cross-browser support
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by dav-id on Sunday July 10, 2011 @05:38PM (#2748682)
It seems to be broken on an iPad.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by chopsueyar on Sunday July 10, 2011 @01:32PM (#2748135)
I like the CSS stylings.
Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by jsavimbi on Sunday July 10, 2011 @11:46AM (#2747940)
Sorry, but this is the latest entry in obsolete and obtrusive functionality. It's useless for mobile (just tested iOS Safari and Opera), which is the platform you should start with, and it's been proven out to be an annoying hindrance to the user on the desktop.

Don't interrupt CRUD. If you can't trust the user to not perform an irreversible action, then you're doing it wrong.

Re:Smoke.js - A framework-agnostic styled alert/confirm syst... by baggachipz on Monday July 11, 2011 @07:49AM (#2750277)
Noticed that it didn't work on my iPad as well. May be an early release, but mobile compatibility is crucial.