2012-08-22 20:31:54 +04:00
|
|
|
$(document).ready(function() {
|
|
|
|
|
2012-08-28 04:36:34 +04:00
|
|
|
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined') {
|
2012-08-22 20:31:54 +04:00
|
|
|
OC.Share.loadIcons('file');
|
2012-08-31 03:05:36 +04:00
|
|
|
FileActions.register('all', 'Share', OC.PERMISSION_READ, function(filename) {
|
2012-08-22 20:31:54 +04:00
|
|
|
// Return the correct sharing icon
|
|
|
|
if (scanFiles.scanning) { return; } // workaround to prevent additional http request block scanning feedback
|
|
|
|
if ($('#dir').val() == '/') {
|
|
|
|
var item = $('#dir').val() + filename;
|
|
|
|
} else {
|
|
|
|
var item = $('#dir').val() + '/' + filename;
|
|
|
|
}
|
|
|
|
// Check if status is in cache
|
|
|
|
if (OC.Share.statuses[item] === true) {
|
|
|
|
return OC.imagePath('core', 'actions/public');
|
|
|
|
} else if (OC.Share.statuses[item] === false) {
|
|
|
|
return OC.imagePath('core', 'actions/shared');
|
|
|
|
} else {
|
|
|
|
var last = '';
|
|
|
|
var path = OC.Share.dirname(item);
|
|
|
|
// Search for possible parent folders that are shared
|
|
|
|
while (path != last) {
|
|
|
|
if (OC.Share.statuses[path] === true) {
|
|
|
|
return OC.imagePath('core', 'actions/public');
|
|
|
|
} else if (OC.Share.statuses[path] === false) {
|
|
|
|
return OC.imagePath('core', 'actions/shared');
|
|
|
|
}
|
|
|
|
last = path;
|
|
|
|
path = OC.Share.dirname(path);
|
|
|
|
}
|
|
|
|
return OC.imagePath('core', 'actions/share');
|
|
|
|
}
|
|
|
|
}, function(filename) {
|
|
|
|
if ($('#dir').val() == '/') {
|
|
|
|
var item = $('#dir').val() + filename;
|
|
|
|
} else {
|
|
|
|
var item = $('#dir').val() + '/' + filename;
|
|
|
|
}
|
2012-08-23 22:48:35 +04:00
|
|
|
var tr = $('tr').filterAttr('data-file', filename);
|
|
|
|
if ($(tr).data('type') == 'dir') {
|
2012-08-22 20:31:54 +04:00
|
|
|
var itemType = 'folder';
|
|
|
|
} else {
|
|
|
|
var itemType = 'file';
|
|
|
|
}
|
2012-08-23 22:48:35 +04:00
|
|
|
var possiblePermissions = $(tr).data('permissions');
|
2012-08-24 18:01:01 +04:00
|
|
|
var appendTo = $(tr).find('td.filename');
|
2012-08-22 20:31:54 +04:00
|
|
|
// Check if drop down is already visible for a different file
|
|
|
|
if (OC.Share.droppedDown) {
|
|
|
|
if (item != $('#dropdown').data('item')) {
|
|
|
|
OC.Share.hideDropDown(function () {
|
2012-08-24 18:01:01 +04:00
|
|
|
$(tr).addClass('mouseOver');
|
|
|
|
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
|
2012-08-22 20:31:54 +04:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
OC.Share.hideDropDown();
|
|
|
|
}
|
|
|
|
} else {
|
2012-08-24 18:01:01 +04:00
|
|
|
$(tr).addClass('mouseOver');
|
|
|
|
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
|
2012-08-22 20:31:54 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|