Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SiB Router
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
19
Issues
19
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Startin blox
framework
SiB Router
Compare Revisions
v0.5.4...v0.5.5
Source
v0.5.5
Select Git revision
...
Target
v0.5.4
Select Git revision
Compare
Commits (2)
feature:
#19
requestNavigation without routeName
· 2005b353
Matthieu Fesselier
authored
Mar 08, 2019
2005b353
Merge branch 'feature/
#19
-navigate-type' into 'master'
· a76fd57b
Clément
authored
Mar 08, 2019
feature:
#19
requestNavigation without routeName See merge request
!7
a76fd57b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
1 deletion
+70
-1
examples/no-route-name.html
examples/no-route-name.html
+61
-0
index.html
index.html
+1
-0
src/sib-router.js
src/sib-router.js
+8
-1
No files found.
examples/no-route-name.html
0 → 100644
View file @
a76fd57b
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
/>
<title>
SIB test: sib-router
</title>
<script
type=
"module"
src=
"../src/index.js"
></script>
<style>
sib-router
{
display
:
block
;
text-align
:
center
;
}
sib-route
,
sib-link
{
display
:
inline-block
;
padding
:
0.5em
;
margin
:
0.2em
;
background-color
:
#ccc
;
cursor
:
pointer
;
}
[
active
]
{
background-color
:
#afa
;
}
</style>
</head>
<body>
<sib-router
default-route=
"page1"
use-hash
>
<sib-route
name=
"page1"
>
1st page
</sib-route>
<sib-route
name=
"page2"
rdf-type=
"doap:project"
>
2nd page
</sib-route>
</sib-router>
<div
id=
"page1"
hidden
>
<h1>
Page 1
</h1>
<p>
Launch navigation event without routeName, but only resource
</p>
<button
id=
"nextPage"
>
requestNavigation
</sib-link>
</div>
<div
id=
"page2"
hidden
>
<h1>
Page 2
</h1>
<p>
Quos, suscipit pariatur! Nulla fugiat excepturi pariatur fuga delectus
corrupti.
</p>
</div>
<script>
nextPage
.
onclick
=
()
=>
{
window
.
dispatchEvent
(
new
CustomEvent
(
'
requestNavigation
'
,
{
detail
:
{
resource
:
{
'
@type
'
:
'
doap:project
'
}
}
}),
);
}
</script>
</body>
</html>
index.html
View file @
a76fd57b
...
...
@@ -23,6 +23,7 @@
<ul>
<li><a
href=
"examples/basic.html"
>
basic
</a></li>
<li><a
href=
"examples/sub-menu.html"
>
sub-menu
</a></li>
<li><a
href=
"examples/no-route-name.html"
>
no-route-name
</a></li>
</ul>
</body>
</html>
src/sib-router.js
View file @
a76fd57b
...
...
@@ -44,7 +44,14 @@ export default class SIBRouter extends HTMLElement {
route
.
hide
();
}
navigate
(
routeName
=
''
,
resource
)
{
const
route
=
this
.
querySelector
(
'
sib-route[name="
'
+
routeName
+
'
"]
'
);
let
route
if
(
routeName
)
{
route
=
this
.
querySelector
(
'
sib-route[name="
'
+
routeName
+
'
"]
'
);
}
else
if
(
!
routeName
&&
resource
&&
resource
[
'
@type
'
])
{
route
=
this
.
querySelector
(
'
sib-route[rdf-type="
'
+
resource
[
'
@type
'
]
+
'
"]
'
);
routeName
=
route
?
route
.
attributes
.
name
.
value
:
null
}
if
(
!
route
)
return
;
//this route is not for me!
const
id
=
resource
?
resource
[
'
@id
'
]
:
null
;
...
...