Skip to content

Commit

Permalink
Merge pull request #132 from Financial-Times/fix-exports-issue
Browse files Browse the repository at this point in the history
Fix exports issue
  • Loading branch information
Nazehs authored Oct 16, 2023
2 parents 25d2d06 + b15050d commit 8b5fc4a
Show file tree
Hide file tree
Showing 10 changed files with 502 additions and 406 deletions.
322 changes: 229 additions & 93 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"main": "main.js",
"description": "Implementation for the syndication indicator, for users who subscribe to the new FT syndication platform",
"devDependencies": {
"@babel/runtime": "^7.10.2",
"@financial-times/eslint-config-next": "^7.0.0",
"@babel/runtime": "^7.23.1",
"@financial-times/eslint-config-next": "^7.1.0",
"@financial-times/n-gage": "^9.0.1",
"@financial-times/n-heroku-tools": "^14.0.0",
"@financial-times/n-heroku-tools": "^15.0.0",
"@financial-times/o-buttons": "^7.3.0",
"@financial-times/o-colors": "^6.4.2",
"@financial-times/o-icons": "^7.2.1",
Expand All @@ -19,8 +19,8 @@
"@sucrase/jest-plugin": "^3.0.0",
"autoprefixer": "^10.2.5",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-loader": "^8.0.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
Expand All @@ -29,20 +29,20 @@
"babel-preset-react": "^6.24.1",
"check-engine": "^1.10.1",
"eslint": "^8.0.1",
"extract-css-block-webpack-plugin": "^1.3.0",
"extract-text-webpack-plugin": "3.0.2",
"extract-css-block-webpack-plugin": "^1.3.1",
"extract-text-webpack-plugin": "^3.0.2",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"lintspaces-cli": "^0.6.0",
"sass-lint": "^1.13.1",
"snyk": "^1.167.2",
"webpack": "^3.1.0",
"webpack-merge": "^4.1.0",
"webpack-sources": "^1.4.3",
"webpack-stats-plugin": "^0.3.0"
"webpack": "^3.12.0",
"webpack-merge": "^5.9.0",
"webpack-sources": "^3.2.3",
"webpack-stats-plugin": "^1.1.3"
},
"dependencies": {
"next-session-client": "^4.0.0",
"next-session-client": "^5.0.0",
"superstore": "^2.1.0"
},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/js/data-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ function init (user, data = null) {

addEventListener(
'nSyndication.fetch',
(evt) => exports.refresh(evt.detail.response),
(evt) => refresh(evt.detail.response),
true
);

if (Array.isArray(data)) {
exports.refresh(data);
refresh(data);
}
}

Expand Down Expand Up @@ -89,7 +89,7 @@ function getItemByHTMLElement (el) {
const id = getContentIDFromHTMLElement(el);
const lang = getContentAttributeFromHTMLElement(el, 'data-iso-lang') || 'en';

return module.exports.getItemByID(id, lang);
return getItemByID(id, lang);
}

function getAllItemsForID (id) {
Expand Down
20 changes: 10 additions & 10 deletions src/js/iconify.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ function init (user) {
USER_DATA = user;
addEventListener(
'asyncContentLoaded',
() => exports.syndicate(),
() => syndicate(),
true
);
addEventListener(
'nSyndication.dataChanged',
() => exports.updatePage(),
() => updatePage(),
true
);

return exports.syndicate();
return syndicate();
}

function createElement (item) {
Expand Down Expand Up @@ -138,21 +138,21 @@ function getSyndicatableItemIDs (items) {
}

function syndicate () {
const ELEMENTS = exports.getSyndicatableItems();
const ELEMENTS = getSyndicatableItems();
const ITEM_IDS = getSyndicatableItemIDs(ELEMENTS);

const ITEM_IDS = exports.getSyndicatableItemIDs(ELEMENTS);

return fetchItems(ITEM_IDS);
}

function syndicateElement (item, el) {
const element = exports.findElementToSyndicate(el);
const element = findElementToSyndicate(el);

if (element !== null && element.getAttribute('data-syndicated') !== 'true') {
element.classList.add('n-syndication');
element.classList.add(`n-syndication-state-${item.canBeSyndicated}`);

prepend(element, exports.createElement(item));
prepend(element, createElement(item));

element.setAttribute('data-content-type', item.type);
element.setAttribute('data-syndicated', 'true');
Expand All @@ -169,12 +169,12 @@ function syndicateElements (item, els) {
return;
}

els.forEach((el) => exports.syndicateElement(item, el));
els.forEach((el) => syndicateElement(item, el));
}

function updatePage (els) {
if (!Array.isArray(els)) {
els = exports.getSyndicatableItems();
els = getSyndicatableItems();
}

const elementsByContentID = Array.from(els).reduce((acc, el) => {
Expand All @@ -190,7 +190,7 @@ function updatePage (els) {
}, {});

DATA_STORE.forEach((item) =>
exports.syndicateElements(item, elementsByContentID[item['id']])
syndicateElements(item, elementsByContentID[item['id']])
);

broadcast('nSyndication.iconified');
Expand Down
20 changes: 10 additions & 10 deletions src/js/modal-download.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const isDownloadPage = location.pathname.includes('/download');
const isSavePage = location.pathname.includes('/save');

function init (user) {
addEventListener('click', exports.actionModalFromClick, true);
addEventListener('click', actionModalFromClick, true);

addEventListener('keyup', exports.actionModalFromKeyboard, true);
addEventListener('keyup', actionModalFromKeyboard, true);
addEventListener('resize', overlayManager.reposition, true);

oViewport.listenTo('resize');
Expand All @@ -38,17 +38,17 @@ function actionModalFromClick (evt) {
const trackingEvent = createTrackingEvent(evt, item, overlayManager);

if (isSyndicationIcon(evt.target)) {
exports.show(evt);
show(evt);
} else if (isDownloadButton(evt.target)) {
evt.preventDefault();
exports.show(evt);
show(evt);
} else if (isSaveAction(evt.target)) {
exports.save(evt);
save(evt);
overlayManager.hideOverlay();
exports.show(evt);
show(evt);
overlayManager.delayModalHide();
} else if (isDownloadAction(evt.target)) {
exports.download(evt);
download(evt);
overlayManager.delayModalHide();
} else {
const isOverlayVisible = overlayManager.isOverlayVisible();
Expand Down Expand Up @@ -85,7 +85,7 @@ function actionModalFromKeyboard (evt) {
case ' ':
case 'Enter':
if (isSyndicationIcon(evt.target)) {
exports.show(evt);
show(evt);
}
break;
}
Expand Down Expand Up @@ -117,8 +117,8 @@ function isSaveDisabled (item) {

function createElement (item) {
try {
const disableDownloadButton = exports.isDownloadDisabled(item);
const disableSaveButton = exports.isSaveDisabled(item);
const disableDownloadButton = isDownloadDisabled(item);
const disableSaveButton = isSaveDisabled(item);
const downloadHref = disableDownloadButton
? '#'
: generateDownloadURI(item.id, item);
Expand Down
10 changes: 5 additions & 5 deletions src/js/modal-maintenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const localStore = new Superstore('local', 'syndication');
const overlayManager = new OverlayVisibilityManager();

function init (user) {
addEventListener('click', exports.actionModalFromClick, true);
addEventListener('click', actionModalFromClick, true);

addEventListener('keyup', exports.actionModalFromKeyboard, true);
addEventListener('keyup', actionModalFromKeyboard, true);
addEventListener('resize', overlayManager.reposition, true);

oViewport.listenTo('resize');
Expand All @@ -45,10 +45,10 @@ function actionModalFromClick (evt) {
const trackingEvent = createTrackingEvent(evt, item, overlayManager);

if (isSyndicationIcon(evt.target)) {
exports.show(evt);
show(evt);
}else if (isDownloadButton(evt.target)) {
evt.preventDefault();
exports.show(evt);
show(evt);
} else if (isSaveAction(evt.target)) {
overlayManager.delayModalHide();
} else {
Expand Down Expand Up @@ -85,7 +85,7 @@ function actionModalFromKeyboard (evt) {
case ' ':
case 'Enter':
if (isSyndicationIcon(evt.target)) {
exports.show(evt);
show(evt);
}

break;
Expand Down
Loading

0 comments on commit 8b5fc4a

Please sign in to comment.