Skip to content

Commit

Permalink
Merge pull request #1108 from jobara/FLUID-5098
Browse files Browse the repository at this point in the history
FLUID-5098: Identify ToC container in demos
  • Loading branch information
greatislander authored Dec 4, 2024
2 parents 9dfe6ec + 18f0cf6 commit 41fe77a
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 37 deletions.
8 changes: 7 additions & 1 deletion demos/prefsFramework/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@

<section class="flc-overviewPanel fl-overviewPanel-container"></section>
<!-- BEGIN markup for Preference Editor -->
<!--
NOTE: When using the Table of Contents preference a container for the table of contents will also need to
be added to the page. An example of this is included below.
-->
<div class="flc-prefsEditor-separatedPanel fl-prefsEditor-separatedPanel">
<!--
This div is for the sliding panel bar that shows and hides the Preference Editor controls in the mobile view.
Expand Down Expand Up @@ -163,7 +167,9 @@

<div id="content" class="demo-content">
<div id="container">
<div class="flc-toc-tocContainer toc"> </div>
<!-- BEGIN markup for Table of Contents container -->
<nav class="flc-toc-tocContainer toc"> </nav>
<!-- END markup for Table of Contents container -->

<header id="header" class="dotGovSub">
<div id="headTitle">
Expand Down
8 changes: 7 additions & 1 deletion demos/uiOptions/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@

<section class="flc-overviewPanel fl-overviewPanel-container"></section>
<!-- BEGIN markup for Preference Editor -->
<!--
NOTE: When using the Table of Contents preference a container for the table of contents will also need to
be added to the page. An example of this is included within the `<main>` element below.
-->
<div class="flc-prefsEditor-separatedPanel fl-prefsEditor-separatedPanel">
<!--
This div is for the sliding panel bar that shows and hides the Preference Editor controls in the mobile view.
Expand Down Expand Up @@ -129,7 +133,9 @@
<!-- END markup for Preference Editor -->

<main class="fl-centered">
<div class="flc-toc-tocContainer toc"> </div>
<!-- BEGIN markup for Table of Contents container -->
<nav class="flc-toc-tocContainer toc"> </nav>
<!-- END markup for Table of Contents container -->

<div class="header">
<h1>Preferences Editor</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

<body class="fl-prefsEditor-separatedPanel fl-focus">
<div class="flc-prefsEditor-panelStyle"></div>
<div class="flc-toc-tocContainer"></div>
<nav class="flc-toc-tocContainer"></nav>

