Module: Golden::Theme::Foundation::CommonHelper

Defined in:
lib/golden/theme/foundation/common_helper.rb

Instance Method Summary collapse

Instance Method Details

#foundation_callback_button(callback_id, options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/golden/theme/foundation/common_helper.rb', line 56

def foundation_callback_button callback_id, options = {}
  options = {
    data: {
      callback_id: callback_id
    },
    class: 'callback hide'
  }.deep_merge options
  link_to nil, '', options
end

#foundation_dl_tag(dt = [], dd = [], options = {}) {|dt, dd| ... } ⇒ Object

Yields:

  • (dt, dd)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/golden/theme/foundation/common_helper.rb', line 29

def foundation_dl_tag dt = [], dd = [], options = {}
  options, dt, dd = dt, [], [] if dt.is_a? Hash or dd.is_a? Hash
  yield dt, dd if block_given?
  items = ''.html_safe
  items << dt if dt.present?
  dd.each_with_index do |item, index|
    if item.is_a? Array
      item_options = item.pop
      item_content = item.join('').html_safe
    else
      item_options = {}
      item_content = item
    end

    item_class = []
    item_class << 'first' if index == 0
    item_class << 'last' if index == (dd.length - 1)
    link = item_content.match(/href=(["'])(.*?)(\1)/)[2] rescue nil
    item_class << 'active' if link and (current_page?(link) rescue false)
    item_class << item_options.delete(:class) if item_options[:class]

    dd_class = item_class.empty? ? nil : item_class.join(' ')
    items << (:dd, item_content, item_options.merge(class: dd_class) )
  end
   :dl, items, options
end

#foundation_ul_tag(li = [], options = {}) {|li| ... } ⇒ Object

Yields:

  • (li)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/golden/theme/foundation/common_helper.rb', line 3

def foundation_ul_tag li = [], options = {}
  options, li = li, [] if li.is_a? Hash
  yield li if block_given?
  items = ''.html_safe
  li.each_with_index do |item, index|
    if item.is_a? Array
      item_options = item.pop
      item_content = item.join('').html_safe
    else
      item_options = {}
      item_content = item
    end

    item_class = []
    item_class << 'first' if index == 0
    item_class << 'last' if index == (li.length - 1)
    link = item_content.match(/href=(["'])(.*?)(\1)/)[2] rescue nil
    item_class << 'current active' if link and (current_page?(link) rescue false)
    item_class << item_options.delete(:class) if item_options[:class]

    li_class = item_class.empty? ? nil : item_class.join(' ')
    items << (:li, item_content, item_options.merge(class: li_class) )
  end
   :ul, items, options
end