Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
ndla-article-scripts
Advanced tools
A collection of functions for making article content responsive (and interactive)
A collection of functions for making article content responsive (and interactive)
$ npm install ndla-article-scripts
or
$ yarn add ndla-article-scripts
import {
addEventListenerForResize,
updateIFrameDimensions,
addAsideClickListener,
} from 'ndla-article-scripts';
window.onload = () => {
// Invoke after article content has loaded
updateIFrameDimensions();
addEventListenerForResize();
addAsideClickListener();
};
import {
addEventListenerForResize,
updateIFrameDimensions,
addAsideClickListener,
removeEventListenerForResize,
removeAsideClickListener,
} from 'ndla-article-scripts';
class Article extends Component {
componentDidMount() {
addEventListenerForResize();
updateIFrameDimensions();
addAsideClickListener();
}
componentWillUnmount() {
removeEventListenerForResize();
removeAsideClickListener();
}
render() {
const { article } = this.props;
return (
<article>
<h1>{article.title}</h1>
<div dangerouslySetInnerHTML={{ __html: article.content }} />
</article>
);
}
}
export default Article;
articleScripts.initArticleScripts()
Initialize all default article scripts.
articleScripts.updateIFrameDimensions()
Update iframe height and width to fit screen/window size.
articleScripts.addEventListenerForResize()
Adds an resize event listener on window. The listener calls updateIFrameDimensions
on browser window resize.
articleScripts.removeEventListenerForResize()
Removes the event listener added by addEventListenerForResize
.
articleScripts.addAsideClickListener()
Adds an click listener on aside buttons for expanding the content on small screens.
articleScripts.removeAsideClickListener()
Removes click listeners added by removeAsideClickListener
.
articleScripts.addShowDialogClickListeners()
Adds click listeners for displaying license info popup.
articleScripts.addCloseDialogClickListeners()
Adds click listeners for closing license info popups.
articleScripts.addCopyToClipboardListeners()
Add a click listener to buttons with a data-copy-string
. The value of the attribute will be copied to the clipboard on click.
articleScripts.makeFigureLicenseIconsClickable()
Adds click listeneres for displaying license text popup on license icon click
articleScripts.addEventListenersForZoom()
Adds click listners for zooming image/figure
Removes click listeners added by addEventListenersForZoom
.
FAQs
A collection of functions for making article content responsive (and interactive)
The npm package ndla-article-scripts receives a total of 17 weekly downloads. As such, ndla-article-scripts popularity was classified as not popular.
We found that ndla-article-scripts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.