Remove legacy questionbox CoffeeScript

This commit is contained in:
Andreas Nedbal 2022-01-03 22:23:52 +01:00 committed by Andreas Nedbal
parent 3df0196e1f
commit 21cba89add
6 changed files with 0 additions and 114 deletions

View File

@ -1,33 +0,0 @@
$(document).on "click", "button[name=qb-all-ask]", ->
btn = $(this)
btn.button "loading"
$("textarea[name=qb-all-question]").attr "readonly", "readonly"
$.ajax
url: '/ajax/ask'
type: 'POST'
data:
rcpt: 'followers'
question: $("textarea[name=qb-all-question]").val()
anonymousQuestion: false
success: (data, status, jqxhr) ->
if data.success
$("textarea[name=qb-all-question]").val ''
$('#modal-ask-followers').modal('hide')
showNotification data.message, data.success
error: (jqxhr, status, error) ->
console.log jqxhr, status, error
showNotification translate('frontend.error.message'), false
complete: (jqxhr, status) ->
btn.button "reset"
$("textarea[name=qb-all-question]").removeAttr "readonly"
# hotkey for accessing this quickly
$(document).on "keydown", (evt) ->
if evt.keyCode == 77 and (evt.ctrlKey or evt.metaKey)
$('.btn[name=toggle-all-ask]').trigger 'click'
# see GitHub issue #2
($ document).on "keydown", "textarea[name=qb-all-question]", (evt) ->
if evt.keyCode == 13 and (evt.ctrlKey or evt.metaKey)
($ "button[name=qb-all-ask]").trigger 'click'

View File

@ -1,30 +0,0 @@
$(document).on "click", "a[data-action=ab-question-destroy]", (ev) ->
ev.preventDefault()
btn = $(this)
qid = btn[0].dataset.qId
swal
title: translate('frontend.destroy_own.confirm.title')
text: translate('frontend.destroy_own.confirm.text')
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: translate('views.actions.y')
cancelButtonText: translate('views.actions.n')
closeOnConfirm: true
, ->
$.ajax
url: '/ajax/destroy_question' # TODO: find a way to use rake routes instead of hardcoding them here
type: 'POST'
data:
question: qid
success: (data, status, jqxhr) ->
if data.success
if btn[0].dataset.redirect != undefined
window.location.pathname = btn[0].dataset.redirect
else
$("div.answerbox[data-q-id=#{qid}], div.questionbox[data-id=#{qid}]").slideUp()
showNotification data.message, data.success
error: (jqxhr, status, error) ->
console.log jqxhr, status, error
showNotification translate('frontend.error.message'), false
complete: (jqxhr, status) ->

View File

@ -1,4 +0,0 @@
import './all'
import './destroy'
import './report'
import './user'

View File

@ -1,5 +0,0 @@
$(document).on "click", "a[data-action=ab-question-report]", (ev) ->
ev.preventDefault()
btn = $(this)
qId = btn[0].dataset.qId
reportDialog "question", qId, -> btn.button "reset"

View File

@ -1,41 +0,0 @@
$(document).on "click", "button[name=qb-ask]", ->
btn = $(this)
btn.button "loading"
promote = btn[0].dataset.promote == "true"
$("textarea[name=qb-question]").attr "readonly", "readonly"
anonymousQuestion = if $("input[name=qb-anonymous]")[0] != undefined
$("input[name=qb-anonymous]")[0].checked
else
true
$.ajax
url: '/ajax/ask' # TODO: find a way to use rake routes instead of hardcoding them here
type: 'POST'
data:
rcpt: $("input[name=qb-to]").val()
question: $("textarea[name=qb-question]").val()
anonymousQuestion: anonymousQuestion
success: (data, status, jqxhr) ->
if data.success
$("textarea[name=qb-question]").val ''
if promote
$("div#question-box").hide()
$("div#question-box-promote").show()
showNotification data.message, data.success
error: (jqxhr, status, error) ->
console.log jqxhr, status, error
showNotification translate('frontend.error.message'), false
complete: (jqxhr, status) ->
btn.button "reset"
$("textarea[name=qb-question]").removeAttr "readonly"
# for that promotional thing
$(document).on "click", "button#new-question", ->
$("div#question-box").show()
$("div#question-box-promote").hide()
# see GitHub issue #2
($ document).on "keydown", "textarea[name=qb-question]", (evt) ->
if evt.keyCode == 13 and evt.ctrlKey
($ "button[name=qb-ask]").trigger 'click'

View File

@ -23,7 +23,6 @@ require('jquery-minicolors/jquery.minicolors.css')
import I18n from '../legacy/i18n' import I18n from '../legacy/i18n'
import '../legacy/answerbox' import '../legacy/answerbox'
import '../legacy/questionbox'
import '../legacy/memes' import '../legacy/memes'
import '../legacy/notifications' import '../legacy/notifications'
import '../legacy/pagination' import '../legacy/pagination'