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()`.

Instance Method Summary collapse

Instance Method Details

#livechat_button(label: nil) ⇒ Object

A plain, unstyled



22
23
24
25
26
27
# File 'app/helpers/livechat/widget_helper.rb', line 22

def livechat_button(label: nil, **)
  return unless Livechat.enabled?(request)

  label ||= I18n.t(:launcher, scope: :livechat, default: 'Chat with us')
  tag.button(label, type: 'button', 'data-livechat-open': '', **)
end

#livechat_tagObject



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