Dotclear

source: admin/js/_comments.js @ 3878:fd5264175804

Revision 3878:fd5264175804, 1.7 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Harmonize scripts used to display entries/comments/trackbacks content in lists - Spam content is displayed as HTML code only, meta key may be used to display other content HTML code (meta key = cmd key on MacOS, windows key on Windows, ...) - Server errors are now basically reported (more info in console log, as timeout, offline, …) to the user

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

Sites map