Creates simple js file to show how to add js to a theme
This commit is contained in:
@@ -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 }}
|
{{ content }}
|
||||||
|
|
||||||
|
<script src="/js/scripts.js" type="text/javascript"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user