Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 8313f38

Browse files
committed
Merge pull request #1545 from rmisio/1540
1540
2 parents e340bb1 + 8d3cabf commit 8313f38

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

js/templates/chatConversation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</div>
1212
</div>
1313

14-
<div class="chatConversationMenu hide">
14+
<div class="chatConversationMenu js-chatSettingsMenu hide">
1515
<div>
1616
<a class="js-clearConvo"><%= polyglot.t('ClearConvo') %></a>
1717
</div>

js/views/chatConversationVw.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ module.exports = baseVw.extend({
8282
this.scrollHandler = __.bind(
8383
__.throttle(this.onScroll, 100), this
8484
);
85+
86+
$(document).on('click', this.onDocumentClick.bind(this));
87+
},
88+
89+
onDocumentClick: function(e) {
90+
if (
91+
e.target !== this.$settingsMenu[0] &&
92+
!$(e.target).parents('.js-chatSettingsMenu').length
93+
) {
94+
this.closeConvoSettings();
95+
}
8596
},
8697

8798
onScroll: function(e) {
@@ -148,11 +159,13 @@ module.exports = baseVw.extend({
148159
},
149160

150161
closeConvoSettings: function() {
151-
this.$('.chatConversationMenu').addClass('hide');
162+
this.$settingsMenu.addClass('hide');
152163
},
153164

154165
toggleConvoSettings: function() {
155-
this.$('.chatConversationMenu').toggleClass('hide');
166+
this.$settingsMenu.toggleClass('hide');
167+
168+
return false;
156169
},
157170

158171
onBlockClick: function() {
@@ -232,6 +245,7 @@ module.exports = baseVw.extend({
232245
this.$loadingSpinner = this.$messagesScrollContainer.find('.js-loadingSpinner');
233246
this.$messagesContainer = this.$messagesScrollContainer.find('.js-messagesContainer');
234247
this.$msgTextArea = this.$('textarea');
248+
this.$settingsMenu = this.$('.js-chatSettingsMenu');
235249

236250
if (this.collection.length) {
237251
this.collection.forEach((md) => {
@@ -252,6 +266,7 @@ module.exports = baseVw.extend({
252266

253267
remove: function() {
254268
this.$scrollContainer && this.$scrollContainer.off('scroll', this.scrollHandler);
269+
$(document).off('click', this.onDocumentClick);
255270

256271
baseVw.prototype.remove.apply(this, arguments);
257272
}

js/views/chatVw.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ module.exports = baseVw.extend({
431431
this.$('.chatConversationHeads').removeClass('chatConversationHeadsCompressed textOpacity50');
432432
this.$('.chatSearch').removeClass('textOpacity50');
433433
this.$convoContainer.addClass('chatConversationContainerHide');
434+
434435
if (this.chatConversationVw) {
435436
this.chatConversationVw.closeConvoSettings();
436437
}

0 commit comments

Comments
 (0)