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.
This commit is contained in:
parent
b93cc61e8b
commit
9d855fda08
1 changed files with 9 additions and 9 deletions
|
@ -86,18 +86,18 @@ $(document).ready(function() {
|
||||||
$otherTextControl.find('.donate-box-highlight').fadeIn(10000);
|
$otherTextControl.find('.donate-box-highlight').fadeIn(10000);
|
||||||
}, 500);
|
}, 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 $input = $(this);
|
||||||
|
var wantShirt = $input.val() == "wantGiftYes";
|
||||||
var $form = $input.parents('form').last();
|
var $form = $input.parents('form').last();
|
||||||
var $tShirtSelector = $('.t-shirt-size-selector', $form);
|
var $tShirtSelector = $('.t-shirt-size-selector', $form);
|
||||||
var $noShippingSelector = $('input[name=no_shipping]', $form);
|
$('input', $tShirtSelector).prop('disabled', wantShirt);
|
||||||
if ($input.val() == "wantGiftYes") {
|
$('input[name=no_shipping]', $form).val(wantShirt ? '2' : '0');
|
||||||
$tShirtSelector.show();
|
if (wantShirt) {
|
||||||
$noShippingSelector.val("2");
|
$tShirtSelector.slideDown(duration);
|
||||||
} else {
|
} else {
|
||||||
$tShirtSelector.hide();
|
$tShirtSelector.slideUp(duration);
|
||||||
$noShippingSelector.val("0");
|
|
||||||
}
|
}
|
||||||
});
|
}).filter(':checked').trigger('change', 0);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue