[FIX] mail: correct announcement bar

bzr revid: chs@openerp.com-20131202114516-u0u44l3xbkk1zcbx
This commit is contained in:
Christophe Simonis 2013-12-02 12:45:16 +01:00
parent f07e01f491
commit eba79e46a5
4 changed files with 62 additions and 29 deletions

View File

@ -81,6 +81,7 @@ Main Features
'css': [
'static/src/css/mail.css',
'static/src/css/mail_group.css',
'static/src/css/announcement.css',
],
'js': [
'static/lib/jquery.expander/jquery.expander.js',

View File

@ -0,0 +1,3 @@
.openerp .annoucement_bar {
display: none;
}

View File

@ -1,21 +1,50 @@
openerp_announcement = function(instance) {
var _t = instance.web._t;
instance.web.WebClient.include({
show_application: function() {
var self = this;
this._super();
var config_parameter = new instance.web.Model('ir.config_parameter');
return config_parameter.call('get_param', ['database.uuid', false]).then(function(result) {
var head = $('head');
head.append($('<link />')
.attr({
rel : 'stylesheet',
type: 'text/css',
href: 'http://127.0.0.1.xip.io:8369/openerp_enterprise/'+result+'.css',
media: 'all',
})
);
});
instance.web.WebClient.include({
show_application: function() {
return $.when(this._super.apply(this, arguments)).then(this.proxy('show_annoucement_bar'));
},
_ab_location: function(dbuuid) {
return _.str.sprintf('https://services.openerp.com/openerp-enterprise/ab/css/%s.css', dbuuid);
},
show_annoucement_bar: function() {
if (this.session.get_cookie('ab') === 'c') {
return;
}
var self = this;
var config_parameter = new instance.web.Model('ir.config_parameter');
var $bar = this.$el.find('.announcement_bar');
return config_parameter.call('get_param', ['database.uuid', false]).then(function(dbuuid) {
if (!dbuuid) {
return;
}
var $css = $('<link />').attr({
rel : 'stylesheet',
type: 'text/css',
media: 'all',
href: self._ab_location(dbuuid)
});
$css.on('load', function() {
var close = function() {
var data = window.getComputedStyle($bar.find('.data')[0], ':before').content || "'{}'";
var delim = data[0];
data = data.slice(1, data.length - 1).replace(new RegExp('\\\\'+delim, 'g'), delim);
try {
data = JSON.parse(data);
} catch(_e) {
data = {};
}
var ttl = data.close_ttl || 24*60*60;
self.session.set_cookie('ab', 'c', ttl);
$bar.slideUp('slow');
};
$bar.on('dblclick', close);
$bar.find('.close').on('click', close);
self.trigger('ab_loaded', $bar);
});
$('head').append($css);
});
}
});
};
};

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="WebClient">
<t t-jquery="table.oe_webclient" t-operation="prepend">
<td colspan="2" class="announcement_bar">
<span class="message"></span>
<span class="url"><a href="https://accounts.openerp.com" target="_blank"></a></span>
</td>
</t>
</t>
</templates>
<t t-extend="WebClient">
<t t-jquery="table.oe_webclient" t-operation="prepend">
<td colspan="2" class="announcement_bar">
<span class="message"></span>
<span class="url"><a href="https://services.openerp.com/openerp-enterprise/ab/register" target="_blank"></a></span>
<span class="close"></span>
<span class="data"></span>
</td>
</t>
</t>
</templates>