[ticket/17326] Updated js to use same as pages ext and fixed icon bug

PHPBB-17326
This commit is contained in:
Daniel James 2025-02-07 17:02:26 +00:00 committed by Marc Alexander
parent 97728da9be
commit 220b655150
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
3 changed files with 20 additions and 7 deletions

View file

@ -53,7 +53,7 @@
<dt><label for="bbcode_font_icon">{{ lang('BBCODE_FONT_ICON') }}</label><br><span>{{ lang('BBCODE_FONT_ICON_EXPLAIN', '<a href="https://fontawesome.com/v6/icons/" target="_blank">', '</a>') }}</span></dt>
<dd>
<input type="text" name="bbcode_font_icon" id="bbcode_font_icon" value="{{ BBCODE_FONT_ICON }}" />
{{ Icon('font', BBCODE_FONT_ICON, '', false, '', {'id':'bbcode_icon_preview'}) }}
{{ Icon('font', ' ', '', false, '', {'id':'bbcode_icon_preview'}) }}
</dd>
</dl>
</fieldset>

View file

@ -279,11 +279,24 @@ function parse_document(container)
});
// Live update BBCode font icon preview
$('#bbcode_font_icon').on('keyup', function(e) {
const iconName = $(this).val();
if (iconName.match(/^[\w-]+$/)) {
$('#bbcode_icon_preview').attr('class', "o-icon o-icon-font fa-fw fas icon fa-" + $(this).val());
}
const updateIconClass = (element, newClass) => {
element.classList.forEach(className => {
if (className.startsWith('fa-') && className !== 'fa-fw') {
element.classList.remove(className);
}
});
element.classList.add(`fa-${newClass}`);
};
const pageIconFont = document.getElementById('bbcode_font_icon');
pageIconFont.addEventListener('keyup', function() {
updateIconClass(this.nextElementSibling, this.value);
});
pageIconFont.addEventListener('blur', function() {
updateIconClass(this.nextElementSibling, this.value);
});
});
})(jQuery);

View file

@ -103,7 +103,7 @@ class acp_bbcodes
'S_EDIT_BBCODE' => true,
'U_BACK' => $this->u_action,
'U_ACTION' => $this->u_action . '&amp;action=' . (($action == 'add') ? 'create' : 'modify') . (($bbcode_id) ? "&amp;bbcode=$bbcode_id" : ''),
'L_BBCODE_USAGE_EXPLAIN' => sprintf($user->lang['BBCODE_USAGE_EXPLAIN'], '<a href="#down">', '</a>'),
'BBCODE_MATCH' => $bbcode_match,
'BBCODE_TPL' => $bbcode_tpl,
'BBCODE_HELPLINE' => $bbcode_helpline,