Skip to content

Commit

Permalink
Clear errors when new file is uploaded (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverroick authored Aug 4, 2017
1 parent 6626fe2 commit 5c13aa1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion buckets/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.21'
__version__ = '0.1.22'
10 changes: 8 additions & 2 deletions buckets/static/buckets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@
}
}

function clearErrors(el) {
if (errs = el.querySelector('.errors')) { errs.remove(); }
}

function error(el, msg) {
message(el);
el.querySelector('.file-url').value = '';
el.querySelector('.file-input').value = '';

if (errs = el.querySelector('.errors')) { errs.remove(); }
clearErrors(el);

var errorList = document.createElement('ul');
errorList.setAttribute('class', 'errors');
Expand All @@ -58,7 +62,7 @@
var link = el.querySelector('.file-link'),
url = el.querySelector('.file-url');

if (errs = el.querySelector('.errors')) { errs.remove(); }
clearErrors(el);

url.value = fileUrl;
link.href = fileUrl;
Expand Down Expand Up @@ -155,6 +159,8 @@
file = el.querySelector('.file-input').files[0],
accepted = el.getAttribute('data-accepted-types');

clearErrors(el);

disableSubmit(el, true);
var ext = file.name.split('.').slice(-1)[0];
var type = file.type || MIME_LOOKUPS[ext];
Expand Down

0 comments on commit 5c13aa1

Please sign in to comment.