Changeset - 26ff31bb7878
[Not reviewed]
5 5 0
Ben Sturmfels (bsturmfels) - 2 years ago 2021-11-16 02:25:39
ben@sturm.com.au
progress bar: Drop JS, make mobile friendly, match design to new site.

The existing jQuery UI-based fundraising progress bar used a float layout,
making it hard to adapt for mobile use. Given that there is not interactivity,
I've dropped all the JS and switched to a flexbox layout. This works well
because the bar will stretch to fit the text rather than always maintaining its scale.
10 files changed with 48 insertions and 650 deletions:
0 comments (0 inline, 0 general)
www/conservancy/local_context_processors.py
Show inline comments
...
 
@@ -4,13 +4,14 @@ from pytz import utc as UTC
 
import conservancy.settings
 
from conservancy.apps.fundgoal.models import FundraisingGoal as FundraisingGoal
 

	
 
SITE_FUNDGOAL = 'cy2020-end-year-match'
 
SITE_FUNDGOAL = 'cy2021-end-year-match'
 
# FIXME: Move this information into the model.
 
FUNDGOAL_ENDTIMES = {
 
    # Noon UTC = the end of the previous day anywhere on Earth (AOE)
 
    'cy2018-end-year-match': DateTime(2019, 1, 16, 12, tzinfo=UTC),
 
    'cy2019-end-year-match': DateTime(2020, 1, 16, 12, tzinfo=UTC),
 
    'cy2020-end-year-match': DateTime(2021, 1, 16, 12, tzinfo=UTC),
 
    'cy2021-end-year-match': DateTime(2021, 1, 16, 12, tzinfo=UTC),
 
}
 

	
 
def fundgoal_lookup(fundraiser_sought):
www/conservancy/static/css/conservancy.css
Show inline comments
...
 
@@ -298,45 +298,44 @@ body > header {
 
  margin-left: .5rem;
 
}
 

	
 
#progressbar {
 
    height: 1.8em;
 
.fundraiser-top-text {
 
  background: #F0FFB8;
 
  margin-top: -.5rem;
 
}
 

	
 
#progressbar .ui-widget-header {
 
    background: rgb(206, 31, 31);
 
.fundraiser-top-text p {
 
  font-size: 110%;
 
  font-style: italic;
 
  text-align: center;
 
}
 

	
 
#siteprogressbar .goalText {
 
    color: #557733;
 
    font-size: 10pt;
 
  color: #557733;
 
}
 
#siteprogressbar .soFarText {
 
    font-size: 10pt;
 
}
 
#siteprogressbar .progress {
 
    background: #577632;
 
}
 
@media all and (max-width: 600px) {
 
  .goalText {
 
      font-size: 8pt;
 
  }
 
  .soFarText {
 
      font-size: 8pt;
 
  }
 
  color: white;
 
}
 
#siteprogressbar .progress {
 
    background: #577632;
 
}
 
#siteprogressbar .middle-goal {
 
    background: #d0d0d0;
 
  background: linear-gradient(var(--khaki-green), #84a377, var(--khaki-green));
 
  padding-left: 0.5rem;
 
  padding-right: 0.5rem;
 
  border-top-left-radius: 16px;
 
  border-bottom-left-radius: 16px;
 
  border: 1px solid #3f4439;
 
}
 

	
 
#siteprogressbar .final-goal {
 
    background: #eeeeee;
 
  border-top-right-radius: 16px;
 
  border-bottom-right-radius: 16px;
 
  border: 1px solid #9bac88;
 
  border-left: none;
 
}
 

	
 
#fundraiser-percentage {
 
    text-align: center;
 
#siteprogressbar .progress.matched {
 
  border-top-right-radius: 16px;
 
  border-bottom-right-radius: 16px;
 
}
 
#siteprogressbar {
 
  background: linear-gradient(var(--washed-green), white, var(--washed-green));
 
  box-shadow: 1px 1px 1px rgba(0,0,0,0.2);
 
  line-height: 1.3;
 
  border-radius: 16px;
 
}
 

	
 
#container #mainContent {
...
 
@@ -654,21 +653,6 @@ dd {
 
    margin: 0 0 1.5em 2em;
 
}
 

	
 
.fundraiser-top-text {
 
    background: #F0FFB8;
 
    padding: .2em .7em;
 
}
 
.fundraiser-top-text * {
 
    margin: .5em auto;
 
    max-width: 70em;
 
    width: 95%;
 
}
 
.fundraiser-top-text p {
 
    font-size: 110%;
 
    font-style: italic;
 
    text-align: center;
 
}
 

	
 
/* Fallback elements created by conservancy.js when no video source is
 
   supported. */
 
div.small-right, div.medium-right {
www/conservancy/static/css/jquery-ui-1.8.22.custom.css
Show inline comments
 
deleted file
www/conservancy/static/css/jquery.ui.multiprogressbar.css
Show inline comments
 
deleted file
www/conservancy/static/js/conservancy.js
Show inline comments
...
 
@@ -19,38 +19,6 @@ $(document).ready(function() {
 
        $('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')
...
 
@@ -69,23 +37,6 @@ $(document).ready(function() {
 
            $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);
 
    });
 

	
 
    $('input[name=on0]:radio').on('change', function(event, duration) {
 
        var $input = $(this);
www/conservancy/static/js/jquery-ui-1.8.22.custom.min.js
Show inline comments
 
deleted file
www/conservancy/static/js/jquery.outerhtml.js
Show inline comments
 
deleted file
www/conservancy/static/js/jquery.ui.multiprogressbar.js
Show inline comments
 
deleted file
www/conservancy/static/views.py
Show inline comments
...
 
@@ -3,7 +3,6 @@ import os.path
 
from django.http import HttpResponse
 
from django.template.response import TemplateResponse
 

	
 
from conservancy.apps.fundgoal.models import FundraisingGoal
 
from conservancy.local_context_processors import fundgoal_lookup
 

	
 
STATIC_ROOT = os.path.abspath(os.path.dirname(__file__))
www/conservancy/templates/base_conservancy.html
Show inline comments
...
 
@@ -17,12 +17,7 @@
 
    <link rel="stylesheet" type="text/css" href="{% static 'css/tachyons.css' %}"/>
 
    <link rel="stylesheet" type="text/css" media="screen" href="/css/conservancy.css" />
 
    <link rel="stylesheet" type="text/css" media="(min-width: 67em)" href="/css/conservancy-bigscreen.css" />
 
    <link rel="stylesheet" href="/css/jquery-ui-1.8.22.custom.css" />
 
    <link rel="stylesheet" href="/css/jquery.ui.multiprogressbar.css" />
 
    <script type="text/javascript" src="/js/jquery-1.7.2.js"></script>
 
    <script type="text/javascript" src="/js/jquery-ui-1.8.22.custom.min.js"></script>
 
    <script type="text/javascript" src="/js/jquery.outerhtml.js"></script>
 
    <script type="text/javascript" src="/js/jquery.ui.multiprogressbar.js"></script>
 
    <script type="text/javascript" src="/js/conservancy.js"></script>
 
    {% block head %}{% endblock %}
 
  </head>
...
 
@@ -114,8 +109,9 @@
 
{% if sitefundgoal and sitefundgoal.fundraiser_so_far_amount and datetime_now < sitefundgoal_endtime %}
 
{% with this_match_goal=sitefundgoal.fundraiser_goal_amount this_match_so_far=sitefundgoal.fundraiser_so_far_amount %}
 
{% with this_match_remaining=this_match_goal|subtract:this_match_so_far sitefundgoal_timeleft=sitefundgoal_endtime|subtract:datetime_now %}
 
    <div class="fundraiser-top-text">
 
      <p>
 
    <div class="fundraiser-top-text ph2 ph3-ns pt2 pb3">
 
      <div class="mw8 center ph2 ph4-ns">
 
      <div class="mt2 mb3 tc">
 
        {% if this_match_remaining <= 0 %}
 
          Thanks to {{ sitegoal.fundraiser_donation_count|intcomma }} Sustainers we earned our full match!
 
          Help us go further to stand up for software freedom &mdash; <a href="/sustainer">sign up now</a>!
...
 
@@ -134,24 +130,28 @@
 
        next ${{ this_match_remaining|floatformat:0|intcomma }} of <a href="/sustainer/">support we receive</a> will be matched!
 

	
 
        {% endif %}
 
      </p>
 
      </div>
 

	
 
{% if sitefundgoal.fundraiser_so_far_amount %}
 
<div id="siteprogressbar">
 
<a href="/sustainer">
 
  We've matched
 
<a href="/sustainer/" style="text-decoration: none !important">
 
<div id="siteprogressbar" class="flex items-stretch w-100">
 
  {% if this_match_remaining <= 0 %}
 
  $<span id="site-fundraiser-match-count">{{ this_match_goal|intcomma }}</span>
 
    <div class="progress matched tc pv1 b dt" style="flex-basis: {{ this_match_so_far }}px">
 
      <span id="site-fundraiser-match-count" class="soFarText dtc v-mid">${{ this_match_goal|floatformat:0|intcomma }} matched!</span>
 
    </div>
 
  {% else %}
 
  $<span id="site-fundraiser-match-count">{{ this_match_so_far|intcomma }}</span>
 
  {% endif %}
 
  of
 
  $<span id="site-fundraiser-final-goal">{{ this_match_goal|intcomma }}</span>
 
  so far!
 
</a>
 
    <div class="progress tc pv1 b dt" style="flex-basis: {{ this_match_so_far }}px">
 
      <span id="site-fundraiser-match-count" class="soFarText dtc v-mid">${{ this_match_so_far|floatformat:0|intcomma }} matched!</span>
 
    </div>
 
    <div class="final-goal tc pv1 b dt" style="flex-basis: {{ this_match_remaining }}px">
 
      <span id="site-fundraiser-final-goal" class="goalText dtc v-mid">${{ this_match_remaining|floatformat:0|intcomma }} to go!</span>
 
    </div>
 
    {% endif %}
 
</div>
 
</a>
 
{% endif %}
 

	
 
</div>
 
</div>
 
{% endwith %}
 
{% endwith %}
0 comments (0 inline, 0 general)