mirror of
https://github.com/doctrine/doctrine-website.git
synced 2026-03-23 22:32:11 +01:00
Remove tab script for being replaced by bootstrap (#549)
With the fix of #546 this script isn't needed anymore
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
import * as fs from 'fs';
|
||||
import tabs from '../../../source/js/tab';
|
||||
document.body.innerHTML = fs.readFileSync('source/projects.html');
|
||||
|
||||
describe('Project Tabs', function () {
|
||||
test('Active projects loads on default', function () {
|
||||
tabs();
|
||||
|
||||
const activeProjectsTab = document.getElementById('active-projects-tab');
|
||||
const integrationProjectsTab = document.getElementById('integration-projects-tab');
|
||||
const inactiveProjectsTab = document.getElementById('inactive-projects-tab');
|
||||
|
||||
expect(activeProjectsTab.className).toBe('nav-link active');
|
||||
expect(integrationProjectsTab.className).toBe('nav-link');
|
||||
expect(inactiveProjectsTab.className).toBe('nav-link');
|
||||
});
|
||||
|
||||
test('Active tab selects on click', function () {
|
||||
tabs();
|
||||
|
||||
const activeProjectsTab = document.getElementById('active-projects-tab');
|
||||
const integrationProjectsTab = document.getElementById('integration-projects-tab');
|
||||
const inactiveProjectsTab = document.getElementById('inactive-projects-tab');
|
||||
|
||||
inactiveProjectsTab.click();
|
||||
activeProjectsTab.click();
|
||||
|
||||
expect(activeProjectsTab.className).toBe('nav-link active');
|
||||
expect(integrationProjectsTab.className).toBe('nav-link');
|
||||
expect(inactiveProjectsTab.className).toBe('nav-link');
|
||||
|
||||
expect(document.getElementById('active-projects').className).toContain('show active');
|
||||
expect(document.getElementById('integration-projects').className).not.toContain('show active');
|
||||
expect(document.getElementById('inactive-projects').className).not.toContain('show active');
|
||||
});
|
||||
|
||||
test('Integration tab selects on click', function () {
|
||||
tabs();
|
||||
|
||||
const activeProjectsTab = document.getElementById('active-projects-tab');
|
||||
const integrationProjectsTab = document.getElementById('integration-projects-tab');
|
||||
const inactiveProjectsTab = document.getElementById('inactive-projects-tab');
|
||||
|
||||
integrationProjectsTab.click();
|
||||
|
||||
expect(activeProjectsTab.className).toBe('nav-link');
|
||||
expect(integrationProjectsTab.className).toBe('nav-link active');
|
||||
expect(inactiveProjectsTab.className).toBe('nav-link');
|
||||
|
||||
expect(document.getElementById('active-projects').className).not.toContain('show active');
|
||||
expect(document.getElementById('integration-projects').className).toContain('show active');
|
||||
expect(document.getElementById('inactive-projects').className).not.toContain('show active');
|
||||
});
|
||||
|
||||
test('Inactive tab selects on click', function () {
|
||||
tabs();
|
||||
|
||||
const activeProjectsTab = document.getElementById('active-projects-tab');
|
||||
const integrationProjectsTab = document.getElementById('integration-projects-tab');
|
||||
const inactiveProjectsTab = document.getElementById('inactive-projects-tab');
|
||||
|
||||
inactiveProjectsTab.click();
|
||||
|
||||
expect(activeProjectsTab.className).toBe('nav-link');
|
||||
expect(integrationProjectsTab.className).toBe('nav-link');
|
||||
expect(inactiveProjectsTab.className).toBe('nav-link active');
|
||||
|
||||
expect(document.getElementById('active-projects').className).not.toContain('show active');
|
||||
expect(document.getElementById('integration-projects').className).not.toContain('show active');
|
||||
expect(document.getElementById('inactive-projects').className).toContain('show active');
|
||||
});
|
||||
});
|
||||
@@ -20,7 +20,3 @@ if ($('#sidebar').length > 0) {
|
||||
new module.default();
|
||||
});
|
||||
}
|
||||
|
||||
import(/* webpackChunkName: "tab" */ './tab').then((module) => {
|
||||
module.default();
|
||||
});
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
const enableTab = function (element) {
|
||||
element.ariaSelected = true;
|
||||
element.classList.add('active');
|
||||
const id = element.attributes.getNamedItem('aria-controls').nodeValue;
|
||||
const referredElement = document.getElementById(id);
|
||||
referredElement.classList.add('show');
|
||||
referredElement.classList.add('active');
|
||||
};
|
||||
|
||||
const disableTab = function (element) {
|
||||
const id = element.attributes.getNamedItem('aria-controls').nodeValue;
|
||||
const targetElement = document.getElementById(id);
|
||||
targetElement.classList.remove('show');
|
||||
targetElement.classList.remove('active');
|
||||
element.ariaSelected = false;
|
||||
element.classList.remove('active');
|
||||
};
|
||||
|
||||
const selectTab = function (targetElement) {
|
||||
getAllTabElements().forEach(function (element) {
|
||||
disableTab(element);
|
||||
});
|
||||
enableTab(targetElement);
|
||||
};
|
||||
|
||||
const getAllTabElements = function () {
|
||||
return document.querySelectorAll('.nav-tabs .nav-link');
|
||||
};
|
||||
|
||||
export default function () {
|
||||
const tabElements = getAllTabElements();
|
||||
|
||||
tabElements.forEach(function (tabElement) {
|
||||
tabElement.addEventListener('click', function (event) {
|
||||
selectTab(event.target);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user