This commit is contained in:
Nicolas Stepien 2013-04-15 23:05:32 +02:00
parent cf1d94876a
commit b3ea2cc08f

View File

@ -29,6 +29,11 @@ QR =
QR.nodes.com.focus() QR.nodes.com.focus()
Header.addShortcut sc Header.addShortcut sc
$.on d, 'QRGetSelectedPost', ({detail: cb}) ->
cb QR.selected
$.on d, 'QRAddPreSubmitHook', ({detail: cb}) ->
QR.preSubmitHooks.push cb
<% if (type === 'crx') { %> <% if (type === 'crx') { %>
$.on d, 'paste', QR.paste $.on d, 'paste', QR.paste
<% } %> <% } %>
@ -449,6 +454,7 @@ QR =
rectList = @nodes.el.parentNode.getBoundingClientRect() rectList = @nodes.el.parentNode.getBoundingClientRect()
@nodes.el.parentNode.scrollLeft += rectEl.left + rectEl.width/2 - rectList.left - rectList.width/2 @nodes.el.parentNode.scrollLeft += rectEl.left + rectEl.width/2 - rectList.left - rectList.width/2
@load() @load()
$.event 'QRPostSelection', @
load: -> load: ->
# Load this post's values. # Load this post's values.
for name in ['thread', 'name', 'email', 'sub', 'com'] for name in ['thread', 'name', 'email', 'sub', 'com']
@ -860,6 +866,7 @@ QR =
# Use it to extend the QR's functionalities, or for XTRM RICE. # Use it to extend the QR's functionalities, or for XTRM RICE.
$.event 'QRDialogCreation', null, dialog $.event 'QRDialogCreation', null, dialog
preSubmitHooks: []
submit: (e) -> submit: (e) ->
e?.preventDefault() e?.preventDefault()
@ -892,6 +899,9 @@ QR =
err = 'No file selected.' err = 'No file selected.'
else if post.file and thread.fileLimit and !thread.isSticky else if post.file and thread.fileLimit and !thread.isSticky
err = 'Max limit of image replies has been reached.' err = 'Max limit of image replies has been reached.'
else for hook in QR.preSubmitHooks
if err = hook post, thread
break
if QR.captcha.isEnabled and !err if QR.captcha.isEnabled and !err
{challenge, response} = QR.captcha.getOne() {challenge, response} = QR.captcha.getOne()
@ -1046,11 +1056,10 @@ QR =
val: true val: true
# Post/upload confirmed as successful. # Post/upload confirmed as successful.
$.event 'QRPostSuccessful', { $.event 'QRPostSuccessful',
board: g.BOARD board: g.BOARD
threadID threadID
postID postID
}, QR.nodes.el
# Enable auto-posting if we have stuff to post, disable it otherwise. # Enable auto-posting if we have stuff to post, disable it otherwise.
QR.cooldown.auto = QR.posts.length > 1 and isReply QR.cooldown.auto = QR.posts.length > 1 and isReply