3 var Marionette = require('backbone.marionette');
4 var context = require('gitter-web-client-context');
5 var ModalView = require('../modals/modal');
6 var AvatarView = require('../widgets/avatar');
7 var collectionTemplate = require('./tmpl/peopleCollectionView.hbs');
8 var remainingTempate = require('./tmpl/remainingView.hbs');
10 require('../behaviors/isomorphic');
12 var PeopleCollectionView = Marionette.CollectionView.extend({
15 childView: AvatarView,
16 childViewOptions: function(item) {
20 tooltipPlacement: 'left',
21 screenReadUsername: true
24 if (item && item.id) {
25 var prerenderedUserEl = this.$el.find('.js-model-id-' + item.id)[0];
26 if (prerenderedUserEl) {
27 options.el = prerenderedUserEl;
34 reset: 'onCollectionReset'
36 onCollectionReset: function() {
37 if (this.collection.length) return;
42 while ((child = el.firstChild)) {
43 el.removeChild(child);
48 var RemainingView = Marionette.ItemView.extend({
49 className: 'remaining',
51 template: remainingTempate,
57 serializeData: function() {
58 var userCount = this.model.get('userCount');
59 var isOneToOne = this.model.get('oneToOne');
60 var isLoggedIn = context.isLoggedIn();
63 showAddButton: isLoggedIn && !isOneToOne,
64 showPeopleButton: !isOneToOne,
66 hasHiddenMembers: userCount > 25
71 var ExpandableRosterView = Marionette.LayoutView.extend({
72 template: collectionTemplate,
76 rosterRegion: { el: '#roster-region', init: 'initRosterRegion' },
77 remainingRegion: { el: '#remaining-region', init: 'initRemainingRegion' }
81 initRosterRegion: function(optionsForRegion) {
82 return new PeopleCollectionView(
84 collection: this.options.rosterCollection,
85 filter: function(child, index) {
87 return index < 25; // Only show the first 25 users
93 initRemainingRegion: function(optionsForRegion) {
94 return new RemainingView(
96 model: context.troupe()
102 var AllUsersModal = ModalView.extend({
103 initialize: function(options) {
104 options = options || {};
105 options.title = 'People';
106 ModalView.prototype.initialize.call(this, options);
107 this.view = new PeopleCollectionView(options);
112 ExpandableRosterView: ExpandableRosterView,