Skip to content

Commit

Permalink
Add script to existing script tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Anke authored Mar 8, 2019
1 parent 00446f1 commit f20bf92
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 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 Expand Up @@ -114,23 +132,3 @@
background-color: transparent !important;
}
</style>

<script>
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>

0 comments on commit f20bf92

Please sign in to comment.