Class: Formtastic::Inputs::BlazeToggleInput

Inherits:
BooleanInput
  • Object
show all
Includes:
Base
Defined in:
lib/formtastic/inputs/blaze_toggle_input.rb

Instance Method Summary collapse

Instance Method Details

#label_html_optionsObject



40
41
42
43
# File 'lib/formtastic/inputs/blaze_toggle_input.rb', line 40

def label_html_options
  classes = input_html_options[:simple_checkbox] ? [] : ['c-toggle', input_html_options[:toggle_class]]
  super.merge(for: input_html_options[:id], class: classes - ['label'])
end

#label_with_embedded_checkboxObject



45
46
47
# File 'lib/formtastic/inputs/blaze_toggle_input.rb', line 45

def label_with_embedded_checkbox
  check_box_html << "" << (input_html_options[:simple_checkbox] ? '' : toggle_html)  # << label_text
end

#to_htmlObject

def to_html

input_wrapping do
  # hidden_field_html <<
  label_html <<
  builder.check_box( method, input_html_options )
  # label_with_nested_checkbox
end

end



17
18
19
20
21
22
23
# File 'lib/formtastic/inputs/blaze_toggle_input.rb', line 17

def to_html
  input_wrapping do
    toggle_label <<
      hidden_field_html <<
      toggle_checkbox
  end
end

#toggle_checkboxObject



32
33
34
35
36
37
38
# File 'lib/formtastic/inputs/blaze_toggle_input.rb', line 32

def toggle_checkbox
  builder.label(
    method,
    label_with_embedded_checkbox,
    label_html_options
  )
end

#toggle_htmlObject



49
50
51
52
53
54
55
# File 'lib/formtastic/inputs/blaze_toggle_input.rb', line 49

def toggle_html
  template.(
    :div,
    template.(:div, '', class: 'c-toggle__handle'),
    class: 'c-toggle__track'
  )
end

#toggle_labelObject



25
26
27
28
29
30
# File 'lib/formtastic/inputs/blaze_toggle_input.rb', line 25

def toggle_label
  builder.label(
    method,
    label_text
  )
end