Files
@ 7fec31ce8aef
Branch filter:
Location: website/www/conservancy/static/supporter-page.js - annotation
7fec31ce8aef
5.1 KiB
application/javascript
Hide t-shirt size selector when t-shirt's unwanted
Use Javascript to hide the t-shirt size selector when the the user
selects "No" for "Do you want a t-shirt?". Reshow it (and make sure
it's shown by default) for "Yes".
Use Javascript to hide the t-shirt size selector when the the user
selects "No" for "Do you want a t-shirt?". Reshow it (and make sure
it's shown by default) for "Yes".
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 01eb8c80c8c1 7fec31ce8aef 7fec31ce8aef 7fec31ce8aef 7fec31ce8aef 7fec31ce8aef 7fec31ce8aef 7fec31ce8aef 7fec31ce8aef 7fec31ce8aef 7fec31ce8aef c54683398484 9bfb5e10dec2 9bfb5e10dec2 9bfb5e10dec2 9bfb5e10dec2 b2c18cc59e52 b2c18cc59e52 b2c18cc59e52 b2c18cc59e52 9bfb5e10dec2 9bfb5e10dec2 9bfb5e10dec2 090fb9f268a0 9bfb5e10dec2 9bfb5e10dec2 9bfb5e10dec2 9bfb5e10dec2 9bfb5e10dec2 b90413809f26 090fb9f268a0 090fb9f268a0 090fb9f268a0 090fb9f268a0 090fb9f268a0 090fb9f268a0 090fb9f268a0 090fb9f268a0 090fb9f268a0 090fb9f268a0 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 c41a897be2ce b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 44301d386ba0 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 b90413809f26 | /* Copyright (C) 2012-2013 Denver Gingerich,
** Copyright (C) 2013-2014 Bradley M. Kuhn.
** License: GPLv3-or-ater
** Find a copy of GPL at https://sfconservancy.org/GPLv3
*/
$(document).ready(function() {
$('.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');
$control.toggleClass('expanded');
$control.find('.toggle-content').slideUp("slow");
$control.find('.toggle-content').slideDown("slow");
});
$(".t-shirt-size-selector").show();
$('input[name=os1]:radio').change(function() {
var input=$(this);
var value = input.val();
if (value == "Yes") {
$(".t-shirt-size-selector").show();
} else {
$(".t-shirt-size-selector").hide();
}
});
$('#amount').addClass("valid");
$('#amount').on('input', function() {
var input=$(this);
var value = input.val();
var errorElement=$("span", input.parent());
var noCommaValue = value;
noCommaValue = value.replace(/,/g, "");
var re = /^((\d{1,3}(,?\d{3})*?(\.\d{0,2})?)|\d+(\.\d{0,2})?)$/;
var isValid = ( re.test(value) && parseInt(noCommaValue) >= 120);
if (isValid) {
input.removeClass("invalid").addClass("valid");
errorElement.removeClass("form-error-show").addClass("form-error");
$("#form-correction-needed").removeClass("form-error-show").addClass("form-error");
}
else {
input.removeClass("valid").addClass("invalid");
errorElement.removeClass("form-error").addClass("form-error-show");
}
});
$("#supporter-form-submit").click(function(event){
var valid = $('#amount').hasClass("valid");
if (! valid) {
$("#form-correction-needed").removeClass("form-error").addClass("form-error-show")
.css("font-weight", "bold").css("font-size", "150%");
event.preventDefault();
} else {
$("#form-correction-needed").removeClass("form-error-show").addClass("form-error");
}
});
/* Handle toggling of annual/monthly form selections */
$('.supporter-type-selection#monthly').hide();
$('#annualSelector').css("font-weight", "bold").css("font-size", "127%");
$("a[href$='monthly']").bind('click', function() {
$('.supporter-type-selection#annual').hide();
$('.supporter-type-selection#monthly').show();
$('#monthlySelector').css("font-weight", "bold").css("font-size", "127%");
$('#annualSelector').css("font-weight", "normal").css("font-size", "125%");
$("#form-correction-needed").removeClass("form-error-show").addClass("form-error");
});
$("a[href$='annual']").bind('click', function() {
$('.supporter-type-selection#annual').show();
$('.supporter-type-selection#monthly').hide();
$('#annualSelector').css("font-weight", "bold").css("font-size", "127%");
$('#monthlySelector').css("font-weight", "normal").css("font-size", "125%");
});
$( ".footnote-mark" ).tooltip({
items: "a",
hide: { duration: 5000 },
position: {
my: "center bottom-20",
at: "center left",
using: function( position, feedback ) {
$( this ).css( position );
$( "<div>" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
},
content: function() {
return $('.footnote-1-text').text();
}
});
});
$(window).load(function () {
verifySelctionCorrectOnPageLoad = function() {
var ourURL = document.URL;
if (ourURL.search("#monthly") > 0) {
$('.supporter-type-selection#annual').hide();
$('.supporter-type-selection#monthly').show();
$('#monthlySelector').css("font-weight", "bold").css("font-size", "127%");
$('#annualSelector').css("font-weight", "normal").css("font-size", "125%");
}
if (ourURL.search("#annual") > 0) {
$('.supporter-type-selection#monthly').hide();
$('.supporter-type-selection#annual').show();
$('#annualSelector').css("font-weight", "bold").css("font-size", "127%");
$('#monthlySelector').css("font-weight", "normal").css("font-size", "125%");
}
}
if (location.hash) {
setTimeout(verifySelctionCorrectOnPageLoad, 1);
}
window.addEventListener("hashchange", verifySelctionCorrectOnPageLoad);
});
|