summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-08-24 15:32:06 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-08-24 15:32:06 -0400
commitd84b1adf34817b4b261db35e51f72ac78adf8e27 (patch)
tree9a4de6e78d4c91ba9080ecaa14d54fc0c7f0e707 /core/js
parent0c4575db7a3de781231571e26e848441ec040f68 (diff)
downloadnextcloud-server-d84b1adf34817b4b261db35e51f72ac78adf8e27.tar.gz
nextcloud-server-d84b1adf34817b4b261db35e51f72ac78adf8e27.zip
Dynamically update shared status icon
Diffstat (limited to 'core/js')
-rw-r--r--core/js/share.js39
1 files changed, 36 insertions, 3 deletions
diff --git a/core/js/share.js b/core/js/share.js
index bd1fa14d3f5..3db69dc6901 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -30,6 +30,34 @@ OC.Share={
}
});
},
+ updateIcon:function(itemType, itemSource) {
+ if (itemType == 'file' || itemType == 'folder') {
+ var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file');
+ if ($('#dir').val() == '/') {
+ itemSource = $('#dir').val() + filename;
+ } else {
+ itemSource = $('#dir').val() + '/' + filename;
+ }
+ }
+ var shares = false;
+ $.each(OC.Share.itemShares, function(index) {
+ if (OC.Share.itemShares[index].length > 0) {
+ shares = true;
+ return;
+ }
+ });
+ 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') {
+ $('a.share[data-item="'+itemSource+'"]').css('background', 'url('+OC.imagePath('core', 'actions/share')+') no-repeat center');
+ }
+ delete OC.Share.statuses[itemSource];
+ }
+ },
loadItem:function(itemType, itemSource) {
var data = '';
var checkReshare = true;
@@ -122,7 +150,6 @@ OC.Share={
OC.Share.showPrivateLink(item, share.share_with);
} else {
OC.Share.addShareWith(share.share_type, share.share_with, share.permissions, possiblePermissions);
-
}
});
}
@@ -149,14 +176,17 @@ OC.Share={
event.preventDefault();
},
select: function(event, selected) {
+ var itemType = $('#dropdown').data('item-type');
+ var itemSource = $('#dropdown').data('item-source');
var shareType = selected.item.value.shareType;
var shareWith = selected.item.value.shareWith;
$(this).val(shareWith);
// Default permissions are Read and Share
var permissions = OC.Share.PERMISSION_READ | OC.Share.PERMISSION_SHARE;
- OC.Share.share($('#dropdown').data('item-type'), $('#dropdown').data('item-source'), shareType, shareWith, permissions, function() {
+ OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, function() {
OC.Share.addShareWith(shareType, shareWith, permissions, possiblePermissions);
$('#shareWith').val('');
+ OC.Share.updateIcon(itemType, itemSource);
});
return false;
}
@@ -327,12 +357,15 @@ $(document).ready(function() {
$('.unshare').live('click', function() {
var li = $(this).parent();
+ var itemType = $('#dropdown').data('item-type');
+ var itemSource = $('#dropdown').data('item-source');
var shareType = $(li).data('share-type');
var shareWith = $(li).data('share-with');
- OC.Share.unshare($('#dropdown').data('item-type'), $('#dropdown').data('item-source'), shareType, shareWith, function() {
+ OC.Share.unshare(itemType, itemSource, shareType, shareWith, function() {
$(li).remove();
var index = OC.Share.itemShares[shareType].indexOf(shareWith);
OC.Share.itemShares[shareType].splice(index, 1);
+ OC.Share.updateIcon(itemType, itemSource);
});
});