summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2012-11-22 16:11:25 +0100
committerFabien Meghazi <fme@openerp.com>2012-11-22 16:11:25 +0100
commit04ee6498553a34e9ecf691bbe9cd367d2980d1b5 (patch)
tree881179f159e21a09944f256bef798920a6339518 /addons/web/static/src/js
parent9b59a88a5cf04ca529f84320f2cb5b1415f722b8 (diff)
[ADD] When application starts, warn the user if it's timezone does not match it's browser's timezone
bzr revid: fme@openerp.com-20121122151125-a8fybzmqyw8uvr7h
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome.js32
1 files changed, 28 insertions, 4 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index f355322b489..b7cbbe37c9f 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -24,7 +24,7 @@ instance.web.Notification = instance.web.Widget.extend({
if (sticky) {
opts.expires = false;
}
- this.$el.notify('create', {
+ return this.$el.notify('create', {
title: title,
text: text
}, opts);
@@ -35,7 +35,7 @@ instance.web.Notification = instance.web.Widget.extend({
if (sticky) {
opts.expires = false;
}
- this.$el.notify('create', 'oe_notification_alert', {
+ return this.$el.notify('create', 'oe_notification_alert', {
title: title,
text: text
}, opts);
@@ -1151,6 +1151,30 @@ instance.web.WebClient = instance.web.Client.extend({
self.user_menu.do_update();
self.bind_hashchange();
self.set_title();
+ self.check_timezone();
+ },
+ check_timezone: function() {
+ var self = this;
+ var user_offset = instance.session.user_context.tz_offset;
+ var offset = -(new Date().getTimezoneOffset());
+ // _.str.sprintf()'s zero front padding is buggy with signed decimals, so doing it manually
+ var browser_offset = (offset < 0) ? "-" : "+";
+ browser_offset += _.str.sprintf("%02d", Math.abs(offset / 60));
+ browser_offset += _.str.sprintf("%02d", Math.abs(offset % 60));
+ if (browser_offset !== user_offset) {
+ var notification = this.do_warn(_t("Timezone"), QWeb.render('WebClient.timezone_notification', {
+ user_timezone: instance.session.user_context.tz || 'UTC',
+ user_offset: user_offset,
+ browser_offset: browser_offset,
+ }), true);
+ notification.element.find('.oe_webclient_timezone_notification').on('click', function() {
+ notification.close();
+ }).find('a').on('click', function() {
+ notification.close();
+ self.user_menu.on_menu_settings();
+ return false;
+ });
+ }
},
destroy_content: function() {
_.each(_.clone(this.getChildren()), function(el) {
@@ -1167,11 +1191,11 @@ instance.web.WebClient = instance.web.Client.extend({
},
do_notify: function() {
var n = this.notification;
- n.notify.apply(n, arguments);
+ return n.notify.apply(n, arguments);
},
do_warn: function() {
var n = this.notification;
- n.warn.apply(n, arguments);
+ return n.warn.apply(n, arguments);
},
on_logout: function() {
var self = this;