Skip to content

Instantly share code, notes, and snippets.

@shuhaowu
Last active December 10, 2015 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuhaowu/4430444 to your computer and use it in GitHub Desktop.
Save shuhaowu/4430444 to your computer and use it in GitHub Desktop.
Status message like the gmail sending messages. An updated version of http://code.google.com/p/humanmsg/, perhaps you can see from some functions This has been DEPRECATED. Use https://github.com/shuhaowu/awesome-statusmsg instead
# This has been deprecated. Use https://github.com/shuhaowu/awesome-statusmsg instead
window["statusmsg"] = statusmsg = {}
# statusmsg = namespace "statusmsg"
# I use my own namespace function from coffeecrispt so not sure how well that first line works.
# To use, do statusmsg.setup() at document load
# Then you can do statusmsg.display("Your text") and close via statusmsg.close()
set_human_msg_css = (msgbox) ->
msgbox.css("position", "fixed").css("left", ($(window).width() - $(msgbox).outerWidth()) / 2)
statusmsg["setup"] = (appendTo="body", msgOpacity=0.8, msgID="statusmsg") ->
statusmsg.msgID = msgID
statusmsg.msgOpacity = msgOpacity
statusmsg.msgbox = $('<div id="' + statusmsg.msgID + '" class="statusmsg"></div>')
$(appendTo).append(statusmsg.msgbox)
$(window).resize(() ->
set_human_msg_css(statusmsg.msgbox)
)
$(window).resize()
statusmsg["display"] = (msg) ->
statusmsg.msgbox.html(msg)
set_human_msg_css(statusmsg.msgbox)
statusmsg.msgbox.fadeIn()
statusmsg["close"] = () ->
statusmsg.msgbox.fadeOut()
.statusmsg { position: fixed; top: 2em; color: #000; border-radius: 5px; background-color: #D4FFA8; text-align: center; display: none; z-index: 1000; padding: 0.5em 0.8em; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment