Skip to content

Commit

Permalink
Include datepicker i18n only as needed
Browse files Browse the repository at this point in the history
* Restore the javascript_tag_for_i18n_datepicker helper (and actually use it)
* Include the datepicker i18n JS in the asset precompilation list
  • Loading branch information
dnrce committed Feb 17, 2016
1 parent 91849c5 commit 4b046b9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
7 changes: 0 additions & 7 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@

//= require jquery-ui/autocomplete
//= require jquery-ui/datepicker
//= require jquery-ui/datepicker-cs
//= require jquery-ui/datepicker-de
//= require jquery-ui/datepicker-es
//= require jquery-ui/datepicker-fr
//= require jquery-ui/datepicker-he
//= require jquery-ui/datepicker-nl
//= require jquery-ui/datepicker-ru
//= require jquery-ui/dialog
//= require jquery-ui/droppable
//= require jquery-ui/effect-highlight
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/tracks_pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ var TracksPages = {
TodoItems.setup_autocomplete_for_predecessor();
},
setup_datepicker: function() {
$.datepicker.setDefaults($.datepicker.regional[i18n_locale]);
$('input.Date').datepicker({
'dateFormat': dateFormat,
'firstDay': weekStart,
Expand Down
8 changes: 8 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ def generate_i18n_strings
return js.html_safe
end

def javascript_tag_for_i18n_datepicker
locale = I18n.locale
# do not include en as locale since this the available by default
if locale && locale != :en
javascript_include_tag("jquery-ui/datepicker-#{locale}")
end
end

def done_path(controller_name, type)
case controller_name
when "contexts"
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
setup_periodic_check("<%=check_deferred_todos_path(:format => 'js')%>", 10*60, 'POST');
<%= generate_i18n_strings %>
</script>
<%= javascript_tag_for_i18n_datepicker %>
<%= favicon_link_tag 'favicon.ico' %>
<%= favicon_link_tag 'apple-touch-icon.png', :rel => 'apple-touch-icon', :type => 'image/png' %>
<%= auto_discovery_link_tag(:rss, {:controller => "todos", :action => "index", :format => 'rss', :token => "#{current_user.token}"}, {:title => t('layouts.next_actions_rss_feed')}) %>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( print.css mobile.css )
Rails.application.config.assets.precompile += %w( print.css mobile.css jquery-ui/datepicker-*.js )

# add /app/assets/swfs to asset pipeline for charts
Rails.application.config.assets.paths << Rails.root.join("app", "assets", "swfs")

0 comments on commit 4b046b9

Please sign in to comment.