mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-12-09 05:37:36 +08:00
fixes flash message [fixes SCI-2142]
This commit is contained in:
parent
1e4a975304
commit
c026044322
4 changed files with 41 additions and 33 deletions
|
|
@ -204,6 +204,12 @@ var HelperModule = (function(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helpers.dismissAlert = function() {
|
||||||
|
$('#alert-flash').on('click', function() {
|
||||||
|
$('#alert-flash').alert('close');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
helpers.flashAlertMsg = function(message, type) {
|
helpers.flashAlertMsg = function(message, type) {
|
||||||
var alertType;
|
var alertType;
|
||||||
var glyphSign;
|
var glyphSign;
|
||||||
|
|
@ -221,23 +227,22 @@ var HelperModule = (function(){
|
||||||
alertType = ' alert-warning ';
|
alertType = ' alert-warning ';
|
||||||
glyphSign = ' glyphicon-exclamation-sign ';
|
glyphSign = ' glyphicon-exclamation-sign ';
|
||||||
}
|
}
|
||||||
var htmlSnippet = '<div class="alert alert' + alertType +
|
var htmlSnippet = '<div id="alert-flash" class="alert alert' + alertType +
|
||||||
'alert-dismissable alert-floating">' +
|
'alert-dismissable alert-floating">' +
|
||||||
'<div class="container">' +
|
'<div class="container">' +
|
||||||
'<button type="button" class="close" ' +
|
|
||||||
'data-dismiss="alert" aria-label="Close">' +
|
|
||||||
'<span aria-hidden="true">×</span></button>' +
|
|
||||||
'<span class="glyphicon' + glyphSign + '"></span> ' +
|
'<span class="glyphicon' + glyphSign + '"></span> ' +
|
||||||
'<span>' + message + '</span>' +
|
'<span>' + message + '</span>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
$('#notifications').html(htmlSnippet);
|
$('#notifications').html(htmlSnippet);
|
||||||
helpers.hideFlashMsg();
|
helpers.hideFlashMsg();
|
||||||
|
helpers.dismissAlert();
|
||||||
}
|
}
|
||||||
|
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
helpers.treeLinkTruncation();
|
helpers.treeLinkTruncation();
|
||||||
helpers.hideFlashMsg();
|
helpers.hideFlashMsg();
|
||||||
|
helpers.dismissAlert();
|
||||||
});
|
});
|
||||||
|
|
||||||
return helpers;
|
return helpers;
|
||||||
|
|
|
||||||
|
|
@ -36,35 +36,10 @@
|
||||||
<%= render "shared/file_preview_modal.html.erb" %>
|
<%= render "shared/file_preview_modal.html.erb" %>
|
||||||
<%= render "shared/navigation" %>
|
<%= render "shared/navigation" %>
|
||||||
|
|
||||||
<div id="notifications">
|
<% unless user_signed_in? %>
|
||||||
<% if flash[:success] %>
|
<%= render partial: 'shared/flash_alerts',
|
||||||
<div id="alert-flash" class="alert alert-success alert-dismissable alert-floating">
|
locals: { flash: flash, notice: notice, alert: alert } %>
|
||||||
<div class="container">
|
<% end %>
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
|
||||||
<span class="glyphicon glyphicon-ok-sign"></span>
|
|
||||||
<span><%= sanitize_input(flash[:success]) %></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% if notice %>
|
|
||||||
<div id="alert-flash" class="alert alert-info alert-dismissable alert-floating">
|
|
||||||
<div class="container">
|
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
|
||||||
<span class="glyphicon glyphicon-info-sign"></span>
|
|
||||||
<span><%= notice %></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% if alert and !alert.empty? or flash[:error]%>
|
|
||||||
<div id="alert-flash" class="alert alert-danger alert-dismissable alert-floating">
|
|
||||||
<div class="container">
|
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
|
||||||
<span class="glyphicon glyphicon-exclamation-sign"></span>
|
|
||||||
<span><%= alert || sanitize_input(flash[:error]) %></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= render "shared/left_menu_bar" if user_signed_in? %>
|
<%= render "shared/left_menu_bar" if user_signed_in? %>
|
||||||
<div id="content-wrapper">
|
<div id="content-wrapper">
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<% content_for :content do %>
|
<% content_for :content do %>
|
||||||
<div class="container-fluid" id="wrapper">
|
<div class="container-fluid" id="wrapper">
|
||||||
|
<%= render partial: 'shared/flash_alerts',
|
||||||
|
locals: { flash: flash, notice: notice, alert: alert } %>
|
||||||
<div id="sidebar-wrapper" class="<%= yield :sidebar_wrapper_class %>">
|
<div id="sidebar-wrapper" class="<%= yield :sidebar_wrapper_class %>">
|
||||||
<%= yield :sidebar %>
|
<%= yield :sidebar %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
26
app/views/shared/_flash_alerts.html.erb
Normal file
26
app/views/shared/_flash_alerts.html.erb
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
<div id="notifications">
|
||||||
|
<% if flash[:success] %>
|
||||||
|
<div id="alert-flash" class="alert alert-success alert-dismissable alert-floating">
|
||||||
|
<div class="container">
|
||||||
|
<span class="glyphicon glyphicon-ok-sign"></span>
|
||||||
|
<span><%= sanitize_input(flash[:success]) %></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if notice %>
|
||||||
|
<div id="alert-flash" class="alert alert-info alert-dismissable alert-floating">
|
||||||
|
<div class="container">
|
||||||
|
<span class="glyphicon glyphicon-info-sign"></span>
|
||||||
|
<span><%= notice %></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if alert and !alert.empty? or flash[:error]%>
|
||||||
|
<div id="alert-flash" class="alert alert-danger alert-dismissable alert-floating">
|
||||||
|
<div class="container">
|
||||||
|
<span class="glyphicon glyphicon-exclamation-sign"></span>
|
||||||
|
<span><%= alert || sanitize_input(flash[:error]) %></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
Loading…
Add table
Reference in a new issue