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: ->
|
init: ->
|
||||||
return if d.cookie.indexOf('pass_enabled=1') >= 0
|
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)
|
if (@noscript = Conf['Force Noscript Captcha'] or not Main.jsEnabled)
|
||||||
$.addClass QR.nodes.el, 'noscript-captcha'
|
$.addClass QR.nodes.el, 'noscript-captcha'
|
||||||
@ -112,6 +112,10 @@ Captcha.v2 =
|
|||||||
window.onRecaptchaLoaded = ->
|
window.onRecaptchaLoaded = ->
|
||||||
render()
|
render()
|
||||||
cbNative()
|
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) ->
|
afterSetup: (mutations) ->
|
||||||
for mutation in mutations
|
for mutation in mutations
|
||||||
|
|||||||
@ -26,8 +26,6 @@ QR =
|
|||||||
|
|
||||||
@posts = []
|
@posts = []
|
||||||
|
|
||||||
return if g.VIEW is 'archive'
|
|
||||||
|
|
||||||
@captcha = Captcha.v2
|
@captcha = Captcha.v2
|
||||||
|
|
||||||
$.on d, '4chanXInitFinished', -> BoardConfig.ready QR.initReady
|
$.on d, '4chanXInitFinished', -> BoardConfig.ready QR.initReady
|
||||||
@ -52,8 +50,7 @@ QR =
|
|||||||
Header.addShortcut 'qr', sc, 540
|
Header.addShortcut 'qr', sc, 540
|
||||||
|
|
||||||
initReady: ->
|
initReady: ->
|
||||||
QR.postingIsEnabled = !!$.id 'postForm'
|
QR.postingIsEnabled = true
|
||||||
return unless QR.postingIsEnabled
|
|
||||||
|
|
||||||
{config} = g.BOARD
|
{config} = g.BOARD
|
||||||
prop = (key, def) -> +(config[key] ? def)
|
prop = (key, def) -> +(config[key] ? def)
|
||||||
@ -72,14 +69,18 @@ QR =
|
|||||||
QR.forcedAnon = !!config.forced_anon
|
QR.forcedAnon = !!config.forced_anon
|
||||||
QR.spoiler = !!config.spoilers
|
QR.spoiler = !!config.spoilers
|
||||||
|
|
||||||
link = $.el 'h1',
|
if (origToggle = $.id 'togglePostFormLink')
|
||||||
className: "qr-link-container"
|
link = $.el 'h1',
|
||||||
$.extend link, <%= html('<a href="javascript:;" class="qr-link">?{g.VIEW === "thread"}{Reply to Thread}{Start a Thread}</a>') %>
|
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
|
QR.link = link.firstElementChild
|
||||||
$.on link.firstChild, 'click', ->
|
$.on link.firstChild, 'click', ->
|
||||||
QR.open()
|
QR.open()
|
||||||
QR.nodes.com.focus()
|
QR.nodes.com.focus()
|
||||||
|
|
||||||
|
$.before origToggle, link
|
||||||
|
origToggle.firstElementChild.textContent = 'Original Form'
|
||||||
|
|
||||||
if g.VIEW is 'thread'
|
if g.VIEW is 'thread'
|
||||||
linkBot = $.el 'div',
|
linkBot = $.el 'div',
|
||||||
@ -92,10 +93,6 @@ QR =
|
|||||||
|
|
||||||
$.prepend navLinksBot, linkBot if (navLinksBot = $ '.navLinksBot')
|
$.prepend navLinksBot, linkBot if (navLinksBot = $ '.navLinksBot')
|
||||||
|
|
||||||
origToggle = $.id 'togglePostFormLink'
|
|
||||||
$.before origToggle, link
|
|
||||||
origToggle.firstElementChild.textContent = 'Original Form'
|
|
||||||
|
|
||||||
$.on d, 'QRGetFile', QR.getFile
|
$.on d, 'QRGetFile', QR.getFile
|
||||||
$.on d, 'QRSetFile', QR.setFile
|
$.on d, 'QRSetFile', QR.setFile
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user