blob: b6195b80c457ea2bcbf57a7deaa5236efcd8619b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*
* @author Joas Schilling <coding@schilljs.com>
* Copyright (c) 2016
*
* This file is licensed under the Affero General Public License version 3
* or later.
*
* See the COPYING-README file.
*/
(function() {
OCA.Comments.ActivityTabViewPlugin = {
/**
* Prepare activity for display
*
* @param {OCA.Activity.ActivityModel} model for this activity
* @param {jQuery} $el jQuery handle for this activity
* @param {string} view The view that displayes this activity
*/
prepareModelForDisplay: function (model, $el, view) {
if (model.get('app') !== 'comments' || model.get('type') !== 'comments') {
return;
}
if (view === 'ActivityTabView') {
$el.addClass('comment');
if (model.get('message') && this._isLong(model.get('message'))) {
$el.addClass('collapsed');
var $overlay = $('<div>').addClass('message-overlay');
$el.find('.activitymessage').after($overlay);
$el.on('click', this._onClickCollapsedComment);
}
}
},
/*
* Copy of CommentsTabView._onClickComment()
*/
_onClickCollapsedComment: function(ev) {
var $row = $(ev.target);
if (!$row.is('.comment')) {
$row = $row.closest('.comment');
}
$row.removeClass('collapsed');
},
/*
* Copy of CommentsTabView._isLong()
*/
_isLong: function(message) {
return message.length > 250 || (message.match(/\n/g) || []).length > 1;
}
};
})();
OC.Plugins.register('OCA.Activity.RenderingPlugins', OCA.Comments.ActivityTabViewPlugin);
|