##// END OF EJS Templates
Reset form to the end of thread instead of closing it
neko259 -
r1058:30602d98 default
parent child Browse files
Show More
@@ -1,85 +1,85 b''
1 1 /*
2 2 @licstart The following is the entire license notice for the
3 3 JavaScript code in this page.
4 4
5 5
6 6 Copyright (C) 2013 neko259
7 7
8 8 The JavaScript code in this page is free software: you can
9 9 redistribute it and/or modify it under the terms of the GNU
10 10 General Public License (GNU GPL) as published by the Free Software
11 11 Foundation, either version 3 of the License, or (at your option)
12 12 any later version. The code is distributed WITHOUT ANY WARRANTY;
13 13 without even the implied warranty of MERCHANTABILITY or FITNESS
14 14 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
15 15
16 16 As additional permission under GNU GPL version 3 section 7, you
17 17 may distribute non-source (e.g., minimized or compacted) forms of
18 18 that code without the copy of the GNU GPL normally required by
19 19 section 4, provided you include this license notice and a URL
20 20 through which recipients can access the Corresponding Source.
21 21
22 22 @licend The above is the entire license notice
23 23 for the JavaScript code in this page.
24 24 */
25 25
26 26 var $html = $("html, body");
27 27
28 28 function moveCaretToEnd(el) {
29 29 if (typeof el.selectionStart == "number") {
30 30 el.selectionStart = el.selectionEnd = el.value.length;
31 31 } else if (typeof el.createTextRange != "undefined") {
32 32 el.focus();
33 33 var range = el.createTextRange();
34 34 range.collapse(false);
35 35 range.select();
36 36 }
37 37 }
38 38
39 39 function getForm() {
40 40 return $('.post-form-w');
41 41 }
42 42
43 43 function closeForm() {
44 44 var form = getForm();
45 form.hide();
45 //form.hide();
46 46 form.insertAfter($('.thread'));
47 47 }
48 48
49 49 function addQuickReply(postId) {
50 50 var textToAdd = '';
51 51 var blockToInsert = null;
52 52
53 53 if (postId != null) {
54 54 var post = $('#' + postId);
55 55
56 56 // If this is not OP, add reflink to the post
57 57 if (!post.is(':first-child')) {
58 58 textToAdd += '[post]' + postId + '[/post]\n';
59 59 }
60 60
61 61 blockToInsert = post;
62 62 } else {
63 63 blockToInsert = $('.thread');
64 64 }
65 65
66 66 var selection = window.getSelection().toString();
67 67 if (selection.length > 0) {
68 68 textToAdd += '[quote]' + selection + '[/quote]\n';
69 69 }
70 70
71 71 var textAreaId = 'textarea';
72 72 $(textAreaId).val($(textAreaId).val()+ textToAdd);
73 73
74 74 var form = getForm();
75 75 form.insertAfter(blockToInsert);
76 76 form.show();
77 77
78 78 var textarea = document.getElementsByTagName('textarea')[0];
79 79 $(textAreaId).focus();
80 80 moveCaretToEnd(textarea);
81 81 }
82 82
83 83 function scrollToBottom() {
84 84 $html.animate({scrollTop: $html.height()}, "fast");
85 85 }
@@ -1,91 +1,95 b''
1 1 {% load i18n %}
2 2 {% load board %}
3 3 {% load cache %}
4 4
5 5 {% get_current_language as LANGUAGE_CODE %}
6 6
7 7 {% if thread.archived %}
8 8 <div class="post archive_post" id="{{ post.id }}">
9 9 {% elif bumpable %}
10 10 <div class="post" id="{{ post.id }}">
11 11 {% else %}
12 12 <div class="post dead_post" id="{{ post.id }}">
13 13 {% endif %}
14 14
15 15 <div class="post-info">
16 16 <a class="post_id" href="{{ post.get_url }}">({{ post.get_absolute_id }})</a>
17 17 <span class="title">{{ post.title }}</span>
18 18 <span class="pub_time"><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time|date:'r' }}</time></span>
19 19 {% comment %}
20 20 Thread death time needs to be shown only if the thread is alredy archived
21 21 and this is an opening post (thread death time) or a post for popup
22 22 (we don't see OP here so we show the death time in the post itself).
23 23 {% endcomment %}
24 24 {% if thread.archived %}
25 25 {% if is_opening %}
26 26 β€” <time datetime="{{ thread.bump_time|date:'c' }}">{{ thread.bump_time|date:'r' }}</time>
27 27 {% endif %}
28 28 {% endif %}
29 29 {% if is_opening and need_open_link %}
30 <a class="link" href="{% url 'thread' post.id %}">{% trans "Open" %}</a>
30 {% if thread.archived %}
31 <a class="link" href="{% url 'thread' post.id %}">{% trans "Open" %}</a>
32 {% else %}
33 <a class="link" href="{% url 'thread' post.id %}#form">{% trans "Reply" %}</a>
34 {% endif %}
31 35 {% endif %}
32 36 {% if reply_link and not thread.archived %}
33 37 <a href="#form" onclick="addQuickReply('{{ post.id }}'); return false;">{% trans 'Reply' %}</a>
34 38 {% endif %}
35 39
36 40 {% if moderator %}
37 41 <span class="moderator_info">
38 42 <a href="{% url 'admin:boards_post_change' post.id %}">{% trans 'Edit' %}</a>
39 43 {% if is_opening %}
40 44 | <a href="{% url 'admin:boards_thread_change' thread.id %}">{% trans 'Edit thread' %}</a>
41 45 {% endif %}
42 46 </span>
43 47 {% endif %}
44 48 </div>
45 49 {% comment %}
46 50 Post images. Currently only 1 image can be posted and shown, but post model
47 51 supports multiple.
48 52 {% endcomment %}
49 53 {% if post.images.exists %}
50 54 {% with post.images.all.0 as image %}
51 55 {% autoescape off %}
52 56 {{ image.get_view }}
53 57 {% endautoescape %}
54 58 {% endwith %}
55 59 {% endif %}
56 60 {% comment %}
57 61 Post message (text)
58 62 {% endcomment %}
59 63 <div class="message">
60 64 {% autoescape off %}
61 65 {% if truncated %}
62 66 {{ post.get_text|truncatewords_html:50 }}
63 67 {% else %}
64 68 {{ post.get_text }}
65 69 {% endif %}
66 70 {% endautoescape %}
67 71 {% if post.is_referenced %}
68 72 <div class="refmap">
69 73 {% autoescape off %}
70 74 {% trans "Replies" %}: {{ post.refmap }}
71 75 {% endautoescape %}
72 76 </div>
73 77 {% endif %}
74 78 </div>
75 79 {% comment %}
76 80 Thread metadata: counters, tags etc
77 81 {% endcomment %}
78 82 {% if is_opening %}
79 83 <div class="metadata">
80 84 {% if is_opening and need_open_link %}
81 85 {{ thread.get_reply_count }} {% trans 'messages' %},
82 86 {{ thread.get_images_count }} {% trans 'images' %}.
83 87 {% endif %}
84 88 <span class="tags">
85 89 {% autoescape off %}
86 90 {{ thread.get_tag_url_list }}
87 91 {% endautoescape %}
88 92 </span>
89 93 </div>
90 94 {% endif %}
91 95 </div>
@@ -1,68 +1,68 b''
1 1 {% extends "boards/thread.html" %}
2 2
3 3 {% load i18n %}
4 4 {% load cache %}
5 5 {% load static from staticfiles %}
6 6 {% load board %}
7 7
8 8 {% block content %}
9 9 {% get_current_language as LANGUAGE_CODE %}
10 10
11 11 {% cache 600 thread_view thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
12 12
13 13 <div class="image-mode-tab">
14 14 <a class="current_mode" href="{% url 'thread' opening_post.id %}">{% trans 'Normal mode' %}</a>,
15 15 <a href="{% url 'thread_gallery' opening_post.id %}">{% trans 'Gallery mode' %}</a>
16 16 </div>
17 17
18 18 {% if bumpable and thread.has_post_limit %}
19 19 <div class="bar-bg">
20 20 <div class="bar-value" style="width:{{ bumplimit_progress }}%" id="bumplimit_progress">
21 21 </div>
22 22 <div class="bar-text">
23 23 <span id="left_to_limit">{{ posts_left }}</span> {% trans 'posts to bumplimit' %}
24 24 </div>
25 25 </div>
26 26 {% endif %}
27 27
28 28 <div class="thread">
29 29 {% for post in thread.get_replies %}
30 30 {% post_view post moderator=moderator reply_link=True %}
31 31 {% endfor %}
32 32 </div>
33 33
34 34 {% if not thread.archived %}
35 35 <div class="post-form-w">
36 36 <script src="{% static 'js/panel.js' %}"></script>
37 37 <div class="form-title">{% trans "Reply to thread" %} #{{ opening_post.id }}</div>
38 38 <div class="post-form" id="compact-form">
39 39 <div class="swappable-form-full">
40 40 <form enctype="multipart/form-data" method="post" id="form">{% csrf_token %}
41 41 <div class="compact-form-text"></div>
42 42 {{ form.as_div }}
43 43 <div class="form-submit">
44 44 <input type="submit" value="{% trans "Post" %}"/>
45 45 </div>
46 46 (ctrl-enter)
47 47 </form>
48 48 </div>
49 49 <div><a href="{% url "staticpage" name="help" %}">
50 50 {% trans 'Text syntax' %}</a></div>
51 <div><a href="#" onClick="getForm().hide(); return false;">{% trans 'Close form' %}</a></div>
51 <div><a href="#" onClick="closeForm(); return false;">{% trans 'Close form' %}</a></div>
52 52 </div>
53 53 </div>
54 54
55 55 <script src="{% static 'js/jquery.form.min.js' %}"></script>
56 56 {% endif %}
57 57
58 58 <script src="{% static 'js/form.js' %}"></script>
59 59 <script src="{% static 'js/thread.js' %}"></script>
60 60 <script src="{% static 'js/thread_update.js' %}"></script>
61 61 <script src="{% static 'js/3party/centrifuge.js' %}"></script>
62 62
63 63 {% endcache %}
64 64 {% endblock %}
65 65
66 66 {% block thread_meta_panel %}
67 67 <button id="autoupdate">{% trans 'Update' %}</button>
68 68 {% endblock %}
General Comments 0
You need to be logged in to leave comments. Login now