From b86ca3a4ec4b984b37d1c9f0913cbcc3f631b267 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 20 May 2019 12:19:54 +0300 Subject: [PATCH] stream popover fix --- client/src/views/stream/panel.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/client/src/views/stream/panel.js b/client/src/views/stream/panel.js index 90f57ce2ee..79db1b37a2 100644 --- a/client/src/views/stream/panel.js +++ b/client/src/views/stream/panel.js @@ -91,6 +91,7 @@ define('views/stream/panel', ['views/record/panels/relationship', 'lib!Textcompl if ($target.parent().hasClass('remove-attachment')) return; if ($.contains(this.$postContainer.get(0), e.target)) return; if (this.$textarea.val() !== '') return; + if (e.target.classList.contains('popover-content')) return; var attachmentsIds = this.seed.get('attachmentsIds') || []; if (!attachmentsIds.length && (!this.getView('attachments') || !this.getView('attachments').isUploading)) { @@ -389,20 +390,33 @@ define('views/stream/panel', ['views/record/panels/relationship', 'lib!Textcompl }, this); } - $a = this.$el.find('.buttons-panel a.stream-post-info'); + var $a = this.$el.find('.buttons-panel a.stream-post-info'); $a.popover({ placement: 'bottom', container: 'body', content: this.translate('streamPostInfo', 'messages').replace(/(\r\n|\n|\r)/gm, '
'), - trigger: 'click', html: true }).on('shown.bs.popover', function () { - $('body').one('click', function () { + $('body').off('click.popover-' + this.id); + $('body').on('click.popover-' + this.id , function (e) { + if (e.target.classList.contains('popover-content')) return; + if ($.contains($a.get(0), e.target)) return; + $('body').off('click.popover-' + this.id); $a.popover('hide'); - }); + e.stopPropagation(); + }.bind(this)); }); + $a.on('click', function () { + $(this).popover('toggle'); + }); + + this.on('remove', function () { + if ($a) $a.popover('destroy') + $('body').off('click.popover-' + this.id); + }, this); + this.createView('attachments', 'views/stream/fields/attachment-multiple', { model: this.seed, mode: 'edit',