2014-12-08 06:42:34 -08:00
|
|
|
$(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 "An error occurred, a developer should check the console for details", false
|
|
|
|
complete: (jqxhr, status) ->
|
|
|
|
btn.button "reset"
|
|
|
|
$("textarea[name=qb-all-question]").removeAttr "readonly"
|
|
|
|
|
2015-01-07 10:58:43 -08:00
|
|
|
# hotkey for accessing this quickly
|
|
|
|
$(document).on "keydown", (evt) ->
|
|
|
|
if evt.keyCode == 77 and (evt.ctrlKey or evt.metaKey)
|
|
|
|
$('button[name=toggle-all-ask]').trigger 'click'
|
2014-12-10 11:54:12 -08:00
|
|
|
|
|
|
|
# see GitHub issue #2
|
|
|
|
($ document).on "keydown", "textarea[name=qb-all-question]", (evt) ->
|
2015-01-07 10:58:43 -08:00
|
|
|
if evt.keyCode == 13 and (evt.ctrlKey or evt.metaKey)
|
|
|
|
($ "button[name=qb-all-ask]").trigger 'click'
|