nextcloud/apps/comments/src/activitytabviewplugin.js
dependabot-preview[bot] ec01e0a790
Bump eslint-config-nextcloud from 0.0.6 to 0.1.0
Bumps [eslint-config-nextcloud](https://github.com/nextcloud/eslint-config-nextcloud) from 0.0.6 to 0.1.0.
- [Release notes](https://github.com/nextcloud/eslint-config-nextcloud/releases)
- [Commits](https://github.com/nextcloud/eslint-config-nextcloud/compare/v0.0.6...v0.1.0)

Co-authored-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2019-12-19 11:55:33 +01:00

58 lines
1.5 KiB
JavaScript

/**
* @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')
const $overlay = $('<div>').addClass('message-overlay')
$el.find('.activitymessage').after($overlay)
$el.on('click', this._onClickCollapsedComment)
}
}
},
/*
* Copy of CommentsTabView._onClickComment()
*/
_onClickCollapsedComment: function(ev) {
let $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)