@dotdev/limelight
Advanced tools
Comparing version 2.2.3 to 2.2.4
@@ -13,3 +13,3 @@ "use strict"; | ||
Limelight | ||
version v2.2.3 | ||
version v2.2.4 | ||
Author: George Butter | ||
@@ -72,3 +72,2 @@ https://github.com/ButsAndCats/limelight | ||
this.outerElement = this.element.querySelector(this.settings.outerSelector); | ||
this.closeElements = this.element.querySelectorAll('[data-close]'); | ||
this.target = target; | ||
@@ -116,3 +115,3 @@ | ||
Limelight.getTarget = function getTheLimelightElementRelatedToTheTarget(event) { | ||
var element = event.currentTarget; | ||
var element = event.elem || event.currentTarget; | ||
@@ -184,5 +183,5 @@ if (element.tagName === 'A') { | ||
function on(eventName, selector, fn) { | ||
document.body.addEventListener(eventName, function (event) { | ||
var possibleTargets = document.body.querySelectorAll(selector); | ||
function on(top, eventName, selector, fn) { | ||
top.addEventListener(eventName, function (event) { | ||
var possibleTargets = top.querySelectorAll(selector); | ||
var target = event.target; | ||
@@ -194,3 +193,3 @@ | ||
while (el && el !== document) { | ||
while (el && el !== top) { | ||
if (el === p) { | ||
@@ -224,9 +223,11 @@ event.preventDefault(); | ||
if (this.settings.click) { | ||
on('click', "[data-trigger][data-target=\"".concat(this.target, "\"]"), clickFunction); | ||
on(document.body, 'click', "[data-trigger][data-target=\"".concat(this.target, "\"]"), clickFunction); | ||
} | ||
if (this.settings.hover) { | ||
on('mouseenter', "[data-trigger][data-target=\"".concat(this.target, "\"]"), hoverFunction); | ||
on(document.body, 'mouseenter', "[data-trigger][data-target=\"".concat(this.target, "\"]"), hoverFunction); | ||
} | ||
on(this.element, 'click', '[data-close]', Limelight.closeEvent.bind(this)); | ||
if (this.settings.slide) { | ||
@@ -236,10 +237,2 @@ window.addEventListener('resize', function () { | ||
}); | ||
} // If the element is intialized visible then create an event listener for closing | ||
if (this.closeElements && this.settings.visible) { | ||
// When someone clicks the [data-close] button then we should close the modal | ||
for (var elem = 0; elem < this.closeElements.length; elem += 1) { | ||
this.closeElements[elem].addEventListener('click', Limelight.closeEvent.bind(this)); | ||
} | ||
} | ||
@@ -317,9 +310,2 @@ }; | ||
if (this.closeElements) { | ||
// When someone clicks the [data-close] button then we should close the modal | ||
for (var _elem = 0; _elem < this.closeElements.length; _elem += 1) { | ||
this.closeElements[_elem].addEventListener('click', Limelight.closeEvent.bind(this)); | ||
} | ||
} | ||
if (this.outerElement) { | ||
@@ -401,9 +387,2 @@ // When someone clicks on the inner class hide the popup | ||
if (this.closeElements) { | ||
// When someone clicks the [data-close] button then we should close the modal | ||
for (var _elem2 = 0; _elem2 < this.closeElements.length; _elem2 += 1) { | ||
this.closeElements[_elem2].addEventListener('click', Limelight.closeEvent.bind(this)); | ||
} | ||
} | ||
if (this.outerElement) { | ||
@@ -410,0 +389,0 @@ // When someone clicks on the inner class hide the popup |
/* ===================================================================================== @preserve = | ||
Limelight | ||
version v2.2.3 | ||
version v2.2.4 | ||
Author: George Butter | ||
@@ -63,3 +63,2 @@ https://github.com/ButsAndCats/limelight | ||
this.outerElement = this.element.querySelector(this.settings.outerSelector) | ||
this.closeElements = this.element.querySelectorAll('[data-close]') | ||
this.target = target | ||
@@ -105,3 +104,3 @@ | ||
Limelight.getTarget = function getTheLimelightElementRelatedToTheTarget (event) { | ||
const element = event.currentTarget | ||
const element = event.elem || event.currentTarget | ||
@@ -171,5 +170,5 @@ if (element.tagName === 'A') { | ||
Limelight.prototype.buildEventListeners = function bindLimelightEventListeners () { | ||
function on (eventName, selector, fn) { | ||
document.body.addEventListener(eventName, (event) => { | ||
const possibleTargets = document.body.querySelectorAll(selector) | ||
function on (top, eventName, selector, fn) { | ||
top.addEventListener(eventName, (event) => { | ||
const possibleTargets = top.querySelectorAll(selector) | ||
const target = event.target | ||
@@ -180,3 +179,3 @@ for (let i = 0, l = possibleTargets.length; i < l; i++) { | ||
while (el && el !== document) { | ||
while (el && el !== top) { | ||
if (el === p) { | ||
@@ -209,8 +208,9 @@ event.preventDefault() | ||
if (this.settings.click) { | ||
on('click', `[data-trigger][data-target="${this.target}"]`, clickFunction) | ||
on(document.body, 'click', `[data-trigger][data-target="${this.target}"]`, clickFunction) | ||
} | ||
if (this.settings.hover) { | ||
on('mouseenter', `[data-trigger][data-target="${this.target}"]`, hoverFunction) | ||
on(document.body, 'mouseenter', `[data-trigger][data-target="${this.target}"]`, hoverFunction) | ||
} | ||
on(this.element, 'click', '[data-close]', Limelight.closeEvent.bind(this)) | ||
@@ -220,10 +220,2 @@ if (this.settings.slide) { | ||
} | ||
// If the element is intialized visible then create an event listener for closing | ||
if (this.closeElements && this.settings.visible) { | ||
// When someone clicks the [data-close] button then we should close the modal | ||
for (let elem = 0; elem < this.closeElements.length; elem += 1) { | ||
this.closeElements[elem].addEventListener('click', Limelight.closeEvent.bind(this)) | ||
} | ||
} | ||
} | ||
@@ -294,9 +286,2 @@ | ||
if (this.closeElements) { | ||
// When someone clicks the [data-close] button then we should close the modal | ||
for (let elem = 0; elem < this.closeElements.length; elem += 1) { | ||
this.closeElements[elem].addEventListener('click', Limelight.closeEvent.bind(this)) | ||
} | ||
} | ||
if (this.outerElement) { | ||
@@ -374,9 +359,2 @@ // When someone clicks on the inner class hide the popup | ||
if (this.closeElements) { | ||
// When someone clicks the [data-close] button then we should close the modal | ||
for (let elem = 0; elem < this.closeElements.length; elem += 1) { | ||
this.closeElements[elem].addEventListener('click', Limelight.closeEvent.bind(this)) | ||
} | ||
} | ||
if (this.outerElement) { | ||
@@ -420,2 +398,2 @@ // When someone clicks on the inner class hide the popup | ||
export default Limelight | ||
export default Limelight |
@@ -57,3 +57,3 @@ { | ||
}, | ||
"version": "2.2.3" | ||
"version": "2.2.4" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38147
790