Class: Jirafe::Dashboard

Inherits:
Object
  • Object
show all
Defined in:
lib/jirafe/dashboard.rb

Class Method Summary collapse

Class Method Details

.css_url(platform) ⇒ Object



9
10
11
# File 'lib/jirafe/dashboard.rb', line 9

def css_url(platform)
  Jirafe::Asset.css_url_for(:dashboard, platform)
end

.default_error_htmlObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/jirafe/dashboard.rb', line 37

def default_error_html
  <<-HTML
  <ul class="messages">
    <li class="error-msg">
      We're unable to connect with the Jirafe service for the moment.
      Please wait a few minutes and refresh this page later.
    </li>
  </ul>
  HTML
end

.js_tag(api_token, app_id, version, locale, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jirafe/dashboard.rb', line 13

def js_tag(api_token, app_id, version, locale, options = {})
  target_id = options[:target_id] || "jirafe"
  error_id = options[:error_id] || "messages"
  error_html = options[:error_html] || default_error_html
  error_html = error_html.gsub(/"/, "\\\"").split("\n").join("")
  timeout = options[:timeout] || 10000

  <<-HTML
<script type='text/javascript' defer='defer'>
  jirafe.jQuery('##{target_id}').jirafe({
    api_url: '#{Jirafe.config.url}',
    api_token: '#{api_token}',
    app_id: '#{app_id}',
    version: '#{version}',
    locale: '#{locale}' });
  setTimeout(function() {
    if ($('mod-jirafe') == undefined) {
$('#{error_id}').insert ("#{error_html}");
    }
  }, #{timeout});
</script>
  HTML
end

.js_url(platform) ⇒ Object



5
6
7
# File 'lib/jirafe/dashboard.rb', line 5

def js_url(platform)
  Jirafe::Asset.js_url_for(:dashboard, platform)
end