Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TP4 - AJAX
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aubrian Duhayon
TP4 - AJAX
Commits
f3d5c727
Commit
f3d5c727
authored
4 years ago
by
Aubrian Duhayon
Browse files
Options
Downloads
Patches
Plain Diff
fin partie B2
parent
6f2c3a86
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
index.html
+0
-4
0 additions, 4 deletions
index.html
news.html
+10
-0
10 additions, 0 deletions
news.html
src/main.js
+24
-7
24 additions, 7 deletions
src/main.js
with
34 additions
and
11 deletions
index.html
+
0
−
4
View file @
f3d5c727
...
...
@@ -32,10 +32,6 @@
</nav>
</header>
<section
class=
"newsContainer"
style=
"display:none"
>
<article>
<button
class=
"closeButton"
></button>
<h1>
Bienvenue chez
<strong>
Pizza
<em>
Land
</em></strong>
!
</h1>
</article>
</section>
<section
class=
"pageContainer"
>
<header
class=
"pageTitle"
></header>
...
...
This diff is collapsed.
Click to expand it.
news.html
0 → 100644
+
10
−
0
View file @
f3d5c727
<article>
<button
class=
"closeButton"
></button>
<h1>
Bienvenue chez
<strong>
Pizza
<em>
Land
</em></strong>
!
</h1>
<p>
Découvrez notre nouvelle pizza
<strong
class=
"spicy"
>
Spicy
</strong>
<br/>
aux délicieuses saveurs épicées !
</p>
</article>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main.js
+
24
−
7
View file @
f3d5c727
...
...
@@ -40,15 +40,16 @@ document.querySelector(
// );
// C.2. Navigation en JS : afficher/masquer un élément
const
newsContainer
=
document
.
querySelector
(
'
.newsContainer
'
)
,
closeButton
=
newsContainer
.
querySelector
(
'
.closeButton
'
);
const
newsContainer
=
document
.
querySelector
(
'
.newsContainer
'
)
;
//
closeButton = newsContainer.querySelector('.closeButton');
// affichage du bandeau de news
newsContainer
.
style
.
display
=
''
;
//
newsContainer.style.display = '';
// gestion du bouton fermer
closeButton
.
addEventListener
(
'
click
'
,
event
=>
{
event
.
preventDefault
();
newsContainer
.
style
.
display
=
'
none
'
;
});
// closeButton.addEventListener('click', event => {
// event.preventDefault();
// newsContainer.style.display = 'none';
// });
// E.3. Deeplinking
// détection des boutons précédent/suivant du navigateur :
...
...
@@ -57,3 +58,19 @@ window.onpopstate = () => Router.navigate(document.location.pathname, false);
// affichage de la page initiale :
// même traitement que lors de l'appui sur les boutons précédent/suivant
window
.
onpopstate
();
function
displayNews
(
html
)
{
newsContainer
.
innerHTML
+=
html
;
newsContainer
.
style
.
display
=
''
;
newsContainer
.
querySelector
(
'
.closeButton
'
)
.
addEventListener
(
'
click
'
,
event
=>
{
event
.
preventDefault
();
newsContainer
.
style
.
display
=
'
none
'
;
});
}
fetch
(
'
./news.html
'
)
.
then
(
response
=>
response
.
text
())
.
then
(
displayNews
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment