1 | dotclear.commentExpander = function(line) { |
---|
2 | var td = line.firstChild; |
---|
3 | |
---|
4 | var img = document.createElement('img'); |
---|
5 | img.src = dotclear.img_plus_src; |
---|
6 | img.alt = dotclear.img_plus_alt; |
---|
7 | img.className = 'expand'; |
---|
8 | $(img).css('cursor','pointer'); |
---|
9 | img.line = line; |
---|
10 | img.onclick = function() { dotclear.viewCommentContent(this,this.line); }; |
---|
11 | |
---|
12 | td.insertBefore(img,td.firstChild); |
---|
13 | }; |
---|
14 | |
---|
15 | dotclear.commentsExpander = function(line,lines) { |
---|
16 | var td = line.firstChild; |
---|
17 | |
---|
18 | var img = document.createElement('img'); |
---|
19 | img.src = dotclear.img_plus_src; |
---|
20 | img.alt = dotclear.img_plus_alt; |
---|
21 | img.className = 'expand'; |
---|
22 | $(img).css('cursor','pointer'); |
---|
23 | img.lines = lines; |
---|
24 | img.onclick = function() { dotclear.viewCommentsContent(this,this.lines); }; |
---|
25 | |
---|
26 | td.insertBefore(img,td.firstChild); |
---|
27 | }; |
---|
28 | |
---|
29 | dotclear.viewCommentsContent = function(img,lines) { |
---|
30 | lines.each(function() { |
---|
31 | var td = this.firstChild; |
---|
32 | td.firstChild.click(); |
---|
33 | }); |
---|
34 | |
---|
35 | if (img.alt == dotclear.img_plus_alt) { |
---|
36 | img.src = dotclear.img_minus_src; |
---|
37 | img.alt = dotclear.img_minus_alt; |
---|
38 | } else { |
---|
39 | img.src = dotclear.img_plus_src; |
---|
40 | img.alt = dotclear.img_plus_alt; |
---|
41 | } |
---|
42 | }; |
---|
43 | |
---|
44 | dotclear.viewCommentContent = function(img,line) { |
---|
45 | var commentId = line.id.substr(1); |
---|
46 | |
---|
47 | var tr = document.getElementById('ce'+commentId); |
---|
48 | |
---|
49 | if (!tr) { |
---|
50 | tr = document.createElement('tr'); |
---|
51 | tr.id = 'ce'+commentId; |
---|
52 | var td = document.createElement('td'); |
---|
53 | td.colSpan = 6; |
---|
54 | td.className = 'expand'; |
---|
55 | tr.appendChild(td); |
---|
56 | |
---|
57 | img.src = dotclear.img_minus_src; |
---|
58 | img.alt = dotclear.img_minus_alt; |
---|
59 | |
---|
60 | // Get comment content |
---|
61 | $.get('services.php',{f:'getCommentById',id: commentId},function(data) { |
---|
62 | var rsp = $(data).children('rsp')[0]; |
---|
63 | |
---|
64 | if (rsp.attributes[0].value == 'ok') { |
---|
65 | var comment = $(rsp).find('comment_display_content').text(); |
---|
66 | |
---|
67 | if (comment) { |
---|
68 | $(td).append(comment); |
---|
69 | var comment_email = $(rsp).find('comment_email').text(); |
---|
70 | var comment_site = $(rsp).find('comment_site').text(); |
---|
71 | var comment_ip = $(rsp).find('comment_ip').text(); |
---|
72 | var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); |
---|
73 | |
---|
74 | $(td).append('<p><strong>' + dotclear.msg.website + |
---|
75 | '</strong> ' + comment_site + '<br />' + |
---|
76 | '<strong>' + dotclear.msg.email + '</strong> ' + comment_email + '<br />' + |
---|
77 | '<strong>' + dotclear.msg.ip_address + |
---|
78 | '</strong> <a href="comments.php?ip=' + comment_ip + '">' + comment_ip + '</a>' + |
---|
79 | '<br />' + comment_spam_disp + '</p>'); |
---|
80 | } |
---|
81 | } else { |
---|
82 | alert($(rsp).find('message').text()); |
---|
83 | } |
---|
84 | }); |
---|
85 | |
---|
86 | $(line).toggleClass('expand'); |
---|
87 | line.parentNode.insertBefore(tr,line.nextSibling); |
---|
88 | } |
---|
89 | else if (tr.style.display == 'none') |
---|
90 | { |
---|
91 | $(tr).toggle(); |
---|
92 | $(line).toggleClass('expand'); |
---|
93 | img.src = dotclear.img_minus_src; |
---|
94 | img.alt = dotclear.img_minus_alt; |
---|
95 | } |
---|
96 | else |
---|
97 | { |
---|
98 | $(tr).toggle(); |
---|
99 | $(line).toggleClass('expand'); |
---|
100 | img.src = dotclear.img_plus_src; |
---|
101 | img.alt = dotclear.img_plus_alt; |
---|
102 | } |
---|
103 | }; |
---|
104 | |
---|
105 | $(function() { |
---|
106 | $('#form-comments tr:not(.line)').each(function() { |
---|
107 | dotclear.commentsExpander(this,$('#form-comments tr.line')); |
---|
108 | }); |
---|
109 | $('#form-comments tr.line').each(function() { |
---|
110 | dotclear.commentExpander(this); |
---|
111 | }); |
---|
112 | $('.checkboxes-helpers').each(function() { |
---|
113 | dotclear.checkboxesHelpers(this); |
---|
114 | }); |
---|
115 | $('#form-comments td input[type=checkbox]').enableShiftClick(); |
---|
116 | dotclear.commentsActionsHelper(); |
---|
117 | }); |
---|