diff options
author | Aleš Smodiš <aless@guru.si> | 2015-10-04 19:45:55 +0200 |
---|---|---|
committer | Aleš Smodiš <aless@guru.si> | 2015-10-04 19:45:55 +0200 |
commit | 5877ffd8aaffdf3e416dbb36e766736b866e5963 (patch) | |
tree | d770d19c36b25039728079e6a0c3b0c7cfa26776 /js/codeq | |
parent | c3bbf004fc6c9278f954b0b6c69e2a256351a7d0 (diff) | |
parent | 6377d405a668b4523041fb6cbb881e752b833eb0 (diff) |
Merge branch 'master' of ssh://212.235.189.51:22122/codeq-web
Diffstat (limited to 'js/codeq')
-rw-r--r-- | js/codeq/login.js | 1 | ||||
-rw-r--r-- | js/codeq/settings.js | 41 |
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 |