Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set language via AJAX #12785

Merged
merged 3 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/base/footer_content.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<div class="ui language bottom floating slide up dropdown link item">
<i class="world icon"></i>
<div class="text">{{.LangName}}</div>
<div class="menu">
<div class="menu language-menu">
{{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}}
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,7 @@ $(document).ready(async () => {
$('.delete-button').on('click', showDeletePopup);
$('.add-all-button').on('click', showAddAllPopup);
$('.link-action').on('click', linkAction);
$('.language-menu a[lang]').on('click', linkLanguageAction);
$('.link-email-action').on('click', linkEmailAction);

$('.delete-branch-button').on('click', showDeletePopup);
Expand Down Expand Up @@ -2602,6 +2603,13 @@ function linkAction(e) {
});
}

function linkLanguageAction() {
const $this = $(this);
$.post($this.data('url')).always(() => {
window.location.reload();
});
}

function linkEmailAction(e) {
const $this = $(this);
$('#form-uid').val($this.data('uid'));
Expand Down