Module: Joyride::ActionViewExtensions

Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/joyride/action_view_extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_optionsObject



5
6
7
# File 'lib/joyride/action_view_extensions.rb', line 5

def self.default_options
  @@default_options ||= {animation: :pop}
end

Instance Method Details

#joyride(id, options, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/joyride/action_view_extensions.rb', line 9

def joyride(id, options,&block)
  if options[:html] == nil
    options[:html] = {}
  end
  opts    = Joyride::ActionViewExtensions::default_options.merge(options)
  opts_from_helper = {}
  if opts[:tip_class]
    opts_from_helper[:class] = opts[:tip_class]
  end
  builder = Joyride::TourBuilder.new(opts_from_helper)
  output  = capture(builder, &block)

  class_str = !options[:html] || !options[:html][:class] ? "_joyride_tour" : "#{options[:html].delete(:class)} _joyride_tour"

  mandatory_options = {:id => id, :class => class_str}
  ht_opts = options[:html] ? mandatory_options.merge(options[:html]) : mandatory_options

  use_cookie = options[:cookie] != nil && options[:cookie] == true
  if use_cookie
    ht_opts['data-cookie-enabled'] = true
  end
  ht_opts['data-animation'] = opts[:animation]
  if opts[:post_tour_callback]
    ht_opts['data-post-tour-callback'] = opts[:post_tour_callback]
  end
  if opts[:post_step_callback]
    ht_opts['data-post-step-callback'] = opts[:post_step_callback]
  end

  (:ol,output,ht_opts)
  #.concat(content_tag(:script,"$(window).load(function() { $(this).joyride({\'tipContent\': \'#{id}\', 'tipAnimation': \'#{opts[:animation]}\'}); });".html_safe,:type => "text/javascript"))
end