diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-08-19 00:04:16 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-16 07:23:26 +0200 |
commit | dcb084a617b2ee24031a14bce8b8e9749c821b75 (patch) | |
tree | 528d9e8bcc41bd595eb6429952ca0db1bf107390 /core/js/sharedialogresharerinfoview.js | |
parent | 1bd6942be70da621da9acae56a23a39040ef24bf (diff) | |
download | nextcloud-server-dcb084a617b2ee24031a14bce8b8e9749c821b75.tar.gz nextcloud-server-dcb084a617b2ee24031a14bce8b8e9749c821b75.zip |
split ShareDialogResharerInfoView from base view
Diffstat (limited to 'core/js/sharedialogresharerinfoview.js')
-rw-r--r-- | core/js/sharedialogresharerinfoview.js | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/core/js/sharedialogresharerinfoview.js b/core/js/sharedialogresharerinfoview.js new file mode 100644 index 00000000000..3f996bb6d21 --- /dev/null +++ b/core/js/sharedialogresharerinfoview.js @@ -0,0 +1,117 @@ +/* + * 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}}' + + ' <div class="avatar"></div>' + + ' {{/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; + + //FIXME: specific to reshares stuff + this.model.on('change', function() { + view.render(); + }); + + if(!_.isUndefined(options.configModel)) { + this.configModel = options.configModel; + } else { + console.warn('missing OC.Share.ShareConfigModel'); + } + }, + + render: function() { + if ( !this.model.hasReshare() + || !this.model.getReshareOwner() !== OC.currentUser) + { + this.$el.html(''); + 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 } + ); + } + + this.$el.html(reshareTemplate({ + avatarEnabled: this.configModel.areAvatarsEnabled(), + sharedByText: sharedByText + })); + + return this; + }, + + /** + * @returns {Function} from Handlebars + * @private + */ + template: function () { + if (!this._template) { + this._template = Handlebars.compile(TEMPLATE); + } + return this._template; + } + + }); + + OC.Share.ShareDialogResharerInfoView = ShareDialogResharerInfoView; + +})(); |