From 4b046b98ea7f929ccdd480c243faf207bf75b5ca Mon Sep 17 00:00:00 2001 From: Dan Rice Date: Tue, 16 Feb 2016 22:08:15 -0500 Subject: [PATCH] Include datepicker i18n only as needed * Restore the javascript_tag_for_i18n_datepicker helper (and actually use it) * Include the datepicker i18n JS in the asset precompilation list --- app/assets/javascripts/application.js | 7 ------- app/assets/javascripts/tracks_pages.js | 1 - app/helpers/application_helper.rb | 8 ++++++++ app/views/layouts/application.html.erb | 1 + config/initializers/assets.rb | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 1fc712ec0..6471f7f0b 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -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 diff --git a/app/assets/javascripts/tracks_pages.js b/app/assets/javascripts/tracks_pages.js index 6e96826b8..308897428 100644 --- a/app/assets/javascripts/tracks_pages.js +++ b/app/assets/javascripts/tracks_pages.js @@ -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, diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1f71959ed..f7b6aeaff 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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" diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 3aedd1ce0..835373972 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -25,6 +25,7 @@ setup_periodic_check("<%=check_deferred_todos_path(:format => 'js')%>", 10*60, 'POST'); <%= generate_i18n_strings %> + <%= 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')}) %> diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index d597eb6f4..340e8daaa 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -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")