@ndla/article-scripts
Advanced tools
Comparing version 2.1.0 to 2.1.1-alpha.20
@@ -9,2 +9,3 @@ /** | ||
import { copyTextToClipboard } from '@ndla/util'; | ||
import jump from 'jump.js'; | ||
import { forEachElement } from './domHelpers'; | ||
@@ -116,3 +117,29 @@ export var toggleLicenseInfoBox = function toggleLicenseInfoBox() { | ||
}; | ||
export var addEventListenerForNotionExpandButton = function addEventListenerForNotionExpandButton() { | ||
forEachElement('button[data-notion-expand-media]', function (el) { | ||
var target = el; | ||
target.onclick = function () { | ||
var id = target.getAttribute('data-notion-media-id'); | ||
var media = document.getElementById(id); | ||
if (media && target.dataset.expanded) { | ||
media.classList.remove('expanded'); | ||
media.classList.add('fadeOut'); | ||
target.classList.remove("expanded"); | ||
delete target.dataset.expanded; | ||
} else if (media) { | ||
target.classList.add("expanded"); | ||
media.classList.add('expanded'); | ||
media.classList.remove('fadeOut'); | ||
target.dataset.expanded = true; | ||
jump(media, { | ||
duration: 300, | ||
offset: -150 | ||
}); | ||
} | ||
}; | ||
}); | ||
}; | ||
var handler = function handler() { | ||
@@ -119,0 +146,0 @@ return updateIFrameDimensions(false); |
@@ -10,3 +10,3 @@ /** | ||
import { addFilelistTooltipListners } from './fileListScript'; | ||
import { addCopyToClipboardListeners, updateIFrameDimensions, addEventListenerForResize, removeEventListenerForResize, toggleLicenseInfoBox, addEventListenerForFigureZoomButton } from './figureScripts'; | ||
import { addCopyToClipboardListeners, updateIFrameDimensions, addEventListenerForResize, removeEventListenerForResize, toggleLicenseInfoBox, addEventListenerForFigureZoomButton, addEventListenerForNotionExpandButton } from './figureScripts'; | ||
import { addShowDialogClickListeners, removeShowDialogClickListeners, addCloseDialogClickListeners } from './dialogScripts'; | ||
@@ -38,3 +38,4 @@ import { addToggleAlternativeVideoListener } from './alternativeVideoPlugin'; | ||
addEventListenerForFigureZoomButton(); | ||
addEventListenerForNotionExpandButton(); | ||
}; | ||
export { initTableScript, removeTableEventListeners, updateIFrameDimensions, addFactBoxClickListener, removeFactBoxClickListener, addEventListenerForResize, removeEventListenerForResize, addCloseDialogClickListeners, addCopyToClipboardListeners, addShowConceptDefinitionClickListeners, addShowDialogClickListeners, addToggleAlternativeVideoListener, removeShowDialogClickListeners, addDetailsEventListeners, removeDetailsEventListeners, addFootnoteClickListeners, toggleLicenseInfoBox, toggleRelatedArticles, addFilelistTooltipListners, initArticleTabs, addEventListenerForFigureZoomButton }; | ||
export { initTableScript, removeTableEventListeners, updateIFrameDimensions, addFactBoxClickListener, removeFactBoxClickListener, addEventListenerForResize, removeEventListenerForResize, addCloseDialogClickListeners, addCopyToClipboardListeners, addShowConceptDefinitionClickListeners, addShowDialogClickListeners, addToggleAlternativeVideoListener, removeShowDialogClickListeners, addDetailsEventListeners, removeDetailsEventListeners, addFootnoteClickListeners, toggleLicenseInfoBox, toggleRelatedArticles, addFilelistTooltipListners, initArticleTabs, addEventListenerForFigureZoomButton, addEventListenerForNotionExpandButton }; |
@@ -6,8 +6,12 @@ "use strict"; | ||
}); | ||
exports.removeEventListenerForResize = exports.addEventListenerForResize = exports.addEventListenerForFigureZoomButton = exports.updateIFrameDimensions = exports.addCopyToClipboardListeners = exports.toggleLicenseInfoBox = void 0; | ||
exports.removeEventListenerForResize = exports.addEventListenerForResize = exports.addEventListenerForNotionExpandButton = exports.addEventListenerForFigureZoomButton = exports.updateIFrameDimensions = exports.addCopyToClipboardListeners = exports.toggleLicenseInfoBox = void 0; | ||
var _util = require("@ndla/util"); | ||
var _jump = _interopRequireDefault(require("jump.js")); | ||
var _domHelpers = require("./domHelpers"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
/** | ||
@@ -137,2 +141,31 @@ * Copyright (c) 2016-present, NDLA. | ||
var addEventListenerForNotionExpandButton = function addEventListenerForNotionExpandButton() { | ||
(0, _domHelpers.forEachElement)('button[data-notion-expand-media]', function (el) { | ||
var target = el; | ||
target.onclick = function () { | ||
var id = target.getAttribute('data-notion-media-id'); | ||
var media = document.getElementById(id); | ||
if (media && target.dataset.expanded) { | ||
media.classList.remove('expanded'); | ||
media.classList.add('fadeOut'); | ||
target.classList.remove("expanded"); | ||
delete target.dataset.expanded; | ||
} else if (media) { | ||
target.classList.add("expanded"); | ||
media.classList.add('expanded'); | ||
media.classList.remove('fadeOut'); | ||
target.dataset.expanded = true; | ||
(0, _jump["default"])(media, { | ||
duration: 300, | ||
offset: -150 | ||
}); | ||
} | ||
}; | ||
}); | ||
}; | ||
exports.addEventListenerForNotionExpandButton = addEventListenerForNotionExpandButton; | ||
var handler = function handler() { | ||
@@ -139,0 +172,0 @@ return updateIFrameDimensions(false); |
@@ -60,2 +60,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "addEventListenerForNotionExpandButton", { | ||
enumerable: true, | ||
get: function get() { | ||
return _figureScripts.addEventListenerForNotionExpandButton; | ||
} | ||
}); | ||
Object.defineProperty(exports, "addShowDialogClickListeners", { | ||
@@ -201,4 +207,5 @@ enumerable: true, | ||
(0, _figureScripts.addEventListenerForFigureZoomButton)(); | ||
(0, _figureScripts.addEventListenerForNotionExpandButton)(); | ||
}; | ||
exports.initArticleScripts = initArticleScripts; |
{ | ||
"name": "@ndla/article-scripts", | ||
"version": "2.1.0", | ||
"version": "2.1.1-alpha.20+22d4e1c49", | ||
"description": "A collection of functions for making article content responsive (and interactive)", | ||
@@ -22,3 +22,3 @@ "license": "GPL-3.0", | ||
"dependencies": { | ||
"@ndla/util": "^2.0.2", | ||
"@ndla/util": "^2.0.3-alpha.64+22d4e1c49", | ||
"focus-trap": "^6.7.3", | ||
@@ -31,3 +31,3 @@ "jump.js": "^1.0.2", | ||
}, | ||
"gitHead": "7d6db8f3945947b35bdbb3c38229dec942d43ec1" | ||
"gitHead": "22d4e1c498b4c967fa6463ce0a8b8ee3bbd2336e" | ||
} |
@@ -8,3 +8,3 @@ # ndla-article-scripts | ||
```sh | ||
$ npm install ndla-article-scripts | ||
npm install @ndla/article-scripts | ||
``` | ||
@@ -15,3 +15,3 @@ | ||
```sh | ||
$ yarn add ndla-article-scripts | ||
yarn add @ndla/article-scripts | ||
``` | ||
@@ -18,0 +18,0 @@ |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
107688
1714
2
1