dropzone.js 757 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import jQuery from 'jQuery';
  2. export class Dropzone {
  3. init(include) {
  4. this._include = include;
  5. }
  6. load() {
  7. if (typeof jQuery.dropzone === "undefined") {
  8. this._include.include('misago/js/dropzone.js');
  9. return this._loadingPromise();
  10. } else {
  11. return this._loadedPromise();
  12. }
  13. }
  14. _loadingPromise() {
  15. return new Promise(function(resolve) {
  16. var wait = function() {
  17. if (typeof jQuery.dropzone === "undefined") {
  18. window.setTimeout(function() {
  19. wait();
  20. }, 200);
  21. } else {
  22. resolve();
  23. }
  24. };
  25. wait();
  26. });
  27. }
  28. _loadedPromise() {
  29. return new Promise(function(resolve) {
  30. resolve();
  31. });
  32. }
  33. }
  34. export default new Dropzone();