Register a ActivityTabView plugin
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
parent
fe6c9f7f47
commit
724cd50e52
|
@ -32,6 +32,7 @@ $eventDispatcher->addListener(
|
||||||
\OCP\Util::addScript('comments', 'commentsummarymodel');
|
\OCP\Util::addScript('comments', 'commentsummarymodel');
|
||||||
\OCP\Util::addScript('comments', 'commentstabview');
|
\OCP\Util::addScript('comments', 'commentstabview');
|
||||||
\OCP\Util::addScript('comments', 'filesplugin');
|
\OCP\Util::addScript('comments', 'filesplugin');
|
||||||
|
\OCP\Util::addScript('comments', 'activitytabviewplugin');
|
||||||
\OCP\Util::addStyle('comments', 'comments');
|
\OCP\Util::addStyle('comments', 'comments');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* @author Joas Schilling <nickvergessen@owncloud.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 (this._isLong(model.get('message_prepared'))) {
|
||||||
|
$el.addClass('collapsed');
|
||||||
|
var $overlay = $('<div>').addClass('message-overlay');
|
||||||
|
$el.find('.activitymessage').after($overlay);
|
||||||
|
$el.on('click', this._onClickCollapsedComment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_onClickCollapsedComment: function(ev) {
|
||||||
|
var $row = $(ev.target);
|
||||||
|
if (!$row.is('.comment')) {
|
||||||
|
$row = $row.closest('.comment');
|
||||||
|
}
|
||||||
|
$row.removeClass('collapsed');
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given message is long and needs
|
||||||
|
* collapsing
|
||||||
|
*/
|
||||||
|
_isLong: function(message) {
|
||||||
|
return message.length > 250 || (message.match(/\n/g) || []).length > 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
OC.Plugins.register('OCA.Activity.Plugins', OCA.Comments.ActivityTabViewPlugin);
|
Loading…
Reference in New Issue