1/* 2 * Copyright (c) 2015 3 * 4 * This file is licensed under the Affero General Public License version 3 5 * or later. 6 * 7 * See the COPYING-README file. 8 * 9 */ 10 11(function() { 12 if (!OC.Share) { 13 OC.Share = {}; 14 } 15 16 var TEMPLATE = 17 '<span class="reshare">' + 18 ' {{#if avatarEnabled}}' + 19 ' <div class="avatar" data-userName="{{reshareOwner}}"></div>' + 20 ' {{/if}}' + 21 ' {{sharedByText}}' + 22 '</span><br/>' 23 ; 24 25 /** 26 * @class OCA.Share.ShareDialogView 27 * @member {OC.Share.ShareItemModel} model 28 * @member {jQuery} $el 29 * @memberof OCA.Sharing 30 * @classdesc 31 * 32 * Represents the GUI of the share dialogue 33 * 34 */ 35 var ShareDialogResharerInfoView = OC.Backbone.View.extend({ 36 /** @type {string} **/ 37 id: 'shareDialogResharerInfo', 38 39 /** @type {string} **/ 40 tagName: 'div', 41 42 /** @type {string} **/ 43 className: 'reshare', 44 45 /** @type {OC.Share.ShareConfigModel} **/ 46 configModel: undefined, 47 48 /** @type {Function} **/ 49 _template: undefined, 50 51 initialize: function(options) { 52 var view = this; 53 54 this.model.on('change:reshare', function() { 55 view.render(); 56 }); 57 58 if(!_.isUndefined(options.configModel)) { 59 this.configModel = options.configModel; 60 } else { 61 throw 'missing OC.Share.ShareConfigModel'; 62 } 63 }, 64 65 render: function() { 66 if (!this.model.hasReshare() 67 || this.model.getReshareOwner() === OC.currentUser) 68 { 69 this.$el.empty(); 70 return this; 71 } 72 73 var reshareTemplate = this.template(); 74 var ownerDisplayName = this.model.getReshareOwnerDisplayname(); 75 var sharedByText = ''; 76 if (this.model.getReshareType() === OC.Share.SHARE_TYPE_GROUP) { 77 sharedByText = t( 78 'core', 79 'Shared with you and the group {group} by {owner}', 80 { 81 group: this.model.getReshareWithDisplayName(), 82 owner: ownerDisplayName 83 } 84 ); 85 } else { 86 sharedByText = t( 87 'core', 88 'Shared with you by {owner}', 89 { owner: ownerDisplayName } 90 ); 91 } 92 93 this.$el.html(reshareTemplate({ 94 avatarEnabled: this.configModel.areAvatarsEnabled(), 95 reshareOwner: this.model.getReshareOwner(), 96 sharedByText: sharedByText 97 })); 98 99 if(this.configModel.areAvatarsEnabled()) { 100 this.$el.find('.avatar').each(function() { 101 var $this = $(this); 102 $this.avatar($this.data('username'), 32); 103 }); 104 } 105 106 return this; 107 }, 108 109 /** 110 * @returns {Function} from Handlebars 111 * @private 112 */ 113 template: function () { 114 if (!this._template) { 115 this._template = Handlebars.compile(TEMPLATE); 116 } 117 return this._template; 118 } 119 120 }); 121 122 OC.Share.ShareDialogResharerInfoView = ShareDialogResharerInfoView; 123 124})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.