@@ -2,53 +2,52 @@ DocsController.$inject = ['$location', '$browser', '$window', '$cookies'];
2
2
function DocsController ( $location , $browser , $window , $cookies ) {
3
3
window . $root = this . $root ;
4
4
5
- var self = this ,
5
+ var scope = this ,
6
6
OFFLINE_COOKIE_NAME = 'ng-offline' ,
7
7
DOCS_PATH = / ^ \/ ( a p i ) | ( g u i d e ) | ( c o o k b o o k ) | ( m i s c ) | ( t u t o r i a l ) / ,
8
8
INDEX_PATH = / ^ ( \/ | \/ i n d e x [ ^ \. ] * .h t m l ) $ / ;
9
9
10
- this . $location = $location ;
11
-
12
- self . versionNumber = angular . version . full ;
13
- self . version = angular . version . full + " " + angular . version . codeName ;
14
- self . subpage = false ;
15
- self . offlineEnabled = ( $cookies [ OFFLINE_COOKIE_NAME ] == angular . version . full ) ;
10
+ scope . $location = $location ;
11
+ scope . versionNumber = angular . version . full ;
12
+ scope . version = angular . version . full + " " + angular . version . codeName ;
13
+ scope . subpage = false ;
14
+ scope . offlineEnabled = ( $cookies [ OFFLINE_COOKIE_NAME ] == angular . version . full ) ;
16
15
17
16
if ( ! $location . path ( ) || INDEX_PATH . test ( $location . path ( ) ) ) {
18
17
$location . path ( '/api' ) . replace ( ) ;
19
18
}
20
19
21
- this . $watch ( '$location.path()' , function ( scope , path ) {
20
+ scope . $watch ( '$location.path()' , function ( scope , path ) {
22
21
// ignore non-doc links which are used in examples
23
22
if ( DOCS_PATH . test ( path ) ) {
24
23
var parts = path . split ( '/' ) ;
25
- self . sectionId = parts [ 1 ] ;
26
- self . partialId = parts [ 2 ] || 'index' ;
27
- self . pages = angular . Array . filter ( NG_PAGES , { section :self . sectionId } ) ;
24
+ scope . sectionId = parts [ 1 ] ;
25
+ scope . partialId = parts [ 2 ] || 'index' ;
26
+ scope . pages = angular . Array . filter ( NG_PAGES , { section : scope . sectionId } ) ;
28
27
29
- var i = self . pages . length ;
28
+ var i = scope . pages . length ;
30
29
while ( i -- ) {
31
- if ( self . pages [ i ] . id == self . partialId ) {
32
- self . partialTitle = self . pages [ i ] . name ;
30
+ if ( scope . pages [ i ] . id == scope . partialId ) {
31
+ scope . partialTitle = scope . pages [ i ] . name ;
33
32
break ;
34
33
}
35
34
}
36
35
if ( i < 0 ) {
37
- self . partialTitle = 'Error: Page Not Found!' ;
38
- delete self . partialId ;
36
+ scope . partialTitle = 'Error: Page Not Found!' ;
37
+ delete scope . partialId ;
39
38
}
40
39
}
41
40
} ) ;
42
41
43
- this . getUrl = function ( page ) {
42
+ scope . getUrl = function ( page ) {
44
43
return page . section + '/' + page . id ;
45
44
} ;
46
45
47
- this . getCurrentPartial = function ( ) {
46
+ scope . getCurrentPartial = function ( ) {
48
47
return this . partialId ? ( './partials/' + this . sectionId + '/' + this . partialId + '.html' ) : '' ;
49
48
} ;
50
49
51
- this . getClass = function ( page ) {
50
+ scope . getClass = function ( page ) {
52
51
var depth = page . depth ,
53
52
cssClass = 'level-' + depth + ( page . name == this . partialId ? ' selected' : '' ) ;
54
53
@@ -58,28 +57,28 @@ function DocsController($location, $browser, $window, $cookies) {
58
57
return cssClass ;
59
58
} ;
60
59
61
- this . selectedSection = function ( section ) {
62
- return section == self . sectionId ? 'current' : '' ;
60
+ scope . selectedSection = function ( section ) {
61
+ return section == scope . sectionId ? 'current' : '' ;
63
62
} ;
64
63
65
- this . selectedPartial = function ( partial ) {
66
- return partial . id == self . partialId ? 'current' : '' ;
64
+ scope . selectedPartial = function ( partial ) {
65
+ return partial . id == scope . partialId ? 'current' : '' ;
67
66
} ;
68
67
69
- this . afterPartialLoaded = function ( ) {
68
+ scope . afterPartialLoaded = function ( ) {
70
69
SyntaxHighlighter . highlight ( ) ;
71
70
$window . scrollTo ( 0 , 0 ) ;
72
71
$window . _gaq . push ( [ '_trackPageview' , $location . path ( ) ] ) ;
73
72
} ;
74
73
75
- this . getFeedbackUrl = function ( ) {
74
+ scope . getFeedbackUrl = function ( ) {
76
75
return "mailto:[email protected] ?" +
77
76
"subject=" + escape ( "Feedback on " + $location . absUrl ( ) ) + "&" +
78
77
"body=" + escape ( "Hi there,\n\nI read " + $location . absUrl ( ) + " and wanted to ask ...." ) ;
79
78
} ;
80
79
81
80
/** stores a cookie that is used by apache to decide which manifest ot send */
82
- this . enableOffline = function ( ) {
81
+ scope . enableOffline = function ( ) {
83
82
//The cookie will be good for one year!
84
83
var date = new Date ( ) ;
85
84
date . setTime ( date . getTime ( ) + ( 365 * 24 * 60 * 60 * 1000 ) ) ;
@@ -94,14 +93,14 @@ function DocsController($location, $browser, $window, $cookies) {
94
93
// bind escape to hash reset callback
95
94
angular . element ( window ) . bind ( 'keydown' , function ( e ) {
96
95
if ( e . keyCode === 27 ) {
97
- self . subpage = false ;
98
- self . $eval ( ) ;
96
+ scope . subpage = false ;
97
+ scope . $eval ( ) ;
99
98
}
100
99
} ) ;
101
100
}
102
101
103
102
// prevent compilation of code
104
- angular . widget ( 'code' , function ( element ) {
103
+ angular . widget ( 'code' , function ( element ) {
105
104
element . attr ( 'ng:non-bindable' , 'true' ) ;
106
105
} ) ;
107
106
0 commit comments