Module: ActiveForm::Mixins::CssMethods
- Defined in:
- lib/active_form/mixins/css_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
- #css_class ⇒ Object
- #css_class=(string_or_array) ⇒ Object (also: #class=)
- #css_style ⇒ Object
- #css_style=(string_or_array) ⇒ Object (also: #style=)
- #default_css_class ⇒ Object
- #default_css_style ⇒ Object
- #element_class ⇒ Object (also: #css)
- #element_style ⇒ Object (also: #style)
- #label_css ⇒ Object
- #label_css_class ⇒ Object
- #runtime_css_class ⇒ Object
- #runtime_css_style ⇒ Object
Instance Method Details
#css_class ⇒ Object
38 39 40 |
# File 'lib/active_form/mixins/css_methods.rb', line 38 def css_class @css_class_attribute ||= CssAttribute.new.push(default_css_class) end |
#css_class=(string_or_array) ⇒ Object Also known as: class=
42 43 44 |
# File 'lib/active_form/mixins/css_methods.rb', line 42 def css_class=(string_or_array) css_class.replace(string_or_array) end |
#css_style ⇒ Object
61 62 63 |
# File 'lib/active_form/mixins/css_methods.rb', line 61 def css_style @css_style_attribute ||= StyleAttribute.new.push(default_css_style) end |
#css_style=(string_or_array) ⇒ Object Also known as: style=
65 66 67 |
# File 'lib/active_form/mixins/css_methods.rb', line 65 def css_style=(string_or_array) css_style.replace(string_or_array) end |
#default_css_class ⇒ Object
3 4 5 |
# File 'lib/active_form/mixins/css_methods.rb', line 3 def default_css_class "active_#{element_type}" end |
#default_css_style ⇒ Object
47 48 49 |
# File 'lib/active_form/mixins/css_methods.rb', line 47 def default_css_style "" end |
#element_class ⇒ Object Also known as: css
33 34 35 |
# File 'lib/active_form/mixins/css_methods.rb', line 33 def element_class (css_class.dup << runtime_css_class << default_css_class).to_s end |
#element_style ⇒ Object Also known as: style
56 57 58 |
# File 'lib/active_form/mixins/css_methods.rb', line 56 def element_style (css_style.dup << runtime_css_style).to_s end |
#label_css ⇒ Object
29 30 31 |
# File 'lib/active_form/mixins/css_methods.rb', line 29 def label_css label_css_class.to_s end |
#label_css_class ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/active_form/mixins/css_methods.rb', line 19 def label_css_class cclass = CssAttribute.new cclass << 'inactive' if readonly? || disabled? || frozen? cclass << 'hidden' if hidden? cclass << 'required' if required? cclass << 'validation-failed' unless valid? cclass << 'label' if container? cclass end |
#runtime_css_class ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/active_form/mixins/css_methods.rb', line 7 def runtime_css_class cclass = CssAttribute.new cclass << 'frozen' if frozen? cclass << 'hidden' if hidden? cclass << 'disabled' if disabled? cclass << 'readonly' if readonly? cclass << 'required' if required? cclass << 'validation-failed' unless valid? cclass << validation_css_class if !container? && client_side? cclass end |
#runtime_css_style ⇒ Object
51 52 53 54 |
# File 'lib/active_form/mixins/css_methods.rb', line 51 def runtime_css_style cstyle = StyleAttribute.new cstyle << 'display: none' if hidden? end |