Skip to content

Commit

Permalink
[DTRA] Maryia/FEQ-1465/TrackJS error '404 : GET https://smarttrader.d…
Browse files Browse the repository at this point in the history
…eriv.com/en/user/top_up_virtual_pop_up.html & dialog.html (#611)

* fix: appending undefind node for pop_up

* fix: restore top up pop up and dialog

* fix: prevent errors without restoring modals

* revert: modals restoration
  • Loading branch information
maryia-deriv authored Feb 21, 2024
1 parent 049c821 commit 7731193
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/javascript/app/common/attach_dom/dialog.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const showPopup = require('./popup');
const elementInnerHtml = require('../../../_common/common_functions').elementInnerHtml;
const urlFor = require('../../../_common/url').urlFor;

// use this function if you need a simple popup with just a confirm or also a cancel button
// if you need to show a form with some validations, use showPopup() instead
const Dialog = (() => {
const baseDialog = (options, is_alert = false) => (
new Promise((resolve) => {
showPopup({
url : urlFor('dialog'),
// url : urlFor('dialog'), // Unused in pages.js.
// TODO: Uncomment/update popup logic when restoring Dialog feature.
popup_id : options.id,
form_id : '#frm_confirm',
content_id : '#dialog_content',
Expand Down
6 changes: 4 additions & 2 deletions src/javascript/app/common/attach_dom/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const showPopup = (options) => {
}
if (cache[options.url]) {
callback(options);
} else {
} else if (options.url) {
const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState !== 4 || this.status !== 200) {
Expand All @@ -32,7 +32,9 @@ const showPopup = (options) => {
const callback = (options) => {
const div = createElement('div', { html: cache[options.url] });
const lightbox = createElement('div', { id: options.popup_id, class: 'lightbox' });
lightbox.appendChild(div.querySelector(options.content_id));
const content = div.querySelector(options.content_id);
if (!content) return;
lightbox.appendChild(content);
lightbox.addEventListener('DOMNodeRemoved', (e) => {
if (!popup_queue.length || e.target.className !== 'lightbox') return;
document.body.appendChild(popup_queue.pop()); // show popup in queue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ const TopUpVirtualPopup = (() => {
showPopup({
form_id,
popup_id,
url : urlFor('user/top_up_virtual_pop_up'),
// url : urlFor('user/top_up_virtual_pop_up'), // Unused in pages.js.
// TODO: Uncomment/update popup logic when restoring TopUpVirtualPopup. Removed JSX can be found in PR#592 (4f8e0ff)
content_id : '#top_up',
additionalFunction: () => {
if (message) {
Expand Down

0 comments on commit 7731193

Please sign in to comment.