From 2592e239e54b5fd8f218ab06a54e87b5cea6274a Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 31 Jan 2015 01:35:58 -0800 Subject: [PATCH] Merge from Appchan X: src/Posting --- src/Posting/Captcha.noscript.coffee | 3 ++- src/Posting/QR.coffee | 32 ++++++++++++++--------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Posting/Captcha.noscript.coffee b/src/Posting/Captcha.noscript.coffee index a7a10ac8d..f06cf4530 100644 --- a/src/Posting/Captcha.noscript.coffee +++ b/src/Posting/Captcha.noscript.coffee @@ -9,6 +9,7 @@ Captcha.noscript = container = $.el 'div', className: 'captcha-img' title: 'Reload reCAPTCHA' + input = $.el 'input', className: 'captcha-input field' title: 'Verification' @@ -103,7 +104,7 @@ Captcha.noscript = $.off input, 'focus click', @cb.focus 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' destroy: -> diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index ca8f68280..a8776ea6a 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -13,6 +13,17 @@ QR = noscript = Conf['Force Noscript Captcha'] or !doc.dataset.jsEnabled @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'] sc = $.el 'a', className: 'qr-shortcut fa fa-comment-o disabled' @@ -35,17 +46,6 @@ QR = # Prevent unnecessary loading of fallback iframe. $.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: -> $.off d, '4chanXInitFinished', @initReady QR.postingIsEnabled = !!$.id 'postForm' @@ -318,7 +318,7 @@ QR = QR.open() QR.handleFiles files $.addClass QR.nodes.el, 'dump' - + handleUrl: -> url = prompt 'Enter a URL:' return if url is null @@ -429,7 +429,6 @@ QR = if (e.ctrlKey or e.metaKey) and e.type is 'click' $.addClass QR.nodes.filename, 'edit' 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 e.preventDefault() QR.nodes.fileInput.click() @@ -437,11 +436,11 @@ QR = generatePostableThreadsList: -> return unless QR.nodes list = QR.nodes.thread - options = [list.firstChild] + options = [list.firstElementChild] for thread in g.BOARD.threads.keys options.push $.el 'option', value: thread - textContent: "Thread No.#{thread}" + textContent: "No.#{thread}" val = list.value $.rmAll list $.add list, options @@ -544,6 +543,7 @@ QR = $.on nodes.urlButton, 'click', QR.handleUrl $.on nodes.addPost, 'click', -> new QR.post true $.on nodes.form, 'submit', QR.submit + $.on nodes.filename, 'blur', -> $.rmClass @, 'edit' $.on nodes.fileRM, 'click', -> QR.selected.rmFile() $.on nodes.fileExtras, 'click', (e) -> e.stopPropagation() $.on nodes.spoiler, 'change', -> QR.selected.nodes.spoiler.click() @@ -661,7 +661,7 @@ QR = QR.status() QR.error $.el 'span', <%= html( - '${g.NAME} encountered an error while posting. ' + + meta.name + ' encountered an error while posting. ' + '[Banned?] ' + '[More info]' ) %>