[IMP] web_livechat: convert to 6.1 web module
bzr revid: chs@openerp.com-20110930150706-84xo4e21l58j9esw
This commit is contained in:
parent
32cdec2c72
commit
c71520ea0d
|
@ -1,5 +1,5 @@
|
|||
OpenERP, Open Source Management Solution
|
||||
Copyright © 2010 OpenERP SA (<http://openerp.com>).
|
||||
Copyright © 2010-2011 OpenERP SA (<http://openerp.com>).
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
|
||||
# Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -20,7 +20,7 @@
|
|||
##############################################################################
|
||||
{
|
||||
'name': 'Live Chat Support',
|
||||
'version': '1.1',
|
||||
'version': '2.0',
|
||||
'category': 'Tools',
|
||||
'complexity': "easy",
|
||||
'description': """
|
||||
|
@ -33,9 +33,15 @@ Add "Support" button in header from where you can access OpenERP Support.
|
|||
'website': 'http://openerp.com',
|
||||
'depends': ['base'],
|
||||
'update_xml': [],
|
||||
'js' : [
|
||||
'static/src/js/web_livechat.js',
|
||||
],
|
||||
'css' : [
|
||||
'static/src/css/lc.css',
|
||||
],
|
||||
'installable': True,
|
||||
'active': True,
|
||||
'web': True,
|
||||
'certificate': '0013762192410413',
|
||||
'images': ['images/web_livechat_support.jpeg'],
|
||||
'images': ['static/src/img/web_livechat_support.jpeg'],
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class publisher_warranty_contract(osv.osv):
|
|||
|
||||
@cache(skiparg=3)
|
||||
def get_default_livechat_text(self, cr, uid):
|
||||
return '<a href="http://www.openerp.com/support-or-publisher-warranty-contract" target="_blank"><img src="/web_livechat/static/images/busy.png"/>Support</a>'
|
||||
return '<a href="http://www.openerp.com/support-or-publisher-warranty-contract" target="_blank"><img src="/web_livechat/static/src/img/busy.png"/>Support</a>'
|
||||
|
||||
publisher_warranty_contract()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#livechat_status a.online {
|
||||
.livechat span.online {
|
||||
text-shadow: 0 0 0.2em #9a0404, 0 0 0.2em #9a0404, 0 0 0.2em #9a0404, 0 0 0.2em #9a0404;
|
||||
}
|
||||
#livechat_status img {
|
||||
.livechat img {
|
||||
vertical-align: middle;
|
||||
margin-right: 0.5em;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,100 @@
|
|||
/*############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2011 OpenERP SA (<http://openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
############################################################################*/
|
||||
|
||||
var __lc_buttons = [];
|
||||
|
||||
openerp.web_livechat = function (openerp) {
|
||||
|
||||
var QWeb = openerp.web.qweb;
|
||||
QWeb.add_template('/web_livechat/static/src/xml/web_livechat.xml');
|
||||
|
||||
|
||||
// tracking code from LiveChat
|
||||
var license = '1035052',
|
||||
params = '',
|
||||
lang = 'en',
|
||||
skill = '0';
|
||||
__lc_load = function (p) { if (typeof __lc_loaded != 'function')
|
||||
if (p) { var d = document, l = d.createElement('script'), s =
|
||||
d.getElementsByTagName('script')[0], a = unescape('%26'),
|
||||
h = ('https:' == d.location.protocol ? 'https://' : 'http://'); l.type = 'text/javascript'; l.async = true;
|
||||
l.src = h + 'gis' + p +'.livechatinc.com/gis.cgi?serverType=control'+a+'licenseID='+license+a+'jsonp=__lc_load';
|
||||
if (!(typeof p['server'] !== 'string' || typeof __lc_serv === 'string')) {
|
||||
l.src = h + (__lc_serv = p['server']) + '/licence/'+license+'/script.cgi?lang='+lang+a+'groups='+skill;
|
||||
l.src += (params == '') ? '' : a+'params='+encodeURIComponent(encodeURIComponent(params)); s.parentNode.insertBefore(l, s);
|
||||
} else setTimeout(__lc_load, 1000); if(typeof __lc_serv != 'string'){ s.parentNode.insertBefore(l, s);}
|
||||
} else __lc_load(Math.ceil(Math.random()*5)); }
|
||||
__lc_load();
|
||||
|
||||
|
||||
|
||||
openerp.web_livechat.Livechat = openerp.web.Widget.extend({
|
||||
template: 'Header-LiveChat',
|
||||
|
||||
start: function() {
|
||||
this._super();
|
||||
if (!this.session)
|
||||
return;
|
||||
var self = this;
|
||||
var pwc = new openerp.web.Model(self.session, "publisher_warranty.contract");
|
||||
pwc.get_func('get_default_livechat_text')().then(function(text) {
|
||||
self.$element.html(text);
|
||||
self.do_update();
|
||||
});
|
||||
|
||||
openerp.webclient.header.do_update.add_last(this.do_update);
|
||||
},
|
||||
|
||||
do_update: function() {
|
||||
var self = this;
|
||||
if (!this.session) {
|
||||
self.$element.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
var lc_id = _.uniqueId('livechat_');
|
||||
this.$element.attr('id', lc_id);
|
||||
|
||||
var pwc = new openerp.web.Model(self.session, "publisher_warranty.contract");
|
||||
|
||||
pwc.get_func('is_livechat_enable')().then(function(res) {
|
||||
console.log('res', res);
|
||||
if(!res) {
|
||||
//return;
|
||||
}
|
||||
|
||||
__lc_buttons.push({
|
||||
elementId: lc_id, //'livechat_status',
|
||||
language: 'en',
|
||||
skill: '0',
|
||||
type: 'text',
|
||||
labels: {
|
||||
online: '<img src="/web_livechat/static/src/img/available.png"/>Support',
|
||||
offline: '<img src="/web_livechat/static/src/img/away.png"/>Support',
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
openerp.webclient.livechat = new openerp.web_livechat.Livechat(openerp.webclient);
|
||||
openerp.webclient.livechat.prependTo('div.header_corner');
|
||||
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- vim:fdl=1:
|
||||
-->
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-name="Header-LiveChat">
|
||||
<div class="livechat block logout"></div>
|
||||
</t>
|
||||
</templates>
|
|
@ -1,5 +0,0 @@
|
|||
##############################################################################
|
||||
# This file is part of the "web-livechatinc-odoo" OpenERP module.
|
||||
# See LICENCE file at the root of the module folder.
|
||||
##############################################################################
|
||||
import editors
|
|
@ -1,93 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import openobject.templating
|
||||
|
||||
class BaseTemplateEditor(openobject.templating.TemplateEditor):
|
||||
templates = ['/openobject/controllers/templates/base.mako']
|
||||
|
||||
def edit(self, template, template_text):
|
||||
output = super(BaseTemplateEditor, self).edit(template, template_text)
|
||||
|
||||
end_head = output.index('</head>')
|
||||
|
||||
output = output[:end_head] + """
|
||||
<link rel="stylesheet" type="text/css" href="/web_livechat/static/css/lc.css"/>
|
||||
<%
|
||||
cp.session['livechat'] = rpc.RPCProxy('publisher_warranty.contract').is_livechat_enable()
|
||||
%>
|
||||
% if cp.session['livechat']:
|
||||
<script type="text/javascript">
|
||||
|
||||
(function() {
|
||||
var lc_params = '';
|
||||
var lc_lang = 'en';
|
||||
var lc_skill = '0';
|
||||
|
||||
var lc = document.createElement('script'); lc.type = 'text/javascript'; lc.async = true;
|
||||
var lc_src = ('https:' == document.location.protocol ? 'https://' : 'http://');
|
||||
lc_src += 'chat.livechatinc.net/licence/1035052/script.cgi?lang='+lc_lang+unescape('%26')+'groups='+lc_skill;
|
||||
lc_src += ((lc_params == '') ? '' : unescape('%26')+'params='+encodeURIComponent(encodeURIComponent(lc_params))); lc.src = lc_src;
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(lc, s);
|
||||
})();
|
||||
|
||||
</script>
|
||||
% endif
|
||||
""" + output[end_head:]
|
||||
|
||||
return output
|
||||
|
||||
|
||||
class HeaderTemplateEditor(openobject.templating.TemplateEditor):
|
||||
templates = ['/openerp/controllers/templates/header.mako']
|
||||
|
||||
|
||||
def edit(self, template, template_text):
|
||||
output = super(HeaderTemplateEditor, self).edit(template, template_text)
|
||||
|
||||
PATTERN = '<div id="corner">'
|
||||
corner = output.index(PATTERN) + len(PATTERN)
|
||||
|
||||
|
||||
output = output[:corner] + """
|
||||
<p id="livechat_status" class="logout">
|
||||
${ rpc.RPCProxy('publisher_warranty.contract').get_default_livechat_text() | n}
|
||||
</p>
|
||||
% if cp.session['livechat']:
|
||||
|
||||
<script type="text/javascript">
|
||||
var __lc_buttons = __lc_buttons || [];
|
||||
__lc_buttons.push({
|
||||
elementId: 'livechat_status',
|
||||
language: 'en',
|
||||
skill: '0',
|
||||
type: 'text',
|
||||
labels: {
|
||||
online: '<img src="/web_livechat/static/images/available.png"/>Support',
|
||||
offline: '<img src="/web_livechat/static/images/away.png"/>Support'
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
% endif
|
||||
""" + output[corner:]
|
||||
return output
|
||||
|
Loading…
Reference in New Issue