Merge branch 'sweetalert'

This commit is contained in:
nilsding 2015-01-03 19:54:42 +01:00
commit f1c0bc5a4c
13 changed files with 111 additions and 22 deletions

View file

@ -20,6 +20,7 @@ gem 'bcrypt', '~> 3.1.7'
gem 'haml' gem 'haml'
gem 'bootstrap-sass', '~> 3.2.0.1' gem 'bootstrap-sass', '~> 3.2.0.1'
gem 'bootswatch-rails' gem 'bootswatch-rails'
gem 'sweetalert-rails'
gem 'will_paginate' gem 'will_paginate'
gem 'will_paginate-bootstrap' gem 'will_paginate-bootstrap'
gem 'http_accept_language' gem 'http_accept_language'

View file

@ -298,6 +298,8 @@ GEM
colorize (>= 0.7.0) colorize (>= 0.7.0)
net-scp (>= 1.1.2) net-scp (>= 1.1.2)
net-ssh (>= 2.8.0) net-ssh (>= 2.8.0)
sweetalert-rails (0.3.3)
railties (>= 3.1.0)
thin (1.6.3) thin (1.6.3)
daemons (~> 1.0, >= 1.0.9) daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0) eventmachine (~> 1.0)
@ -387,6 +389,7 @@ DEPENDENCIES
simplecov simplecov
sinatra sinatra
spring spring
sweetalert-rails
thin thin
turbolinks turbolinks
twitter twitter

View file

@ -1,8 +1,16 @@
$(document).on "click", "a[data-action=ab-comment-destroy]", (ev) -> $(document).on "click", "a[data-action=ab-comment-destroy]", (ev) ->
ev.preventDefault() ev.preventDefault()
if confirm 'Are you sure?'
btn = $(this) btn = $(this)
cid = btn[0].dataset.cId cid = btn[0].dataset.cId
swal
title: "Really delete?"
text: "You will not be able to recover this comment."
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Delete"
closeOnConfirm: true
, ->
$.ajax $.ajax
url: '/ajax/destroy_comment' url: '/ajax/destroy_comment'
type: 'POST' type: 'POST'

View file

@ -1,8 +1,16 @@
$(document).on "click", "a[data-action=ab-comment-report]", (ev) -> $(document).on "click", "a[data-action=ab-comment-report]", (ev) ->
ev.preventDefault() ev.preventDefault()
if confirm 'Are you sure you want to report this comment?'
btn = $(this) btn = $(this)
cid = btn[0].dataset.cId cid = btn[0].dataset.cId
swal
title: "Really report?"
text: "A moderator will review this comment and decide what happens."
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Report"
closeOnConfirm: true
, ->
$.ajax $.ajax
url: '/ajax/report' url: '/ajax/report'
type: 'POST' type: 'POST'

View file

@ -1,8 +1,16 @@
$(document).on "click", "a[data-action=ab-destroy]", (ev) -> $(document).on "click", "a[data-action=ab-destroy]", (ev) ->
ev.preventDefault() ev.preventDefault()
if confirm 'Are you sure?'
btn = $(this) btn = $(this)
aid = btn[0].dataset.aId aid = btn[0].dataset.aId
swal
title: "Really delete?"
text: "The question will be moved back to your inbox."
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Delete"
closeOnConfirm: true
, ->
$.ajax $.ajax
url: '/ajax/destroy_answer' # TODO: find a way to use rake routes instead of hardcoding them here url: '/ajax/destroy_answer' # TODO: find a way to use rake routes instead of hardcoding them here
type: 'POST' type: 'POST'

View file

@ -1,8 +1,16 @@
$(document).on "click", "a[data-action=ab-report]", (ev) -> $(document).on "click", "a[data-action=ab-report]", (ev) ->
ev.preventDefault() ev.preventDefault()
if confirm 'Are you sure you want to report this answer?'
btn = $(this) btn = $(this)
aid = btn[0].dataset.aId aid = btn[0].dataset.aId
swal
title: "Really report?"
text: "A moderator will review this answer and decide what happens."
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Report"
closeOnConfirm: true
, ->
$.ajax $.ajax
url: '/ajax/report' # TODO: find a way to use rake routes instead of hardcoding them here url: '/ajax/report' # TODO: find a way to use rake routes instead of hardcoding them here
type: 'POST' type: 'POST'

