Gitter migration: Point people to app.gitter.im (rollout pt. 1)
[gitter.git] / public / js / router-nli-chat.js
blob9203c3b59591cefa270edb8af56fe8c1ac1218ed
1 'use strict';
3 require('./utils/font-setup');
5 var appEvents = require('./utils/appevents');
6 var Backbone = require('backbone');
7 var itemCollections = require('./collections/instances/integrated-items');
8 var chatCollection = require('./collections/instances/chats');
9 var PeopleModal = require('./views/modals/people-modal');
10 var LoginView = require('./views/modals/login-view');
11 var onready = require('./utils/onready');
12 var ChatToolbarLayout = require('./views/layouts/chat-toolbar');
13 var urlParse = require('url-parse');
15 /* Set the timezone cookie */
16 require('./components/timezone-cookie');
18 require('./views/widgets/preload');
19 require('./components/dozy');
20 require('./template/helpers/all');
21 require('./components/bug-reporting');
23 // Preload widgets
24 require('./views/widgets/avatar');
25 require('./components/ping');
27 onready(function() {
28   require('./components/link-handler').installLinkHandler();
30   appEvents.on('navigation', function(url) {
31     // No pushState here. Open links within the parent...
32     window.parent.location.href = url;
33   });
35   var appView = new ChatToolbarLayout({
36     template: false,
37     el: 'body',
38     chatCollection: chatCollection
39   });
40   appView.render();
42   var Router = Backbone.Router.extend({
43     routes: {
44       '': 'hideModal',
45       people: 'people',
46       login: 'login'
47     },
49     hideModal: function() {
50       appView.dialogRegion.destroy();
51     },
53     people: function() {
54       appView.dialogRegion.show(
55         new PeopleModal({
56           rosterCollection: itemCollections.roster
57         })
58       );
59     },
61     login: function(query) {
62       var options = query ? urlParse('?' + query, true).query : {};
63       appView.dialogRegion.show(new LoginView(options));
64     }
65   });
67   var router = new Router();
69   appEvents.on('loginClicked', function(route) {
70     router.navigate(route, { trigger: true });
71   });
73   // // Listen for changes to the room
74   // liveContext.syncRoom();
76   Backbone.history.stop();
77   Backbone.history.start();
78 });