2019-09-25 16:19:42 +00:00
|
|
|
/* eslint-disable */
|
2014-07-03 11:19:14 +00:00
|
|
|
/**
|
|
|
|
* @namespace
|
|
|
|
*/
|
2015-09-15 08:27:33 +00:00
|
|
|
OC.Share = _.extend(OC.Share || {}, {
|
2019-09-25 16:19:42 +00:00
|
|
|
SHARE_TYPE_USER: 0,
|
|
|
|
SHARE_TYPE_GROUP: 1,
|
|
|
|
SHARE_TYPE_LINK: 3,
|
|
|
|
SHARE_TYPE_EMAIL: 4,
|
|
|
|
SHARE_TYPE_REMOTE: 6,
|
|
|
|
SHARE_TYPE_CIRCLE: 7,
|
|
|
|
SHARE_TYPE_GUEST: 8,
|
|
|
|
SHARE_TYPE_REMOTE_GROUP: 9,
|
|
|
|
SHARE_TYPE_ROOM: 10,
|
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
|
|
|
|
*/
|
2019-09-25 16:19:42 +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
|
|
|
|
*/
|
2019-09-25 16:19:42 +00:00
|
|
|
itemShares: [],
|
2014-06-04 08:37:04 +00:00
|
|
|
/**
|
|
|
|
* Full list of all share statuses
|
|
|
|
*/
|
2019-09-25 16:19:42 +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.
|
|
|
|
*/
|
2019-09-25 16:19:42 +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
|
|
|
*/
|
2019-09-25 16:19:42 +00:00
|
|
|
loadIcons: function(itemType, fileList, callback) {
|
|
|
|
var path = fileList.dirInfo.path
|
2016-02-11 10:06:26 +00:00
|
|
|
if (path === '/') {
|
2019-09-25 16:19:42 +00:00
|
|
|
path = ''
|
2016-02-11 10:06:26 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
path += '/' + fileList.dirInfo.name
|
2016-02-11 10:06:26 +00:00
|
|
|
|
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) {
|
2019-09-25 16:19:42 +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)) {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.Share.statuses[share.item_source] = { link: false }
|
2016-02-11 07:17:52 +00:00
|
|
|
}
|
|
|
|
if (share.share_type === OC.Share.SHARE_TYPE_LINK) {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.Share.statuses[share.item_source] = { link: true }
|
2016-02-11 07:17:52 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2014-07-01 19:32:04 +00:00
|
|
|
if (_.isFunction(callback)) {
|
2019-09-25 16:19:42 +00:00
|
|
|
callback(OC.Share.statuses)
|
2014-07-01 19:32:04 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.Share.updateIcons(itemType, fileList)
|
2014-07-01 19:32:04 +00:00
|
|
|
}
|
2014-03-01 01:46:27 +00:00
|
|
|
}
|
2013-10-17 09:59:13 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +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
|
|
|
*/
|
2019-09-25 16:19:42 +00:00
|
|
|
updateIcons: function(itemType, fileList) {
|
|
|
|
var item
|
|
|
|
var $fileList
|
|
|
|
var currentDir
|
2014-05-28 14:34:00 +00:00
|
|
|
if (!fileList && OCA.Files) {
|
2019-09-25 16:19:42 +00:00
|
|
|
fileList = OCA.Files.App.fileList
|
2014-05-28 14:34:00 +00:00
|
|
|
}
|
|
|
|
// fileList is usually only defined in the files app
|
|
|
|
if (fileList) {
|
2019-09-25 16:19:42 +00:00
|
|
|
$fileList = fileList.$fileList
|
|
|
|
currentDir = fileList.getCurrentDirectory()
|
2014-05-28 14:34:00 +00:00
|
|
|
}
|
2014-06-02 15:23:52 +00:00
|
|
|
// TODO: iterating over the files might be more efficient
|
2019-09-25 16:19:42 +00:00
|
|
|
for (item in OC.Share.statuses) {
|
|
|
|
var iconClass = 'icon-shared'
|
|
|
|
var data = OC.Share.statuses[item]
|
|
|
|
var hasLink = data.link
|
2013-10-17 09:59:13 +00:00
|
|
|
// Links override shared in terms of icon display
|
|
|
|
if (hasLink) {
|
2019-09-25 16:19:42 +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') {
|
2019-09-25 16:19:42 +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
|
2019-09-25 16:19:42 +00:00
|
|
|
var file = $fileList.find('tr[data-id="' + item + '"]')
|
|
|
|
var shareFolder = OC.imagePath('core', 'filetypes/folder-shared')
|
|
|
|
var img
|
2013-10-17 09:59:13 +00:00
|
|
|
if (file.length > 0) {
|
2019-09-25 16:19:42 +00:00
|
|
|
this.markFileAsShared(file, true, hasLink)
|
2013-10-17 09:59:13 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
var dir = currentDir
|
2013-10-17 09:59:13 +00:00
|
|
|
if (dir.length > 1) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var last = ''
|
|
|
|
var path = dir
|
2013-10-17 09:59:13 +00:00
|
|
|
// 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) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var actions = $fileList.find('.fileactions .action[data-action="Share"]')
|
|
|
|
var files = $fileList.find('.filename')
|
|
|
|
var i
|
2014-05-28 10:13:55 +00:00
|
|
|
for (i = 0; i < actions.length; i++) {
|
2014-05-28 16:39:29 +00:00
|
|
|
// TODO: use this.markFileAsShared()
|
2019-09-25 16:19:42 +00:00
|
|
|
img = $(actions[i]).find('img')
|
2014-05-21 10:54:34 +00:00
|
|
|
if (img.attr('src') !== OC.imagePath('core', 'actions/public')) {
|
2019-09-25 16:19:42 +00:00
|
|
|
img.attr('src', image)
|
|
|
|
$(actions[i]).addClass('permanent')
|
|
|
|
$(actions[i]).html('<span> ' + t('core', 'Shared') + '</span>').prepend(img)
|
2014-05-28 10:13:55 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
for (i = 0; i < files.length; i++) {
|
2014-05-28 10:13:55 +00:00
|
|
|
if ($(files[i]).closest('tr').data('type') === 'dir') {
|
2019-09-25 16:19:42 +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
|
|
|
}
|
2019-09-25 16:19:42 +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
|
|
|
},
|
2019-09-25 16:19:42 +00:00
|
|
|
updateIcon: function(itemType, itemSource) {
|
|
|
|
var shares = false
|
|
|
|
var link = false
|
|
|
|
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) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shares = true
|
|
|
|
iconClass = 'icon-public'
|
|
|
|
link = true
|
|
|
|
|
2012-09-19 05:44:15 +00:00
|
|
|
}
|
|
|
|
} else if (OC.Share.itemShares[index].length > 0) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shares = true
|
|
|
|
iconClass = 'icon-shared'
|
2012-09-19 05:44:15 +00:00
|
|
|
}
|
2012-08-24 19:32:06 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2012-09-19 05:44:15 +00:00
|
|
|
if (itemType != 'file' && itemType != 'folder') {
|
2019-09-25 16:19:42 +00:00
|
|
|
$('a.share[data-item="' + itemSource + '"] .icon').removeClass('icon-shared icon-public').addClass(iconClass)
|
2013-01-26 18:25:15 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
var $tr = $('tr').filterAttr('data-id', String(itemSource))
|
2014-05-28 16:39:29 +00:00
|
|
|
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() {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.Share.markFileAsShared($(this), shares, link)
|
|
|
|
})
|
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) {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.Share.statuses[itemSource] = OC.Share.statuses[itemSource] || {}
|
|
|
|
OC.Share.statuses[itemSource].link = link
|
2012-08-24 19:32:06 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
delete OC.Share.statuses[itemSource]
|
2012-08-24 19:32:06 +00:00
|
|
|
}
|
|
|
|
},
|
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
|
2019-09-25 16:19:42 +00:00
|
|
|
* @returns {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) {
|
2019-09-25 16:19:42 +00:00
|
|
|
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
|
2019-09-25 16:19:42 +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> '
|
|
|
|
return avatar + hidden
|
2014-07-03 11:19:14 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var userName = parts[1]
|
|
|
|
var userDomain = parts[3]
|
|
|
|
var server = parts[4]
|
|
|
|
var tooltip = message + ' ' + userName
|
2014-07-03 11:19:14 +00:00
|
|
|
if (userDomain) {
|
2019-09-25 16:19:42 +00:00
|
|
|
tooltip += '@' + userDomain
|
2014-07-03 11:19:14 +00:00
|
|
|
}
|
|
|
|
if (server) {
|
2015-01-27 10:06:18 +00:00
|
|
|
if (!userDomain) {
|
2019-09-25 16:19:42 +00:00
|
|
|
userDomain = '…'
|
2015-01-27 10:06:18 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
tooltip += '@' + server
|
2014-07-03 11:19:14 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var html = '<span class="remoteAddress" title="' + escapeHTML(tooltip) + '">'
|
|
|
|
html += '<span class="username">' + escapeHTML(userName) + '</span>'
|
2014-07-03 11:19:14 +00:00
|
|
|
if (userDomain) {
|
2019-09-25 16:19:42 +00:00
|
|
|
html += '<span class="userDomain">@' + escapeHTML(userDomain) + '</span>'
|
2014-07-03 11:19:14 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
html += '</span> '
|
|
|
|
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
|
2019-09-25 16:19:42 +00:00
|
|
|
* @returns {String[]} modified list of recipients
|
2015-05-16 12:22:10 +00:00
|
|
|
*/
|
|
|
|
_formatShareList: function(recipients) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var _parent = this
|
|
|
|
recipients = _.toArray(recipients)
|
2017-11-21 11:45:57 +00:00
|
|
|
recipients.sort(function(a, b) {
|
2019-09-25 16:19:42 +00:00
|
|
|
return a.shareWithDisplayName.localeCompare(b.shareWithDisplayName)
|
|
|
|
})
|
2017-11-21 10:29:42 +00:00
|
|
|
return $.map(recipients, function(recipient) {
|
2019-09-25 16:19:42 +00:00
|
|
|
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) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var action = $tr.find('.fileactions .action[data-action="Share"]')
|
|
|
|
var type = $tr.data('type')
|
|
|
|
var icon = action.find('.icon')
|
|
|
|
var message, recipients, avatars
|
|
|
|
var ownerId = $tr.attr('data-share-owner-id')
|
|
|
|
var owner = $tr.attr('data-share-owner')
|
|
|
|
var mountType = $tr.attr('data-mounttype')
|
|
|
|
var shareFolderIcon
|
|
|
|
var iconClass = 'icon-shared'
|
|
|
|
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)) {
|
2019-09-03 08:07:27 +00:00
|
|
|
if (typeof mountType !== 'undefined' && mountType !== 'shared-root' && mountType !== 'shared') {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareFolderIcon = OC.MimeType.getIconUrl('dir-' + mountType)
|
2019-09-03 08:07:27 +00:00
|
|
|
} else if (hasLink) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareFolderIcon = OC.MimeType.getIconUrl('dir-public')
|
2019-09-03 08:07:27 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareFolderIcon = OC.MimeType.getIconUrl('dir-shared')
|
2014-06-02 15:23:52 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
$tr.find('.filename .thumbnail').css('background-image', 'url(' + shareFolderIcon + ')')
|
|
|
|
$tr.attr('data-icon', shareFolderIcon)
|
2014-05-28 16:39:29 +00:00
|
|
|
} else if (type === 'dir') {
|
2019-09-25 16:19:42 +00:00
|
|
|
var isEncrypted = $tr.attr('data-e2eencrypted')
|
2015-10-28 16:43:36 +00:00
|
|
|
// FIXME: duplicate of FileList._createRow logic for external folder,
|
|
|
|
// need to refactor the icon logic into a single code path eventually
|
2017-09-19 15:24:53 +00:00
|
|
|
if (isEncrypted === 'true') {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareFolderIcon = OC.MimeType.getIconUrl('dir-encrypted')
|
|
|
|
$tr.attr('data-icon', shareFolderIcon)
|
2017-09-19 15:24:53 +00:00
|
|
|
} else if (mountType && mountType.indexOf('external') === 0) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareFolderIcon = OC.MimeType.getIconUrl('dir-external')
|
|
|
|
$tr.attr('data-icon', shareFolderIcon)
|
2015-10-28 16:43:36 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareFolderIcon = OC.MimeType.getIconUrl('dir')
|
2015-10-28 16:43:36 +00:00
|
|
|
// back to default
|
2019-09-25 16:19:42 +00:00
|
|
|
$tr.removeAttr('data-icon')
|
2015-10-28 16:43:36 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +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) {
|
2019-09-25 16:19:42 +00:00
|
|
|
recipients = $tr.data('share-recipient-data')
|
|
|
|
action.addClass('shared-style')
|
2014-05-28 16:39:29 +00:00
|
|
|
|
2019-09-25 16:19:42 +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) {
|
2019-09-25 16:19:42 +00:00
|
|
|
message = t('core', 'Shared by')
|
|
|
|
avatars = this._formatRemoteShare(ownerId, owner, message)
|
2017-09-21 12:04:23 +00:00
|
|
|
} else if (recipients) {
|
2019-09-25 16:19:42 +00:00
|
|
|
avatars = this._formatShareList(recipients)
|
2014-05-28 16:39:29 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +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) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var avatarElement = action.find('.avatar')
|
|
|
|
avatarElement.each(function() {
|
|
|
|
$(this).avatar($(this).data('username'), 32)
|
|
|
|
})
|
|
|
|
action.find('span[title]').tooltip({ placement: 'top' })
|
2014-07-03 11:19:14 +00:00
|
|
|
}
|
2017-09-21 12:21:37 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +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) {
|
2019-09-25 16:19:42 +00:00
|
|
|
iconClass = 'icon-public'
|
2014-06-02 15:23:52 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
icon.removeClass('icon-shared icon-public').addClass(iconClass)
|
2014-05-28 16:39:29 +00:00
|
|
|
},
|
2019-09-25 16:19:42 +00:00
|
|
|
showDropDown: function(itemType, itemSource, appendTo, link, possiblePermissions, filename) {
|
|
|
|
var configModel = new OC.Share.ShareConfigModel()
|
|
|
|
var attributes = { itemType: itemType, itemSource: itemSource, possiblePermissions: possiblePermissions }
|
|
|
|
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
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
|
|
|
dialogView.setShowLink(link)
|
|
|
|
var $dialog = dialogView.render().$el
|
|
|
|
$dialog.appendTo(appendTo)
|
2015-07-30 22:07:41 +00:00
|
|
|
$dialog.slideDown(OC.menuSpeed, function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.Share.droppedDown = true
|
|
|
|
})
|
|
|
|
itemModel.fetch()
|
2012-05-05 18:56:52 +00:00
|
|
|
},
|
2019-09-25 16:19:42 +00:00
|
|
|
hideDropDown: function(callback) {
|
|
|
|
OC.Share.currentShares = null
|
2015-03-26 11:21:40 +00:00
|
|
|
$('#dropdown').slideUp(OC.menuSpeed, function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.Share.droppedDown = false
|
|
|
|
$('#dropdown').remove()
|
2012-08-08 21:50:09 +00:00
|
|
|
if (typeof FileActions !== 'undefined') {
|
2019-09-25 16:19:42 +00:00
|
|
|
$('tr').removeClass('mouseOver')
|
2012-08-08 21:50:09 +00:00
|
|
|
}
|
2012-05-05 18:56:52 +00:00
|
|
|
if (callback) {
|
2019-09-25 16:19:42 +00:00
|
|
|
callback.call()
|
2012-05-05 18:56:52 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2012-05-05 18:56:52 +00:00
|
|
|
},
|
2019-09-25 16:19:42 +00:00
|
|
|
dirname: function(path) {
|
|
|
|
return path.replace(/\\/g, '/').replace(/\/[^\/]*$/, '')
|
2012-05-05 18:56:52 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2012-05-05 18:56:52 +00:00
|
|
|
|
2011-07-27 01:27:40 +00:00
|
|
|
$(document).ready(function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
if (typeof monthNames !== 'undefined') {
|
2014-08-08 09:09:17 +00:00
|
|
|
// min date should always be the next day
|
2019-09-25 16:19:42 +00:00
|
|
|
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,
|
2019-09-25 16:19:42 +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) {
|
2019-09-25 16:19:42 +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')
|
2019-09-25 16:19:42 +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) {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.Share.hideDropDown()
|
2012-08-08 21:50:09 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2012-12-10 22:22:42 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|