From 6083136a85a7fcfbe7e45beb568e009e20a09fd5 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 30 Jan 2012 00:04:13 +0100 Subject: [PATCH] Create a custom event when the QR dialog is first initialized. Use it to extend the QR's functionalities, or for BRUTAL RICE. --- 4chan_x.user.js | 7 +++++-- script.coffee | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c6cc49402..990efc2ab 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1542,7 +1542,7 @@ } }, dialog: function() { - var fileInput, input, mimeTypes, spoiler, thread, threads, _i, _j, _len, _len2, _ref, _ref2; + var e, fileInput, input, mimeTypes, spoiler, thread, threads, _i, _j, _len, _len2, _ref, _ref2; qr.el = ui.dialog('qr', 'top:0;right:0;', '\
\ Quick Reply \ @@ -1630,7 +1630,10 @@ qr.cooldown.init(); qr.captcha.init(); qr.message.init(); - return $.add(d.body, qr.el); + $.add(d.body, qr.el); + e = d.createEvent('CustomEvent'); + e.initEvent('QRDialogCreation', true, false); + return qr.el.dispatchEvent(e); }, submit: function(e) { var captcha, captchas, challenge, err, file, m, post, reader, reply, response, threadID; diff --git a/script.coffee b/script.coffee index fbfcb1a8f..1f02c0736 100644 --- a/script.coffee +++ b/script.coffee @@ -1208,6 +1208,12 @@ qr = qr.message.init() $.add d.body, qr.el + # Create a custom event when the QR dialog is first initialized. + # Use it to extend the QR's functionalities, or for XTRM RICE. + e = d.createEvent 'CustomEvent' + e.initEvent 'QRDialogCreation', true, false + qr.el.dispatchEvent e + submit: (e) -> e?.preventDefault() if qr.cooldown.seconds