Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 826286 - time label should update should wait for moztimechange

  • Loading branch information...
commit 1a007cc7f103fbebc8fd4d5a4a84d224208fbd2d 1 parent b2515d8
@timdream timdream authored
Showing with 12 additions and 8 deletions.
  1. +5 −7 apps/communications/ftu/js/ui.js
  2. +7 −1 shared/js/tz_select.js
View
12 apps/communications/ftu/js/ui.js
@@ -232,13 +232,11 @@ var UIManager = {
document.getElementById('tz-continent-label').textContent =
timezone.id.replace(/\/.*$/, '');
document.getElementById('tz-city-label').textContent = timezone.city;
- // it can take a few milliseconds before the TZ change is reflected on time
- setTimeout(function updateTime() {
- var f = new navigator.mozL10n.DateTimeFormat();
- var now = new Date();
- var timeLabel = document.getElementById('time-configuration-label');
- timeLabel.innerHTML = f.localeFormat(now, _('shortTimeFormat'));
- });
+
+ var f = new navigator.mozL10n.DateTimeFormat();
+ var now = new Date();
+ var timeLabel = document.getElementById('time-configuration-label');
+ timeLabel.innerHTML = f.localeFormat(now, _('shortTimeFormat'));
},
chooseNetwork: function ui_cn(event) {
View
8 shared/js/tz_select.js
@@ -103,7 +103,13 @@ function tzSelect(contSelector, citySelector, onchange) {
var req = settings.createLock().set({ 'time.timezone': tz.id });
if (onchange) {
req.onsuccess = function updateTZ_callback() {
- onchange(tz);
+ // Wait until the timezone is actually set
+ // before calling the callback.
+ window.addEventListener('moztimechange', function timeChanged() {
+ window.removeEventListener('moztimechange', timeChanged);
+
+ onchange(tz);
+ });
}
}
}, lastMozSettingValue);
Please sign in to comment.
Something went wrong with that request. Please try again.