<script>
fluid.uiOptions(".flc-prefsEditor-panelStyle", {
Expand Down
6 changes: 3 additions & 3 deletions examples/framework/preferences/minimalFootprint/fullPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script src="../../../../src/lib/jquery/core/js/jquery.js"></script>
<script src="../../../../src/lib/jquery/ui/js/version.js"></script>
<script src="../../../../src/lib/jquery/ui/js/keycode.js"></script>

<script src="../../../../src/framework/core/js/jquery.keyboard-a11y.js"></script>
<script src="../../../../src/framework/core/js/Fluid.js"></script>
<script src="../../../../src/framework/core/js/FluidPromises.js"></script>
Expand Down Expand Up @@ -70,8 +70,8 @@
<a href="index.html">To Content</a>
</div>
<div class="fl-hidden">
<div class="flc-toc-tocContainer">
</div>
<nav class="flc-toc-tocContainer">
</nav>
</div>

<h1>Preferences Editor: Full Page</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<a href="#">Go To Display Preferences</a>
</div>
<main class="fl-centered">
<div class="flc-toc-tocContainer toc"> </div>
<nav class="flc-toc-tocContainer toc"> </nav>

<h1>Minimal Footprint - Preferences Framework</h1>

Expand Down
2 changes: 1 addition & 1 deletion examples/framework/preferences/minimalFootprint/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a href="fullPage.html">Go To Display Preferences</a>
</div>
<main class="fl-centered">
<div class="flc-toc-tocContainer toc"> </div>
<nav class="flc-toc-tocContainer toc"> </nav>

<script>

Expand Down
6 changes: 6 additions & 0 deletions src/components/tableOfContents/js/TableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ fluid.defaults("fluid.tableOfContents", {
}
},
listeners: {
"onCreate.setLabel": {
"this": "{that}.dom.tocContainer",
"method": "attr",
"args": ["aria-label", "{that}.options.strings.tocHeader"],
"priority": "before:refreshView"
},
"onCreate.refreshView": {
func: "{that}.refreshView",
// New for FLUID-6148: Make sure we do not try to refresh view until after "levels" subcomponent is constructed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h2 id="qunit-userAgent"></h2>
<!-- Test HTML -->
<div id="qunit-fixture" >
<div id="flc-toc">
<div class="flc-toc-tocContainer toc"></div>
<nav class="flc-toc-tocContainer toc"></nav>

<h1 id="amphibians">Amphibians</h1>
<p>
Expand Down Expand Up @@ -102,7 +102,7 @@ <h3>CATT</h3>
</div>

<div id="flc-toc-noHeaders">
<div class="flc-toc-tocContainer toc"></div>
<nav class="flc-toc-tocContainer toc"></nav>
<p>Paragraph 1</p>
<div>
<p>Paragraph 2</p>
Expand All @@ -111,22 +111,27 @@ <h3>CATT</h3>
</div>

<div id="flc-toc-refreshHeadings">
<div class="flc-toc-tocContainer toc"></div>
<nav class="flc-toc-tocContainer toc"></nav>
<h2>H2</h2>
</div>

<div id="flc-toc-l10n">
<div class="flc-toc-tocContainer toc"></div>
<nav class="flc-toc-tocContainer toc"></nav>
<h2>L10N</h2>
</div>

<div id="fluid-5697">
<div class="flc-toc-tocContainer toc"></div>
<nav class="flc-toc-tocContainer toc"></nav>
<h2>Included</h2>
<h2 class="fluid-5697-exclude">Excluded</h2>
<section class="fluid-5697-exclude">
<h3>Excluded</h3>
</section>
</div>

<div id="flc-toc-nav-label">
<nav class="flc-toc-tocContainer toc"></nav>
<h2>Nav Label Test</h2>
</div>
</body>
</html>
18 changes: 18 additions & 0 deletions tests/component-tests/tableOfContents/js/TableOfContentsTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,3 +610,21 @@ jqUnit.asyncTest("FLUID-5697: Header exclusion", function () {
}
});
});


jqUnit.asyncTest("Table of Contents nav label", function () {
fluid.tableOfContents("#flc-toc-nav-label", {
strings: {
tocHeader: "Test ToC label"
},
listeners: {
onReady: {
listener: function (that) {
jqUnit.assertEquals("The toc container should have an aria-label", that.options.strings.tocHeader, that.locate("tocContainer").attr("aria-label"));
jqUnit.start();
},
args: ["{that}"]
}
}
});
});
2 changes: 1 addition & 1 deletion tests/component-tests/uiOptions/html/UIOptions-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h2 id="qunit-userAgent"></h2>
<!-- END markup for Preference Editor -->

<!-- Markup for table of contents -->
<div class="flc-toc-tocContainer toc"> </div>
<nav class="flc-toc-tocContainer toc"> </nav>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion tests/framework-tests/preferences/html/Builder-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>

<div class="flc-toc-tocContainer"></div>
<nav class="flc-toc-tocContainer"></nav>
<div id="flc-prefsEditor"></div>
<div class="flc-prefs-builder"></div>
<div class="fluid-tests-composite-prefsEditor"></div>
Expand Down
2 changes: 1 addition & 1 deletion tests/framework-tests/preferences/html/Enactors-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h2 id="qunit-userAgent"></h2>

<div class="flc-tableOfContents">
<!-- FLUID-6696: setting to display: none to ensure that the ToC container is visible after init -->
<div class="flc-toc-tocContainer" style="display: none"></div>
<nav class="flc-toc-tocContainer" style="display: none"></nav>
<h1>Heading 1</h1>
<h2>Heading 1.1</h2>
<h1>Heading 2</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h2 id="qunit-userAgent"></h2>

<!-- Test HTML -->
<div id="qunit-fixture">
<div class="flc-toc-tocContainer toc"></div>
<nav class="flc-toc-tocContainer toc"></nav>
<div id="myPrefsEditor" ></div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h2 id="qunit-userAgent"></h2>

<!-- Test HTML -->
<div id="qunit-fixture">
<div class="flc-toc-tocContainer toc"></div>
<nav class="flc-toc-tocContainer toc"></nav>
<div id="myPrefsEditor" ></div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ <h2 id="qunit-userAgent"></h2>
</div>
</div>

<div class="flc-toc-tocContainer toc">
</div>
<nav class="flc-toc-tocContainer toc">
</nav>

<div id="main">
<h1>Some Sample Title</h1>
Expand Down
4 changes: 2 additions & 2 deletions tests/framework-tests/preferences/html/PageEnhancer-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ <h2 id="qunit-userAgent"></h2>

<!-- Test HTML -->
<div id="qunit-fixture" class="container fl-font-times">
<div class="flc-toc-tocContainer toc">
</div>
<nav class="flc-toc-tocContainer toc">
</nav>

<h1>This heading is to test TOC and link creation</h1>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ <h2 id="qunit-userAgent"></h2>
</div>
</div>

<div class="flc-toc-tocContainer toc">
</div>
<nav class="flc-toc-tocContainer toc">
</nav>

<div id="main">
<h1>Some Sample Title</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
</div>
<!-- END markup for Preference Editor -->

<div class="flc-toc-tocContainer toc">
</div>
<nav class="flc-toc-tocContainer toc">
</nav>

<div id="main">
<h1>Some Sample Title</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</head>
<body>
<!-- TODO: This needs to be here otherwise TOC will simply fail -->
<div class="flc-toc-tocContainer toc">
</div>
<nav class="flc-toc-tocContainer toc">
</nav>
<h1>A test heading to provoke Table of Contents</h1>
<p>Hello, Preferences Editor!</p>
</body>
Expand Down
4 changes: 2 additions & 2 deletions tests/framework-tests/preferences/html/UIEnhancer-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ <h2 id="qunit-userAgent"></h2>

<!-- Test HTML -->
<div id="qunit-fixture" class="container">
<div class="flc-toc-tocContainer toc">
</div>
<nav class="flc-toc-tocContainer toc">
</nav>

<h1>This heading is to test TOC and link creation</h1>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@

<body class="assortedContent-theme-basic fl-focus">
<!-- BEGIN markup for Preference Editor -->
<!--
NOTE: When using the Table of Contents preference a container for the table of contents will also need to
be added to the page. An example of this is included within the `<main>` element below.
-->
<div class="flc-prefsEditor-separatedPanel fl-prefsEditor-separatedPanel">
<!--
This div is for the sliding panel bar that shows and hides the Preference Editor controls in the mobile view.
Expand Down Expand Up @@ -113,7 +117,10 @@ <h2>Instructions</h2>
<h1>HTML 5 Cheat Sheet</h1>
</header>

<nav class="flc-toc-tocContainer toc"></nav>
<!-- BEGIN markup for Table of Contents container -->
<nav class="flc-toc-tocContainer toc"> </nav>
<!-- END markup for Table of Contents container -->

<article>
<h2>HTML 5</h2>
<p class="intro fl-centered">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ <h2>Instructions</h2>

<main class="content">
<div class="fl-hidden">
<div class="flc-toc-tocContainer">
</div>
<nav class="flc-toc-tocContainer">
</nav>
</div>

<h1>Preferences Editor: Full Page using Schema</h1>
Expand Down
4 changes: 2 additions & 2 deletions tests/manual-tests/framework/preferences/fullPage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ <h2>Instructions</h2>

<main class="content">
<div class="fl-hidden">
<div class="flc-toc-tocContainer">
</div>
<nav class="flc-toc-tocContainer">
</nav>
</div>

<h1>Preferences Editor: Full Page</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<body class="prefsEditor-demo-theme fl-focus">

<div class="flc-toc-tocContainer toc">
</div>
<nav class="flc-toc-tocContainer toc">
</nav>

<div class="fl-centered">
<div class="fl-fix header">
Expand Down

0 comments on commit 41fe77a

Please sign in to comment.