Module: Fe::ApplicationHelper
Instance Method Summary
collapse
#li_page_active_if, #load_page_js
Instance Method Details
#calendar_date_select_tag(name, value = nil, options = {}) ⇒ Object
34
35
36
37
|
# File 'app/helpers/fe/application_helper.rb', line 34
def calendar_date_select_tag(name, value = nil, options = {})
options.merge!({'data-calendar' => true})
text_field_tag(name, value, options )
end
|
#error_messages_for(model) ⇒ Object
58
59
60
61
|
# File 'app/helpers/fe/application_helper.rb', line 58
def error_messages_for(model)
record = instance_variable_get(:"@#{(model.is_a?(ActiveRecord::Base) ? model.class : model).to_s.underscore}")
render "layouts/fe/error_messages_for", record: record
end
|
#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
|
#link_to_function(name, *args, &block) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'app/helpers/fe/application_helper.rb', line 48
def link_to_function(name, *args, &block)
html_options = args..symbolize_keys
function = block_given? ? update_page(&block) : args[0] || ''
onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function}; return false;"
href = html_options[:href] || '#'
content_tag(:a, name, html_options.merge(href: href, onclick: onclick))
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( = nil)
e = ? "spinner_#{}" : 'spinner'
image_tag('fe/spinner.gif', id: e, style: 'display:none', class: 'spinner')
end
|
#tip(t) ⇒ Object
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
|