You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

activitytabviewplugin.js 1.5KB

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