Skip to content

Commit

Permalink
Merge pull request #202 from anketwokings/master
Browse files Browse the repository at this point in the history
Remember tab when switching locale
  • Loading branch information
bobdenotter committed Apr 1, 2019
2 parents d2a60d5 + f20bf92 commit 8760d13
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions templates/fields/_locale.twig
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@
);
{% endif %}
});
var localeTab = document.querySelector('#locale-select');
if (localeTab !== null) {
var links = localeTab.querySelectorAll('a');
window.onhashchange = function (){
var tab = window.location.hash.substr(1);
Array.prototype.forEach.call(links, function(link) {
var origHref = link.getAttribute('href').split('#')[0];
if (tab.length>0) {
link.setAttribute('href', origHref + '#' + tab);
}
});
};
}
</script>

<style>
Expand Down

0 comments on commit 8760d13

Please sign in to comment.