mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 10:06:53 +08:00
13 lines
543 B
Ruby
13 lines
543 B
Ruby
module ActivityHelper
|
|
def activity_truncate(message, len = Constants::NAME_TRUNCATION_LENGTH)
|
|
activity_title = message.match(/<strong>(.*?)<\/strong>/)[1]
|
|
if activity_title.length > Constants::NAME_TRUNCATION_LENGTH
|
|
title = "<div class='modal-tooltip'>#{truncate(activity_title, length: len)}
|
|
<span class='modal-tooltiptext'>#{activity_title}</span></div>"
|
|
else
|
|
title = truncate(activity_title, length: len)
|
|
end
|
|
message = message.gsub(/#{activity_title}/, title )
|
|
message.html_safe if message
|
|
end
|
|
end
|