Sha256: fe024d311f015b2bcbec015f2b8c1df6dbb9c1d3b9b660fe575c8c1941a092ff

Contents?: true

Size: 965 Bytes

Versions: 9

Compression:

Stored size: 965 Bytes

Contents

module GlyphExtension

  # Render glyph and content html
  def glyph_and_content_html content_html = nil
    [glyph_with_space, ct_html(content_html)].compact.join(' ').html_safe
  end

  def ct_html content_html
    if options[:text].nil? || options[:text] == true
      content_html || content
    end
  end

  # Render glyph with space html
  def glyph_with_space
    out = [glyph]
    out << " " if options[:text] != false
    out.join unless glyph.nil?
  end

  # Render glyph html
  def glyph
    if options.kind_of?(Hash)
      if options[:glyph].kind_of?(Hash)
        glyph_name = options[:glyph].try(:[], :name)
        glyph_opts = options[:glyph]
      else
        glyph_name = options[:glyph]
        glyph_opts = {}
      end
      glyph_html_opts = options[:text].nil? ? {} : (options[:text] ? {} : { title: content })
    end

    UiBibz::Ui::Core::Icons::Glyph.new(glyph_name, glyph_opts, glyph_html_opts).render unless glyph_name.nil?
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ui_bibz-2.1.0 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-2.0.8 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-2.0.7 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-2.0.5 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-2.0.4 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-2.0.3 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-2.0.2 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-2.0.1 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-2.0.0 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb