Supporter page: Try #2 for scroll to type selection after window ready.
* Trigger on the "load" event rather than "ready". * Install the handler outside document's "ready" handler so it should take effect more reliably.
This commit is contained in:
parent
fa6a61ed9b
commit
ab29d45639
1 changed files with 13 additions and 8 deletions
|
@ -4,6 +4,19 @@
|
||||||
** Find a copy of GPL at https://sfconservancy.org/GPLv3
|
** Find a copy of GPL at https://sfconservancy.org/GPLv3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var supportTypeSelector = function(supportTypeHash) {
|
||||||
|
return $(".supporter-type-selector a[href=" + supportTypeHash + "]");
|
||||||
|
};
|
||||||
|
|
||||||
|
var $window = $(window);
|
||||||
|
|
||||||
|
$window.load(function() {
|
||||||
|
var $selectorLink = supportTypeSelector(window.location.hash);
|
||||||
|
if ($selectorLink.length > 0) {
|
||||||
|
$window.scrollTop($selectorLink.offset().top);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var siteFinalGoal = $('span#site-fundraiser-final-goal').text();
|
var siteFinalGoal = $('span#site-fundraiser-final-goal').text();
|
||||||
var noCommaSiteFinalGoal = parseInt(siteFinalGoal.replace(/,/g, ""));
|
var noCommaSiteFinalGoal = parseInt(siteFinalGoal.replace(/,/g, ""));
|
||||||
|
@ -222,21 +235,13 @@ $(document).ready(function() {
|
||||||
};
|
};
|
||||||
$(".supporter-type-selector a").bind("click", selectSupportType);
|
$(".supporter-type-selector a").bind("click", selectSupportType);
|
||||||
|
|
||||||
var supportTypeSelector = function(supportTypeHash) {
|
|
||||||
return $(".supporter-type-selector a[href=" + supportTypeHash + "]");
|
|
||||||
};
|
|
||||||
var selectSupportTypeFromHash = function() {
|
var selectSupportTypeFromHash = function() {
|
||||||
return supportTypeSelector(window.location.hash).click();
|
return supportTypeSelector(window.location.hash).click();
|
||||||
};
|
};
|
||||||
var $window = $(window);
|
|
||||||
$window.bind("hashchange", selectSupportTypeFromHash);
|
$window.bind("hashchange", selectSupportTypeFromHash);
|
||||||
var $selectorLink = selectSupportTypeFromHash();
|
var $selectorLink = selectSupportTypeFromHash();
|
||||||
if ($selectorLink.length === 0) {
|
if ($selectorLink.length === 0) {
|
||||||
supportTypeSelector("#annual").click();
|
supportTypeSelector("#annual").click();
|
||||||
} else {
|
|
||||||
$window.bind("ready", function() {
|
|
||||||
scrollTop($selectorLink.offset().top);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$( ".footnote-mark" ).tooltip({
|
$( ".footnote-mark" ).tooltip({
|
||||||
|
|
Loading…
Reference in a new issue