diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 6e5b1df3d..cf1d2eba4 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -31,7 +31,7 @@ var initialize_modules = function() { App.Votes.initialize(); App.Tags.initialize(); App.Stats.initialize(); - App.LocaleSwitcher.initialize(); + App.LocationChanger.initialize(); App.DebatesOrderSelector.initialize(); }; diff --git a/app/assets/javascripts/locale_switcher.js.coffee b/app/assets/javascripts/locale_switcher.js.coffee deleted file mode 100644 index 2bd88b8ef..000000000 --- a/app/assets/javascripts/locale_switcher.js.coffee +++ /dev/null @@ -1,19 +0,0 @@ -App.LocaleSwitcher = - - href_with_params: (query_params) -> - loc = window.location - - loc.protocol + "//" + loc.hostname + - (if loc.port then ':' + loc.port else '') + - loc.pathname + - loc.hash + - '?' + $.param(query_params) - - initialize: -> - $('.js-locale-switcher').on 'change', -> - query_params = window.getQueryParameters() - query_params['locale'] = $(this).val() - window.location.assign(App.LocaleSwitcher.href_with_params(query_params)) - - - diff --git a/app/assets/javascripts/location_changer.js.coffee b/app/assets/javascripts/location_changer.js.coffee new file mode 100644 index 000000000..54693633d --- /dev/null +++ b/app/assets/javascripts/location_changer.js.coffee @@ -0,0 +1,8 @@ +App.LocationChanger = + + initialize: -> + $('.js-location-changer').on 'change', -> + window.location.assign($(this).val()) + + + diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 11e4cae8c..69cb06d45 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -14,13 +14,4 @@ module ApplicationHelper home_page? ? '' : 'results' end - def available_locale_options_for_select - options_for_select(available_locales_array, I18n.locale) - end - - private - def available_locales_array - I18n.available_locales.map { |loc| [I18n.t('locale', locale: loc), loc] } - end - end diff --git a/app/views/shared/_locale_switcher.html.erb b/app/views/shared/_locale_switcher.html.erb index 2ac1c851f..f76a71b9c 100644 --- a/app/views/shared/_locale_switcher.html.erb +++ b/app/views/shared/_locale_switcher.html.erb @@ -1,8 +1,13 @@