From eb51b024c9b77527420014cdf7dbb292b5b9dd6b Mon Sep 17 00:00:00 2001
From: Jeff Cross
Date: Wed, 6 Nov 2013 10:19:36 -0800
Subject: fix(docModuleComponents): implement anchor scroll when content added
When navigating to URLs such as
docs.angularjs.org/api/ng#filter, the browser
was not able to navigate to the named anchor,
"filter," because the anchor did not yet exist
in the DOM.
This fix uses the $anchorScroll service
to automatically scroll to the right place when
the content has been added to the page.
Fixes #4703
---
docs/src/templates/js/docs.js | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
(limited to 'docs/src/templates')
diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js
index 70c5c888..5a99ef46 100644
--- a/docs/src/templates/js/docs.js
+++ b/docs/src/templates/js/docs.js
@@ -207,28 +207,29 @@ docsApp.directive.sourceEdit = function(getEmbeddedTemplate) {
}
};
-docsApp.directive.docModuleComponents = ['sections', function(sections) {
+docsApp.directive.docModuleComponents = function() {
return {
template: '
' +
'
Module Components
' +
- '
' +
- '
{{ section.title }}
' +
- '
' +
- ' ' +
- ' | Name | ' +
- ' Description | ' +
- '
' +
- ' ' +
- ' | {{ component.shortName }} | ' +
- ' {{ component.shortDescription }} | ' +
- '
' +
- '
' +
+ '
' +
+ '
{{ section.title }}
' +
+ '
' +
+ ' ' +
+ ' | Name | ' +
+ ' Description | ' +
+ '
' +
+ ' ' +
+ ' | {{ component.shortName }} | ' +
+ ' {{ component.shortDescription }} | ' +
+ '
' +
+ '
' +
'
' +
'
',
scope : {
module : '@docModuleComponents'
},
- controller : ['$scope', function($scope) {
+ controller : ['$scope', '$anchorScroll', '$timeout', 'sections',
+ function($scope, $anchorScroll, $timeout, sections) {
var validTypes = ['property','function','directive','service','object','filter'];
var components = {};
angular.forEach(sections.api, function(item) {
@@ -239,16 +240,17 @@ docsApp.directive.docModuleComponents = ['sections', function(sections) {
components[type] = components[type] || {
title : type,
type : type,
- components : []
+ components : []
};
components[type].components.push(item);
}
}
});
$scope.components = components;
+ $timeout($anchorScroll, 0, false);
}]
};
-}]
+};
docsApp.directive.docTutorialNav = function(templateMerge) {
var pages = [
@@ -411,7 +413,7 @@ docsApp.serviceFactory.prepareDefaultAppModule = function() {
var moduleName = 'App';
return {
module : moduleName,
- script : "angular.module('" + moduleName + "', [" +
+ script : "angular.module('" + moduleName + "', [" +
(deps.length ? "'" + deps.join("','") + "'" : "") + "]);\n\n"
};
};
@@ -709,7 +711,7 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie
error: 'Error Reference'
};
- populateComponentsList();
+ populateComponentsList();
$scope.$watch(function docsPathWatch() {return $location.path(); }, function docsPathWatchAction(path) {
// ignore non-doc links which are used in examples
--
cgit v1.2.3