|
1 |
| -- renderer = question.renderer(question_group ||= nil) |
2 |
| -- case renderer |
3 |
| -- when :label |
4 |
| - - div_for question, :class => "label #{question.css_class(response_set)}" do |
5 |
| - %span.text= question.text |
6 |
| - %span.help= question.help_text |
7 |
| -- when :image |
8 |
| - .image= image_tag(question.text) |
9 |
| -- when :dropdown, :slider |
10 |
| - - if renderer == :slider |
11 |
| - %script{:type => "text/javascript"}= "$(function(){$('#slider_#{question.id}').accessibleUISlider({width: 400, labels:#{question.answers.size} }).hide();});" |
12 |
| - - div_for question, :class => question.css_class(response_set) do |
13 |
| - .number= next_number unless question.dependent? |
14 |
| - %fieldset |
15 |
| - %legend{:style => "display:inline;"} |
16 |
| - %span.text= question.text |
17 |
| - %span.help= question.help_text |
18 |
| - = hidden_field_tag("responses[#{question.id}][question_id]", question.id) |
19 |
| - %ol.answers |
20 |
| - %li.answer |
21 |
| - - options = question.answers.collect{|a| "<option #{ (response_set.response_for(question.id, a.id).selected?)? "selected='selected'" : nil } value ='#{a.id}'>#{a.text}</option>" } |
22 |
| - = renderer == :slider ? select_tag("responses[#{question.id}][answer_id]", options, {:id => "slider_#{question.id}"}) : select_tag("responses[#{question.id}][answer_id]", ["<option value=''>#{t('surveyor.Select_one')}</option>"].concat(options)) |
23 |
| -- when :grid_default |
24 |
| - - reset_cycle("col") |
25 |
| - - content_tag_for :tr, question, :class => question.css_class(response_set) do |
26 |
| - %th.question_prefix |
27 |
| - %span.text= split_text(question.text)[:prefix] |
28 |
| - %span.help= question.help_text |
29 |
| - = hidden_field_tag("responses[#{question.id}][question_id]", question.id) |
30 |
| - - question.answers.each do |answer| |
31 |
| - %td{:class => "#{cycle("column_highlight", "", :name => "col")}"} |
32 |
| - .answer{:class => answer.custom_class}= render(:partial => answer.custom_renderer || "/partials/answer", :locals => {:answer => answer, :question => question, :response_obj => @response_set.response_for(question.id, answer.id), :hide_label => true}) |
33 |
| - %th.question_postfix |
34 |
| - %span.text= split_text(question.text)[:postfix] |
35 |
| -- when :repeater_default, :repeater_dropdown |
36 |
| - - disabled ||= false |
37 |
| - - div_for question, :class => "#{disabled ? 'dis' : 'en'}abled #{question.css_class(response_set)}" do |
38 |
| - %span.text= question.text |
39 |
| - %span.help= question.help_text |
40 |
| - = hidden_field_tag("response_groups[#{question.id}][#{response_group}][response_group]", response_group) |
41 |
| - = hidden_field_tag("response_groups[#{question.id}][#{response_group}][question_id]", question.id) |
42 |
| - %br |
43 |
| - %ol.answers |
44 |
| - - if renderer == :repeater_default |
45 |
| - - question.answers.each do |answer| |
46 |
| - - content_tag_for :li, answer, :class => answer.custom_class do |
47 |
| - = render(:partial => answer.custom_renderer || "/partials/answer", :locals => {:answer => answer, :question => question, :response_obj => @response_set.response_for(question.id, answer.id, response_group), :response_group => response_group, :hide_label => true, :disabled => disabled}) |
48 |
| - - else |
49 |
| - %li.answer |
50 |
| - - options = question.answers.collect{|a| "<option #{ (response_set.response_for(question.id, a.id, response_group).selected?)? "selected='selected'" : nil } value ='#{a.id}'>#{a.text}</option>" } |
51 |
| - = select_tag("response_groups[#{question.id}][#{response_group}][answer_id]", ["<option value=''>Select one...</option>"].concat(options), :disabled => disabled) |
52 |
| -- when :inline_default, :inline_dropdown |
53 |
| - - div_for question, :class => "inline #{question.css_class(response_set)}" do |
54 |
| - = hidden_field_tag("responses[#{question.id}][question_id]", question.id) |
55 |
| - - if renderer == :inline_default |
56 |
| - - question.answers.each do |answer| |
57 |
| - .answer{:class => answer.custom_class}= render(:partial => answer.custom_renderer || "/partials/answer", :locals => {:answer => answer, :question => question, :response_obj => @response_set.response_for(question.id, answer.id), :hide_label => answer.hide_label}) |
58 |
| - - else |
59 |
| - - options = question.answers.collect{|a| "<option #{ (response_set.response_for(question.id, a.id).selected?)? "selected='selected'" : nil } value ='#{a.id}'>#{a.text}</option>" } |
60 |
| - = select_tag("responses[#{question.id}][answer_id]", ["<option value=''>Select one...</option>"].concat(options)) |
61 |
| -- else # :default, :inline |
62 |
| - - div_for question, :class => question.css_class(response_set) do |
63 |
| - .number= next_number unless question.dependent? |
64 |
| - %fieldset |
65 |
| - %legend |
66 |
| - %span.text= question.text |
67 |
| - %span.help= question.help_text |
68 |
| - = hidden_field_tag("responses[#{question.id}][question_id]", question.id) |
69 |
| - %ol.answers{:class => renderer == :inline ? "inline" : nil} |
70 |
| - - question.answers.each do |answer| |
71 |
| - - content_tag_for :li, answer, :class => answer.custom_class do |
72 |
| - = render(:partial => answer.custom_renderer || "/partials/answer", :locals => {:answer => answer, :question => question, :response_obj => @response_set.response_for(question.id, answer.id), :hide_label => answer.hide_label}) |
| 1 | +-# TODO: js for slider pre/post text for question in a grid |
| 2 | +- renderer = q.renderer(g ||= nil) |
| 3 | +- f.inputs q_text(q), :id => "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}" do |
| 4 | + %span.help= q.help_text |
| 5 | + - case renderer |
| 6 | + - when :image, :label |
| 7 | + - when :dropdown, :inline_dropdown, :slider |
| 8 | + - r = response_for(@response_set, q) |
| 9 | + - i = response_idx |
| 10 | + - f.semantic_fields_for i, r do |g| |
| 11 | + = g.input :question_id, :as => :hidden |
| 12 | + = g.input :answer_id, :collection => q.answers.map{|a| [a.text, a.id]}, :label => false |
| 13 | + - else # :default, :inline, :inline_default, :inline_dropdown |
| 14 | + - if q.pick == "one" |
| 15 | + - r = response_for(@response_set, q) |
| 16 | + - i = response_idx |
| 17 | + - f.semantic_fields_for i, r do |g| |
| 18 | + = g.input :question_id, :as => :hidden |
| 19 | + - q.answers.each do |a| |
| 20 | + = render a.custom_renderer || '/partials/answer', :q => q, :a => a, :f => f |
0 commit comments