Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
howto-cards
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roland Krause
howto-cards
Commits
428577ce
Commit
428577ce
authored
4 years ago
by
Jacek Lebioda
Browse files
Options
Downloads
Patches
Plain Diff
feat: added box hider to index page
(to be used after landing page)
parent
7acfe9fe
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
_includes/scripts.html
+7
-1
7 additions, 1 deletion
_includes/scripts.html
assets/js/box_hider.js
+89
-0
89 additions, 0 deletions
assets/js/box_hider.js
index.md
+1
-1
1 addition, 1 deletion
index.md
with
97 additions
and
2 deletions
_includes/scripts.html
+
7
−
1
View file @
428577ce
<script
type=
"text/javascript"
src=
"https://analytics.lcsb.uni.lu/lap/static/js/jquery.min.js"
></script>
<script
type=
"text/javascript"
src=
"{{ "
assets
/
js
/
router.js
"
|
relative_url
}}"
></script>
\ No newline at end of file
<script
type=
"text/javascript"
src=
"{{ "
assets
/
js
/
router.js
"
|
relative_url
}}"
></script>
<script
type=
"text/javascript"
src=
"{{ "
assets
/
js
/
box_hider.js
"
|
relative_url
}}"
></script>
<script>
window
.
addEventListener
(
'
load
'
,
function
()
{
window
.
boxHider
.
Trigger
();
})
</script>
This diff is collapsed.
Click to expand it.
assets/js/box_hider.js
0 → 100644
+
89
−
0
View file @
428577ce
/**
* This is used to hide the sections of the index page
* based on the URL fragment (a.k.a. "hash")
*/
window
.
boxHider
=
(
function
()
{
function
GetSelectedId
()
{
var
boxId
=
window
.
location
.
hash
;
if
(
boxId
.
length
>
0
)
{
return
boxId
.
substring
(
1
);
}
return
""
;
}
function
GetAllBoxElements
()
{
return
document
.
getElementsByClassName
(
'
index-box
'
);
}
function
GetAllBoxElementsArray
()
{
var
allBoxes
=
GetAllBoxElements
();
var
allBoxesArray
=
Array
.
prototype
.
slice
.
call
(
allBoxes
);
return
allBoxesArray
;
}
function
GetSelectedBoxElement
(
id
)
{
var
allBoxesArray
=
GetAllBoxElementsArray
();
var
element
=
document
.
getElementById
(
id
);
if
(
allBoxesArray
.
includes
(
element
))
{
return
element
;
}
return
false
;
}
function
HideElement
(
element
)
{
if
(
element
instanceof
HTMLElement
)
{
element
.
style
[
'
display
'
]
=
'
none
'
;
}
}
function
UnhideElement
(
element
)
{
if
(
element
instanceof
HTMLElement
)
{
element
.
style
[
'
display
'
]
=
'
block
'
;
}
}
function
HideAllCategories
()
{
var
allCategoriesElement
=
document
.
getElementById
(
'
all-categories
'
);
HideElement
(
allCategoriesElement
);
}
function
ShowAllBoxes
()
{
var
allBoxes
=
GetAllBoxElementsArray
();
allBoxes
.
map
(
function
(
box
)
{
UnhideElement
(
box
);
});
}
function
Trigger
()
{
// First, try to get the hash from the URL (https://example.com/uri?param#hash)
var
boxId
=
GetSelectedId
();
if
(
boxId
.
length
==
0
)
{
// If there is no hash in the URL, just show all the boxes
ShowAllBoxes
();
return
;
}
// Otherwise, proceed to getting the corresponding div element
var
selectedBox
=
GetSelectedBoxElement
(
boxId
);
if
(
selectedBox
==
false
)
{
// If the user selection is not a `div.index-box`, then just show all the boxes
ShowAllBoxes
();
return
;
}
// Hide the "All Categories" element
HideAllCategories
();
// Finally, hide all boxes except of the selected one
var
allBoxes
=
GetAllBoxElementsArray
();
allBoxes
.
map
(
function
(
box
)
{
if
(
box
!=
selectedBox
)
{
HideElement
(
box
);
}
});
}
return
{
'
Trigger
'
:
Trigger
,
'
ShowAllBoxes
'
:
ShowAllBoxes
}
})();
This diff is collapsed.
Click to expand it.
index.md
+
1
−
1
View file @
428577ce
...
...
@@ -65,4 +65,4 @@ The How-to cards are intended to provide practical guidance in implementing Data
</ul>
</div>
</div>
\ No newline at end of file
</div>
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