Merge from Appchan X: src/Posting

This commit is contained in:
ccd0 2015-01-31 01:35:58 -08:00
parent d983857976
commit 2592e239e5
2 changed files with 18 additions and 17 deletions

View File

@ -9,6 +9,7 @@ Captcha.noscript =
container = $.el 'div', container = $.el 'div',
className: 'captcha-img' className: 'captcha-img'
title: 'Reload reCAPTCHA' title: 'Reload reCAPTCHA'
input = $.el 'input', input = $.el 'input',
className: 'captcha-input field' className: 'captcha-input field'
title: 'Verification' title: 'Verification'
@ -103,7 +104,7 @@ Captcha.noscript =
$.off input, 'focus click', @cb.focus $.off input, 'focus click', @cb.focus
if QR.nodes.el.getBoundingClientRect().bottom > doc.clientHeight if QR.nodes.el.getBoundingClientRect().bottom > doc.clientHeight
QR.nodes.el.style.top = null QR.nodes.el.style.top = ''
QR.nodes.el.style.bottom = '0px' QR.nodes.el.style.bottom = '0px'
destroy: -> destroy: ->

View File

@ -13,6 +13,17 @@ QR =
noscript = Conf['Force Noscript Captcha'] or !doc.dataset.jsEnabled noscript = Conf['Force Noscript Captcha'] or !doc.dataset.jsEnabled
@captcha = Captcha[if noscript then 'noscript' else 'v2'] @captcha = Captcha[if noscript then 'noscript' else 'v2']
$.on d, '4chanXInitFinished', @initReady
window.addEventListener 'focus', @focus, true
window.addEventListener 'blur', @focus, true
# We don't receive blur events from captcha iframe.
$.on d, 'click', @focus
Post.callbacks.push
name: 'Quick Reply'
cb: @node
if Conf['QR Shortcut'] if Conf['QR Shortcut']
sc = $.el 'a', sc = $.el 'a',
className: 'qr-shortcut fa fa-comment-o disabled' className: 'qr-shortcut fa fa-comment-o disabled'
@ -35,17 +46,6 @@ QR =
# Prevent unnecessary loading of fallback iframe. # Prevent unnecessary loading of fallback iframe.
$.onExists doc, '#postForm noscript', true, $.rm $.onExists doc, '#postForm noscript', true, $.rm
$.on d, '4chanXInitFinished', @initReady
window.addEventListener 'focus', @focus, true
window.addEventListener 'blur', @focus, true
# We don't receive blur events from captcha iframe.
$.on d, 'click', @focus
Post.callbacks.push
name: 'Quick Reply'
cb: @node
initReady: -> initReady: ->
$.off d, '4chanXInitFinished', @initReady $.off d, '4chanXInitFinished', @initReady
QR.postingIsEnabled = !!$.id 'postForm' QR.postingIsEnabled = !!$.id 'postForm'
@ -429,7 +429,6 @@ QR =
if (e.ctrlKey or e.metaKey) and e.type is 'click' if (e.ctrlKey or e.metaKey) and e.type is 'click'
$.addClass QR.nodes.filename, 'edit' $.addClass QR.nodes.filename, 'edit'
QR.nodes.filename.focus() QR.nodes.filename.focus()
return $.on QR.nodes.filename, 'blur', -> $.rmClass QR.nodes.filename, 'edit'
return if e.target.nodeName is 'INPUT' or (e.keyCode and e.keyCode not in [32, 13]) or e.ctrlKey return if e.target.nodeName is 'INPUT' or (e.keyCode and e.keyCode not in [32, 13]) or e.ctrlKey
e.preventDefault() e.preventDefault()
QR.nodes.fileInput.click() QR.nodes.fileInput.click()
@ -437,11 +436,11 @@ QR =
generatePostableThreadsList: -> generatePostableThreadsList: ->
return unless QR.nodes return unless QR.nodes
list = QR.nodes.thread list = QR.nodes.thread
options = [list.firstChild] options = [list.firstElementChild]
for thread in g.BOARD.threads.keys for thread in g.BOARD.threads.keys
options.push $.el 'option', options.push $.el 'option',
value: thread value: thread
textContent: "Thread No.#{thread}" textContent: "No.#{thread}"
val = list.value val = list.value
$.rmAll list $.rmAll list
$.add list, options $.add list, options
@ -544,6 +543,7 @@ QR =
$.on nodes.urlButton, 'click', QR.handleUrl $.on nodes.urlButton, 'click', QR.handleUrl
$.on nodes.addPost, 'click', -> new QR.post true $.on nodes.addPost, 'click', -> new QR.post true
$.on nodes.form, 'submit', QR.submit $.on nodes.form, 'submit', QR.submit
$.on nodes.filename, 'blur', -> $.rmClass @, 'edit'
$.on nodes.fileRM, 'click', -> QR.selected.rmFile() $.on nodes.fileRM, 'click', -> QR.selected.rmFile()
$.on nodes.fileExtras, 'click', (e) -> e.stopPropagation() $.on nodes.fileExtras, 'click', (e) -> e.stopPropagation()
$.on nodes.spoiler, 'change', -> QR.selected.nodes.spoiler.click() $.on nodes.spoiler, 'change', -> QR.selected.nodes.spoiler.click()
@ -661,7 +661,7 @@ QR =
QR.status() QR.status()
QR.error $.el 'span', QR.error $.el 'span',
<%= html( <%= html(
'${g.NAME} encountered an error while posting. ' + meta.name + ' encountered an error while posting. ' +
'[<a href="//4chan.org/banned" target="_blank">Banned?</a>] ' + '[<a href="//4chan.org/banned" target="_blank">Banned?</a>] ' +
'[<a href="${g.FAQ}#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean" target="_blank">More info</a>]' '[<a href="${g.FAQ}#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean" target="_blank">More info</a>]'
) %> ) %>