aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/js/share.js
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2014-05-30 13:42:24 +0200
committerLukas Reschke <lukas@statuscode.ch>2014-05-30 13:42:24 +0200
commit517501ffbf369b24191d8b9a9f2ce44a9891fb97 (patch)
treef638ba7e2f3554b7b1a31f628496c7d0740fd2ac /apps/files_sharing/js/share.js
parent929882a32a020b6c05605f416fa55024b9a60d33 (diff)
parent7fac2b62e954b0f8a693516da1151c97efa2ee99 (diff)
downloadnextcloud-server-517501ffbf369b24191d8b9a9f2ce44a9891fb97.tar.gz
nextcloud-server-517501ffbf369b24191d8b9a9f2ce44a9891fb97.zip
Merge pull request #8417 from owncloud/share-overview
Sharing overview page
Diffstat (limited to 'apps/files_sharing/js/share.js')
-rw-r--r--apps/files_sharing/js/share.js50
1 files changed, 26 insertions, 24 deletions
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 84c5bf57b38..5a42604c866 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -8,12 +8,8 @@
*
*/
-/* global FileList, FileActions */
$(document).ready(function() {
-
- var sharesLoaded = false;
-
- if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined') {
+ if (!_.isUndefined(OC.Share) && !_.isUndefined(OCA.Files)) {
// TODO: make a separate class for this or a hook or jQuery event ?
if (OCA.Files.FileList) {
var oldCreateRow = OCA.Files.FileList.prototype._createRow;
@@ -31,10 +27,12 @@ $(document).ready(function() {
};
}
- $('#fileList').on('fileActionsReady',function(){
+ // use delegate to catch the case with multiple file lists
+ $('#content').delegate('#fileList', 'fileActionsReady',function(ev){
// 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.
+ var fileList = ev.fileList;
var $fileList = $(this);
$fileList.find('[data-share-owner]').each(function() {
var $tr = $(this);
@@ -62,46 +60,50 @@ $(document).ready(function() {
return $result;
});
}
- })
+ });
- // FIXME: these calls are also working on hard-coded
- // list selectors...
- if (!sharesLoaded){
- OC.Share.loadIcons('file');
+ if (!OCA.Sharing.sharesLoaded){
+ OC.Share.loadIcons('file', fileList);
// assume that we got all shares, so switching directories
// will not invalidate that list
- sharesLoaded = true;
+ OCA.Sharing.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);
}
});
}