tripal.file.js 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. (function ($) {
  2. Drupal.behaviors.TripalFile = {
  3. attach: function (context, settings) {
  4. // Initialize the TripalUploader object.
  5. var tripal_files = new TripalUploader();
  6. // All tables that belong to the html5-file form element should
  7. // be enabled for uploading.
  8. $('.tripal-html5-file-upload-table-key').each(function (index) {
  9. // If we already attached functionality to the field, skip it
  10. if ($(this).data('tripal.file')) {
  11. return;
  12. }
  13. // Set the field status
  14. $(this).data('tripal.file', true);
  15. // The settings for this uploader are provided in a custom variable
  16. // specific to the table. We can get the variable name by piecing
  17. // together parts of the table ID.
  18. var id = $(this).val();
  19. var details = id.split('-');
  20. var settings_var_name = 'Drupal.settings.uploader_' + details[0] + '_' + details[1] + '_' + details[2];
  21. var settings = eval(settings_var_name);
  22. // Initialize the table for uploads.
  23. tripal_files.addUploadTable(details[0] + '-' + details[1], settings);
  24. });
  25. }
  26. };
  27. })(jQuery);