diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-07-05 16:14:48 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-07-05 16:14:48 +0200 |
| commit | 66bb578ac9f0cc260a5b7f859fc0bb4fcfab6e25 (patch) | |
| tree | 57b147168f7118374f0f5b4ba46f4c9d75220df2 /addons/website_profile/static | |
| parent | 201c5b5878f13c34cb7a9edb3c3296fc9a1944fe (diff) | |
| parent | be5e8fdab800ff1fd9e953ec64801f96bcc3dac5 (diff) | |
[MERGE] forward port branch saas-12.2 up to be5e8fdab80
Diffstat (limited to 'addons/website_profile/static')
| -rw-r--r-- | addons/website_profile/static/src/js/website_profile.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/addons/website_profile/static/src/js/website_profile.js b/addons/website_profile/static/src/js/website_profile.js index caccf454f1a..b78d2ed9f06 100644 --- a/addons/website_profile/static/src/js/website_profile.js +++ b/addons/website_profile/static/src/js/website_profile.js @@ -44,6 +44,9 @@ publicWidget.registry.websiteProfile = publicWidget.Widget.extend({ publicWidget.registry.websiteProfileEditor = publicWidget.Widget.extend({ selector: '.o_wprofile_editor_form', read_events: { + 'click .o_forum_profile_pic_edit': '_onEditProfilePicClick', + 'change .o_forum_file_upload': '_onFileUploadChange', + 'click .o_forum_profile_pic_clear': '_onProfilePicClearClick', 'click .o_wprofile_submit_btn': '_onSubmitClick', }, @@ -76,6 +79,43 @@ publicWidget.registry.websiteProfileEditor = publicWidget.Widget.extend({ /** * @private + * @param {Event} ev + */ + _onEditProfilePicClick: function (ev) { + ev.preventDefault(); + $(ev.currentTarget).closest('form').find('.o_forum_file_upload').trigger('click'); + }, + /** + * @private + * @param {Event} ev + */ + _onFileUploadChange: function (ev) { + if (!ev.currentTarget.files.length) { + return; + } + var $form = $(ev.currentTarget).closest('form'); + var reader = new window.FileReader(); + reader.readAsDataURL(ev.currentTarget.files[0]); + reader.onload = function (ev) { + $form.find('.o_forum_avatar_img').attr('src', ev.target.result); + }; + $form.find('#forum_clear_image').remove(); + }, + /** + * @private + * @param {Event} ev + */ + _onProfilePicClearClick: function (ev) { + var $form = $(ev.currentTarget).closest('form'); + $form.find('.o_forum_avatar_img').attr('src', '/web/static/src/img/placeholder.png'); + $form.append($('<input/>', { + name: 'clear_image', + id: 'forum_clear_image', + type: 'hidden', + })); + }, + /** + * @private */ _onSubmitClick: function () { this.$('textarea.load_editor').data('wysiwyg').save(); |
