mirror of
https://github.com/flextype/flextype.git
synced 2025-08-20 11:51:28 +02:00
feat(admin-plugin): add tabs module #211
This commit is contained in:
31
site/plugins/admin/templates/partials/modules/tabs.html
Normal file
31
site/plugins/admin/templates/partials/modules/tabs.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<script>
|
||||
function Tabs() {
|
||||
|
||||
var bindAll = function () {
|
||||
var menuElements = document.querySelectorAll('[data-tab]');
|
||||
for (var i = 0; i < menuElements.length; i++) {
|
||||
menuElements[i].addEventListener('click', change, false);
|
||||
}
|
||||
}
|
||||
|
||||
var clear = function () {
|
||||
var menuElements = document.querySelectorAll('[data-tab]');
|
||||
for (var i = 0; i < menuElements.length; i++) {
|
||||
menuElements[i].classList.remove('tab-link--active');
|
||||
var id = menuElements[i].getAttribute('data-tab');
|
||||
document.getElementById(id).classList.remove('tab--active');
|
||||
}
|
||||
}
|
||||
|
||||
var change = function (e) {
|
||||
clear();
|
||||
e.target.classList.add('tab-link--active');
|
||||
var id = e.currentTarget.getAttribute('data-tab');
|
||||
document.getElementById(id).classList.add('tab--active');
|
||||
}
|
||||
|
||||
bindAll();
|
||||
}
|
||||
|
||||
var connectTabs = new Tabs();
|
||||
</script>
|
Reference in New Issue
Block a user