##// END OF EJS Templates
Quote many lines of one post
neko259 -
r1513:bf093d24 default
parent child Browse files
Show More
@@ -1,109 +1,117 b''
1 /*
1 /*
2 @licstart The following is the entire license notice for the
2 @licstart The following is the entire license notice for the
3 JavaScript code in this page.
3 JavaScript code in this page.
4
4
5
5
6 Copyright (C) 2013 neko259
6 Copyright (C) 2013 neko259
7
7
8 The JavaScript code in this page is free software: you can
8 The JavaScript code in this page is free software: you can
9 redistribute it and/or modify it under the terms of the GNU
9 redistribute it and/or modify it under the terms of the GNU
10 General Public License (GNU GPL) as published by the Free Software
10 General Public License (GNU GPL) as published by the Free Software
11 Foundation, either version 3 of the License, or (at your option)
11 Foundation, either version 3 of the License, or (at your option)
12 any later version. The code is distributed WITHOUT ANY WARRANTY;
12 any later version. The code is distributed WITHOUT ANY WARRANTY;
13 without even the implied warranty of MERCHANTABILITY or FITNESS
13 without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
14 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
15
15
16 As additional permission under GNU GPL version 3 section 7, you
16 As additional permission under GNU GPL version 3 section 7, you
17 may distribute non-source (e.g., minimized or compacted) forms of
17 may distribute non-source (e.g., minimized or compacted) forms of
18 that code without the copy of the GNU GPL normally required by
18 that code without the copy of the GNU GPL normally required by
19 section 4, provided you include this license notice and a URL
19 section 4, provided you include this license notice and a URL
20 through which recipients can access the Corresponding Source.
20 through which recipients can access the Corresponding Source.
21
21
22 @licend The above is the entire license notice
22 @licend The above is the entire license notice
23 for the JavaScript code in this page.
23 for the JavaScript code in this page.
24 */
24 */
25
25
26 var CLOSE_BUTTON = '#form-close-button';
26 var CLOSE_BUTTON = '#form-close-button';
27 var REPLY_TO_MSG = '.reply-to-message';
27 var REPLY_TO_MSG = '.reply-to-message';
28 var REPLY_TO_MSG_ID = '#reply-to-message-id';
28 var REPLY_TO_MSG_ID = '#reply-to-message-id';
29
29
30 var $html = $("html, body");
30 var $html = $("html, body");
31
31
32 function moveCaretToEnd(el) {
32 function moveCaretToEnd(el) {
33 if (typeof el.selectionStart == "number") {
33 if (typeof el.selectionStart == "number") {
34 el.selectionStart = el.selectionEnd = el.value.length;
34 el.selectionStart = el.selectionEnd = el.value.length;
35 } else if (typeof el.createTextRange != "undefined") {
35 } else if (typeof el.createTextRange != "undefined") {
36 el.focus();
36 el.focus();
37 var range = el.createTextRange();
37 var range = el.createTextRange();
38 range.collapse(false);
38 range.collapse(false);
39 range.select();
39 range.select();
40 }
40 }
41 }
41 }
42
42
43 function getForm() {
43 function getForm() {
44 return $('.post-form-w');
44 return $('.post-form-w');
45 }
45 }
46
46
47 function resetFormPosition() {
47 function resetFormPosition() {
48 var form = getForm();
48 var form = getForm();
49 form.insertAfter($('.thread'));
49 form.insertAfter($('.thread'));
50
50
51 $(CLOSE_BUTTON).hide();
51 $(CLOSE_BUTTON).hide();
52 $(REPLY_TO_MSG).hide();
52 $(REPLY_TO_MSG).hide();
53 }
53 }
54
54
55 function showFormAfter(blockToInsertAfter) {
55 function showFormAfter(blockToInsertAfter) {
56 var form = getForm();
56 var form = getForm();
57 form.insertAfter(blockToInsertAfter);
57 form.insertAfter(blockToInsertAfter);
58
58
59 $(CLOSE_BUTTON).show();
59 $(CLOSE_BUTTON).show();
60 form.show();
60 form.show();
61 $(REPLY_TO_MSG_ID).text(blockToInsertAfter.attr('id'));
61 $(REPLY_TO_MSG_ID).text(blockToInsertAfter.attr('id'));
62 $(REPLY_TO_MSG).show();
62 $(REPLY_TO_MSG).show();
63 }
63 }
64
64
65 function addQuickReply(postId) {
65 function addQuickReply(postId) {
66 // If we click "reply" on the same post, it means "cancel"
66 // If we click "reply" on the same post, it means "cancel"
67 if (getForm().prev().attr('id') == postId) {
67 if (getForm().prev().attr('id') == postId) {
68 resetFormPosition();
68 resetFormPosition();
69 } else {
69 } else {
70 var postLinkRaw = '[post]' + postId + '[/post]'
71
70
72 var textToAdd = '';
73 var blockToInsert = null;
71 var blockToInsert = null;
74
72
75 var textAreaJq = $('textarea');
76
73
77 if (postId != null) {
74 if (postId != null) {
78 var post = $('#' + postId);
75 var post = $('#' + postId);
79
76
80 // If this is not OP, add reflink to the post. If there already is
81 // the same reflink, don't add it again.
82 if (!post.is(':first-child') && textAreaJq.val().indexOf(postLinkRaw) < 0) {
83 textToAdd += postLinkRaw + '\n';
84 }
85
86 blockToInsert = post;
77 blockToInsert = post;
87 } else {
78 } else {
88 blockToInsert = $('.thread');
79 blockToInsert = $('.thread');
89 }
80 }
81 showFormAfter(blockToInsert);
82 }
83 }
90
84
91 var selection = window.getSelection().toString();
85 function addQuickQuote(postId) {
92 if (selection.length > 0) {
86 if (getForm().prev().attr('id') != postId) {
93 textToAdd += '[quote]' + selection + '[/quote]\n';
87 addQuickReply(postId);
94 }
88 }
89
90 var textToAdd = '';
91 var textAreaJq = $('textarea');
92 var postLinkRaw = '[post]' + postId + '[/post]'
93 if (postId != null) {
94 var post = $('#' + postId);
95
95
96 textAreaJq.val(textAreaJq.val()+ textToAdd);
96 // If this is not OP, add reflink to the post. If there already is
97
97 // the same reflink, don't add it again.
98 showFormAfter(blockToInsert);
98 if (!post.is(':first-child') && textAreaJq.val().indexOf(postLinkRaw) < 0) {
99 textToAdd += postLinkRaw + '\n';
100 }
101 }
102 var selection = window.getSelection().toString();
103 if (selection.length > 0) {
104 textToAdd += '[quote]' + selection + '[/quote]\n';
105 }
99
106
100 textAreaJq.focus();
107 textAreaJq.val(textAreaJq.val()+ textToAdd);
101 var textarea = document.getElementsByTagName('textarea')[0];
108
102 moveCaretToEnd(textarea);
109 textAreaJq.focus();
103 }
110 var textarea = document.getElementsByTagName('textarea')[0];
111 moveCaretToEnd(textarea);
104 }
112 }
105
113
106 function scrollToBottom() {
114 function scrollToBottom() {
107 $html.animate({scrollTop: $html.height()}, "fast");
115 $html.animate({scrollTop: $html.height()}, "fast");
108 }
116 }
109
117
@@ -1,105 +1,106 b''
1 {% load i18n %}
1 {% load i18n %}
2 {% load board %}
2 {% load board %}
3
3
4 {% get_current_language as LANGUAGE_CODE %}
4 {% get_current_language as LANGUAGE_CODE %}
5
5
6 <div class="{{ css_class }}" id="{{ post.id }}" data-uid="{{ post.uid }}" {% if tree_depth %}style="margin-left: {{ tree_depth }}em;"{% endif %}>
6 <div class="{{ css_class }}" id="{{ post.id }}" data-uid="{{ post.uid }}" {% if tree_depth %}style="margin-left: {{ tree_depth }}em;"{% endif %}>
7 <div class="post-info">
7 <div class="post-info">
8 <a class="post_id" href="{{ post.get_absolute_url }}">#{{ post.get_absolute_id }}</a>
8 <a class="post_id" href="{{ post.get_absolute_url }}">#{{ post.get_absolute_id }}</a>
9 <span class="title">{{ post.title }}</span>
9 <span class="title">{{ post.title }}</span>
10 <span class="pub_time"><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time }}</time></span>
10 <span class="pub_time"><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time }}</time></span>
11 {% if post.tripcode %}
11 {% if post.tripcode %}
12 /
12 /
13 {% with tripcode=post.get_tripcode %}
13 {% with tripcode=post.get_tripcode %}
14 <a href="{% url 'feed' %}?tripcode={{ tripcode.get_full_text }}"
14 <a href="{% url 'feed' %}?tripcode={{ tripcode.get_full_text }}"
15 class="tripcode" title="{{ tripcode.get_full_text }}"
15 class="tripcode" title="{{ tripcode.get_full_text }}"
16 style="border: solid 2px #{{ tripcode.get_color }}; border-left: solid 1ex #{{ tripcode.get_color }};">{{ tripcode.get_short_text }}</a>
16 style="border: solid 2px #{{ tripcode.get_color }}; border-left: solid 1ex #{{ tripcode.get_color }};">{{ tripcode.get_short_text }}</a>
17 {% endwith %}
17 {% endwith %}
18 {% endif %}
18 {% endif %}
19 {% comment %}
19 {% comment %}
20 Thread death time needs to be shown only if the thread is alredy archived
20 Thread death time needs to be shown only if the thread is alredy archived
21 and this is an opening post (thread death time) or a post for popup
21 and this is an opening post (thread death time) or a post for popup
22 (we don't see OP here so we show the death time in the post itself).
22 (we don't see OP here so we show the death time in the post itself).
23 {% endcomment %}
23 {% endcomment %}
24 {% if thread.is_archived %}
24 {% if thread.is_archived %}
25 {% if is_opening %}
25 {% if is_opening %}
26 β€” <time datetime="{{ thread.bump_time|date:'c' }}">{{ thread.bump_time }}</time>
26 β€” <time datetime="{{ thread.bump_time|date:'c' }}">{{ thread.bump_time }}</time>
27 {% endif %}
27 {% endif %}
28 {% endif %}
28 {% endif %}
29 {% if is_opening %}
29 {% if is_opening %}
30 {% if need_open_link %}
30 {% if need_open_link %}
31 {% if thread.is_archived %}
31 {% if thread.is_archived %}
32 <a class="link" href="{% url 'thread' post.id %}">{% trans "Open" %}</a>
32 <a class="link" href="{% url 'thread' post.id %}">{% trans "Open" %}</a>
33 {% else %}
33 {% else %}
34 <a class="link" href="{% url 'thread' post.id %}#form">{% trans "Reply" %}</a>
34 <a class="link" href="{% url 'thread' post.id %}#form">{% trans "Reply" %}</a>
35 {% endif %}
35 {% endif %}
36 {% endif %}
36 {% endif %}
37 {% else %}
37 {% else %}
38 {% if need_op_data %}
38 {% if need_op_data %}
39 {% with thread.get_opening_post as op %}
39 {% with thread.get_opening_post as op %}
40 {% trans " in " %}{{ op.get_link_view|safe }} <span class="title">{{ op.get_title_or_text }}</span>
40 {% trans " in " %}{{ op.get_link_view|safe }} <span class="title">{{ op.get_title_or_text }}</span>
41 {% endwith %}
41 {% endwith %}
42 {% endif %}
42 {% endif %}
43 {% endif %}
43 {% endif %}
44 {% if reply_link and not thread.is_archived %}
44 {% if reply_link and not thread.is_archived %}
45 <a href="#form" onclick="addQuickReply('{{ post.id }}'); return false;">{% trans 'Reply' %}</a>
45 <a href="#form" onclick="addQuickReply('{{ post.id }}'); return false;">{% trans 'Reply' %}</a> |
46 <a href="#form" onclick="addQuickQuote('{{ post.id }}'); return false;">{% trans 'Quote' %}</a>
46 {% endif %}
47 {% endif %}
47
48
48 {% if perms.boards.change_post or perms.boards.delete_post or perms.boards.change_thread or perms_boards.delete_thread %}
49 {% if perms.boards.change_post or perms.boards.delete_post or perms.boards.change_thread or perms_boards.delete_thread %}
49 <span class="moderator_info">
50 <span class="moderator_info">
50 {% if perms.boards.change_post or perms.boards.delete_post %}
51 {% if perms.boards.change_post or perms.boards.delete_post %}
51 | <a href="{% url 'admin:boards_post_change' post.id %}">{% trans 'Edit' %}</a>
52 | <a href="{% url 'admin:boards_post_change' post.id %}">{% trans 'Edit' %}</a>
52 {% endif %}
53 {% endif %}
53 {% if perms.boards.change_thread or perms_boards.delete_thread %}
54 {% if perms.boards.change_thread or perms_boards.delete_thread %}
54 {% if is_opening %}
55 {% if is_opening %}
55 | <a href="{% url 'admin:boards_thread_change' thread.id %}">{% trans 'Edit thread' %}</a>
56 | <a href="{% url 'admin:boards_thread_change' thread.id %}">{% trans 'Edit thread' %}</a>
56 {% endif %}
57 {% endif %}
57 {% endif %}
58 {% endif %}
58 </form>
59 </form>
59 </span>
60 </span>
60 {% endif %}
61 {% endif %}
61 </div>
62 </div>
62 {% comment %}
63 {% comment %}
63 Post images. Currently only 1 image can be posted and shown, but post model
64 Post images. Currently only 1 image can be posted and shown, but post model
64 supports multiple.
65 supports multiple.
65 {% endcomment %}
66 {% endcomment %}
66 {% for image in post.images.all %}
67 {% for image in post.images.all %}
67 {{ image.get_view|safe }}
68 {{ image.get_view|safe }}
68 {% endfor %}
69 {% endfor %}
69 {% for file in post.attachments.all %}
70 {% for file in post.attachments.all %}
70 {{ file.get_view|safe }}
71 {{ file.get_view|safe }}
71 {% endfor %}
72 {% endfor %}
72 {% comment %}
73 {% comment %}
73 Post message (text)
74 Post message (text)
74 {% endcomment %}
75 {% endcomment %}
75 <div class="message">
76 <div class="message">
76 {% autoescape off %}
77 {% autoescape off %}
77 {% if truncated %}
78 {% if truncated %}
78 {{ post.get_text|truncatewords_html:50 }}
79 {{ post.get_text|truncatewords_html:50 }}
79 {% else %}
80 {% else %}
80 {{ post.get_text }}
81 {{ post.get_text }}
81 {% endif %}
82 {% endif %}
82 {% endautoescape %}
83 {% endautoescape %}
83 </div>
84 </div>
84 {% if post.is_referenced %}
85 {% if post.is_referenced %}
85 {% if not mode_tree %}
86 {% if not mode_tree %}
86 <div class="refmap">
87 <div class="refmap">
87 {% trans "Replies" %}: {{ post.refmap|safe }}
88 {% trans "Replies" %}: {{ post.refmap|safe }}
88 </div>
89 </div>
89 {% endif %}
90 {% endif %}
90 {% endif %}
91 {% endif %}
91 {% comment %}
92 {% comment %}
92 Thread metadata: counters, tags etc
93 Thread metadata: counters, tags etc
93 {% endcomment %}
94 {% endcomment %}
94 {% if is_opening %}
95 {% if is_opening %}
95 <div class="metadata">
96 <div class="metadata">
96 {% if is_opening and need_open_link %}
97 {% if is_opening and need_open_link %}
97 {% blocktrans count count=thread.get_reply_count %}{{ count }} message{% plural %}{{ count }} messages{% endblocktrans %},
98 {% blocktrans count count=thread.get_reply_count %}{{ count }} message{% plural %}{{ count }} messages{% endblocktrans %},
98 {% blocktrans count count=thread.get_images_count %}{{ count }} image{% plural %}{{ count }} images{% endblocktrans %}.
99 {% blocktrans count count=thread.get_images_count %}{{ count }} image{% plural %}{{ count }} images{% endblocktrans %}.
99 {% endif %}
100 {% endif %}
100 <span class="tags">
101 <span class="tags">
101 {{ thread.get_tag_url_list|safe }}
102 {{ thread.get_tag_url_list|safe }}
102 </span>
103 </span>
103 </div>
104 </div>
104 {% endif %}
105 {% endif %}
105 </div>
106 </div>
General Comments 0
You need to be logged in to leave comments. Login now