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