class UiBibz::Ui::Core::Forms::Numbers::RangeField
Create a RangeField
This element is an extend of UiBibz::Ui::Core::Component
.
Attributes¶ ↑
-
content
- Content of element -
options
- Options of element -
html_options
- Html Options of element
Options¶ ↑
You can add HTML attributes using the html_options
. You can pass arguments in options attribute:
-
max
- [Float, Integer] -
min
- [Float, Integer] -
step
- [Float, Integer] -
in
- Array -
within
- Array -
status
- status of element with symbol value: (:primary
,:secondary
,:success
, :info+,:warning
,:danger
,:light
,:dark
) -
thumb_status
- status of the thumb: (:primary
,:secondary
,:success
, :info+,:warning
,:danger
,:light
,:dark
) -
track_status
- status of track: (:primary
,:secondary
,:success
, :info+,:warning
,:danger
,:light
,:dark
)
Signatures¶ ↑
UiBibz::Ui::Core::Forms::Numbers::RangeField.new(content, options = {}, html_options = {}).render UiBibz::Ui::Core::Forms::Numbers::RangeField.new(options = {}, html_options = {}) do content end.render
Examples¶ ↑
UiBibz::Ui::Core::Forms::Numbers::RangeField.new(4, max: 20, min: 0, step: 2) UiBibz::Ui::Core::Forms::Numbers::RangeField.new(max: 2, min: -3, step: 0.5) do 5 end
Helper¶ ↑
ui_range_field(content, options = {}, html_options = {}) ui_range_field(options = {}, html_options = {}) do # content end
Public Instance Methods
html_id()
click to toggle source
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 65 def html_id @html_id ||= html_options[:id] || generate_id('range') end
pre_render()
click to toggle source
Render html tag
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 58 def pre_render capture do concat range_field_tag(content, options[:value] || html_options[:value], html_options) concat datalist_tag if options[:tick] end end
Private Instance Methods
component_html_classes()
click to toggle source
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 83 def component_html_classes ['form-range', status, thumb_status, track_status] end
component_html_options()
click to toggle source
Calls superclass method
UiBibz::Ui::Core::Forms::Numbers::NumberField#component_html_options
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 79 def component_html_options options[:tick] ? super.merge(list: datalist_id) : super end
datalist_id()
click to toggle source
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 107 def datalist_id "#{html_id}-list" end
datalist_tag()
click to toggle source
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 71 def datalist_tag content_tag :datalist, id: datalist_id do (html_min..html_max).step(html_step).map do |i| content_tag :option, option_label(i), value: i, label: option_label(i) end.join.html_safe end end
middle_range_value()
click to toggle source
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 103 def middle_range_value (html_min..html_max).to_a[(html_min..html_max).size / 2] end
option_label(value)
click to toggle source
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 99 def option_label(value) value if [html_min, middle_range_value, html_max].include?(value) end
status()
click to toggle source
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 87 def status "form-range-#{options[:status]}" if options[:status] end
thumb_status()
click to toggle source
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 91 def thumb_status "form-range-thumb-#{options[:thumb_status]}" if options[:thumb_status] end
track_status()
click to toggle source
# File lib/ui_bibz/ui/core/forms/numbers/range_field.rb, line 95 def track_status "form-range-track-#{options[:track_status]}" if options[:track_status] end