diff --git a/4chan_x.user.js b/4chan_x.user.js
index b2508c75e..d163d9eac 100644
--- a/4chan_x.user.js
+++ b/4chan_x.user.js
@@ -1269,19 +1269,24 @@
ta.setSelectionRange(i, i);
return ta.focus();
},
+ close: function() {
+ $.rm(QR.el);
+ return QR.el = null;
+ },
dialog: function(text) {
- var l, ta;
+ var el, l, ta;
if (text == null) {
text = '';
}
- QR.el = ui.dialog('qr', {
+ QR.el = el = ui.dialog('qr', {
top: '0',
left: '0'
}, " X
Quick Reply
");
- $.bind($('form', QR.el), 'submit', QR.submit);
- $.bind($('#recaptcha_response_field', QR.el), 'keydown', QR.keydown);
- $.append(d.body, QR.el);
- ta = $('textarea', QR.el);
+ $.bind($('.close', el), 'click', QR.close);
+ $.bind($('form', el), 'submit', QR.submit);
+ $.bind($('#recaptcha_response_field', el), 'keydown', QR.keydown);
+ $.append(d.body, el);
+ ta = $('textarea', el);
l = text.length;
ta.setSelectionRange(l, l);
return ta.focus();
@@ -1354,8 +1359,7 @@
if (data) {
return $.extend($('a.error', QR.el), JSON.parse(data));
} else {
- $.rm(QR.el);
- return QR.el = null;
+ return QR.close();
}
}
};
diff --git a/script.coffee b/script.coffee
index 2088da3be..f495e6af2 100644
--- a/script.coffee
+++ b/script.coffee
@@ -994,8 +994,11 @@ QR =
i = ss + text.length
ta.setSelectionRange i, i
ta.focus()
+ close: ->
+ $.rm QR.el
+ QR.el = null
dialog: (text='') ->
- QR.el = ui.dialog 'qr', top: '0', left: '0', "
+ QR.el = el = ui.dialog 'qr', top: '0', left: '0', "
X
Quick Reply
"
- $.bind $('form', QR.el), 'submit', QR.submit
- $.bind $('#recaptcha_response_field', QR.el), 'keydown', QR.keydown
- $.append d.body, QR.el
- ta = $ 'textarea', QR.el
+ $.bind $('.close', el), 'click', QR.close
+ $.bind $('form', el), 'submit', QR.submit
+ $.bind $('#recaptcha_response_field', el), 'keydown', QR.keydown
+ $.append d.body, el
+ ta = $ 'textarea', el
l = text.length
ta.setSelectionRange l, l
ta.focus()
@@ -1065,8 +1069,7 @@ QR =
if data
$.extend $('a.error', QR.el), JSON.parse data
else
- $.rm QR.el
- QR.el = null
+ QR.close()
qr =
# TODO