Skip to content

Commit 6eb1179

Browse files
committed
style(docs): change "this" to "scope" in the controller
1 parent 9b85757 commit 6eb1179

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

docs/src/templates/docs.js

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,52 @@ DocsController.$inject = ['$location', '$browser', '$window', '$cookies'];
22
function DocsController($location, $browser, $window, $cookies) {
33
window.$root = this.$root;
44

5-
var self = this,
5+
var scope = this,
66
OFFLINE_COOKIE_NAME = 'ng-offline',
77
DOCS_PATH = /^\/(api)|(guide)|(cookbook)|(misc)|(tutorial)/,
88
INDEX_PATH = /^(\/|\/index[^\.]*.html)$/;
99

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);
1615

1716
if (!$location.path() || INDEX_PATH.test($location.path())) {
1817
$location.path('/api').replace();
1918
}
2019

21-
this.$watch('$location.path()', function(scope, path) {
20+
scope.$watch('$location.path()', function(scope, path) {
2221
// ignore non-doc links which are used in examples
2322
if (DOCS_PATH.test(path)) {
2423
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});
2827

29-
var i = self.pages.length;
28+
var i = scope.pages.length;
3029
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;
3332
break;
3433
}
3534
}
3635
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;
3938
}
4039
}
4140
});
4241

43-
this.getUrl = function(page){
42+
scope.getUrl = function(page) {
4443
return page.section + '/' + page.id;
4544
};
4645

47-
this.getCurrentPartial = function() {
46+
scope.getCurrentPartial = function() {
4847
return this.partialId ? ('./partials/' + this.sectionId + '/' + this.partialId + '.html') : '';
4948
};
5049

51-
this.getClass = function(page) {
50+
scope.getClass = function(page) {
5251
var depth = page.depth,
5352
cssClass = 'level-' + depth + (page.name == this.partialId ? ' selected' : '');
5453

@@ -58,28 +57,28 @@ function DocsController($location, $browser, $window, $cookies) {
5857
return cssClass;
5958
};
6059

61-
this.selectedSection = function(section) {
62-
return section == self.sectionId ? 'current' : '';
60+
scope.selectedSection = function(section) {
61+
return section == scope.sectionId ? 'current' : '';
6362
};
6463

65-
this.selectedPartial = function(partial) {
66-
return partial.id == self.partialId ? 'current' : '';
64+
scope.selectedPartial = function(partial) {
65+
return partial.id == scope.partialId ? 'current' : '';
6766
};
6867

69-
this.afterPartialLoaded = function() {
68+
scope.afterPartialLoaded = function() {
7069
SyntaxHighlighter.highlight();
7170
$window.scrollTo(0,0);
7271
$window._gaq.push(['_trackPageview', $location.path()]);
7372
};
7473

75-
this.getFeedbackUrl = function() {
74+
scope.getFeedbackUrl = function() {
7675
return "mailto:[email protected]?" +
7776
"subject=" + escape("Feedback on " + $location.absUrl()) + "&" +
7877
"body=" + escape("Hi there,\n\nI read " + $location.absUrl() + " and wanted to ask ....");
7978
};
8079

8180
/** stores a cookie that is used by apache to decide which manifest ot send */
82-
this.enableOffline = function() {
81+
scope.enableOffline = function() {
8382
//The cookie will be good for one year!
8483
var date = new Date();
8584
date.setTime(date.getTime()+(365*24*60*60*1000));
@@ -94,14 +93,14 @@ function DocsController($location, $browser, $window, $cookies) {
9493
// bind escape to hash reset callback
9594
angular.element(window).bind('keydown', function(e) {
9695
if (e.keyCode === 27) {
97-
self.subpage = false;
98-
self.$eval();
96+
scope.subpage = false;
97+
scope.$eval();
9998
}
10099
});
101100
}
102101

103102
// prevent compilation of code
104-
angular.widget('code', function(element){
103+
angular.widget('code', function(element) {
105104
element.attr('ng:non-bindable', 'true');
106105
});
107106

0 commit comments

Comments
 (0)