Skip to content

Commit b958105

Browse files
author
bcgwebdesign
committed
better boundary actions
1 parent ae7bcb0 commit b958105

2 files changed

Lines changed: 46 additions & 4 deletions

File tree

themes/doi-theme/assets/sass/partials/_handbook.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
gap:10px;
6262
.prev,.next {
6363
border:1px solid lightgrey;
64-
flex-grow:1;
64+
flex-basis:50%;
6565
border-radius:10px;
6666
padding:10px;
6767
}

themes/doi-theme/static/js/script.js

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ $(function() {
176176

177177
var $parentDiv = $('.tabs-content');
178178
$parentDiv.animate({ scrollTop: 0 });
179+
genPrevNextLevelNN();
179180
});
180181

181182
// and this one for the left sub sub navs.
@@ -230,16 +231,52 @@ $(function() {
230231

231232

232233
function genPrevNextLevelN() {
233-
console.log('genprevnext');
234+
console.log('genprevnext level 1');
234235
var nextsection=$('.content.visible').next()
235236
var nextsectionid=nextsection.attr('internal-destination');
236237
var nextsectiontitle=nextsection.find('.section-title').text();
237-
$('.content.visible .prevnextnav .next .nexttext').text(nextsectiontitle);
238+
if (!nextsectionid) {
239+
$('.content.visible .prevnextnav .next .nexttext').text('');
240+
} else {
241+
$('.content.visible .prevnextnav .next .nexttext').text(nextsectiontitle);
242+
}
238243

239244
var prevsection=$('.content.visible').prev()
240245
var prevsectionid=prevsection.attr('internal-destination');
241246
var prevsectiontitle=prevsection.find('.section-title').text();
242-
$('.content.visible .prevnextnav .prev .prevtext').text(prevsectiontitle);
247+
if (!prevsectionid) {
248+
$('.content.visible .prevnextnav .prev .prevtext').text('');
249+
} else {
250+
$('.content.visible .prevnextnav .prev .prevtext').text(prevsectiontitle);
251+
}
252+
}
253+
254+
function genPrevNextLevelNN() {
255+
console.log('genprevnext level 2');
256+
var nextchapter=$('.chapters.visible').next()
257+
var nextchapterid=nextchapter.attr('internal-destination');
258+
var nextchaptertitle=nextchapter.find('h3:first').text();
259+
if (!nextchapterid) {
260+
// check for next section since we are at last chapter
261+
var nextsection=$('.content.visible').next()
262+
var nextsectionid=nextsection.attr('internal-destination');
263+
var nextsectiontitle=nextsection.find('.section-title').text();
264+
$('.content.visible .prevnextnav .next .nexttext').text(nextsectiontitle);
265+
} else {
266+
$('.content.visible .prevnextnav .next .nexttext').text(nextchaptertitle);
267+
}
268+
269+
var prevchapter=$('.chapters.visible').prev()
270+
var prevchapterid=prevchapter.attr('internal-destination');
271+
var prevchaptertitle=prevchapter.find('h3:first').text();
272+
if (!prevchapterid) {
273+
var prevsection=$('.content.visible').prev()
274+
var prevsectionid=prevsection.attr('internal-destination');
275+
var prevsectiontitle=prevsection.find('.section-title').text();
276+
$('.content.visible .prevnextnav .prev .prevtext').text(prevsectiontitle);
277+
} else {
278+
$('.content.visible .prevnextnav .prev .prevtext').text(prevchaptertitle);
279+
}
243280
}
244281

245282

@@ -248,6 +285,9 @@ $(function() {
248285
// search querystring for error param value
249286
var matches = window.location.search.match(/xref=([\w.]+)/);
250287

288+
289+
genPrevNextLevelN();
290+
251291
if (matches) {
252292
// show the matching element
253293

@@ -278,6 +318,7 @@ $(function() {
278318

279319
$('.tabs-nav nav.top-nav[internal-destination="' + id + '"]').addClass('selected');
280320
$('.tabs-nav nav.top-nav[internal-destination="' + id + '"] > a').addClass('selected');
321+
genPrevNextLevelN();
281322
}
282323
if (levels>=2) {
283324

@@ -305,6 +346,7 @@ $(function() {
305346

306347
$('.tabs-nav nav.sub-nav[internal-destination="' + id + '"]').addClass('selected');
307348
$('.tabs-nav nav.sub-nav[internal-destination="' + id + '"] > a').addClass('selected');
349+
genPrevNextLevelNN();
308350
}
309351
if (levels>=3) {
310352
id = 'sec' + parts[0] + '.' + parts[1] + '.' + parts[2];

0 commit comments

Comments
 (0)