summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/thread.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-12-21 12:29:50 +0100
committerAlexandre Kühn <alex.e.kuhn@gmail.com>2018-02-01 14:51:58 +0100
commit02ec09cb1c3e2d7bc7968f40c18f2208d7f3f498 (patch)
tree10d91136786b13666e78cfb94b12f1609d6f883d /addons/mail/static/src/js/thread.js
parent0cd656b5af38051df3f7d6319e99705150bb1cd8 (diff)
[REF][IMP] *: mail js refactoring
This commit improves the JS code of the mail module, which comes maily from the new coding guidelines and the addition of "JS services". JS services are important objects that do not fit well in the component tree, such as chat_manager or ajax. The benefits of JS services are improved readability of the code, reduced coupling, and more testable modules. In particular, discuss was hard to Summary of the changes: - ClientAction has been renamed into Discuss - Clear instantiation of chatManager - New coding guidelines in most mail modules - JS Services can interact with each other - Chat Manager and Window Manager are services - Window Manager renamed to Chat Window Manager - bus.bus is now encapsulated in Bus Service (a service) - The test infrastructure has been tweaked with JS Services - Chat Mixin has been removed A future improvement would be to translate some 'trigger' into 'trigger_up'.
Diffstat (limited to 'addons/mail/static/src/js/thread.js')
-rw-r--r--addons/mail/static/src/js/thread.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/addons/mail/static/src/js/thread.js b/addons/mail/static/src/js/thread.js
index 156fb77c1ad..729d24b6163 100644
--- a/addons/mail/static/src/js/thread.js
+++ b/addons/mail/static/src/js/thread.js
@@ -142,7 +142,7 @@ var Thread = Widget.extend({
this.attachments = _.uniq(_.flatten(_.map(messages, 'attachment_ids')));
- _.each(msgs, function(msg) {
+ _.each(msgs, function (msg) {
var $msg = self.$('.o_thread_message[data-message-id="'+ msg.id +'"]');
$msg.find('.o_mail_timestamp').data('date', msg.date);
@@ -150,7 +150,7 @@ var Thread = Widget.extend({
});
if (!this.update_timestamps_interval) {
- this.update_timestamps_interval = setInterval(function() {
+ this.update_timestamps_interval = setInterval(function () {
self.update_timestamps();
}, 1000*60);
}
@@ -172,17 +172,17 @@ var Thread = Widget.extend({
// nodeType 1: element_node
// nodeType 3: text_node
var $children = $element.contents()
- .filter(function() {
+ .filter(function () {
return this.nodeType === 1 || this.nodeType === 3 && this.nodeValue.trim();
});
- _.each($children, function(child) {
+ _.each($children, function (child) {
var $child = $(child);
// Hide Text nodes if "stopSpelling"
if (child.nodeType === 3 && $child.prevAll("[id*='stopSpelling']").length > 0) {
// Convert Text nodes to Element nodes
- var $child = $('<span>', {
+ $child = $('<span>', {
text: child.textContent,
"data-o-mail-quote": "1",
});
@@ -203,7 +203,7 @@ var Thread = Widget.extend({
}
});
- _.each(groups, function(group) {
+ _.each(groups, function (group) {
// Insert link just before the first node
var $read_more = $('<a>', {
class: "o_mail_read_more",
@@ -213,7 +213,7 @@ var Thread = Widget.extend({
// Toggle All next nodes
var is_read_more = true;
- $read_more.click(function(e) {
+ $read_more.click(function (e) {
e.preventDefault();
is_read_more = !is_read_more;
_.each(group, function ($child) {
@@ -226,7 +226,7 @@ var Thread = Widget.extend({
},
update_timestamps: function () {
var isAtBottom = this.is_at_bottom();
- this.$('.o_mail_timestamp').each(function() {
+ this.$('.o_mail_timestamp').each(function () {
var date = $(this).data('date');
$(this).html(time_from_now(date));
});