mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-23 02:10:01 +01:00
rewrite menu.js without jQuery
This commit is contained in:
parent
c031a063f0
commit
11dd15c584
@ -2,28 +2,21 @@
|
||||
|
||||
const krlcMenu = (() => { // eslint-disable-line no-unused-vars
|
||||
const _config = {
|
||||
thesite: $('.site'),
|
||||
thelink: $('.menu-btn'),
|
||||
thepop: $('.nav-popover')
|
||||
thesite: document.getElementsByClassName('site')[0],
|
||||
thelink: document.getElementsByClassName('menu-btn')[0],
|
||||
thepop: document.getElementsByClassName('nav-popover')[0]
|
||||
}
|
||||
|
||||
const _private = {
|
||||
toggleMenu() {
|
||||
_config.thelink.on('click', e => {
|
||||
_config.thelink.addEventListener('click', e => {
|
||||
e.preventDefault()
|
||||
|
||||
// Toggle menu
|
||||
_config.thesite.toggleClass('has-menu-open')
|
||||
|
||||
// Bind the hide controls
|
||||
$(document).bind('click.hidethepop', () => {
|
||||
_config.thesite.removeClass('has-menu-open')
|
||||
// Unbind the hide controls
|
||||
$(document).unbind('click.hidethepop')
|
||||
})
|
||||
_config.thesite.classList.toggle('has-menu-open')
|
||||
|
||||
// Dont close thepop when you click on thepop
|
||||
_config.thepop.on('click', e => {
|
||||
_config.thepop.addEventListener('click', e => {
|
||||
e.stopPropagation()
|
||||
})
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
// Init jQuery-based modules
|
||||
//
|
||||
$(document).ready(() => {
|
||||
krlcMenu.init()
|
||||
krlcSearch.init()
|
||||
})
|
||||
|
||||
@ -24,6 +23,7 @@ $(document).ready(() => {
|
||||
//
|
||||
// Init js modules
|
||||
//
|
||||
krlcMenu.init()
|
||||
krlcModals.init()
|
||||
|
||||
svg4everybody({
|
||||
|
@ -1,7 +1,7 @@
|
||||
<script src="/assets/js/kremalicious3.min.js" async></script>
|
||||
|
||||
{% if page.js %}
|
||||
<script src="/assets/js/{{ page.js }}"></script>
|
||||
<script src="/assets/js/{{ page.js }}" async></script>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
@ -213,8 +213,8 @@ export const criticalCss = done => {
|
||||
//
|
||||
export const js = () =>
|
||||
src([
|
||||
SRC + '/_assets/js/kremalicious3.js',
|
||||
SRC + '/_assets/js/analytics.js',
|
||||
SRC + '/_assets/js/*.js',
|
||||
'!' + SRC + '/_assets/js/_*.js',
|
||||
'node_modules/picturefill/dist/picturefill.js'
|
||||
])
|
||||
.pipe($.sourcemaps.init())
|
||||
|
Loading…
Reference in New Issue
Block a user