Skip to content

Commit

Permalink
date picker. closes NUBIC#58
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Yoon committed Jan 31, 2011
1 parent 607007b commit 0b200e7
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 10 deletions.
8 changes: 7 additions & 1 deletion app/helpers/surveyor_helper.rb
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/views/partials/_answer.html.haml
Expand Up @@ -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
Binary file added generators/surveyor/templates/assets/images/next.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added generators/surveyor/templates/assets/images/prev.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -33,12 +33,14 @@ jQuery(document).ready(function(){
// is_exclusive checkboxes should disble sibling checkboxes
$('input.exclusive:checked').parents('fieldset[id^="q_"]').find(':checkbox').not(".exclusive").attr('checked', false).attr('disabled', true);
$('input.exclusive:checkbox').click(function(){
var e = $(this);
var others = e.parents('fieldset[id^="q_"]').find(':checkbox').not(".exclusive");
if(e.is(':checked')){
others.attr('checked', false).attr('disabled', true);
}else{
others.attr('disabled', false);
}
});
var e = $(this);
var others = e.parents('fieldset[id^="q_"]').find(':checkbox').not(".exclusive");
if(e.is(':checked')){
others.attr('checked', false).attr('disabled', true);
}else{
others.attr('disabled', false);
}
});

$('li.date input').dateinput();
});
149 changes: 149 additions & 0 deletions generators/surveyor/templates/assets/stylesheets/dateinput.css
@@ -0,0 +1,149 @@
/* For the details, see: http://flowplayer.org/tools/dateinput/index.html#skinning */

/* the input field */
/*
.date {
border:1px solid #ccc;
font-size:18px;
padding:4px;
text-align:center;
width:194px;
-moz-box-shadow:0 0 10px #eee inset;
}
*/
/* calendar root element */
#calroot {
/* place on top of other elements. set a higher value if nessessary */
z-index:9999;

margin-top:-1px;
width:198px;
padding:2px;
background-color:#fff;
font-size:11px;
border:1px solid #ccc;
-moz-border-radius:5px;
-webkit-border-radius:5px;
-moz-box-shadow: 0 0 15px #666;
-webkit-box-shadow: 0 0 15px #666;
position: absolute;
}

/* head. contains title, prev/next month controls and possible month/year selectors */
#calhead {
padding:2px 0;
height:22px;
}

#caltitle {
font-size:14px;
color:#0150D1;
float:left;
text-align:center;
width:155px;
line-height:20px;
text-shadow:0 1px 0 #ddd;
}

#calnext, #calprev {
display:block;
width:20px;
height:20px;
background:transparent url('/images/surveyor/prev.gif') no-repeat scroll center center;
float:left;
cursor:pointer;
}

#calnext {
background-image:url('/images/surveyor/next.gif');
float:right;
}

#calprev.caldisabled, #calnext.caldisabled {
visibility:hidden;
}

/* year/month selector */
#caltitle select {
font-size:10px;
}

/* names of the days */
#caldays {
height:14px;
border-bottom:1px solid #ddd;
}

#caldays span {
display:block;
float:left;
width:28px;
text-align:center;
}

/* container for weeks */
#calweeks {
background-color:#fff;
margin-top:4px;
}

/* single week */
.calweek {
clear:left;
height:22px;
}

/* single day */
.calweek a {
display:block;
float:left;
width:27px;
height:20px;
text-decoration:none;
font-size:11px;
margin-left:1px;
text-align:center;
line-height:20px;
color:#666;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}

/* different states */
.calweek a:hover, .calfocus {
background-color:#ddd;
}

/* sunday */
a.calsun {
color:red;
}

/* offmonth day */
a.caloff {
color:#ccc;
}

a.caloff:hover {
background-color:rgb(245, 245, 250);
}


/* unselecteble day */
a.caldisabled {
background-color:#efefef !important;
color:#ccc !important;
cursor:default;
}

/* current day */
#calcurrent {
background-color:#498CE2;
color:#fff;
}

/* today */
#caltoday {
background-color:#333;
color:#fff;
}
Expand Up @@ -82,6 +82,9 @@ body
:display inline
li.inline
:display inline
li.datetime, li.time
input, fieldset, fieldset ol li
:display inline
&.q_inline ol li
:display inline
input, textarea, select
Expand Down
3 changes: 3 additions & 0 deletions lib/formtastic/surveyor_builder.rb
Expand Up @@ -76,5 +76,8 @@ def surveyor_radio_input(method, options)

Formtastic::Util.html_safe(list_item_content.join)
end
def date_input(method, options)
string_input(method, options)
end
end
end

0 comments on commit 0b200e7

Please sign in to comment.