2016-04-26 10:47:57 +00:00
|
|
|
/*
|
2016-10-05 12:33:54 +00:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2016-04-26 10:47:57 +00:00
|
|
|
* 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');
|
2016-11-16 10:39:06 +00:00
|
|
|
if (model.get('message') && this._isLong(model.get('message'))) {
|
2016-04-26 10:47:57 +00:00
|
|
|
$el.addClass('collapsed');
|
|
|
|
var $overlay = $('<div>').addClass('message-overlay');
|
|
|
|
$el.find('.activitymessage').after($overlay);
|
|
|
|
$el.on('click', this._onClickCollapsedComment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-04-26 13:18:55 +00:00
|
|
|
/*
|
|
|
|
* Copy of CommentsTabView._onClickComment()
|
|
|
|
*/
|
2016-04-26 10:47:57 +00:00
|
|
|
_onClickCollapsedComment: function(ev) {
|
|
|
|
var $row = $(ev.target);
|
|
|
|
if (!$row.is('.comment')) {
|
|
|
|
$row = $row.closest('.comment');
|
|
|
|
}
|
|
|
|
$row.removeClass('collapsed');
|
|
|
|
},
|
|
|
|
|
2016-04-26 13:18:55 +00:00
|
|
|
/*
|
|
|
|
* Copy of CommentsTabView._isLong()
|
2016-04-26 10:47:57 +00:00
|
|
|
*/
|
|
|
|
_isLong: function(message) {
|
|
|
|
return message.length > 250 || (message.match(/\n/g) || []).length > 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
2016-09-12 09:44:38 +00:00
|
|
|
OC.Plugins.register('OCA.Activity.RenderingPlugins', OCA.Comments.ActivityTabViewPlugin);
|