Module: Livechat::WidgetHelper
- Defined in:
- app/helpers/livechat/widget_helper.rb
Overview
Included into the host's ActionView. Drop <%= livechat_tag %> before
in your layout; it renders nothing unless chat is enabled for the request. The widget shows a floating launcher (unless show_launcher is off) and also opens from any element carrying `data-livechat-open`, or from `window.Livechat.open()`.
A plain, unstyled
A plain, unstyled
23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/livechat/widget_helper.rb', line 23 def (label = nil, message: nil, **) return unless Livechat.enabled?(request) label ||= .delete(:label) label ||= I18n.t(:launcher, scope: :livechat, default: 'Chat with us') data = (.delete(:data) { {} } || {}).merge(livechat_open: '') data[:livechat_message] = if .present? tag.(label, type: 'button', data: data, **) end |
10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/livechat/widget_helper.rb', line 10 def livechat_tag return unless Livechat.enabled?(request) Widget.snippet( locale: I18n.locale, authenticated: livechat_visitor.present?, nonce: (content_security_policy_nonce if respond_to?(:content_security_policy_nonce)) ).html_safe end |