From 0b200e7534cf0eb12a93b84ed02f450a07baf576 Mon Sep 17 00:00:00 2001 From: Mark Yoon Date: Mon, 31 Jan 2011 16:18:13 -0600 Subject: [PATCH] date picker. closes #58 --- app/helpers/surveyor_helper.rb | 8 +- app/views/partials/_answer.html.haml | 2 +- .../surveyor/templates/assets/images/next.gif | Bin 0 -> 601 bytes .../surveyor/templates/assets/images/prev.gif | Bin 0 -> 599 bytes .../assets/javascripts/jquery.surveyor.js | 18 ++- .../assets/stylesheets/dateinput.css | 149 ++++++++++++++++++ .../assets/stylesheets/sass/surveyor.sass | 3 + lib/formtastic/surveyor_builder.rb | 3 + 8 files changed, 173 insertions(+), 10 deletions(-) create mode 100644 generators/surveyor/templates/assets/images/next.gif create mode 100644 generators/surveyor/templates/assets/images/prev.gif create mode 100644 generators/surveyor/templates/assets/stylesheets/dateinput.css diff --git a/app/helpers/surveyor_helper.rb b/app/helpers/surveyor_helper.rb index f418bad7..f76a5cba 100644 --- a/app/helpers/surveyor_helper.rb +++ b/app/helpers/surveyor_helper.rb @@ -4,7 +4,7 @@ def surveyor_includes surveyor_stylsheets + surveyor_javascripts end def surveyor_stylsheets - stylesheet_link_tag 'surveyor/reset', 'surveyor' + stylesheet_link_tag 'surveyor/reset', 'surveyor/dateinput', 'surveyor' end def surveyor_javascripts javascript_include_tag 'surveyor/jquery.tools.min', 'surveyor/jquery.surveyor' @@ -57,6 +57,12 @@ def rc_to_attr(type_sym) else :answer_id end end + def rc_to_as(type_sym) + case type_sym.to_s + when /(integer|float)/ then :string + else type_sym + end + end # Responses def response_for(response_set, question, answer = nil, response_group = nil) diff --git a/app/views/partials/_answer.html.haml b/app/views/partials/_answer.html.haml index 9dab6433..d3b37adb 100644 --- a/app/views/partials/_answer.html.haml +++ b/app/views/partials/_answer.html.haml @@ -14,6 +14,6 @@ - when "none" - if %w(date datetime time float integer string text).include? a.response_class = ff.quiet_input :answer_id, :input_html => {:class => a.css_class, :value => a.id} - = ff.input rc_to_attr(a.response_class), :label => a.split_or_hidden_text(:pre).blank? ? false : a.split_or_hidden_text(:pre), :hint => a.split_or_hidden_text(:post), :input_html => {:value => a.default_value} + = ff.input rc_to_attr(a.response_class), :as => rc_to_as(a.response_class), :label => a.split_or_hidden_text(:pre).blank? ? false : a.split_or_hidden_text(:pre), :hint => a.split_or_hidden_text(:post), :input_html => {:value => a.default_value} - else = a.text diff --git a/generators/surveyor/templates/assets/images/next.gif b/generators/surveyor/templates/assets/images/next.gif new file mode 100644 index 0000000000000000000000000000000000000000..730fc3e66935d79d22346fc59abe5beb96426fe1 GIT binary patch literal 601 zcmZ?wbhEHbnXQCOuzpA=f8i`?|*vz>u>AX*ABZMpMUe6q2v6mPrsPj z&oOtLJNNnY2I<>|XH|HivjcRp}* zp1<+wSJK|cSKj|*Xg*VP;2C?zIfmx5$6tTr>bY>{{SSr-mv|>!I`sT&*_qe+EAQ-o z^L^2c_kJ7h9eeTR>({SSFTeTl`>(~Cdpr{^@lU+;@83U$wsQ>a=YIV7!O(Q(%a9zcA86cimP^pC1a-gIi7%cXQ^PG40%?Lgh)Ow$rKOMR5qEA z%$##E8#f(jYEe!-qj8{c!K7IXjtwyp4Q`G-LMd!KLBS1f?84F;Oe_}^3eIL>;t;Ty LtR^zsfx#L8GeaSC literal 0 HcmV?d00001 diff --git a/generators/surveyor/templates/assets/images/prev.gif b/generators/surveyor/templates/assets/images/prev.gif new file mode 100644 index 0000000000000000000000000000000000000000..7ec2d6c9c6ae8279bc10ae89c2cbae1a658429ff GIT binary patch literal 599 zcmZ?wbhEHbnXQCOuzpA=f8i`?|*vz>u>AX*ABZMpMUe6q2v6mPrsPj z&oOtLJNNnY2I<>|XH|HivjcRp}* zp1<+wSJK|cSKj|*Xg*VP;2C?zIfmx5$6tTr>bY>{{SSr-mv|>!I`sT&*_qe+EAQ-o z^L^2c_kJ7h9eeTR>({SSFTeTl`>(~Cdpr{^@lU+;@83U$wsQ>a=YIV7!O(Q(%ak< z&77iY$d$n@?%>EcJ&WCfD=pPsNQ^ryJUu5fM20QZ)FVaGi!U;PgH=9*Cs@ikK7c1X zTRoG}GDF)nCE6wJG_NNEqd%XPm4KUG;Au8dhIB=?G&3J19sbm`P)$x|6$3vFeRH{3 z344t%J3