Fix changing of share status icons, bug fix for oc-1631

This commit is contained in:
Michael Gapczynski 2012-09-19 01:44:15 -04:00
parent 1e1e8ae3b5
commit 518ca0ac58
1 changed files with 22 additions and 11 deletions

View File

@ -35,21 +35,29 @@ OC.Share={
} }
} }
var shares = false; var shares = false;
var link = false;
var image = OC.imagePath('core', 'actions/share');
$.each(OC.Share.itemShares, function(index) { $.each(OC.Share.itemShares, function(index) {
if (OC.Share.itemShares[index].length > 0) { if (OC.Share.itemShares[index]) {
if (index == OC.Share.SHARE_TYPE_LINK) {
if (OC.Share.itemShares[index] == true) {
shares = true; shares = true;
image = OC.imagePath('core', 'actions/public');
link = true;
return; return;
} }
} else if (OC.Share.itemShares[index].length > 0) {
shares = true;
image = OC.imagePath('core', 'actions/shared');
}
}
}); });
if (shares) {
$('a.share[data-item="'+itemSource+'"]').css('background', 'url('+OC.imagePath('core', 'actions/shared')+') no-repeat center');
if (typeof OC.Share.statuses[itemSource] === 'undefined') {
OC.Share.statuses[itemSource] = false;
}
} else {
if (itemType != 'file' && itemType != 'folder') { if (itemType != 'file' && itemType != 'folder') {
$('a.share[data-item="'+itemSource+'"]').css('background', 'url('+OC.imagePath('core', 'actions/share')+') no-repeat center'); $('a.share[data-item="'+itemSource+'"]').css('background', 'url('+image+') no-repeat center');
} }
if (shares) {
OC.Share.statuses[itemSource] = link;
} else {
delete OC.Share.statuses[itemSource]; delete OC.Share.statuses[itemSource];
} }
}, },
@ -287,6 +295,7 @@ OC.Share={
} }
}, },
showLink:function(itemSource, password) { showLink:function(itemSource, password) {
OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = true;
$('#linkCheckbox').attr('checked', true); $('#linkCheckbox').attr('checked', true);
var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file'); var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file');
if ($('#dir').val() == '/') { if ($('#dir').val() == '/') {
@ -421,12 +430,14 @@ $(document).ready(function() {
// Create a link // Create a link
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, function() { OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, function() {
OC.Share.showLink(itemSource); OC.Share.showLink(itemSource);
// TODO Change icon OC.Share.updateIcon(itemType, itemSource);
}); });
} else { } else {
// Delete private link // Delete private link
OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', function() { OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', function() {
OC.Share.hideLink(); OC.Share.hideLink();
OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = false;
OC.Share.updateIcon(itemType, itemSource);
if (typeof OC.Share.statuses[itemSource] === 'undefined') { if (typeof OC.Share.statuses[itemSource] === 'undefined') {
$('#expiration').hide(); $('#expiration').hide();
} }