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