Module: Georgia::UiHelper

Defined in:
app/helpers/georgia/ui_helper.rb

Instance Method Summary collapse

Instance Method Details

#avatar_url(email, options = {}) ⇒ Object



4
5
6
7
8
# File 'app/helpers/georgia/ui_helper.rb', line 4

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

#caret_tagObject



16
17
18
# File 'app/helpers/georgia/ui_helper.rb', line 16

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

#icon_tag(icon_name, options = {}) ⇒ Object



10
11
12
13
14
# File 'app/helpers/georgia/ui_helper.rb', line 10

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


25
26
27
# File 'app/helpers/georgia/ui_helper.rb', line 25

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

Link to close modal box



35
36
37
# File 'app/helpers/georgia/ui_helper.rb', line 35

def link_to_close
   :button, icon_tag('times'), class: 'close', data: {dismiss: 'modal'}, aria: {hidden: true}, type: 'button'
end


29
30
31
32
# File 'app/helpers/georgia/ui_helper.rb', line 29

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

#spinner_tag(options = {}) ⇒ Object



20
21
22
23
# File 'app/helpers/georgia/ui_helper.rb', line 20

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

#tooltip_tag(icon, tooltip, options = {}) ⇒ Object



39
40
41
# File 'app/helpers/georgia/ui_helper.rb', line 39

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

#welcomed?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/helpers/georgia/ui_helper.rb', line 43

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