diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-05-19 15:20:44 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-05-30 10:06:29 +0200 |
commit | 60bcdc550e95fbf0104bbc9c8028777016d73663 (patch) | |
tree | d6ca8475d7ea4cb8aa7e034add8902926171e612 /apps/files_sharing/js/share.js | |
parent | 279ede33af09c43e03f97458c7fa673ff2b7982a (diff) | |
download | nextcloud-server-60bcdc550e95fbf0104bbc9c8028777016d73663.tar.gz nextcloud-server-60bcdc550e95fbf0104bbc9c8028777016d73663.zip |
Fixed file actions for sharing views
FileActions can now be clone to be use for separate file list views
without having the side-effect of affecting the main file list view.
Added "Open" action in sharing overview file lists to redirect to the
regular file list when clicking on a folder.
Diffstat (limited to 'apps/files_sharing/js/share.js')
-rw-r--r-- | apps/files_sharing/js/share.js | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 84c5bf57b38..28586a179a4 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -8,7 +8,6 @@ * */ -/* global FileList, FileActions */ $(document).ready(function() { var sharesLoaded = false; @@ -31,7 +30,8 @@ $(document).ready(function() { }; } - $('#fileList').on('fileActionsReady',function(){ + // use delegate to catch the case with multiple file lists + $('#content').delegate('#fileList', 'fileActionsReady',function(){ // if no share action exists because the admin disabled sharing for this user // we create a share notification action to inform the user about files // shared with him otherwise we just update the existing share action. @@ -64,44 +64,48 @@ $(document).ready(function() { } }) - // FIXME: these calls are also working on hard-coded - // list selectors... if (!sharesLoaded){ - OC.Share.loadIcons('file'); + OC.Share.loadIcons('file', $fileList); // assume that we got all shares, so switching directories // will not invalidate that list sharesLoaded = true; } else{ - OC.Share.updateIcons('file'); + OC.Share.updateIcons('file', $fileList); } }); - FileActions.register('all', 'Share', OC.PERMISSION_SHARE, OC.imagePath('core', 'actions/share'), function(filename) { - var tr = FileList.findFileEl(filename); + OCA.Files.FileActions.register( + 'all', + 'Share', + OC.PERMISSION_SHARE, + OC.imagePath('core', 'actions/share'), + function(filename, context) { + + var $tr = context.$file; var itemType = 'file'; - if ($(tr).data('type') == 'dir') { + if ($tr.data('type') === 'dir') { itemType = 'folder'; } - var possiblePermissions = $(tr).data('reshare-permissions'); + var possiblePermissions = $tr.data('reshare-permissions'); if (_.isUndefined(possiblePermissions)) { - possiblePermissions = $(tr).data('permissions'); + possiblePermissions = $tr.data('permissions'); } - var appendTo = $(tr).find('td.filename'); + 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')) { + 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); + $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); + $tr.addClass('mouseOver'); + OC.Share.showDropDown(itemType, $tr.data('id'), appendTo, true, possiblePermissions, filename); } }); } |