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

View File

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

View File

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