2015-05-11 00:01:48 -07:00
|
|
|
load = ->
|
2020-04-25 06:51:28 -07:00
|
|
|
return unless document.getElementById('ban-control-super') != null
|
|
|
|
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"]')
|
2015-05-11 00:01:48 -07:00
|
|
|
|
2020-04-25 06:51:28 -07:00
|
|
|
banCheckbox.addEventListener "change", (event) ->
|
2015-04-22 17:56:29 -07:00
|
|
|
$t = $ this
|
|
|
|
if $t.is(":checked")
|
|
|
|
$("#ban-controls").show()
|
|
|
|
else
|
|
|
|
$("#ban-controls").hide()
|
2020-04-25 06:51:28 -07:00
|
|
|
permabanCheckbox.addEventListener "change", (event) ->
|
2015-04-22 17:56:29 -07:00
|
|
|
$t = $ this
|
|
|
|
if $t.is(":checked")
|
|
|
|
$("#ban-controls-time").hide()
|
|
|
|
else
|
|
|
|
$("#ban-controls-time").show()
|
|
|
|
|
2020-04-25 06:51:28 -07:00
|
|
|
untilInput = $ modalForm.elements["until"]
|
|
|
|
untilInput.datetimepicker
|
|
|
|
defaultDate: untilInput.val()
|
2015-04-23 12:21:58 -07:00
|
|
|
sideBySide: true
|
2015-04-23 12:07:39 -07:00
|
|
|
icons:
|
|
|
|
time: "fa fa-clock-o"
|
|
|
|
date: "fa fa-calendar"
|
|
|
|
up: "fa fa-chevron-up"
|
|
|
|
down: "fa fa-chevron-down"
|
|
|
|
previous: "fa fa-chevron-left"
|
|
|
|
next: "fa fa-chevron-right"
|
|
|
|
today: "fa fa-home"
|
|
|
|
clear: "fa fa-trash-o"
|
|
|
|
close: "fa fa-times"
|
|
|
|
|
2020-04-25 06:51:28 -07:00
|
|
|
modalForm.addEventListener "submit", (event) ->
|
2015-04-22 17:56:29 -07:00
|
|
|
event.preventDefault();
|
|
|
|
|
2020-04-25 06:51:28 -07:00
|
|
|
checktostr = (el) ->
|
|
|
|
if el.checked
|
2015-04-22 17:56:29 -07:00
|
|
|
"1"
|
|
|
|
else
|
|
|
|
"0"
|
|
|
|
|
|
|
|
data = {
|
2020-04-25 06:51:28 -07:00
|
|
|
ban: checktostr banCheckbox
|
|
|
|
permaban: checktostr permabanCheckbox
|
|
|
|
until: modalForm.elements["until"].value.trim()
|
|
|
|
reason: modalForm.elements["reason"].value.trim()
|
|
|
|
user: modalForm.elements["user"].value
|
2015-04-22 17:56:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
$.ajax
|
|
|
|
url: '/ajax/mod/ban'
|
|
|
|
type: 'POST'
|
|
|
|
data: data
|
|
|
|
success: (data, status, jqxhr) ->
|
|
|
|
showNotification data.message, data.success
|
|
|
|
error: (jqxhr, status, error) ->
|
|
|
|
console.log jqxhr, status, error
|
2015-06-08 11:35:16 -07:00
|
|
|
showNotification translate('frontend.error.message'), false
|
2015-04-22 17:56:29 -07:00
|
|
|
complete: (jqxhr, status) ->
|
2015-05-11 00:01:48 -07:00
|
|
|
|
|
|
|
$(document).on "DOMContentLoaded", ->
|
|
|
|
load()
|
|
|
|
|
|
|
|
$(document).on "page:load", ->
|
|
|
|
load()
|