Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created August 15, 2011 00:04
Show Gist options
  • Save mahemoff/1145482 to your computer and use it in GitHub Desktop.
Save mahemoff/1145482 to your computer and use it in GitHub Desktop.
Simple growl-style notifier (jQuery)
// include the following
.notifier
img.progressor(src='/progressor.gif')
span.message loading fonts and stuff ...
notify = (message, isError) -> {
clearTimeout(timer);
if (!arguments.length) $(".notifier").fadeOut()
$(".notifier").toggleClass("error", isError===true).show().find(".message").html(message)
if (isError) timer = setTimeout(-> { $(".notifier").fadeOut() }, 3000)
}
lightgray = #ecf1f2
.notifier
// visibility hidden ---- I leave this commented out as I want to show "app loading" message
position fixed
top 0
right 0
background lightgray
border-color lightgray * 0.9
border-width 1px
border-style solid
color black
padding 0.5em
&.error
color red
.progressor
display none
.progressor
width 1em
height 1em
position relative
top 0.2em
margin-right 0.3em
This is a simple notifier geared around progress indication and loading stuff. I found the main libs don't seem to support this use case too well, ie this lib includes progress indicator by default and the notion of being able to close the notifier. (Most libs seem to close notifier on a timeout or by user intervention, whereas I want my app to close it when an async message comes in.)
Requirements:
jQuery + Kaffeine + Stylus + Jade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment