scinote-web/app/helpers/activity_helper.rb

14 lines
543 B
Ruby
Raw Normal View History

2016-07-21 19:11:15 +08:00
module ActivityHelper
def activity_truncate(message, len = Constants::NAME_TRUNCATION_LENGTH)
2016-07-21 19:11:15 +08:00
activity_title = message.match(/<strong>(.*?)<\/strong>/)[1]
if activity_title.length > Constants::NAME_TRUNCATION_LENGTH
2016-07-21 19:11:15 +08:00
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