Skip to content

Commit

Permalink
Merge pull request #105 from foundersandcoders/disable-form-input
Browse files Browse the repository at this point in the history
Disable form input
  • Loading branch information
des-des authored Mar 4, 2018
2 parents 2f66140 + 5928f98 commit 3c8bca4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion public/image-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@
var fileErrorMessage = document.getElementById('fileErrorMessage');
var spinner = document.getElementById('spinner');
var imagePreview = document.getElementById('imagePreview');
var formSubmitButton = document.getElementById('formSubmitButton');

fileInput.onchange = function() {
var fileInputFiles = fileInput.files;
var file = fileInputFiles[0];
// Dom changes
imagePreview.src = imagePreview.src && '';
spinner.classList.toggle('dn');
imagePreview.classList.add('dn');
formSubmitButton.disabled = true;

getSignedRequest(file)
.then(function(res) {
imagePreview.src = res.data.url;
hiddenFileInput.value = res.data.url;
return uploadFile(res.data.signedRequest, file);
})
.then(function() {
formSubmitButton.disabled = false;
spinner.classList.toggle('dn');
imagePreview.classList.remove('dn');
})
Expand All @@ -31,7 +36,7 @@

function getSignedRequest(file) {
return axios.get(
'/sign-s3?file-name=' + file.name + '&file-type=' + file.type,
'/sign-s3?file-name=' + file.name + '&file-type=' + file.type
);
}

Expand Down
2 changes: 1 addition & 1 deletion views/event-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
</table>
<div class="w-100 tc pa4">

<input class="f6 w4 tc grow br-pill ba bw1 b--gray pv2 dib mid-gray b bg-main outline-0" type="submit" value="{{localText.formSubmit}}">
<input class="f6 w4 tc grow br-pill ba bw1 b--gray pv2 dib mid-gray b bg-main outline-0" type="submit" value="{{localText.formSubmit}}" id="formSubmitButton">
</div>
</form>

Expand Down
2 changes: 1 addition & 1 deletion views/place-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
</table>
<div class="w-100 tc pa4">

<input class="f6 w4 tc grow br-pill ba bw1 b--gray pv2 dib mid-gray b bg-main" type="submit" value="{{localText.formSubmit}}">
<input class="f6 w4 tc grow br-pill ba bw1 b--gray pv2 dib mid-gray b bg-main" type="submit" value="{{localText.formSubmit}}" id="formSubmitButton">
</div>
</form>
<script src="/image-upload.js" charset="utf-8"></script>
Expand Down

0 comments on commit 3c8bca4

Please sign in to comment.