mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-31 14:39:07 +01:00
Fix exception being thrown upon attempting to ban a user (#82)
This commit is contained in:
parent
d09cf5e979
commit
9f992d398f
1 changed files with 19 additions and 16 deletions
|
@ -1,22 +1,27 @@
|
||||||
load = ->
|
load = ->
|
||||||
parent = $ "#ban-control-super"
|
return unless document.getElementById('ban-control-super') != null
|
||||||
return unless parent.length > 0
|
modalEl = $("#modal-ban")
|
||||||
|
modalEl.modal "hide"
|
||||||
|
modalForm = modalEl.find("form")[0]
|
||||||
|
banCheckbox = modalForm.querySelector('[name="ban"][type="checkbox"]')
|
||||||
|
permabanCheckbox = modalForm.querySelector('[name="permaban"][type="checkbox"]')
|
||||||
|
|
||||||
parent.find('#_ban').on "change", (event) ->
|
banCheckbox.addEventListener "change", (event) ->
|
||||||
$t = $ this
|
$t = $ this
|
||||||
if $t.is(":checked")
|
if $t.is(":checked")
|
||||||
$("#ban-controls").show()
|
$("#ban-controls").show()
|
||||||
else
|
else
|
||||||
$("#ban-controls").hide()
|
$("#ban-controls").hide()
|
||||||
parent.find('#_permaban').on "change", (event) ->
|
permabanCheckbox.addEventListener "change", (event) ->
|
||||||
$t = $ this
|
$t = $ this
|
||||||
if $t.is(":checked")
|
if $t.is(":checked")
|
||||||
$("#ban-controls-time").hide()
|
$("#ban-controls-time").hide()
|
||||||
else
|
else
|
||||||
$("#ban-controls-time").show()
|
$("#ban-controls-time").show()
|
||||||
|
|
||||||
parent.find("#until").datetimepicker
|
untilInput = $ modalForm.elements["until"]
|
||||||
defaultDate: parent.find("#until").val()
|
untilInput.datetimepicker
|
||||||
|
defaultDate: untilInput.val()
|
||||||
sideBySide: true
|
sideBySide: true
|
||||||
icons:
|
icons:
|
||||||
time: "fa fa-clock-o"
|
time: "fa fa-clock-o"
|
||||||
|
@ -29,23 +34,21 @@ load = ->
|
||||||
clear: "fa fa-trash-o"
|
clear: "fa fa-trash-o"
|
||||||
close: "fa fa-times"
|
close: "fa fa-times"
|
||||||
|
|
||||||
parent.parent()[0].addEventListener "submit", (event) ->
|
modalForm.addEventListener "submit", (event) ->
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
$("#modal-ban").modal "hide"
|
checktostr = (el) ->
|
||||||
|
if el.checked
|
||||||
checktostr = (selector) ->
|
|
||||||
if $(selector)[0].checked
|
|
||||||
"1"
|
"1"
|
||||||
else
|
else
|
||||||
"0"
|
"0"
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
ban: checktostr "#_ban"
|
ban: checktostr banCheckbox
|
||||||
permaban: checktostr "#_permaban"
|
permaban: checktostr permabanCheckbox
|
||||||
until: $("#until")[0].value.trim()
|
until: modalForm.elements["until"].value.trim()
|
||||||
reason: $("#reason")[0].value.trim()
|
reason: modalForm.elements["reason"].value.trim()
|
||||||
user: $("#_user")[0].value
|
user: modalForm.elements["user"].value
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax
|
$.ajax
|
||||||
|
|
Loading…
Reference in a new issue