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
Hugo Dutoit
TP4 - AJAX
Commits
e4514830
Commit
e4514830
authored
4 years ago
by
Hugo Dutoit
Browse files
Options
Downloads
Patches
Plain Diff
B2
parent
395f4e5f
Branches
Branches containing commit
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
+25
-7
25 additions, 7 deletions
src/main.js
with
35 additions
and
11 deletions
index.html
+
0
−
4
View file @
e4514830
...
...
@@ -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 @
e4514830
<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
+
25
−
7
View file @
e4514830
...
...
@@ -4,6 +4,22 @@ import PizzaList from './pages/PizzaList';
import
PizzaForm
from
'
./pages/PizzaForm
'
;
import
Component
from
'
./components/Component
'
;
function
displayNews
(
html
)
{
// 1. injectez le contenu du fichier dans la section .newsContainer
newsContainer
.
innerHTML
=
html
;
// 2. affichez la balise .newsContainer
newsContainer
.
style
.
display
=
''
;
closeButton
=
newsContainer
.
querySelector
(
'
.closeButton
'
);
closeButton
.
addEventListener
(
'
click
'
,
event
=>
{
event
.
preventDefault
();
newsContainer
.
style
.
display
=
'
none
'
;
});
}
fetch
(
'
./news.html
'
)
.
then
(
response
=>
response
.
text
())
.
then
(
displayNews
);
const
pizzaList
=
new
PizzaList
([]),
aboutPage
=
new
Component
(
'
p
'
,
null
,
'
ce site est génial
'
),
pizzaForm
=
new
PizzaForm
();
...
...
@@ -40,15 +56,17 @@ 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
'
)
;
let
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 :
...
...
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