script.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * FancyUpload Showcase
  3. *
  4. * @license MIT License
  5. * @author Harald Kirschner <mail [at] digitarald [dot] de>
  6. * @copyright Authors
  7. */
  8. window.addEvent('domready', function() {
  9. /**
  10. * Uploader instance
  11. */
  12. var up = new FancyUpload3.Attach('demo-list', '#demo-attach, #demo-attach-2', {
  13. path: '../../source/Swiff.Uploader.swf',
  14. url: '../script.php',
  15. fileSizeMax: 2 * 1024 * 1024,
  16. verbose: true,
  17. onSelectFail: function(files) {
  18. files.each(function(file) {
  19. new Element('li', {
  20. 'class': 'file-invalid',
  21. events: {
  22. click: function() {
  23. this.destroy();
  24. }
  25. }
  26. }).adopt(
  27. new Element('span', {html: file.validationErrorMessage || file.validationError})
  28. ).inject(this.list, 'bottom');
  29. }, this);
  30. },
  31. onFileSuccess: function(file) {
  32. new Element('input', {type: 'checkbox', 'checked': true}).inject(file.ui.element, 'top');
  33. file.ui.element.highlight('#e6efc2');
  34. },
  35. onFileError: function(file) {
  36. file.ui.cancel.set('html', 'Retry').removeEvents().addEvent('click', function() {
  37. file.requeue();
  38. return false;
  39. });
  40. new Element('span', {
  41. html: file.errorMessage,
  42. 'class': 'file-error'
  43. }).inject(file.ui.cancel, 'after');
  44. },
  45. onFileRequeue: function(file) {
  46. file.ui.element.getElement('.file-error').destroy();
  47. file.ui.cancel.set('html', 'Cancel').removeEvents().addEvent('click', function() {
  48. file.remove();
  49. return false;
  50. });
  51. this.start();
  52. }
  53. });
  54. });