Show More
@@ -1,84 +1,88 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 $html = $("html, body"); |
|
26 | var $html = $("html, body"); | |
27 |
|
27 | |||
28 | function moveCaretToEnd(el) { |
|
28 | function moveCaretToEnd(el) { | |
29 | if (typeof el.selectionStart == "number") { |
|
29 | if (typeof el.selectionStart == "number") { | |
30 | el.selectionStart = el.selectionEnd = el.value.length; |
|
30 | el.selectionStart = el.selectionEnd = el.value.length; | |
31 | } else if (typeof el.createTextRange != "undefined") { |
|
31 | } else if (typeof el.createTextRange != "undefined") { | |
32 | el.focus(); |
|
32 | el.focus(); | |
33 | var range = el.createTextRange(); |
|
33 | var range = el.createTextRange(); | |
34 | range.collapse(false); |
|
34 | range.collapse(false); | |
35 | range.select(); |
|
35 | range.select(); | |
36 | } |
|
36 | } | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | function getForm() { |
|
39 | function getForm() { | |
40 | return $('.post-form-w'); |
|
40 | return $('.post-form-w'); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | function resetFormPosition() { |
|
43 | function resetFormPosition() { | |
44 | var form = getForm(); |
|
44 | var form = getForm(); | |
45 | form.insertAfter($('.thread')); |
|
45 | form.insertAfter($('.thread')); | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | function addQuickReply(postId) { |
|
48 | function addQuickReply(postId) { | |
|
49 | var postLinkRaw = '[post]' + postId + '[/post]' | |||
|
50 | ||||
49 | var textToAdd = ''; |
|
51 | var textToAdd = ''; | |
50 | var blockToInsert = null; |
|
52 | var blockToInsert = null; | |
51 |
|
53 | |||
|
54 | var textAreaJq = $('textarea'); | |||
|
55 | ||||
52 | if (postId != null) { |
|
56 | if (postId != null) { | |
53 | var post = $('#' + postId); |
|
57 | var post = $('#' + postId); | |
54 |
|
58 | |||
55 | // If this is not OP, add reflink to the post |
|
59 | // If this is not OP, add reflink to the post. If there already is | |
56 | if (!post.is(':first-child')) { |
|
60 | // the same reflink, don't add it again. | |
57 | textToAdd += '[post]' + postId + '[/post]\n'; |
|
61 | if (!post.is(':first-child') && !textAreaJq.val().contains(postLinkRaw)) { | |
|
62 | textToAdd += postLinkRaw + '\n'; | |||
58 | } |
|
63 | } | |
59 |
|
64 | |||
60 | blockToInsert = post; |
|
65 | blockToInsert = post; | |
61 | } else { |
|
66 | } else { | |
62 | blockToInsert = $('.thread'); |
|
67 | blockToInsert = $('.thread'); | |
63 | } |
|
68 | } | |
64 |
|
69 | |||
65 | var selection = window.getSelection().toString(); |
|
70 | var selection = window.getSelection().toString(); | |
66 | if (selection.length > 0) { |
|
71 | if (selection.length > 0) { | |
67 | textToAdd += '[quote]' + selection + '[/quote]\n'; |
|
72 | textToAdd += '[quote]' + selection + '[/quote]\n'; | |
68 | } |
|
73 | } | |
69 |
|
74 | |||
70 | var textAreaId = 'textarea'; |
|
75 | textAreaJq.val(textAreaJq.val()+ textToAdd); | |
71 | $(textAreaId).val($(textAreaId).val()+ textToAdd); |
|
|||
72 |
|
76 | |||
73 | var form = getForm(); |
|
77 | var form = getForm(); | |
74 | form.insertAfter(blockToInsert); |
|
78 | form.insertAfter(blockToInsert); | |
75 | form.show(); |
|
79 | form.show(); | |
76 |
|
80 | |||
|
81 | textAreaJq.focus(); | |||
77 | var textarea = document.getElementsByTagName('textarea')[0]; |
|
82 | var textarea = document.getElementsByTagName('textarea')[0]; | |
78 | $(textAreaId).focus(); |
|
|||
79 | moveCaretToEnd(textarea); |
|
83 | moveCaretToEnd(textarea); | |
80 | } |
|
84 | } | |
81 |
|
85 | |||
82 | function scrollToBottom() { |
|
86 | function scrollToBottom() { | |
83 | $html.animate({scrollTop: $html.height()}, "fast"); |
|
87 | $html.animate({scrollTop: $html.height()}, "fast"); | |
84 | } |
|
88 | } |
General Comments 0
You need to be logged in to leave comments.
Login now