Show More
@@ -91,3 +91,7 b' textarea, input {' | |||||
91 | background: none; |
|
91 | background: none; | |
92 | font-size: inherit; |
|
92 | font-size: inherit; | |
93 | } |
|
93 | } | |
|
94 | ||||
|
95 | #form-close-button { | |||
|
96 | display: none; | |||
|
97 | } |
@@ -23,6 +23,7 b'' | |||||
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 $html = $("html, body"); |
|
27 | var $html = $("html, body"); | |
27 |
|
28 | |||
28 | function moveCaretToEnd(el) { |
|
29 | function moveCaretToEnd(el) { | |
@@ -43,46 +44,60 b' function getForm() {' | |||||
43 | function resetFormPosition() { |
|
44 | function resetFormPosition() { | |
44 | var form = getForm(); |
|
45 | var form = getForm(); | |
45 | form.insertAfter($('.thread')); |
|
46 | form.insertAfter($('.thread')); | |
|
47 | ||||
|
48 | $(CLOSE_BUTTON).hide(); | |||
|
49 | } | |||
|
50 | ||||
|
51 | function showFormAfter(blockToInsertAfter) { | |||
|
52 | var form = getForm(); | |||
|
53 | form.insertAfter(blockToInsertAfter); | |||
|
54 | ||||
|
55 | $(CLOSE_BUTTON).show(); | |||
|
56 | form.show(); | |||
46 | } |
|
57 | } | |
47 |
|
58 | |||
48 | function addQuickReply(postId) { |
|
59 | function addQuickReply(postId) { | |
49 | var postLinkRaw = '[post]' + postId + '[/post]' |
|
60 | // If we click "reply" on the same post, it means "cancel" | |
|
61 | if (getForm().prev().attr('id') == postId) { | |||
|
62 | resetFormPosition(); | |||
|
63 | } else { | |||
|
64 | var postLinkRaw = '[post]' + postId + '[/post]' | |||
50 |
|
65 | |||
51 | var textToAdd = ''; |
|
66 | var textToAdd = ''; | |
52 | var blockToInsert = null; |
|
67 | var blockToInsert = null; | |
53 |
|
68 | |||
54 | var textAreaJq = $('textarea'); |
|
69 | var textAreaJq = $('textarea'); | |
55 |
|
70 | |||
56 | if (postId != null) { |
|
71 | if (postId != null) { | |
57 | var post = $('#' + postId); |
|
72 | var post = $('#' + postId); | |
58 |
|
73 | |||
59 | // If this is not OP, add reflink to the post. If there already is |
|
74 | // If this is not OP, add reflink to the post. If there already is | |
60 | // the same reflink, don't add it again. |
|
75 | // the same reflink, don't add it again. | |
61 | if (!post.is(':first-child') && textAreaJq.val().indexOf(postLinkRaw) < 0) { |
|
76 | if (!post.is(':first-child') && textAreaJq.val().indexOf(postLinkRaw) < 0) { | |
62 | textToAdd += postLinkRaw + '\n'; |
|
77 | textToAdd += postLinkRaw + '\n'; | |
|
78 | } | |||
|
79 | ||||
|
80 | blockToInsert = post; | |||
|
81 | } else { | |||
|
82 | blockToInsert = $('.thread'); | |||
63 | } |
|
83 | } | |
64 |
|
84 | |||
65 | blockToInsert = post; |
|
85 | var selection = window.getSelection().toString(); | |
66 | } else { |
|
86 | if (selection.length > 0) { | |
67 | blockToInsert = $('.thread'); |
|
87 | textToAdd += '[quote]' + selection + '[/quote]\n'; | |
68 | } |
|
88 | } | |
69 |
|
89 | |||
70 | var selection = window.getSelection().toString(); |
|
90 | textAreaJq.val(textAreaJq.val()+ textToAdd); | |
71 | if (selection.length > 0) { |
|
|||
72 | textToAdd += '[quote]' + selection + '[/quote]\n'; |
|
|||
73 | } |
|
|||
74 |
|
91 | |||
75 | textAreaJq.val(textAreaJq.val()+ textToAdd); |
|
92 | showFormAfter(blockToInsert); | |
76 |
|
93 | |||
77 | var form = getForm(); |
|
94 | textAreaJq.focus(); | |
78 | form.insertAfter(blockToInsert); |
|
95 | var textarea = document.getElementsByTagName('textarea')[0]; | |
79 | form.show(); |
|
96 | moveCaretToEnd(textarea); | |
80 |
|
97 | } | ||
81 | textAreaJq.focus(); |
|
|||
82 | var textarea = document.getElementsByTagName('textarea')[0]; |
|
|||
83 | moveCaretToEnd(textarea); |
|
|||
84 | } |
|
98 | } | |
85 |
|
99 | |||
86 | function scrollToBottom() { |
|
100 | function scrollToBottom() { | |
87 | $html.animate({scrollTop: $html.height()}, "fast"); |
|
101 | $html.animate({scrollTop: $html.height()}, "fast"); | |
88 | } |
|
102 | } | |
|
103 |
@@ -46,7 +46,7 b'' | |||||
46 | </div> |
|
46 | </div> | |
47 | <div><a href="{% url "staticpage" name="help" %}"> |
|
47 | <div><a href="{% url "staticpage" name="help" %}"> | |
48 | {% trans 'Text syntax' %}</a></div> |
|
48 | {% trans 'Text syntax' %}</a></div> | |
49 | <div><a href="#" onClick="resetFormPosition(); return false;">{% trans 'Close form' %}</a></div> |
|
49 | <div><a id="form-close-button" href="#" onClick="resetFormPosition(); return false;">{% trans 'Close form' %}</a></div> | |
50 | </div> |
|
50 | </div> | |
51 | </div> |
|
51 | </div> | |
52 |
|
52 |
General Comments 0
You need to be logged in to leave comments.
Login now