From 945565f4206367be53a2c612a2d078a6b539a343 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Tue, 19 Jun 2012 14:19:30 -0400 Subject: Move ajax and js files to core --- core/js/share.js | 366 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100644 core/js/share.js (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js new file mode 100644 index 00000000000..5f695774ce1 --- /dev/null +++ b/core/js/share.js @@ -0,0 +1,366 @@ +OC.Share={ + icons:[], + itemUsers:[], + itemGroups:[], + itemPrivateLink:false, + usersAndGroups:[], + loadIcons:function() { + // Cache all icons for shared files + $.getJSON(OC.filePath('core', 'ajax', 'share.php'), function(result) { + if (result && result.status === 'success') { + $.each(result.data, function(item, hasPrivateLink) { + if (hasPrivateLink) { + OC.Share.icons[item] = OC.imagePath('core', 'actions/public'); + } else { + OC.Share.icons[item] = OC.imagePath('core', 'actions/shared'); + } + }); + } + }); + }, + loadItem:function(item) { + $.ajax({type: 'GET', url: OC.filePath('core', 'ajax', 'share.php'), data: { item: item }, async: false, success: function(result) { + if (result && result.status === 'success') { + var item = result.data; + OC.Share.itemUsers = item.users; + OC.Share.itemGroups = item.groups; + OC.Share.itemPrivateLink = item.privateLink; + } + }}); + }, + share:function(source, uid_shared_with, permissions, callback) { + $.post(OC.filePath('core', 'ajax', 'share.php'), { sources: source, uid_shared_with: uid_shared_with, permissions: permissions }, function(result) { + if (result && result.status === 'success') { + if (callback) { + callback(result.data); + } + } else { + OC.dialogs.alert(result.data.message, 'Error while sharing'); + } + }); + }, + unshare:function(source, uid_shared_with, callback) { + $.post(OC.filePath('core', 'ajax', 'share.php'), { source: source, uid_shared_with: uid_shared_with }, function(result) { + if (result && result.status === 'success') { + if (callback) { + callback(); + } + } else { + OC.dialogs.alert('Error', 'Error while unsharing'); + } + }); + }, + setPermissions:function(source, uid_shared_with, permissions) { + $.post(OC.filePath('core', 'ajax', 'share.php'), { source: source, uid_shared_with: uid_shared_with, permissions: permissions }, function(result) { + if (!result || result.status !== 'success') { + OC.dialogs.alert('Error', 'Error while changing permissions'); + } + }); + }, + showDropDown:function(item, appendTo) { + OC.Share.loadItem(item); + var html = '