whatsapp-button.js
39 lines
| 1 | (function () { |
| 2 | njtWhatsApp.ready(function () { |
| 3 | const init = function () { |
| 4 | document.querySelectorAll(".nta_wa_button").forEach(function (element) { |
| 5 | if (element._isWaButton) return |
| 6 | const info = JSON.parse(element.getAttribute('data-info')) |
| 7 | njtWhatsApp.createButton(element, { |
| 8 | ...info, |
| 9 | timezone: njt_wa_global.timezone, |
| 10 | i18n: njt_wa_global.i18n, |
| 11 | urlSettings: njt_wa_global.urlSettings, |
| 12 | }); |
| 13 | }); |
| 14 | }; |
| 15 | init(); |
| 16 | |
| 17 | if (window.jQuery) { |
| 18 | // Support Riode Theme |
| 19 | if (typeof(Riode) !== 'undefined' && typeof(jQuery) !== 'undefined') { |
| 20 | Riode.$window.on('riode_load', function(){ init() }) |
| 21 | jQuery(document).ajaxComplete((e, xhs, req) => { |
| 22 | try { |
| 23 | if (req.data.indexOf('riode_quickview') > -1) { init() } |
| 24 | } catch (e) { |
| 25 | console.log("error") |
| 26 | } |
| 27 | }) |
| 28 | } |
| 29 | |
| 30 | // Support Porto Theme |
| 31 | jQuery(document).ajaxComplete((e, xhs, req) => { |
| 32 | try { |
| 33 | if (req.data.indexOf('action=porto_lazyload_menu') > -1) { init() } |
| 34 | } catch (e) {} |
| 35 | }) |
| 36 | } |
| 37 | }); |
| 38 | })(); |
| 39 |