Changeset - 492de3eab3de
[Not reviewed]
0 1 0
Brett Smith (brett) - 7 years ago 2016-12-29 15:33:22
brett@sfconservancy.org
js: Rewrite #renew links to the Supporter page.

#renewal is the correct hash to use.
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/js/supporter-page.js
Show inline comments
 
/* Copyright (C) 2012-2013 Denver Gingerich, 
 
** Copyright (C) 2013-2014 Bradley M. Kuhn,
 
** Copyright (C) 2016 Brett Smith.
 
** License: GPLv3-or-later
 
**  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() {
 
    /* We've sometimes published links that say #renew instead of #renewal.
 
       Rewrite that to work as intended. */
 
    if (window.location.hash === "#renew") {
 
        window.location.hash = "#renewal";
 
    }
 
    var $selectorLink = supportTypeSelector(window.location.hash);
 
    if ($selectorLink.length > 0) {
 
        $window.scrollTop($selectorLink.offset().top);
 
    }
 
});
 

	
 
$(document).ready(function() {
 
    var siteFinalGoal = $('span#site-fundraiser-final-goal').text();
 
    var noCommaSiteFinalGoal = parseInt(siteFinalGoal.replace(/,/g, ""));
 
    var siteMatchCount = $('span#site-fundraiser-match-count').text();
 
    var noCommaSiteMatchCount = parseInt(siteMatchCount.replace(/,/g, ""));
 
    if (! noCommaSiteMatchCount) {
 
        noCommaSiteMatchCount = "0";
 
    }
 
    var barParts = [{
 
        value: (noCommaSiteMatchCount / noCommaSiteFinalGoal) * 100,
 
        text: noCommaSiteMatchCount.toLocaleString() + " matched!",
 
        barClass: "progress",
 
        textClass: "soFarText",
 
    }];
 
    if (barParts[0].value < 100) {
 
        var matchesLeft = noCommaSiteFinalGoal - noCommaSiteMatchCount;
 
        barParts.push({
 
            value: 100,
0 comments (0 inline, 0 general)