Sha256: 59ed2344107e044be6aaa88c2108dd8655109acbfede38b4b56b6864ee5a2af9

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

module Sufia
  module RecordsHelperBehavior

    def help_icon(key, content = nil, title = nil)
      content = content || metadata_help(key)
      title = title || get_label(key)
      link_to '#', id: "generic_file_#{key.to_s}_help", rel: 'popover',
              'data-content' => content,
              'data-original-title' => title,
              'aria-label' => get_aria_label(key) do
        content_tag 'i', '', "aria-hidden" => true, class: "help-icon"
      end
    end

    def help_icon_modal(modal_id)
      link_to '#' + modal_id, id: "generic_file_#{modal_id}_help_modal", rel: 'button', 
              data: { toggle: 'modal' }, 'aria-label' => get_aria_label(modal_id) do
        content_tag 'i', '', "aria-hidden" => true, class: 'help-icon'
      end
    end

    def metadata_help(key)
      I18n.t("sufia.metadata_help.#{key}", default: key.to_s.humanize)
    end

    def get_label(key)
      I18n.t("sufia.field_label.#{key}", default: key.to_s.humanize)
    end

    def get_aria_label(key)
      I18n.t("sufia.aria_label.#{key}", default: default_aria_label(key.to_s.humanize))
    end
  
    private

    def sr_hidden icon
      content_tag "span", "aria-hidden" => true do 
        content_tag "i", "", class: "glyphicon glyphicon-#{icon}" 
      end
    end

    def sr_only text
      content_tag "span", class: "sr-only" do 
        "add another #{text}"
      end
    end

    def default_aria_label text
      I18n.t("sufia.aria_label.default", title: text)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sufia-5.0.0 app/helpers/sufia/records_helper_behavior.rb
sufia-5.0.0.rc1 app/helpers/sufia/records_helper_behavior.rb