Commit 659c7d608bd37e76504ae5fd69d6b50e0e12aab8
1 parent
ab06d3ac39
Exists in
master
On regroupe les fonction js dans un fichier commun
Ajout du bouton go to top
Showing 4 changed files with 76 additions and 66 deletions Side-by-side Diff
templates/html/Wize.html
... | ... | @@ -92,22 +92,15 @@ |
92 | 92 | href="[% resource('common/hljs/styles/sunburst.css') %]" > |
93 | 93 | |
94 | 94 | <!-- hljs --> |
95 | - <script src="[% resource('common/hljs/highlight.pack.js') %]"></script> | |
95 | + <script src="[% resource('common/hljs/highlight.pack.js') %]"></script> | |
96 | 96 | |
97 | + <script src="[% resource('common/wizefunc.js') %]"></script> | |
98 | + | |
97 | 99 | <script src="[% resource('common-spec/notice.js') %]"></script> |
98 | 100 | |
99 | - <script> | |
100 | - function testLogo() { | |
101 | - logo=document.getElementById("logoImgId"); | |
102 | - logodiv=document.getElementById("logoDivId"); | |
103 | - if (logo.naturalHeight == 0) { | |
104 | - logodiv.setAttribute("style","display:none;"); | |
105 | - } | |
106 | - } | |
107 | - </script> | |
108 | 101 | </head> |
109 | 102 | <body onload="testLogo()"> |
110 | - | |
103 | +<button onclick="topFunction()" id="upBtn" title="Go to top"></button> | |
111 | 104 | [% options.empty_lines = "default" %] |
112 | 105 | |
113 | 106 | <div class='header'> |
... | ... | @@ -239,6 +232,13 @@ |
239 | 232 | |
240 | 233 | <script src="[% resource('common/go-hljs.js') %]"></script> |
241 | 234 | <script>printNotice()</script> |
235 | +<script> | |
236 | +/* Get the button */ | |
237 | +var upButton = document.getElementById("upBtn"); | |
238 | + | |
239 | +/* When the user scrolls call our scrollFunction */ | |
240 | +window.onscroll = function() {scrollFunction()}; | |
241 | +</script> | |
242 | 242 | |
243 | 243 | </body> |
244 | 244 |
templates/html/Wize_with_index.html
... | ... | @@ -122,43 +122,19 @@ |
122 | 122 | <!-- hljs --> |
123 | 123 | <script src="[% resource('common/hljs/highlight.pack.js') %]"></script> |
124 | 124 | |
125 | - <script> | |
126 | - function openNav() { | |
127 | - if (document.getElementById("mySidenav").getAttribute("class").split(' ')[1] == "menuClosed") { | |
128 | - document.getElementById("mySidenav").style.width = "300px"; | |
129 | - /*document.getElementById("main").style.marginLeft = "300px";*/ | |
130 | - document.getElementById("mySidenav").setAttribute("class","menu menuOpen"); | |
131 | - /* Scroll to top when opening menu */ | |
132 | - document.body.scrollTop = 0 | |
133 | - document.documentElement.scrollTop = 0; | |
134 | - } else { | |
135 | - document.getElementById("mySidenav").style.width = "0"; | |
136 | - /*document.getElementById("main").style.marginLeft = "0";*/ | |
137 | - document.getElementById("mySidenav").setAttribute("class","menu menuClosed"); | |
138 | - } | |
139 | - } | |
140 | - </script> | |
141 | - | |
125 | + <script src="[% resource('common/wizefunc.js') %]"></script> | |
126 | + | |
142 | 127 | <script src="[% resource('common-spec/notice.js') %]"></script> |
143 | 128 | |
144 | - <script> | |
145 | - function testLogo() { | |
146 | - logo=document.getElementById("logoImgId"); | |
147 | - logodiv=document.getElementById("logoDivId"); | |
148 | - if (logo.naturalHeight == 0) { | |
149 | - logodiv.setAttribute("style","display:none;"); | |
150 | - } | |
151 | - } | |
152 | - </script> | |
153 | 129 | </head> |
154 | 130 | <body onload="testLogo()"> |
155 | - | |
131 | +<button onclick="topFunction()" id="upBtn" title="Go to top"></button> | |
156 | 132 | <!-- Header --> |
157 | 133 | <div class='header'> |
158 | 134 | <table class='navigation' style="float:left"> |
159 | 135 | <tr class='navigation'> |
160 | 136 | <td class='navigation'> |
161 | -<span style="font-size:30px;cursor:pointer;color: var(--main-header-color);" onclick="openNav()">☰</span> | |
137 | +<span style="font-size:30px;cursor:pointer;color: var(--main-header-color);" onclick="openNav(0)">☰</span> | |
162 | 138 | </td> |
163 | 139 | <td class='navigation'> |
164 | 140 | [% IF navigation.prev %] |
... | ... | @@ -291,6 +267,13 @@ |
291 | 267 | |
292 | 268 | <script src="[% resource('common/go-hljs.js') %]"></script> |
293 | 269 | <script>printNotice()</script> |
270 | +<script> | |
271 | +/* Get the button */ | |
272 | +var upButton = document.getElementById("upBtn"); | |
273 | + | |
274 | +/* When the user scrolls call our scrollFunction */ | |
275 | +window.onscroll = function() {scrollFunction()}; | |
276 | +</script> | |
294 | 277 | |
295 | 278 | </body> |
296 | 279 |
templates/html/Wize_with_index_sod.html
... | ... | @@ -118,6 +118,7 @@ |
118 | 118 | background: white; |
119 | 119 | } |
120 | 120 | |
121 | + | |
121 | 122 | </style> |
122 | 123 | |
123 | 124 | <!-- Themes clair : |
124 | 125 | |
125 | 126 | |
126 | 127 | |
... | ... | @@ -134,43 +135,19 @@ |
134 | 135 | <!-- hljs --> |
135 | 136 | <script src="[% resource('common/hljs/highlight.pack.js') %]"></script> |
136 | 137 | |
137 | - <script> | |
138 | - function openNav() { | |
139 | - if (document.getElementById("mySidenav").getAttribute("class").split(' ')[1] == "menuClosed") { | |
140 | - document.getElementById("mySidenav").style.width = "300px"; | |
141 | - document.getElementById("main").style.marginLeft = "300px"; | |
142 | - document.getElementById("mySidenav").setAttribute("class","menu menuOpen"); | |
143 | - /* Scroll to top when opening menu */ | |
144 | - document.body.scrollTop = 0 | |
145 | - document.documentElement.scrollTop = 0; | |
146 | - } else { | |
147 | - document.getElementById("mySidenav").style.width = "0"; | |
148 | - document.getElementById("main").style.marginLeft = "0"; | |
149 | - document.getElementById("mySidenav").setAttribute("class","menu menuClosed"); | |
150 | - } | |
151 | - } | |
152 | - </script> | |
138 | + <script src="[% resource('common/wizefunc.js') %]"></script> | |
153 | 139 | |
154 | 140 | <script src="[% resource('common-spec/notice.js') %]"></script> |
155 | 141 | |
156 | - <script> | |
157 | - function testLogo() { | |
158 | - logo=document.getElementById("logoImgId"); | |
159 | - logodiv=document.getElementById("logoDivId"); | |
160 | - if (logo.naturalHeight == 0) { | |
161 | - logodiv.setAttribute("style","display:none;"); | |
162 | - } | |
163 | - } | |
164 | - </script> | |
165 | 142 | </head> |
166 | 143 | <body onload="testLogo()"> |
167 | - | |
144 | +<button onclick="topFunction()" id="upBtn" title="Go to top"></button> | |
168 | 145 | <!-- Header --> |
169 | 146 | <div class='header'> |
170 | 147 | <table class='navigation' style="float:left"> |
171 | 148 | <tr class='navigation'> |
172 | 149 | <td class='navigation'> |
173 | -<span style="font-size:30px;cursor:pointer;color: var(--main-header-color);" onclick="openNav()">☰</span> | |
150 | +<span style="font-size:30px;cursor:pointer;color: var(--main-header-color);" onclick="openNav(1)">☰</span> | |
174 | 151 | </td> |
175 | 152 | <td class='navigation'> |
176 | 153 | [% IF navigation.prev %] |
... | ... | @@ -306,6 +283,13 @@ |
306 | 283 | |
307 | 284 | <script src="[% resource('common/go-hljs.js') %]"></script> |
308 | 285 | <script>printNotice()</script> |
286 | +<script> | |
287 | +/* Get the button */ | |
288 | +var upButton = document.getElementById("upBtn"); | |
289 | + | |
290 | +/* When the user scrolls call our scrollFunction */ | |
291 | +window.onscroll = function() {scrollFunction()}; | |
292 | +</script> | |
309 | 293 | |
310 | 294 | </body> |
311 | 295 |
templates/html/common/wizefunc.js
1 | + | |
2 | + /* Go to top of page */ | |
3 | + function topFunction() { | |
4 | + document.body.scrollTop = 0; | |
5 | + document.documentElement.scrollTop = 0; | |
6 | + } | |
7 | + | |
8 | + /* open/close navigation optionally slide page */ | |
9 | + function openNav(slide) { | |
10 | + if (document.getElementById("mySidenav").getAttribute("class").split(' ')[1] == "menuClosed") { | |
11 | + document.getElementById("mySidenav").style.width = "300px"; | |
12 | + if (slide==1) { | |
13 | + document.getElementById("main").style.marginLeft = "300px"; | |
14 | + } | |
15 | + document.getElementById("mySidenav").setAttribute("class","menu menuOpen"); | |
16 | + /* Scroll to top when opening menu */ | |
17 | + topFunction(); | |
18 | + } else { | |
19 | + document.getElementById("mySidenav").style.width = "0"; | |
20 | + if (slide==1) { | |
21 | + document.getElementById("main").style.marginLeft = "0"; | |
22 | + } | |
23 | + document.getElementById("mySidenav").setAttribute("class","menu menuClosed"); | |
24 | + } | |
25 | + } | |
26 | + | |
27 | + /* when scrolling down 20 pixel display upButton */ | |
28 | + function scrollFunction() { | |
29 | + if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { | |
30 | + upButton.style.display = "block"; | |
31 | + } else { | |
32 | + upButton.style.display = "none"; | |
33 | + } | |
34 | + } | |
35 | + | |
36 | + /* Test if the logo is present (to avoid displaying broken link icon on chrome) */ | |
37 | + function testLogo() { | |
38 | + logo=document.getElementById("logoImgId"); | |
39 | + logodiv=document.getElementById("logoDivId"); | |
40 | + if (logo.naturalHeight == 0) { | |
41 | + logodiv.setAttribute("style","display:none;"); | |
42 | + } | |
43 | + } |