From 9d3b8cced414091ce0b153de4171d443c8a5c916 Mon Sep 17 00:00:00 2001 From: Andreas N Date: Sat, 3 Jan 2015 17:36:55 +0100 Subject: [PATCH] replaced alerts with sweetAlert --- Gemfile.lock | 3 +++ .../answerbox/comment/destroy.coffee | 9 +++++++++ .../answerbox/comment/report.coffee | 10 +++++++++- .../javascripts/answerbox/destroy.coffee | 10 +++++++++- .../javascripts/answerbox/report.coffee | 10 +++++++++- app/assets/javascripts/inbox.coffee | 20 +++++++++++++++++-- .../javascripts/moderation/comment.coffee | 10 +++++++++- .../javascripts/moderation/destroy.coffee | 10 +++++++++- 8 files changed, 75 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 165fe918..9e09452c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -298,6 +298,8 @@ GEM colorize (>= 0.7.0) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) + sweetalert-rails (0.3.3) + railties (>= 3.1.0) thin (1.6.3) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0) @@ -387,6 +389,7 @@ DEPENDENCIES simplecov sinatra spring + sweetalert-rails thin turbolinks twitter diff --git a/app/assets/javascripts/answerbox/comment/destroy.coffee b/app/assets/javascripts/answerbox/comment/destroy.coffee index 19de53e5..ac89bef3 100644 --- a/app/assets/javascripts/answerbox/comment/destroy.coffee +++ b/app/assets/javascripts/answerbox/comment/destroy.coffee @@ -1,5 +1,14 @@ $(document).on "click", "a[data-action=ab-comment-destroy]", (ev) -> ev.preventDefault() + swal + title: "Are you sure?" + text: "You will not be able to recover this!" + type: "warning" + showCancelButton: true + confirmButtonColor: "#DD6B55" + confirmButtonText: "Yes, delete it!" + closeOnConfirm: false + , -> if confirm 'Are you sure?' btn = $(this) cid = btn[0].dataset.cId diff --git a/app/assets/javascripts/answerbox/comment/report.coffee b/app/assets/javascripts/answerbox/comment/report.coffee index 3f407a69..e21e7071 100644 --- a/app/assets/javascripts/answerbox/comment/report.coffee +++ b/app/assets/javascripts/answerbox/comment/report.coffee @@ -1,6 +1,14 @@ $(document).on "click", "a[data-action=ab-comment-report]", (ev) -> ev.preventDefault() - if confirm 'Are you sure you want to report this comment?' + swal + title: "Report?" + text: "A moderator will check this and decide what happens!" + type: "warning" + showCancelButton: true + confirmButtonColor: "#DD6B55" + confirmButtonText: "Report!" + closeOnConfirm: false + , -> btn = $(this) cid = btn[0].dataset.cId $.ajax diff --git a/app/assets/javascripts/answerbox/destroy.coffee b/app/assets/javascripts/answerbox/destroy.coffee index a26214a1..4ec5e38e 100644 --- a/app/assets/javascripts/answerbox/destroy.coffee +++ b/app/assets/javascripts/answerbox/destroy.coffee @@ -1,6 +1,14 @@ $(document).on "click", "a[data-action=ab-destroy]", (ev) -> ev.preventDefault() - if confirm 'Are you sure?' + swal + title: "Are you sure?" + text: "You will not be able to recover this!" + type: "warning" + showCancelButton: true + confirmButtonColor: "#DD6B55" + confirmButtonText: "Yes, delete it!" + closeOnConfirm: false + , -> btn = $(this) aid = btn[0].dataset.aId $.ajax diff --git a/app/assets/javascripts/answerbox/report.coffee b/app/assets/javascripts/answerbox/report.coffee index bacf29c1..804aa1bd 100644 --- a/app/assets/javascripts/answerbox/report.coffee +++ b/app/assets/javascripts/answerbox/report.coffee @@ -1,6 +1,14 @@ $(document).on "click", "a[data-action=ab-report]", (ev) -> ev.preventDefault() - if confirm 'Are you sure you want to report this answer?' + swal + title: "Report?" + text: "A moderator will check this and decide what happens!" + type: "warning" + showCancelButton: true + confirmButtonColor: "#DD6B55" + confirmButtonText: "Report!" + closeOnConfirm: false + , -> btn = $(this) aid = btn[0].dataset.aId $.ajax diff --git a/app/assets/javascripts/inbox.coffee b/app/assets/javascripts/inbox.coffee index 14c835e2..9347891e 100644 --- a/app/assets/javascripts/inbox.coffee +++ b/app/assets/javascripts/inbox.coffee @@ -22,7 +22,15 @@ ($ document).on "click", "button#ib-delete-all", -> btn = ($ this) count = btn[0].dataset.ibCount - if confirm "Really delete #{count} questions?" + swal + title: "Really delete #{count} questions??" + text: "You will not be able to recover them!" + type: "warning" + showCancelButton: true + confirmButtonColor: "#DD6B55" + confirmButtonText: "Yes, delete all!" + closeOnConfirm: false + , -> btn.button "loading" succ = no $.ajax @@ -84,7 +92,15 @@ $(document).on "click", "button[name=ib-answer]", -> $(document).on "click", "button[name=ib-destroy]", -> - if confirm 'Are you sure?' + swal + title: "Are you sure?" + text: "You will not be able to recover this question!" + type: "warning" + showCancelButton: true + confirmButtonColor: "#DD6B55" + confirmButtonText: "Yes, delete it!" + closeOnConfirm: false + , -> btn = $(this) btn.button "loading" iid = btn[0].dataset.ibId diff --git a/app/assets/javascripts/moderation/comment.coffee b/app/assets/javascripts/moderation/comment.coffee index 27d7544c..dd8647b8 100644 --- a/app/assets/javascripts/moderation/comment.coffee +++ b/app/assets/javascripts/moderation/comment.coffee @@ -68,7 +68,15 @@ $(document).on "input", "input[name=mod-comment-new]", (evt) -> # destroy $(document).on "click", "a[data-action=mod-comment-destroy]", (ev) -> ev.preventDefault() - if confirm 'Are you sure?' + swal + title: "Are you sure?" + text: "You will not be able to recover this comment!" + type: "warning" + showCancelButton: true + confirmButtonColor: "#DD6B55" + confirmButtonText: "Yes, delete it!" + closeOnConfirm: false + , -> btn = $(this) cid = btn[0].dataset.id $.ajax diff --git a/app/assets/javascripts/moderation/destroy.coffee b/app/assets/javascripts/moderation/destroy.coffee index 728b36f3..75feabc5 100644 --- a/app/assets/javascripts/moderation/destroy.coffee +++ b/app/assets/javascripts/moderation/destroy.coffee @@ -1,5 +1,13 @@ $(document).on "click", "button[name=mod-delete-report]", -> - if confirm 'Are you sure?' + swal + title: "Are you sure?" + text: "You will not be able to recover this!" + type: "warning" + showCancelButton: true + confirmButtonColor: "#DD6B55" + confirmButtonText: "Yes, delete it!" + closeOnConfirm: false + , -> btn = $(this) id = btn[0].dataset.id $.ajax