1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-31 20:11:54 +02:00

[ticket/17100] Refactor code to be more reusable

PHPBB3-17100
This commit is contained in:
Marc Alexander
2022-04-18 20:10:02 +02:00
parent 516d5313ad
commit 2dfe5ebe6d
16 changed files with 189 additions and 101 deletions

View File

@@ -2,15 +2,12 @@
<!-- IF S_SHOW_COPPA or S_REGISTRATION -->
{% if lang_options|length > 0 %}
{% if LANG_OPTIONS %}
<form method="post" action="{S_UCP_ACTION}" id="register">
<p class="rightside">
<label for="lang">{{ lang('LANGUAGE') ~ lang('COLON') }}</label>
<select name="lang" id="lang" title="{{ lang('LANGUAGE') }}">
{% for option in lang_options %}
<option value="{{ option.LANG_ISO }}"{% if option.SELECTED %} selected="selected"{% endif %}>{{ option.LANG_LOCAL_NAME }}</option>
{% endfor %}
</select>
<label for="{{ LANG_OPTIONS.id }}">{{ lang('LANGUAGE') ~ lang('COLON') }}</label>
{% import "macros/form_macros.twig" as form_macros %}
{{ form_macros.select(LANG_OPTIONS) }}
{S_HIDDEN_FIELDS}
</p>
</form>
@@ -21,7 +18,7 @@
/**
* Change language on change
*/
document.querySelector('#lang').addEventListener('change', (event) => {
document.querySelector("{{ '#' ~ LANG_OPTIONS.id }}").addEventListener('change', (event) => {
const langIso = event.target.value;
document.cookie = '{{ COOKIE_NAME }}_lang=' + langIso + '; path={{ COOKIE_PATH }}';
document.forms['register'].change_lang.value = langIso;