Skip to content

Commit 8fb297f

Browse files
authored
Topic/sponsorship form fixes (#1761)
* Add sticky class to packages benefits * Display message if benefits customization * Replace disclaimer text about benefits customizations and price * Update package selection color to fits better with background * Display cost text change as legend
1 parent 8a9d173 commit 8fb297f

File tree

4 files changed

+65
-5
lines changed

4 files changed

+65
-5
lines changed

static/js/sponsors/applicationForm.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ $(document).ready(function(){
4545
benefitInput.prop("checked", true);
4646
});
4747

48+
// hide previous custom fee messages
49+
$('.custom-fee').hide();
50+
4851
mobileUpdate(package);
4952
});
5053
});
@@ -80,9 +83,23 @@ function benefitUpdate(benefitId, packageId) {
8083
const hiddenInput = benefitsInputs.filter((b) => b.getAttribute('data-benefit-id') == benefitId)[0];
8184
hiddenInput.checked = !hiddenInput.checked;
8285
clickedImg.src = newSrc;
83-
};
8486

87+
// Check if there are any type of customization. If so, display custom-fee label.
88+
let pkgBenefits = Array(...document.getElementById(`package_benefits_${packageId}`).children).map(div => div.textContent).sort();
89+
let checkedBenefis = Array(...document.querySelectorAll('[data-benefit-id]')).filter(e => e.checked).map(input => input.value).sort();
90+
91+
const hasAllBenefts = pkgBenefits.reduce((sum, id) => sum && checkedBenefis.includes(id), true);
92+
const sameBenefitsNum = pkgBenefits.length === checkedBenefis.length;
93+
94+
const customFeeElems = Array(...document.getElementsByClassName(`custom-fee-${packageId}`));
95+
if (hasAllBenefts && sameBenefitsNum) {
96+
customFeeElems.map(e => e.style.display = 'none');
97+
} else {
98+
customFeeElems.map(e => e.style.display = 'initial');
99+
}
100+
};
85101

102+
// Callback function when user selects a package;
86103
function updatePackageInput(packageId){
87104
const packageInput = document.getElementById(`id_package_${ packageId }`);
88105
packageInput.click();

static/sass/style.css

+22-1
Original file line numberDiff line numberDiff line change
@@ -3808,8 +3808,11 @@ span.highlighted {
38083808
border-bottom: none; }
38093809
#select_sponsorship_benefits_container #benefitsTable .package-input {
38103810
cursor: pointer; }
3811-
#select_sponsorship_benefits_container #benefitsTable .package-input span {
3811+
#select_sponsorship_benefits_container #benefitsTable .package-input .package-price {
38123812
padding-bottom: 0.5em; }
3813+
#select_sponsorship_benefits_container #benefitsTable .package-input .custom-fee {
3814+
font-size: 75%;
3815+
display: none; }
38133816
#select_sponsorship_benefits_container #benefitsTable .package-input h4 {
38143817
transform: rotateY(35deg); }
38153818
#select_sponsorship_benefits_container #benefitsTable .selected {
@@ -3909,6 +3912,24 @@ span.highlighted {
39093912
@media (max-width: 1200px) and (max-width: 640px) {
39103913
#select_sponsorship_benefits_container #package-selection .row .col:not(first-child) {
39113914
width: 80%; } }
3915+
@media (min-width: 1200px) {
3916+
#select_sponsorship_benefits_container {
3917+
/* Destkop version have the package selection row as a fixed header after some scrolling.
3918+
This CSS block address this logic.
3919+
*/ }
3920+
#select_sponsorship_benefits_container .sticky {
3921+
position: -webkit-sticky;
3922+
/* for Safari */
3923+
position: sticky;
3924+
top: 0;
3925+
background-color: #fcfcfc;
3926+
*zoom: 1;
3927+
filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FFF9F9F9', endColorstr='#FFFCFCFC');
3928+
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(10%, #f9f9f9), color-stop(90%, #fcfcfc));
3929+
background-image: -webkit-linear-gradient(#f9f9f9 10%, #fcfcfc 90%);
3930+
background-image: -moz-linear-gradient(#f9f9f9 10%, #fcfcfc 90%);
3931+
background-image: -o-linear-gradient(#f9f9f9 10%, #fcfcfc 90%);
3932+
background-image: linear-gradient(#f9f9f9 10%, #fcfcfc 90%); } }
39123933

39133934
#thank-you-container {
39143935
background: #417DAF;

static/sass/style.scss

+21-1
Original file line numberDiff line numberDiff line change
@@ -2673,10 +2673,15 @@ $breakpoint-desktop: 1200px;
26732673
}
26742674

26752675
.package-input {
2676-
span {
2676+
.package-price {
26772677
padding-bottom: 0.5em;
26782678
}
26792679

2680+
.custom-fee {
2681+
font-size: 75%;
2682+
display: none;
2683+
}
2684+
26802685
h4 {
26812686
transform: rotateY(35deg);
26822687
}
@@ -2831,6 +2836,21 @@ $breakpoint-desktop: 1200px;
28312836
}
28322837
}
28332838
}
2839+
2840+
2841+
@media (min-width: $breakpoint-desktop) {
2842+
/* Destkop version have the package selection row as a fixed header after some scrolling.
2843+
This CSS block address this logic.
2844+
*/
2845+
.sticky {
2846+
position: -webkit-sticky; /* for Safari */
2847+
position: sticky;
2848+
top: 0;
2849+
//background-color: #fcfcfc; /* same as content-wrapper */
2850+
@include vertical-gradient(#f9f9f9, #fcfcfc);
2851+
}
2852+
}
2853+
28342854
}
28352855

28362856
#thank-you-container {

templates/sponsors/sponsorship_benefits_form.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<div id="select_sponsorship_benefits_container">
1515
<h1>Sponsor the PSF</h1>
1616
<p>Select a sponsorship package or customize the benefits that make the most sense for your business.</p>
17+
<p><small>The listed sponsorship costs are subject to change if customization to selected benefits are made.</small></p>
1718
<br/>
1819

1920
<div class="row section-title">
@@ -24,7 +25,7 @@ <h4 class="col">Select a Sponsorship Package</h4>
2425
<div id="benefitsTable">
2526

2627
<!-- Package selection --!>
27-
<div id="package-selection">
28+
<div id="package-selection" class="sticky">
2829
<div class="row no-border">
2930
<span class="col">
3031
{% if form.errors %}
@@ -44,8 +45,9 @@ <h4 class="col">Select a Sponsorship Package</h4>
4445
{% for package in form.fields.package.queryset %}
4546
<div class="col col-items package-input" data-package-id="{{ package.id}}" onclick="updatePackageInput({{forloop.counter0}})">
4647
<h4>{{ package.name|upper }}</h4>
47-
<span>${{ package.sponsorship_amount|intcomma }}</span>
48+
<span class="package-price">${{ package.sponsorship_amount|intcomma }}<span class="custom-fee-{{ package.id }} custom-fee">*</span></span>
4849
<input type="radio" name="package" value="{{ package.id }}" id="id_package_{{ forloop.counter0 }}" {% if package.id == form.initial.package %}checked="checked"{% endif %} data-pos={{ forloop.counter0 }} />
50+
<span class="custom-fee-{{ package.id }} custom-fee">* Subject to change</span>
4951
</div>
5052
{% endfor %}
5153
</div>

0 commit comments

Comments
 (0)