popup with object
This commit is contained in:
parent
1675d4f7ff
commit
efb31cc993
3 changed files with 23 additions and 21 deletions
|
|
@ -9,7 +9,7 @@ class PopupNotification {
|
||||||
render() {
|
render() {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.id = this.id;
|
div.id = this.id;
|
||||||
div.className = 'top-notification-good';
|
div.className = 'top-notification-good max-size-zero';
|
||||||
|
|
||||||
div.innerHTML = `<img src="/img/circle-check-white.svg" />
|
div.innerHTML = `<img src="/img/circle-check-white.svg" />
|
||||||
<p>${this.text}</p>`;
|
<p>${this.text}</p>`;
|
||||||
|
|
@ -21,5 +21,19 @@ class PopupNotification {
|
||||||
display() {
|
display() {
|
||||||
this.element.classList.add('revealed');
|
this.element.classList.add('revealed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayTemporarily(milliseconds) {
|
||||||
|
if (!milliseconds) {
|
||||||
|
milliseconds = 1000;
|
||||||
|
}
|
||||||
|
this.element.classList.remove('max-size-zero');
|
||||||
|
this.element.classList.add('revealed');
|
||||||
|
setTimeout(() => {
|
||||||
|
this.element.classList.remove('revealed');
|
||||||
|
}, milliseconds);
|
||||||
|
setTimeout(() => {
|
||||||
|
this.element.classList.add('max-size-zero');
|
||||||
|
}, milliseconds + 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
module.exports = PopupNotification;
|
module.exports = PopupNotification;
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,7 @@ const TimeInput = require('../components/TimeInput');
|
||||||
const BitcoinMethodCheckboxes = require('../components/BitcoinMethodCheckboxes');
|
const BitcoinMethodCheckboxes = require('../components/BitcoinMethodCheckboxes');
|
||||||
const TrustCheckboxes = require('../components/TrustCheckboxes');
|
const TrustCheckboxes = require('../components/TrustCheckboxes');
|
||||||
const BigNotesCheckbox = require('../components/BigNotesCheckbox');
|
const BigNotesCheckbox = require('../components/BigNotesCheckbox');
|
||||||
|
const PopupNotification = require('../components/PopupNotification');
|
||||||
const offerCreatedPopup = document.getElementById('offer-created-confirmation');
|
|
||||||
function toggleOfferCreatedAlert() {
|
|
||||||
offerCreatedPopup.classList.remove('max-size-zero');
|
|
||||||
offerCreatedPopup.classList.add('revealed');
|
|
||||||
setTimeout(() => {
|
|
||||||
offerCreatedPopup.classList.remove('revealed');
|
|
||||||
}, 3000);
|
|
||||||
setTimeout(() => {
|
|
||||||
offerCreatedPopup.classList.add('max-size-zero');
|
|
||||||
}, 4000);
|
|
||||||
}
|
|
||||||
|
|
||||||
class CreateOfferModal {
|
class CreateOfferModal {
|
||||||
// Actual creation logic to be provided by a service
|
// Actual creation logic to be provided by a service
|
||||||
|
|
@ -254,12 +243,18 @@ class CreateOfferModal {
|
||||||
}
|
}
|
||||||
|
|
||||||
function offersPage() {
|
function offersPage() {
|
||||||
|
const offerCreatedPopup = new PopupNotification({
|
||||||
|
parentElement: document.body,
|
||||||
|
text: '¡Oferta creada! Puedes verla en tus ofertas.',
|
||||||
|
});
|
||||||
|
|
||||||
|
offerCreatedPopup.render();
|
||||||
const createOfferModal = new CreateOfferModal({
|
const createOfferModal = new CreateOfferModal({
|
||||||
parentElement: document.body,
|
parentElement: document.body,
|
||||||
onCreationCallback: async () => {
|
onCreationCallback: async () => {
|
||||||
await myOffers.getOffersFromApi();
|
await myOffers.getOffersFromApi();
|
||||||
await myOffers.render();
|
await myOffers.render();
|
||||||
await toggleOfferCreatedAlert();
|
offerCreatedPopup.displayTemporarily(3000);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
createOfferModal.render();
|
createOfferModal.render();
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,6 @@
|
||||||
<p>Vaya, no hay nada por aquí...</p>
|
<p>Vaya, no hay nada por aquí...</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
id="offer-created-confirmation"
|
|
||||||
class="top-notification-good max-size-zero"
|
|
||||||
>
|
|
||||||
<img src="/img/circle-check-white.svg" />
|
|
||||||
<p>¡Oferta creada! Puedes verla en tus ofertas.</p>
|
|
||||||
</div>
|
|
||||||
<div
|
<div
|
||||||
id="offer-deleted-confirmation"
|
id="offer-deleted-confirmation"
|
||||||
class="top-notification-good max-size-zero"
|
class="top-notification-good max-size-zero"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue