Skip to content
Snippets Groups Projects
Commit bca7bd7f authored by Alice Heaton's avatar Alice Heaton :speech_balloon:
Browse files

Make the file upload button work when javascript is disabled.

parent 823e95e5
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
* - The form element should have a 'auto-upload-file' class; * - The form element should have a 'auto-upload-file' class;
* - The upload button replacement should have an 'upload-button' class * - The upload button replacement should have an 'upload-button' class
* (optional, we can also use the normal upload button). * (optional, we can also use the normal upload button).
* - The file input tag should be a descendant of a .form-group element
* (optional, this will be hidden if we have a button replacement).
*
* This is progressive enhancement, so the upload-button should be hidden
* to be begin with, and will only be displayed if the javascript executes.
* *
* Note that this will only work if the form has one file upload element. * Note that this will only work if the form has one file upload element.
* *
...@@ -17,6 +22,13 @@ ...@@ -17,6 +22,13 @@
var $form = $(this); var $form = $(this);
var $button = $('.upload-button', $form); var $button = $('.upload-button', $form);
var $file_input = $('[type="file"]', $form); var $file_input = $('[type="file"]', $form);
var $input_group = $file_input.closest('.form-group');
// Hide the file input group and show the alternative button.
if ($button.length > 0) {
$input_group.hide();
$button.show();
}
// Auto-submit // Auto-submit
$file_input.on('change', function(e) { $file_input.on('change', function(e) {
......
...@@ -402,6 +402,12 @@ body { ...@@ -402,6 +402,12 @@ body {
line-height: 1.33; line-height: 1.33;
} }
// Auto-upload button. Progressive enhencement, this
// will be displayed if the associated js executes.
.auto-upload-file .upload-button {
display: none;
}
// Grid Demo Elements // Grid Demo Elements
.show-grid [class^="col-"] { .show-grid [class^="col-"] {
...@@ -519,4 +525,4 @@ body { ...@@ -519,4 +525,4 @@ body {
.fa-fw { .fa-fw {
color:@gray-base; color:@gray-base;
margin-right:5px; margin-right:5px;
} }
\ No newline at end of file
//Styles for import, loading and sources //Styles for import, loading and sources
.bootstrap3-multi-input {
display:none;
}
.item-source-info > h2 { .item-source-info > h2 {
margin:15px; margin:15px;
} }
...@@ -12,4 +8,4 @@ ...@@ -12,4 +8,4 @@
.item-source-info > h2 > img { .item-source-info > h2 > img {
max-width: 120px; max-width: 120px;
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment