summaryrefslogtreecommitdiff
path: root/addons/im_livechat/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/im_livechat/static/src')
-rw-r--r--addons/im_livechat/static/src/css/im_livechat.css31
-rw-r--r--addons/im_livechat/static/src/img/bad.pngbin962 -> 0 bytes
-rw-r--r--addons/im_livechat/static/src/img/good.pngbin886 -> 0 bytes
-rw-r--r--addons/im_livechat/static/src/img/ok.pngbin739 -> 0 bytes
-rw-r--r--addons/im_livechat/static/src/js/im_livechat.js103
-rw-r--r--addons/im_livechat/static/src/xml/im_livechat.xml28
6 files changed, 81 insertions, 81 deletions
diff --git a/addons/im_livechat/static/src/css/im_livechat.css b/addons/im_livechat/static/src/css/im_livechat.css
index 19a20483308..becceb34f7f 100644
--- a/addons/im_livechat/static/src/css/im_livechat.css
+++ b/addons/im_livechat/static/src/css/im_livechat.css
@@ -1,45 +1,42 @@
-/* feedback */
-.oe_im_chatview_feedback{
+/* Livechat Rating : feedback smiley */
+.oe_im_chatview .oe_livechat_rating{
padding: 15px;
vertical-align: middle;
}
-.oe_im_chatview_feedback .oe_im_feedback_text {
+.oe_im_chatview .oe_livechat_rating .oe_im_feedback_text {
color: white;
vertical-align: middle;
font-size: 14px;
}
-.oe_im_chatview_feedback .oe_im_feedback_small_text {
- color: white;
- vertical-align: middle;
- font-size: 12px;
-}
-.oe_im_chatview_feedback .oe_im_feedback_choices{
+.oe_im_chatview .oe_livechat_rating .oe_livechat_rating_choices{
height:40px;
text-align: center;
- margin: 10px 0;
+ margin: 10px 0 30px 0;
}
-.oe_im_chatview_feedback .oe_im_feedback_choices a{
+.oe_im_chatview .oe_livechat_rating .oe_livechat_rating_choices img{
+ width: 50px;
+ opacity: 0.60;
cursor: pointer;
margin: 5px;
- opacity: 0.65;
}
-.oe_im_chatview_feedback .oe_im_feedback_choices a:hover{
+.oe_im_chatview .oe_livechat_rating .oe_livechat_rating_choices img:hover{
opacity:1;
}
-.oe_im_chatview_feedback .oe_im_feedback_choices a.selected{
+.oe_im_chatview .oe_livechat_rating .oe_livechat_rating_choices img.selected{
opacity: 1;
}
/* feedback reason */
-.oe_im_feedback_reason {
+.oe_im_chatview .oe_livechat_rating .oe_livechat_rating_reason {
margin: 10px 0;
+ display: none; /* hidden by default */
}
-.oe_im_feedback_reason textarea {
+.oe_im_chatview .oe_livechat_rating .oe_livechat_rating_reason textarea {
width: 100%;
height: 70px;
resize: none;
}
-.oe_im_feedback_btn input{
+.oe_im_chatview .oe_livechat_rating .oe_livechat_rating_reason_button input{
float: right;
margin-left : 10px;
}
diff --git a/addons/im_livechat/static/src/img/bad.png b/addons/im_livechat/static/src/img/bad.png
deleted file mode 100644
index 485a59bc3e5..00000000000
--- a/addons/im_livechat/static/src/img/bad.png
+++ /dev/null
Binary files differ
diff --git a/addons/im_livechat/static/src/img/good.png b/addons/im_livechat/static/src/img/good.png
deleted file mode 100644
index 9ae6cce415f..00000000000
--- a/addons/im_livechat/static/src/img/good.png
+++ /dev/null
Binary files differ
diff --git a/addons/im_livechat/static/src/img/ok.png b/addons/im_livechat/static/src/img/ok.png
deleted file mode 100644
index b79a83240d6..00000000000
--- a/addons/im_livechat/static/src/img/ok.png
+++ /dev/null
Binary files differ
diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js
index 188248b7d90..0ff35dde366 100644
--- a/addons/im_livechat/static/src/js/im_livechat.js
+++ b/addons/im_livechat/static/src/js/im_livechat.js
@@ -1,7 +1,3 @@
-/*
- This file must compile in EcmaScript 3 and work in IE7.
-*/
-
(function() {
"use strict";
@@ -20,9 +16,7 @@
this._super.apply(this, arguments);
this.shown = true;
this.loading_history = true; // since the session is kept after a refresh, anonymous can reload their history
-
- this.feedback = false;
- this.rating = false;
+ this.feedback = false;
},
define_options: function(){
// no options for anonymous user
@@ -57,51 +51,17 @@
openerp.set_cookie(im_livechat.COOKIE_NAME, JSON.stringify(session), 60*60);
},
click_close: function(event) {
- this.$('.oe_im_chatview_input').attr('disabled','disabled');
if(!this.feedback && (this.get('messages').length > 1)){
- this.feedback = true;
- this.$(".oe_im_chatview_content").html(openerp.qweb.render("support_feedback"));
- this.$('.oe_im_feedback_choices a').on('click', _.bind(this.choose_feedback, this));
- this.$('.oe_im_chatview_feedback #submit').on('click', _.bind(this.submit_feedback, this));
+ this.feedback = new im_livechat.Feedback(this);
+ this.$(".oe_im_chatview_content").empty();
+ this.$(".oe_im_chatview_input").prop('disabled', true);
+ this.feedback.appendTo( this.$(".oe_im_chatview_content"));
+ // bind event to close conversation
+ this.feedback.on("feedback_sent", this, this.click_close);
}else{
- if(this.rating){
- this.send_feedback(this.rating);
- }
- // delete cookie
- openerp.set_cookie(im_livechat.COOKIE_NAME, "", -1);
this._super.apply(this, arguments);
}
},
- choose_feedback: function(e){
- var self = this;
- this.rating = parseInt($(e.currentTarget).data('value'));
- this.$('.oe_im_feedback_choices a').removeClass('selected');
- this.$('.oe_im_feedback_choices a[data-value="'+this.rating+'"]').addClass('selected');
- },
- submit_feedback: function(e){
- var self = this;
- if(this.rating){
- var reason = self.$('.oe_im_chatview_feedback textarea').val();
- if(this.rating > 1){
- this.send_feedback(this.rating, reason);
- }else{
- if(reason){
- this.send_feedback(this.rating, reason);
- }else{
- self.$('.oe_im_chatview_feedback textarea').css('border', 'red solid 2px');
- }
- }
- }else{
- this.feedback = false;
- }
- },
- send_feedback: function(rate, reason){
- var self = this;
- openerp.session.rpc("/im_livechat/feedback", {uuid: this.get('session').uuid, rating: rate, reason : reason}).then(function(res) {
- self.$(".oe_im_chatview_feedback").html($(document.createElement('div')).addClass("oe_im_feedback_text").html(_t("Thanks you for your feedback. You can close the chat window now.")));
- });
- this.rating = false;
- }
});
// To avoid exeption when the anonymous has close his
@@ -138,11 +98,14 @@
openerp.session = new openerp.Session(null, server_url, { use_cors: false });
this.load_template(db, channel, options, rule);
},
+ _get_template_list: function(){
+ return ['/im_chat/static/src/xml/im_chat.xml', '/im_livechat/static/src/xml/im_livechat.xml'];
+ },
load_template: function(db, channel, options, rule){
var self = this;
// load the qweb templates
var defs = [];
- var templates = ['/im_livechat/static/src/xml/im_livechat.xml', '/im_chat/static/src/xml/im_chat.xml'];
+ var templates = this._get_template_list();
_.each(templates, function(tmpl){
defs.push(openerp.session.rpc('/web/proxy/load', {path: tmpl}).then(function(xml) {
openerp.qweb.add_template(xml);
@@ -191,7 +154,7 @@
this.no_session_message = _t("None of our collaborators seems to be available, please try again later.");
},
start: function() {
- this.$().append(openerp.qweb.render("chatButton", {widget: this}));
+ this.$().append(openerp.qweb.render("im_livechat.chatButton", {widget: this}));
// set up the manager
this.manager = new openerp.im_chat.ConversationManager(this, this.options);
this.manager.set("bottom_offset", $('.oe_chat_button').outerHeight());
@@ -257,6 +220,48 @@
}
});
+ /* Rating livechat object */
+ im_livechat.Feedback = openerp.Widget.extend({
+ template : "im_livechat.feedback",
+ init: function(parent){
+ this._super(parent);
+ this.conversation = parent;
+ this.reason = false;
+ this.rating = false;
+ },
+ start: function(){
+ this._super.apply(this.arguments);
+ // bind events
+ this.$('.oe_livechat_rating_choices img').on('click', _.bind(this.click_smiley, this));
+ this.$('#rating_submit').on('click', _.bind(this.click_send, this));
+ },
+ click_smiley: function(ev){
+ this.rating = parseInt($(ev.currentTarget).data('value'));
+ this.$('.oe_livechat_rating_choices img').removeClass('selected');
+ this.$('.oe_livechat_rating_choices img[data-value="'+this.rating+'"]').addClass('selected');
+ // only display textearea if bad smiley selected
+ if(this.rating == 0){
+ this.$('.oe_livechat_rating_reason').show();
+ }else{
+ this.$('.oe_livechat_rating_reason').hide();
+ }
+ this.$('textarea').val(''); // empty the reason each time a click on a smiley is done
+ },
+ click_send: function(ev){
+ this.reason = this.$('textarea').val();
+ if(_.contains([0,5,10], this.rating)){ // need to use contains, since the rating can 0, evaluate to false
+ this._send_feedback();
+ }
+ },
+ _send_feedback: function(){
+ var self = this;
+ var uuid = this.conversation.get('session').uuid;
+ openerp.session.rpc("/rating/livechat/feedback", {uuid: uuid, rate: this.rating, reason : this.reason}).then(function(res) {
+ self.trigger("feedback_sent"); // will close the conversation
+ });
+ }
+ });
+
return im_livechat;
})();
diff --git a/addons/im_livechat/static/src/xml/im_livechat.xml b/addons/im_livechat/static/src/xml/im_livechat.xml
index 6e9d8f33520..1bbeefc0b0b 100644
--- a/addons/im_livechat/static/src/xml/im_livechat.xml
+++ b/addons/im_livechat/static/src/xml/im_livechat.xml
@@ -1,31 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
-<templates>
+<templates xml:space="preserve">
- <t t-name="chatButton">
+ <t t-name="im_livechat.chatButton">
<t t-esc="widget.text"/>
</t>
- <t t-name="support_feedback">
- <div class="oe_im_chatview_feedback">
+ <t t-name="im_livechat.feedback">
+ <div class="oe_livechat_rating">
<div class="oe_im_feedback_text">
- Please take a second to rate our Livechat Support ...
+ Did we correctly answer your question ?
</div>
- <div class="oe_im_feedback_choices">
- <a data-value="10" name="good" title="Good"><img src='/im_livechat/static/src/img/good.png'/></a>
- <a data-value="5" name="ok" title="OK"><img src='/im_livechat/static/src/img/ok.png'/></a>
- <a data-value="1" name="bad" title="Bad"><img src='/im_livechat/static/src/img/bad.png'/></a>
+ <div class="oe_livechat_rating_choices">
+ <img src='/rating/static/src/img/rating_10.png' alt="Good" data-value="10"/>
+ <img src='/rating/static/src/img/rating_5.png' alt="OK" data-value="5"/>
+ <img src='/rating/static/src/img/rating_0.png' alt="Bad" data-value="0" />
</div>
- <div class="oe_im_feedback_small_text">
- Click on the icon that represent the most your feeling.
- </div>
- <div class="oe_im_feedback_reason">
+ <div class="oe_livechat_rating_reason">
<textarea id="reason" placeholder="Explain your note"></textarea>
</div>
- <div class="oe_im_feedback_btn">
- <input type="button" id="submit" value="Send" />
+ <div class="oe_livechat_rating_reason_button">
+ <input type="button" id="rating_submit" value="Send" />
</div>
</div>
</t>
+
</templates> \ No newline at end of file