@adadapted/react-native-sdk 3.1.5 → 3.1.8
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/android/.project +18 -1
- package/android/.settings/org.eclipse.buildship.core.prefs +4 -4
- package/android/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkModule.kt +2 -2
- package/lib/commonjs/api/adadaptedApiRequests.mock.js +0 -20
- package/lib/commonjs/api/adadaptedApiRequests.mock.js.map +1 -1
- package/lib/commonjs/api/adadaptedApiTypes.js +0 -5
- package/lib/commonjs/api/adadaptedApiTypes.js.map +1 -1
- package/lib/commonjs/components/AdZone.js +10 -40
- package/lib/commonjs/components/AdZone.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/api/adadaptedApiRequests.mock.js +0 -20
- package/lib/module/api/adadaptedApiRequests.mock.js.map +1 -1
- package/lib/module/api/adadaptedApiTypes.js +0 -5
- package/lib/module/api/adadaptedApiTypes.js.map +1 -1
- package/lib/module/components/AdZone.js +10 -39
- package/lib/module/components/AdZone.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/api/adadaptedApiTypes.d.ts +0 -47
- package/lib/typescript/src/components/AdZone.d.ts +0 -4
- package/lib/typescript/src/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/api/adadaptedApiRequests.mock.ts +0 -20
- package/src/api/adadaptedApiTypes.ts +0 -48
- package/src/components/AdZone.tsx +13 -56
- package/src/index.tsx +1 -1
- package/lib/commonjs/components/AdPopup.js +0 -352
- package/lib/commonjs/components/AdPopup.js.map +0 -1
- package/lib/commonjs/components/AdPopup.test.js +0 -60
- package/lib/commonjs/components/AdPopup.test.js.map +0 -1
- package/lib/module/components/AdPopup.js +0 -339
- package/lib/module/components/AdPopup.js.map +0 -1
- package/lib/module/components/AdPopup.test.js +0 -50
- package/lib/module/components/AdPopup.test.js.map +0 -1
- package/lib/typescript/src/components/AdPopup.d.ts +0 -75
- package/lib/typescript/src/components/AdPopup.test.d.ts +0 -1
- package/src/components/AdPopup.test.tsx +0 -60
- package/src/components/AdPopup.tsx +0 -471
|
@@ -226,16 +226,6 @@ const AD_SESSION_DATA: AdSession = {
|
|
|
226
226
|
},
|
|
227
227
|
],
|
|
228
228
|
},
|
|
229
|
-
popup: {
|
|
230
|
-
title_text: "",
|
|
231
|
-
background_color: "",
|
|
232
|
-
text_color: "",
|
|
233
|
-
alt_close_btn: "",
|
|
234
|
-
type: "",
|
|
235
|
-
hide_banner: false,
|
|
236
|
-
hide_close_btn: false,
|
|
237
|
-
hide_browser_nav: false,
|
|
238
|
-
},
|
|
239
229
|
},
|
|
240
230
|
],
|
|
241
231
|
},
|
|
@@ -283,16 +273,6 @@ const REFRESHED_AD_SESSION_DATA: AdSession = {
|
|
|
283
273
|
},
|
|
284
274
|
],
|
|
285
275
|
},
|
|
286
|
-
popup: {
|
|
287
|
-
title_text: "",
|
|
288
|
-
background_color: "",
|
|
289
|
-
text_color: "",
|
|
290
|
-
alt_close_btn: "",
|
|
291
|
-
type: "",
|
|
292
|
-
hide_banner: false,
|
|
293
|
-
hide_close_btn: false,
|
|
294
|
-
hide_browser_nav: false,
|
|
295
|
-
},
|
|
296
276
|
},
|
|
297
277
|
],
|
|
298
278
|
},
|
|
@@ -106,10 +106,6 @@ export interface Ad {
|
|
|
106
106
|
* ?
|
|
107
107
|
*/
|
|
108
108
|
payload: AdPayload;
|
|
109
|
-
/**
|
|
110
|
-
* ?
|
|
111
|
-
*/
|
|
112
|
-
popup: AdPopup;
|
|
113
109
|
}
|
|
114
110
|
|
|
115
111
|
/**
|
|
@@ -194,44 +190,6 @@ export interface DetailedListItem {
|
|
|
194
190
|
tracking_id?: string;
|
|
195
191
|
}
|
|
196
192
|
|
|
197
|
-
/**
|
|
198
|
-
* The definition of an Ad Popup.
|
|
199
|
-
*/
|
|
200
|
-
export interface AdPopup {
|
|
201
|
-
/**
|
|
202
|
-
* ?
|
|
203
|
-
*/
|
|
204
|
-
alt_close_btn: string;
|
|
205
|
-
/**
|
|
206
|
-
* ?
|
|
207
|
-
*/
|
|
208
|
-
background_color: string;
|
|
209
|
-
/**
|
|
210
|
-
* ?
|
|
211
|
-
*/
|
|
212
|
-
hide_banner: boolean;
|
|
213
|
-
/**
|
|
214
|
-
* ?
|
|
215
|
-
*/
|
|
216
|
-
hide_browser_nav: boolean;
|
|
217
|
-
/**
|
|
218
|
-
* ?
|
|
219
|
-
*/
|
|
220
|
-
hide_close_btn: boolean;
|
|
221
|
-
/**
|
|
222
|
-
* ?
|
|
223
|
-
*/
|
|
224
|
-
text_color: string;
|
|
225
|
-
/**
|
|
226
|
-
* ?
|
|
227
|
-
*/
|
|
228
|
-
title_text: string;
|
|
229
|
-
/**
|
|
230
|
-
* ?
|
|
231
|
-
*/
|
|
232
|
-
type: string;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
193
|
/**
|
|
236
194
|
* The definition of a Keyword Intercepts object.
|
|
237
195
|
*/
|
|
@@ -426,16 +384,10 @@ export enum AdActionType {
|
|
|
426
384
|
EXTERNAL = "e",
|
|
427
385
|
/**
|
|
428
386
|
* Used for opening URLs in a web view within the app.
|
|
429
|
-
* Works the same as {@link AdActionType.POPUP}.
|
|
430
387
|
* NOTE: This one should probably be deprecated with the new
|
|
431
388
|
* platform redesign, since its not as obvious what it does.
|
|
432
389
|
*/
|
|
433
390
|
LINK = "l",
|
|
434
|
-
/**
|
|
435
|
-
* Used for opening URLs in a web view within the app.
|
|
436
|
-
* Works the same as {@link AdActionType.LINK}.
|
|
437
|
-
*/
|
|
438
|
-
POPUP = "p",
|
|
439
391
|
/**
|
|
440
392
|
* Used for opening app store URLs in the app store.
|
|
441
393
|
*/
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from "../api/adadaptedApiTypes";
|
|
15
15
|
import { WebView } from "react-native-webview";
|
|
16
16
|
import { ApiEnv, DeviceOS } from "../index";
|
|
17
|
-
import { AdPopup } from "./AdPopup";
|
|
18
17
|
import { safeInvoke } from "../util";
|
|
19
18
|
|
|
20
19
|
/**
|
|
@@ -69,10 +68,6 @@ interface State {
|
|
|
69
68
|
* Tracks the current ad index being shown.
|
|
70
69
|
*/
|
|
71
70
|
adIndexShown: number;
|
|
72
|
-
/**
|
|
73
|
-
* If true, the ad popup(if available) is open.
|
|
74
|
-
*/
|
|
75
|
-
isAdPopupOpen: boolean;
|
|
76
71
|
/**
|
|
77
72
|
* Tracks the coordinates when the user started touching the Ad View.
|
|
78
73
|
*/
|
|
@@ -130,7 +125,6 @@ export class AdZone extends React.Component<Props, State> {
|
|
|
130
125
|
|
|
131
126
|
this.state = {
|
|
132
127
|
adIndexShown: startingAdIndex,
|
|
133
|
-
isAdPopupOpen: false,
|
|
134
128
|
touchStartCoords: undefined,
|
|
135
129
|
};
|
|
136
130
|
}
|
|
@@ -214,20 +208,6 @@ export class AdZone extends React.Component<Props, State> {
|
|
|
214
208
|
}}
|
|
215
209
|
/>
|
|
216
210
|
) : undefined}
|
|
217
|
-
{currentAd && currentAd.creative_url ? (
|
|
218
|
-
<AdPopup
|
|
219
|
-
ad={currentAd}
|
|
220
|
-
isOpen={this.state.isAdPopupOpen}
|
|
221
|
-
onClose={() => {
|
|
222
|
-
this.setState({
|
|
223
|
-
isAdPopupOpen: false,
|
|
224
|
-
});
|
|
225
|
-
}}
|
|
226
|
-
onAddToListItemClicked={(item) => {
|
|
227
|
-
safeInvoke(this.props.onAddToListTriggered, [item]);
|
|
228
|
-
}}
|
|
229
|
-
/>
|
|
230
|
-
) : undefined}
|
|
231
211
|
</View>
|
|
232
212
|
);
|
|
233
213
|
}
|
|
@@ -244,15 +224,6 @@ export class AdZone extends React.Component<Props, State> {
|
|
|
244
224
|
) {
|
|
245
225
|
// Action Type: EXTERNAL
|
|
246
226
|
Linking.openURL(currentAd.action_path).then();
|
|
247
|
-
} else if (
|
|
248
|
-
(currentAd.action_type === AdActionType.POPUP ||
|
|
249
|
-
currentAd.action_type === AdActionType.LINK) &&
|
|
250
|
-
currentAd.action_path
|
|
251
|
-
) {
|
|
252
|
-
// Action Type: POPUP or LINK
|
|
253
|
-
this.setState({
|
|
254
|
-
isAdPopupOpen: true,
|
|
255
|
-
});
|
|
256
227
|
} else if (
|
|
257
228
|
currentAd.action_type === AdActionType.CONTENT &&
|
|
258
229
|
currentAd.payload &&
|
|
@@ -324,35 +295,21 @@ export class AdZone extends React.Component<Props, State> {
|
|
|
324
295
|
* Cycles to the next ad to display in the current available sequence of ads.
|
|
325
296
|
*/
|
|
326
297
|
private cycleDisplayedAd(): void {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
let nextAdIndex = 0;
|
|
330
|
-
|
|
331
|
-
if (
|
|
332
|
-
this.state.adIndexShown <
|
|
333
|
-
this.props.adZoneData.ads.length - 1
|
|
334
|
-
) {
|
|
335
|
-
nextAdIndex = this.state.adIndexShown + 1;
|
|
336
|
-
}
|
|
298
|
+
// Start by determining the next ad index to display.
|
|
299
|
+
let nextAdIndex = 0;
|
|
337
300
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
adIndexShown: nextAdIndex,
|
|
341
|
-
},
|
|
342
|
-
() => {
|
|
343
|
-
this.initializeAd();
|
|
344
|
-
}
|
|
345
|
-
);
|
|
346
|
-
} else {
|
|
347
|
-
// Create a new timer with a timer length of just 10 seconds.
|
|
348
|
-
// This will allow us to re-check if the popup is still open
|
|
349
|
-
// quicker and handle switching to the next ad sooner instead of
|
|
350
|
-
// just restarting the current timer. We do this, because we must
|
|
351
|
-
// maintain the current ad shown or the popup will cycle to the
|
|
352
|
-
// next ad while the user is actively engaged with it. Then when
|
|
353
|
-
// the user closes the popup, the ad will cycle to the next quickly.
|
|
354
|
-
this.createAdTimer(10000);
|
|
301
|
+
if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {
|
|
302
|
+
nextAdIndex = this.state.adIndexShown + 1;
|
|
355
303
|
}
|
|
304
|
+
|
|
305
|
+
this.setState(
|
|
306
|
+
{
|
|
307
|
+
adIndexShown: nextAdIndex,
|
|
308
|
+
},
|
|
309
|
+
() => {
|
|
310
|
+
this.initializeAd();
|
|
311
|
+
}
|
|
312
|
+
);
|
|
356
313
|
}
|
|
357
314
|
|
|
358
315
|
/**
|
package/src/index.tsx
CHANGED
|
@@ -294,7 +294,7 @@ export class AdadaptedReactNativeSdk {
|
|
|
294
294
|
private keywordIntercepts: KeywordIntercepts | undefined;
|
|
295
295
|
/**
|
|
296
296
|
* If provided, triggers when an "add to list" item is
|
|
297
|
-
* clicked in an ad zone
|
|
297
|
+
* clicked in an ad zone.
|
|
298
298
|
* @param items - The array of items to "add to list".
|
|
299
299
|
* @param isExternalPayload - If true, the items are from an external payload.
|
|
300
300
|
*/
|
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.AdPopup = void 0;
|
|
7
|
-
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _reactNativeWebview = require("react-native-webview");
|
|
11
|
-
|
|
12
|
-
var _reactNativeModal = _interopRequireDefault(require("react-native-modal"));
|
|
13
|
-
|
|
14
|
-
var _reactNative = require("react-native");
|
|
15
|
-
|
|
16
|
-
var _adadaptedApiTypes = require("../api/adadaptedApiTypes");
|
|
17
|
-
|
|
18
|
-
var _util = require("../util");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
23
|
-
|
|
24
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
-
|
|
26
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Creates the AdPopup component.
|
|
30
|
-
*/
|
|
31
|
-
class AdPopup extends React.Component {
|
|
32
|
-
/**
|
|
33
|
-
* The web view element reference.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @inheritDoc
|
|
38
|
-
*/
|
|
39
|
-
constructor(props, context) {
|
|
40
|
-
super(props, context);
|
|
41
|
-
|
|
42
|
-
_defineProperty(this, "webViewElementRef", null);
|
|
43
|
-
|
|
44
|
-
this.state = {
|
|
45
|
-
canGoBack: false,
|
|
46
|
-
canGoForward: false,
|
|
47
|
-
isPageLoading: true
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @inheritDoc
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
render() {
|
|
56
|
-
// Generate the styles each render in case the ad is updated with
|
|
57
|
-
// new settings that need to be reflected in the styles of the view.
|
|
58
|
-
const styles = this.generateStyles();
|
|
59
|
-
return /*#__PURE__*/React.createElement(_reactNativeModal.default, {
|
|
60
|
-
style: styles.mainView,
|
|
61
|
-
isVisible: this.props.isOpen,
|
|
62
|
-
hasBackdrop: false,
|
|
63
|
-
coverScreen: true
|
|
64
|
-
}, /*#__PURE__*/React.createElement(_reactNative.SafeAreaView, {
|
|
65
|
-
style: {
|
|
66
|
-
flex: 1
|
|
67
|
-
}
|
|
68
|
-
}, /*#__PURE__*/React.createElement(_reactNative.SafeAreaView, {
|
|
69
|
-
style: styles.navHeaderView
|
|
70
|
-
}, /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
71
|
-
style: styles.navArrowsContainer
|
|
72
|
-
}, /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
73
|
-
onTouchStart: () => {
|
|
74
|
-
if (this.webViewElementRef && this.state.canGoBack) {
|
|
75
|
-
this.webViewElementRef.goBack();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}, /*#__PURE__*/React.createElement(_reactNative.Image, {
|
|
79
|
-
source: {
|
|
80
|
-
uri: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABpUlEQVRoQ+2YvUrFQBBGZ59Hq8QXsLcVLCwsFBQUFBQUlHsFBQUFBQUFLSwsBB9C+/2m0ifxAUYCCinM5i47c83Cpgy7yznzzZAfR5lfLnN+KgL/nWBJoCSQWIHSQokFTN5eEogtYVVVY+fcAhF9icg7M49jz2ivn2oCP/CjFsAngNksBP6Ab7gBYG7wAh3wJCLHg2+hLngiOgJwklL9Zq/pDATgDwCcpcKbCgTg9wBcaMCbCQR6foeZr7TgTQS64J1zW977G014dYFA22wAuNOGVxUIwK8BeLCAVxMIwK8AeLKCVxEIDOwyMz9bwqsI1HX9QUQzbVARWWLmF2t4LQFPRHW2Atm3UFP5rIf4t3UCD7BV7/2j1TyovswFJNa99/cWEqoCoXYSkU1mvtWWUBfomYltANeaEiYCPRK7AC61JMwEeiT2AZxrSJgKhCScc4fe+9NUCXOBnsEe/kd9z3Min/9CHUm8AZhPaaOptFAbsKqqkXNusbknIq+D/y+UUt1J9k49gUmgYtYUgZhqWawtCVhUNebMkkBMtSzWlgQsqhpz5jfHSasx85A3NgAAAABJRU5ErkJggg=="
|
|
81
|
-
},
|
|
82
|
-
style: styles.navLeftArrow
|
|
83
|
-
})), /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
84
|
-
onTouchStart: () => {
|
|
85
|
-
if (this.webViewElementRef && this.state.canGoForward) {
|
|
86
|
-
this.webViewElementRef.goForward();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}, /*#__PURE__*/React.createElement(_reactNative.Image, {
|
|
90
|
-
source: {
|
|
91
|
-
uri: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABnklEQVRoQ+3YsUoEMRAG4H8ewCfRKpNeH0KwsLBQUFBQUFBQ8ERBQUFBQUELCwsLS3tfwFylzzOykAVZmz0yM+dCrs7O/d9Mwu2FMPAPDTw/KmDaE6wTqBMo7EDdQoUNLH68TiCEMCKieQAzIvI+Ho9HxW2doEDxBJj5C8Bs+50icuKJ0AB8AuDfTfNEFAPyFjruTt0LUQxogjPzEYDTaSBUABlxAODcG6EGyIg9AJeeCFVAEzyEsENE114IdUATPMa4JSK3HggTQN5OGwDurRFmgIxYA/BoiTAFZMQKgGcrhDkgH+xlInqxQLgAMmKJiF47iO+U0twE725/lk4bkFJK8d8DQgjD3ULMPNxDHGNcFZEni8Pb1jQ7AzHGdRF5sAzf1DYBhBA2iejOOrwJgJm3Adx4hFcHMPMugCuv8KoAZt4HcOEZXg0QYzwUkTPv8CqAwf+p794LNV3xupFQmQAzfwBYaLePZ3gVQN5Ci7nzb563ciqAkjdJjWdNfok1gvWtUQF9O2W1rk7AqrN969YJ9O2U1bo6AavO9q37A5jF5jGXG4ruAAAAAElFTkSuQmCC"
|
|
92
|
-
},
|
|
93
|
-
style: styles.navRightArrow
|
|
94
|
-
}))), /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
95
|
-
style: styles.navBarTitleView
|
|
96
|
-
}, /*#__PURE__*/React.createElement(_reactNative.Text, {
|
|
97
|
-
style: styles.titleText,
|
|
98
|
-
numberOfLines: 1,
|
|
99
|
-
ellipsizeMode: "tail"
|
|
100
|
-
}, this.props.ad.popup.title_text)), /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
101
|
-
style: styles.loadingIndicatorContainer
|
|
102
|
-
}, this.state.isPageLoading ? /*#__PURE__*/React.createElement(_reactNative.ActivityIndicator, {
|
|
103
|
-
size: "large",
|
|
104
|
-
color: "#2969a0"
|
|
105
|
-
}) : undefined)), /*#__PURE__*/React.createElement(_reactNativeWebview.WebView, {
|
|
106
|
-
source: {
|
|
107
|
-
uri: this.props.ad.action_path
|
|
108
|
-
},
|
|
109
|
-
ref: ref => {
|
|
110
|
-
this.webViewElementRef = ref;
|
|
111
|
-
},
|
|
112
|
-
androidHardwareAccelerationDisabled: true,
|
|
113
|
-
automaticallyAdjustContentInsets: false,
|
|
114
|
-
allowFileAccess: true,
|
|
115
|
-
style: styles.webView,
|
|
116
|
-
javaScriptEnabled: true,
|
|
117
|
-
injectedJavaScript: this.props.ad.action_type === _adadaptedApiTypes.AdActionType.POPUP || this.props.ad.action_type === _adadaptedApiTypes.AdActionType.LINK ? this.getAddToListCircularJavascript() : "",
|
|
118
|
-
onMessage: event => {
|
|
119
|
-
const responseObj = JSON.parse(event.nativeEvent.data);
|
|
120
|
-
(0, _util.safeInvoke)(this.props.onAddToListItemClicked, responseObj);
|
|
121
|
-
},
|
|
122
|
-
onNavigationStateChange: navState => {
|
|
123
|
-
this.setState({
|
|
124
|
-
canGoBack: navState.canGoBack,
|
|
125
|
-
canGoForward: navState.canGoForward
|
|
126
|
-
});
|
|
127
|
-
},
|
|
128
|
-
onLoadStart: () => {
|
|
129
|
-
this.setState({
|
|
130
|
-
isPageLoading: true
|
|
131
|
-
});
|
|
132
|
-
},
|
|
133
|
-
onLoadEnd: () => {
|
|
134
|
-
this.setState({
|
|
135
|
-
isPageLoading: false
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}), /*#__PURE__*/React.createElement(_reactNative.SafeAreaView, {
|
|
139
|
-
style: styles.closeButtonView
|
|
140
|
-
}, /*#__PURE__*/React.createElement(_reactNative.TouchableOpacity, {
|
|
141
|
-
style: styles.closeButtonContainer,
|
|
142
|
-
onPress: () => {
|
|
143
|
-
(0, _util.safeInvoke)(this.props.onClose);
|
|
144
|
-
}
|
|
145
|
-
}, /*#__PURE__*/React.createElement(_reactNative.Text, {
|
|
146
|
-
style: styles.closeButtonText
|
|
147
|
-
}, "Close")))));
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Generates the javascript to pass down to the Web View that extracts the
|
|
151
|
-
* clicked product information based on the circular ad design.
|
|
152
|
-
* @returns the javascript string to pass to the Web View.
|
|
153
|
-
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
getAddToListCircularJavascript() {
|
|
157
|
-
// TODO: This method should ultimately be removed. We shouldn't have to
|
|
158
|
-
// hack the web view's javascript just to get the correct data to
|
|
159
|
-
// return. When the circular templates get reworked, we should
|
|
160
|
-
// build in an onMessage response within the circulars page so we
|
|
161
|
-
// don't have to do it this way.
|
|
162
|
-
return `
|
|
163
|
-
const adButtons = document.getElementsByTagName("button");
|
|
164
|
-
|
|
165
|
-
if (adButtons.length > 0) {
|
|
166
|
-
if (adButtons.length > 1 && adButtons[1].getAttribute("data-payload-id")) {
|
|
167
|
-
for (let x = 0; x < adButtons.length; x++) {
|
|
168
|
-
if (adButtons[x].getAttribute("data-payload-id")) {
|
|
169
|
-
adButtons[x].addEventListener("click", (event) => {
|
|
170
|
-
window.ReactNativeWebView.postMessage(
|
|
171
|
-
JSON.stringify(
|
|
172
|
-
window.AdAdapted.payloads[adButtons[x].getAttribute("data-payload-id")]
|
|
173
|
-
)
|
|
174
|
-
);
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
} else {
|
|
179
|
-
const onDataPostMessage = (imgSrc) => {
|
|
180
|
-
const valueAfterLastSlash = imgSrc.match(/(?:[^\\/](?!(\\/)))+$/g).toString();
|
|
181
|
-
const upcValueWithLeadingZeros = valueAfterLastSlash.match(/[^.]*/).toString();
|
|
182
|
-
const finalUpcValue = parseInt(upcValueWithLeadingZeros, 10);
|
|
183
|
-
const itemData = window.__NUXT__.data[0].items;
|
|
184
|
-
let clickedItem = {};
|
|
185
|
-
|
|
186
|
-
for (let i = 0; i < itemData.length; i++) {
|
|
187
|
-
if (itemData[i].upc == finalUpcValue) {
|
|
188
|
-
clickedItem = itemData[i];
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
window.ReactNativeWebView.postMessage(
|
|
193
|
-
JSON.stringify({
|
|
194
|
-
product_barcode: clickedItem.upc,
|
|
195
|
-
product_brand: clickedItem.brand,
|
|
196
|
-
product_category: clickedItem.category,
|
|
197
|
-
product_discount: clickedItem.sale_price,
|
|
198
|
-
product_image: clickedItem.image,
|
|
199
|
-
product_sku: clickedItem.retailer_sku,
|
|
200
|
-
product_title: clickedItem.title
|
|
201
|
-
})
|
|
202
|
-
);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
const onItemDialogLoad = () => {
|
|
206
|
-
setTimeout(() => {
|
|
207
|
-
document.getElementsByClassName("modal-body")[0].getElementsByTagName("button")[0].addEventListener("click", (event) => {
|
|
208
|
-
onDataPostMessage(
|
|
209
|
-
event.target.parentElement.getElementsByTagName("img")[0].getAttribute("src")
|
|
210
|
-
);
|
|
211
|
-
});
|
|
212
|
-
}, 100);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const adItemImages = document.querySelectorAll(".item img");
|
|
216
|
-
const adItemPromotionDivs = document.querySelectorAll(".item .promotion");
|
|
217
|
-
const adItemTitleDivs = document.querySelectorAll(".item .title");
|
|
218
|
-
const adItemPricingDivs = document.querySelectorAll(".item .pricing");
|
|
219
|
-
|
|
220
|
-
for (let x = 0; x < adItemImages.length; x++) {
|
|
221
|
-
adItemImages[x].addEventListener("click", (event) => {
|
|
222
|
-
onItemDialogLoad();
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
for (let x = 0; x < adItemPromotionDivs.length; x++) {
|
|
227
|
-
adItemPromotionDivs[x].addEventListener("click", (event) => {
|
|
228
|
-
onItemDialogLoad();
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
for (let x = 0; x < adItemTitleDivs.length; x++) {
|
|
233
|
-
adItemTitleDivs[x].addEventListener("click", (event) => {
|
|
234
|
-
onItemDialogLoad();
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
for (let x = 0; x < adItemPricingDivs.length; x++) {
|
|
239
|
-
adItemPricingDivs[x].addEventListener("click", (event) => {
|
|
240
|
-
onItemDialogLoad();
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
for (let x = 0; x < adButtons.length; x++) {
|
|
245
|
-
adButtons[x].addEventListener("click", (event) => {
|
|
246
|
-
onDataPostMessage(
|
|
247
|
-
event.target.parentElement.getElementsByTagName("img")[0].getAttribute("src")
|
|
248
|
-
);
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
`;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Generates all component related styles.
|
|
257
|
-
* @returns the styles needed for the component.
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
generateStyles() {
|
|
262
|
-
const backButtonOpacity = this.state.canGoBack ? 1 : 0.3;
|
|
263
|
-
const forwardButtonOpacity = this.state.canGoForward ? 1 : 0.3;
|
|
264
|
-
return _reactNative.StyleSheet.create({
|
|
265
|
-
mainView: {
|
|
266
|
-
display: "flex",
|
|
267
|
-
flexDirection: "column",
|
|
268
|
-
position: "relative",
|
|
269
|
-
margin: 0,
|
|
270
|
-
width: "100%",
|
|
271
|
-
height: "100%"
|
|
272
|
-
},
|
|
273
|
-
navHeaderView: {
|
|
274
|
-
display: "flex",
|
|
275
|
-
flexDirection: "row",
|
|
276
|
-
height: 60,
|
|
277
|
-
width: "100%",
|
|
278
|
-
backgroundColor: "#dadada",
|
|
279
|
-
zIndex: 1
|
|
280
|
-
},
|
|
281
|
-
navArrowsContainer: {
|
|
282
|
-
display: "flex",
|
|
283
|
-
flexDirection: "row",
|
|
284
|
-
justifyContent: "center",
|
|
285
|
-
alignItems: "center"
|
|
286
|
-
},
|
|
287
|
-
navLeftArrow: {
|
|
288
|
-
width: 48,
|
|
289
|
-
height: 48,
|
|
290
|
-
marginRight: 5,
|
|
291
|
-
marginLeft: 10,
|
|
292
|
-
opacity: backButtonOpacity
|
|
293
|
-
},
|
|
294
|
-
navRightArrow: {
|
|
295
|
-
width: 48,
|
|
296
|
-
height: 48,
|
|
297
|
-
marginRight: 10,
|
|
298
|
-
marginLeft: 5,
|
|
299
|
-
opacity: forwardButtonOpacity
|
|
300
|
-
},
|
|
301
|
-
navBarTitleView: {
|
|
302
|
-
display: "flex",
|
|
303
|
-
flexDirection: "row",
|
|
304
|
-
alignItems: "center",
|
|
305
|
-
flex: 1
|
|
306
|
-
},
|
|
307
|
-
titleText: {
|
|
308
|
-
color: "#333333",
|
|
309
|
-
fontWeight: "bold",
|
|
310
|
-
fontSize: 18,
|
|
311
|
-
overflow: "hidden",
|
|
312
|
-
flexWrap: "nowrap"
|
|
313
|
-
},
|
|
314
|
-
loadingIndicatorContainer: {
|
|
315
|
-
display: "flex",
|
|
316
|
-
flexDirection: "row",
|
|
317
|
-
justifyContent: "center",
|
|
318
|
-
alignItems: "center",
|
|
319
|
-
marginLeft: 10,
|
|
320
|
-
marginRight: 10
|
|
321
|
-
},
|
|
322
|
-
webView: {
|
|
323
|
-
width: "100%",
|
|
324
|
-
height: "100%",
|
|
325
|
-
zIndex: 0
|
|
326
|
-
},
|
|
327
|
-
closeButtonView: {
|
|
328
|
-
height: 60,
|
|
329
|
-
width: "100%",
|
|
330
|
-
backgroundColor: "#dadada",
|
|
331
|
-
zIndex: 1
|
|
332
|
-
},
|
|
333
|
-
closeButtonContainer: {
|
|
334
|
-
display: "flex",
|
|
335
|
-
justifyContent: "center",
|
|
336
|
-
width: "100%",
|
|
337
|
-
height: "100%"
|
|
338
|
-
},
|
|
339
|
-
closeButtonText: {
|
|
340
|
-
width: "100%",
|
|
341
|
-
color: "#2969a0",
|
|
342
|
-
margin: "auto",
|
|
343
|
-
fontSize: 18,
|
|
344
|
-
textAlign: "center"
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
exports.AdPopup = AdPopup;
|
|
352
|
-
//# sourceMappingURL=AdPopup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["AdPopup.tsx"],"names":["AdPopup","React","Component","constructor","props","context","state","canGoBack","canGoForward","isPageLoading","render","styles","generateStyles","mainView","isOpen","flex","navHeaderView","navArrowsContainer","webViewElementRef","goBack","uri","navLeftArrow","goForward","navRightArrow","navBarTitleView","titleText","ad","popup","title_text","loadingIndicatorContainer","undefined","action_path","ref","webView","action_type","AdActionType","POPUP","LINK","getAddToListCircularJavascript","event","responseObj","JSON","parse","nativeEvent","data","onAddToListItemClicked","navState","setState","closeButtonView","closeButtonContainer","onClose","closeButtonText","backButtonOpacity","forwardButtonOpacity","StyleSheet","create","display","flexDirection","position","margin","width","height","backgroundColor","zIndex","justifyContent","alignItems","marginRight","marginLeft","opacity","color","fontWeight","fontSize","overflow","flexWrap","textAlign"],"mappings":";;;;;;;AAIA;;AACA;;AACA;;AACA;;AAYA;;AACA;;;;;;;;;;AAkGA;AACA;AACA;AACO,MAAMA,OAAN,SAAsBC,KAAK,CAACC,SAA5B,CAAoD;AACvD;AACJ;AACA;;AAGI;AACJ;AACA;AACIC,EAAAA,WAAW,CAACC,KAAD,EAAeC,OAAf,EAA8B;AACrC,UAAMD,KAAN,EAAaC,OAAb;;AADqC,+CALG,IAKH;;AAGrC,SAAKC,KAAL,GAAa;AACTC,MAAAA,SAAS,EAAE,KADF;AAETC,MAAAA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nC,aAAKC,QAAL,CAAc;AACVxC,UAAAA,SAAS,EAAEuC,QAAQ,CAACvC,SADV;AAEVC,UAAAA,YAAY,EAAEsC,QAAQ,CAACtC;AAFb,SAAd;AAIH,OAjCL;AAkCI,MAAA,WAAW,EAAE,MAAM;AACf,aAAKuC,QAAL,CAAc;AACVtC,UAAAA,aAAa,EAAE;AADL,SAAd;AAGH,OAtCL;AAuCI,MAAA,SAAS,EAAE,MAAM;AACb,aAAKsC,QAAL,CAAc;AACVtC,UAAAA,aAAa,EAAE;AADL,SAAd;AAGH;AA3CL,MA1DJ,eAuGI,oBAAC,yBAAD;AAAc,MAAA,KAAK,EAAEE,MAAM,CAACqC;AAA5B,oBACI,oBAAC,6BAAD;AACI,MAAA,KAAK,EAAErC,MAAM,CAACsC,oBADlB;AAEI,MAAA,OAAO,EAAE,MAAM;AACX,8BAAW,KAAK7C,KAAL,CAAW8C,OAAtB;AACH;AAJL,oBAMI,oBAAC,iBAAD;AAAM,MAAA,KAAK,EAAEvC,MAAM,CAACwC;AAApB,eANJ,CADJ,CAvGJ,CANJ,CADJ;AA2HH;AAED;AACJ;AACA;AACA;AACA;;;AACYb,EAAAA,8BAAR,GAAiD;AAC7C;AACA;AACA;AACA;AACA;AACA,WAAQ;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SA3FQ;AA4FH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E,MAHK;AAIbY,QAAAA,QAAQ,EAAE,EAJG;AAKbG,QAAAA,SAAS,EAAE;AALE;AA3EI,KAAlB,CAAP;AAmFH;;AA5VsD","sourcesContent":["/**\n * Component for creating an {@link AdPopup}.\n * @module\n */\nimport * as React from \"react\";\nimport { WebView } from \"react-native-webview\";\nimport Modal from \"react-native-modal\";\nimport {\n ActivityIndicator,\n Image,\n ImageStyle,\n SafeAreaView,\n StyleSheet,\n Text,\n TextStyle,\n TouchableOpacity,\n View,\n ViewStyle,\n} from \"react-native\";\nimport { Ad, AdActionType, DetailedListItem } from \"../api/adadaptedApiTypes\";\nimport { safeInvoke } from \"../util\";\n\n/**\n * Props interface for {@link AdPopup}.\n */\ninterface Props {\n /**\n * The add to display in the popup.\n */\n ad: Ad;\n /**\n * If true, the ad popup is displayed.\n */\n isOpen?: boolean;\n /**\n * Triggered when the popup is closing.\n */\n onClose?(): void;\n /**\n * Triggered when an ad circular item is clicked and\n * the item should be \"added to list\".\n * @param item - The item to add to list.\n */\n onAddToListItemClicked(item: DetailedListItem): void;\n}\n\n/**\n * State interface for {@link AdPopup}.\n */\ninterface State {\n /**\n * If true, the popup web view can navigate back.\n */\n canGoBack: boolean;\n /**\n * If true, the popup web view can navigate forward.\n */\n canGoForward: boolean;\n /**\n * If true, the webview is loading a new page.\n */\n isPageLoading: boolean;\n}\n\n/**\n * Defines the style typing for the component.\n */\ninterface StyleDef {\n /**\n * Styles for the main View element.\n */\n mainView: ViewStyle;\n /**\n * Styles for the WebView element.\n */\n webView: ViewStyle;\n /**\n * Styles for the close button View element.\n */\n closeButtonView: ViewStyle;\n /**\n * Styles for the navigation header View element.\n */\n navHeaderView: ViewStyle;\n /**\n * Styles for the nav arrow buttons view.\n */\n navArrowsContainer: ViewStyle;\n /**\n * Styles for the navigation left arrow button.\n */\n navLeftArrow: ImageStyle;\n /**\n * Styles for the navigation right arrow button.\n */\n navRightArrow: ImageStyle;\n /**\n * Styles for the nav bar title container.\n */\n navBarTitleView: ViewStyle;\n /**\n * Styles for the title text.\n */\n titleText: TextStyle;\n /**\n * Styles for the loading indicator container.\n */\n loadingIndicatorContainer: ViewStyle;\n /**\n * Styles for the close button opacity container.\n */\n closeButtonContainer: ViewStyle;\n /**\n * Styles for the button text.\n */\n closeButtonText: TextStyle;\n}\n\n/**\n * Creates the AdPopup component.\n */\nexport class AdPopup extends React.Component<Props, State> {\n /**\n * The web view element reference.\n */\n private webViewElementRef: WebView | null = null;\n\n /**\n * @inheritDoc\n */\n constructor(props: Props, context?: any) {\n super(props, context);\n\n this.state = {\n canGoBack: false,\n canGoForward: false,\n isPageLoading: true,\n };\n }\n\n /**\n * @inheritDoc\n */\n public render(): JSX.Element {\n // Generate the styles each render in case the ad is updated with\n // new settings that need to be reflected in the styles of the view.\n const styles = this.generateStyles();\n\n return (\n <Modal\n style={styles.mainView}\n isVisible={this.props.isOpen}\n hasBackdrop={false}\n coverScreen={true}\n >\n <SafeAreaView style={{ flex: 1 }}>\n <SafeAreaView style={styles.navHeaderView}>\n <View style={styles.navArrowsContainer}>\n <View\n onTouchStart={() => {\n if (\n this.webViewElementRef &&\n this.state.canGoBack\n ) {\n this.webViewElementRef.goBack();\n }\n }}\n >\n <Image\n source={{\n uri:\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABpUlEQVRoQ+2YvUrFQBBGZ59Hq8QXsLcVLCwsFBQUFBQUlHsFBQUFBQUFLSwsBB9C+/2m0ifxAUYCCinM5i47c83Cpgy7yznzzZAfR5lfLnN+KgL/nWBJoCSQWIHSQokFTN5eEogtYVVVY+fcAhF9icg7M49jz2ivn2oCP/CjFsAngNksBP6Ab7gBYG7wAh3wJCLHg2+hLngiOgJwklL9Zq/pDATgDwCcpcKbCgTg9wBcaMCbCQR6foeZr7TgTQS64J1zW977G014dYFA22wAuNOGVxUIwK8BeLCAVxMIwK8AeLKCVxEIDOwyMz9bwqsI1HX9QUQzbVARWWLmF2t4LQFPRHW2Atm3UFP5rIf4t3UCD7BV7/2j1TyovswFJNa99/cWEqoCoXYSkU1mvtWWUBfomYltANeaEiYCPRK7AC61JMwEeiT2AZxrSJgKhCScc4fe+9NUCXOBnsEe/kd9z3Min/9CHUm8AZhPaaOptFAbsKqqkXNusbknIq+D/y+UUt1J9k49gUmgYtYUgZhqWawtCVhUNebMkkBMtSzWlgQsqhpz5jfHSasx85A3NgAAAABJRU5ErkJggg==\",\n }}\n style={styles.navLeftArrow}\n />\n </View>\n <View\n onTouchStart={() => {\n if (\n this.webViewElementRef &&\n this.state.canGoForward\n ) {\n this.webViewElementRef.goForward();\n }\n }}\n >\n <Image\n source={{\n uri:\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABnklEQVRoQ+3YsUoEMRAG4H8ewCfRKpNeH0KwsLBQUFBQUFBQ8ERBQUFBQUELCwsLS3tfwFylzzOykAVZmz0yM+dCrs7O/d9Mwu2FMPAPDTw/KmDaE6wTqBMo7EDdQoUNLH68TiCEMCKieQAzIvI+Ho9HxW2doEDxBJj5C8Bs+50icuKJ0AB8AuDfTfNEFAPyFjruTt0LUQxogjPzEYDTaSBUABlxAODcG6EGyIg9AJeeCFVAEzyEsENE114IdUATPMa4JSK3HggTQN5OGwDurRFmgIxYA/BoiTAFZMQKgGcrhDkgH+xlInqxQLgAMmKJiF47iO+U0twE725/lk4bkFJK8d8DQgjD3ULMPNxDHGNcFZEni8Pb1jQ7AzHGdRF5sAzf1DYBhBA2iejOOrwJgJm3Adx4hFcHMPMugCuv8KoAZt4HcOEZXg0QYzwUkTPv8CqAwf+p794LNV3xupFQmQAzfwBYaLePZ3gVQN5Ci7nzb563ciqAkjdJjWdNfok1gvWtUQF9O2W1rk7AqrN969YJ9O2U1bo6AavO9q37A5jF5jGXG4ruAAAAAElFTkSuQmCC\",\n }}\n style={styles.navRightArrow}\n />\n </View>\n </View>\n <View style={styles.navBarTitleView}>\n <Text\n style={styles.titleText}\n numberOfLines={1}\n ellipsizeMode={\"tail\"}\n >\n {this.props.ad.popup.title_text}\n </Text>\n </View>\n <View style={styles.loadingIndicatorContainer}>\n {this.state.isPageLoading ? (\n <ActivityIndicator\n size=\"large\"\n color=\"#2969a0\"\n />\n ) : undefined}\n </View>\n </SafeAreaView>\n <WebView\n source={{\n uri: this.props.ad.action_path,\n }}\n ref={(ref) => {\n this.webViewElementRef = ref;\n }}\n androidHardwareAccelerationDisabled={true}\n automaticallyAdjustContentInsets={false}\n allowFileAccess={true}\n style={styles.webView}\n javaScriptEnabled={true}\n injectedJavaScript={\n this.props.ad.action_type === AdActionType.POPUP ||\n this.props.ad.action_type === AdActionType.LINK\n ? this.getAddToListCircularJavascript()\n : \"\"\n }\n onMessage={(event) => {\n const responseObj: DetailedListItem = JSON.parse(\n event.nativeEvent.data\n );\n\n safeInvoke(\n this.props.onAddToListItemClicked,\n responseObj\n );\n }}\n onNavigationStateChange={(navState) => {\n this.setState({\n canGoBack: navState.canGoBack,\n canGoForward: navState.canGoForward,\n });\n }}\n onLoadStart={() => {\n this.setState({\n isPageLoading: true,\n });\n }}\n onLoadEnd={() => {\n this.setState({\n isPageLoading: false,\n });\n }}\n />\n <SafeAreaView style={styles.closeButtonView}>\n <TouchableOpacity\n style={styles.closeButtonContainer}\n onPress={() => {\n safeInvoke(this.props.onClose);\n }}\n >\n <Text style={styles.closeButtonText}>Close</Text>\n </TouchableOpacity>\n </SafeAreaView>\n </SafeAreaView>\n </Modal>\n );\n }\n\n /**\n * Generates the javascript to pass down to the Web View that extracts the\n * clicked product information based on the circular ad design.\n * @returns the javascript string to pass to the Web View.\n */\n private getAddToListCircularJavascript(): string {\n // TODO: This method should ultimately be removed. We shouldn't have to\n // hack the web view's javascript just to get the correct data to\n // return. When the circular templates get reworked, we should\n // build in an onMessage response within the circulars page so we\n // don't have to do it this way.\n return `\n const adButtons = document.getElementsByTagName(\"button\");\n\n if (adButtons.length > 0) {\n if (adButtons.length > 1 && adButtons[1].getAttribute(\"data-payload-id\")) {\n for (let x = 0; x < adButtons.length; x++) {\n if (adButtons[x].getAttribute(\"data-payload-id\")) {\n adButtons[x].addEventListener(\"click\", (event) => {\n window.ReactNativeWebView.postMessage(\n JSON.stringify(\n window.AdAdapted.payloads[adButtons[x].getAttribute(\"data-payload-id\")]\n )\n );\n });\n }\n }\n } else {\n const onDataPostMessage = (imgSrc) => {\n const valueAfterLastSlash = imgSrc.match(/(?:[^\\\\/](?!(\\\\/)))+$/g).toString();\n const upcValueWithLeadingZeros = valueAfterLastSlash.match(/[^.]*/).toString();\n const finalUpcValue = parseInt(upcValueWithLeadingZeros, 10);\n const itemData = window.__NUXT__.data[0].items;\n let clickedItem = {};\n \n for (let i = 0; i < itemData.length; i++) {\n if (itemData[i].upc == finalUpcValue) {\n clickedItem = itemData[i];\n }\n }\n \n window.ReactNativeWebView.postMessage(\n JSON.stringify({\n product_barcode: clickedItem.upc,\n product_brand: clickedItem.brand,\n product_category: clickedItem.category,\n product_discount: clickedItem.sale_price,\n product_image: clickedItem.image,\n product_sku: clickedItem.retailer_sku,\n product_title: clickedItem.title\n })\n );\n };\n \n const onItemDialogLoad = () => {\n setTimeout(() => {\n document.getElementsByClassName(\"modal-body\")[0].getElementsByTagName(\"button\")[0].addEventListener(\"click\", (event) => {\n onDataPostMessage(\n event.target.parentElement.getElementsByTagName(\"img\")[0].getAttribute(\"src\")\n );\n });\n }, 100);\n };\n \n const adItemImages = document.querySelectorAll(\".item img\");\n const adItemPromotionDivs = document.querySelectorAll(\".item .promotion\");\n const adItemTitleDivs = document.querySelectorAll(\".item .title\");\n const adItemPricingDivs = document.querySelectorAll(\".item .pricing\");\n \n for (let x = 0; x < adItemImages.length; x++) {\n adItemImages[x].addEventListener(\"click\", (event) => {\n onItemDialogLoad();\n });\n }\n \n for (let x = 0; x < adItemPromotionDivs.length; x++) {\n adItemPromotionDivs[x].addEventListener(\"click\", (event) => {\n onItemDialogLoad();\n });\n }\n \n for (let x = 0; x < adItemTitleDivs.length; x++) {\n adItemTitleDivs[x].addEventListener(\"click\", (event) => {\n onItemDialogLoad();\n });\n }\n \n for (let x = 0; x < adItemPricingDivs.length; x++) {\n adItemPricingDivs[x].addEventListener(\"click\", (event) => {\n onItemDialogLoad();\n });\n }\n \n for (let x = 0; x < adButtons.length; x++) {\n adButtons[x].addEventListener(\"click\", (event) => {\n onDataPostMessage(\n event.target.parentElement.getElementsByTagName(\"img\")[0].getAttribute(\"src\")\n );\n });\n }\n }\n }\n `;\n }\n\n /**\n * Generates all component related styles.\n * @returns the styles needed for the component.\n */\n private generateStyles(): StyleDef {\n const backButtonOpacity = this.state.canGoBack ? 1 : 0.3;\n const forwardButtonOpacity = this.state.canGoForward ? 1 : 0.3;\n\n return StyleSheet.create({\n mainView: {\n display: \"flex\",\n flexDirection: \"column\",\n position: \"relative\",\n margin: 0,\n width: \"100%\",\n height: \"100%\",\n },\n navHeaderView: {\n display: \"flex\",\n flexDirection: \"row\",\n height: 60,\n width: \"100%\",\n backgroundColor: \"#dadada\",\n zIndex: 1,\n },\n navArrowsContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"center\",\n alignItems: \"center\",\n },\n navLeftArrow: {\n width: 48,\n height: 48,\n marginRight: 5,\n marginLeft: 10,\n opacity: backButtonOpacity,\n },\n navRightArrow: {\n width: 48,\n height: 48,\n marginRight: 10,\n marginLeft: 5,\n opacity: forwardButtonOpacity,\n },\n navBarTitleView: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n flex: 1,\n },\n titleText: {\n color: \"#333333\",\n fontWeight: \"bold\",\n fontSize: 18,\n overflow: \"hidden\",\n flexWrap: \"nowrap\",\n },\n loadingIndicatorContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"center\",\n alignItems: \"center\",\n marginLeft: 10,\n marginRight: 10,\n },\n webView: {\n width: \"100%\",\n height: \"100%\",\n zIndex: 0,\n },\n closeButtonView: {\n height: 60,\n width: \"100%\",\n backgroundColor: \"#dadada\",\n zIndex: 1,\n },\n closeButtonContainer: {\n display: \"flex\",\n justifyContent: \"center\",\n width: \"100%\",\n height: \"100%\",\n },\n closeButtonText: {\n width: \"100%\",\n color: \"#2969a0\",\n margin: \"auto\",\n fontSize: 18,\n textAlign: \"center\",\n },\n });\n }\n}\n"]}
|