summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorroot <root@chasey.guru.si>2015-10-02 17:44:45 +0200
committerroot <root@chasey.guru.si>2015-10-02 17:44:45 +0200
commit6377d405a668b4523041fb6cbb881e752b833eb0 (patch)
tree083a551c10ae4cae81e4b29bd46b75864b13c29a /js
parent06a105ed842e74b12a55be140e9f145ba860559d (diff)
moved gui language selection completely into the settings dropdown menu and (gui) language changes are now written to the DB once the save button is pressed
Diffstat (limited to 'js')
-rw-r--r--js/codeq/login.js1
-rw-r--r--js/codeq/settings.js41
2 files changed, 32 insertions, 10 deletions
diff --git a/js/codeq/login.js b/js/codeq/login.js
index 9be1c8c..391592b 100644
--- a/js/codeq/login.js
+++ b/js/codeq/login.js
@@ -20,6 +20,7 @@
$.merge(true, codeq.settings, sett);
if('lan' in sett && sett['lan'] in codeq.supportedLangs){
codeq.setLang(sett['lan']);
+ $("#gui_lang_select").val(sett['lan']);
}
codeq.globalStateMachine.transition('language');
diff --git a/js/codeq/settings.js b/js/codeq/settings.js
index 73bef14..9eb4366 100644
--- a/js/codeq/settings.js
+++ b/js/codeq/settings.js
@@ -2,17 +2,38 @@
* Created by robert on 9/29/15.
*/
(function(){
- $("#gui_lang_select").on("change",function() {
+
+ var guiLangSelect = $("#gui_lang_select");
+ var previousLang = guiLangSelect.val();
+ var closedWithSave = false;
+
+ guiLangSelect.on("change",function() {
var lang = $("#gui_lang_select").val();
if (lang in codeq.supportedLangs) {
- codeq.log.debug("Changing lang to:" + lang);
- codeq.comms.updateSettings({'lang': lang})
- .then(function (data) {
- if (data.code !== 0) throw new Error('Change language failed, code: ' + data.code + ', message: ' + data.message);
- codeq.log.debug("success with settings");
- codeq.setLang(lang);
- })
- .done();
+ codeq.setLang(lang);
}
- })
+ });
+
+ $("#settings_save_btn").on("click", function() {
+ closedWithSave = true;
+ });
+
+ $("#settings_dropdown_menu").on("shown.bs.dropdown", function() {
+ closedWithSave = false;
+ previousLang = codeq.getLang();
+ }).on("hidden.bs.dropdown", function() {
+ if(closedWithSave){
+ var lang = $("#gui_lang_select").val();
+ if (lang in codeq.supportedLangs) {
+ codeq.comms.updateSettings({'lang': lang})
+ .then(function (data) {
+ if (data.code !== 0) throw new Error('Change language failed, code: ' + data.code + ', message: ' + data.message);//error msg if something went wring while saving to db
+ })
+ .done();
+ }
+ }else{
+ $("#gui_lang_select").val(previousLang);
+ if (previousLang in codeq.supportedLangs) codeq.setLang(previousLang);
+ }
+ });
})(); \ No newline at end of file