2016-12-14 03:01:05 +00:00
|
|
|
/* eslint-disable no-param-reassign */
|
|
|
|
|
2016-08-08 13:04:18 +00:00
|
|
|
((global) => {
|
|
|
|
const MAX_MESSAGE_LENGTH = 500;
|
|
|
|
const MESSAGE_CELL_SELECTOR = '.abuse-reports .message';
|
|
|
|
|
|
|
|
class AbuseReports {
|
|
|
|
constructor() {
|
|
|
|
$(MESSAGE_CELL_SELECTOR).each(this.truncateLongMessage);
|
|
|
|
$(document)
|
|
|
|
.off('click', MESSAGE_CELL_SELECTOR)
|
|
|
|
.on('click', MESSAGE_CELL_SELECTOR, this.toggleMessageTruncation);
|
|
|
|
}
|
|
|
|
|
|
|
|
truncateLongMessage() {
|
2016-08-13 11:20:57 +00:00
|
|
|
const $messageCellElement = $(this);
|
|
|
|
const reportMessage = $messageCellElement.text();
|
2016-08-08 13:04:18 +00:00
|
|
|
if (reportMessage.length > MAX_MESSAGE_LENGTH) {
|
|
|
|
$messageCellElement.data('original-message', reportMessage);
|
|
|
|
$messageCellElement.data('message-truncated', 'true');
|
2016-08-18 13:22:14 +00:00
|
|
|
$messageCellElement.text(global.text.truncate(reportMessage, MAX_MESSAGE_LENGTH));
|
2016-08-08 13:04:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleMessageTruncation() {
|
2016-08-13 11:20:57 +00:00
|
|
|
const $messageCellElement = $(this);
|
|
|
|
const originalMessage = $messageCellElement.data('original-message');
|
2016-08-08 13:04:18 +00:00
|
|
|
if (!originalMessage) return;
|
|
|
|
if ($messageCellElement.data('message-truncated') === 'true') {
|
|
|
|
$messageCellElement.data('message-truncated', 'false');
|
|
|
|
$messageCellElement.text(originalMessage);
|
|
|
|
} else {
|
|
|
|
$messageCellElement.data('message-truncated', 'true');
|
2016-08-08 23:04:39 +00:00
|
|
|
$messageCellElement.text(`${originalMessage.substr(0, (MAX_MESSAGE_LENGTH - 3))}...`);
|
2016-08-08 13:04:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
global.AbuseReports = AbuseReports;
|
2016-08-24 11:25:06 +00:00
|
|
|
})(window.gl || (window.gl = {}));
|