123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- /*
- * Copyright (c) 2015
- *
- * This file is licensed under the Affero General Public License version 3
- * or later.
- *
- * See the COPYING-README file.
- *
- */
- /* globals Handlebars */
- (function() {
- if (!OC.Share) {
- OC.Share = {};
- }
- /**
- * @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;
- this.model.on('change:reshare', function() {
- view.render();
- });
- if(!_.isUndefined(options.configModel)) {
- this.configModel = options.configModel;
- } else {
- throw 'missing OC.Share.ShareConfigModel';
- }
- },
- render: function() {
- if (!this.model.hasReshare()
- || this.model.getReshareOwner() === OC.currentUser)
- {
- this.$el.empty();
- return this;
- }
- var reshareTemplate = this.template();
- var ownerDisplayName = this.model.getReshareOwnerDisplayname();
- var shareNote = this.model.getReshareNote();
-
- 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.getReshareWithDisplayName(),
- owner: ownerDisplayName
- },
- undefined,
- {escape: false}
- );
- } else if (this.model.getReshareType() === OC.Share.SHARE_TYPE_CIRCLE) {
- sharedByText = t(
- 'core',
- 'Shared with you and {circle} by {owner}',
- {
- circle: this.model.getReshareWithDisplayName(),
- owner: ownerDisplayName
- },
- undefined,
- {escape: false}
- );
- } else if (this.model.getReshareType() === OC.Share.SHARE_TYPE_ROOM) {
- if (this.model.get('reshare').share_with_displayname) {
- sharedByText = t(
- 'core',
- 'Shared with you and the conversation {conversation} by {owner}',
- {
- conversation: this.model.getReshareWithDisplayName(),
- owner: ownerDisplayName
- },
- undefined,
- {escape: false}
- );
- } else {
- sharedByText = t(
- 'core',
- 'Shared with you in a conversation by {owner}',
- {
- owner: ownerDisplayName
- },
- undefined,
- {escape: false}
- );
- }
- } else {
- sharedByText = t(
- 'core',
- 'Shared with you by {owner}',
- { owner: ownerDisplayName },
- undefined,
- {escape: false}
- );
- }
- this.$el.html(reshareTemplate({
- reshareOwner: this.model.getReshareOwner(),
- sharedByText: sharedByText,
- shareNote: shareNote,
- hasShareNote: shareNote !== ''
- }));
- this.$el.find('.avatar').each(function() {
- var $this = $(this);
- $this.avatar($this.data('username'), 32);
- });
- this.$el.find('.reshare').contactsMenu(
- this.model.getReshareOwner(),
- OC.Share.SHARE_TYPE_USER,
- this.$el);
- return this;
- },
- /**
- * @returns {Function} from Handlebars
- * @private
- */
- template: function () {
- return OC.Share.Templates['sharedialogresharerinfoview'];
- }
- });
- OC.Share.ShareDialogResharerInfoView = ShareDialogResharerInfoView;
- })();
|