Module: Spurs::Modal::ControllerMods

Extended by:
ActiveSupport::Concern
Defined in:
lib/spurs/modal/controller_mods.rb

Instance Method Summary collapse

Instance Method Details

#spawn_close_modal(title, file, options = { }) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/spurs/modal/controller_mods.rb', line 18

def spawn_close_modal(title, file, options={ })
  opts = {
      :actions => [
          { :name => :cancel, :position => :left, :action => :close_modal, :class => "btn-large" }
      ]
  }.merge(options)
  spawn_modal(title, file, nil, opts)
end

#spawn_form_modal(title, partial, object, options = { }) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/spurs/modal/controller_mods.rb', line 6

def spawn_form_modal(title, partial, object, options={ })
  opts = {
      :actions => [
          { :name => :cancel, :position => :left, :action => :close_modal, :class => "btn-large" },
          { :name => :save, :position => :right, :action => :submit_form_and_close_modal, :class => "btn-primary btn-large" },
      ]
  }.merge(options)
  spawn_modal(title, partial, object, opts)
end

#spawn_modal(title, partial, object, options = { }) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/spurs/modal/controller_mods.rb', line 29

def spawn_modal(title, partial, object, options={ })

  opts = {
      :header => {
          :title => title.titlecase,
          :icon  => options[:title_icon] ? options.delete(:title_icon) : nil
      },

  }.merge(options)

  render :file => "spurs/modals/spawn", :locals => {  :modal_file_or_partial => partial,
                                                      :modal_object          => object,
                                                      :modal_options         => opts }
end