diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/website_mail_channel/static/src/js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/website_mail_channel/static/src/js')
| -rw-r--r-- | addons/website_mail_channel/static/src/js/website_mail_channel.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/addons/website_mail_channel/static/src/js/website_mail_channel.js b/addons/website_mail_channel/static/src/js/website_mail_channel.js new file mode 100644 index 00000000..30928d78 --- /dev/null +++ b/addons/website_mail_channel/static/src/js/website_mail_channel.js @@ -0,0 +1,71 @@ +odoo.define('website_mail_channel', function (require) { +'use strict'; + +var publicWidget = require('web.public.widget'); + +publicWidget.registry.websiteMailChannel = publicWidget.Widget.extend({ + selector: '#wrapwrap', + events: { + 'click .o_mg_link_hide': '_onHideLinkClick', + 'click .o_mg_link_show': '_onShowLinkClick', + 'click button.o_mg_read_more': '_onReadMoreClick', + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * @private + * @param {Event} ev + */ + _onHideLinkClick: function (ev) { + ev.preventDefault(); + ev.stopPropagation(); + var $link = $(ev.currentTarget); + var $container = $link.parents('div').first(); + $container.find('.o_mg_link_hide').first().hide(); + $container.find('.o_mg_link_show').first().show(); + $container.find('.o_mg_link_content').first().show(); + }, + /** + * @private + * @param {Event} ev + */ + _onShowLinkClick: function (ev) { + ev.preventDefault(); + ev.stopPropagation(); + var $link = $(ev.currentTarget); + var $container = $link.parents('div').first(); + $container.find('.o_mg_link_hide').first().show(); + $container.find('.o_mg_link_show').first().hide(); + $container.find('.o_mg_link_content').first().hide(); + }, + /** + * @private + * @param {Event} ev + */ + _onReadMoreClick: function (ev) { + var $link = $(ev.target); + this._rpc({ + route: $link.data('href'), + params: { + last_displayed_id: $link.data('msg-id'), + }, + }).then(function (data) { + if (!data) { + return; + } + var $threadContainer = $link.parents('.o_mg_replies').first().find('ul.list-unstyled'); + if ($threadContainer) { + var $lastMsg = $threadContainer.find('li.media').last(); + $(data).find('li.media').insertAfter($lastMsg); + $(data).find('.o_mg_read_more').parent().appendTo($threadContainer); + } + var $showMore = $link.parent(); + $showMore.remove(); + return; + }); + }, +}); +}); |
