Created
July 3, 2011 02:59
-
-
Save brentertz/1061916 to your computer and use it in GitHub Desktop.
Flash messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Flashes | |
-------------------------------------------------------------- */ | |
.js #flash { | |
display: none; | |
} | |
#flash { | |
position: absolute; | |
width: 100%; | |
z-index: 10000; | |
p { | |
margin: 1em 0; | |
} | |
.error, | |
.alert, | |
.notice, | |
.success, | |
.info, | |
.flash { padding: 0.8em; border: 2px solid #ddd; } | |
.error { background: #fbe3e4; color: #8a1f11; border-color: #fbc2c4; } | |
.alert, | |
.notice { background: #fff6bf; color: #514721; border-color: #ffd324; } | |
.success { background: #e6efc2; color: #264409; border-color: #c6d880; } | |
.info, | |
.flash { background: #d5edf8; color: #205791; border-color: #92cae4; } | |
.error a { color: #8a1f11; } | |
.alert a, | |
.notice a { color: #514721; } | |
.success a { color: #264409; } | |
.info a, | |
.flash a { color: #205791; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#flash | |
- flash.each do |key, value| | |
%div{ :title => key.to_s.humanize, :class => key } | |
%p= value | |
.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
common = | |
# Default settings | |
# eg) Override defaults | |
# common.defaults.message = 'Hello' | |
# common.init({'message': 'Hello'}) | |
defaults: {} | |
# Primary initialization function | |
init: (options) -> | |
@settings = $.extend(true, {}, @defaults, options); | |
# Save DOM references | |
@$flash = $("#flash") | |
@flash() | |
# Show flash notifications | |
flash: -> | |
if (@$flash.html().length > 0) | |
slideup = -> $('#flash').slideUp(-> $(@).empty()) | |
@$flash.click(slideup).slideDown() | |
setTimeout(slideup, 10000) | |
window.common = common | |
$ -> | |
common.init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment