Module: Fe::ApplicationHelper

Includes:
AnswerPagesHelper
Defined in:
app/helpers/fe/application_helper.rb

Instance Method Summary collapse

Methods included from AnswerPagesHelper

#li_page_active_if, #load_page_js

Instance Method Details

#flat_hash_key(names) ⇒ Object



25
26
27
28
29
30
31
32
# File 'app/helpers/fe/application_helper.rb', line 25

def flat_hash_key(names)
  names = Array.new(names)
  name = names.shift.to_s.dup
  names.each do |n|
    name << "[#{n}]"
  end
  name
end

#flatten_hash(hash = params, ancestor_names = []) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/fe/application_helper.rb', line 8

def flatten_hash(hash = params, ancestor_names = [])
  flat_hash = {}
  hash.each do |k, v|
    names = Array.new(ancestor_names)
    names << k
    if v.is_a?(Hash)
      flat_hash.merge!(flatten_hash(v, names))
    else
      key = flat_hash_key(names)
      key += "[]" if v.is_a?(Array)
      flat_hash[key] = v
    end
  end

  flat_hash
end

#pretty_tag(txt) ⇒ Object



4
5
6
# File 'app/helpers/fe/application_helper.rb', line 4

def pretty_tag(txt)
  txt.to_s.gsub(/\s/, "_").gsub(/(?!-)\W/, "").downcase
end

#spinner(extra = nil) ⇒ Object



43
44
45
46
# File 'app/helpers/fe/application_helper.rb', line 43

def spinner(extra = nil)
  e = extra ? "spinner_#{extra}" : 'spinner'
  image_tag('spinner.gif', :id => e, :style => 'display:none', :class => 'spinner')
end

#tip(t) ⇒ Object

def calendar_date_select_tag(name, value = nil, options = {})

options.merge!({'data-calendar' => true})
text_field_tag(name, value, options )

end



39
40
41
# File 'app/helpers/fe/application_helper.rb', line 39

def tip(t)
  image_tag('fe/icons/question-balloon.png', :title => t, :class => 'tip')
end