Files
@ b93cc61e8b33
Branch filter:
Location: website/www/conservancy/static/js/conservancy.js - annotation
b93cc61e8b33
4.3 KiB
application/javascript
supporter: New form styling.
This makes better use of bigger screens, and degrades better to smaller
ones.
This makes better use of bigger screens, and degrades better to smaller
ones.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 619bc033bc52 619bc033bc52 619bc033bc52 619bc033bc52 619bc033bc52 619bc033bc52 619bc033bc52 619bc033bc52 619bc033bc52 619bc033bc52 619bc033bc52 619bc033bc52 619bc033bc52 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 034a60be9b5c 8605b65783f9 8605b65783f9 8605b65783f9 8605b65783f9 8605b65783f9 8605b65783f9 8605b65783f9 034a60be9b5c 8605b65783f9 8605b65783f9 034a60be9b5c 034a60be9b5c 034a60be9b5c | /* 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
*/
$(document).ready(function() {
/* When the browser doesn't support any video source, replace it
with the HTML inside the <video> element. */
var showVideoInnerHTML = function(event) {
var video = event.target.parentNode;
var div = document.createElement('div');
div.classList = video.classList;
div.innerHTML = video.innerHTML;
video.parentNode.replaceChild(div, video);
}
$('video').each(function(index, video) {
$('source', video).last().on('error', showVideoInnerHTML);
});
/* Set up the fundraiser multiprogressbar near the top of each page. */
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,
text: matchesLeft.toLocaleString() + " to go!",
barClass: "final-goal",
textClass: "goalText",
});
}
$('#siteprogressbar').empty().multiprogressbar({parts: barParts});
$('span#fundraiser-percentage').css({ 'color' : 'green',
'font-weight' : 'bold',
'float' : 'right',
'margin-right' : '40%',
'margin-top' : '2.5%',
'text-align' : 'inherit'});
/* Set up donation form elements used across the whole site. */
$('.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();
// if control has HTML5 data attributes, use to update text
if ($parent.hasClass('expanded')) {
$control.html($control.attr('data-expanded-text'));
} else {
$control.html($control.attr('data-text'));
}
});
$('a.donate-now')
.addClass('clickable')
.bind('click', function() {
var $control = $('#donate-box');
var $otherTextControl = $('.donate-sidebar');
setTimeout(function() { $control.find('.toggle-content').slideUp(100);
$control.toggleClass('expanded');
$control.find('.toggle-content').slideDown(800).fadeOut(10);
$otherTextControl.find('.donate-box-highlight').fadeOut(100);
}, 300);
setTimeout(function() { $control.find('.toggle-content').fadeIn(2000);
$otherTextControl.find('.donate-box-highlight')
.css({'font-weight': 'bold', 'font-size' : '110%' });
$otherTextControl.find('.donate-box-highlight').fadeIn(10000);
}, 500);
});
$(".t-shirt-size-selector").hide();
$('input[name=on0]:radio').change(function() {
var $input = $(this);
var $form = $input.parents('form').last();
var $tShirtSelector = $('.t-shirt-size-selector', $form);
var $noShippingSelector = $('input[name=no_shipping]', $form);
if ($input.val() == "wantGiftYes") {
$tShirtSelector.show();
$noShippingSelector.val("2");
} else {
$tShirtSelector.hide();
$noShippingSelector.val("0");
}
});
});
|