2011-02-03 23:21:34 +00:00
|
|
|
var HAS_HASH = /#/;
|
2010-11-16 21:39:50 +00:00
|
|
|
DocsController.$inject = ['$location', '$browser', '$window'];
|
|
|
|
|
function DocsController($location, $browser, $window) {
|
2010-11-15 20:15:27 +00:00
|
|
|
window.$root = this.$root;
|
2011-04-29 22:18:27 +00:00
|
|
|
var self = this;
|
2011-02-01 18:01:02 +00:00
|
|
|
this.$location = $location;
|
|
|
|
|
|
2011-07-21 02:27:59 +00:00
|
|
|
self.versionNumber = angular.version.full;
|
|
|
|
|
self.version = angular.version.full + " " + angular.version.codeName;
|
|
|
|
|
self.cookieName = "angularPref";
|
|
|
|
|
self.subpage = false;
|
|
|
|
|
self.offlineEnabled = (document.cookie.indexOf(self.cookieName) !== -1);
|
|
|
|
|
|
2011-02-03 23:21:34 +00:00
|
|
|
if (!HAS_HASH.test($location.href)) {
|
2011-06-06 17:15:17 +00:00
|
|
|
$location.hashPath = '!/api';
|
2011-02-03 23:21:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.$watch('$location.hashPath', function(hashPath) {
|
2011-02-01 18:01:02 +00:00
|
|
|
if (hashPath.match(/^!/)) {
|
2011-04-29 22:18:27 +00:00
|
|
|
var parts = hashPath.substring(1).split('/');
|
2011-06-06 17:15:17 +00:00
|
|
|
self.sectionId = parts[1];
|
|
|
|
|
self.partialId = parts[2] || 'index';
|
2011-04-29 22:18:27 +00:00
|
|
|
self.pages = angular.Array.filter(NG_PAGES, {section:self.sectionId});
|
2011-06-30 07:49:44 +00:00
|
|
|
|
|
|
|
|
var i = self.pages.length;
|
|
|
|
|
while (i--) {
|
|
|
|
|
if (self.pages[i].id == self.partialId) {
|
|
|
|
|
self.partialTitle = self.pages[i].name
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (i<0) {
|
|
|
|
|
self.partialTitle = 'Error: Page Not Found!';
|
|
|
|
|
delete self.partialId;
|
|
|
|
|
}
|
2011-02-01 18:01:02 +00:00
|
|
|
}
|
|
|
|
|
});
|
2011-01-19 23:42:11 +00:00
|
|
|
|
2010-11-15 20:15:27 +00:00
|
|
|
this.getUrl = function(page){
|
2011-06-06 17:15:17 +00:00
|
|
|
return '#!/' + page.section + '/' + page.id;
|
2010-10-27 22:31:10 +00:00
|
|
|
};
|
2010-11-15 20:15:27 +00:00
|
|
|
|
|
|
|
|
this.getCurrentPartial = function(){
|
2011-06-30 07:49:44 +00:00
|
|
|
return this.partialId ? ('./' + this.sectionId + '/' + this.partialId + '.html') : '';
|
2010-11-15 20:15:27 +00:00
|
|
|
};
|
2011-01-19 23:42:11 +00:00
|
|
|
|
2010-11-15 20:15:27 +00:00
|
|
|
this.getClass = function(page) {
|
2011-01-26 05:55:11 +00:00
|
|
|
var depth = page.depth,
|
2011-02-01 18:01:02 +00:00
|
|
|
cssClass = 'level-' + depth + (page.name == this.partialId ? ' selected' : '');
|
2010-11-17 19:33:30 +00:00
|
|
|
|
2011-04-29 22:18:27 +00:00
|
|
|
if (page.section == 'api')
|
|
|
|
|
cssClass += ' monospace';
|
2010-11-17 19:33:30 +00:00
|
|
|
|
|
|
|
|
return cssClass;
|
2010-11-15 20:15:27 +00:00
|
|
|
};
|
2010-11-16 21:39:50 +00:00
|
|
|
|
2011-04-29 22:18:27 +00:00
|
|
|
this.selectedSection = function(section) {
|
2011-05-11 00:01:01 +00:00
|
|
|
return section == self.sectionId ? 'current' : '';
|
2011-04-29 22:18:27 +00:00
|
|
|
};
|
|
|
|
|
|
2011-05-11 00:01:01 +00:00
|
|
|
this.selectedPartial = function(partial) {
|
|
|
|
|
return partial.id == self.partialId ? 'current' : '';
|
2011-05-18 12:28:37 +00:00
|
|
|
};
|
2011-05-11 00:01:01 +00:00
|
|
|
|
2010-11-16 21:39:50 +00:00
|
|
|
this.afterPartialLoaded = function() {
|
|
|
|
|
SyntaxHighlighter.highlight();
|
2011-05-25 12:00:12 +00:00
|
|
|
$window.scrollTo(0,0);
|
2011-06-06 17:15:17 +00:00
|
|
|
$window._gaq.push(['_trackPageview', $location.hashPath.substr(1)]);
|
2010-11-16 21:39:50 +00:00
|
|
|
};
|
2010-11-19 00:53:11 +00:00
|
|
|
|
|
|
|
|
this.getFeedbackUrl = function() {
|
|
|
|
|
return "mailto:angular@googlegroups.com?" +
|
|
|
|
|
"subject=" + escape("Feedback on " + $location.href) + "&" +
|
|
|
|
|
"body=" + escape("Hi there,\n\nI read " + $location.href + " and wanted to ask ....");
|
2010-12-10 21:55:18 +00:00
|
|
|
};
|
2010-10-27 22:31:10 +00:00
|
|
|
}
|
2010-11-15 20:15:27 +00:00
|
|
|
|
2011-01-31 19:55:44 +00:00
|
|
|
// prevent compilation of code
|
|
|
|
|
angular.widget('code', function(element){
|
|
|
|
|
element.attr('ng:non-bindable', 'true');
|
|
|
|
|
});
|
|
|
|
|
|
2010-12-10 21:55:18 +00:00
|
|
|
SyntaxHighlighter['defaults'].toolbar = false;
|
2011-06-06 15:52:02 +00:00
|
|
|
SyntaxHighlighter['defaults'].gutter = true;
|
2011-05-23 22:49:33 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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);
|
|
|
|
|
};
|
|
|
|
|
}
|