Skip to content

Commit

Permalink
Joomla popup alert/confirm handle cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik committed Mar 12, 2023
1 parent 25b6b16 commit 6923750
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions build/media_source/system/js/joomla-popup.w-c.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ class JoomlaPopup extends HTMLElement {
}
return response.text();
}).then((text) => {
this.popupTmplB.insertAdjacentHTML('afterbegin', text);
this.popupContentElement = this.popupTmplB;
onLoad();
}).catch((error) => {
throw error;
});
this.popupTmplB.insertAdjacentHTML('afterbegin', text);
this.popupContentElement = this.popupTmplB;
onLoad();
}).catch((error) => {
throw error;
});
break;
}

Expand Down Expand Up @@ -368,10 +368,10 @@ class JoomlaPopup extends HTMLElement {
label: 'Okay',
onClick: () => {
popup.close();
resolve();
},
}];
popup.classList.add('joomla-popup-alert');
popup.addEventListener('joomla-popup:close', () => resolve());
popup.show();
});
}
Expand All @@ -384,27 +384,29 @@ class JoomlaPopup extends HTMLElement {
*/
static confirm(message) {
return new Promise((resolve) => {
let result = false;
const popup = new this();
popup.popupType = 'inline';
popup.popupContent = message;
popup.popupButtons = [
{
label: 'Yes',
onClick: () => {
result = true;
popup.close();
resolve(true);
},
},
{
label: 'No',
onClick: () => {
result = false
popup.close();
resolve(false);
},
className: 'button btn btn-outline-primary',
},
];
popup.classList.add('joomla-popup-confirm');
popup.addEventListener('joomla-popup:close', () => resolve(result));
popup.show();
});
}
Expand Down

0 comments on commit 6923750

Please sign in to comment.