Truncate long messages in support

pull/1/head
yflory 4 years ago
parent da9cccca88
commit 52393cafd6

@ -367,6 +367,29 @@ define([
]); ]);
}); });
var displayed = content.message;
var pre = h('pre.cp-support-message-content');
var $pre = $(pre);
var more;
if (content.message.length >= 3000) {
displayed = content.message.slice(0, 3000) + '...';
var expand = h('button.btn.btn-secondary', Messages.admin_support_open);
var collapse = h('button.btn.btn-secondary', Messages.admin_support_collapse);
var $collapse = $(collapse).hide();
var $expand = $(expand).click(function () {
$pre.text(content.message);
$expand.hide();
$collapse.show();
});
$collapse.click(function () {
$pre.text(displayed);
$collapse.hide();
$expand.show();
});
more = h('div', [expand, collapse]);
}
$pre.text(displayed);
var adminClass = (fromAdmin? '.cp-support-fromadmin': ''); var adminClass = (fromAdmin? '.cp-support-fromadmin': '');
var premiumClass = (fromPremium && !fromAdmin? '.cp-support-frompremium': ''); var premiumClass = (fromPremium && !fromAdmin? '.cp-support-frompremium': '');
var name = Util.fixHTML(content.sender.name) || Messages.anonymous; var name = Util.fixHTML(content.sender.name) || Messages.anonymous;
@ -377,7 +400,8 @@ define([
UI.setHTML(h('span'), Messages._getKey('support_from', [name])), UI.setHTML(h('span'), Messages._getKey('support_from', [name])),
h('span.cp-support-message-time', content.time ? new Date(content.time).toLocaleString() : '') h('span.cp-support-message-time', content.time ? new Date(content.time).toLocaleString() : '')
]), ]),
h('pre.cp-support-message-content', content.message), pre,
more,
h('div.cp-support-attachments', attachments), h('div.cp-support-attachments', attachments),
isAdmin ? userData : undefined, isAdmin ? userData : undefined,
]); ]);

Loading…
Cancel
Save