Module: Tungsten::TopologyGridHelper

Defined in:
app/helpers/tungsten/topology_grid_helper.rb

Instance Method Summary collapse

Instance Method Details

#topology_grid(name, components = 2, options = {}, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/tungsten/topology_grid_helper.rb', line 3

def topology_grid(name, components=2, options={}, &block)
  
  options[:class] = "topology-grid-wrapper #{options[:class]} #{ 'disabled' if options[:disabled] }".strip
  options[:'data-track-input-state'] = "##{name}-slider"
  disabled = options.delete(:disabled)
  
  label = block_given? ? capture(&block) : options.delete(:label)

  ( :div, options){
    concat ( :div, class: "topology-grid"){
      components.times do
        concat ( :div, class: "component") {}
      end
    }
    
    if options[:step_label]
      concat tag( :span, 'data-step-label': "#{options[:step_label]}", class: "topology-grid-label")
      options.delete(:step_label)
    elsif label
      concat ( :span, class: "topology-grid-label"){ label }
    end
  }

end