@mjhls/mjh-framework 1.0.449 → 1.0.451

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- # mjh-framework v. 1.0.449
2
+ # mjh-framework v. 1.0.451
3
3
 
4
4
  > Foundation Framework
5
5
 
@@ -143,7 +143,7 @@ var Article = function Article(props) {
143
143
  regionalPages = props.regionalPages,
144
144
  nationalPage = props.nationalPage,
145
145
  ISIContent = props.ISIContent,
146
- changeUrl = props.changeUrl,
146
+ onChangeArticle = props.onChangeArticle,
147
147
  shareOptions = props.shareOptions,
148
148
  cpModificationRequired = props.cpModificationRequired,
149
149
  authorPrefix = props.authorPrefix,
@@ -455,7 +455,7 @@ var Article = function Article(props) {
455
455
  id: 'article-' + title,
456
456
  onChange: function onChange(visible) {
457
457
  if (visible === 'top' || visible === 'bottom' || visible === 'small-top') {
458
- changeUrl(url, visible, meta);
458
+ onChangeArticle(url, visible, meta);
459
459
  }
460
460
  } },
461
461
  React__default.createElement(
@@ -798,38 +798,36 @@ var ArticleQueue = function ArticleQueue(props) {
798
798
  document.querySelector('meta[name="twitter:description"]').setAttribute('content', meta.shareSummary);
799
799
  };
800
800
 
801
- var changeUrl = function changeUrl(path, visibility, meta) {
801
+ var onChangeArticle = function onChangeArticle(path, visibility, meta) {
802
802
  var currentPath = window && window.location && window.location.pathname ? window.location.pathname.replace('/view/', '') : '';
803
803
  var newPath = '/view/' + path;
804
+
805
+ // Change URL and do other changes
806
+ var doChanges = function doChanges() {
807
+ window.history.pushState({ page: path }, meta.shareTitle, newPath);
808
+ changeMeta(meta);
809
+ if (props.setCustomDimensions) {
810
+ var activeArticle = queueData.find(function (item) {
811
+ return item.url.current === path;
812
+ });
813
+ props.setCustomDimensions(activeArticle, '200', prevUrl);
814
+ }
815
+ if (props.pageview) props.pageview(newPath);
816
+ refreshAD(path);
817
+ };
818
+
804
819
  if (currentPath !== path) {
805
820
  if (isScrollDown) {
806
821
  if (visibility === 'top') {
807
- // router.push('/view/[url]', newPath, { shallow: true })
808
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
809
- changeMeta(meta);
810
- if (props.pageview) {
811
- props.pageview(newPath);
812
- }
813
- refreshAD(path);
822
+ doChanges();
814
823
  }
815
824
  } else {
816
825
  if (visibility === 'bottom') {
817
- // router.push('/view/[url]', newPath, { shallow: true })
818
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
819
- changeMeta(meta);
820
- if (props.pageview) {
821
- props.pageview(newPath);
822
- }
823
- refreshAD(path);
826
+ doChanges();
824
827
  }
825
828
  }
826
829
  if (visibility === 'small-top') {
827
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
828
- changeMeta(meta);
829
- if (props.pageview) {
830
- props.pageview(newPath);
831
- }
832
- refreshAD(path);
830
+ doChanges();
833
831
  }
834
832
  }
835
833
  };
@@ -847,7 +845,7 @@ var ArticleQueue = function ArticleQueue(props) {
847
845
  return React__default.createElement(Article, _extends._extends({
848
846
  key: index
849
847
  }, props, {
850
- changeUrl: changeUrl,
848
+ onChangeArticle: onChangeArticle,
851
849
  authorPrfix: authorPrefix,
852
850
  article: article,
853
851
  cpModificationRequired: cpModificationRequired,
package/dist/cjs/View.js CHANGED
@@ -57,7 +57,7 @@ var getSerializers = require('./getSerializers.js');
57
57
  require('./util-f2c1b65b.js');
58
58
  require('react-bootstrap/Pagination');
59
59
  require('next/dynamic');
60
- var getTargeting = require('./getTargeting-37612527.js');
60
+ var getTargeting = require('./getTargeting-ec7dd217.js');
61
61
  var urlFor = require('./urlFor.js');
62
62
 
63
63
  var renderAuthor = function renderAuthor(authorName, authorURL, index, length) {
@@ -264,7 +264,7 @@ var Article = function Article(props) {
264
264
  shareOptions = props.shareOptions,
265
265
  cpModificationRequired = props.cpModificationRequired,
266
266
  authorPrefix = props.authorPrefix;
267
- var changeUrl = props.changeUrl;
267
+ var onChangeArticle = props.onChangeArticle;
268
268
 
269
269
  var _useState = React.useState(null),
270
270
  _useState2 = slicedToArray._slicedToArray(_useState, 2),
@@ -600,7 +600,7 @@ var Article = function Article(props) {
600
600
  shareVia: props.Settings.title
601
601
  };
602
602
  if (!props.infiniteScroll) {
603
- changeUrl = function changeUrl() {
603
+ onChangeArticle = function onChangeArticle() {
604
604
  return null;
605
605
  };
606
606
  }
@@ -616,7 +616,7 @@ var Article = function Article(props) {
616
616
  id: 'article-' + title,
617
617
  onChange: function onChange(visible) {
618
618
  if (visible === 'top' || visible === 'bottom' || visible === 'small-top') {
619
- changeUrl(url, visible, meta);
619
+ onChangeArticle(url, visible, meta);
620
620
  }
621
621
  } },
622
622
  React__default.createElement(
@@ -963,38 +963,36 @@ var ArticleQueue = function ArticleQueue(props) {
963
963
  document.querySelector('meta[name="twitter:description"]').setAttribute('content', meta.shareSummary);
964
964
  };
965
965
 
966
- var changeUrl = function changeUrl(path, visibility, meta) {
966
+ var onChangeArticle = function onChangeArticle(path, visibility, meta) {
967
967
  var currentPath = window && window.location && window.location.pathname ? window.location.pathname.replace('/view/', '') : '';
968
968
  var newPath = '/view/' + path;
969
+
970
+ // Change URL and do other changes
971
+ var doChanges = function doChanges() {
972
+ window.history.pushState({ page: path }, meta.shareTitle, newPath);
973
+ changeMeta(meta);
974
+ if (props.setCustomDimensions) {
975
+ var activeArticle = queueData.find(function (item) {
976
+ return item.url.current === path;
977
+ });
978
+ props.setCustomDimensions(activeArticle, '200', prevUrl);
979
+ }
980
+ if (props.pageview) props.pageview(newPath);
981
+ refreshAD(path);
982
+ };
983
+
969
984
  if (currentPath !== path) {
970
985
  if (isScrollDown) {
971
986
  if (visibility === 'top') {
972
- // router.push('/view/[url]', newPath, { shallow: true })
973
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
974
- changeMeta(meta);
975
- if (props.pageview) {
976
- props.pageview(newPath);
977
- }
978
- refreshAD(path);
987
+ doChanges();
979
988
  }
980
989
  } else {
981
990
  if (visibility === 'bottom') {
982
- // router.push('/view/[url]', newPath, { shallow: true })
983
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
984
- changeMeta(meta);
985
- if (props.pageview) {
986
- props.pageview(newPath);
987
- }
988
- refreshAD(path);
991
+ doChanges();
989
992
  }
990
993
  }
991
994
  if (visibility === 'small-top') {
992
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
993
- changeMeta(meta);
994
- if (props.pageview) {
995
- props.pageview(newPath);
996
- }
997
- refreshAD(path);
995
+ doChanges();
998
996
  }
999
997
  }
1000
998
  };
@@ -1009,7 +1007,7 @@ var ArticleQueue = function ArticleQueue(props) {
1009
1007
  if (!checkSponseredArticle(article) && Ads.getNativeContextualAD) {
1010
1008
  article.contextualAD = Ads.getNativeContextualAD(getTargeting.getTargeting(props));
1011
1009
  }
1012
- return React__default.createElement(Article, _extends$1._extends({ key: index }, props, { changeUrl: changeUrl, authorPrfix: authorPrefix, article: article, cpModificationRequired: cpModificationRequired }));
1010
+ return React__default.createElement(Article, _extends$1._extends({ key: index }, props, { onChangeArticle: onChangeArticle, authorPrfix: authorPrefix, article: article, cpModificationRequired: cpModificationRequired }));
1013
1011
  })
1014
1012
  );
1015
1013
  };
@@ -52,6 +52,8 @@ var getTargeting = function getTargeting(props) {
52
52
  context = context && context.split('?')[0];
53
53
  context = context && context.split('&')[0];
54
54
  var content_placement_urls = [];
55
+ // New variable to store document group
56
+ var document_group_urls = [];
55
57
  if (content_placement && prevUrl && prevUrl.length) {
56
58
  content_placement.forEach(function (item) {
57
59
  var path = item.path;
@@ -70,21 +72,32 @@ var getTargeting = function getTargeting(props) {
70
72
  });
71
73
  }
72
74
 
73
- if (content_placement) {
74
- if (content_placement_urls.length === 0) {
75
- content_placement_urls = content_placement.map(function (item) {
76
- return cpModificationRequired ? getContentPlacementUrl(item) : item.path;
77
- });
75
+ // Comparing document group with previous url to store in 'document_group_urls'.
76
+ if (document_group && prevUrl && prevUrl.length) {
77
+ var previous_url_to_check = prevUrl;
78
+ if (prevUrl.includes('?')) {
79
+ previous_url_to_check = prevUrl.split('?')[0];
78
80
  }
79
- } else {
80
- content_placement_urls = ['/'];
81
+
82
+ if (previous_url_to_check.endsWith(document_group)) {
83
+ document_group_urls.push(document_group);
84
+ }
85
+ }
86
+
87
+ // Updating condition to set content_placement only when 'document_group_urls' and 'content_placement_urls' is empty.
88
+ if (content_placement && content_placement_urls.length === 0 && document_group_urls.length === 0) {
89
+ content_placement_urls = content_placement.map(function (item) {
90
+ return cpModificationRequired ? getContentPlacementUrl(item) : item.path;
91
+ });
81
92
  }
93
+
82
94
  var articleKeywords = [].concat(toConsumableArray._toConsumableArray(internalTag), toConsumableArray._toConsumableArray(userDefinedTag), toConsumableArray._toConsumableArray(SponsorshipTag), toConsumableArray._toConsumableArray(seoTag));
83
95
  var targeting = {
84
96
  tags: articleKeywords,
85
- document_group: [document_group],
97
+ // making sure either 'document_group' or 'content_placement' is returned in targeting.
98
+ document_group: content_placement_urls && content_placement_urls.length ? '' : document_group_urls,
86
99
  document_url: [url],
87
- content_placement: content_placement_urls
100
+ content_placement: document_group_urls && document_group_urls.length ? '' : content_placement_urls
88
101
  };
89
102
 
90
103
  if (article.issue && article.issue.path) {
@@ -8,7 +8,7 @@ require('./from-ea347372.js');
8
8
  require('./toConsumableArray-ca04303b.js');
9
9
  require('./_object-pie-68c5bcbc.js');
10
10
  require('./extends-60837c34.js');
11
- var getTargeting = require('./getTargeting-37612527.js');
11
+ var getTargeting = require('./getTargeting-ec7dd217.js');
12
12
 
13
13
 
14
14
 
package/dist/cjs/index.js CHANGED
@@ -157,7 +157,7 @@ require('swr');
157
157
  require('passport-local');
158
158
  require('mysql');
159
159
  var View = require('./View.js');
160
- var getTargeting = require('./getTargeting-37612527.js');
160
+ var getTargeting = require('./getTargeting-ec7dd217.js');
161
161
  var urlFor = require('./urlFor.js');
162
162
  var getKeywords = require('./getKeywords.js');
163
163
  var getQuery = require('./getQuery.js');
@@ -138,7 +138,7 @@ var Article = function Article(props) {
138
138
  regionalPages = props.regionalPages,
139
139
  nationalPage = props.nationalPage,
140
140
  ISIContent = props.ISIContent,
141
- changeUrl = props.changeUrl,
141
+ onChangeArticle = props.onChangeArticle,
142
142
  shareOptions = props.shareOptions,
143
143
  cpModificationRequired = props.cpModificationRequired,
144
144
  authorPrefix = props.authorPrefix,
@@ -450,7 +450,7 @@ var Article = function Article(props) {
450
450
  id: 'article-' + title,
451
451
  onChange: function onChange(visible) {
452
452
  if (visible === 'top' || visible === 'bottom' || visible === 'small-top') {
453
- changeUrl(url, visible, meta);
453
+ onChangeArticle(url, visible, meta);
454
454
  }
455
455
  } },
456
456
  React__default.createElement(
@@ -793,38 +793,36 @@ var ArticleQueue = function ArticleQueue(props) {
793
793
  document.querySelector('meta[name="twitter:description"]').setAttribute('content', meta.shareSummary);
794
794
  };
795
795
 
796
- var changeUrl = function changeUrl(path, visibility, meta) {
796
+ var onChangeArticle = function onChangeArticle(path, visibility, meta) {
797
797
  var currentPath = window && window.location && window.location.pathname ? window.location.pathname.replace('/view/', '') : '';
798
798
  var newPath = '/view/' + path;
799
+
800
+ // Change URL and do other changes
801
+ var doChanges = function doChanges() {
802
+ window.history.pushState({ page: path }, meta.shareTitle, newPath);
803
+ changeMeta(meta);
804
+ if (props.setCustomDimensions) {
805
+ var activeArticle = queueData.find(function (item) {
806
+ return item.url.current === path;
807
+ });
808
+ props.setCustomDimensions(activeArticle, '200', prevUrl);
809
+ }
810
+ if (props.pageview) props.pageview(newPath);
811
+ refreshAD(path);
812
+ };
813
+
799
814
  if (currentPath !== path) {
800
815
  if (isScrollDown) {
801
816
  if (visibility === 'top') {
802
- // router.push('/view/[url]', newPath, { shallow: true })
803
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
804
- changeMeta(meta);
805
- if (props.pageview) {
806
- props.pageview(newPath);
807
- }
808
- refreshAD(path);
817
+ doChanges();
809
818
  }
810
819
  } else {
811
820
  if (visibility === 'bottom') {
812
- // router.push('/view/[url]', newPath, { shallow: true })
813
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
814
- changeMeta(meta);
815
- if (props.pageview) {
816
- props.pageview(newPath);
817
- }
818
- refreshAD(path);
821
+ doChanges();
819
822
  }
820
823
  }
821
824
  if (visibility === 'small-top') {
822
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
823
- changeMeta(meta);
824
- if (props.pageview) {
825
- props.pageview(newPath);
826
- }
827
- refreshAD(path);
825
+ doChanges();
828
826
  }
829
827
  }
830
828
  };
@@ -842,7 +840,7 @@ var ArticleQueue = function ArticleQueue(props) {
842
840
  return React__default.createElement(Article, _extends({
843
841
  key: index
844
842
  }, props, {
845
- changeUrl: changeUrl,
843
+ onChangeArticle: onChangeArticle,
846
844
  authorPrfix: authorPrefix,
847
845
  article: article,
848
846
  cpModificationRequired: cpModificationRequired,
package/dist/esm/View.js CHANGED
@@ -52,7 +52,7 @@ import getSerializers from './getSerializers.js';
52
52
  import './util-7700fc59.js';
53
53
  import 'react-bootstrap/Pagination';
54
54
  import 'next/dynamic';
55
- import { a as getContentPlacementUrl, g as getTargeting } from './getTargeting-8f4bd5db.js';
55
+ import { a as getContentPlacementUrl, g as getTargeting } from './getTargeting-02118961.js';
56
56
  import urlFor from './urlFor.js';
57
57
 
58
58
  var renderAuthor = function renderAuthor(authorName, authorURL, index, length) {
@@ -259,7 +259,7 @@ var Article = function Article(props) {
259
259
  shareOptions = props.shareOptions,
260
260
  cpModificationRequired = props.cpModificationRequired,
261
261
  authorPrefix = props.authorPrefix;
262
- var changeUrl = props.changeUrl;
262
+ var onChangeArticle = props.onChangeArticle;
263
263
 
264
264
  var _useState = useState(null),
265
265
  _useState2 = _slicedToArray(_useState, 2),
@@ -595,7 +595,7 @@ var Article = function Article(props) {
595
595
  shareVia: props.Settings.title
596
596
  };
597
597
  if (!props.infiniteScroll) {
598
- changeUrl = function changeUrl() {
598
+ onChangeArticle = function onChangeArticle() {
599
599
  return null;
600
600
  };
601
601
  }
@@ -611,7 +611,7 @@ var Article = function Article(props) {
611
611
  id: 'article-' + title,
612
612
  onChange: function onChange(visible) {
613
613
  if (visible === 'top' || visible === 'bottom' || visible === 'small-top') {
614
- changeUrl(url, visible, meta);
614
+ onChangeArticle(url, visible, meta);
615
615
  }
616
616
  } },
617
617
  React__default.createElement(
@@ -958,38 +958,36 @@ var ArticleQueue = function ArticleQueue(props) {
958
958
  document.querySelector('meta[name="twitter:description"]').setAttribute('content', meta.shareSummary);
959
959
  };
960
960
 
961
- var changeUrl = function changeUrl(path, visibility, meta) {
961
+ var onChangeArticle = function onChangeArticle(path, visibility, meta) {
962
962
  var currentPath = window && window.location && window.location.pathname ? window.location.pathname.replace('/view/', '') : '';
963
963
  var newPath = '/view/' + path;
964
+
965
+ // Change URL and do other changes
966
+ var doChanges = function doChanges() {
967
+ window.history.pushState({ page: path }, meta.shareTitle, newPath);
968
+ changeMeta(meta);
969
+ if (props.setCustomDimensions) {
970
+ var activeArticle = queueData.find(function (item) {
971
+ return item.url.current === path;
972
+ });
973
+ props.setCustomDimensions(activeArticle, '200', prevUrl);
974
+ }
975
+ if (props.pageview) props.pageview(newPath);
976
+ refreshAD(path);
977
+ };
978
+
964
979
  if (currentPath !== path) {
965
980
  if (isScrollDown) {
966
981
  if (visibility === 'top') {
967
- // router.push('/view/[url]', newPath, { shallow: true })
968
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
969
- changeMeta(meta);
970
- if (props.pageview) {
971
- props.pageview(newPath);
972
- }
973
- refreshAD(path);
982
+ doChanges();
974
983
  }
975
984
  } else {
976
985
  if (visibility === 'bottom') {
977
- // router.push('/view/[url]', newPath, { shallow: true })
978
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
979
- changeMeta(meta);
980
- if (props.pageview) {
981
- props.pageview(newPath);
982
- }
983
- refreshAD(path);
986
+ doChanges();
984
987
  }
985
988
  }
986
989
  if (visibility === 'small-top') {
987
- window.history.pushState({ page: path }, meta.shareTitle, newPath);
988
- changeMeta(meta);
989
- if (props.pageview) {
990
- props.pageview(newPath);
991
- }
992
- refreshAD(path);
990
+ doChanges();
993
991
  }
994
992
  }
995
993
  };
@@ -1004,7 +1002,7 @@ var ArticleQueue = function ArticleQueue(props) {
1004
1002
  if (!checkSponseredArticle(article) && Ads.getNativeContextualAD) {
1005
1003
  article.contextualAD = Ads.getNativeContextualAD(getTargeting(props));
1006
1004
  }
1007
- return React__default.createElement(Article, _extends({ key: index }, props, { changeUrl: changeUrl, authorPrfix: authorPrefix, article: article, cpModificationRequired: cpModificationRequired }));
1005
+ return React__default.createElement(Article, _extends({ key: index }, props, { onChangeArticle: onChangeArticle, authorPrfix: authorPrefix, article: article, cpModificationRequired: cpModificationRequired }));
1008
1006
  })
1009
1007
  );
1010
1008
  };
@@ -50,6 +50,8 @@ var getTargeting = function getTargeting(props) {
50
50
  context = context && context.split('?')[0];
51
51
  context = context && context.split('&')[0];
52
52
  var content_placement_urls = [];
53
+ // New variable to store document group
54
+ var document_group_urls = [];
53
55
  if (content_placement && prevUrl && prevUrl.length) {
54
56
  content_placement.forEach(function (item) {
55
57
  var path = item.path;
@@ -68,21 +70,32 @@ var getTargeting = function getTargeting(props) {
68
70
  });
69
71
  }
70
72
 
71
- if (content_placement) {
72
- if (content_placement_urls.length === 0) {
73
- content_placement_urls = content_placement.map(function (item) {
74
- return cpModificationRequired ? getContentPlacementUrl(item) : item.path;
75
- });
73
+ // Comparing document group with previous url to store in 'document_group_urls'.
74
+ if (document_group && prevUrl && prevUrl.length) {
75
+ var previous_url_to_check = prevUrl;
76
+ if (prevUrl.includes('?')) {
77
+ previous_url_to_check = prevUrl.split('?')[0];
76
78
  }
77
- } else {
78
- content_placement_urls = ['/'];
79
+
80
+ if (previous_url_to_check.endsWith(document_group)) {
81
+ document_group_urls.push(document_group);
82
+ }
83
+ }
84
+
85
+ // Updating condition to set content_placement only when 'document_group_urls' and 'content_placement_urls' is empty.
86
+ if (content_placement && content_placement_urls.length === 0 && document_group_urls.length === 0) {
87
+ content_placement_urls = content_placement.map(function (item) {
88
+ return cpModificationRequired ? getContentPlacementUrl(item) : item.path;
89
+ });
79
90
  }
91
+
80
92
  var articleKeywords = [].concat(_toConsumableArray(internalTag), _toConsumableArray(userDefinedTag), _toConsumableArray(SponsorshipTag), _toConsumableArray(seoTag));
81
93
  var targeting = {
82
94
  tags: articleKeywords,
83
- document_group: [document_group],
95
+ // making sure either 'document_group' or 'content_placement' is returned in targeting.
96
+ document_group: content_placement_urls && content_placement_urls.length ? '' : document_group_urls,
84
97
  document_url: [url],
85
- content_placement: content_placement_urls
98
+ content_placement: document_group_urls && document_group_urls.length ? '' : content_placement_urls
86
99
  };
87
100
 
88
101
  if (article.issue && article.issue.path) {
@@ -6,4 +6,4 @@ import './from-2c0a5f49.js';
6
6
  import './toConsumableArray-8712d678.js';
7
7
  import './_object-pie-33c40e79.js';
8
8
  import './extends-6e00b262.js';
9
- export { g as default } from './getTargeting-8f4bd5db.js';
9
+ export { g as default } from './getTargeting-02118961.js';
package/dist/esm/index.js CHANGED
@@ -153,7 +153,7 @@ import 'swr';
153
153
  import 'passport-local';
154
154
  import 'mysql';
155
155
  export { default as View } from './View.js';
156
- export { g as getTargeting } from './getTargeting-8f4bd5db.js';
156
+ export { g as getTargeting } from './getTargeting-02118961.js';
157
157
  export { default as urlFor } from './urlFor.js';
158
158
  export { default as getKeywords } from './getKeywords.js';
159
159
  export { default as getQuery } from './getQuery.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.449",
3
+ "version": "1.0.451",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",