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

Commit 1257248

Browse files
committed
Added TOC link to beginning of article
Accessibility aid for tab navigation
1 parent c09a007 commit 1257248

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

resources/js/contentTransformation.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ window.addEventListener('load', function () {
2626
$toc.find('.toctoggle').attr('hidden', '');
2727
$toc.find('>ul').addClass('uk-nav uk-nav-default uk-margin-remove-top')
2828
.attr('uk-scrollspy-nav', 'closest: li; scroll: true;'); // BUG: Scrollspy isn't working (uikit#3100)
29+
// Useful for tab navigation
30+
$toc.find('>ul').prepend(`
31+
<li class="toclevel-0 tocsection-0 uk-parent">
32+
<a href="#content">
33+
<span class="tocnumber"></span>
34+
<span class="toctext">Introduction</span>
35+
</a></li>`);
2936
$toc.find('.toclevel-1').addClass('uk-parent');
3037
$toc.find('.toclevel-1>ul').addClass('uk-nav-sub');
3138
}
@@ -122,10 +129,10 @@ window.addEventListener('load', function () {
122129
$table = $('table').addClass('uk-table uk-table-divider uk-table-hover uk-table-justify uk-table-small uk-text-small tablesorter');
123130

124131
// TODO: Add more tools to the history tools menu (next to the "undo")
125-
132+
126133
// TODO: Make sure this sorts properly at the beginning of a month
127134
$table.tablesorter();
128-
135+
129136
};
130137
});
131138

@@ -154,15 +161,15 @@ window.addEventListener('load', function () {
154161
var caller = $(this).next();
155162

156163
$.getJSON('https://en.wikipedia.org/api/rest_v1/page/summary/' + $(this)[0].title)
157-
.done(function (res) {
158-
caller.find('h2').html(res.title);
159-
if (res.type != 'no-extract') {
160-
caller.find('p').html(res.extract);
161-
};
162-
caller.find('p').html('No extract available!'); // TODO: Add "warning" icon for policy pages, and "info" icon for guideline pages
163-
})
164-
.fail(function (res, status, err) {
165-
caller.find('p').html('Article not found!<br>Reason: ' + status + ', ' + err);
166-
});
164+
.done(function (res) {
165+
caller.find('h2').html(res.title);
166+
if (res.type != 'no-extract') {
167+
caller.find('p').html(res.extract);
168+
};
169+
caller.find('p').html('No extract available!'); // TODO: Add "warning" icon for policy pages, and "info" icon for guideline pages
170+
})
171+
.fail(function (res, status, err) {
172+
caller.find('p').html('Article not found!<br>Reason: ' + status + ', ' + err);
173+
});
167174
};
168175
});

0 commit comments

Comments
 (0)