DefinitelyTyped/types/plupload/plupload-tests.ts
Matt Gibbs 22bea9740b [plupload] Additional Documentation and .features type fix (#24919)
* Add test for features map

I can't find a good description on the site for all of the values in
this map, so for now it's just "any".  I would like to specify this
though.

* Add documentation for a couple plupload constants

* Expand features scope out to the "any" map

These are technically fixed, but there's no good documentation on what
"features" are all supported that I can find.

* Update more documentation

* WHITESPAZE
2018-04-12 10:00:40 -07:00

52 lines
1.6 KiB
TypeScript

import 'plupload';
{
const uploader = new plupload.Uploader({
browse_button: 'browse', // this can be an id of a DOM element or the DOM element itself
url: 'upload.php'
});
uploader.init();
uploader.start();
uploader.bind('FilesAdded', function (up: any, files: any) {
var html = '';
plupload.each(files, function (file: any) {
html += '<li id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></li>';
});
document.getElementById('filelist').innerHTML += html;
});
uploader.bind('Error', function (up: any, err: any) {
document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
});
if (!uploader.features.chunks || !uploader.features.multipart) {
window.alert('Your browser does not support a feature required for uploads. Try installing Flash or Silverlight.');
}
}
{
const settings: plupload_settings = {
runtimes: 'html5',
browse_button: '#button',
container: '#container',
chunk_size: '1mb',
url: 'https://fakesite.com/upload',
flash_swf_url: './plupload.flash.swf',
silverlight_xap_url: '/Scripts/plupload/js/plupload.silverlight.xap',
filters:
{
max_file_size: '50mb',
mime_types: [{ title: 'title', extensions: '*' }]
},
init: {
Error: function (up, args) {
}
}
};
const uploader = new plupload.Uploader(settings);
uploader.init();
}