|
|
|
|
@ -4,57 +4,76 @@ OC.Share={
|
|
|
|
|
SHARE_TYPE_LINK:3,
|
|
|
|
|
SHARE_TYPE_EMAIL:4,
|
|
|
|
|
itemShares:[],
|
|
|
|
|
statuses:[],
|
|
|
|
|
statuses:{},
|
|
|
|
|
droppedDown:false,
|
|
|
|
|
/**
|
|
|
|
|
* Loads ALL share statuses from server, stores them in OC.Share.statuses then
|
|
|
|
|
* calls OC.Share.updateIcons() to update the files "Share" icon to "Shared"
|
|
|
|
|
* according to their share status and share type.
|
|
|
|
|
*/
|
|
|
|
|
loadIcons:function(itemType) {
|
|
|
|
|
// Load all share icons
|
|
|
|
|
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) {
|
|
|
|
|
if (result && result.status === 'success') {
|
|
|
|
|
OC.Share.statuses = {};
|
|
|
|
|
$.each(result.data, function(item, data) {
|
|
|
|
|
OC.Share.statuses[item] = data;
|
|
|
|
|
var hasLink = data['link'];
|
|
|
|
|
// Links override shared in terms of icon display
|
|
|
|
|
if (hasLink) {
|
|
|
|
|
var image = OC.imagePath('core', 'actions/public');
|
|
|
|
|
} else {
|
|
|
|
|
var image = OC.imagePath('core', 'actions/shared');
|
|
|
|
|
}
|
|
|
|
|
if (itemType != 'file' && itemType != 'folder') {
|
|
|
|
|
$('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
|
|
|
|
|
} else {
|
|
|
|
|
var file = $('tr[data-id="'+item+'"]');
|
|
|
|
|
if (file.length > 0) {
|
|
|
|
|
var action = $(file).find('.fileactions .action[data-action="Share"]');
|
|
|
|
|
var img = action.find('img').attr('src', image);
|
|
|
|
|
action.addClass('permanent');
|
|
|
|
|
action.html(' '+t('core', 'Shared')).prepend(img);
|
|
|
|
|
} else {
|
|
|
|
|
var dir = $('#dir').val();
|
|
|
|
|
if (dir.length > 1) {
|
|
|
|
|
var last = '';
|
|
|
|
|
var path = dir;
|
|
|
|
|
// Search for possible parent folders that are shared
|
|
|
|
|
while (path != last) {
|
|
|
|
|
if (path == data['path']) {
|
|
|
|
|
var actions = $('.fileactions .action[data-action="Share"]');
|
|
|
|
|
$.each(actions, function(index, action) {
|
|
|
|
|
var img = $(action).find('img');
|
|
|
|
|
if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
|
|
|
|
|
img.attr('src', image);
|
|
|
|
|
$(action).addClass('permanent');
|
|
|
|
|
$(action).html(' '+t('core', 'Shared')).prepend(img);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
OC.Share.updateIcons(itemType);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* Updates the files' "Share" icons according to the known
|
|
|
|
|
* sharing states stored in OC.Share.statuses.
|
|
|
|
|
* (not reloaded from server)
|
|
|
|
|
*/
|
|
|
|
|
updateIcons:function(itemType){
|
|
|
|
|
var item;
|
|
|
|
|
for (item in OC.Share.statuses){
|
|
|
|
|
var data = OC.Share.statuses[item];
|
|
|
|
|
|
|
|
|
|
var hasLink = data['link'];
|
|
|
|
|
// Links override shared in terms of icon display
|
|
|
|
|
if (hasLink) {
|
|
|
|
|
var image = OC.imagePath('core', 'actions/public');
|
|
|
|
|
} else {
|
|
|
|
|
var image = OC.imagePath('core', 'actions/shared');
|
|
|
|
|
}
|
|
|
|
|
if (itemType != 'file' && itemType != 'folder') {
|
|
|
|
|
$('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
|
|
|
|
|
} else {
|
|
|
|
|
var file = $('tr[data-id="'+item+'"]');
|
|
|
|
|
if (file.length > 0) {
|
|
|
|
|
var action = $(file).find('.fileactions .action[data-action="Share"]');
|
|
|
|
|
var img = action.find('img').attr('src', image);
|
|
|
|
|
action.addClass('permanent');
|
|
|
|
|
action.html(' '+t('core', 'Shared')).prepend(img);
|
|
|
|
|
} else {
|
|
|
|
|
var dir = $('#dir').val();
|
|
|
|
|
if (dir.length > 1) {
|
|
|
|
|
var last = '';
|
|
|
|
|
var path = dir;
|
|
|
|
|
// Search for possible parent folders that are shared
|
|
|
|
|
while (path != last) {
|
|
|
|
|
if (path == data['path']) {
|
|
|
|
|
var actions = $('.fileactions .action[data-action="Share"]');
|
|
|
|
|
$.each(actions, function(index, action) {
|
|
|
|
|
var img = $(action).find('img');
|
|
|
|
|
if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
|
|
|
|
|
img.attr('src', image);
|
|
|
|
|
$(action).addClass('permanent');
|
|
|
|
|
$(action).html(' '+t('core', 'Shared')).prepend(img);
|
|
|
|
|
}
|
|
|
|
|
last = path;
|
|
|
|
|
path = OC.Share.dirname(path);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
last = path;
|
|
|
|
|
path = OC.Share.dirname(path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
updateIcon:function(itemType, itemSource) {
|
|
|
|
|
var shares = false;
|
|
|
|
|
|