add toastr for notifications
This commit is contained in:
parent
b46a721a7d
commit
5e3e482311
6 changed files with 44 additions and 7 deletions
2
Gemfile
2
Gemfile
|
|
@ -20,6 +20,8 @@ gem 'responders', '~> 2.0'
|
||||||
# as the database for Active Record
|
# as the database for Active Record
|
||||||
gem 'mysql2'
|
gem 'mysql2'
|
||||||
|
|
||||||
|
# for toastr notifications
|
||||||
|
gem 'toastr-rails'
|
||||||
# for observing records
|
# for observing records
|
||||||
gem 'rails-observers'
|
gem 'rails-observers'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -497,6 +497,8 @@ GEM
|
||||||
timecop (0.7.1)
|
timecop (0.7.1)
|
||||||
timers (1.1.0)
|
timers (1.1.0)
|
||||||
tins (1.6.0)
|
tins (1.6.0)
|
||||||
|
toastr-rails (1.0.3)
|
||||||
|
railties (>= 3.1.0)
|
||||||
transitions (0.1.12)
|
transitions (0.1.12)
|
||||||
ttfunk (1.1.1)
|
ttfunk (1.1.1)
|
||||||
turbolinks (2.5.3)
|
turbolinks (2.5.3)
|
||||||
|
|
@ -628,6 +630,7 @@ DEPENDENCIES
|
||||||
stripe
|
stripe
|
||||||
stripe-ruby-mock
|
stripe-ruby-mock
|
||||||
timecop
|
timecop
|
||||||
|
toastr-rails
|
||||||
transitions
|
transitions
|
||||||
turbolinks
|
turbolinks
|
||||||
uglifier (>= 1.3.0)
|
uglifier (>= 1.3.0)
|
||||||
|
|
@ -637,4 +640,4 @@ DEPENDENCIES
|
||||||
whenever
|
whenever
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.14.3
|
1.14.5
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,32 @@
|
||||||
//= require unobtrusive_flash
|
//= require unobtrusive_flash
|
||||||
//= require unobtrusive_flash_bootstrap
|
//= require unobtrusive_flash_bootstrap
|
||||||
//= require countable
|
//= require countable
|
||||||
|
//= require toastr
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('a[disabled=disabled]').click(function(event){
|
$('a[disabled=disabled]').click(function(event){
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').smoothScroll({
|
$('body').smoothScroll({
|
||||||
delegateSelector: 'a.smoothscroll'
|
delegateSelector: 'a.smoothscroll'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
toastr.options = {
|
||||||
|
"closeButton": false,
|
||||||
|
"debug": false,
|
||||||
|
"newestOnTop": false,
|
||||||
|
"progressBar": true,
|
||||||
|
"positionClass": "toast-top-right",
|
||||||
|
"preventDuplicates": false,
|
||||||
|
"onclick": null,
|
||||||
|
"showDuration": "300",
|
||||||
|
"hideDuration": "1000",
|
||||||
|
"timeOut": "5000",
|
||||||
|
"extendedTimeOut": "1000",
|
||||||
|
"showEasing": "swing",
|
||||||
|
"hideEasing": "linear",
|
||||||
|
"showMethod": "fadeIn",
|
||||||
|
"hideMethod": "fadeOut"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,5 @@
|
||||||
*= require leaflet
|
*= require leaflet
|
||||||
*= require bootstrap3-switch
|
*= require bootstrap3-switch
|
||||||
*= require osem-payments
|
*= require osem-payments
|
||||||
|
*= require toastr
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,17 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def toast_bootstrap_flash
|
||||||
|
flash_messages = []
|
||||||
|
flash.each do |type, message|
|
||||||
|
type = 'success' if type == 'notice'
|
||||||
|
type = 'error' if type == 'alert'
|
||||||
|
text = "<script>toastr.#{type}('#{message}');</script>"
|
||||||
|
flash_messages << text.html_safe if message
|
||||||
|
end
|
||||||
|
flash_messages.join("\n").html_safe
|
||||||
|
end
|
||||||
|
|
||||||
def label_for(event_state)
|
def label_for(event_state)
|
||||||
result = ''
|
result = ''
|
||||||
case event_state
|
case event_state
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
= yield(:head)
|
= yield(:head)
|
||||||
%body
|
%body
|
||||||
= render 'layouts/navigation'
|
= render 'layouts/navigation'
|
||||||
|
= toast_bootstrap_flash
|
||||||
-# Admin area
|
-# Admin area
|
||||||
- if controller.class.name.split("::").first=="Admin"
|
- if controller.class.name.split("::").first=="Admin"
|
||||||
= render 'layouts/admin'
|
= render 'layouts/admin'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue