Changeset - f3b930579f1b
[Not reviewed]
0 1 0
Bradley Kuhn (bkuhn) - 9 years ago 2015-03-05 16:00:14
bkuhn@ebb.org
Automatically generate fundraiser percentage text.

Using this span, we can update the number in the fundraising percentage
text automatically. The downside is that non-javascript browsers will
not receive a fundraising percentage, but the upside is that fewer
things need to be calculated by hand, and now only the amount raised so
far needs updated.
1 file changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/supporter-page.js
Show inline comments
 
/* Copyright (C) 2012-2013 Denver Gingerich, 
 
** Copyright (C) 2013-2014 Bradley M. Kuhn.
 
** License: GPLv3-or-later
 
**  Find a copy of GPL at https://sfconservancy.org/GPLv3
 
*/
 

	
 
$(document).ready(function() {
 
    var goal  = $('span#fundraiser-goal').text();
 
    var soFar = $('span#fundraiser-so-far').text();
 
    var noCommaGoal = goal.replace(/,/g, "");
 
    var noCommaSoFar = soFar.replace(/,/g, "");
 
    var percentage = (parseFloat(noCommaSoFar) / parseFloat(noCommaGoal)) * 100;
 

	
 
    $("#progressbar").progressbar({ value: (parseFloat(noCommaSoFar) / parseFloat(noCommaGoal)) * 100 });
 
    $('span#fundraiser-percentage').text(percentage.toFixed(2) + "%");
 
    $("#progressbar").progressbar({ value:  percentage });
 

	
 
    $('.toggle-content').hide();
 

	
 
    $('.toggle-control')
 
     .addClass('clickable')
 
     .bind('click', function() {
 
        var $control = $(this);
 
        var $parent = $control.parents('.toggle-unit');
 

	
 
        $parent.toggleClass('expanded');
 
        $parent.find('.toggle-content').slideToggle();
 

	
0 comments (0 inline, 0 general)