3 var Marionette = require('backbone.marionette');
4 var toggleClass = require('../../utils/toggle-class');
5 var context = require('gitter-web-client-context');
7 var ProfileMenu = require('../../views/profile-menu/profile-menu-view.js');
8 var headerViewTemplate = require('./org-directory-header-view.hbs');
10 require('../behaviors/isomorphic');
11 require('../behaviors/tooltip');
13 var HeaderView = Marionette.LayoutView.extend({
15 template: headerViewTemplate,
18 favourite: '.js-group-favourite-button',
19 favouriteIcon: '.js-group-favourite-button-icon'
23 'click @ui.favourite': 'onFavouriteButtonClicked'
27 'change:favourite': 'onFavouriteChange'
30 behaviors: function() {
34 '.js-group-favourite-button': { placement: 'left' }
38 if (context.isLoggedIn()) {
39 behaviors.Isomorphic.profileMenuView = {
41 init: 'initProfileMenuView'
48 initProfileMenuView: function(optionsForRegion) {
49 this.profileMenuView = new ProfileMenu(
54 return this.profileMenuView;
57 onFavouriteChange: function() {
58 var isFavourited = !!this.model.get('favourite');
59 toggleClass(this.ui.favouriteIcon[0], 'favourite', isFavourited);
62 onFavouriteButtonClicked: function() {
63 var isFavourited = !!this.model.get('favourite');
66 favourite: !isFavourited
76 module.exports = HeaderView;