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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
DocsController.$inject = ['$location', '$window', '$cookies'];
function DocsController($location, $window, $cookies) {
window.$root = this.$root;
var scope = this,
OFFLINE_COOKIE_NAME = 'ng-offline',
DOCS_PATH = /^\/(api)|(guide)|(cookbook)|(misc)|(tutorial)/,
INDEX_PATH = /^(\/|\/index[^\.]*.html)$/;
scope.$location = $location;
scope.versionNumber = angular.version.full;
scope.version = angular.version.full + " " + angular.version.codeName;
scope.subpage = false;
scope.offlineEnabled = ($cookies[OFFLINE_COOKIE_NAME] == angular.version.full);
scope.futurePartialTitle = null;
scope.loading = 0;
if (!$location.path() || INDEX_PATH.test($location.path())) {
$location.path('/api').replace();
}
scope.$watch('$location.path()', function(scope, path) {
// ignore non-doc links which are used in examples
if (DOCS_PATH.test(path)) {
var parts = path.split('/');
scope.sectionId = parts[1];
scope.partialId = parts[2] || 'index';
scope.pages = angular.Array.filter(NG_PAGES, {section: scope.sectionId});
scope.loading++;
var i = scope.pages.length;
while (i--) {
if (scope.pages[i].id == scope.partialId) {
// TODO(i): this is not ideal but better than updating the title before a partial arrives,
// which results in the old partial being displayed with the new title
scope.futurePartialTitle = scope.pages[i].name;
break;
}
}
if (i<0) {
scope.partialTitle = 'Error: Page Not Found!';
delete scope.partialId;
}
}
});
scope.getUrl = function(page) {
return page.section + '/' + page.id;
};
scope.getCurrentPartial = function() {
return this.partialId ? ('./partials/' + this.sectionId + '/' + this.partialId + '.html') : '';
};
scope.getClass = function(page) {
var depth = page.depth,
cssClass = 'level-' + depth + (page.name == this.partialId ? ' selected' : '');
if (page.section == 'api')
cssClass += ' monospace';
return cssClass;
};
scope.selectedSection = function(section) {
return section == scope.sectionId ? 'current' : '';
};
scope.selectedPartial = function(partial) {
return partial.id == scope.partialId ? 'current' : '';
};
scope.afterPartialLoaded = function() {
scope.loading--;
scope.partialTitle = scope.futurePartialTitle;
SyntaxHighlighter.highlight();
$window.scrollTo(0,0);
$window._gaq.push(['_trackPageview', $location.path()]);
};
scope.getFeedbackUrl = function() {
return "mailto:angular@googlegroups.com?" +
"subject=" + escape("Feedback on " + $location.absUrl()) + "&" +
"body=" + escape("Hi there,\n\nI read " + $location.absUrl() + " and wanted to ask ....");
};
/** stores a cookie that is used by apache to decide which manifest ot send */
scope.enableOffline = function() {
//The cookie will be good for one year!
var date = new Date();
date.setTime(date.getTime()+(365*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
var value = angular.version.full;
document.cookie = OFFLINE_COOKIE_NAME + "="+value+expires+"; path=" + $location.path;
//force the page to reload so server can serve new manifest file
window.location.reload(true);
};
// bind escape to hash reset callback
angular.element(window).bind('keydown', function(e) {
if (e.keyCode === 27) {
scope.$apply(function() {
scope.subpage = false;
});
}
});
}
// prevent compilation of code
angular.widget('code', function(element) {
element.attr('ng:non-bindable', 'true');
});
SyntaxHighlighter['defaults'].toolbar = false;
SyntaxHighlighter['defaults'].gutter = true;
/**
* Controller for tutorial instructions
* @param $cookieStore
* @constructor
*/
function TutorialInstructionsCtrl($cookieStore) {
this.selected = $cookieStore.get('selEnv') || 'git-mac';
this.currentCls = function(id, cls) {
return this.selected == id ? cls || 'current' : '';
};
this.select = function(id) {
this.selected = id;
$cookieStore.put('selEnv', id);
};
}
angular.service('$locationConfig', function() {
return {
html5Mode: true,
hashPrefix: '!'
};
});
|