Revision 4029:5121f80344cc,
1.4 KB
checked in by franck <carnet.franck.paul@…>, 6 years ago
(diff) |
Add aria attributes (expanded, label) into the button, thank's llune!
|
Line | |
---|
1 | /*global $, getData */ |
---|
2 | 'use strict'; |
---|
3 | |
---|
4 | const dotclear_berlin = getData('dotclear_berlin'); |
---|
5 | |
---|
6 | $('html').addClass('js'); |
---|
7 | // Show/Hide main menu |
---|
8 | $('.header__nav'). |
---|
9 | before(`<button id="hamburger" type="button" aria-label="${dotclear_berlin.navigation}" aria-expanded="false"></button>`). |
---|
10 | toggle(); |
---|
11 | $('#hamburger').click(function() { |
---|
12 | $(this).attr('aria-expanded', $(this).attr('aria-expanded') == "true" ? "false" : "true"); |
---|
13 | $(this).toggleClass('open'); |
---|
14 | $('.header__nav').toggle('easing'); |
---|
15 | }); |
---|
16 | // Show/Hide sidebar on small screens |
---|
17 | $('#main').prepend(`<button id="offcanvas-on" type="button"><span class="visually-hidden">${dotclear_berlin.show_menu}</span></button>`); |
---|
18 | $('#offcanvas-on').click(function() { |
---|
19 | const btn = $(`<button id="offcanvas-off" type="button"><span class="visually-hidden">${dotclear_berlin.hide_menu}</span></button>`); |
---|
20 | $('#wrapper').addClass('off-canvas'); |
---|
21 | $('#footer').addClass('off-canvas'); |
---|
22 | $('#sidebar').prepend(btn); |
---|
23 | btn.click(function(evt) { |
---|
24 | $('#wrapper').removeClass('off-canvas'); |
---|
25 | $('#footer').removeClass('off-canvas'); |
---|
26 | evt.target.remove(); |
---|
27 | }); |
---|
28 | }); |
---|
29 | $(document).ready(function() { |
---|
30 | // totop scroll |
---|
31 | $(window).scroll(function() { |
---|
32 | if ($(this).scrollTop() != 0) { |
---|
33 | $('#gotop').fadeIn(); |
---|
34 | } else { |
---|
35 | $('#gotop').fadeOut(); |
---|
36 | } |
---|
37 | }); |
---|
38 | $('#gotop').click(function(e) { |
---|
39 | $('body,html').animate({ |
---|
40 | scrollTop: 0 |
---|
41 | }, 800); |
---|
42 | e.preventDefault(); |
---|
43 | }); |
---|
44 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.