ffs.callback.js 982 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * elFinder Integration
  3. *
  4. * Copyright (c) 2010-2018, Alexey Sukhotin. All rights reserved.
  5. */
  6. function elfinder_ffs_callback(arg1) {
  7. var fieldName = Drupal.settings.elfinder.field_name;
  8. var fieldId = Drupal.settings.elfinder.filepath_id;
  9. var url = arg1;
  10. if (typeof arg1 == 'object') {
  11. if ($.isArray(arg1)) {
  12. url = arg1[0];
  13. } else {
  14. url = arg1.url;
  15. }
  16. }
  17. var filePath = url;
  18. /* Needs rework: must support both classic single file selection and multiple selection */
  19. //var filePath = arg1.join('%%');
  20. if (typeof filePath == 'undefined') {
  21. console.log('Undefined filePath, please check integration');
  22. }
  23. window.opener.jQuery('input#' + fieldId).val(filePath).change();
  24. window.opener.focus();
  25. // Avoid beforeunload event when selecting an image.
  26. // https://github.com/Studio-42/elFinder/issues/1340
  27. // Maybe remove this when elfinder js library gets updated.
  28. //$(window).off('beforeunload');
  29. window.close();
  30. }