Module: Georgia::UiHelper
- Defined in:
- app/helpers/georgia/ui_helper.rb
Instance Method Summary collapse
- #avatar_url(email, options = {}) ⇒ Object
- #caret_tag ⇒ Object
- #icon_tag(icon_name, options = {}) ⇒ Object
- #link_to_back(url = :back) ⇒ Object
- #link_to_delete(url, options = {}) ⇒ Object
- #picture_tag(picture, options = {}) ⇒ Object
- #spinner_tag(options = {}) ⇒ Object
- #tooltip_tag(icon, tooltip, options = {}) ⇒ Object
- #welcomed? ⇒ Boolean
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, ={}) gravatar_id = Digest::MD5.hexdigest(email.try(:downcase)) size = .fetch(:size, '32') "http://gravatar.com/avatar/#{gravatar_id}.png?s=#{size}&d=mm" end |
#caret_tag ⇒ Object
16 17 18 |
# File 'app/helpers/georgia/ui_helper.rb', line 16 def caret_tag content_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, ={} [:class] ||= '' [:class] << "fa fa-#{icon_name}" content_tag :i, nil, end |
#link_to_back(url = :back) ⇒ Object
33 34 35 |
# File 'app/helpers/georgia/ui_helper.rb', line 33 def link_to_back url=:back link_to icon_tag('level-up fa-rotate-270'), url, class: 'btn btn-back' end |
#link_to_delete(url, options = {}) ⇒ Object
37 38 39 40 |
# File 'app/helpers/georgia/ui_helper.rb', line 37 def link_to_delete url, ={} text = .delete(:text) { "#{icon_tag('trash-o')} Delete".html_safe } link_to text, url, .reverse_merge(data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger') end |
#picture_tag(picture, options = {}) ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/helpers/georgia/ui_helper.rb', line 25 def picture_tag picture, ={} return unless picture and picture.url.present? format = .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 |
#spinner_tag(options = {}) ⇒ Object
20 21 22 23 |
# File 'app/helpers/georgia/ui_helper.rb', line 20 def spinner_tag ={} [:class] = .fetch(:class, 'spinner') content_tag :div, icon_tag('spinner fa-spin fa-4x'), end |
#tooltip_tag(icon, tooltip, options = {}) ⇒ Object
42 43 44 |
# File 'app/helpers/georgia/ui_helper.rb', line 42 def tooltip_tag icon, tooltip, ={} content_tag(:span, icon, .reverse_merge(title: tooltip, class: 'js-tooltip', data: {placement: 'right'})) end |
#welcomed? ⇒ Boolean
46 47 48 |
# File 'app/helpers/georgia/ui_helper.rb', line 46 def welcomed? session[:welcomed] || !(session[:welcomed] = true) end |