2015-08-19 01:04:16 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
if (!OC.Share) {
|
|
|
|
OC.Share = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
var TEMPLATE =
|
|
|
|
'<span class="reshare">' +
|
|
|
|
' {{#if avatarEnabled}}' +
|
2015-09-01 13:43:04 +03:00
|
|
|
' <div class="avatar" data-userName="{{reshareOwner}}"></div>' +
|
2015-08-19 01:04:16 +03:00
|
|
|
' {{/if}}' +
|
|
|
|
' {{sharedByText}}' +
|
|
|
|
'</span><br/>'
|
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class OCA.Share.ShareDialogView
|
|
|
|
* @member {OC.Share.ShareItemModel} model
|
|
|
|
* @member {jQuery} $el
|
|
|
|
* @memberof OCA.Sharing
|
|
|
|
* @classdesc
|
|
|
|
*
|
|
|
|
* Represents the GUI of the share dialogue
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
var ShareDialogResharerInfoView = OC.Backbone.View.extend({
|
|
|
|
/** @type {string} **/
|
|
|
|
id: 'shareDialogResharerInfo',
|
|
|
|
|
|
|
|
/** @type {string} **/
|
|
|
|
tagName: 'div',
|
|
|
|
|
|
|
|
/** @type {string} **/
|
|
|
|
className: 'reshare',
|
|
|
|
|
|
|
|
/** @type {OC.Share.ShareConfigModel} **/
|
|
|
|
configModel: undefined,
|
|
|
|
|
|
|
|
/** @type {Function} **/
|
|
|
|
_template: undefined,
|
|
|
|
|
|
|
|
initialize: function(options) {
|
|
|
|
var view = this;
|
|
|
|
|
2015-08-21 16:00:15 +03:00
|
|
|
this.model.on('change:reshare', function() {
|
2015-08-19 01:04:16 +03:00
|
|
|
view.render();
|
|
|
|
});
|
|
|
|
|
|
|
|
if(!_.isUndefined(options.configModel)) {
|
|
|
|
this.configModel = options.configModel;
|
|
|
|
} else {
|
2015-08-25 00:20:01 +03:00
|
|
|
throw 'missing OC.Share.ShareConfigModel';
|
2015-08-19 01:04:16 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
if ( !this.model.hasReshare()
|
|
|
|
|| !this.model.getReshareOwner() !== OC.currentUser)
|
|
|
|
{
|
2015-08-21 16:00:15 +03:00
|
|
|
this.$el.empty();
|
2015-08-19 01:04:16 +03:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
var reshareTemplate = this.template();
|
|
|
|
var ownerDisplayName = this.model.getReshareOwnerDisplayname();
|
|
|
|
var sharedByText = '';
|
|
|
|
if (this.model.getReshareType() === OC.Share.SHARE_TYPE_GROUP) {
|
|
|
|
sharedByText = t(
|
|
|
|
'core',
|
|
|
|
'Shared with you and the group {group} by {owner}',
|
|
|
|
{
|
|
|
|
group: this.model.getReshareWith(),
|
|
|
|
owner: ownerDisplayName
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
sharedByText = t(
|
|
|
|
'core',
|
|
|
|
'Shared with you by {owner}',
|
|
|
|
{ owner: ownerDisplayName }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-08-25 00:20:01 +03:00
|
|
|
this.$el.html(reshareTemplate({
|
2015-08-19 01:04:16 +03:00
|
|
|
avatarEnabled: this.configModel.areAvatarsEnabled(),
|
2015-09-01 13:43:04 +03:00
|
|
|
reshareOwner: this.model.getReshareOwner(),
|
2015-08-19 01:04:16 +03:00
|
|
|
sharedByText: sharedByText
|
|
|
|
}));
|
|
|
|
|
2015-09-12 15:21:14 +03:00
|
|
|
if(this.configModel.areAvatarsEnabled()) {
|
|
|
|
this.$el.find('.avatar').each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
$this.avatar($this.data('username'), 32);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-08-19 01:04:16 +03:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Function} from Handlebars
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
template: function () {
|
|
|
|
if (!this._template) {
|
|
|
|
this._template = Handlebars.compile(TEMPLATE);
|
|
|
|
}
|
|
|
|
return this._template;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
OC.Share.ShareDialogResharerInfoView = ShareDialogResharerInfoView;
|
|
|
|
|
|
|
|
})();
|