diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e69de29b..b8b1a698 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -0,0 +1,3 @@ +document.getElementById('locale').addEventListener('change', function() { + document.getElementById('locale-form').submit(); +}); diff --git a/app/assets/javascripts/outfits/edit.js b/app/assets/javascripts/outfits/edit.js index dd43e1f6..6f53f887 100644 --- a/app/assets/javascripts/outfits/edit.js +++ b/app/assets/javascripts/outfits/edit.js @@ -314,6 +314,7 @@ View.Hash = function (wardrobe) { previous_query = new_query; document.location.hash = '#' + new_query; updateLinksWithReturnTo(); + updateLocaleForm(); } function updateLinksWithReturnTo() { @@ -327,6 +328,12 @@ View.Hash = function (wardrobe) { }); } + function updateLocaleForm() { + var fullPath = document.location.pathname + document.location.search + + document.location.hash; + $('#locale-form').find('input[name=return_to]').val(fullPath); + } + this.initialize = function () { checkQuery(); setInterval(checkQuery, 100); @@ -1362,13 +1369,6 @@ userbar_sessions_link.hover(function () { userbar_message_el.stop().fadeOut('fast'); }); -var localeForm = $('#locale-form'); -localeForm.submit(function (e) { - var fullPath = document.location.pathname + document.location.search + - document.location.hash; - localeForm.find('input[name=return_to]').val(fullPath); -}); - $.ajaxSetup({ error: function (xhr) { $.jGrowl("There was an error loading that last resource. Oops. Please try again!"); diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 5b464683..9b09b900 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -57,7 +57,7 @@ = form_tag choose_locale_path, :id => 'locale-form' do = hidden_field_tag 'return_to', request.fullpath = select_tag 'locale', options_for_select(locale_options, locale) - = submit_tag 'Go' + %noscript= submit_tag 'Go' %ul %li= link_to t('organization_name'), 'http://openneo.net/' @@ -74,5 +74,6 @@ %p= t '.footer.copyright', :year => Date.today.year + = javascript_include_tag 'application' = yield(:javascripts)