Don't open the QR in closed threads. Ideally I'd make the QR independant of the DOM but it's impossible without captcha and known board configs.

This commit is contained in:
Nicolas Stepien 2013-02-24 16:40:01 +01:00
parent 491721e049
commit 43530b0302
3 changed files with 32 additions and 14 deletions

View File

@ -2832,7 +2832,7 @@
return key;
},
qr: function(thread, quote) {
if (!Conf['Quick Reply']) {
if (!(Conf['Quick Reply'] && QR.postingIsEnable)) {
return;
}
QR.open();
@ -5641,7 +5641,6 @@
QR = {
init: function() {
var link;
if (g.VIEW === 'catalog' || !Conf['Quick Reply']) {
return;
}
@ -5650,6 +5649,18 @@
if (Conf['Hide Original Post Form']) {
$.addClass(doc, 'hide-original-post-form');
}
$.on(d, '4chanXInitFinished', this.initReady);
return Post.prototype.callbacks.push({
name: 'Quick Reply',
cb: this.node
});
},
initReady: function() {
var link;
QR.postingIsEnable = !!$.id('postForm');
if (!QR.postingIsEnable) {
return;
}
link = $.el('a', {
className: 'qr-shortcut',
textContent: 'Quick Reply',
@ -5669,9 +5680,6 @@
$.on(d, 'dragover', QR.dragOver);
$.on(d, 'drop', QR.dropFile);
$.on(d, 'dragstart dragend', QR.drag);
if (Conf['Persistent QR']) {
$.on(d, '4chanXInitFinished', QR.persist);
}
$.on(d, 'ThreadUpdate', function() {
if (g.DEAD) {
return QR.abort();
@ -5679,10 +5687,9 @@
return QR.status();
}
});
return Post.prototype.callbacks.push({
name: 'Quick Reply',
cb: this.node
});
if (Conf['Persistent QR']) {
return QR.persist();
}
},
node: function() {
return $.on($('a[title="Quote this post"]', this.nodes.info), 'click', QR.quote);
@ -5922,6 +5929,9 @@
if (e != null) {
e.preventDefault();
}
if (!QR.postingIsEnable) {
return;
}
text = "";
sel = d.getSelection();
selectionRoot = $.x('ancestor::div[contains(@class,"postContainer")][1]', sel.anchorNode);

View File

@ -1554,7 +1554,7 @@ Keybinds =
key
qr: (thread, quote) ->
return unless Conf['Quick Reply']
return unless Conf['Quick Reply'] and QR.postingIsEnable
QR.open()
if quote
QR.quote.call $ 'input', $('.post.highlight', thread) or thread

View File

@ -8,6 +8,16 @@ QR =
if Conf['Hide Original Post Form']
$.addClass doc, 'hide-original-post-form'
$.on d, '4chanXInitFinished', @initReady
Post::callbacks.push
name: 'Quick Reply'
cb: @node
initReady: ->
QR.postingIsEnable = !!$.id 'postForm'
return unless QR.postingIsEnable
link = $.el 'a',
className: 'qr-shortcut'
textContent: 'Quick Reply'
@ -25,16 +35,13 @@ QR =
$.on d, 'dragover', QR.dragOver
$.on d, 'drop', QR.dropFile
$.on d, 'dragstart dragend', QR.drag
$.on d, '4chanXInitFinished', QR.persist if Conf['Persistent QR']
$.on d, 'ThreadUpdate', ->
if g.DEAD
QR.abort()
else
QR.status()
Post::callbacks.push
name: 'Quick Reply'
cb: @node
QR.persist() if Conf['Persistent QR']
node: ->
$.on $('a[title="Quote this post"]', @nodes.info), 'click', QR.quote
@ -229,6 +236,7 @@ QR =
quote: (e) ->
e?.preventDefault()
return unless QR.postingIsEnable
text = ""
sel = d.getSelection()