add toastr for notifications

This commit is contained in:
hitman 2017-03-06 22:04:09 +05:30
parent b46a721a7d
commit 5e3e482311
6 changed files with 44 additions and 7 deletions

View file

@ -46,13 +46,32 @@
//= require unobtrusive_flash
//= require unobtrusive_flash_bootstrap
//= require countable
//= require toastr
$(document).ready(function() {
$('a[disabled=disabled]').click(function(event){
return false;
});
$('a[disabled=disabled]').click(function(event){
return false;
});
$('body').smoothScroll({
delegateSelector: 'a.smoothscroll'
});
$('body').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"
}
});

View file

@ -15,4 +15,5 @@
*= require leaflet
*= require bootstrap3-switch
*= require osem-payments
*= require toastr
*/

View file

@ -148,6 +148,17 @@ module ApplicationHelper
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)
result = ''
case event_state

View file

@ -22,6 +22,7 @@
= yield(:head)
%body
= render 'layouts/navigation'
= toast_bootstrap_flash
-# Admin area
- if controller.class.name.split("::").first=="Admin"
= render 'layouts/admin'