share.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. $(document).ready(function() {
  2. var disableSharing = $('#disableSharing').data('status'),
  3. sharesLoaded = false;
  4. if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !disableSharing) {
  5. $('#fileList').on('fileActionsReady',function(){
  6. if (!sharesLoaded){
  7. OC.Share.loadIcons('file');
  8. // assume that we got all shares, so switching directories
  9. // will not invalidate that list
  10. sharesLoaded = true;
  11. }
  12. else{
  13. OC.Share.updateIcons('file');
  14. }
  15. });
  16. FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) {
  17. if ($('#dir').val() == '/') {
  18. var item = $('#dir').val() + filename;
  19. } else {
  20. var item = $('#dir').val() + '/' + filename;
  21. }
  22. var tr = $('tr').filterAttr('data-file', filename);
  23. if ($(tr).data('type') == 'dir') {
  24. var itemType = 'folder';
  25. } else {
  26. var itemType = 'file';
  27. }
  28. var possiblePermissions = $(tr).data('permissions');
  29. var appendTo = $(tr).find('td.filename');
  30. // Check if drop down is already visible for a different file
  31. if (OC.Share.droppedDown) {
  32. if ($(tr).data('id') != $('#dropdown').attr('data-item-source')) {
  33. OC.Share.hideDropDown(function () {
  34. $(tr).addClass('mouseOver');
  35. OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions, filename);
  36. });
  37. } else {
  38. OC.Share.hideDropDown();
  39. }
  40. } else {
  41. $(tr).addClass('mouseOver');
  42. OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions, filename);
  43. }
  44. });
  45. }
  46. });