Skip to content

Commit

Permalink
Add Chat Widget JS API code and append to head
Browse files Browse the repository at this point in the history
  • Loading branch information
roseliux committed Nov 26, 2020
1 parent 18c20e6 commit 26bac6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- if Workarea::Livechat.enabled?
:javascript
window.__lc = window.__lc || {};
window.__lc.license = "#{Workarea::Livechat.license_number}";
;(function(n,t,c){function i(n){return e._h?e._h.apply(null,n):e._q.push(n)}var e={_q:[],_h:null,_v:"2.0",on:function(){i(["on",c.call(arguments)])},once:function(){i(["once",c.call(arguments)])},off:function(){i(["off",c.call(arguments)])},get:function(){if(!e._h)throw new Error("[LiveChatWidget] You can't use getters before load.");return i(["get",c.call(arguments)])},call:function(){i(["call",c.call(arguments)])},init:function(){var n=t.createElement("script");n.async=!0,n.type="text/javascript",n.src="https://cdn.livechatinc.com/tracking.js",t.head.appendChild(n)}};!n.__lc.asyncInit&&e.init(),n.LiveChatWidget=n.LiveChatWidget||e}(window,document,[].slice))
%noscript
%a{:href => "https://www.livechatinc.com/chat-with/#{Workarea::Livechat.license_number}/", :rel => "nofollow"}> Chat with us
, powered by
%a{:href => "https://www.livechatinc.com/?welcome", :rel => "noopener nofollow", :target => "_blank"} LiveChat
5 changes: 5 additions & 0 deletions config/initializers/appends.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Workarea.append_partials(
'storefront.document_head',
'workarea/storefront/livechat/livechat_javascript'
)

0 comments on commit 26bac6b

Please sign in to comment.