forked from golang/tour
/
app.js
executable file
·50 lines (46 loc) · 1.5 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Copyright 2012 The Go Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
'use strict';
angular.module('tour', ['ui', 'tour.services', 'tour.controllers', 'tour.directives', 'tour.values', 'ng']).
config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider.
when('/', {
redirectTo: '/welcome/1'
}).
when('/list', {
templateUrl: '/static/partials/list.html',
}).
when('/:lessonId/:pageNumber', {
templateUrl: '/static/partials/editor.html',
controller: 'EditorCtrl'
}).
when('/:lessonId', {
redirectTo: '/:lessonId/1'
}).
otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode(true).hashPrefix('!');
}
]).
// handle mapping from old paths (#42) to the new organization.
run(function($rootScope, $location, mapping) {
$rootScope.$on( "$locationChangeStart", function(event, next) {
var url = document.createElement('a');
url.href = next;
if (url.pathname != '/' || url.hash == '') {
return;
}
$location.hash('');
var m = mapping[url.hash];
if (m === undefined) {
console.log('unknown url, redirecting home');
$location.path('/welcome/1');
return;
}
$location.path(m);
});
});