Module: Qe::ApplicationHelper

Defined in:
app/helpers/qe/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#calendar_date_select_tag(name, value = nil, options = {}) ⇒ Object



35
36
37
38
# File 'app/helpers/qe/application_helper.rb', line 35

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

#flat_hash_key(names) ⇒ Object



25
26
27
28
29
30
31
32
# File 'app/helpers/qe/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/qe/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/qe/application_helper.rb', line 4

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

#spinner(extra = nil) ⇒ Object



44
45
46
47
# File 'app/helpers/qe/application_helper.rb', line 44

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

#tip(t) ⇒ Object



40
41
42
# File 'app/helpers/qe/application_helper.rb', line 40

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