diff options
author | matrix.org <matrix@matrix.org> | 2014-08-12 15:10:52 +0100 |
---|---|---|
committer | matrix.org <matrix@matrix.org> | 2014-08-12 15:10:52 +0100 |
commit | 4f475c7697722e946e39e42f38f3dd03a95d8765 (patch) | |
tree | 076d96d3809fb836c7245fd9f7960e7b75888a77 /webclient/app.js | |
download | synapse-4f475c7697722e946e39e42f38f3dd03a95d8765.tar.xz |
Reference Matrix Home Server
Diffstat (limited to 'webclient/app.js')
-rw-r--r-- | webclient/app.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/webclient/app.js b/webclient/app.js new file mode 100644 index 0000000000..2a75560edd --- /dev/null +++ b/webclient/app.js @@ -0,0 +1,57 @@ +var matrixWebClient = angular.module('matrixWebClient', [ + 'ngRoute', + 'MatrixWebClientController', + 'LoginController', + 'RoomController', + 'RoomsController', + 'matrixService' +]); + +matrixWebClient.config(['$routeProvider', + function($routeProvider) { + $routeProvider. + when('/login', { + templateUrl: 'login/login.html', + controller: 'LoginController' + }). + when('/room/:room_id', { + templateUrl: 'room/room.html', + controller: 'RoomController' + }). + when('/rooms', { + templateUrl: 'rooms/rooms.html', + controller: 'RoomsController' + }). + otherwise({ + redirectTo: '/rooms' + }); + }]); + +matrixWebClient.run(['$location', 'matrixService' , function($location, matrixService) { + // If we have no persistent login information, go to the login page + var config = matrixService.config(); + if (!config || !config.access_token) { + $location.path("login"); + } +}]); + +matrixWebClient + .directive('ngEnter', function () { + return function (scope, element, attrs) { + element.bind("keydown keypress", function (event) { + if(event.which === 13) { + scope.$apply(function () { + scope.$eval(attrs.ngEnter); + }); + event.preventDefault(); + } + }); + }; + }) + .directive('ngFocus', ['$timeout', function($timeout) { + return { + link: function(scope, element, attr) { + $timeout(function() { element[0].focus() }, 0); + } + }; + }]); |