Gitter migration: Point people to app.gitter.im (rollout pt. 1)
[gitter.git] / public / js / views / modals / welcome-message.js
blob2b2815f26eabda2922723d07ef4b354a600e57f3
1 'use strict';
3 var Marionette = require('backbone.marionette');
4 var ModalView = require('./modal');
5 var context = require('gitter-web-client-context');
6 var template = require('./tmpl/welcome-message-view.hbs');
7 var apiClient = require('../../components/api-client');
9 var View = Marionette.ItemView.extend({
10 template: template,
11 ui: {
12 welcomeMessage: '#welcome-message-container'
15 initialize: function() {
16 this.listenTo(this, 'menuItemClicked', this.menuItemClicked, this);
19 menuItemClicked: function(type) {
20 switch (type) {
21 case 'submit':
22 apiClient.user.post('/rooms', { id: context.troupe().id }).then(
23 function(body) {
24 context.setTroupe(body);
25 this.destroyWelcomeMessage();
26 }.bind(this)
28 break;
32 onRender: function() {
33 apiClient.room.get('/meta').then(
34 function(roomMetadata) {
35 this.ui.welcomeMessage.html(roomMetadata.welcomeMessage.html);
36 }.bind(this)
40 destroyWelcomeMessage: function() {
41 this.dialog.hide();
42 this.dislog = null;
44 });
46 var Modal = ModalView.extend({
47 initialize: function(attrs, options) {
48 ModalView.prototype.initialize.call(this, options, attrs);
49 this.view = new View(attrs, options);
51 menuItems: [
53 action: 'submit',
54 pull: 'right',
55 text: 'I Understand',
56 className: 'modal--default__footer__btn'
59 });
61 module.exports = {
62 View: View,
63 Modal: Modal