[FIX] im_livechat : add a cookie to prevent the automatic opening on a auto-popup page. Each time the page is refresh, the auto-popup was triggered, which can be very intrusive for users. The cookie remember the auto-popup is desactivate for an hour, for every page. The button stay displayed on page.

This commit is contained in:
Jérome Maes
2015-03-31 13:19:16 +02:00
parent 4f7f47988a
commit eb5de33eac
@@ -61,6 +61,7 @@
}else{
this._super.apply(this, arguments);
openerp.set_cookie(im_livechat.COOKIE_NAME, "", -1);
openerp.set_cookie('im_livechat_auto_popup', JSON.stringify(false), 60*60);
}
},
});
@@ -132,7 +133,8 @@
build_button: function(channel, options, session, rule){
var button = new im_livechat.ChatButton(null, channel, options, session);
button.appendTo($("body"));
if (rule.action === 'auto_popup'){
var auto_popup_cookie = openerp.get_cookie('im_livechat_auto_popup') ? JSON.parse(openerp.get_cookie('im_livechat_auto_popup')) : true;
if (rule.action === 'auto_popup' && auto_popup_cookie){
setTimeout(function() {
button.click();
}, rule.auto_popup_timer*1000);