@mjhls/mjh-framework 1.0.959-gridcontent-nojs-fix-v2 → 1.0.959-gridcontent-nojs-fix-v3

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.
@@ -87,7 +87,8 @@ var GridContent = function (_React$Component) {
87
87
  lgInfeedAd: _this.props.lgInfeedAd ? _this.props.lgInfeedAd : false,
88
88
  showCategory: _this.props.showCategory ? _this.props.showCategory : false,
89
89
  contentCategoryMapping: _this.props.contentCategoryMapping ? contentCategoryMapping : [],
90
- lastDataSize: _this.data ? _this.data.length : 0
90
+ lastDataSize: _this.data ? _this.data.length : 0,
91
+ dataRemapped: !_this.props.showBI || !_this.props.brandInsight
91
92
  }, _this.loadMore = debounce.debounce_1(function () {
92
93
  _this.setState(function (state) {
93
94
  var page = state.page,
@@ -115,6 +116,10 @@ var GridContent = function (_React$Component) {
115
116
  if (pageview && currentPath !== prevPath) {
116
117
  pageview(currentPath);
117
118
  }
119
+ // set dataRemap to true as there are no infeed or BI ads or window width is less than limit
120
+ if (typeof window !== 'undefined' && (!_this.props.lgInfeedAd || !_this.props.brandInsight || window.innerWidth < 1400) && !_this.state.dataRemapped) {
121
+ !_this.state.dataRemapped && _this.setState({ dataRemapped: true });
122
+ }
118
123
  }, _this.loadData = function () {
119
124
  var _this$state = _this.state,
120
125
  from = _this$state.from,
@@ -429,6 +434,7 @@ var GridContent = function (_React$Component) {
429
434
  });
430
435
 
431
436
  posts = lodash.lodash.flatten(chunks);
437
+ !this.state.dataRemapped && this.setState({ dataRemapped: true }); // To detect if appending of insights ads are completed
432
438
  }
433
439
 
434
440
  if (showBI) {
@@ -463,8 +469,6 @@ var GridContent = function (_React$Component) {
463
469
  posts = insert(posts, pos, inFeedAd);
464
470
  pos += brandInsight.interval + 1;
465
471
  }
466
- } else {
467
- posts = data;
468
472
  }
469
473
  posts = firstThree.concat(posts);
470
474
  } else {
@@ -496,6 +500,10 @@ var GridContent = function (_React$Component) {
496
500
  var itemsPerPage = this.props.params && this.props.params.itemsPerPage ? this.props.params.itemsPerPage : 10;
497
501
  var heroContent = this.props.heroContent ? this.props.heroContent : 0;
498
502
  var featureCount = 0;
503
+ if (!this.state.dataRemapped) {
504
+ //For Javascript Disabled Cases. data is not remapped if JS is disabled.
505
+ posts = this.state.data;
506
+ }
499
507
  return React__default['default'].createElement(
500
508
  'div',
501
509
  { className: 'grid-container' },
@@ -77,7 +77,8 @@ var GridContent = function (_React$Component) {
77
77
  lgInfeedAd: _this.props.lgInfeedAd ? _this.props.lgInfeedAd : false,
78
78
  showCategory: _this.props.showCategory ? _this.props.showCategory : false,
79
79
  contentCategoryMapping: _this.props.contentCategoryMapping ? contentCategoryMapping : [],
80
- lastDataSize: _this.data ? _this.data.length : 0
80
+ lastDataSize: _this.data ? _this.data.length : 0,
81
+ dataRemapped: !_this.props.showBI || !_this.props.brandInsight
81
82
  }, _this.loadMore = debounce_1(function () {
82
83
  _this.setState(function (state) {
83
84
  var page = state.page,
@@ -105,6 +106,10 @@ var GridContent = function (_React$Component) {
105
106
  if (pageview && currentPath !== prevPath) {
106
107
  pageview(currentPath);
107
108
  }
109
+ // set dataRemap to true as there are no infeed or BI ads or window width is less than limit
110
+ if (typeof window !== 'undefined' && (!_this.props.lgInfeedAd || !_this.props.brandInsight || window.innerWidth < 1400) && !_this.state.dataRemapped) {
111
+ !_this.state.dataRemapped && _this.setState({ dataRemapped: true });
112
+ }
108
113
  }, _this.loadData = function () {
109
114
  var _this$state = _this.state,
110
115
  from = _this$state.from,
@@ -419,6 +424,7 @@ var GridContent = function (_React$Component) {
419
424
  });
420
425
 
421
426
  posts = lodash.flatten(chunks);
427
+ !this.state.dataRemapped && this.setState({ dataRemapped: true }); // To detect if appending of insights ads are completed
422
428
  }
423
429
 
424
430
  if (showBI) {
@@ -453,8 +459,6 @@ var GridContent = function (_React$Component) {
453
459
  posts = insert(posts, pos, inFeedAd);
454
460
  pos += brandInsight.interval + 1;
455
461
  }
456
- } else {
457
- posts = data;
458
462
  }
459
463
  posts = firstThree.concat(posts);
460
464
  } else {
@@ -486,6 +490,10 @@ var GridContent = function (_React$Component) {
486
490
  var itemsPerPage = this.props.params && this.props.params.itemsPerPage ? this.props.params.itemsPerPage : 10;
487
491
  var heroContent = this.props.heroContent ? this.props.heroContent : 0;
488
492
  var featureCount = 0;
493
+ if (!this.state.dataRemapped) {
494
+ //For Javascript Disabled Cases. data is not remapped if JS is disabled.
495
+ posts = this.state.data;
496
+ }
489
497
  return React__default.createElement(
490
498
  'div',
491
499
  { className: 'grid-container' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.959-gridcontent-nojs-fix-v2",
3
+ "version": "1.0.959-gridcontent-nojs-fix-v3",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",