Skip to content
Snippets Groups Projects
Commit 74df0e05 authored by Maxime Wallart's avatar Maxime Wallart :speech_balloon:
Browse files

C2.2

parent e54d13d2
No related branches found
No related tags found
No related merge requests found
......@@ -10,4 +10,16 @@ export default class Router {
this.contentElement.innerHTML = route.page.render();
}
}
static #menuElement;
static set menuElement(element) {
this.#menuElement = element;
function redirect(event) {
event.currentTarget.navigate(menuElement.getAttribute('href'));
console.log(event.currentTarget.getAttribute('href'))
}
var liens = menuElement.getAttribute('a');
for(var i=0;i<liens.length; i++) {
liens[i].addEventListener('click',redirect);
}
}
}
......@@ -11,3 +11,22 @@ Router.routes = [{ path: '/', page: pizzaList, title: 'La carte' }];
Router.navigate('/'); // affiche une page vide
pizzaList.pizzas = data;
Router.navigate('/'); // affiche la liste des pizzas
document.querySelector('.newsContainer').setAttribute('style','');
function fermer(event) {
document.querySelector('.newsContainer').setAttribute('style','display:none');
}
const close = document.querySelector('.closeButton');
close.addEventListener('click', fermer);
pizzaList = new PizzaList([]),
aboutPage = new Component('section', null, 'Ce site est génial'),
pizzaForm = new Component('section', null, 'Ici vous pourrez ajouter une pizza');
Router.routes = [
{ path: '/', page: pizzaList, title: 'La carte' },
{ path: '/a-propos', page: aboutPage, title: 'À propos' },
{ path: '/ajouter-pizza', page: pizzaForm, title: 'Ajouter une pizza' },
];
Router.menuElement = document.querySelector('.mainMenu');
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment