Module: FormHelper
- Defined in:
- app/helpers/form_helper.rb
Instance Method Summary collapse
- #form_asset_selected(asset) ⇒ Object
- #html_options(type) ⇒ Object
- #select_tree(field_id, data, field_options, value = nil) ⇒ Object
- #show_tree(data) ⇒ Object
- #text_captcha_entry ⇒ Object
- #text_captcha_qa ⇒ Object
Instance Method Details
#form_asset_selected(asset) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/form_helper.rb', line 3 def form_asset_selected(asset) if @form && @form.id!=nil @form.html_assets.include?(asset) else false end end |
#html_options(type) ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'app/helpers/form_helper.rb', line 91 def (type) hash = {} type..split('|').each do |ss| name,value = ss.split('=') hash[name] = value end return hash end |
#select_tree(field_id, data, field_options, value = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/helpers/form_helper.rb', line 49 def select_tree(field_id, data, , value = nil) # sample: Test1\BlahA\BlahB\BlahC|Test2\BloopA\BloopB # value: if present, of the form x:y return "no values" unless data a = data.split("|") = [] parent_value = nil child_value = nil parent_value, child_value = value.split(':') if value op = '<script type="text/javascript">' op += "var data_#{field_id} = {" a.each do |parent| first = true parent.split('~').each do |v| v.strip! if first op += " '#{v}' : [" << v first = false else op += '"' + v + '",' end end op += '],' end op += "};" op += "$(document).ready(function() {" op += "$('##{field_id}_parent').bind('change', function() {" op += "select_change_parent('#{field_id}_parent', '#{field_id}', data_#{field_id}, \"#{child_value}\");" op += "});" op += "select_change_parent('#{field_id}_parent', '#{field_id}', data_#{field_id}, \"#{child_value}\");" op += "});" op += "</script>"; op += select_tag("#{field_id}_parent", (, parent_value), ) op += select_tag(field_id, "", {:style=>"margin-left: 20px;"}) return op.html_safe end |
#show_tree(data) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/form_helper.rb', line 26 def show_tree(data) a = data.split("|") = [] op = "<table class='loosen'>" a.each do |aa| first = true bb = aa.split('~') op += "<tr><td valign='top'>#{bb[0]} →</td><td>" for i in 1..bb.length-1 op += bb[i] op += "<br/>" end op += "</td></tr>" end op += "</table>" op.html_safe end |
#text_captcha_entry ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/helpers/form_helper.rb', line 12 def text_captcha_entry question, answers = Form.captcha_question(500) "<div class='q_a'> <input type='hidden' name='q_q' value='#{answers}'/> <label>#{question}</label> <input type='text' name='q_a' value='' class='captcha'> </div>".html_safe end |
#text_captcha_qa ⇒ Object
22 23 24 |
# File 'app/helpers/form_helper.rb', line 22 def text_captcha_qa return Form.captcha_question(500) end |