add toastr cdn and modified toast function

This commit is contained in:
hitman 2017-03-07 02:45:29 +05:30
parent 5e3e482311
commit 40b99cc2d6
6 changed files with 22 additions and 27 deletions

View file

@ -20,8 +20,6 @@ gem 'responders', '~> 2.0'
# as the database for Active Record
gem 'mysql2'
# for toastr notifications
gem 'toastr-rails'
# for observing records
gem 'rails-observers'

View file

@ -497,8 +497,6 @@ GEM
timecop (0.7.1)
timers (1.1.0)
tins (1.6.0)
toastr-rails (1.0.3)
railties (>= 3.1.0)
transitions (0.1.12)
ttfunk (1.1.1)
turbolinks (2.5.3)
@ -630,7 +628,6 @@ DEPENDENCIES
stripe
stripe-ruby-mock
timecop
toastr-rails
transitions
turbolinks
uglifier (>= 1.3.0)

View file

@ -46,7 +46,6 @@
//= require unobtrusive_flash
//= require unobtrusive_flash_bootstrap
//= require countable
//= require toastr
$(document).ready(function() {
$('a[disabled=disabled]').click(function(event){
@ -56,22 +55,4 @@ $(document).ready(function() {
$('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,5 +15,4 @@
*= require leaflet
*= require bootstrap3-switch
*= require osem-payments
*= require toastr
*/

View file

@ -153,7 +153,26 @@ module ApplicationHelper
flash.each do |type, message|
type = 'success' if type == 'notice'
type = 'error' if type == 'alert'
text = "<script>toastr.#{type}('#{message}');</script>"
text = "<script>
toastr.options = {
'closeButton': false,
'debug': false,
'newestOnTop': false,
'progressBar': true,
'positionClass': 'toast-bottom-center',
'preventDuplicates': true,
'onclick': null,
'showDuration': '300',
'hideDuration': '100',
'timeOut': '5000',
'extendedTimeOut': '1000',
'showEasing': 'swing',
'hideEasing': 'linear',
'showMethod': 'fadeIn',
'hideMethod': 'fadeOut'
};
toastr.#{type}('#{message}');
</script>"
flash_messages << text.html_safe if message
end
flash_messages.join("\n").html_safe

View file

@ -6,6 +6,7 @@
%meta{:content => "", :name => "description"}
%meta{:content => "", :name => "author"}
= stylesheet_link_tag "application", :media => "all"
= stylesheet_link_tag "https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css"
= javascript_include_tag "application"
= csrf_meta_tags
@ -18,7 +19,7 @@
};
= content_for(:script_head)
= javascript_include_tag "//cdn.transifex.com/live.js"
= javascript_include_tag "https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"
= yield(:head)
%body
= render 'layouts/navigation'