tawk_rails 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 405464f2e72850c3d7e2086f5d95ae361b4a0c2d
4
- data.tar.gz: bfe6e1bc95859024deb7dd583f761dfe8d57ec32
3
+ metadata.gz: b16a7692773500ca09d11f5f7a0c9d5815ee756e
4
+ data.tar.gz: 8def385ff13ab3528d3e5ab1e71907e82f096d28
5
5
  SHA512:
6
- metadata.gz: bf81e350f175c5f22baabca06db1eac3dcc3ad753496ec1d37559ee86e870af03fde3681a5fa90c3f25603b768bfb9f551def890c962462c4b6f8a0892e28e9f
7
- data.tar.gz: 170a27a0238239e9ef9069d65b71cdf38844cc6a17b3833ed2da27a18c5c476ea3e889f11db1a57c1a71e456e9f2675e1feabe714792d855c939c4edb8f4cd06
6
+ metadata.gz: 8f2cffa58cfa96fb106c86d3aeb2e503ecb8a78b7137a6414e0eca56538a5781335cf5d8b6debdd0b7abaf7609b953d29857dfb0c28cb6c4754e86a5ed879ede
7
+ data.tar.gz: f37ac24a8e7232d12636ef7e56985a3424ec53e5126b69b63a966054c4ca25f46a65299aded3c1eb27db50e42c3cd581876e756eaac0f6dee0df60f928a2b265
@@ -0,0 +1 @@
1
+ language: ruby
data/README.md CHANGED
@@ -20,16 +20,22 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Create file `tawk.rb` in `config/initializes/tawk.rb` and add
23
+ Create file `tawk.rb` in `config/initializers/tawk.rb` and add
24
24
 
25
- TawkRails.configure do |config|
26
- config.id_site = 'replace-me-with-your-id_site'
27
- end
25
+ ```ruby
26
+ TawkRails.configure do |config|
27
+ config.id_site = 'replace-me-with-your-id_site'
28
+ end
29
+ ```
28
30
 
29
31
  place render method where you want in view.
30
32
 
31
33
  <%= tawk_init %>
32
34
 
35
+ you can pass js methods as string to the helper https://www.tawk.to/javascript-api/
36
+
37
+ <%= tawk_init "Tawk_API.onStatusChange = function(status){console.log(status);}; Tawk_API.visitor = {name : 'Name', email : 'email@email.com'};" %>
38
+
33
39
  ## Contributing
34
40
 
35
41
  1. Fork it ( https://github.com/luizpicolo/tawk_rails/fork )
@@ -1,10 +1,13 @@
1
1
  # coding: utf-8
2
-
3
2
  module TawkRails
4
3
  class Chatbox
4
+ def initialize(params = nil)
5
+ @params = params
6
+ end
7
+
5
8
  def render_script
6
9
  <<-JAVASCRIPT
7
- <script type="text/javascript">window.$_Tawk = undefined; var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();(function(){var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];s1.async=true;s1.src='https://embed.tawk.to/#{TawkRails.configuration.id_site}/default';s1.charset='UTF-8';s1.setAttribute('crossorigin','*');s0.parentNode.insertBefore(s1,s0);})();</script>
10
+ <script type="text/javascript">window.$_Tawk = undefined; var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();#{@params}(function(){var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];s1.async=true;s1.src='https://embed.tawk.to/#{TawkRails.configuration.id_site}/default';s1.charset='UTF-8';s1.setAttribute('crossorigin','*');s0.parentNode.insertBefore(s1,s0);})();</script>
8
11
  JAVASCRIPT
9
12
  end
10
13
  end
@@ -1,17 +1,12 @@
1
1
  # coding: utf-8
2
-
3
2
  require 'active_support/core_ext/string/output_safety'
4
3
  require 'active_support/core_ext/object/blank'
5
4
 
6
5
  module TawkRails::Rails
7
-
8
6
  module ViewHelpers
9
-
10
- def tawk_init
11
-
12
- queue = TawkRails::Chatbox.new
7
+ def tawk_init(params = nil)
8
+ queue = TawkRails::Chatbox.new(params)
13
9
  queue.render_script.html_safe
14
-
15
10
  end
16
11
  end
17
12
  end
@@ -1,3 +1,3 @@
1
1
  module TawkRails
2
- VERSION = "1.0.2"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -9,10 +9,20 @@ describe TawkRails::Chatbox do
9
9
  end
10
10
  end
11
11
 
12
- let(:chatbox) { TawkRails::Chatbox.new() }
12
+ it "should return javascript correctly within params" do
13
+ chatbox = TawkRails::Chatbox.new()
14
+ expect(chatbox.render_script).to be_a_kind_of(String)
15
+ end
13
16
 
14
- it "should return javascript correctly" do
17
+ it "should return javascript correctly with params" do
18
+ params = "Tawk_API.onStatusChange = function(status){console.log(status);}; Tawk_API.visitor = {name : 'Name', email : 'email@email.com'};"
19
+ chatbox = TawkRails::Chatbox.new(params)
15
20
  expect(chatbox.render_script).to be_a_kind_of(String)
21
+ expect(chatbox.render_script).to include(params)
22
+ end
23
+
24
+ it "should return JS within version" do
25
+ chatbox = TawkRails::Chatbox.new()
16
26
  expect(chatbox.render_script).to include('replace-me-with-your-id_site')
17
27
  end
18
28
  end
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
  require_relative '../../lib/tawk_rails/configuration'
3
3
 
4
4
  describe TawkRails::Configuration do
5
-
6
5
  before do
7
6
  TawkRails.configure do |config|
8
7
  config.id_site = 'replace-me-with-your-id_site'
@@ -16,7 +15,6 @@ describe TawkRails::Configuration do
16
15
 
17
16
  it "should return version correctly" do
18
17
  expect(TawkRails.configuration.version).to be_a_kind_of(String)
19
- expect(TawkRails.configuration.version).to eq '0.0.2'
18
+ expect(TawkRails.configuration.version).to eq '1.2.0'
20
19
  end
21
-
22
20
  end
@@ -5,6 +5,6 @@ describe TawkRails do
5
5
 
6
6
  it "should return version correctly" do
7
7
  expect(TawkRails::VERSION).to be_a_kind_of(String)
8
- expect(TawkRails::VERSION).to eq '0.0.2'
8
+ expect(TawkRails::VERSION).to eq '1.2.0'
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tawk_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luiz Picolo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-08 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
+ - ".travis.yml"
64
65
  - Gemfile
65
66
  - LICENSE.txt
66
67
  - README.md