View file

@ -8,6 +8,7 @@
#= require growl #= require growl
#= require cheet #= require cheet
#= require jquery.guillotine #= require jquery.guillotine
#= require sweet-alert
#= require_tree . #= require_tree .
NProgress.configure NProgress.configure
@ -24,3 +25,9 @@ window.showNotification = (text, success=true) ->
$(document).on "click", "button#create-account", -> $(document).on "click", "button#create-account", ->
Turbolinks.visit "/sign_up" Turbolinks.visit "/sign_up"
_ready = ->
sweetAlertInitialize()
$(document).ready _ready
$(document).on 'page:load', _ready

View file

@ -22,7 +22,15 @@
($ document).on "click", "button#ib-delete-all", -> ($ document).on "click", "button#ib-delete-all", ->
btn = ($ this) btn = ($ this)
count = btn[0].dataset.ibCount count = btn[0].dataset.ibCount
if confirm "Really delete #{count} questions?" swal
title: "Really delete #{count} questions?"
text: "They will be gone forever."
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Delete"
closeOnConfirm: true
, ->
btn.button "loading" btn.button "loading"
succ = no succ = no
$.ajax $.ajax
@ -85,8 +93,16 @@ $(document).on "click", "button[name=ib-answer]", ->
$(document).on "click", "button[name=ib-destroy]", -> $(document).on "click", "button[name=ib-destroy]", ->
if confirm 'Are you sure?'
btn = $(this) btn = $(this)
swal
title: "Really delete?"
text: "This question will be gone forever."
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Delete"
closeOnConfirm: true
, ->
btn.button "loading" btn.button "loading"
iid = btn[0].dataset.ibId iid = btn[0].dataset.ibId
$("textarea[name=ib-answer][data-id=#{iid}]").attr "readonly", "readonly" $("textarea[name=ib-answer][data-id=#{iid}]").attr "readonly", "readonly"

View file

@ -68,9 +68,17 @@ $(document).on "input", "input[name=mod-comment-new]", (evt) ->
# destroy # destroy
$(document).on "click", "a[data-action=mod-comment-destroy]", (ev) -> $(document).on "click", "a[data-action=mod-comment-destroy]", (ev) ->
ev.preventDefault() ev.preventDefault()
if confirm 'Are you sure?'
btn = $(this) btn = $(this)
cid = btn[0].dataset.id cid = btn[0].dataset.id
swal
title: "Really delete?"
text: "You will not be able to recover this comment."
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Delete"
closeOnConfirm: true
, ->
$.ajax $.ajax
url: '/ajax/mod/destroy_comment' url: '/ajax/mod/destroy_comment'
type: 'POST' type: 'POST'

View file

@ -1,7 +1,15 @@
$(document).on "click", "button[name=mod-delete-report]", -> $(document).on "click", "button[name=mod-delete-report]", ->
if confirm 'Are you sure?'
btn = $(this) btn = $(this)
id = btn[0].dataset.id id = btn[0].dataset.id
swal
title: "Really delete?"
text: "You will not be able to recover this report."
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Delete"
closeOnConfirm: true
, ->
$.ajax $.ajax
url: '/ajax/mod/destroy_report' url: '/ajax/mod/destroy_report'
type: 'POST' type: 'POST'

View file

@ -50,7 +50,16 @@ $(document).on "click", "a[data-action=report-user]", (ev) ->
ev.preventDefault() ev.preventDefault()
btn = $(this) btn = $(this)
target = btn[0].dataset.target target = btn[0].dataset.target
if confirm "Are you sure you want to report #{target}?"
swal
title: "Really report #{target}?"
text: "A moderator will review this user and decide what happens."
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Report"
closeOnConfirm: true
, ->
$.ajax $.ajax
url: '/ajax/report' url: '/ajax/report'
type: 'POST' type: 'POST'

View file

@ -2,6 +2,7 @@
*= require rails_bootstrap_forms *= require rails_bootstrap_forms
*= require growl *= require growl
*= require jquery.guillotine *= require jquery.guillotine
*= require sweet-alert
*= require_self *= require_self
*/ */

View file

@ -70,3 +70,7 @@ body {
.j2-up { .j2-up {
text-transform: uppercase; text-transform: uppercase;
} }
.sweet-overlay {
z-index: 1031;
}