@ndla/article-scripts
Advanced tools
Comparing version 0.5.5 to 0.5.6
import { updateIFrameDimensions } from './figureScripts'; | ||
import { forEachElement } from './domHelpers'; | ||
var toggleExploded = function toggleExploded(container, isOpen) { | ||
if (!isOpen) { | ||
container.classList.remove('c-details--exploded'); | ||
return; | ||
} | ||
var table = container.getElementsByTagName('table')[0]; | ||
var tbody = container.getElementsByTagName('tbody')[0]; | ||
if (!table || !tbody) { | ||
return; | ||
} | ||
var tbodyWidth = tbody.getBoundingClientRect().width; | ||
var tableWidth = table.getBoundingClientRect().width; | ||
if (tbodyWidth > tableWidth) { | ||
container.classList.add('c-details--exploded'); | ||
} | ||
}; | ||
var eventListener = function eventListener(event) { | ||
if (event.currentTarget.getAttribute('open') !== null) { | ||
updateIFrameDimensions(false, event.currentTarget); | ||
toggleExploded(event.currentTarget, true); | ||
} else { | ||
toggleExploded(event.currentTarget, false); | ||
} | ||
@@ -8,0 +32,0 @@ }; |
@@ -12,5 +12,29 @@ "use strict"; | ||
var toggleExploded = function toggleExploded(container, isOpen) { | ||
if (!isOpen) { | ||
container.classList.remove('c-details--exploded'); | ||
return; | ||
} | ||
var table = container.getElementsByTagName('table')[0]; | ||
var tbody = container.getElementsByTagName('tbody')[0]; | ||
if (!table || !tbody) { | ||
return; | ||
} | ||
var tbodyWidth = tbody.getBoundingClientRect().width; | ||
var tableWidth = table.getBoundingClientRect().width; | ||
if (tbodyWidth > tableWidth) { | ||
container.classList.add('c-details--exploded'); | ||
} | ||
}; | ||
var eventListener = function eventListener(event) { | ||
if (event.currentTarget.getAttribute('open') !== null) { | ||
(0, _figureScripts.updateIFrameDimensions)(false, event.currentTarget); | ||
toggleExploded(event.currentTarget, true); | ||
} else { | ||
toggleExploded(event.currentTarget, false); | ||
} | ||
@@ -17,0 +41,0 @@ }; |
{ | ||
"name": "@ndla/article-scripts", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "A collection of functions for making article content responsive (and interactive)", | ||
@@ -30,3 +30,3 @@ "license": "GPL-3.0", | ||
}, | ||
"gitHead": "84b8002661e3569d84ef1d57fc5e57cf2fe6f062" | ||
"gitHead": "9cff94cd0afa90d567e46b80fd3da25a979978cf" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
109105
1745
1