Dotclear

source: admin/js/_comments.js @ 3880:e6d1f6d9d7df

Revision 3880:e6d1f6d9d7df, 1.8 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Use let and const rather than var (ES2015/ES6), use template string where is more efficient

RevLine 
[3706]1/*global $, dotclear */
2'use strict';
[2531]3
[3878]4dotclear.viewCommentContent = function(line, action, e) {
[3706]5  action = action || 'toggle';
[3878]6  if ($(line).attr('id') == undefined) {
7    return;
8  }
9
[3880]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'));
[2566]16
[3878]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');
[3880]23        tr.id = lineId;
24        const td = document.createElement('td');
[3878]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);
[3706]31      } else {
[3878]32        // No content, content not found or server error
33        $(line).removeClass('expand');
[3706]34      }
[3878]35    }, {
[3880]36      clean: clean
[3706]37    });
[3878]38  } else {
39    $(tr).toggle();
[3706]40    $(line).toggleClass('expand');
41  }
[0]42};
43
44$(function() {
[3706]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  });
[0]59});
Note: See TracBrowser for help on using the repository browser.

Sites map