Creates simple js file to show how to add js to a theme
This commit is contained in:
parent
fd169b2c01
commit
2c3cc33b1e
14
_includes/scripts.js
Normal file
14
_includes/scripts.js
Normal file
@ -0,0 +1,14 @@
|
||||
// Data attribute switch
|
||||
var toggleState = function (elem, one, two) {
|
||||
var elem = document.querySelector(elem);
|
||||
elem.setAttribute('data-state', elem.getAttribute('data-state') === one ? two : one);
|
||||
};
|
||||
|
||||
// Mobile navigation toggle selector
|
||||
var buttonMenu = document.querySelector('.button--nav');
|
||||
if (typeof(buttonMenu) != 'undefined' && buttonMenu != null) {
|
||||
buttonMenu.onclick = function (e) {
|
||||
toggleState('.nav', 'open', 'closed');
|
||||
e.preventDefault();
|
||||
};
|
||||
};
|
@ -17,5 +17,6 @@
|
||||
|
||||
{{ content }}
|
||||
|
||||
<script src="/js/scripts.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user