Created
February 26, 2018 21:37
-
-
Save brunopulis/0cf94943bd8da5c5fee7eee17481688e to your computer and use it in GitHub Desktop.
Module Modal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Spaguette | |
let jsSearch = $('.menu-item:nth-child(1)').find('.menu-link').addClass('js-search'); | |
let openMenu = $('.menu-item:nth-child(4)').find('.menu-link').addClass('js-link'); | |
let openSearch = $('.banner-index__link'); | |
let btnClose = $('.lightbox-close'); | |
jsSearch.on('click', function() { | |
$('.lightbox--search').addClass('lightbox--open'); | |
$('.lightbox--search').attr('aria-hidden', 'false'); | |
}); | |
openSearch.on('click', function() { | |
$('.lightbox--search').addClass('lightbox--open'); | |
$('.lightbox--search').attr('aria-hidden', 'false'); | |
}); | |
openMenu.on('click', function() { | |
$('.lightbox--nav').addClass('lightbox--open'); | |
$('.lightbox--nav').attr('aria-hidden', 'false'); | |
}); | |
btnClose.on('click', function(e) { | |
e.preventDefault(); | |
$('.lightbox--nav').removeClass('lightbox--open'); | |
$('.lightbox--search').removeClass('lightbox--open'); | |
}); | |
// Object Literal Pattern | |
var modal = { | |
cacheDOM: () => { | |
this.jsSearch = document.querySelector('.menu-item:nth-child(1)').find('.menu-link').addClass('js-search'); | |
let openMenu = $('.menu-item:nth-child(4)').find('.menu-link').addClass('js-link'); | |
let openSearch = $('.banner-index__link'); | |
let btnClose = $('.lightbox-close'); | |
}, | |
render: () => { | |
}, | |
bindEvents: () => { | |
this.$btnClose.close(this.close.bind()); | |
}, | |
show: () => { | |
$('.lightbox--nav').addClass('lightbox--open'); | |
$('.lightbox--nav').attr('aria-hidden', 'false'); | |
}, | |
close: (e) => { | |
e.preventDefault(); | |
$('.lightbox--nav').removeClass('lightbox--open'); | |
$('.lightbox--search').removeClass('lightbox--open'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment