Merge pull request #6308 from bugron/fix/auto_scroll-to-last-visited

Auto-scroll to the last visited/completed challenge
This commit is contained in:
Rex Schrader
2016-01-19 09:55:07 -08:00

View File

@ -263,15 +263,23 @@ $(document).ready(function() {
window.location.href = link; window.location.href = link;
}); });
if ($('.sr-only').length) { var scrollTo, dashedName = localStorage.getItem('currentDashedName'),
var lastChallenge = $('.sr-only').filter(function() { elemsToSearch = $('p.padded-ionic-icon a'), currOrLastChallenge;
return $(this).text() === ' Complete'; if (!dashedName && $('.sr-only').length) {
}); elemsToSearch = $('.sr-only');
if (lastChallenge.length) { }
lastChallenge = lastChallenge[lastChallenge.length - 1];
var scrollTo = $(lastChallenge).offset().top - 380; currOrLastChallenge = elemsToSearch.filter(function() {
$('html, body, .map-accordion').scrollTop(scrollTo); if (dashedName) {
return $(this).attr('href').match(dashedName);
} }
return $(this).text() === ' Complete';
});
if (currOrLastChallenge.length) {
currOrLastChallenge = currOrLastChallenge[currOrLastChallenge.length - 1];
scrollTo = $(currOrLastChallenge).offset().top - 380;
$('html, body, .map-accordion').scrollTop(scrollTo);
} }
if (String(window.location).match(/\/map$/ig)) { if (String(window.location).match(/\/map$/ig)) {