Class: PasswordWithHintsInput
- Inherits:
-
SimpleForm::Inputs::Base
- Object
- SimpleForm::Inputs::Base
- PasswordWithHintsInput
- Defined in:
- lib/simple_form_password_with_hints/password_with_hints_input.rb
Instance Method Summary collapse
- #controls ⇒ Object
- #input(wrapper_options = nil) ⇒ Object
- #length_div ⇒ Object
- #lowercase_div ⇒ Object
- #numeric_div ⇒ Object
- #password_uncloaking_div ⇒ Object
- #special_char_div ⇒ Object
- #uppercase_div ⇒ Object
Instance Method Details
#controls ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/simple_form_password_with_hints/password_with_hints_input.rb', line 17 def controls template.content_tag(:div, '', class: 'sfpwh-controls js-sfpwh-controls') do [ length_div, uppercase_div, lowercase_div, numeric_div, special_char_div, ].compact.join.html_safe end end |
#input(wrapper_options = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/simple_form_password_with_hints/password_with_hints_input.rb', line 4 def input( = nil) = (, ) [:class] << " js-sfpwh-input js-sfpwh-hints-input " input_wrapper_class = 'sfpwh-input-div' input_wrapper_class += ' sfpwh-input-div-invalid' if has_errors? ( template.content_tag(:div, '', class: input_wrapper_class) do [ @builder.password_field(attribute_name, ), password_uncloaking_div ].compact.join.html_safe end ) + controls end |
#length_div ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/simple_form_password_with_hints/password_with_hints_input.rb', line 37 def length_div template.content_tag( :span, t('simple_form_password_with_hints.test_chars', min_length: [:validators][:length]), data: { length: [:validators][:length] }, class: 'sfpwh-hint sfpwh-hint--invalid sfpwh-hint--length js-sfpwh-hint-length' ) if should_display?(:length) end |
#lowercase_div ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/simple_form_password_with_hints/password_with_hints_input.rb', line 54 def lowercase_div template.content_tag( :span, t('simple_form_password_with_hints.test_lowercase'), class: 'sfpwh-hint sfpwh-hint--invalid sfpwh-hint--lowercase js-sfpwh-hint-lowercase' ) if should_display?(:lowercase_char) end |
#numeric_div ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/simple_form_password_with_hints/password_with_hints_input.rb', line 62 def numeric_div template.content_tag( :span, t('simple_form_password_with_hints.test_numeric'), class: 'sfpwh-hint sfpwh-hint--invalid sfpwh-hint--number js-sfpwh-hint-number' ) if should_display?(:numeric_char) end |
#password_uncloaking_div ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/simple_form_password_with_hints/password_with_hints_input.rb', line 29 def password_uncloaking_div template.content_tag( :span, '', class: 'sfpwh-password-toggle js-sfpwh-password-toggle' ) if [:allow_password_uncloaking] end |
#special_char_div ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/simple_form_password_with_hints/password_with_hints_input.rb', line 70 def special_char_div template.content_tag( :span, t('simple_form_password_with_hints.test_special_char'), data: { chars: [:validators][:special_char] }, class: 'sfpwh-hint sfpwh-hint--invalid sfpwh-hint--special js-sfpwh-hint-special' ) if should_display?(:special_char) end |
#uppercase_div ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/simple_form_password_with_hints/password_with_hints_input.rb', line 46 def uppercase_div template.content_tag( :span, t('simple_form_password_with_hints.test_uppercase'), class: 'sfpwh-hint sfpwh-hint--invalid sfpwh-hint--uppercase js-sfpwh-hint-uppercase' ) if should_display?(:uppercase_char) end |