Sha256: 1e2a4eaf6fbf897c3d899e3e5a62a607b54cd9d7cd4597f793d6e286736008d8

Contents?: true

Size: 953 Bytes

Versions: 28

Compression:

Stored size: 953 Bytes

Contents

module WithHelpIcon
  def label(wrapper_options = nil)
    "#{super} #{link_to_help}"
  end

  protected

    def link_to_help
      template.link_to '#', id: "#{input_class}_help",
                            data: { toggle: 'popover'.freeze,
                                    content: metadata_help,
                                    'original-title' => raw_label_text },
                            'aria-label' => aria_label do
        help_icon
      end
    end

    def help_icon
      template.content_tag 'i', nil, 'aria-hidden' => true, class: "help-icon"
    end

    def metadata_help
      translate_from_namespace(:metadata_help) || attribute_name.to_s.humanize
    end

    def aria_label
      translate_from_namespace(:aria_label) || default_aria_label
    end

    def default_aria_label
      I18n.t("#{i18n_scope}.aria_label.#{lookup_model_names.join('.')}.default",
             title: attribute_name.to_s.humanize)
    end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
curation_concerns-1.0.0.beta4 app/inputs/with_help_icon.rb
curation_concerns-1.0.0.beta3 app/inputs/with_help_icon.rb
curation_concerns-1.0.0.beta2 app/inputs/with_help_icon.rb
curation_concerns-1.0.0.beta1 app/inputs/with_help_icon.rb
curation_concerns-0.14.0 app/inputs/with_help_icon.rb
curation_concerns-0.14.0.pre4 app/inputs/with_help_icon.rb
curation_concerns-0.14.0.pre3 app/inputs/with_help_icon.rb
curation_concerns-0.14.0.pre2 app/inputs/with_help_icon.rb
curation_concerns-0.14.0.pre1 app/inputs/with_help_icon.rb
curation_concerns-0.13.1 app/inputs/with_help_icon.rb
curation_concerns-0.13.0 app/inputs/with_help_icon.rb
curation_concerns-0.12.0 app/inputs/with_help_icon.rb
curation_concerns-0.12.0.pre9 app/inputs/with_help_icon.rb
curation_concerns-0.12.0.pre8 app/inputs/with_help_icon.rb
curation_concerns-0.12.0.pre7 app/inputs/with_help_icon.rb
curation_concerns-0.12.0.pre6 app/inputs/with_help_icon.rb
curation_concerns-0.12.0.pre5 app/inputs/with_help_icon.rb
curation_concerns-0.12.0.pre4 app/inputs/with_help_icon.rb
curation_concerns-0.12.0.pre3 app/inputs/with_help_icon.rb
curation_concerns-0.12.0.pre2 app/inputs/with_help_icon.rb