Initial attempt to resolve dateFormat issue

Translating from strftime format to jQuery UI's format on the fly on every
page render. That kind of sucks, but it works. I think I have enough
translations here to cover everybody, but possibly not.
This commit is contained in:
Eric Allen 2009-10-30 15:37:40 -04:00
parent c1dfeaf0f2
commit 686086dcdf
3 changed files with 15 additions and 1 deletions

View file

@ -166,4 +166,17 @@ module ApplicationHelper
return rt+rp+rts
end
def date_format_for_date_picker()
standard_format = current_user.prefs.date_format
translations = [
['%m', 'mm'],
['%d', 'dd'],
['%Y', 'yy'],
['%y', 'y']
]
translations.inject(standard_format) do |str, translation|
str.gsub(*translation)
end
end
end

View file

@ -32,6 +32,7 @@
var defaultContexts = <%= default_contexts_for_autocomplete %>;
var defaultTags = <%= default_tags_for_autocomplete %>;
var tagNames = <%= tag_names_for_autocomplete %>;
var dateFormat = '<%= date_format_for_date_picker %>';
<% end -%>
</script>
<link rel="shortcut icon" href="<%= url_for(:controller => 'favicon.ico') %>" />

View file

@ -185,7 +185,7 @@ function project_defaults(){
}
function enable_rich_interaction(){
$('input.Date').datepicker();
$('input.Date').datepicker({'dateFormat': dateFormat});
/* Autocomplete */
$('input[name=context_name]').autocomplete(contextNames);
$('input[name=project[default_context_name]]').autocomplete(contextNames);