Show More
@@ -1,71 +1,96 b'' | |||||
|
1 | /* | |||
|
2 | @licstart The following is the entire license notice for the | |||
|
3 | JavaScript code in this page. | |||
|
4 | ||||
|
5 | ||||
|
6 | Copyright (C) 2013 neko259 | |||
|
7 | ||||
|
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 | |||
|
10 | General Public License (GNU GPL) as published by the Free Software | |||
|
11 | Foundation, either version 3 of the License, or (at your option) | |||
|
12 | any later version. The code is distributed WITHOUT ANY WARRANTY; | |||
|
13 | without even the implied warranty of MERCHANTABILITY or FITNESS | |||
|
14 | FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. | |||
|
15 | ||||
|
16 | As additional permission under GNU GPL version 3 section 7, you | |||
|
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 | |||
|
19 | section 4, provided you include this license notice and a URL | |||
|
20 | through which recipients can access the Corresponding Source. | |||
|
21 | ||||
|
22 | @licend The above is the entire license notice | |||
|
23 | for the JavaScript code in this page. | |||
|
24 | */ | |||
|
25 | ||||
1 | function addImgPreview() { |
|
26 | function addImgPreview() { | |
2 | var margin = 20; //..change |
|
27 | var margin = 20; //..change | |
3 |
|
28 | |||
4 | //keybind |
|
29 | //keybind | |
5 | $(document).on('keyup.removepic', function(e) { |
|
30 | $(document).on('keyup.removepic', function(e) { | |
6 | if(e.which === 27) { |
|
31 | if(e.which === 27) { | |
7 | $('.img-full').remove(); |
|
32 | $('.img-full').remove(); | |
8 | } |
|
33 | } | |
9 | }); |
|
34 | }); | |
10 |
|
35 | |||
11 | $('body').on('click', '.thumb', function() { |
|
36 | $('body').on('click', '.thumb', function() { | |
12 | var el = $(this); |
|
37 | var el = $(this); | |
13 | var thumb_id = 'full' + el.find('img').attr('alt'); |
|
38 | var thumb_id = 'full' + el.find('img').attr('alt'); | |
14 |
|
39 | |||
15 | if(!$('#'+thumb_id).length) { |
|
40 | if(!$('#'+thumb_id).length) { | |
16 | var img_w = el.find('img').attr('data-width'); |
|
41 | var img_w = el.find('img').attr('data-width'); | |
17 | var img_h = el.find('img').attr('data-height'); |
|
42 | var img_h = el.find('img').attr('data-height'); | |
18 |
|
43 | |||
19 | var win_w = $(window).width(); |
|
44 | var win_w = $(window).width(); | |
20 | var win_h = $(window).height(); |
|
45 | var win_h = $(window).height(); | |
21 | //new image size |
|
46 | //new image size | |
22 | if (img_w > win_w) { |
|
47 | if (img_w > win_w) { | |
23 | img_h = img_h * (win_w/img_w) - margin; |
|
48 | img_h = img_h * (win_w/img_w) - margin; | |
24 | img_w = win_w - margin; |
|
49 | img_w = win_w - margin; | |
25 | } |
|
50 | } | |
26 | if (img_h > win_h) { |
|
51 | if (img_h > win_h) { | |
27 | img_w = img_w * (win_h/img_h) - margin; |
|
52 | img_w = img_w * (win_h/img_h) - margin; | |
28 | img_h = win_h - margin; |
|
53 | img_h = win_h - margin; | |
29 | } |
|
54 | } | |
30 |
|
55 | |||
31 | var img_pv = new Image(); |
|
56 | var img_pv = new Image(); | |
32 | $(img_pv) |
|
57 | $(img_pv) | |
33 | .addClass('img-full') |
|
58 | .addClass('img-full') | |
34 | .attr('id', thumb_id) |
|
59 | .attr('id', thumb_id) | |
35 | .attr('src', $(el).attr('href')) |
|
60 | .attr('src', $(el).attr('href')) | |
36 | .appendTo($(el)) |
|
61 | .appendTo($(el)) | |
37 | .css({ |
|
62 | .css({ | |
38 | 'width': img_w, |
|
63 | 'width': img_w, | |
39 | 'height': img_h, |
|
64 | 'height': img_h, | |
40 | 'left': (win_w - img_w) / 2, |
|
65 | 'left': (win_w - img_w) / 2, | |
41 | 'top': ((win_h - img_h) / 2) |
|
66 | 'top': ((win_h - img_h) / 2) | |
42 | }) |
|
67 | }) | |
43 | //scaling preview |
|
68 | //scaling preview | |
44 | .mousewheel(function(event, delta) { |
|
69 | .mousewheel(function(event, delta) { | |
45 | var cx = event.originalEvent.clientX, |
|
70 | var cx = event.originalEvent.clientX, | |
46 | cy = event.originalEvent.clientY, |
|
71 | cy = event.originalEvent.clientY, | |
47 | i_w = parseFloat($(img_pv).width()), |
|
72 | i_w = parseFloat($(img_pv).width()), | |
48 | i_h = parseFloat($(img_pv).height()), |
|
73 | i_h = parseFloat($(img_pv).height()), | |
49 | newIW = i_w * (delta > 0 ? 1.25 : 0.8), |
|
74 | newIW = i_w * (delta > 0 ? 1.25 : 0.8), | |
50 | newIH = i_h * (delta > 0 ? 1.25 : 0.8); |
|
75 | newIH = i_h * (delta > 0 ? 1.25 : 0.8); | |
51 |
|
76 | |||
52 | $(img_pv).width(newIW); |
|
77 | $(img_pv).width(newIW); | |
53 | $(img_pv).height(newIH); |
|
78 | $(img_pv).height(newIH); | |
54 | //set position |
|
79 | //set position | |
55 | $(img_pv) |
|
80 | $(img_pv) | |
56 | .css({ |
|
81 | .css({ | |
57 | left: parseInt(cx - (newIW/i_w) * (cx - parseInt($(img_pv).position().left, 10)), 10), |
|
82 | left: parseInt(cx - (newIW/i_w) * (cx - parseInt($(img_pv).position().left, 10)), 10), | |
58 | top: parseInt(cy - (newIH/i_h) * (cy - parseInt($(img_pv).position().top, 10)), 10) |
|
83 | top: parseInt(cy - (newIH/i_h) * (cy - parseInt($(img_pv).position().top, 10)), 10) | |
59 | }); |
|
84 | }); | |
60 |
|
85 | |||
61 | return false; |
|
86 | return false; | |
62 | } |
|
87 | } | |
63 | ).draggable() |
|
88 | ).draggable() | |
64 | } |
|
89 | } | |
65 | else { |
|
90 | else { | |
66 | $('#'+thumb_id).remove(); |
|
91 | $('#'+thumb_id).remove(); | |
67 | } |
|
92 | } | |
68 | //prevent default |
|
93 | //prevent default | |
69 | return false; |
|
94 | return false; | |
70 | }); |
|
95 | }); | |
71 | } No newline at end of file |
|
96 | } |
@@ -1,13 +1,38 b'' | |||||
|
1 | /* | |||
|
2 | @licstart The following is the entire license notice for the | |||
|
3 | JavaScript code in this page. | |||
|
4 | ||||
|
5 | ||||
|
6 | Copyright (C) 2013 neko259 | |||
|
7 | ||||
|
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 | |||
|
10 | General Public License (GNU GPL) as published by the Free Software | |||
|
11 | Foundation, either version 3 of the License, or (at your option) | |||
|
12 | any later version. The code is distributed WITHOUT ANY WARRANTY; | |||
|
13 | without even the implied warranty of MERCHANTABILITY or FITNESS | |||
|
14 | FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. | |||
|
15 | ||||
|
16 | As additional permission under GNU GPL version 3 section 7, you | |||
|
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 | |||
|
19 | section 4, provided you include this license notice and a URL | |||
|
20 | through which recipients can access the Corresponding Source. | |||
|
21 | ||||
|
22 | @licend The above is the entire license notice | |||
|
23 | for the JavaScript code in this page. | |||
|
24 | */ | |||
|
25 | ||||
1 | $( document ).ready(function() { |
|
26 | $( document ).ready(function() { | |
2 | $("a[href='#top']").click(function() { |
|
27 | $("a[href='#top']").click(function() { | |
3 | $("html, body").animate({ scrollTop: 0 }, "slow"); |
|
28 | $("html, body").animate({ scrollTop: 0 }, "slow"); | |
4 | return false; |
|
29 | return false; | |
5 | }); |
|
30 | }); | |
6 |
|
31 | |||
7 | addImgPreview(); |
|
32 | addImgPreview(); | |
8 |
|
33 | |||
9 | // TODO Rewrite popups module and reenable it |
|
34 | // TODO Rewrite popups module and reenable it | |
10 | //addPopups(); |
|
35 | //addPopups(); | |
11 |
|
36 | |||
12 | addMarkPanel(); |
|
37 | addMarkPanel(); | |
13 | }); |
|
38 | }); |
@@ -1,34 +1,59 b'' | |||||
|
1 | /* | |||
|
2 | @licstart The following is the entire license notice for the | |||
|
3 | JavaScript code in this page. | |||
|
4 | ||||
|
5 | ||||
|
6 | Copyright (C) 2013 neko259 | |||
|
7 | ||||
|
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 | |||
|
10 | General Public License (GNU GPL) as published by the Free Software | |||
|
11 | Foundation, either version 3 of the License, or (at your option) | |||
|
12 | any later version. The code is distributed WITHOUT ANY WARRANTY; | |||
|
13 | without even the implied warranty of MERCHANTABILITY or FITNESS | |||
|
14 | FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. | |||
|
15 | ||||
|
16 | As additional permission under GNU GPL version 3 section 7, you | |||
|
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 | |||
|
19 | section 4, provided you include this license notice and a URL | |||
|
20 | through which recipients can access the Corresponding Source. | |||
|
21 | ||||
|
22 | @licend The above is the entire license notice | |||
|
23 | for the JavaScript code in this page. | |||
|
24 | */ | |||
|
25 | ||||
1 | function addMarkToMsg(start, end) { |
|
26 | function addMarkToMsg(start, end) { | |
2 | var textarea = document.getElementById('id_text'); |
|
27 | var textarea = document.getElementById('id_text'); | |
3 | if(!textarea) return; |
|
28 | if(!textarea) return; | |
4 | if( document.selection ) { |
|
29 | if( document.selection ) { | |
5 | textarea.focus(); |
|
30 | textarea.focus(); | |
6 | sel = document.selection.createRange(); |
|
31 | sel = document.selection.createRange(); | |
7 | sel.text = start + sel.text + end; |
|
32 | sel.text = start + sel.text + end; | |
8 | } else if(textarea.selectionStart || textarea.selectionStart == '0') { |
|
33 | } else if(textarea.selectionStart || textarea.selectionStart == '0') { | |
9 | textarea.focus(); |
|
34 | textarea.focus(); | |
10 | var startPos = textarea.selectionStart; |
|
35 | var startPos = textarea.selectionStart; | |
11 | var endPos = textarea.selectionEnd; |
|
36 | var endPos = textarea.selectionEnd; | |
12 | textarea.value = textarea.value.substring(0, startPos) + start + textarea.value.substring(startPos, endPos) + end + textarea.value.substring( endPos, textarea.value.length ); |
|
37 | textarea.value = textarea.value.substring(0, startPos) + start + textarea.value.substring(startPos, endPos) + end + textarea.value.substring( endPos, textarea.value.length ); | |
13 | } else { |
|
38 | } else { | |
14 | textarea.value += start + end; |
|
39 | textarea.value += start + end; | |
15 | } |
|
40 | } | |
16 | return false; |
|
41 | return false; | |
17 | } |
|
42 | } | |
18 |
|
43 | |||
19 | function addMarkPanel() { |
|
44 | function addMarkPanel() { | |
20 | $('.mark_btn').on('click', function() { |
|
45 | $('.mark_btn').on('click', function() { | |
21 | switch($(this).attr('id')) { |
|
46 | switch($(this).attr('id')) { | |
22 | case "italic": |
|
47 | case "italic": | |
23 | return addMarkToMsg('_', '_'); |
|
48 | return addMarkToMsg('_', '_'); | |
24 | case "bold": |
|
49 | case "bold": | |
25 | return addMarkToMsg('__', '__'); |
|
50 | return addMarkToMsg('__', '__'); | |
26 | case "spoiler": |
|
51 | case "spoiler": | |
27 | return addMarkToMsg('%%', '%%'); |
|
52 | return addMarkToMsg('%%', '%%'); | |
28 | case "comment": |
|
53 | case "comment": | |
29 | return addMarkToMsg('//', ''); |
|
54 | return addMarkToMsg('//', ''); | |
30 | case "quote": |
|
55 | case "quote": | |
31 | return addMarkToMsg('>', ''); |
|
56 | return addMarkToMsg('>', ''); | |
32 | } |
|
57 | } | |
33 | }); |
|
58 | }); | |
34 | } |
|
59 | } |
@@ -1,44 +1,69 b'' | |||||
|
1 | /* | |||
|
2 | @licstart The following is the entire license notice for the | |||
|
3 | JavaScript code in this page. | |||
|
4 | ||||
|
5 | ||||
|
6 | Copyright (C) 2013 neko259 | |||
|
7 | ||||
|
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 | |||
|
10 | General Public License (GNU GPL) as published by the Free Software | |||
|
11 | Foundation, either version 3 of the License, or (at your option) | |||
|
12 | any later version. The code is distributed WITHOUT ANY WARRANTY; | |||
|
13 | without even the implied warranty of MERCHANTABILITY or FITNESS | |||
|
14 | FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. | |||
|
15 | ||||
|
16 | As additional permission under GNU GPL version 3 section 7, you | |||
|
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 | |||
|
19 | section 4, provided you include this license notice and a URL | |||
|
20 | through which recipients can access the Corresponding Source. | |||
|
21 | ||||
|
22 | @licend The above is the entire license notice | |||
|
23 | for the JavaScript code in this page. | |||
|
24 | */ | |||
|
25 | ||||
1 | /** |
|
26 | /** | |
2 | * Created with IntelliJ IDEA. |
|
27 | * Created with IntelliJ IDEA. | |
3 | * User: vurdalak |
|
28 | * User: vurdalak | |
4 | * Date: 21.09.13 |
|
29 | * Date: 21.09.13 | |
5 | * Time: 15:21 |
|
30 | * Time: 15:21 | |
6 | * To change this template use File | Settings | File Templates. |
|
31 | * To change this template use File | Settings | File Templates. | |
7 | */ |
|
32 | */ | |
8 |
|
33 | |||
9 | function addPopups() { |
|
34 | function addPopups() { | |
10 |
|
35 | |||
11 | $('a').each(function() { |
|
36 | $('a').each(function() { | |
12 | if($(this).text().indexOf('>>') == 0) { |
|
37 | if($(this).text().indexOf('>>') == 0) { | |
13 | var refNum = $(this).text().match(/\d+/); |
|
38 | var refNum = $(this).text().match(/\d+/); | |
14 |
|
39 | |||
15 | if (refNum != null) { |
|
40 | if (refNum != null) { | |
16 | var self = $(this); |
|
41 | var self = $(this); | |
17 |
|
42 | |||
18 | $(this).mouseenter(function() { |
|
43 | $(this).mouseenter(function() { | |
19 | $.get('/get_post/' + refNum, function(data) { |
|
44 | $.get('/get_post/' + refNum, function(data) { | |
20 | var popup = $('<div/>').html(data) |
|
45 | var popup = $('<div/>').html(data) | |
21 |
|
46 | |||
22 | popup.dialog({ |
|
47 | popup.dialog({ | |
23 | modal: false, |
|
48 | modal: false, | |
24 | minHeight: 0, |
|
49 | minHeight: 0, | |
25 | }); |
|
50 | }); | |
26 |
|
51 | |||
27 | popup.position({ |
|
52 | popup.position({ | |
28 | my: "left+20 top+20", |
|
53 | my: "left+20 top+20", | |
29 | at: "right bottom", |
|
54 | at: "right bottom", | |
30 | of: self |
|
55 | of: self | |
31 | }) |
|
56 | }) | |
32 |
|
57 | |||
33 | self.mouseleave(function() { |
|
58 | self.mouseleave(function() { | |
34 | if (popup != null) { |
|
59 | if (popup != null) { | |
35 | popup.remove(); |
|
60 | popup.remove(); | |
36 | } |
|
61 | } | |
37 | }); |
|
62 | }); | |
38 | }) |
|
63 | }) | |
39 | }); |
|
64 | }); | |
40 | } |
|
65 | } | |
41 | } |
|
66 | } | |
42 | }); |
|
67 | }); | |
43 |
|
68 | |||
44 | } |
|
69 | } |
@@ -1,55 +1,80 b'' | |||||
|
1 | /* | |||
|
2 | @licstart The following is the entire license notice for the | |||
|
3 | JavaScript code in this page. | |||
|
4 | ||||
|
5 | ||||
|
6 | Copyright (C) 2013 neko259 | |||
|
7 | ||||
|
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 | |||
|
10 | General Public License (GNU GPL) as published by the Free Software | |||
|
11 | Foundation, either version 3 of the License, or (at your option) | |||
|
12 | any later version. The code is distributed WITHOUT ANY WARRANTY; | |||
|
13 | without even the implied warranty of MERCHANTABILITY or FITNESS | |||
|
14 | FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. | |||
|
15 | ||||
|
16 | As additional permission under GNU GPL version 3 section 7, you | |||
|
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 | |||
|
19 | section 4, provided you include this license notice and a URL | |||
|
20 | through which recipients can access the Corresponding Source. | |||
|
21 | ||||
|
22 | @licend The above is the entire license notice | |||
|
23 | for the JavaScript code in this page. | |||
|
24 | */ | |||
|
25 | ||||
1 | function addGalleryPanel() { |
|
26 | function addGalleryPanel() { | |
2 | var gallery = $('a[class="thumb"]').clone(true), |
|
27 | var gallery = $('a[class="thumb"]').clone(true), | |
3 | normal = $('.post').clone(true); |
|
28 | normal = $('.post').clone(true); | |
4 |
|
29 | |||
5 | $('.navigation_panel').filter(':first').after( |
|
30 | $('.navigation_panel').filter(':first').after( | |
6 | '<div class="image-mode-tab" role="radiogroup" aria-label="Image mode2">' + |
|
31 | '<div class="image-mode-tab" role="radiogroup" aria-label="Image mode2">' + | |
7 | '<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>' + | |
8 | '<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>' + | |
9 | '</div>' |
|
34 | '</div>' | |
10 | ); |
|
35 | ); | |
11 |
|
36 | |||
12 | $('input[name="image-mode"]').change(function() { |
|
37 | $('input[name="image-mode"]').change(function() { | |
13 | //gallery mode |
|
38 | //gallery mode | |
14 | if($(this).val() === '1') { |
|
39 | if($(this).val() === '1') { | |
15 | $('.thread').replaceWith( |
|
40 | $('.thread').replaceWith( | |
16 | $('<div id="posts-table"></div>').append(gallery) |
|
41 | $('<div id="posts-table"></div>').append(gallery) | |
17 | ); |
|
42 | ); | |
18 | } |
|
43 | } | |
19 | //normal mode |
|
44 | //normal mode | |
20 | else { |
|
45 | else { | |
21 | $('#posts-table').replaceWith( |
|
46 | $('#posts-table').replaceWith( | |
22 | $('<div class="thread"></div>').append(normal) |
|
47 | $('<div class="thread"></div>').append(normal) | |
23 | ); |
|
48 | ); | |
24 | } |
|
49 | } | |
25 | }); |
|
50 | }); | |
26 | } |
|
51 | } | |
27 |
|
52 | |||
28 | function moveCaretToEnd(el) { |
|
53 | function moveCaretToEnd(el) { | |
29 | if (typeof el.selectionStart == "number") { |
|
54 | if (typeof el.selectionStart == "number") { | |
30 | el.selectionStart = el.selectionEnd = el.value.length; |
|
55 | el.selectionStart = el.selectionEnd = el.value.length; | |
31 | } else if (typeof el.createTextRange != "undefined") { |
|
56 | } else if (typeof el.createTextRange != "undefined") { | |
32 | el.focus(); |
|
57 | el.focus(); | |
33 | var range = el.createTextRange(); |
|
58 | var range = el.createTextRange(); | |
34 | range.collapse(false); |
|
59 | range.collapse(false); | |
35 | range.select(); |
|
60 | range.select(); | |
36 | } |
|
61 | } | |
37 | } |
|
62 | } | |
38 |
|
63 | |||
39 | function addQuickReply(postId) { |
|
64 | function addQuickReply(postId) { | |
40 | var textToAdd = '>>' + postId + '\n\n'; |
|
65 | var textToAdd = '>>' + postId + '\n\n'; | |
41 | var textAreaId = '#id_text'; |
|
66 | var textAreaId = '#id_text'; | |
42 | $(textAreaId).val($(textAreaId).val()+ textToAdd); |
|
67 | $(textAreaId).val($(textAreaId).val()+ textToAdd); | |
43 |
|
68 | |||
44 | var textarea = document.getElementById('id_text'); |
|
69 | var textarea = document.getElementById('id_text'); | |
45 | $(textAreaId).focus(); |
|
70 | $(textAreaId).focus(); | |
46 | moveCaretToEnd(textarea); |
|
71 | moveCaretToEnd(textarea); | |
47 |
|
72 | |||
48 | $("html, body").animate({ scrollTop: $(textAreaId).offset().top }, "slow"); |
|
73 | $("html, body").animate({ scrollTop: $(textAreaId).offset().top }, "slow"); | |
49 | } |
|
74 | } | |
50 |
|
75 | |||
51 |
|
76 | |||
52 |
|
77 | |||
53 | $(document).ready(function(){ |
|
78 | $(document).ready(function(){ | |
54 | addGalleryPanel(); |
|
79 | addGalleryPanel(); | |
55 | }); |
|
80 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now