Files
Grav-Admin-Plugin/themes/grav/app/forms/fields/files.js
Andy Miller 8cd0279b01 Feature/upload improvements (#617)
* various improvements.. needs cleanup

* more progress - supports deeply nested + pages

* Getting close now!

* more progress!

* some cleanup

* use data[_json] to store page-based upload

* Smarter logic to get nested form fields

* some refactoring/cleanup

* Fixed issue with removing multiple files in pages

* Refactor and support `destination: page@:/images` and `destination: self@` syntax for file fields

* Prettifying the upload field

* Handling Files API to better represent the selected files in the input field

* Better plurarl string

* Fixed harcoded height for input field

* revamped CSS!!!

* `fancy: false` turns off fancy styling

* Create folder if not exists

* Add support for @theme/theme@ destination

* Fixed create directory functionality to take into account resolved paths

* Don't allow @self on page to be uploaded to if not created

* added field languages

* css tweaks

* language integration
2016-05-26 14:49:45 -06:00

23 lines
629 B
JavaScript

import $ from 'jquery';
import format from '../../utils/formatbytes';
$('body').on('change', '.form-input-file > input[type="file"]', (event) => {
let input = event.target;
let files = input.files;
let container = $(input).next();
if (files.length) {
let plural = files.length > 1 ? 's' : '';
let html = '';
html += `${files.length} file${plural} selected`;
html += '<ul>';
for (let i = 0; i < files.length; i++) {
html += `<li>${files[i].name} (${format(files[i].size, 2)})</li>`;
}
html += '</ul>';
container.html(html);
}
});