Add caching for filelist sharing icon status to avoid many http req.

This commit is contained in:
Brice Maron 2011-10-20 23:02:38 +02:00
parent 3a937f79f7
commit 2906ea3d78

View file

@ -1,8 +1,11 @@
$(document).ready(function() {
var shared_status = {};
if (typeof FileActions !== 'undefined') {
FileActions.register('all', 'Share', function(filename) {
var icon;
var file = $('#dir').val()+'/'+filename;
if(shared_status[file])
return shared_status[file].icon;
$.ajax({
type: 'GET',
url: OC.linkTo('files_sharing', 'ajax/getitem.php'),
@ -20,6 +23,7 @@ $(document).ready(function() {
} else {
icon = OC.imagePath('core', 'actions/share');
}
shared_status[file]= { timestamp: new Date().getTime(), icon: icon };
}
});
return icon;
@ -54,6 +58,7 @@ $(document).ready(function() {
$(this).click(function(event) {
if (!($(event.target).hasClass('drop')) && $(event.target).parents().index($('#dropdown')) == -1) {
if ($('#dropdown').is(':visible')) {
delete shared_status[$('#dropdown').data('file')]; //Remove File from icon cache
$('#dropdown').hide('blind', function() {
$('#dropdown').remove();
$('tr').removeClass('mouseOver');