Created
August 19, 2013 15:03
-
-
Save atomgiant/6270147 to your computer and use it in GitHub Desktop.
Notification box css for full width
This file contains 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
<style> | |
#notification-box { | |
position: absolute; | |
top: 25px; left: 0; | |
width: 100%; | |
padding: 0; margin: 0; | |
} | |
</style> | |
<div id="notification-box"> | |
<div class="alert alert-error"> | |
<a class="close" data-dismiss="alert">×</a> | |
<div id="flash_alert">There was a problem...</div> | |
</div> | |
</div> | |
</div> |
<%# This file is structured in such a way as to allow both Rails and JavaScript
# to use the same DOM for displaying flash messages.
# %>
<% parent_display = flash.present? ? 'block' : 'none' -%>
<div class="flash-alerts" style="display: <%= parent_display %>;">
<%
[ [ :error, 'alert-danger' ],
[ :warning, 'alert-warning' ],
[ :info, 'alert-info' ],
[ :message, 'alert-success' ] ].each do |key, class_str|
display = flash[key].present? ? 'block' : 'none'
-%>
<div class="alert <%= "#{class_str}" %>" style="display: <%= display %>;">
<a class="close" data-dismiss="alert">×</a>
<div class="flash-msg">
<% if flash[key] -%>
<%= flash[key] %>
<% end -%>
</div>
</div>
<% end -%>
</div>
<% if flash.present? -%>
<script>
$(".flash-alerts").delay(5000).fadeOut();
</script>
<% end -%>
var setAlert = function (msg) {
$('.flash-alerts .alert-danger .flash-msg').text(msg);
$(".flash-alerts").show();
$(".flash-alerts .alert-danger").show();
$(".flash-alerts").delay(5000).fadeOut();
};
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A helper option