Sha256: e8b8035cc6138e8e10273975953b09816e5854d5e71d1079191419fbe4f35d72

Contents?: true

Size: 858 Bytes

Versions: 7

Compression:

Stored size: 858 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", rel: 'popover'.freeze,
              :'data-content' => metadata_help, :'data-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

7 entries across 7 versions & 1 rubygems

Version Path
sufia-6.2.0 app/inputs/with_help_icon.rb
sufia-6.1.0 app/inputs/with_help_icon.rb
sufia-6.0.0 app/inputs/with_help_icon.rb
sufia-6.0.0.rc4 app/inputs/with_help_icon.rb
sufia-6.0.0.rc3 app/inputs/with_help_icon.rb
sufia-6.0.0.rc2 app/inputs/with_help_icon.rb
sufia-6.0.0.rc1 app/inputs/with_help_icon.rb