Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Commit

Permalink
Add handler to close flash messages
Browse files Browse the repository at this point in the history
  • Loading branch information
frodenas committed Jan 17, 2012
1 parent 09499f0 commit ccafe50
Show file tree
Hide file tree
Showing 26 changed files with 106 additions and 77 deletions.
10 changes: 10 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
//= require users
//= require_self

// JQuery handler to close flash messages
$(function() {
$('body').on('click', '#flash .close', function(e) {
$(this).parent('#flash').fadeOut('slow');
e && e.preventDefault()
});
});

// Browser Update
var $buoop = {vs:{i:8,f:4,o:11,s:5,n:9}}
$buoop.ol = window.onload;
window.onload=function(){
Expand All @@ -32,6 +41,7 @@ window.onload=function(){
document.body.appendChild(e);
}

// Google Analytics
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview'],['_trackPageLoadTime']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
Expand Down
24 changes: 12 additions & 12 deletions app/assets/javascripts/apps.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ $(function() {
}
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand All @@ -85,8 +85,8 @@ $(function() {
$(this).find('img').attr({ src : '<%= asset_path('wait.gif') %>'}).removeClass('start');
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand All @@ -100,8 +100,8 @@ $(function() {
$(this).find('img').attr({ src : '<%= asset_path('wait.gif') %>'}).removeClass('stop');
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand All @@ -115,8 +115,8 @@ $(function() {
$(this).find('img').attr({ src : '<%= asset_path('wait.gif') %>'}).removeClass('restart');
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand All @@ -139,8 +139,8 @@ $(function() {
}
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand All @@ -154,8 +154,8 @@ $(function() {
$(this).find('img').attr({ src : '<%= asset_path('wait.gif') %>'}).removeClass('delete');
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand Down
42 changes: 21 additions & 21 deletions app/assets/javascripts/appsshow.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ $(function() {
row.fadeIn(1800, function() {
$(this).removeClass('highlight');
});
$('#flash').empty();
$('#flash-content').empty();
},
'submitdata' : function(value, settings) {
var value = rangeapi.getValue();
return {'instances': value};
},
'onerror' : function(settings, original, xhr) {
original.reset();
$('#flash').empty();
$('#flash').append('<div class="alert">Error ' + xhr.status + ': ' + xhr.responseText + '</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">Error ' + xhr.status + ': ' + xhr.responseText + '</div>');
$('#flash').fadeIn('slow');
}
});
Expand All @@ -101,12 +101,12 @@ $(function() {
row.fadeIn(1800, function() {
$(this).removeClass('highlight');
});
$('#flash').empty();
$('#flash-content').empty();
},
'onerror' : function(settings, original, xhr) {
original.reset();
$('#flash').empty();
$('#flash').append('<div class="alert">Error ' + xhr.status + ': ' + xhr.responseText + '</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">Error ' + xhr.status + ': ' + xhr.responseText + '</div>');
$('#flash').fadeIn('slow');
}
});
Expand Down Expand Up @@ -155,7 +155,7 @@ $(function() {
$(this).removeClass('highlight');
});
appEnvvarsTable.fnUpdate(value, aPos[0], aPos[1]);
$('#flash').empty();
$('#flash-content').empty();
},
'submitdata': function(value, settings) {
return {
Expand All @@ -166,8 +166,8 @@ $(function() {
},
'onerror' : function(settings, original, xhr) {
original.reset();
$('#flash').empty();
$('#flash').append('<div class="alert">Error ' + xhr.status + ': ' + xhr.responseText + '</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">Error ' + xhr.status + ': ' + xhr.responseText + '</div>');
$('#flash').fadeIn('slow');
}
});
Expand Down Expand Up @@ -232,8 +232,8 @@ $(function() {
})
.on('ajax:error', function(evt, xhr, status, error) {
request_processed = true;
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {;
Expand All @@ -247,8 +247,8 @@ $(function() {
$(this).find('img').attr({ src : '<%= asset_path('wait.gif') %>'}).removeClass('delete');
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand All @@ -270,8 +270,8 @@ $(function() {
})
.on('ajax:error', function(evt, xhr, status, error) {
request_processed = true;
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {;
Expand All @@ -285,8 +285,8 @@ $(function() {
$(this).find('img').attr({ src : '<%= asset_path('wait.gif') %>'}).removeClass('delete');
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand All @@ -308,8 +308,8 @@ $(function() {
})
.on('ajax:error', function(evt, xhr, status, error) {
request_processed = true;
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand All @@ -323,8 +323,8 @@ $(function() {
$(this).find('img').attr({ src : '<%= asset_path('wait.gif') %>'}).removeClass('delete');
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand Down
8 changes: 4 additions & 4 deletions app/assets/javascripts/services.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ $(function() {
})
.on('ajax:error', function(evt, xhr, status, error) {
request_processed = true;
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand All @@ -70,8 +70,8 @@ $(function() {
$(this).find('img').attr({ src : '<%= asset_path('wait.gif') %>'}).removeClass('delete');
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand Down
8 changes: 4 additions & 4 deletions app/assets/javascripts/users.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ $(function() {
})
.on('ajax:error', function(evt, xhr, status, error) {
request_processed = true;
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand All @@ -59,8 +59,8 @@ $(function() {
$(this).find('img').attr({ src : '<%= asset_path('wait.gif') %>'}).removeClass('delete');
})
.on('ajax:error', function(evt, xhr, status, error) {
$('#flash').empty();
$('#flash').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash-content').empty();
$('#flash-content').append('<div class="alert">An error occurred processing your request, please reload the page and try again.</div>');
$('#flash').fadeIn('slow');
})
.on('ajax:complete', function(evt, xhr, status) {
Expand Down
17 changes: 17 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@ header a:hover {
padding: 1em;
}

#main #flash .close {
color: #404040;
cursor: pointer;
float: right;
font-weight: bold;
opacity: 0.50;
padding: .5em;
}

#main #flash a.close, #main #flash a.close:active, #main #flash a.close:visited {
text-decoration: none;
}

#main #flash a.close:hover {
opacity: 0.75;
}

#main h1 {
font-size: 150%;
margin-bottom: 1em;
Expand Down
4 changes: 2 additions & 2 deletions app/views/apps/create.js.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$('#flash').empty();
$('#flash-content').empty();
$('.modalBox-flash').empty();
<%- if flash[:alert] %>
request_processed = false;
Expand All @@ -11,7 +11,7 @@ $('.modalBox-flash').empty();
appsTable.dataTable().fnDestroy();
appsTable.dataTable(appsTable_Settings);
<%- if flash[:notice] %>
$('#flash').append('<div class="notice"><%= escape_javascript(flash[:notice]) %></div>');
$('#flash-content').append('<div class="notice"><%= escape_javascript(flash[:notice]) %></div>');
$('#flash').fadeIn('slow');
<%- end %>
<%- end %>
4 changes: 2 additions & 2 deletions app/views/apps/delete.js.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$('#flash').empty();
$('#flash-content').empty();
<%- if flash[:alert] %>
$('#flash').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash-content').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash').fadeIn('slow');
<%- else %>
var row = $('tr.#app-<%= @name %>').html('<td colspan="9" class="tdcenter"><%= escape_javascript(flash[:notice]) %></td>').addClass('highlight');
Expand Down
2 changes: 1 addition & 1 deletion app/views/apps/envvars/set_var.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= escape_javascript @var_value %>
<%- end %>
<%- else %>
$('#flash').empty();
$('#flash-content').empty();
$('.modalBox-flash').empty();
<%- if flash[:alert] %>
request_processed = false;
Expand Down
4 changes: 2 additions & 2 deletions app/views/apps/envvars/unset_var.js.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$('#flash').empty();
$('#flash-content').empty();
<%- if flash[:alert] %>
$('#flash').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash-content').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash').fadeIn('slow');
<%- else %>
var row = $('tr.#app-<%= @name %>-envvar-<%= @var_name %>').html('<td colspan="3" class="tdcenter"><%= escape_javascript(flash[:notice]) %></td>').addClass('highlight');
Expand Down
4 changes: 2 additions & 2 deletions app/views/apps/files/app_view_file.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
- if flash[:alert]
:javascript
$(function() {
$('#flash').empty();
$('#flash-content').empty();
$('.modalLog-flash').empty();
$('.modalLog-flash').append('<div class="alert">#{escape_javascript(flash[:alert])}</div>');
$('.modalLog-flash').fadeIn('slow');
});
- else
:javascript
$(function() {
$('#flash').empty();
$('#flash-content').empty();
$('.modalLog-flash').empty();
appLogfileTable_Settings = {
'bAutoWidth': false,
Expand Down
4 changes: 2 additions & 2 deletions app/views/apps/files/files.js.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$('#flash').empty();
$('#flash-content').empty();
<%- if flash[:alert] %>
$('#flash').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash-content').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash').fadeIn('slow');
<%- else %>
$('#app-files').hide(150, function() {
Expand Down
4 changes: 2 additions & 2 deletions app/views/apps/files/view_file.js.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$('#flash').empty();
$('#flash-content').empty();
<%- if flash[:alert] %>
$('#flash').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash-content').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash').fadeIn('slow');
<%- else %>
$('#app-files').hide(150, function() {
Expand Down
4 changes: 2 additions & 2 deletions app/views/apps/restart.js.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$('#flash').empty();
$('#flash-content').empty();
<%- if flash[:alert] %>
request_processed = false;
$('#flash').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash-content').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash').fadeIn('slow');
<%- else %>
request_processed = true;
Expand Down
2 changes: 1 addition & 1 deletion app/views/apps/services/bind_service.js.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$('#flash').empty();
$('#flash-content').empty();
$('.modalBox-flash').empty();
<%- if flash[:alert] %>
request_processed = false;
Expand Down
4 changes: 2 additions & 2 deletions app/views/apps/services/unbind_service.js.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$('#flash').empty();
$('#flash-content').empty();
<%- if flash[:alert] %>
$('#flash').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash-content').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash').fadeIn('slow');
<%- else %>
var row = $('tr.#app-<%= @name %>-service-<%= @service %>').html('<td colspan="4" class="tdcenter"><%= escape_javascript(flash[:notice]) %></td>').addClass('highlight');
Expand Down
4 changes: 2 additions & 2 deletions app/views/apps/start.js.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$('#flash').empty();
$('#flash-content').empty();
<%- if flash[:alert] %>
request_processed = false;
$('#flash').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash-content').append('<div class="alert"><%= escape_javascript(flash[:alert]) %></div>');
$('#flash').fadeIn('slow');
<%- else %>
request_processed = true;
Expand Down
Loading

0 comments on commit ccafe50

Please sign in to comment.