##// END OF EJS Templates
Fixed adding replies to posts in thread
neko259 -
r439:2ad39e04 default
parent child Browse files
Show More
@@ -1,37 +1,35
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 $( document ).ready(function() {
26 $( document ).ready(function() {
27 $("a[href='#top']").click(function() {
27 $("a[href='#top']").click(function() {
28 $("html, body").animate({ scrollTop: 0 }, "slow");
28 $("html, body").animate({ scrollTop: 0 }, "slow");
29 return false;
29 return false;
30 });
30 });
31
31
32 addImgPreview();
32 addImgPreview();
33
33
34 addMarkPanel();
35
36 addRefLinkPreview();
34 addRefLinkPreview();
37 });
35 });
@@ -1,81 +1,81
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 function addGalleryPanel() {
26 function addGalleryPanel() {
27 var gallery = $('a[class="thumb"]').clone(true),
27 var gallery = $('a[class="thumb"]').clone(true),
28 normal = $('.post').clone(true);
28 normal = $('.post').clone(true);
29
29
30 $('.navigation_panel').filter(':first').after(
30 $('.navigation_panel').filter(':first').after(
31 '<div class="image-mode-tab" role="radiogroup" aria-label="Image mode2">' +
31 '<div class="image-mode-tab" role="radiogroup" aria-label="Image mode2">' +
32 '<label><input type="radio" class="image-mode-normal" name="image-mode" value="0" checked="checked"/>'+ gettext('Normal') +'</label>' +
32 '<label><input type="radio" class="image-mode-normal" name="image-mode" value="0" checked="checked"/>'+ gettext('Normal') +'</label>' +
33 '<label><input type="radio" class="image-mode-table" name="image-mode" value="1"/>'+ gettext('Gallery') +'</label>' +
33 '<label><input type="radio" class="image-mode-table" name="image-mode" value="1"/>'+ gettext('Gallery') +'</label>' +
34 '</div>'
34 '</div>'
35 );
35 );
36
36
37 $('input[name="image-mode"]').change(function() {
37 $('input[name="image-mode"]').change(function() {
38 //gallery mode
38 //gallery mode
39 if($(this).val() === '1') {
39 if($(this).val() === '1') {
40 $('.thread').replaceWith(
40 $('.thread').replaceWith(
41 $('<div id="posts-table"></div>').append(gallery)
41 $('<div id="posts-table"></div>').append(gallery)
42 );
42 );
43 }
43 }
44 //normal mode
44 //normal mode
45 else {
45 else {
46 $('#posts-table').replaceWith(
46 $('#posts-table').replaceWith(
47 $('<div class="thread"></div>').append(normal)
47 $('<div class="thread"></div>').append(normal)
48 );
48 );
49 }
49 }
50 });
50 });
51 }
51 }
52
52
53 function moveCaretToEnd(el) {
53 function moveCaretToEnd(el) {
54 if (typeof el.selectionStart == "number") {
54 if (typeof el.selectionStart == "number") {
55 el.selectionStart = el.selectionEnd = el.value.length;
55 el.selectionStart = el.selectionEnd = el.value.length;
56 } else if (typeof el.createTextRange != "undefined") {
56 } else if (typeof el.createTextRange != "undefined") {
57 el.focus();
57 el.focus();
58 var range = el.createTextRange();
58 var range = el.createTextRange();
59 range.collapse(false);
59 range.collapse(false);
60 range.select();
60 range.select();
61 }
61 }
62 }
62 }
63
63
64 function addQuickReply(postId) {
64 function addQuickReply(postId) {
65 var textToAdd = '>>' + postId + '\n\n';
65 var textToAdd = '>>' + postId + '\n\n';
66 var textAreaId = '#id_text';
66 var textAreaId = 'textarea';
67 $(textAreaId).val($(textAreaId).val()+ textToAdd);
67 $(textAreaId).val($(textAreaId).val()+ textToAdd);
68
68
69 var textarea = document.getElementById('id_text');
69 var textarea = document.getElementsByTagName('textarea')[0];
70 $(textAreaId).focus();
70 $(textAreaId).focus();
71 moveCaretToEnd(textarea);
71 moveCaretToEnd(textarea);
72
72
73 $("html, body").animate({ scrollTop: $(textAreaId).offset().top }, "slow");
73 $("html, body").animate({ scrollTop: $(textAreaId).offset().top }, "slow");
74 }
74 }
75
75
76
76
77
77
78 $(document).ready(function(){
78 $(document).ready(function(){
79 addGalleryPanel();
79 addGalleryPanel();
80 initAutoupdate();
80 initAutoupdate();
81 });
81 });
General Comments 0
You need to be logged in to leave comments. Login now