* Get the correct script for the container. * @param {!Window} global * @param {string} scriptSource The source of the script, different for post and comment embeds. * @param {string} widgetType The type of the widget being instantiated. * @param {function(!Object, string)} cb
(global, scriptSource, widgetType, cb)
| 8 | * @param {function(!Object, string)} cb |
| 9 | */ |
| 10 | function getContainerScript(global, scriptSource, widgetType, cb) { |
| 11 | loadScript(global, scriptSource, () => { |
| 12 | global.Yotpo = global.Yotpo || {}; |
| 13 | if (widgetType !== 'ReviewsTab') { |
| 14 | delete global.Yotpo.widgets['testimonials']; |
| 15 | } |
| 16 | const yotpoWidget = |
| 17 | typeof global.yotpo === 'undefined' ? undefined : global.yotpo; |
| 18 | yotpoWidget.on('CssReady', function () { |
| 19 | cb(yotpoWidget, 'cssLoaded'); |
| 20 | }); |
| 21 | yotpoWidget.on('BatchReady', function () { |
| 22 | cb(yotpoWidget, 'batchLoaded'); |
| 23 | }); |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Create DOM element for the Yotpo bottom line plugin: |
no test coverage detected