This commit is contained in:
Nicolas Stepien 2013-02-13 16:57:32 +01:00
parent c2715231a3
commit 859c5db1f0
3 changed files with 29 additions and 17 deletions

View File

@ -4045,23 +4045,25 @@
}
},
quote: function(e) {
var caretPos, post, range, s, sel, selectionRoot, ta, text;
var caretPos, post, range, s, sel, selectionRoot, ta, text, thread;
if (e != null) {
e.preventDefault();
}
QR.open();
ta = $('textarea', QR.el);
if (QR.threadSelector && !ta.value && g.BOARD.ID !== 'f') {
QR.threadSelector.value = $.x('ancestor::div[parent::div[@class="board"]]', this).id.slice(1);
}
post = Get.postFromRoot($.x('ancestor-or-self::div[contains(@class,"postContainer")][1]', this));
text = ">>" + post + "\n";
text = "";
sel = d.getSelection();
selectionRoot = $.x('ancestor-or-self::div[contains(@class,"postContainer")][1]', sel.anchorNode);
selectionRoot = $.x('ancestor::div[contains(@class,"postContainer")][1]', sel.anchorNode);
post = Get.postFromRoot($.x('ancestor::div[contains(@class,"postContainer")][1]', this));
thread = g.BOARD.posts[Get.contextFromLink(this).thread];
if ((s = sel.toString().trim()) && post.nodes.root === selectionRoot) {
s = s.replace(/\n/g, '\n>');
text += ">" + s + "\n";
}
text = !text && post === thread && (!QR.el || QR.el.hidden) ? "" : ">>" + post + "\n" + text;
QR.open();
ta = $('textarea', QR.el);
if (QR.threadSelector && !ta.value && g.BOARD.ID !== 'f') {
QR.threadSelector.value = thread.ID;
}
caretPos = ta.selectionStart;
ta.value = ta.value.slice(0, caretPos) + text + ta.value.slice(ta.selectionEnd);
range = caretPos + text.length;

View File

@ -10,6 +10,7 @@ alpha
QR changes:
Creating threads outside of the index is now possible.
Selection-to-quote also applies to selected text inside the post, not just inside the comment.
Quoting the OP will not insert the >>opnumber anymore unless the QR was already opened.
Added touch and multi-touch support for dragging windows.
The Thread Updater will pause when offline, and resume when online.
Added Thread & Post Hiding in the Menu, with individual settings.

View File

@ -219,21 +219,30 @@ QR =
quote: (e) ->
e?.preventDefault()
QR.open()
ta = $ 'textarea', QR.el
if QR.threadSelector and !ta.value and g.BOARD.ID isnt 'f'
QR.threadSelector.value = $.x('ancestor::div[parent::div[@class="board"]]', @).id[1..]
# Make sure we get the correct number, even with XXX censors
post = Get.postFromRoot $.x 'ancestor-or-self::div[contains(@class,"postContainer")][1]', @
text = ">>#{post}\n"
text = ""
sel = d.getSelection()
selectionRoot = $.x 'ancestor-or-self::div[contains(@class,"postContainer")][1]', sel.anchorNode
selectionRoot = $.x 'ancestor::div[contains(@class,"postContainer")][1]', sel.anchorNode
post = Get.postFromRoot $.x 'ancestor::div[contains(@class,"postContainer")][1]', @
thread = g.BOARD.posts[Get.contextFromLink(@).thread]
if (s = sel.toString().trim()) and post.nodes.root is selectionRoot
# XXX Opera doesn't retain `\n`s?
s = s.replace /\n/g, '\n>'
text += ">#{s}\n"
text = if !text and post is thread and (!QR.el or QR.el.hidden)
# Don't quote the OP unless the QR was already opened once.
""
else
">>#{post}\n#{text}"
QR.open()
ta = $ 'textarea', QR.el
if QR.threadSelector and !ta.value and g.BOARD.ID isnt 'f'
QR.threadSelector.value = thread.ID
# Make sure we get the correct number, even with XXX censors
caretPos = ta.selectionStart
# Replace selection for text.
ta.value = ta.value[...caretPos] + text + ta.value[ta.selectionEnd..]