2014-09-02 18:07:02 +05:30
|
|
|
module BroadcastMessagesHelper
|
2016-01-19 16:12:03 +05:30
|
|
|
def broadcast_message(message = BroadcastMessage.current)
|
|
|
|
return unless message.present?
|
|
|
|
|
|
|
|
content_tag :div, class: 'broadcast-message', style: broadcast_message_style(message) do
|
2016-11-03 12:29:30 +05:30
|
|
|
icon('bullhorn') << ' ' << render_broadcast_message(message)
|
2016-01-19 16:12:03 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def broadcast_message_style(broadcast_message)
|
|
|
|
style = ''
|
2015-09-11 14:41:01 +05:30
|
|
|
|
|
|
|
if broadcast_message.color.present?
|
2016-01-19 16:12:03 +05:30
|
|
|
style << "background-color: #{broadcast_message.color}"
|
|
|
|
style << '; ' if broadcast_message.font.present?
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
|
|
|
if broadcast_message.font.present?
|
2016-01-19 16:12:03 +05:30
|
|
|
style << "color: #{broadcast_message.font}"
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
|
2016-01-19 16:12:03 +05:30
|
|
|
style
|
|
|
|
end
|
|
|
|
|
|
|
|
def broadcast_message_status(broadcast_message)
|
|
|
|
if broadcast_message.active?
|
|
|
|
'Active'
|
|
|
|
elsif broadcast_message.ended?
|
|
|
|
'Expired'
|
|
|
|
else
|
|
|
|
'Pending'
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2016-04-02 18:10:28 +05:30
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
def render_broadcast_message(broadcast_message)
|
|
|
|
Banzai.render_field(broadcast_message, :message).html_safe
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|