mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 00:00:12 +01:00
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:
parent
c1dfeaf0f2
commit
686086dcdf
3 changed files with 15 additions and 1 deletions
|
|
@ -166,4 +166,17 @@ module ApplicationHelper
|
||||||
return rt+rp+rts
|
return rt+rp+rts
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
var defaultContexts = <%= default_contexts_for_autocomplete %>;
|
var defaultContexts = <%= default_contexts_for_autocomplete %>;
|
||||||
var defaultTags = <%= default_tags_for_autocomplete %>;
|
var defaultTags = <%= default_tags_for_autocomplete %>;
|
||||||
var tagNames = <%= tag_names_for_autocomplete %>;
|
var tagNames = <%= tag_names_for_autocomplete %>;
|
||||||
|
var dateFormat = '<%= date_format_for_date_picker %>';
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</script>
|
</script>
|
||||||
<link rel="shortcut icon" href="<%= url_for(:controller => 'favicon.ico') %>" />
|
<link rel="shortcut icon" href="<%= url_for(:controller => 'favicon.ico') %>" />
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ function project_defaults(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function enable_rich_interaction(){
|
function enable_rich_interaction(){
|
||||||
$('input.Date').datepicker();
|
$('input.Date').datepicker({'dateFormat': dateFormat});
|
||||||
/* Autocomplete */
|
/* Autocomplete */
|
||||||
$('input[name=context_name]').autocomplete(contextNames);
|
$('input[name=context_name]').autocomplete(contextNames);
|
||||||
$('input[name=project[default_context_name]]').autocomplete(contextNames);
|
$('input[name=project[default_context_name]]').autocomplete(contextNames);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue