mirror of
https://github.com/biobulkbende/biobulkbende.org.git
synced 2024-12-28 13:55:24 +00:00
39 lines
721 B
JavaScript
39 lines
721 B
JavaScript
import $ from 'jquery';
|
|
|
|
class Modal {
|
|
constructor(){
|
|
this.openModalButton = $(".open-modal");
|
|
this.modal = $(".modal");
|
|
this.closeModalButton = $(".modal__close");
|
|
this.events();
|
|
}
|
|
|
|
events(){
|
|
// clicking the open modal button
|
|
this.openModalButton.click(this.openModal.bind(this));
|
|
|
|
// clicking the x close modal button
|
|
this.closeModalButton.click(this.closeModal.bind(this));
|
|
|
|
// pushes any key
|
|
$(document).keyup(this.keyPressHandler.bind(this));
|
|
|
|
}
|
|
|
|
openModal() {
|
|
this.modal.addClass("modal--is-visible");
|
|
return false
|
|
}
|
|
|
|
closeModal() {
|
|
this.modal.removeClass("modal--is-visible");
|
|
}
|
|
|
|
keyPressHandler(e) {
|
|
if (e.keyCode == 27) {
|
|
this.closeModal();
|
|
}
|
|
}
|
|
}
|
|
|
|
export default Modal; |