Sha256: aa81401a631af776eeb1873e041ab635d68e95715f7dfde3bdbd24f3ce34bff0

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 Bytes

Contents

# coding: utf-8

require "zopim_rails/version"

module ZopimRails

  PLACEHOLDER_KEY = "xxxxxxxxx"
  # Get the current api key.
  # @return [String]
  def self.api_key
    @@api_key ||= PLACEHOLDER_KEY
  end

  # Set the current api key.
  # @param [String] tracker The api key.
  def self.api_key=(api_key)
    @@api_key = api_key
  end

  # @return [Boolean]
  def self.valid_api_key?
    !api_key.blank? || api_key == PLACEHOLDER_KEY ? false : true
  end

  def self.render
    <<-JAVASCRIPT
    <script type="text/javascript">window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set._.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');$.src='//v2.zopim.com/?#{self.api_key}';z.t=+new Date;$.type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');</script>
    JAVASCRIPT
  end
  def self.init
    self.render.html_safe
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zopim_rails-0.0.1 lib/zopim_rails.rb