Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 67826f5

Browse files
Splaktarjelbourn
authored andcommitted
docs: allow up/down/page up/page down to scroll docs content (#11712)
don't convert menu-headers to anchors as they have no content convert skip to content button to an icon button with tooltip - make it visible always Fixes #2961
1 parent 16cea88 commit 67826f5

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

docs/app/css/style.css

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,19 @@ ul.skip-links li {
173173
padding: 0;
174174
}
175175
ul.skip-links li a {
176-
background-color: #fff;
177-
display: block;
178-
margin: 0.5em 0 0.5em 0.5em;
179-
opacity: 0;
180-
left: 0;
176+
color: white;
177+
margin: 0.9em 0 0.5em 0.5em !important;
178+
right: 0;
181179
position: absolute;
182-
text-decoration: none;
183180
top: 0;
184-
width: 92%;
185-
transition: opacity 0.15s linear;
186-
}
187-
ul.skip-links li a:focus {
188-
background-color: #fff !important;
189-
opacity: 1;
190181
z-index: 2;
191182
}
183+
ul.skip-links li a md-icon {
184+
color: white;
185+
}
186+
.md-breadcrumb:focus {
187+
outline: #BDBDC0 solid 2px;
188+
}
192189
/*******************
193190
* CODE HIGHLIGHTING
194191
*******************/
@@ -346,8 +343,6 @@ body[dir=rtl] .docs-menu .md-button {
346343
padding: 8px 16px 0;
347344
text-align: left;
348345
width: 100%;
349-
}
350-
.menu-heading>a {
351346
color: white;
352347
font-weight: 700;
353348
font-size: 12px;

docs/app/js/anchor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
function postLink(scope, element, attr, ctrl) {
2222

2323
// Only create anchors when being inside of a md-content.
24-
if (!ctrl) {
24+
// Don't create anchors for menu headers as they have no associated content.
25+
if (!ctrl || element[0].classList && element[0].classList.contains('menu-heading')) {
2526
return;
2627
}
2728

docs/app/js/app.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ function($scope, COMPONENTS, BUILDCONFIG, $mdSidenav, $timeout, $mdDialog, menu,
643643
this.autoFocusContent = false;
644644

645645

646-
var mainContentArea = document.querySelector("[role='main']");
646+
var mainContentArea = document.querySelector("main");
647+
var mainContentHeader = mainContentArea.querySelector(".md-breadcrumb");
647648
var scrollContentEl = mainContentArea.querySelector('md-content[md-scroll-y]');
648649

649650

@@ -682,12 +683,13 @@ function($scope, COMPONENTS, BUILDCONFIG, $mdSidenav, $timeout, $mdDialog, menu,
682683
}
683684

684685
function focusMainContent($event) {
686+
$scope.closeMenu();
685687
// prevent skip link from redirecting
686688
if ($event) { $event.preventDefault(); }
687689

688690
$timeout(function(){
689-
mainContentArea.focus();
690-
},90);
691+
mainContentHeader.focus();
692+
}, 90);
691693

692694
}
693695

@@ -918,7 +920,7 @@ function($rootScope, $scope, component, demos, $templateRequest) {
918920
.directive('cacheScrollPosition', ['$route', '$mdUtil', '$timeout', '$location', '$anchorScroll',
919921
'scrollCache',
920922
function($route, $mdUtil, $timeout, $location, $anchorScroll, scrollCache) {
921-
var mainContentArea = document.querySelector("[role='main']");
923+
var mainContentArea = document.querySelector("main");
922924
var scrollContentEl = mainContentArea.querySelector('md-content[md-scroll-y]');
923925

924926
/**

docs/config/template/index.template.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ <h1 class="docs-logotype md-heading">AngularJS Material</h1>
2727
</header>
2828

2929
<ul class="skip-links">
30-
<li class="md-whiteframe-z2">
31-
<md-button ng-click="focusMainContent($event)" href="#">Skip to content</md-button>
30+
<li>
31+
<md-button class="md-icon-button" ng-click="focusMainContent($event)" href="#"
32+
aria-label="Skip to main content">
33+
<md-tooltip>Focus main content header</md-tooltip>
34+
<md-icon md-svg-src="img/icons/ic_chevron_right_24px.svg"></md-icon>
35+
</md-button>
3236
</li>
3337
</ul>
3438

@@ -54,15 +58,15 @@ <h2 class="menu-heading md-subhead" ng-if="section.type === 'heading'" id="headi
5458
</md-content>
5559
</md-sidenav>
5660

57-
<div layout="column" tabIndex="-1" role="main" flex>
61+
<main layout="column" flex>
5862
<md-toolbar class="md-whiteframe-glow-z1 site-content-toolbar" md-theme="site-toolbar">
5963

6064
<div class="md-toolbar-tools docs-toolbar-tools" tabIndex="-1">
6165
<md-button class="md-icon-button" ng-click="openMenu()" hide-gt-sm aria-label="Toggle Menu">
6266
<md-icon md-svg-src="img/icons/ic_menu_24px.svg"></md-icon>
6367
</md-button>
6468
<div layout="row" flex class="fill-height">
65-
<h2 class="md-toolbar-item md-breadcrumb md-headline">
69+
<h2 class="md-toolbar-item md-breadcrumb md-headline" tabindex="-1">
6670
<span ng-if="menu.currentPage.name !== menu.currentSection.name">
6771
<span hide-sm hide-md>{{menu.currentSection.name}}</span>
6872
<span class="docs-menu-separator-icon" hide-sm hide-md style="transform: translate3d(0, 1px, 0)">
@@ -176,7 +180,7 @@ <h2 class="md-toolbar-item md-breadcrumb md-headline">
176180

177181
</md-content>
178182

179-
</div>
183+
</main>
180184

181185

182186
<!-- Preload is (currently) only used for testing jQuery -->

0 commit comments

Comments
 (0)