Fix QR hiding issue.
We should now be able to tell when the QR is focused even when within the captcha <iframe>. No longer need to hold open QR when there is a captcha.
This commit is contained in:
parent
a9e7240547
commit
dd7dbf80f4
@ -969,7 +969,7 @@ span.hide-announcement {
|
|||||||
|
|
||||||
/* QR */
|
/* QR */
|
||||||
:root.hide-original-post-form #togglePostFormLink,
|
:root.hide-original-post-form #togglePostFormLink,
|
||||||
#qr.autohide:not(.focus):not(:hover):not(:active):not(.captcha-open) > form,
|
#qr.autohide:not(.focus):not(:hover):not(:active) > form,
|
||||||
:root.thread-view #qr:not(.show-new-thread-option) select[data-name="thread"],
|
:root.thread-view #qr:not(.show-new-thread-option) select[data-name="thread"],
|
||||||
#file-n-submit:not(.has-file) #qr-filerm {
|
#file-n-submit:not(.has-file) #qr-filerm {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@ -16,8 +16,6 @@ Captcha.noscript =
|
|||||||
spellcheck: false
|
spellcheck: false
|
||||||
@nodes = {container, input}
|
@nodes = {container, input}
|
||||||
|
|
||||||
$.on input, 'blur', QR.focusout
|
|
||||||
$.on input, 'focus', QR.focusin
|
|
||||||
$.on input, 'keydown', @keydown.bind @
|
$.on input, 'keydown', @keydown.bind @
|
||||||
$.on @nodes.container, 'click', =>
|
$.on @nodes.container, 'click', =>
|
||||||
@reload()
|
@reload()
|
||||||
|
|||||||
@ -37,6 +37,9 @@ QR =
|
|||||||
|
|
||||||
$.on d, '4chanXInitFinished', @initReady
|
$.on d, '4chanXInitFinished', @initReady
|
||||||
|
|
||||||
|
window.addEventListener 'focus', @focus, true
|
||||||
|
window.addEventListener 'blur', @focus, true
|
||||||
|
|
||||||
Post.callbacks.push
|
Post.callbacks.push
|
||||||
name: 'Quick Reply'
|
name: 'Quick Reply'
|
||||||
cb: @node
|
cb: @node
|
||||||
@ -127,11 +130,14 @@ QR =
|
|||||||
QR.cooldown.auto = false
|
QR.cooldown.auto = false
|
||||||
QR.status()
|
QR.status()
|
||||||
QR.captcha.destroy()
|
QR.captcha.destroy()
|
||||||
focusin: ->
|
focus: ->
|
||||||
QR.captcha.setup() if $.hasClass(QR.nodes.el, 'autohide') and !$.hasClass(QR.nodes.el, 'focus')
|
$.queueTask ->
|
||||||
$.addClass QR.nodes.el, 'focus'
|
return unless QR.nodes
|
||||||
focusout: ->
|
if d.activeElement and QR.nodes.el.contains d.activeElement
|
||||||
$.rmClass QR.nodes.el, 'focus'
|
QR.captcha.setup() if $.hasClass(QR.nodes.el, 'autohide') and !$.hasClass(QR.nodes.el, 'focus')
|
||||||
|
$.addClass QR.nodes.el, 'focus'
|
||||||
|
else
|
||||||
|
$.rmClass QR.nodes.el, 'focus'
|
||||||
hide: ->
|
hide: ->
|
||||||
d.activeElement.blur()
|
d.activeElement.blur()
|
||||||
$.addClass QR.nodes.el, 'autohide'
|
$.addClass QR.nodes.el, 'autohide'
|
||||||
@ -518,12 +524,6 @@ QR =
|
|||||||
|
|
||||||
$.on nodes.filename.parentNode, 'click keydown', QR.openFileInput
|
$.on nodes.filename.parentNode, 'click keydown', QR.openFileInput
|
||||||
|
|
||||||
items = $$ '*', QR.nodes.el
|
|
||||||
i = 0
|
|
||||||
while elm = items[i++]
|
|
||||||
$.on elm, 'blur', QR.focusout
|
|
||||||
$.on elm, 'focus', QR.focusin
|
|
||||||
|
|
||||||
$.on nodes.autohide, 'change', QR.toggleHide
|
$.on nodes.autohide, 'change', QR.toggleHide
|
||||||
$.on nodes.close, 'click', QR.close
|
$.on nodes.close, 'click', QR.close
|
||||||
$.on nodes.dumpButton, 'click', -> nodes.el.classList.toggle 'dump'
|
$.on nodes.dumpButton, 'click', -> nodes.el.classList.toggle 'dump'
|
||||||
|
|||||||
@ -13,12 +13,6 @@ QR.post = class
|
|||||||
spoiler: $ 'input', el
|
spoiler: $ 'input', el
|
||||||
span: el.lastChild
|
span: el.lastChild
|
||||||
|
|
||||||
<% if (type === 'userscript') { %>
|
|
||||||
# XXX Firefox lacks focusin/focusout support.
|
|
||||||
for elm in $$ '*', el
|
|
||||||
$.on elm, 'blur', QR.focusout
|
|
||||||
$.on elm, 'focus', QR.focusin
|
|
||||||
<% } %>
|
|
||||||
$.on el, 'click', @select
|
$.on el, 'click', @select
|
||||||
$.on @nodes.rm, 'click', (e) => e.stopPropagation(); @rm()
|
$.on @nodes.rm, 'click', (e) => e.stopPropagation(); @rm()
|
||||||
$.on @nodes.label, 'click', (e) => e.stopPropagation()
|
$.on @nodes.label, 'click', (e) => e.stopPropagation()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user