diff options
author | techknowlogick <techknowlogick@gitea.io> | 2020-09-09 21:09:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 09:09:23 +0800 |
commit | 33ac0cc125b3f5031119e677775bf07d8c21419b (patch) | |
tree | 5d5a368873b8dfe31ba3ebb5d88467dddb734b25 | |
parent | fcc410c350db0241435856cfa8464a0ff01b3d0f (diff) | |
download | gitea-33ac0cc125b3f5031119e677775bf07d8c21419b.tar.gz gitea-33ac0cc125b3f5031119e677775bf07d8c21419b.zip |
Set language via AJAX (#12785)
* Set language via AJAX
* fix lint
-rw-r--r-- | templates/base/footer_content.tmpl | 4 | ||||
-rw-r--r-- | web_src/js/index.js | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl index b99a000894..ddd4f23649 100644 --- a/templates/base/footer_content.tmpl +++ b/templates/base/footer_content.tmpl @@ -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> diff --git a/web_src/js/index.js b/web_src/js/index.js index 73f040ac75..91b6936a50 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -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); @@ -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')); |