3 var Marionette = require('backbone.marionette');
4 var hasScrollBars = require('../../utils/scrollbar-detect');
5 var appEvents = require('../../utils/appevents');
6 var ChatCollectionView = require('../chat/chatCollectionView');
7 var ChatConnectionIndicatorView = require('../chat/chatConnectivityIndicatorView');
8 var context = require('gitter-web-client-context');
9 var unreadItemsClient = require('../../components/unread-items-client');
10 const isTouch = require('../../utils/is-touch');
12 require('../behaviors/isomorphic');
14 module.exports = Marionette.LayoutView.extend({
18 el: '#chat-container',
19 init: function(optionsForRegion) {
20 var chatCollectionView = (this.chatCollectionView = new ChatCollectionView(
22 collection: this.collection,
23 decorators: this.options.decorators
27 if (this.options.monitorScrollPane) {
28 unreadItemsClient.monitorViewForUnreadItems(
29 this.options.monitorScrollPane,
34 return chatCollectionView;
37 connectivityIndicator: {
38 el: '.chat-connectivity-indicator-wrapper',
39 init: 'initConnectivityIndicatorView'
44 initConnectivityIndicatorView: function(optionsForRegion) {
45 if (context.hasFeature('connectivity-indicator')) {
46 return new ChatConnectionIndicatorView(optionsForRegion({}));
51 primaryScroll: '.primary-scroll'
58 onRender: function() {
59 if (hasScrollBars()) {
60 this.ui.primaryScroll.addClass('scroller');
64 onClick: function(e) {
65 var hasTextSelected = window.getSelection().toString().length > 0;
68 !isTouch() && // on touch devices we use double tapping message to edit, the focus would intervene
69 e.target.tagName.toLowerCase() !== 'textarea' &&
70 // we want to focus a TMF input if user opens the TMF by clicking on
71 // parent message indicator
72 !e.target.className.match(/js-parent-message-indicator/)
74 appEvents.trigger('focus.request.chat');