| 1 | /*global $, dotclear */ | 
|---|
| 2 | 'use strict'; | 
|---|
| 3 |  | 
|---|
| 4 | dotclear.viewCommentContent = function(line, action, e) { | 
|---|
| 5 | action = action || 'toggle'; | 
|---|
| 6 | if ($(line).attr('id') == undefined) { | 
|---|
| 7 | return; | 
|---|
| 8 | } | 
|---|
| 9 |  | 
|---|
| 10 | const commentId = $(line).attr('id').substr(1); | 
|---|
| 11 | const lineId = `ce${commentId}`; | 
|---|
| 12 | let tr = document.getElementById(lineId); | 
|---|
| 13 |  | 
|---|
| 14 | // If meta key down or it's a spam then display content HTML code | 
|---|
| 15 | const clean = (e.metaKey || $(line).hasClass('sts-junk')); | 
|---|
| 16 |  | 
|---|
| 17 | if (!tr) { | 
|---|
| 18 | // Get comment content if possible | 
|---|
| 19 | dotclear.getCommentContent(commentId, function(content) { | 
|---|
| 20 | if (content) { | 
|---|
| 21 | // Content found | 
|---|
| 22 | tr = document.createElement('tr'); | 
|---|
| 23 | tr.id = lineId; | 
|---|
| 24 | const td = document.createElement('td'); | 
|---|
| 25 | td.colSpan = $(line).children('td').length; | 
|---|
| 26 | td.className = 'expand'; | 
|---|
| 27 | tr.appendChild(td); | 
|---|
| 28 | $(td).append(content); | 
|---|
| 29 | $(line).addClass('expand'); | 
|---|
| 30 | line.parentNode.insertBefore(tr, line.nextSibling); | 
|---|
| 31 | } else { | 
|---|
| 32 | // No content, content not found or server error | 
|---|
| 33 | $(line).removeClass('expand'); | 
|---|
| 34 | } | 
|---|
| 35 | }, { | 
|---|
| 36 | clean: clean | 
|---|
| 37 | }); | 
|---|
| 38 | } else { | 
|---|
| 39 | $(tr).toggle(); | 
|---|
| 40 | $(line).toggleClass('expand'); | 
|---|
| 41 | } | 
|---|
| 42 | }; | 
|---|
| 43 |  | 
|---|
| 44 | $(function() { | 
|---|
| 45 | $.expandContent({ | 
|---|
| 46 | line: $('#form-comments tr:not(.line)'), | 
|---|
| 47 | lines: $('#form-comments tr.line'), | 
|---|
| 48 | callback: dotclear.viewCommentContent | 
|---|
| 49 | }); | 
|---|
| 50 | $('.checkboxes-helpers').each(function() { | 
|---|
| 51 | dotclear.checkboxesHelpers(this, undefined, '#form-comments td input[type=checkbox]', '#form-comments #do-action'); | 
|---|
| 52 | }); | 
|---|
| 53 | $('#form-comments td input[type=checkbox]').enableShiftClick(); | 
|---|
| 54 | dotclear.commentsActionsHelper(); | 
|---|
| 55 | dotclear.condSubmit('#form-comments td input[type=checkbox]', '#form-comments #do-action'); | 
|---|
| 56 | $('form input[type=submit][name=delete_all_spam]').click(function() { | 
|---|
| 57 | return window.confirm(dotclear.msg.confirm_spam_delete); | 
|---|
| 58 | }); | 
|---|
| 59 | }); | 
|---|