From 0fbb99690b436f3d46710c0efd8775e05a9d78ba Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 28 Oct 2012 16:03:31 +0100 Subject: properly replace fileaction icons with pngs when needed --- apps/files/js/fileactions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/files/js/fileactions.js') diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 24c8e85656c..901c685ecb2 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -82,7 +82,7 @@ var FileActions = { } var html = ''; if (img) { - html += ' '; + html += ' '; } html += t('files', name) + ''; var element = $(html); @@ -111,7 +111,7 @@ var FileActions = { } var element = $(html); if (img) { - element.append($('')); + element.append($('')); } element.data('action', 'Delete'); element.click(function (event) { -- cgit v1.2.3 From 60e5054ae8bd5e85e6116e52a3de311c71b8b453 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sun, 28 Oct 2012 16:01:50 -0400 Subject: Fix shared status icons --- apps/files/js/fileactions.js | 2 +- apps/files_sharing/js/share.js | 34 ++++------------------------------ core/js/share.js | 40 +++++++++++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 38 deletions(-) (limited to 'apps/files/js/fileactions.js') diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 901c685ecb2..82d990bf780 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -80,7 +80,7 @@ var FileActions = { if (img.call) { img = img(file); } - var html = ''; + var html = ''; if (img) { html += ' '; } diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 72663c068c9..7eb086712f4 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -1,36 +1,8 @@ $(document).ready(function() { if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !publicListView) { - OC.Share.loadIcons('file'); - FileActions.register('all', 'Share', OC.PERMISSION_READ, 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) { + + FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) { if ($('#dir').val() == '/') { var item = $('#dir').val() + filename; } else { @@ -59,6 +31,8 @@ $(document).ready(function() { OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions); } }); + OC.Share.loadIcons('file'); } + }); \ No newline at end of file diff --git a/core/js/share.js b/core/js/share.js index 00e5ef3eed6..c9b3a4288ac 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -10,17 +10,43 @@ OC.Share={ // Load all share icons $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) { if (result && result.status === 'success') { - $.each(result.data, function(item, hasPrivateLink) { - // Private links override shared in terms of icon display + $.each(result.data, function(item, hasLink) { + OC.Share.statuses[item] = hasLink; + // 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') { - if (hasPrivateLink) { - var image = OC.imagePath('core', 'actions/public'); + $('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 image = OC.imagePath('core', 'actions/shared'); + 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); + } + } } - $('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center'); } - OC.Share.statuses[item] = hasPrivateLink; }); } }); -- cgit v1.2.3