Skip to content

Instantly share code, notes, and snippets.

@andrew-tc
Last active February 7, 2018 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrew-tc/1baa848de0c9f78bcae942a3de331c05 to your computer and use it in GitHub Desktop.
Save andrew-tc/1baa848de0c9f78bcae942a3de331c05 to your computer and use it in GitHub Desktop.
Stack Exchange Bounty Form JavaScript
<script>
$(function() {
var page = 1;
$('#start-bounty-popup .next-page').click(function() {
$('#start-bounty-popup #bountyamount-confirm').html($('#bountyamount option:selected').data('confirm'));
var popup = $('#start-bounty-popup');
popup.fadeOut('fast', function() {
$('#pane-main .page' + page).hide();
page += 1;
$('#pane-main .page' + page).show();
popup.center().fadeIn('fast', function() {
if ($('.page3').is(':visible')) {
$('#custom-message').focus();
}
});
});
});
$('#start-bounty-popup .back').click(function() {
var popup = $('#start-bounty-popup');
popup.fadeOut('fast', function() {
$('#pane-main .page' + page).hide();
page -= 1;
$('#pane-main .page' + page).show();
popup.center().fadeIn();
});
});
$("#start-bounty-popup a.cancel").click(function() {
$('#start-bounty-popup .popup-close a').click();
});
$('#start-bounty-popup .action-desc').click(function() {
$(this).closest('li').find('input').click();
});
$('#start-bounty-popup #custom-message').charCounter({
min: 30,
max: 3000
});
$('#start-bounty-form').submit(function() {
$('#bounty-start').disable();
var length = $('#start-bounty-popup #custom-message').val().length;
var good = (length == 0) || (length >= 30 && length <= 3000);
if (!good) {
$('#bounty-submit-error').show();
$('#bounty-start').enable();
}
return good;
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment