Changeset - 9d855fda0862
[Not reviewed]
0 1 0
Brett Smith (brett) - 4 years ago 2017-01-01 20:28:33
brett@sfconservancy.org
supporter: Improve shirt selection JavaScript.

* Add an animation for state changes.
* Set the start state by triggering the event on the selection at page load.
Firefox at least remembers the selected button on page load. This avoids
a situation where the user says they want a shirt, reload, and now the
size selection is invisible because we used to hide that unconditionally.
1 file changed with 9 insertions and 9 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/js/conservancy.js
Show inline comments
...
 
@@ -86,18 +86,18 @@ $(document).ready(function() {
 
                                  $otherTextControl.find('.donate-box-highlight').fadeIn(10000);
 
                                }, 500);
 
    });
 
    $(".t-shirt-size-selector").hide();
 
    $('input[name=on0]:radio').change(function() {
 

	
 
    $('input[name=on0]:radio').on('change', function(event, duration) {
 
        var $input = $(this);
 
        var wantShirt = $input.val() == "wantGiftYes";
 
        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");
 
        $('input', $tShirtSelector).prop('disabled', wantShirt);
 
        $('input[name=no_shipping]', $form).val(wantShirt ? '2' : '0');
 
        if (wantShirt) {
 
            $tShirtSelector.slideDown(duration);
 
        } else {
 
            $tShirtSelector.hide();
 
            $noShippingSelector.val("0");
 
            $tShirtSelector.slideUp(duration);
 
        }
 
    });
 
    }).filter(':checked').trigger('change', 0);
 
});
0 comments (0 inline, 0 general)