1 | /*global $, dotclear */ |
---|
2 | 'use strict'; |
---|
3 | |
---|
4 | dotclear.viewCommentContent = function(line, action) { |
---|
5 | action = action || 'toggle'; |
---|
6 | var commentId = $(line).attr('id').substr(1); |
---|
7 | var tr = document.getElementById('ce' + commentId); |
---|
8 | |
---|
9 | if (!tr && (action == 'toggle' || action == 'open')) { |
---|
10 | tr = document.createElement('tr'); |
---|
11 | tr.id = 'ce' + commentId; |
---|
12 | var td = document.createElement('td'); |
---|
13 | td.colSpan = 6; |
---|
14 | td.className = 'expand'; |
---|
15 | tr.appendChild(td); |
---|
16 | |
---|
17 | // Get comment content |
---|
18 | $.get('services.php', { |
---|
19 | f: 'getCommentById', |
---|
20 | id: commentId |
---|
21 | }, function(data) { |
---|
22 | var rsp = $(data).children('rsp')[0]; |
---|
23 | |
---|
24 | if (rsp.attributes[0].value == 'ok') { |
---|
25 | var comment = $(rsp).find('comment_display_content').text(); |
---|
26 | |
---|
27 | if (comment) { |
---|
28 | $(td).append(comment); |
---|
29 | var comment_email = $(rsp).find('comment_email').text(); |
---|
30 | var comment_site = $(rsp).find('comment_site').text(); |
---|
31 | var comment_ip = $(rsp).find('comment_ip').text(); |
---|
32 | var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); |
---|
33 | |
---|
34 | $(td).append('<p><strong>' + dotclear.msg.website + |
---|
35 | '</strong> ' + comment_site + '<br />' + |
---|
36 | '<strong>' + dotclear.msg.email + '</strong> ' + comment_email + '<br />' + |
---|
37 | '<strong>' + dotclear.msg.ip_address + |
---|
38 | '</strong> <a href="comments.php?ip=' + comment_ip + '">' + comment_ip + '</a>' + |
---|
39 | '<br />' + comment_spam_disp + '</p>'); |
---|
40 | } |
---|
41 | } else { |
---|
42 | window.alert($(rsp).find('message').text()); |
---|
43 | } |
---|
44 | }); |
---|
45 | |
---|
46 | $(line).toggleClass('expand'); |
---|
47 | line.parentNode.insertBefore(tr, line.nextSibling); |
---|
48 | } else if (tr && tr.style.display == 'none' && (action == 'toggle' || action == 'open')) { |
---|
49 | $(tr).css('display', 'table-row'); |
---|
50 | $(line).addClass('expand'); |
---|
51 | } else if (tr && tr.style.display != 'none' && (action == 'toggle' || action == 'close')) { |
---|
52 | $(tr).css('display', 'none'); |
---|
53 | $(line).removeClass('expand'); |
---|
54 | } |
---|
55 | }; |
---|
56 | |
---|
57 | $(function() { |
---|
58 | $.expandContent({ |
---|
59 | line: $('#form-comments tr:not(.line)'), |
---|
60 | lines: $('#form-comments tr.line'), |
---|
61 | callback: dotclear.viewCommentContent |
---|
62 | }); |
---|
63 | $('.checkboxes-helpers').each(function() { |
---|
64 | dotclear.checkboxesHelpers(this, undefined, '#form-comments td input[type=checkbox]', '#form-comments #do-action'); |
---|
65 | }); |
---|
66 | $('#form-comments td input[type=checkbox]').enableShiftClick(); |
---|
67 | dotclear.commentsActionsHelper(); |
---|
68 | dotclear.condSubmit('#form-comments td input[type=checkbox]', '#form-comments #do-action'); |
---|
69 | $('form input[type=submit][name=delete_all_spam]').click(function() { |
---|
70 | return window.confirm(dotclear.msg.confirm_spam_delete); |
---|
71 | }); |
---|
72 | }); |
---|