Permalink
Browse files

Create new event to avoid warning in Jasmine

  • Loading branch information...
1 parent b98f88b commit 9ed213b437f09c06c13720e8df037d2021d6164d @Johann-S Johann-S committed Mar 7, 2016
Showing with 11 additions and 10 deletions.
  1. +11 −10 js/modals.js
View
@@ -9,14 +9,6 @@
!(function () {
'use strict';
- var eventModalOpen = new CustomEvent('modalOpen', {
- bubbles: true,
- cancelable: true
- });
- var eventModalClose = new CustomEvent('modalClose', {
- bubbles: true,
- cancelable: true
- });
var findModals = function (target) {
var i;
var modals = document.querySelectorAll('a');
@@ -40,9 +32,18 @@
window.addEventListener('touchend', function (event) {
var modal = getModal(event);
if (modal && modal.classList.contains('modal')) {
- var eventToDispatch = eventModalOpen;
+ var eventToDispatch = null;
if (modal.classList.contains('active')) {
- eventToDispatch = eventModalClose;
+ eventToDispatch = new CustomEvent('modalClose', {
+ bubbles: true,
+ cancelable: true
+ });
+ }
+ else {
+ eventToDispatch = new CustomEvent('modalOpen', {
+ bubbles: true,
+ cancelable: true
+ });
}
modal.dispatchEvent(eventToDispatch);
modal.classList.toggle('active');

0 comments on commit 9ed213b

Please sign in to comment.