diff options
| author | Sebastian Müller | 2014-01-13 21:32:20 +0100 |
|---|---|---|
| committer | Peter Bacon Darwin | 2014-01-14 06:39:44 +0000 |
| commit | 02a45826f12842a5eec07989264abbe42b381a7c (patch) | |
| tree | 9fa05211283176de8a57d068b8d530aecfd2e099 /docs/src/templates/js/docs.js | |
| parent | e324c149077d99cb722ab3b9e05759cb4dfa07a9 (diff) | |
| download | angular.js-02a45826f12842a5eec07989264abbe42b381a7c.tar.bz2 | |
docs(docs): preserve path to current doc page when switching versions
Preserve URL path when switching between doc versions.
Closes #4661
Closes #5773
Diffstat (limited to 'docs/src/templates/js/docs.js')
| -rw-r--r-- | docs/src/templates/js/docs.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js index 331a781e..15041774 100644 --- a/docs/src/templates/js/docs.js +++ b/docs/src/templates/js/docs.js @@ -5,11 +5,19 @@ var docsApp = { filter: {} }; -docsApp.controller.DocsVersionsCtrl = ['$scope', '$window', 'NG_VERSIONS', 'NG_VERSION', function($scope, $window, NG_VERSIONS, NG_VERSION) { +docsApp.controller.DocsVersionsCtrl = ['$scope', '$rootScope', '$window', 'NG_VERSIONS', 'NG_VERSION', function($scope, $rootScope, $window, NG_VERSIONS, NG_VERSION) { $scope.docs_versions = NG_VERSIONS; $scope.docs_version = NG_VERSIONS[0]; + $scope.jumpToDocsVersion = function(version) { - $window.location = version.url; + var currentPagePath = ''; + + // preserve URL path when switching between doc versions + if (angular.isObject($rootScope.currentPage) && $rootScope.currentPage.section && $rootScope.currentPage.id) { + currentPagePath = '/' + $rootScope.currentPage.section + '/' + $rootScope.currentPage.id; + } + + $window.location = version.url + currentPagePath; }; }]; @@ -645,7 +653,7 @@ docsApp.serviceFactory.sections = ['NG_PAGES', function sections(NG_PAGES) { }]; -docsApp.controller.DocsController = function($scope, $location, $window, $cookies, sections) { +docsApp.controller.DocsController = function($scope, $rootScope, $location, $window, $cookies, sections) { $scope.fold = function(url) { if(url) { $scope.docs_fold = '/notes/' + url; @@ -736,9 +744,9 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie sectionName = SECTION_NAME[sectionId] || sectionId, page = sections.getPage(sectionId, partialId); - $scope.currentPage = sections.getPage(sectionId, partialId); + $rootScope.currentPage = sections.getPage(sectionId, partialId); - if (!$scope.currentPage) { + if (!$rootScope.currentPage) { $scope.partialTitle = 'Error: Page Not Found!'; } |
