mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 05:18:52 +00:00
[ticket/13713] Move mentions avatar template HTML to html file
PHPBB3-13713
This commit is contained in:
parent
5c2ada19c8
commit
51097d937a
4 changed files with 24 additions and 7 deletions
|
@ -8,6 +8,8 @@
|
||||||
// ]]>
|
// ]]>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{% include 'mentions_templates.html' %}
|
||||||
|
|
||||||
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js -->
|
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js -->
|
||||||
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/tribute.min.js -->
|
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/tribute.min.js -->
|
||||||
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/mentions.js -->
|
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/mentions.js -->
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
const mentionNamesLimit = $mentionDataContainer.data('mentionNamesLimit');
|
const mentionNamesLimit = $mentionDataContainer.data('mentionNamesLimit');
|
||||||
const mentionTopicId = $mentionDataContainer.data('topicId');
|
const mentionTopicId = $mentionDataContainer.data('topicId');
|
||||||
const mentionUserId = $mentionDataContainer.data('userId');
|
const mentionUserId = $mentionDataContainer.data('userId');
|
||||||
|
const $mentionAvatarTemplate = $('[data-id="mentions-avatar-span"]');
|
||||||
let queryInProgress = null;
|
let queryInProgress = null;
|
||||||
const cachedNames = [];
|
const cachedNames = [];
|
||||||
const cachedAll = [];
|
const cachedAll = [];
|
||||||
|
@ -51,15 +52,26 @@
|
||||||
* @return {string} Avatar HTML
|
* @return {string} Avatar HTML
|
||||||
*/
|
*/
|
||||||
function getAvatar(data, type) {
|
function getAvatar(data, type) {
|
||||||
const avatarToHtml = avatarData => {
|
if (data.html === '' && data.src === '') {
|
||||||
if (avatarData.html === '') {
|
return defaultAvatar(type);
|
||||||
return '<img class="avatar" src="' + avatarData.src + '" width="' + avatarData.width + '" height="' + avatarData.height + '" alt="' + avatarData.title + '" />';
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return avatarData.html;
|
const $avatarSpan = $mentionAvatarTemplate.clone();
|
||||||
};
|
$avatarSpan.removeAttr('style'); // Remove automatically added display: none
|
||||||
|
|
||||||
return data.html === '' && data.src === '' ? defaultAvatar(type) : '<span class=\'mention-media-avatar\'>' + avatarToHtml(data) + '</span>';
|
if (data.html === '') {
|
||||||
|
const $avatarImg = $avatarSpan.find('img');
|
||||||
|
$avatarImg.attr({
|
||||||
|
src: data.src,
|
||||||
|
width: data.width,
|
||||||
|
height: data.height,
|
||||||
|
alt: data.title,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$avatarSpan.html(data.html);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $avatarSpan.get(0).outerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
1
phpBB/styles/prosilver/template/mentions_templates.html
Normal file
1
phpBB/styles/prosilver/template/mentions_templates.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<template data-id="mentions-avatar-span"><span class="mention-media-avatar"><img class="avatar" src="" width="" height="" alt="" /></span></template>
|
|
@ -26,6 +26,8 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{% include 'mentions_templates.html' %}
|
||||||
|
|
||||||
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js -->
|
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js -->
|
||||||
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/tribute.min.js -->
|
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/tribute.min.js -->
|
||||||
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/mentions.js -->
|
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/mentions.js -->
|
||||||
|
|
Loading…
Add table
Reference in a new issue