Allow the Quick Reply to be used on pages without an original post form such as archived threads. #242
This commit is contained in:
parent
6a00c9f757
commit
5d2abe09b0
@ -3,7 +3,7 @@ Captcha.v2 =
|
||||
|
||||
init: ->
|
||||
return if d.cookie.indexOf('pass_enabled=1') >= 0
|
||||
return if not (@isEnabled = !!$ '#g-recaptcha, #captcha-forced-noscript')
|
||||
return if not (@isEnabled = !!$('#g-recaptcha, #captcha-forced-noscript') or !$.id('postForm'))
|
||||
|
||||
if (@noscript = Conf['Force Noscript Captcha'] or not Main.jsEnabled)
|
||||
$.addClass QR.nodes.el, 'noscript-captcha'
|
||||
@ -112,6 +112,10 @@ Captcha.v2 =
|
||||
window.onRecaptchaLoaded = ->
|
||||
render()
|
||||
cbNative()
|
||||
unless document.head.querySelector 'script[src^="https://www.google.com/recaptcha/api.js"]'
|
||||
script = document.createElement 'script'
|
||||
script.src = 'https://www.google.com/recaptcha/api.js?onload=onRecaptchaLoaded&render=explicit'
|
||||
document.head.appendChild script
|
||||
|
||||
afterSetup: (mutations) ->
|
||||
for mutation in mutations
|
||||
|
||||
@ -26,8 +26,6 @@ QR =
|
||||
|
||||
@posts = []
|
||||
|
||||
return if g.VIEW is 'archive'
|
||||
|
||||
@captcha = Captcha.v2
|
||||
|
||||
$.on d, '4chanXInitFinished', -> BoardConfig.ready QR.initReady
|
||||
@ -52,8 +50,7 @@ QR =
|
||||
Header.addShortcut 'qr', sc, 540
|
||||
|
||||
initReady: ->
|
||||
QR.postingIsEnabled = !!$.id 'postForm'
|
||||
return unless QR.postingIsEnabled
|
||||
QR.postingIsEnabled = true
|
||||
|
||||
{config} = g.BOARD
|
||||
prop = (key, def) -> +(config[key] ? def)
|
||||
@ -72,14 +69,18 @@ QR =
|
||||
QR.forcedAnon = !!config.forced_anon
|
||||
QR.spoiler = !!config.spoilers
|
||||
|
||||
link = $.el 'h1',
|
||||
className: "qr-link-container"
|
||||
$.extend link, <%= html('<a href="javascript:;" class="qr-link">?{g.VIEW === "thread"}{Reply to Thread}{Start a Thread}</a>') %>
|
||||
if (origToggle = $.id 'togglePostFormLink')
|
||||
link = $.el 'h1',
|
||||
className: "qr-link-container"
|
||||
$.extend link, <%= html('<a href="javascript:;" class="qr-link">?{g.VIEW === "thread"}{Reply to Thread}{Start a Thread}</a>') %>
|
||||
|
||||
QR.link = link.firstElementChild
|
||||
$.on link.firstChild, 'click', ->
|
||||
QR.open()
|
||||
QR.nodes.com.focus()
|
||||
QR.link = link.firstElementChild
|
||||
$.on link.firstChild, 'click', ->
|
||||
QR.open()
|
||||
QR.nodes.com.focus()
|
||||
|
||||
$.before origToggle, link
|
||||
origToggle.firstElementChild.textContent = 'Original Form'
|
||||
|
||||
if g.VIEW is 'thread'
|
||||
linkBot = $.el 'div',
|
||||
@ -92,10 +93,6 @@ QR =
|
||||
|
||||
$.prepend navLinksBot, linkBot if (navLinksBot = $ '.navLinksBot')
|
||||
|
||||
origToggle = $.id 'togglePostFormLink'
|
||||
$.before origToggle, link
|
||||
origToggle.firstElementChild.textContent = 'Original Form'
|
||||
|
||||
$.on d, 'QRGetFile', QR.getFile
|
||||
$.on d, 'QRSetFile', QR.setFile
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user