Module: Exvo::ViewHelpers

Defined in:
lib/exvo_helpers/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#bugherd(apikey) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/exvo_helpers/view_helpers.rb', line 106

def bugherd(apikey)
  out = <<END
<script type='text/javascript'>
(function (d, t) {
  var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];
  bh.type = 'text/javascript';
  bh.src = '//www.bugherd.com/sidebarv2.js?apikey=#{ apikey }';
  s.parentNode.insertBefore(bh, s);
  })(document, 'script');
</script>
END

  out.respond_to?(:html_safe) ? out.html_safe : out
end

#google_analytics(account, opts = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/exvo_helpers/view_helpers.rb', line 28

def google_analytics(, opts = {})
  domain = opts.delete(:domain)
  track_hash_changes = opts.delete(:track_hash_changes)

  out = <<END
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '#{}']);
END

  if domain
    out += <<END
  _gaq.push(['_setDomainName', '#{domain}']);
END
  end

  out += <<END
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  (function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
END

  if track_hash_changes
    out += <<END

  var current_location_hash = window.location.hash;
  var update_hash = function() {
if (current_location_hash != window.location.hash) {
  current_location_hash = window.location.hash;
  _gaq.push(['_trackPageview', current_location_hash]);
}
  }
  setInterval(update_hash, 500);
END
  end

  out += <<END
</script>
END

  out.respond_to?(:html_safe) ? out.html_safe : out
end

#javascript_bundle_include_tag(bundle) ⇒ Object

Returns ‘javascript_include_tag` with link to js bundles (based on env)



6
7
8
9
10
11
12
13
# File 'lib/exvo_helpers/view_helpers.rb', line 6

def javascript_bundle_include_tag(bundle)
  case Exvo::Helpers.env.to_sym
  when :production, :staging
    javascript_include_tag "#{Exvo::Helpers.cdn_uri}/javascripts/#{bundle}.js"
  else
    javascript_include_tag "#{Exvo::Helpers.cdn_uri}/javascripts/bundles/#{bundle}.js"
  end
end

#kissmetricsObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/exvo_helpers/view_helpers.rb', line 76

def kissmetrics
  out = <<END
<script type="text/javascript">
  var _kmq = _kmq || [];
  function _kms(u) {
setTimeout(function() {
  var s = document.createElement('script');
  var f = document.getElementsByTagName('script')[0];
  s.type = 'text/javascript';
  s.async = true;
  s.src = u;
  f.parentNode.insertBefore(s, f);
}, 1);
  }
  _kms('//i.kissmetrics.com/i.js');
  _kms('//doug1izaerwt3.cloudfront.net/#{ENV['KISSMETRICS_KEY']}.1.js');
END
  if current_user && current_user.email
    out += <<END
  _kmq.push(['identify', '#{current_user.email}']);
END
  end

  out += <<END
</script>
END

  out.respond_to?(:html_safe) ? out.html_safe : out
end

#themes_image_tag(path, options = {}) ⇒ Object

Returns ‘image_tag` with link to image on themes (based on env)



23
24
25
26
# File 'lib/exvo_helpers/view_helpers.rb', line 23

def themes_image_tag(path, options = {})
  path = '/' + path unless path.start_with?('/')
  image_tag(Exvo::Helpers.themes_uri + '/stylesheets/images' + path, options)
end

Returns ‘stylesheet_link_tag` with link to css on themes (based on env)



16
17
18
19
20
# File 'lib/exvo_helpers/view_helpers.rb', line 16

def themes_stylesheet_link_tag(path, options = {})
  path = '/' + path unless path.start_with?('/')
  path = path + '.css' unless path.end_with?('.css')
  stylesheet_link_tag(Exvo::Helpers.themes_uri + '/stylesheets/themes' + path, options)
end

#zendeskObject



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/exvo_helpers/view_helpers.rb', line 121

def zendesk
  out = <<END
<script type="text/javascript" src="//assets.zendesk.com/external/zenbox/v2.6/zenbox.js"></script>

<style type="text/css" media="screen, projection">
@import url(//assets.zendesk.com/external/zenbox/v2.6/zenbox.css);
</style>

<script type="text/javascript">
if (typeof(Zenbox) !== "undefined") {
  Zenbox.init({
dropboxID:   "20187392",
url:         "https://exvocom.zendesk.com",
tabTooltip:  "Support",
tabImageURL: "https://assets.zendesk.com/external/zenbox/images/tab_support.png",
tabColor:    "black",
tabPosition: "Right",
hide_tab:    "true"
  });
}
</script>
END

  out.respond_to?(:html_safe) ? out.html_safe : out
end