2014-07-03 11:19:14 +00:00
|
|
|
/* global escapeHTML */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @namespace
|
|
|
|
*/
|
2015-09-15 08:27:33 +00:00
|
|
|
OC.Share = _.extend(OC.Share || {}, {
|
2012-06-25 23:27:57 +00:00
|
|
|
SHARE_TYPE_USER:0,
|
|
|
|
SHARE_TYPE_GROUP:1,
|
2012-08-28 00:05:51 +00:00
|
|
|
SHARE_TYPE_LINK:3,
|
2012-07-31 14:18:26 +00:00
|
|
|
SHARE_TYPE_EMAIL:4,
|
2014-12-04 18:51:04 +00:00
|
|
|
SHARE_TYPE_REMOTE:6,
|
2017-03-17 19:48:33 +00:00
|
|
|
SHARE_TYPE_CIRCLE:7,
|
2017-04-28 07:56:57 +00:00
|
|
|
SHARE_TYPE_GUEST:8,
|
2014-07-03 11:19:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Regular expression for splitting parts of remote share owners:
|
|
|
|
* "user@example.com/path/to/owncloud"
|
|
|
|
* "user@anotherexample.com@example.com/path/to/owncloud
|
|
|
|
*/
|
2015-05-16 12:22:10 +00:00
|
|
|
_REMOTE_OWNER_REGEXP: new RegExp("^([^@]*)@(([^@]*)@)?([^/]*)([/](.*)?)?$"),
|
2014-07-03 11:19:14 +00:00
|
|
|
|
2014-06-04 08:37:04 +00:00
|
|
|
/**
|
|
|
|
* @deprecated use OC.Share.currentShares instead
|
|
|
|
*/
|
2012-07-31 17:06:32 +00:00
|
|
|
itemShares:[],
|
2014-06-04 08:37:04 +00:00
|
|
|
/**
|
|
|
|
* Full list of all share statuses
|
|
|
|
*/
|
2013-10-17 09:59:13 +00:00
|
|
|
statuses:{},
|
2014-06-04 08:37:04 +00:00
|
|
|
/**
|
|
|
|
* Shares for the currently selected file.
|
|
|
|
* (for which the dropdown is open)
|
|
|
|
*
|
|
|
|
* Key is item type and value is an array or
|
|
|
|
* shares of the given item type.
|
|
|
|
*/
|
|
|
|
currentShares: {},
|
|
|
|
/**
|
|
|
|
* Whether the share dropdown is opened.
|
|
|
|
*/
|
2012-08-08 21:50:09 +00:00
|
|
|
droppedDown:false,
|
2013-10-17 09:59:13 +00:00
|
|
|
/**
|
2014-03-01 01:46:27 +00:00
|
|
|
* Loads ALL share statuses from server, stores them in
|
|
|
|
* OC.Share.statuses then calls OC.Share.updateIcons() to update the
|
|
|
|
* files "Share" icon to "Shared" according to their share status and
|
|
|
|
* share type.
|
2014-05-19 13:20:44 +00:00
|
|
|
*
|
2014-07-01 19:32:04 +00:00
|
|
|
* If a callback is specified, the update step is skipped.
|
|
|
|
*
|
2014-05-19 13:20:44 +00:00
|
|
|
* @param itemType item type
|
|
|
|
* @param fileList file list instance, defaults to OCA.Files.App.fileList
|
2014-07-01 19:32:04 +00:00
|
|
|
* @param callback function to call after the shares were loaded
|
2013-10-17 09:59:13 +00:00
|
|
|
*/
|
2014-07-01 19:32:04 +00:00
|
|
|
loadIcons:function(itemType, fileList, callback) {
|
2016-02-11 10:06:26 +00:00
|
|
|
var path = fileList.dirInfo.path;
|
|
|
|
if (path === '/') {
|
|
|
|
path = '';
|
|
|
|
}
|
|
|
|
path += '/' + fileList.dirInfo.name;
|
|
|
|
|
2012-06-24 23:16:50 +00:00
|
|
|
// Load all share icons
|
2014-03-01 01:46:27 +00:00
|
|
|
$.get(
|
2016-02-11 07:17:52 +00:00
|
|
|
OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'shares',
|
2014-03-01 01:46:27 +00:00
|
|
|
{
|
2016-02-11 07:17:52 +00:00
|
|
|
subfiles: 'true',
|
2016-02-11 10:06:26 +00:00
|
|
|
path: path,
|
2016-02-11 07:17:52 +00:00
|
|
|
format: 'json'
|
2014-03-01 01:46:27 +00:00
|
|
|
}, function(result) {
|
2016-02-11 07:17:52 +00:00
|
|
|
if (result && result.ocs.meta.statuscode === 200) {
|
2014-03-01 01:46:27 +00:00
|
|
|
OC.Share.statuses = {};
|
2016-02-11 07:17:52 +00:00
|
|
|
$.each(result.ocs.data, function(it, share) {
|
|
|
|
if (!(share.item_source in OC.Share.statuses)) {
|
|
|
|
OC.Share.statuses[share.item_source] = {link: false};
|
|
|
|
}
|
|
|
|
if (share.share_type === OC.Share.SHARE_TYPE_LINK) {
|
|
|
|
OC.Share.statuses[share.item_source] = {link: true};
|
|
|
|
}
|
2014-03-01 01:46:27 +00:00
|
|
|
});
|
2014-07-01 19:32:04 +00:00
|
|
|
if (_.isFunction(callback)) {
|
|
|
|
callback(OC.Share.statuses);
|
|
|
|
} else {
|
|
|
|
OC.Share.updateIcons(itemType, fileList);
|
|
|
|
}
|
2014-03-01 01:46:27 +00:00
|
|
|
}
|
2013-10-17 09:59:13 +00:00
|
|
|
}
|
2014-03-01 01:46:27 +00:00
|
|
|
);
|
2013-10-17 09:59:13 +00:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Updates the files' "Share" icons according to the known
|
|
|
|
* sharing states stored in OC.Share.statuses.
|
|
|
|
* (not reloaded from server)
|
2014-05-19 13:20:44 +00:00
|
|
|
*
|
|
|
|
* @param itemType item type
|
2014-05-21 10:54:34 +00:00
|
|
|
* @param fileList file list instance
|
2014-05-19 13:20:44 +00:00
|
|
|
* defaults to OCA.Files.App.fileList
|
2013-10-17 09:59:13 +00:00
|
|
|
*/
|
2014-05-19 13:20:44 +00:00
|
|
|
updateIcons:function(itemType, fileList){
|
2013-10-17 12:39:20 +00:00
|
|
|
var item;
|
2014-05-28 14:34:00 +00:00
|
|
|
var $fileList;
|
|
|
|
var currentDir;
|
|
|
|
if (!fileList && OCA.Files) {
|
|
|
|
fileList = OCA.Files.App.fileList;
|
|
|
|
}
|
|
|
|
// fileList is usually only defined in the files app
|
|
|
|
if (fileList) {
|
|
|
|
$fileList = fileList.$fileList;
|
|
|
|
currentDir = fileList.getCurrentDirectory();
|
|
|
|
}
|
2014-06-02 15:23:52 +00:00
|
|
|
// TODO: iterating over the files might be more efficient
|
2013-10-17 09:59:13 +00:00
|
|
|
for (item in OC.Share.statuses){
|
2017-04-12 13:04:12 +00:00
|
|
|
var iconClass = 'icon-shared';
|
2013-10-17 09:59:13 +00:00
|
|
|
var data = OC.Share.statuses[item];
|
2014-05-21 10:54:34 +00:00
|
|
|
var hasLink = data.link;
|
2013-10-17 09:59:13 +00:00
|
|
|
// Links override shared in terms of icon display
|
|
|
|
if (hasLink) {
|
2016-02-17 10:04:29 +00:00
|
|
|
iconClass = 'icon-public';
|
2013-10-17 09:59:13 +00:00
|
|
|
}
|
2014-05-21 10:54:34 +00:00
|
|
|
if (itemType !== 'file' && itemType !== 'folder') {
|
2017-04-12 13:04:12 +00:00
|
|
|
$('a.share[data-item="'+item+'"] .icon').removeClass('icon-shared icon-public').addClass(iconClass);
|
2013-10-17 09:59:13 +00:00
|
|
|
} else {
|
2014-05-28 16:39:29 +00:00
|
|
|
// TODO: ultimately this part should be moved to files_sharing app
|
2014-05-19 13:20:44 +00:00
|
|
|
var file = $fileList.find('tr[data-id="'+item+'"]');
|
2014-05-28 10:13:55 +00:00
|
|
|
var shareFolder = OC.imagePath('core', 'filetypes/folder-shared');
|
|
|
|
var img;
|
2013-10-17 09:59:13 +00:00
|
|
|
if (file.length > 0) {
|
2014-06-02 15:23:52 +00:00
|
|
|
this.markFileAsShared(file, true, hasLink);
|
2013-10-17 09:59:13 +00:00
|
|
|
} else {
|
2014-05-21 10:54:34 +00:00
|
|
|
var dir = currentDir;
|
2013-10-17 09:59:13 +00:00
|
|
|
if (dir.length > 1) {
|
|
|
|
var last = '';
|
|
|
|
var path = dir;
|
|
|
|
// Search for possible parent folders that are shared
|
|
|
|
while (path != last) {
|
2014-05-21 10:54:34 +00:00
|
|
|
if (path === data.path && !data.link) {
|
2014-05-19 13:20:44 +00:00
|
|
|
var actions = $fileList.find('.fileactions .action[data-action="Share"]');
|
2014-05-28 10:13:55 +00:00
|
|
|
var files = $fileList.find('.filename');
|
|
|
|
var i;
|
|
|
|
for (i = 0; i < actions.length; i++) {
|
2014-05-28 16:39:29 +00:00
|
|
|
// TODO: use this.markFileAsShared()
|
2014-05-28 10:13:55 +00:00
|
|
|
img = $(actions[i]).find('img');
|
2014-05-21 10:54:34 +00:00
|
|
|
if (img.attr('src') !== OC.imagePath('core', 'actions/public')) {
|
2013-10-17 09:59:13 +00:00
|
|
|
img.attr('src', image);
|
2014-05-28 10:13:55 +00:00
|
|
|
$(actions[i]).addClass('permanent');
|
2015-08-26 08:27:55 +00:00
|
|
|
$(actions[i]).html('<span> '+t('core', 'Shared')+'</span>').prepend(img);
|
2014-05-28 10:13:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for(i = 0; i < files.length; i++) {
|
|
|
|
if ($(files[i]).closest('tr').data('type') === 'dir') {
|
2014-12-11 16:36:14 +00:00
|
|
|
$(files[i]).find('.thumbnail').css('background-image', 'url('+shareFolder+')');
|
2012-10-28 20:01:50 +00:00
|
|
|
}
|
2014-05-28 10:13:55 +00:00
|
|
|
}
|
2012-10-28 20:01:50 +00:00
|
|
|
}
|
2013-10-17 09:59:13 +00:00
|
|
|
last = path;
|
|
|
|
path = OC.Share.dirname(path);
|
2012-06-24 23:16:50 +00:00
|
|
|
}
|
2012-05-05 18:56:52 +00:00
|
|
|
}
|
2013-10-17 09:59:13 +00:00
|
|
|
}
|
2012-05-05 18:56:52 +00:00
|
|
|
}
|
2013-10-17 09:59:13 +00:00
|
|
|
}
|
2012-05-05 18:56:52 +00:00
|
|
|
},
|
2012-08-24 19:32:06 +00:00
|
|
|
updateIcon:function(itemType, itemSource) {
|
|
|
|
var shares = false;
|
2012-09-19 05:44:15 +00:00
|
|
|
var link = false;
|
|
|
|
var image = OC.imagePath('core', 'actions/share');
|
2016-02-17 10:04:29 +00:00
|
|
|
var iconClass = '';
|
2012-08-24 19:32:06 +00:00
|
|
|
$.each(OC.Share.itemShares, function(index) {
|
2012-09-19 05:44:15 +00:00
|
|
|
if (OC.Share.itemShares[index]) {
|
|
|
|
if (index == OC.Share.SHARE_TYPE_LINK) {
|
|
|
|
if (OC.Share.itemShares[index] == true) {
|
|
|
|
shares = true;
|
2016-02-17 10:04:29 +00:00
|
|
|
iconClass = 'icon-public';
|
2012-09-19 05:44:15 +00:00
|
|
|
link = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (OC.Share.itemShares[index].length > 0) {
|
|
|
|
shares = true;
|
2017-04-12 13:04:12 +00:00
|
|
|
iconClass = 'icon-shared';
|
2012-09-19 05:44:15 +00:00
|
|
|
}
|
2012-08-24 19:32:06 +00:00
|
|
|
}
|
|
|
|
});
|
2012-09-19 05:44:15 +00:00
|
|
|
if (itemType != 'file' && itemType != 'folder') {
|
2017-04-12 13:04:12 +00:00
|
|
|
$('a.share[data-item="'+itemSource+'"] .icon').removeClass('icon-shared icon-public').addClass(iconClass);
|
2013-01-26 18:25:15 +00:00
|
|
|
} else {
|
2014-05-28 16:39:29 +00:00
|
|
|
var $tr = $('tr').filterAttr('data-id', String(itemSource));
|
|
|
|
if ($tr.length > 0) {
|
2014-06-02 15:23:52 +00:00
|
|
|
// it might happen that multiple lists exist in the DOM
|
|
|
|
// with the same id
|
|
|
|
$tr.each(function() {
|
|
|
|
OC.Share.markFileAsShared($(this), shares, link);
|
2014-05-21 10:54:34 +00:00
|
|
|
});
|
2013-01-26 18:25:15 +00:00
|
|
|
}
|
2012-09-19 05:44:15 +00:00
|
|
|
}
|
2012-08-24 19:32:06 +00:00
|
|
|
if (shares) {
|
2013-07-22 18:02:56 +00:00
|
|
|
OC.Share.statuses[itemSource] = OC.Share.statuses[itemSource] || {};
|
2017-05-01 03:45:41 +00:00
|
|
|
OC.Share.statuses[itemSource].link = link;
|
2012-08-24 19:32:06 +00:00
|
|
|
} else {
|
|
|
|
delete OC.Share.statuses[itemSource];
|
|
|
|
}
|
|
|
|
},
|
2014-07-03 11:19:14 +00:00
|
|
|
/**
|
2015-05-16 12:22:10 +00:00
|
|
|
* Format a remote address
|
2014-07-03 11:19:14 +00:00
|
|
|
*
|
2017-11-19 21:41:28 +00:00
|
|
|
* @param {String} shareWith userid, full remote share, or whatever
|
|
|
|
* @param {String} shareWithDisplayName
|
|
|
|
* @param {String} message
|
2015-05-16 12:22:10 +00:00
|
|
|
* @return {String} HTML code to display
|
2014-07-03 11:19:14 +00:00
|
|
|
*/
|
2017-11-19 21:41:28 +00:00
|
|
|
_formatRemoteShare: function(shareWith, shareWithDisplayName, message) {
|
|
|
|
var parts = this._REMOTE_OWNER_REGEXP.exec(shareWith);
|
2014-07-03 11:19:14 +00:00
|
|
|
if (!parts) {
|
2017-09-21 12:04:23 +00:00
|
|
|
// display avatar of the user
|
2017-11-19 21:41:28 +00:00
|
|
|
var avatar = '<span class="avatar" data-username="' + escapeHTML(shareWith) + '" title="' + message + " " + escapeHTML(shareWithDisplayName) + '"></span>';
|
|
|
|
var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(shareWithDisplayName) + '</span> ';
|
2017-09-21 12:04:23 +00:00
|
|
|
return avatar + hidden;
|
2014-07-03 11:19:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var userName = parts[1];
|
|
|
|
var userDomain = parts[3];
|
|
|
|
var server = parts[4];
|
2017-11-02 12:11:11 +00:00
|
|
|
var tooltip = message + ' ' + userName;
|
2014-07-03 11:19:14 +00:00
|
|
|
if (userDomain) {
|
|
|
|
tooltip += '@' + userDomain;
|
|
|
|
}
|
|
|
|
if (server) {
|
2015-01-27 10:06:18 +00:00
|
|
|
if (!userDomain) {
|
|
|
|
userDomain = '…';
|
|
|
|
}
|
2014-07-03 11:19:14 +00:00
|
|
|
tooltip += '@' + server;
|
|
|
|
}
|
|
|
|
|
2015-05-16 12:22:10 +00:00
|
|
|
var html = '<span class="remoteAddress" title="' + escapeHTML(tooltip) + '">';
|
2014-07-03 11:19:14 +00:00
|
|
|
html += '<span class="username">' + escapeHTML(userName) + '</span>';
|
|
|
|
if (userDomain) {
|
|
|
|
html += '<span class="userDomain">@' + escapeHTML(userDomain) + '</span>';
|
|
|
|
}
|
2017-11-01 14:14:45 +00:00
|
|
|
html += '</span> ';
|
2014-07-11 13:16:26 +00:00
|
|
|
return html;
|
2014-07-03 11:19:14 +00:00
|
|
|
},
|
2015-05-16 12:22:10 +00:00
|
|
|
/**
|
2015-08-25 12:45:39 +00:00
|
|
|
* Loop over all recipients in the list and format them using
|
2015-05-16 12:22:10 +00:00
|
|
|
* all kind of fancy magic.
|
|
|
|
*
|
2017-11-21 10:29:42 +00:00
|
|
|
* @param {Object} recipients array of all the recipients
|
2015-05-16 12:22:10 +00:00
|
|
|
* @return {String[]} modified list of recipients
|
|
|
|
*/
|
|
|
|
_formatShareList: function(recipients) {
|
|
|
|
var _parent = this;
|
2017-11-21 11:45:57 +00:00
|
|
|
recipients = _.toArray(recipients);
|
|
|
|
recipients.sort(function(a, b) {
|
|
|
|
return a.shareWithDisplayName.localeCompare(b.shareWithDisplayName);
|
|
|
|
});
|
2017-11-21 10:29:42 +00:00
|
|
|
return $.map(recipients, function(recipient) {
|
|
|
|
return _parent._formatRemoteShare(recipient.shareWith, recipient.shareWithDisplayName, t('core', 'Shared with'));
|
2015-05-16 12:22:10 +00:00
|
|
|
});
|
|
|
|
},
|
2014-05-28 16:39:29 +00:00
|
|
|
/**
|
2014-06-02 15:23:52 +00:00
|
|
|
* Marks/unmarks a given file as shared by changing its action icon
|
|
|
|
* and folder icon.
|
2014-05-28 16:39:29 +00:00
|
|
|
*
|
|
|
|
* @param $tr file element to mark as shared
|
2014-06-02 15:23:52 +00:00
|
|
|
* @param hasShares whether shares are available
|
|
|
|
* @param hasLink whether link share is available
|
2014-05-28 16:39:29 +00:00
|
|
|
*/
|
2014-06-02 15:23:52 +00:00
|
|
|
markFileAsShared: function($tr, hasShares, hasLink) {
|
2014-05-28 16:39:29 +00:00
|
|
|
var action = $tr.find('.fileactions .action[data-action="Share"]');
|
|
|
|
var type = $tr.data('type');
|
2016-02-17 10:04:29 +00:00
|
|
|
var icon = action.find('.icon');
|
2017-09-21 12:04:23 +00:00
|
|
|
var message, recipients, avatars;
|
2017-11-19 15:38:04 +00:00
|
|
|
var ownerId = $tr.attr('data-share-owner-id');
|
2014-06-03 09:04:57 +00:00
|
|
|
var owner = $tr.attr('data-share-owner');
|
2014-05-28 16:39:29 +00:00
|
|
|
var shareFolderIcon;
|
2017-04-12 13:04:12 +00:00
|
|
|
var iconClass = 'icon-shared';
|
2015-08-25 12:45:39 +00:00
|
|
|
action.removeClass('shared-style');
|
2014-06-02 15:23:52 +00:00
|
|
|
// update folder icon
|
2017-11-19 15:38:04 +00:00
|
|
|
if (type === 'dir' && (hasShares || hasLink || ownerId)) {
|
2014-06-02 15:23:52 +00:00
|
|
|
if (hasLink) {
|
2015-10-28 16:43:36 +00:00
|
|
|
shareFolderIcon = OC.MimeType.getIconUrl('dir-public');
|
2014-06-02 15:23:52 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-10-28 16:43:36 +00:00
|
|
|
shareFolderIcon = OC.MimeType.getIconUrl('dir-shared');
|
2014-06-02 15:23:52 +00:00
|
|
|
}
|
2014-12-11 16:36:14 +00:00
|
|
|
$tr.find('.filename .thumbnail').css('background-image', 'url(' + shareFolderIcon + ')');
|
2015-10-28 16:43:36 +00:00
|
|
|
$tr.attr('data-icon', shareFolderIcon);
|
2014-05-28 16:39:29 +00:00
|
|
|
} else if (type === 'dir') {
|
2015-10-28 16:43:36 +00:00
|
|
|
var mountType = $tr.attr('data-mounttype');
|
|
|
|
// FIXME: duplicate of FileList._createRow logic for external folder,
|
|
|
|
// need to refactor the icon logic into a single code path eventually
|
|
|
|
if (mountType && mountType.indexOf('external') === 0) {
|
|
|
|
shareFolderIcon = OC.MimeType.getIconUrl('dir-external');
|
|
|
|
$tr.attr('data-icon', shareFolderIcon);
|
|
|
|
} else {
|
|
|
|
shareFolderIcon = OC.MimeType.getIconUrl('dir');
|
|
|
|
// back to default
|
|
|
|
$tr.removeAttr('data-icon');
|
|
|
|
}
|
2014-12-11 16:36:14 +00:00
|
|
|
$tr.find('.filename .thumbnail').css('background-image', 'url(' + shareFolderIcon + ')');
|
2014-05-28 16:39:29 +00:00
|
|
|
}
|
2014-06-02 15:23:52 +00:00
|
|
|
// update share action text / icon
|
2017-11-19 15:38:04 +00:00
|
|
|
if (hasShares || ownerId) {
|
2017-11-19 15:37:37 +00:00
|
|
|
recipients = $tr.data('share-recipient-data');
|
2015-08-25 12:45:39 +00:00
|
|
|
action.addClass('shared-style');
|
2014-05-28 16:39:29 +00:00
|
|
|
|
2017-09-21 12:21:37 +00:00
|
|
|
avatars = '<span>' + t('core', 'Shared') + '</span>';
|
2014-06-03 09:04:57 +00:00
|
|
|
// even if reshared, only show "Shared by"
|
2017-11-19 15:38:04 +00:00
|
|
|
if (ownerId) {
|
2017-11-01 14:14:45 +00:00
|
|
|
message = t('core', 'Shared by');
|
2017-11-19 21:41:28 +00:00
|
|
|
avatars = this._formatRemoteShare(ownerId, owner, message);
|
2017-09-21 12:04:23 +00:00
|
|
|
} else if (recipients) {
|
2017-11-19 15:37:37 +00:00
|
|
|
avatars = this._formatShareList(recipients);
|
2014-05-28 16:39:29 +00:00
|
|
|
}
|
2017-09-21 12:04:23 +00:00
|
|
|
action.html(avatars).prepend(icon);
|
2017-08-13 13:39:48 +00:00
|
|
|
|
2017-11-19 15:38:04 +00:00
|
|
|
if (ownerId || recipients) {
|
2017-08-13 13:39:48 +00:00
|
|
|
var avatarElement = action.find('.avatar');
|
2017-11-19 15:37:37 +00:00
|
|
|
avatarElement.each(function () {
|
|
|
|
$(this).avatar($(this).data('username'), 32);
|
2017-11-21 11:52:49 +00:00
|
|
|
$(this).tooltip({placement: 'top'});
|
2017-11-19 15:37:37 +00:00
|
|
|
});
|
2014-07-03 11:19:14 +00:00
|
|
|
}
|
2017-09-21 12:21:37 +00:00
|
|
|
} else {
|
2016-09-20 13:49:21 +00:00
|
|
|
action.html('<span class="hidden-visually">' + t('core', 'Shared') + '</span>').prepend(icon);
|
2014-05-28 16:39:29 +00:00
|
|
|
}
|
2014-06-02 15:23:52 +00:00
|
|
|
if (hasLink) {
|
2016-02-17 10:04:29 +00:00
|
|
|
iconClass = 'icon-public';
|
2014-06-02 15:23:52 +00:00
|
|
|
}
|
2017-04-12 13:04:12 +00:00
|
|
|
icon.removeClass('icon-shared icon-public').addClass(iconClass);
|
2014-05-28 16:39:29 +00:00
|
|
|
},
|
2013-10-23 16:39:37 +00:00
|
|
|
showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions, filename) {
|
2015-08-13 00:38:14 +00:00
|
|
|
var configModel = new OC.Share.ShareConfigModel();
|
2015-08-11 21:14:44 +00:00
|
|
|
var attributes = {itemType: itemType, itemSource: itemSource, possiblePermissions: possiblePermissions};
|
2015-08-13 00:38:14 +00:00
|
|
|
var itemModel = new OC.Share.ShareItemModel(attributes, {configModel: configModel});
|
2015-08-07 22:23:06 +00:00
|
|
|
var dialogView = new OC.Share.ShareDialogView({
|
|
|
|
id: 'dropdown',
|
|
|
|
model: itemModel,
|
2015-08-13 00:38:14 +00:00
|
|
|
configModel: configModel,
|
2015-08-07 22:23:06 +00:00
|
|
|
className: 'drop shareDropDown',
|
|
|
|
attributes: {
|
2015-08-11 21:14:44 +00:00
|
|
|
'data-item-source-name': filename,
|
|
|
|
'data-item-type': itemType,
|
2015-09-18 21:19:59 +00:00
|
|
|
'data-item-source': itemSource
|
2015-08-07 22:23:06 +00:00
|
|
|
}
|
|
|
|
});
|
2015-07-30 22:07:41 +00:00
|
|
|
dialogView.setShowLink(link);
|
2015-08-07 22:23:06 +00:00
|
|
|
var $dialog = dialogView.render().$el;
|
2015-07-30 22:07:41 +00:00
|
|
|
$dialog.appendTo(appendTo);
|
|
|
|
$dialog.slideDown(OC.menuSpeed, function() {
|
|
|
|
OC.Share.droppedDown = true;
|
|
|
|
});
|
2015-08-24 21:27:43 +00:00
|
|
|
itemModel.fetch();
|
2012-05-05 18:56:52 +00:00
|
|
|
},
|
|
|
|
hideDropDown:function(callback) {
|
2014-06-04 08:37:04 +00:00
|
|
|
OC.Share.currentShares = null;
|
2015-03-26 11:21:40 +00:00
|
|
|
$('#dropdown').slideUp(OC.menuSpeed, function() {
|
2012-08-08 21:50:09 +00:00
|
|
|
OC.Share.droppedDown = false;
|
2012-05-05 18:56:52 +00:00
|
|
|
$('#dropdown').remove();
|
2012-08-08 21:50:09 +00:00
|
|
|
if (typeof FileActions !== 'undefined') {
|
|
|
|
$('tr').removeClass('mouseOver');
|
|
|
|
}
|
2012-05-05 18:56:52 +00:00
|
|
|
if (callback) {
|
|
|
|
callback.call();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2013-02-08 10:05:56 +00:00
|
|
|
dirname:function(path) {
|
2012-05-05 18:56:52 +00:00
|
|
|
return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
|
|
|
|
}
|
2015-07-30 22:07:41 +00:00
|
|
|
});
|
2012-05-05 18:56:52 +00:00
|
|
|
|
2011-07-27 01:27:40 +00:00
|
|
|
$(document).ready(function() {
|
2012-11-14 15:47:52 +00:00
|
|
|
if(typeof monthNames != 'undefined'){
|
2014-08-08 09:09:17 +00:00
|
|
|
// min date should always be the next day
|
|
|
|
var minDate = new Date();
|
|
|
|
minDate.setDate(minDate.getDate()+1);
|
2013-02-08 10:05:56 +00:00
|
|
|
$.datepicker.setDefaults({
|
|
|
|
monthNames: monthNames,
|
2015-08-21 07:17:36 +00:00
|
|
|
monthNamesShort: monthNamesShort,
|
2013-02-08 10:05:56 +00:00
|
|
|
dayNames: dayNames,
|
2015-08-21 07:17:36 +00:00
|
|
|
dayNamesMin: dayNamesMin,
|
|
|
|
dayNamesShort: dayNamesShort,
|
2014-06-06 15:40:16 +00:00
|
|
|
firstDay: firstDay,
|
2014-08-08 09:09:17 +00:00
|
|
|
minDate : minDate
|
2013-02-08 10:05:56 +00:00
|
|
|
});
|
|
|
|
}
|
2012-06-24 23:16:50 +00:00
|
|
|
|
2012-08-08 21:50:09 +00:00
|
|
|
$(this).click(function(event) {
|
2012-10-08 19:03:16 +00:00
|
|
|
var target = $(event.target);
|
2013-03-27 20:18:19 +00:00
|
|
|
var isMatched = !target.is('.drop, .ui-datepicker-next, .ui-datepicker-prev, .ui-icon')
|
2013-10-07 11:25:30 +00:00
|
|
|
&& !target.closest('#ui-datepicker-div').length && !target.closest('.ui-autocomplete').length;
|
2015-09-15 08:27:33 +00:00
|
|
|
if (OC.Share && OC.Share.droppedDown && isMatched && $('#dropdown').has(event.target).length === 0) {
|
2012-08-08 21:50:09 +00:00
|
|
|
OC.Share.hideDropDown();
|
|
|
|
}
|
|
|
|
});
|
2012-05-05 18:56:52 +00:00
|
|
|
|
2013-08-30 11:53:49 +00:00
|
|
|
|
2012-12-10 22:22:42 +00:00
|
|
|
|
2012-06-25 18:55:49 +00:00
|
|
|
});
|