From 91ef2c812a15400cc8f251e8165728a363d235b0 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 10 Sep 2015 18:53:26 +0200 Subject: [PATCH] Small code improvement --- program/js/app.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index e2e323344..af484071b 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -510,8 +510,11 @@ function rcube_webmail() break; case 'login': - var input_user = $('#rcmloginuser'); - input_user.bind('keyup', function(e){ return ref.login_user_keyup(e); }); + var tz, tz_name, jstz = window.jstz, + input_user = $('#rcmloginuser'), + input_tz = $('#rcmlogintz'); + + input_user.bind('keyup', function(e) { return ref.login_user_keyup(e); }); if (input_user.val() == '') input_user.focus(); @@ -519,14 +522,10 @@ function rcube_webmail() $('#rcmloginpwd').focus(); // detect client timezone - if (window.jstz) { - var timezone = jstz.determine(); - if (timezone.name()) - $('#rcmlogintz').val(timezone.name()); - } - else { - $('#rcmlogintz').val(new Date().getStdTimezoneOffset() / -60); - } + if (jstz && (tz = jstz.determine())) + tz_name = tz.name(); + + input_tz.val(tz_name ? tz_name : (new Date().getStdTimezoneOffset() / -60)); // display 'loading' message on form submit, lock submit button $('form').submit(function () {