nextcloud/apps/files_sharing/js/share.js

57 lines
1.8 KiB
JavaScript
Raw Normal View History

$(document).ready(function() {
var disableSharing = $('#disableSharing').data('status'),
sharesLoaded = false;
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !disableSharing) {
$('#fileList').on('fileActionsReady',function(){
2014-01-30 17:47:00 +04:00
var allShared = $('#fileList').find('[data-share-owner]').find('[data-Action="Share"]');
2014-01-30 17:47:00 +04:00
allShared.addClass('permanent');
allShared.find('span').text(function(){
$owner = $(this).closest('tr').attr('data-share-owner');
2014-01-30 19:29:32 +04:00
return ' ' + t('files_sharing', 'Shared by {owner}', {owner: $owner});
2014-01-30 17:47:00 +04:00
});
if (!sharesLoaded){
OC.Share.loadIcons('file');
// assume that we got all shares, so switching directories
// will not invalidate that list
sharesLoaded = true;
}
else{
OC.Share.updateIcons('file');
}
});
2012-10-29 00:01:50 +04:00
FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) {
var dir = $('#dir').val();
2014-01-30 19:29:32 +04:00
var item = dir + '/' + filename;
if (dir == '/') {
item = dir + filename;
}
var tr = FileList.findFileEl(filename);
var itemType = 'file';
if ($(tr).data('type') == 'dir') {
itemType = 'folder';
}
var possiblePermissions = $(tr).data('permissions');
var appendTo = $(tr).find('td.filename');
// Check if drop down is already visible for a different file
if (OC.Share.droppedDown) {
if ($(tr).data('id') != $('#dropdown').attr('data-item-source')) {
OC.Share.hideDropDown(function () {
$(tr).addClass('mouseOver');
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions, filename);
});
} else {
OC.Share.hideDropDown();
}
} else {
$(tr).addClass('mouseOver');
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions, filename);
}
});
}
});