Skip to content

Instantly share code, notes, and snippets.

@jpemberthy
Created August 25, 2009 17:17
Show Gist options
  • Save jpemberthy/174845 to your computer and use it in GitHub Desktop.
Save jpemberthy/174845 to your computer and use it in GitHub Desktop.
def datetime_calendar(initial_date, opts = {}, html_opts = {}) #:nodoc:
options = {:prefix => 'date'}
options.merge!(opts)
date_format = Wice::Defaults::DATETIME_FORMAT
date_string = initial_date.nil? ? '' : initial_date.strftime(Wice::Defaults::DATETIME_FORMAT)
date_picker, datepicker_placeholder_id, trigger_id, dom_id, date_span_id = select_date_datetime_common(options, date_string, html_opts)
html = "<span id=\"#{datepicker_placeholder_id}\">#{date_picker}</span>"
html << %(<script type="text/javascript">\n)
html << %( Calendar.setup\({\n)
html << %( button : "#{trigger_id}",\n )
html << %( ifFormat : "#{date_format}",\n )
html << %( inputField : "#{dom_id}",\n )
html << %( include_blank : true,\n )
html << %( showsTime : true, \n)
html << %( time24 : true, \n)
html << %( singleClick : true,\n)
html << %( onClose : function(cal){ new Effect.Highlight("#{date_span_id}"); cal.hide(); }\n)
html << %( }\);\n)
html << %(</script>\n)
html
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment