diff --git a/Gemfile b/Gemfile index 167d4335..f6c7d5f4 100644 --- a/Gemfile +++ b/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' diff --git a/Gemfile.lock b/Gemfile.lock index 56eb17ad..5237c61b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/assets/javascripts/application.js.erb.coffee b/app/assets/javascripts/application.js.erb.coffee index 9eb2c973..84a3a63a 100644 --- a/app/assets/javascripts/application.js.erb.coffee +++ b/app/assets/javascripts/application.js.erb.coffee @@ -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" diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 6deacc67..5e59ab76 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -1,5 +1,6 @@ /* *= require rails_bootstrap_forms + *= require growl *= require_self */