Merge branch 'master' into master

This commit is contained in:
Vincent 2018-08-29 17:58:29 +01:00 committed by GitHub
commit ac38a58a38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 14 deletions

View file

@ -1,3 +1,5 @@
var dialogOpen = false;
function showDialogWithText(titleTxt, bodyTxt) {
var modalDialog = $('#modalDialog');
var title = modalDialog.find('.modal-title');
@ -10,7 +12,10 @@ function showDialogWithText(titleTxt, bodyTxt) {
body.empty();
body.append( p );
modalDialog.modal('show');
if(!dialogOpen) {
modalDialog.modal('toggle');
dialogOpen = true;
}
}
// This should stop people ticking more than the maximum permitted
@ -67,9 +72,16 @@ function isVotingInputValid() {
// This will highlight when people haven't selected enough options
if(!valid) {
let errText = "You've only selected " + selectedCount
+ " option(s). The minimum number you need to select is " + MIN_SELECTIONS
+ " and the maximum is " + MAX_SELECTIONS + ". Please go back and correct this.";
let errText = "You've only selected " + selectedCount;
if(selectedCount > 1) {
errText += " options.";
} else {
errText = " You haven't selected any options.";
}
errText += " The minimum number you need to select is " + MIN_SELECTIONS + " and the maximum is "
+ MAX_SELECTIONS + ". Please go back and correct this.";
let titleTxt = 'Voting Error';
@ -194,7 +206,7 @@ function genBlankVote() {
vote += ",";
}
}
return vote;
}
@ -454,4 +466,30 @@ function onAfterBallotSend(ballotID, SK) {
}
modalDialog.modal('show');
}
}
$('#modalDialog').on('hide.bs.modal', function (e) {
var titleText = $(this).find('.modal-title').text();
if(titleText.indexOf("Received") > -1) {
// Update page to reflect the fact that a vote has taken place
location.reload();
} else {
// Reset poll voting to allow user to vote again
progressBar.setAttribute("style", "width: 0%;");
$('#gen-ballots-btn').toggleClass("hidden");
$('#progress-bar-description').toggleClass('hidden');
$('#progress-bar-container').toggleClass('hidden');
var inputs = $("label input[type=checkbox]");
inputs.each(function () {
var input = $(this);
input.prop('checked', false);
input.prop('disabled', false);
});
selectedCount = 0;
}
dialogOpen = false;
});