dropzone.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*=========================================================================================
  2. File Name: dropzone.js
  3. Description: dropzone
  4. --------------------------------------------------------------------------------------
  5. Item name: Vuexy - Vuejs, HTML & Laravel Admin Dashboard Template
  6. Author: PIXINVENT
  7. Author URL: http://www.themeforest.net/user/pixinvent
  8. ==========================================================================================*/
  9. Dropzone.options.dpzSingleFile = {
  10. paramName: "file", // The name that will be used to transfer the file
  11. maxFiles: 1,
  12. init: function () {
  13. this.on("maxfilesexceeded", function (file) {
  14. this.removeAllFiles();
  15. this.addFile(file);
  16. });
  17. }
  18. };
  19. /********************************************
  20. * Multiple Files *
  21. ********************************************/
  22. Dropzone.options.dpzMultipleFiles = {
  23. paramName: "file", // The name that will be used to transfer the file
  24. maxFilesize: 0.5, // MB
  25. clickable: true
  26. }
  27. /********************************************************
  28. * Use Button To Select Files *
  29. ********************************************************/
  30. new Dropzone(document.body, { // Make the whole body a dropzone
  31. url: "#", // Set the url
  32. previewsContainer: "#dpz-btn-select-files", // Define the container to display the previews
  33. clickable: "#select-files" // Define the element that should be used as click trigger to select files.
  34. });
  35. /****************************************************************
  36. * Limit File Size and No. Of Files *
  37. ****************************************************************/
  38. Dropzone.options.dpzFileLimits = {
  39. paramName: "file", // The name that will be used to transfer the file
  40. maxFilesize: 0.5, // MB
  41. maxFiles: 5,
  42. maxThumbnailFilesize: 1, // MB
  43. }
  44. /********************************************
  45. * Accepted Files *
  46. ********************************************/
  47. Dropzone.options.dpAcceptFiles = {
  48. paramName: "file", // The name that will be used to transfer the file
  49. maxFilesize: 1, // MB
  50. acceptedFiles: 'image/*'
  51. }
  52. /************************************************
  53. * Remove Thumbnail *
  54. ************************************************/
  55. Dropzone.options.dpzRemoveThumb = {
  56. paramName: "file", // The name that will be used to transfer the file
  57. maxFilesize: 1, // MB
  58. addRemoveLinks: true,
  59. dictRemoveFile: " Trash"
  60. }
  61. /*****************************************************
  62. * Remove All Thumbnails *
  63. *****************************************************/
  64. Dropzone.options.dpzRemoveAllThumb = {
  65. paramName: "file", // The name that will be used to transfer the file
  66. maxFilesize: 1, // MB
  67. init: function () {
  68. // Using a closure.
  69. var _this = this;
  70. // Setup the observer for the button.
  71. $("#clear-dropzone").on("click", function () {
  72. // Using "_this" here, because "this" doesn't point to the dropzone anymore
  73. _this.removeAllFiles();
  74. // If you want to cancel uploads as well, you
  75. // could also call _this.removeAllFiles(true);
  76. });
  77. }
  78. }