uc_file.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * @file
  3. * Modifies the file selection and download access expiration interfaces.
  4. */
  5. var uc_file_list = {};
  6. /**
  7. * Adds files to delete to the list.
  8. */
  9. function _uc_file_delete_list_populate() {
  10. jQuery('.affected-file-name').empty().append(uc_file_list[jQuery('#edit-recurse-directories').attr('checked')]);
  11. }
  12. jQuery(document).ready(
  13. function() {
  14. _uc_file_delete_list_populate();
  15. }
  16. );
  17. // When you (un)check the recursion option on the file deletion form.
  18. Drupal.behaviors.ucFileDeleteList = {
  19. attach: function(context, settings) {
  20. jQuery('#edit-recurse-directories:not(.ucFileDeleteList-processed)', context).addClass('ucFileDeleteList-processed').change(
  21. function() {
  22. _uc_file_delete_list_populate()
  23. }
  24. );
  25. }
  26. }
  27. /**
  28. * Give visual feedback to the user about download numbers.
  29. *
  30. * TODO: would be to use AJAX to get the new download key and
  31. * insert it into the link if the user hasn't exceeded download limits.
  32. * I dunno if that's technically feasible though.
  33. */
  34. function uc_file_update_download(id, accessed, limit) {
  35. if (accessed < limit || limit == -1) {
  36. // Handle the max download number as well.
  37. var downloads = '';
  38. downloads += accessed + 1;
  39. downloads += '/';
  40. downloads += limit == -1 ? 'Unlimited' : limit;
  41. jQuery('td#download-' + id).html(downloads);
  42. jQuery('td#download-' + id).attr("onclick", "");
  43. }
  44. }