2013-12-09 00:34:51 -05:00
|
|
|
module BroadcastMessagesHelper
|
2015-12-31 16:42:56 -05:00
|
|
|
def broadcast_message(message = BroadcastMessage.current)
|
|
|
|
return unless message.present?
|
|
|
|
|
|
|
|
content_tag :div, class: 'broadcast-message', style: broadcast_message_style(message) do
|
2016-10-06 18:01:42 -04:00
|
|
|
icon('bullhorn') << ' ' << render_broadcast_message(message)
|
2015-12-31 16:42:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def broadcast_message_style(broadcast_message)
|
|
|
|
style = ''
|
2015-05-21 17:49:06 -04:00
|
|
|
|
|
|
|
if broadcast_message.color.present?
|
2015-12-31 16:42:56 -05:00
|
|
|
style << "background-color: #{broadcast_message.color}"
|
|
|
|
style << '; ' if broadcast_message.font.present?
|
2013-12-09 00:34:51 -05:00
|
|
|
end
|
2015-05-21 17:49:06 -04:00
|
|
|
|
|
|
|
if broadcast_message.font.present?
|
2015-12-31 16:42:56 -05:00
|
|
|
style << "color: #{broadcast_message.font}"
|
2015-05-21 17:49:06 -04:00
|
|
|
end
|
|
|
|
|
2015-12-31 16:42:56 -05:00
|
|
|
style
|
2013-12-09 00:34:51 -05:00
|
|
|
end
|
2016-01-13 11:46:32 -05:00
|
|
|
|
|
|
|
def broadcast_message_status(broadcast_message)
|
|
|
|
if broadcast_message.active?
|
|
|
|
'Active'
|
|
|
|
elsif broadcast_message.ended?
|
|
|
|
'Expired'
|
|
|
|
else
|
|
|
|
'Pending'
|
|
|
|
end
|
|
|
|
end
|
2016-02-03 23:01:04 -05:00
|
|
|
|
2016-10-06 18:01:42 -04:00
|
|
|
def render_broadcast_message(broadcast_message)
|
|
|
|
Banzai.render_field(broadcast_message, :message).html_safe
|
2016-02-03 23:01:04 -05:00
|
|
|
end
|
2013-12-09 00:34:51 -05:00
|
|
|
end
|