Set language via AJAX (#12785)

* Set language via AJAX

* fix lint
tokarchuk/v1.17
techknowlogick 4 years ago committed by GitHub
parent fcc410c350
commit 33ac0cc125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      templates/base/footer_content.tmpl
  2. 8
      web_src/js/index.js

@ -10,9 +10,9 @@
<div class="ui language bottom floating slide up dropdown link item"> <div class="ui language bottom floating slide up dropdown link item">
<i class="world icon"></i> <i class="world icon"></i>
<div class="text">{{.LangName}}</div> <div class="text">{{.LangName}}</div>
<div class="menu"> <div class="menu language-menu">
{{range .AllLangs}} {{range .AllLangs}}
<a lang="{{.Lang}}" class="item {{if eq $.Lang .Lang}}active selected{{end}}" href="{{if eq $.Lang .Lang}}#{{else}}{{$.Link}}?lang={{.Lang}}{{end}}">{{.Name}}</a> <a lang="{{.Lang}}" data-url="{{AppSubUrl}}/?lang={{.Lang}}" class="item {{if eq $.Lang .Lang}}active selected{{end}}">{{.Name}}</a>
{{end}} {{end}}
</div> </div>
</div> </div>

@ -2314,6 +2314,7 @@ $(document).ready(async () => {
$('.delete-button').on('click', showDeletePopup); $('.delete-button').on('click', showDeletePopup);
$('.add-all-button').on('click', showAddAllPopup); $('.add-all-button').on('click', showAddAllPopup);
$('.link-action').on('click', linkAction); $('.link-action').on('click', linkAction);
$('.language-menu a[lang]').on('click', linkLanguageAction);
$('.link-email-action').on('click', linkEmailAction); $('.link-email-action').on('click', linkEmailAction);
$('.delete-branch-button').on('click', showDeletePopup); $('.delete-branch-button').on('click', showDeletePopup);
@ -2602,6 +2603,13 @@ function linkAction(e) {
}); });
} }
function linkLanguageAction() {
const $this = $(this);
$.post($this.data('url')).always(() => {
window.location.reload();
});
}
function linkEmailAction(e) { function linkEmailAction(e) {
const $this = $(this); const $this = $(this);
$('#form-uid').val($this.data('uid')); $('#form-uid').val($this.data('uid'));

Loading…
Cancel
Save