##// END OF EJS Templates
Added post preview popups
neko259 -
r352:bba983c3 default
parent child Browse files
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
@@ -1,24 +1,29 b''
1 1 .ui-button {
2 2 display: none;
3 3 }
4 4
5 5 .ui-dialog-content {
6 6 padding: 0;
7 7 min-height: 0;
8 8 }
9 9
10 10 .mark_btn {
11 11 cursor: pointer;
12 12 }
13 13
14 14 .img-full {
15 15 position: fixed;
16 16 z-index: 9999;
17 17 background-color: #CCC;
18 18 border: 1px solid #000;
19 19 cursor: pointer;
20 20 }
21 21
22 22 .strikethrough {
23 23 text-decoration: line-through;
24 24 }
25
26 .post_preview {
27 z-index: 300;
28 position:absolute;
29 }
@@ -1,38 +1,40 b''
1 1 /*
2 2 @licstart The following is the entire license notice for the
3 3 JavaScript code in this page.
4 4
5 5
6 6 Copyright (C) 2013 neko259
7 7
8 8 The JavaScript code in this page is free software: you can
9 9 redistribute it and/or modify it under the terms of the GNU
10 10 General Public License (GNU GPL) as published by the Free Software
11 11 Foundation, either version 3 of the License, or (at your option)
12 12 any later version. The code is distributed WITHOUT ANY WARRANTY;
13 13 without even the implied warranty of MERCHANTABILITY or FITNESS
14 14 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
15 15
16 16 As additional permission under GNU GPL version 3 section 7, you
17 17 may distribute non-source (e.g., minimized or compacted) forms of
18 18 that code without the copy of the GNU GPL normally required by
19 19 section 4, provided you include this license notice and a URL
20 20 through which recipients can access the Corresponding Source.
21 21
22 22 @licend The above is the entire license notice
23 23 for the JavaScript code in this page.
24 24 */
25 25
26 26 $( document ).ready(function() {
27 27 $("a[href='#top']").click(function() {
28 28 $("html, body").animate({ scrollTop: 0 }, "slow");
29 29 return false;
30 30 });
31 31
32 32 addImgPreview();
33 33
34 34 // TODO Rewrite popups module and reenable it
35 35 //addPopups();
36 36
37 37 addMarkPanel();
38
39 addRefLinkPreview();
38 40 });
@@ -1,57 +1,58 b''
1 1 {% load staticfiles %}
2 2 {% load i18n %}
3 3 {% load static from staticfiles %}
4 4
5 5 <!DOCTYPE html>
6 6 <html>
7 7 <head>
8 8 <link rel="stylesheet" type="text/css"
9 9 href="{% static 'css/base.css' %}" media="all"/>
10 10 <link rel="stylesheet" type="text/css"
11 11 href="{% static theme_css %}" media="all"/>
12 12 <link rel="alternate" type="application/rss+xml" href="rss/" title=
13 13 "{% trans 'Feed' %}"/>
14 14
15 15 <link rel="icon" type="image/png"
16 16 href="{% static 'favicon.png' %}">
17 17
18 18 <meta name="viewport" content="width=device-width, initial-scale=1"/>
19 19 <meta charset="utf-8"/>
20 20
21 21 {% block head %}{% endblock %}
22 22 </head>
23 23 <body>
24 24 <script src="{% static 'js/jquery-2.0.1.min.js' %}"></script>
25 25 <script src="{% static 'js/jquery-ui-1.10.3.custom.min.js' %}"></script>
26 26 <script src="{% static 'js/jquery.mousewheel.js' %}"></script>
27 27 <script src="{% url 'django.views.i18n.javascript_catalog' %}"></script>
28 28 <script src="{% static 'js/panel.js' %}"></script>
29 29 <script src="{% static 'js/popup.js' %}"></script>
30 30 <script src="{% static 'js/image.js' %}"></script>
31 <script src="{% static 'js/refpopup.js' %}"></script>
31 32 <script src="{% static 'js/main.js' %}"></script>
32 33
33 34 <div class="navigation_panel">
34 35 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>
35 36 {% for tag in tags %}
36 37 <a class="tag" href="{% url 'tag' tag_name=tag.name %}"
37 38 >#{{ tag.name }}</a>,
38 39 {% endfor %}
39 40 <a class="tag" href="{% url 'tags' %}" title="{% trans 'Tag management' %}"
40 41 >[...]</a>
41 42 <a class="link" href="{% url 'settings' %}">{% trans 'Settings' %}</a>
42 43 </div>
43 44
44 45 {% block content %}{% endblock %}
45 46
46 47 <div class="navigation_panel">
47 48 {% block metapanel %}{% endblock %}
48 49 [<a href="{% url "login" %}">{% trans 'Login' %}</a>]
49 50 <a class="link" href="#top">{% trans 'Up' %}</a>
50 51 </div>
51 52
52 53 <div class="footer">
53 54 <!-- Put your banners here -->
54 55 </div>
55 56
56 57 </body>
57 58 </html>
@@ -1,41 +1,41 b''
1 1 = Features =
2 2 [DONE] Connecting tags to each other
3 3 [DONE] Connect posts to the replies (in messages), get rid of the JS reply map
4 4 [DONE] Better django admin pages to simplify admin operations
5 5 [DONE] Regen script to update all posts
6 6 [DONE] Remove jump links from refmaps
7 7 [DONE] Ban reasons. Split bans into 2 types "read-only" and "read
8 8 denied". Use second only for autoban for spam
9 9 [DONE] Clean up tests and make them run ALWAYS
10 [DONE] Use transactions in tests
10 11
11 12 [NOT STARTED] Tree view (JS)
12 13 [NOT STARTED] Adding tags to images filename
13 14 [NOT STARTED] Federative network for s2s communication
14 15 [NOT STARTED] XMPP gate
15 16 [NOT STARTED] Bitmessage gate
16 17 [NOT STARTED] Notification engine
17 18 [NOT STARTED] Javascript disabling engine
18 19 [NOT STARTED] Thread autoupdate (JS + API)
19 20 [NOT STARTED] Group tags by first letter in all tags list
20 21 [NOT STARTED] Show board speed in the lower panel (posts per day)
21 22 [NOT STARTED] Character counter in the post field
22 [NOT STARTED] Use transactions in tests
23 23 [NOT STARTED] Save image thumbnails size to the separate field
24 24 [NOT STARTED] Whitelist functionality. Permin autoban of an address
25 25 [NOT STARTED] Split up post model into post and thread,
26 26 and move everything that is used only in 1st post to thread model.
27 27 [NOT STARTED] Statistics module. Count views (optional, may result in bad
28 28 performance), posts per day/week/month, users (or IPs)
29 29 [NOT STARTED] Quote button next to "reply" for posts in thread to include full
30 30 post or its part (delimited by N characters) into quote of the new post.
31 31 [NOT STARTED] Ban confirmation page with reason
32 32 [NOT STARTED] Post deletion confirmation page
33 33
34 34 = Bugs =
35 35 [DONE] Fix bug with creating threads from tag view
36 36 [DONE] Quote characters within quote causes quote parsing to fail
37 37
38 38 = Testing =
39 39 [NOT STARTED] Make tests for every view
40 40 [NOT STARTED] Make tests for every model
41 41 [NOT STARTED] Make tests for every form
General Comments 0
You need to be logged in to leave comments. Login now