// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. var ChannelStore = require('../stores/channel_store.jsx'); var UserStore = require('../stores/user_store.jsx'); var PostStore = require('../stores/post_store.jsx'); var UserProfile = require( './user_profile.jsx' ); var NavbarSearchBox =require('./search_bar.jsx'); var AsyncClient = require('../utils/async_client.jsx'); var Client = require('../utils/client.jsx'); var utils = require('../utils/utils.jsx'); var MessageWrapper = require('./message_wrapper.jsx'); var AppDispatcher = require('../dispatcher/app_dispatcher.jsx'); var Constants = require('../utils/constants.jsx'); var ActionTypes = Constants.ActionTypes; function getExtraInfoStateFromStores() { return { extra_info: ChannelStore.getCurrentExtraInfo() }; } var ExtraMembers = React.createClass({ componentDidMount: function() { ChannelStore.addExtraInfoChangeListener(this._onChange); ChannelStore.addChangeListener(this._onChange); var originalLeave = $.fn.popover.Constructor.prototype.leave; $.fn.popover.Constructor.prototype.leave = function(obj) { var self = obj instanceof this.constructor ? obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type); originalLeave.call(this, obj); if (obj.currentTarget && self.$tip) { self.$tip.one('mouseenter', function() { clearTimeout(self.timeout); self.$tip.one('mouseleave', function() { $.fn.popover.Constructor.prototype.leave.call(self, self); }); }) } }; $("#member_popover").popover({placement : 'bottom', trigger: 'click', html: true}); $('body').on('click', function (e) { if ($(e.target.parentNode.parentNode)[0] !== $("#member_popover")[0] && $(e.target).parents('.popover.in').length === 0) { $("#member_popover").popover('hide'); } }); }, componentWillUnmount: function() { ChannelStore.removeExtraInfoChangeListener(this._onChange); ChannelStore.removeChangeListener(this._onChange); }, _onChange: function() { var newState = getExtraInfoStateFromStores(); if (!utils.areStatesEqual(newState, this.state)) { this.setState(newState); } }, getInitialState: function() { return getExtraInfoStateFromStores(); }, render: function() { var count = this.state.extra_info.members.length == 0 ? "-" : this.state.extra_info.members.length; count = this.state.extra_info.members.length > 19 ? "20+" : count; var data_content = ""; this.state.extra_info.members.forEach(function(m) { data_content += "
{ !isDirect ?
{channelTitle}
{description}
|
---|