added rails-assets-growl for notifications
This commit is contained in:
parent
6f03b75f00
commit
5b013314ed
2
Gemfile
2
Gemfile
|
@ -1,4 +1,5 @@
|
|||
source 'https://rubygems.org'
|
||||
source 'https://rails-assets.org'
|
||||
|
||||
gem 'rails', '4.1.7'
|
||||
|
||||
|
@ -26,6 +27,7 @@ gem 'bootstrap_form'
|
|||
gem 'font-kit-rails'
|
||||
gem 'nprogress-rails'
|
||||
gem 'font-awesome-rails', '~> 4.2.0.0'
|
||||
gem 'rails-assets-growl'
|
||||
|
||||
group :development do
|
||||
gem 'spring'
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
remote: https://rails-assets.org/
|
||||
specs:
|
||||
actionmailer (4.1.7)
|
||||
actionpack (= 4.1.7)
|
||||
|
@ -120,6 +121,9 @@ GEM
|
|||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.1.7)
|
||||
sprockets-rails (~> 2.0)
|
||||
rails-assets-growl (1.2.0)
|
||||
rails-assets-jquery
|
||||
rails-assets-jquery (2.1.1)
|
||||
railties (4.1.7)
|
||||
actionpack (= 4.1.7)
|
||||
activesupport (= 4.1.7)
|
||||
|
@ -222,6 +226,7 @@ DEPENDENCIES
|
|||
pg
|
||||
poltergeist
|
||||
rails (= 4.1.7)
|
||||
rails-assets-growl
|
||||
rspec-rails (~> 3.0.0)
|
||||
sass-rails (~> 4.0.3)
|
||||
sdoc (~> 0.4.1)
|
||||
|
|
|
@ -5,16 +5,20 @@
|
|||
#= require bootstrap
|
||||
#= require nprogress
|
||||
#= require nprogress-turbolinks
|
||||
#= require growl
|
||||
#= require_tree .
|
||||
|
||||
NProgress.configure
|
||||
showSpinner: false
|
||||
|
||||
showSnackbar = (text) ->
|
||||
$.snackbar # allahu snackbar
|
||||
content: text
|
||||
style: "snackbar"
|
||||
timeout: 5000
|
||||
showNotification = (text, success=true) ->
|
||||
args =
|
||||
title: if success then "Success!" else "Uh-oh..."
|
||||
message: text
|
||||
if success
|
||||
$.growl.notice args
|
||||
else
|
||||
$.growl.error args
|
||||
|
||||
$(document).on "click", "button[name=qb-ask]", ->
|
||||
btn = $(this)
|
||||
|
@ -38,13 +42,10 @@ $(document).on "click", "button[name=qb-ask]", ->
|
|||
if promote
|
||||
$("div#question-box").hide()
|
||||
$("div#question-box-promote").show()
|
||||
showSnackbar data.message
|
||||
else
|
||||
console.log data, status, jqxhr
|
||||
showSnackbar "An error occurred, a developer should check the console for details"
|
||||
showNotification data.message, data.success
|
||||
error: (jqxhr, status, error) ->
|
||||
console.log jqxhr, status, error
|
||||
showSnackbar "An error occurred, a developer should check the console for details"
|
||||
showNotification "An error occurred, a developer should check the console for details", false
|
||||
complete: (jqxhr, status) ->
|
||||
btn.button "reset"
|
||||
$("textarea[name=qb-question]").removeAttr "readonly"
|
||||
|
@ -63,13 +64,10 @@ $(document).on "click", "button[name=ib-answer]", ->
|
|||
success: (data, status, jqxhr) ->
|
||||
if data.success
|
||||
$("div.inbox-box[data-id=#{iid}]").slideUp()
|
||||
showSnackbar data.message
|
||||
else
|
||||
console.log data, status, jqxhr
|
||||
showSnackbar "An error occurred, a developer should check the console for details"
|
||||
showNotification data.message, data.success
|
||||
error: (jqxhr, status, error) ->
|
||||
console.log jqxhr, status, error
|
||||
showSnackbar "An error occurred, a developer should check the console for details"
|
||||
showNotification "An error occurred, a developer should check the console for details", false
|
||||
complete: (jqxhr, status) ->
|
||||
btn.button "reset"
|
||||
$("textarea[name=ib-answer][data-id=#{iid}]").removeAttr "readonly"
|
||||
|
@ -87,10 +85,10 @@ $(document).on "click", "button[name=ab-destroy]", ->
|
|||
success: (data, status, jqxhr) ->
|
||||
if data.success
|
||||
$("div.answer-box[data-id=#{aid}]").slideUp()
|
||||
showSnackbar data.message
|
||||
showNotification data.message, data.success
|
||||
error: (jqxhr, status, error) ->
|
||||
console.log jqxhr, status, error
|
||||
showSnackbar "An error occurred, a developer should check the console for details"
|
||||
showNotification "An error occurred, a developer should check the console for details", false
|
||||
complete: (jqxhr, status) ->
|
||||
btn.button "reset"
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
*= require rails_bootstrap_forms
|
||||
*= require growl
|
||||
*= require_self
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue