Fix shared status icons
This commit is contained in:
parent
f3971e659b
commit
60e5054ae8
|
@ -80,7 +80,7 @@ var FileActions = {
|
||||||
if (img.call) {
|
if (img.call) {
|
||||||
img = img(file);
|
img = img(file);
|
||||||
}
|
}
|
||||||
var html = '<a href="#" class="action">';
|
var html = '<a href="#" class="action" data-action="'+name+'">';
|
||||||
if (img) {
|
if (img) {
|
||||||
html += '<img class ="svg" src="' + img + '"/> ';
|
html += '<img class ="svg" src="' + img + '"/> ';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,8 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !publicListView) {
|
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !publicListView) {
|
||||||
OC.Share.loadIcons('file');
|
|
||||||
FileActions.register('all', 'Share', OC.PERMISSION_READ, function(filename) {
|
FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) {
|
||||||
// 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() == '/') {
|
if ($('#dir').val() == '/') {
|
||||||
var item = $('#dir').val() + filename;
|
var item = $('#dir').val() + filename;
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,6 +31,8 @@ $(document).ready(function() {
|
||||||
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
|
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
OC.Share.loadIcons('file');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
|
@ -10,17 +10,43 @@ OC.Share={
|
||||||
// Load all share icons
|
// Load all share icons
|
||||||
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) {
|
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) {
|
||||||
if (result && result.status === 'success') {
|
if (result && result.status === 'success') {
|
||||||
$.each(result.data, function(item, hasPrivateLink) {
|
$.each(result.data, function(item, hasLink) {
|
||||||
// Private links override shared in terms of icon display
|
OC.Share.statuses[item] = hasLink;
|
||||||
if (itemType != 'file' && itemType != 'folder') {
|
// Links override shared in terms of icon display
|
||||||
if (hasPrivateLink) {
|
if (hasLink) {
|
||||||
var image = OC.imagePath('core', 'actions/public');
|
var image = OC.imagePath('core', 'actions/public');
|
||||||
} else {
|
} else {
|
||||||
var image = OC.imagePath('core', 'actions/shared');
|
var image = OC.imagePath('core', 'actions/shared');
|
||||||
}
|
}
|
||||||
$('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
|
if (itemType != 'file' && itemType != 'folder') {
|
||||||
|
$('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
|
||||||
|
} else {
|
||||||
|
var dir = $('#dir').val();
|
||||||
|
if ($('#dir').val().length > 1) {
|
||||||
|
console.log(item);
|
||||||
|
var last = '';
|
||||||
|
var path = dir;
|
||||||
|
// Search for possible parent folders that are shared
|
||||||
|
while (path != last) {
|
||||||
|
if (path == item) {
|
||||||
|
var img = $('.fileactions .action').filterAttr('data-action', 'Share').find('img');
|
||||||
|
if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
|
||||||
|
img.attr('src', image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
last = path;
|
||||||
|
path = OC.Share.dirname(path);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var file = $('tr').filterAttr('data-file', OC.basename(item));
|
||||||
|
if (file.length > 0) {
|
||||||
|
var img = $(file).find('.fileactions .action').filterAttr('data-action', 'Share').find('img');
|
||||||
|
if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
|
||||||
|
img.attr('src', image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
OC.Share.statuses[item] = hasPrivateLink;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue