Show More
@@ -0,0 +1,198 b'' | |||||
|
1 | function $X(path, root) { | |||
|
2 | return document.evaluate(path, root || document, null, 6, null); | |||
|
3 | } | |||
|
4 | function $x(path, root) { | |||
|
5 | return document.evaluate(path, root || document, null, 8, null).singleNodeValue; | |||
|
6 | } | |||
|
7 | ||||
|
8 | function $del(el) { | |||
|
9 | if(el) el.parentNode.removeChild(el); | |||
|
10 | } | |||
|
11 | ||||
|
12 | function $each(list, fn) { | |||
|
13 | if(!list) return; | |||
|
14 | var i = list.snapshotLength; | |||
|
15 | if(i > 0) while(i--) fn(list.snapshotItem(i), i); | |||
|
16 | } | |||
|
17 | ||||
|
18 | function addRefLinkPreview(node) { | |||
|
19 | $each($X('.//a[starts-with(text(),">>")]', node || document), function(link) { | |||
|
20 | link.addEventListener('mouseover', showPostPreview, false); | |||
|
21 | link.addEventListener('mouseout', delPostPreview, false); | |||
|
22 | }); | |||
|
23 | } | |||
|
24 | ||||
|
25 | function showPostPreview(e) { | |||
|
26 | var doc = document; | |||
|
27 | //ref id | |||
|
28 | var pNum = $(this).text().match(/\d+/); | |||
|
29 | ||||
|
30 | //position | |||
|
31 | //var x = e.clientX + (doc.documentElement.scrollLeft || doc.body.scrollLeft) - doc.documentElement.clientLeft + 1; | |||
|
32 | //var y = e.clientY + (doc.documentElement.scrollTop || doc.body.scrollTop) - doc.documentElement.clientTop; | |||
|
33 | ||||
|
34 | var x = e.clientX + (doc.documentElement.scrollLeft || doc.body.scrollLeft) + 2; | |||
|
35 | var y = e.clientY + (doc.documentElement.scrollTop || doc.body.scrollTop); | |||
|
36 | ||||
|
37 | var cln = doc.createElement('div'); | |||
|
38 | cln.id = 'pstprev_' + pNum; | |||
|
39 | cln.className = 'post_preview post'; | |||
|
40 | ||||
|
41 | cln.style.cssText = 'top:' + y + 'px;' + (x < doc.body.clientWidth/2 ? 'left:' + x + 'px' : 'right:' + parseInt(doc.body.clientWidth - x + 1) + 'px'); | |||
|
42 | ||||
|
43 | cln.addEventListener('mouseout', delPostPreview, false); | |||
|
44 | ||||
|
45 | ||||
|
46 | var mkPreview = function(cln, html) { | |||
|
47 | ||||
|
48 | cln.innerHTML = html; | |||
|
49 | ||||
|
50 | addRefLinkPreview(cln); | |||
|
51 | ||||
|
52 | //if(!$x('.//small', cln)) showRefMap(post, p_num, refMap) | |||
|
53 | }; | |||
|
54 | ||||
|
55 | ||||
|
56 | cln.innerHTML = 'Загрузка...'; | |||
|
57 | ||||
|
58 | //если пост найден в дереве. | |||
|
59 | if($('div[id='+pNum+']').length > 0) { | |||
|
60 | var postdata = $('div[id='+pNum+']').html(); | |||
|
61 | ||||
|
62 | //TODO: временно | |||
|
63 | //funcInit(postdata); | |||
|
64 | ||||
|
65 | //make preview | |||
|
66 | mkPreview(cln, postdata); | |||
|
67 | } | |||
|
68 | //ajax api | |||
|
69 | // else { | |||
|
70 | // $.getJSON(mayuri_cfg['board_url']+'api/single/'+pNum) | |||
|
71 | // .success(function(data) { | |||
|
72 | // //post templates | |||
|
73 | // var postdata = makeAjaxPost(data).html(); | |||
|
74 | // | |||
|
75 | // //TODO: временно | |||
|
76 | // //funcInit(postdata); | |||
|
77 | // | |||
|
78 | // //make preview | |||
|
79 | // mkPreview(cln, postdata); | |||
|
80 | // | |||
|
81 | // })//if error | |||
|
82 | // .error(function() { | |||
|
83 | // cln.innerHTML = 'Пост не найден.'; | |||
|
84 | // }); | |||
|
85 | // } | |||
|
86 | ||||
|
87 | $del(doc.getElementById(cln.id)); | |||
|
88 | ||||
|
89 | //add preview | |||
|
90 | $('body').append(cln); | |||
|
91 | } | |||
|
92 | ||||
|
93 | function delPostPreview(e) { | |||
|
94 | var el = $x('ancestor-or-self::*[starts-with(@id,"pstprev")]', e.relatedTarget); | |||
|
95 | if(!el) $each($X('.//div[starts-with(@id,"pstprev")]'), function(clone) { | |||
|
96 | $del(clone) | |||
|
97 | }); | |||
|
98 | else while(el.nextSibling) $del(el.nextSibling); | |||
|
99 | } | |||
|
100 | ||||
|
101 | ||||
|
102 | ||||
|
103 | ||||
|
104 | ||||
|
105 | ||||
|
106 | function addPreview() { | |||
|
107 | $('.post').find('a').each(function() { | |||
|
108 | showPostPreview($(this)); | |||
|
109 | }); | |||
|
110 | } | |||
|
111 | ||||
|
112 | function showPreview(node) { | |||
|
113 | node.each(function() { | |||
|
114 | //reflink? | |||
|
115 | if($(this).text().indexOf('>>') == 0) { | |||
|
116 | //add mouseover event | |||
|
117 | $(this).on('mouseover', function(e) { | |||
|
118 | var ref = $(this); | |||
|
119 | ||||
|
120 | var doc = document; | |||
|
121 | //ref id | |||
|
122 | var pNum = ref.text().match(/\d+/); | |||
|
123 | ||||
|
124 | //position | |||
|
125 | var x = e.clientX + (doc.documentElement.scrollLeft || doc.body.scrollLeft) + 2; | |||
|
126 | var y = e.clientY + (doc.documentElement.scrollTop || doc.body.scrollTop); | |||
|
127 | ||||
|
128 | //create preview block | |||
|
129 | var cln = $('<div>', { | |||
|
130 | id: 'pstprev_' + pNum, | |||
|
131 | class: 'post_preview post' | |||
|
132 | }) | |||
|
133 | .css('cssText', 'top:' + y + 'px;' + (x < doc.body.clientWidth/2 ? 'left:' + x + 'px' : 'right:' + parseInt(doc.body.clientWidth - x + 1) | |||
|
134 | + 'px')); | |||
|
135 | ||||
|
136 | ||||
|
137 | var mkPreview = function(cln, html) { | |||
|
138 | ||||
|
139 | cln.html(html); | |||
|
140 | ||||
|
141 | showPreview($(cln)); | |||
|
142 | //if(!$x('.//small', cln)) showRefMap(post, p_num, refMap) | |||
|
143 | }; | |||
|
144 | ||||
|
145 | cln.html('Загрузка...'); | |||
|
146 | ||||
|
147 | //если пост найден в дереве. | |||
|
148 | if($('div[id='+pNum+']').length > 0) { | |||
|
149 | var postdata = $('div[id='+pNum+']').clone().html(); | |||
|
150 | //TODO: лучше бы вынести в mkPreview | |||
|
151 | //if($.localStorage('addImgPreview') > 0) showImgPreview($(postdata)); | |||
|
152 | ||||
|
153 | //make preview | |||
|
154 | mkPreview(cln, postdata); | |||
|
155 | } | |||
|
156 | //ajax api | |||
|
157 | // else { | |||
|
158 | // $.getJSON(mayuri_cfg['board_url']+'api/single/'+pNum) | |||
|
159 | // .success(function(data) { | |||
|
160 | // //post templates | |||
|
161 | // var postdata = makeAjaxPost(data).html(); | |||
|
162 | // | |||
|
163 | // //make preview | |||
|
164 | // mkPreview(cln, postdata); | |||
|
165 | // | |||
|
166 | // })//if error | |||
|
167 | // .error(function() { | |||
|
168 | // cln.html('Пост не найден.'); | |||
|
169 | // }); | |||
|
170 | // } | |||
|
171 | ||||
|
172 | $del(doc.getElementById(cln.id)); | |||
|
173 | ||||
|
174 | //add preview | |||
|
175 | $('body').append(cln); | |||
|
176 | }); | |||
|
177 | ||||
|
178 | $(this).on('mouseout', function() { | |||
|
179 | delPreview($(this)); | |||
|
180 | }) | |||
|
181 | } | |||
|
182 | }); | |||
|
183 | ||||
|
184 | } | |||
|
185 | ||||
|
186 | function delPreview(e) { | |||
|
187 | var el = e.relatedTarget; | |||
|
188 | if(!el) { | |||
|
189 | $(el).each(function(clone) { | |||
|
190 | $del(clone) | |||
|
191 | }); | |||
|
192 | } | |||
|
193 | { | |||
|
194 | while(el.next()) | |||
|
195 | $del(el.next()); | |||
|
196 | } | |||
|
197 | } | |||
|
198 |
@@ -22,3 +22,8 b'' | |||||
22 | .strikethrough { |
|
22 | .strikethrough { | |
23 | text-decoration: line-through; |
|
23 | text-decoration: line-through; | |
24 | } |
|
24 | } | |
|
25 | ||||
|
26 | .post_preview { | |||
|
27 | z-index: 300; | |||
|
28 | position:absolute; | |||
|
29 | } |
@@ -35,4 +35,6 b'' | |||||
35 | //addPopups(); |
|
35 | //addPopups(); | |
36 |
|
36 | |||
37 | addMarkPanel(); |
|
37 | addMarkPanel(); | |
|
38 | ||||
|
39 | addRefLinkPreview(); | |||
38 | }); |
|
40 | }); |
@@ -28,6 +28,7 b'' | |||||
28 | <script src="{% static 'js/panel.js' %}"></script> |
|
28 | <script src="{% static 'js/panel.js' %}"></script> | |
29 | <script src="{% static 'js/popup.js' %}"></script> |
|
29 | <script src="{% static 'js/popup.js' %}"></script> | |
30 | <script src="{% static 'js/image.js' %}"></script> |
|
30 | <script src="{% static 'js/image.js' %}"></script> | |
|
31 | <script src="{% static 'js/refpopup.js' %}"></script> | |||
31 | <script src="{% static 'js/main.js' %}"></script> |
|
32 | <script src="{% static 'js/main.js' %}"></script> | |
32 |
|
33 | |||
33 | <div class="navigation_panel"> |
|
34 | <div class="navigation_panel"> |
@@ -7,6 +7,7 b'' | |||||
7 | [DONE] Ban reasons. Split bans into 2 types "read-only" and "read |
|
7 | [DONE] Ban reasons. Split bans into 2 types "read-only" and "read | |
8 | denied". Use second only for autoban for spam |
|
8 | denied". Use second only for autoban for spam | |
9 | [DONE] Clean up tests and make them run ALWAYS |
|
9 | [DONE] Clean up tests and make them run ALWAYS | |
|
10 | [DONE] Use transactions in tests | |||
10 |
|
11 | |||
11 | [NOT STARTED] Tree view (JS) |
|
12 | [NOT STARTED] Tree view (JS) | |
12 | [NOT STARTED] Adding tags to images filename |
|
13 | [NOT STARTED] Adding tags to images filename | |
@@ -19,7 +20,6 b' denied". Use second only for autoban for' | |||||
19 | [NOT STARTED] Group tags by first letter in all tags list |
|
20 | [NOT STARTED] Group tags by first letter in all tags list | |
20 | [NOT STARTED] Show board speed in the lower panel (posts per day) |
|
21 | [NOT STARTED] Show board speed in the lower panel (posts per day) | |
21 | [NOT STARTED] Character counter in the post field |
|
22 | [NOT STARTED] Character counter in the post field | |
22 | [NOT STARTED] Use transactions in tests |
|
|||
23 | [NOT STARTED] Save image thumbnails size to the separate field |
|
23 | [NOT STARTED] Save image thumbnails size to the separate field | |
24 | [NOT STARTED] Whitelist functionality. Permin autoban of an address |
|
24 | [NOT STARTED] Whitelist functionality. Permin autoban of an address | |
25 | [NOT STARTED] Split up post model into post and thread, |
|
25 | [NOT STARTED] Split up post model into post and thread, |
General Comments 0
You need to be logged in to leave comments.
Login now