Skip to content

Commit

Permalink
replace all instances of window.onload with addEventListener (#1185)
Browse files Browse the repository at this point in the history
* Add event listener for window loading

* reformat

* reformat

* new line at end

* remove semi colons

* replace all instances of window.load with addEventListener

* add new endline

* remove extra spacecs
  • Loading branch information
ibrahimjaved12 authored Jul 10, 2023
1 parent 3afe20e commit 39a09d2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
7 changes: 4 additions & 3 deletions base-offline/layouts/shortcodes/image-gallery.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
</div>

<script>
window.onload = function() {
if (window.initNanogallery2)
window.initNanogallery2()
window.addEventListener('load', function() {
if (window.initNanogallery2) {
window.initNanogallery2()
}
})
</script>
6 changes: 3 additions & 3 deletions base-theme/layouts/partials/local_video_player.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

{{ if or .startTime .endTime }}
<script>
window.onload = function() {
window.addEventListener('load', function() {
if (window.videojs) {
const player = window.videojs("{{ $playerId }}")
const startTime = {{ .startTime }}
Expand All @@ -35,6 +35,6 @@
player.on("timeupdate", stopper)
}
}
}
})
</script>
{{ end }}
{{ end }}
7 changes: 4 additions & 3 deletions base-theme/layouts/partials/youtube_player.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
</div>

<script>
window.onload = function() {
if (window.initVideoJS)
window.addEventListener('load', function() {
if (window.initVideoJS) {
window.initVideoJS()
}
}
})
</script>
9 changes: 5 additions & 4 deletions base-theme/layouts/shortcodes/image-gallery.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{{ $baseUrl := .Get "baseUrl" }}
<div id="{{ .Get "id" }}" class="image-gallery" data-nanogallery2='{ "itemsBaseURL": "{{ partial "resource_url.html" (dict "context" .Page "url" $baseUrl) }}" }'>
{{ .Inner }}
{{ .Inner }}
</div>

<script>
window.onload = function() {
if (window.initNanogallery2)
window.initNanogallery2()
window.addEventListener('load', function() {
if (window.initNanogallery2) {
window.initNanogallery2()
}
})
</script>
4 changes: 2 additions & 2 deletions www-offline/layouts/search/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h3 class="col-3 text-center m-auto">Start typing to search</h3>
</div>
</div>
<script>
window.onload = function() {
window.addEventListener('load', function() {
if (window.Fuse) {
// an array of known websites generated at build time
const websites = [
Expand Down Expand Up @@ -129,6 +129,6 @@ <h3 class="col-3 text-center m-auto">Start typing to search</h3>
searchInput.addEventListener("input", onInput)
searchButton.addEventListener("click", onSearchButtonClick)
}
}
})
</script>
{{ end }}

0 comments on commit 39a09d2

Please sign in to comment.