Sha256: beb03d8eb4286fc5432f9bc7d82f94816c70d61b95b85942ad5c4ac3ef2f7728

Contents?: true

Size: 1.59 KB

Versions: 7

Compression:

Stored size: 1.59 KB

Contents

module Georgia
  module UiHelper

    def avatar_url(email, options={})
      gravatar_id = Digest::MD5.hexdigest(email.try(:downcase))
      size = options.fetch(:size, '32')
      "http://gravatar.com/avatar/#{gravatar_id}.png?s=#{size}&d=mm"
    end

    def icon_tag icon_name, options={}
      options[:class] ||= ''
      options[:class] << "fa fa-#{icon_name}"
      content_tag :i, nil, options
    end

    def caret_tag
      content_tag :span, nil, class: 'caret'
    end

    def spinner_tag options={}
      options[:class] = options.fetch(:class, 'spinner')
      content_tag :div, icon_tag('spinner fa-spin fa-4x'), options
    end

    def picture_tag picture, options={}
      return unless picture and picture.url.present?
      format = options.fetch(:format, :tiny)
      link_to picture.url_content, class: 'media-link bg-transparent', rel: 'shadowbox[gallery]' do
        image_tag(picture.url(format), title: picture.data_file_name, class: 'media-image')
      end
    end

    def link_to_back url=:back
      link_to icon_tag('level-up fa-rotate-270'), url, class: 'btn btn-back'
    end

    def link_to_delete url, options={}
      text = options.delete(:text) { "#{icon_tag('trash-o')} Delete".html_safe }
      link_to text, url, options.reverse_merge(data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger')
    end

    def tooltip_tag icon, tooltip, options={}
      content_tag(:span, icon, options.reverse_merge(title: tooltip, class: 'js-tooltip', data: {placement: 'right'}))
    end

    def welcomed?
      session[:welcomed] || !(session[:welcomed] = true)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
georgia-0.7.6 app/helpers/georgia/ui_helper.rb
georgia-0.7.5 app/helpers/georgia/ui_helper.rb
georgia-0.7.4 app/helpers/georgia/ui_helper.rb
georgia-0.7.3 app/helpers/georgia/ui_helper.rb
georgia-0.7.2 app/helpers/georgia/ui_helper.rb
georgia-0.7.1 app/helpers/georgia/ui_helper.rb
georgia-0.7.0 app/helpers/georgia/ui_helper.rb