mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-22 07:51:00 +00:00
Persistent change language dialog on click
This commit is contained in:
parent
54c67ba2d7
commit
a67db35d61
2 changed files with 39 additions and 17 deletions
|
@ -56,8 +56,9 @@ h3.header {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#nav:hover #change-language:hover + .locale-panel,
|
#nav:hover .change-language:hover + .locale-panel,
|
||||||
#nav-mobile:hover #change-language:hover + .locale-panel{
|
#nav-mobile:hover .change-language:hover + .locale-panel,
|
||||||
|
.change-language.clicked + .locale-panel{
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,9 +69,9 @@
|
||||||
{% if api_keys %}
|
{% if api_keys %}
|
||||||
<li><a class="noline" href="javascript:setApiKey()" title="{{ _h('Set API Key') }}" aria-label="{{ _h('Set API Key') }}"><i class="material-icons">vpn_key</i></a></li>
|
<li><a class="noline" href="javascript:setApiKey()" title="{{ _h('Set API Key') }}" aria-label="{{ _h('Set API Key') }}"><i class="material-icons">vpn_key</i></a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li id="change-language"><a class="noline" href="javascript:void(0)" title="{{ _h('Change language') }}"><i class="material-icons">language</i></a>
|
<li class="change-language"><a class="noline" href="javascript:void(0)" title="{{ _h('Change language') }}"><i class="material-icons">language</i></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="locale-panel" id="locale-panel">
|
<li class="locale-panel">
|
||||||
<select id="locales" onchange="changeLocale(this)">
|
<select id="locales" onchange="changeLocale(this)">
|
||||||
{% for l in available_locales %}<option value="{{ l['code'] }}" {{ 'selected' if current_locale == l['code'] else ''}}>{{ l['name'] }}</option>{% endfor %}
|
{% for l in available_locales %}<option value="{{ l['code'] }}" {{ 'selected' if current_locale == l['code'] else ''}}>{{ l['name'] }}</option>{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
@ -80,6 +80,9 @@
|
||||||
{% endset %}
|
{% endset %}
|
||||||
{{ menulinks }}
|
{{ menulinks }}
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul id="nav-mobile" class="sidenav">
|
||||||
|
{{ menulinks }}
|
||||||
|
</ul>
|
||||||
<script>
|
<script>
|
||||||
var localeLinks = {
|
var localeLinks = {
|
||||||
{% for al in alternate_locales %}"{{ al.lang }}": "{{ al.link }}"{% if not loop.last %},{% endif %}
|
{% for al in alternate_locales %}"{{ al.lang }}": "{{ al.link }}"{% if not loop.last %},{% endif %}
|
||||||
|
@ -91,11 +94,29 @@
|
||||||
if (localeLinks[lang]) location.href = localeLinks[lang];
|
if (localeLinks[lang]) location.href = localeLinks[lang];
|
||||||
else location.href = '?lang=' + slt.value;
|
else location.href = '?lang=' + slt.value;
|
||||||
}
|
}
|
||||||
</script>
|
|
||||||
|
|
||||||
<ul id="nav-mobile" class="sidenav">
|
var btnChangeLangs = document.getElementsByClassName("change-language");
|
||||||
{{ menulinks }}
|
var localePanels = document.getElementsByClassName("locale-panel");
|
||||||
</ul>
|
console.log(btnChangeLangs);
|
||||||
|
for (var i = 0; i < btnChangeLangs.length; i++){
|
||||||
|
(function(btn){
|
||||||
|
btn.addEventListener('click', function(e){
|
||||||
|
e.stopPropagation();
|
||||||
|
btn.classList.toggle('clicked');
|
||||||
|
});
|
||||||
|
})(btnChangeLangs[i]);
|
||||||
|
}
|
||||||
|
for (var i = 0; i < localePanels.length; i++){
|
||||||
|
localePanels[i].addEventListener('click', function(e){
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
document.addEventListener('click', function(){
|
||||||
|
for (var i = 0; i < btnChangeLangs.length; i++){
|
||||||
|
btnChangeLangs[i].classList.remove('clicked');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
Loading…
Reference in a new issue