Skip to content

Commit

Permalink
SweetAlert2 v6.11.5 -> 9.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sacr3dc0w committed Jan 3, 2020
1 parent f14b572 commit a90c867
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 243 deletions.
12 changes: 6 additions & 6 deletions assets/js/theme/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ export default class Account extends PageManager {

if (!submitForm) {
event.preventDefault();
swal({
swal.fire({
text: this.context.selectItem,
type: 'error',
icon: 'error',
});
}
});
Expand Down Expand Up @@ -198,9 +198,9 @@ export default class Account extends PageManager {
return true;
}

swal({
swal.fire({
text: errorMessage,
type: 'error',
icon: 'error',
});

return event.preventDefault();
Expand Down Expand Up @@ -299,9 +299,9 @@ export default class Account extends PageManager {
storeInstrument(this.context, data, () => {
window.location.href = this.context.paymentMethodsUrl;
}, () => {
swal({
swal.fire({
text: this.context.generic_error,
type: 'error',
icon: 'error',
});
});
}
Expand Down
64 changes: 33 additions & 31 deletions assets/js/theme/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ export default class Cart extends PageManager {
const newQty = $target.data('action') === 'inc' ? oldQty + 1 : oldQty - 1;
// Does not quality for min/max quantity
if (newQty < minQty) {
return swal({
return swal.fire({
text: minError,
type: 'error',
icon: 'error',
});
} else if (maxQty > 0 && newQty > maxQty) {
return swal({
return swal.fire({
text: maxError,
type: 'error',
icon: 'error',
});
}

Expand All @@ -51,9 +51,9 @@ export default class Cart extends PageManager {
this.refreshContent(remove);
} else {
$el.val(oldQty);
swal({
swal.fire({
text: response.data.errors.join('\n'),
type: 'error',
icon: 'error',
});
}
});
Expand All @@ -74,21 +74,21 @@ export default class Cart extends PageManager {
if (!newQty) {
invalidEntry = $el.val();
$el.val(oldQty);
return swal({
return swal.fire({
text: `${invalidEntry} is not a valid entry`,
type: 'error',
icon: 'error',
});
} else if (newQty < minQty) {
$el.val(oldQty);
return swal({
return swal.fire({
text: minError,
type: 'error',
icon: 'error',
});
} else if (maxQty > 0 && newQty > maxQty) {
$el.val(oldQty);
return swal({
return swal.fire({
text: maxError,
type: 'error',
icon: 'error',
});
}

Expand All @@ -103,9 +103,9 @@ export default class Cart extends PageManager {
this.refreshContent(remove);
} else {
$el.val(oldQty);
swal({
swal.fire({
text: response.data.errors.join('\n'),
type: 'error',
icon: 'error',
});
}
});
Expand All @@ -117,9 +117,9 @@ export default class Cart extends PageManager {
if (response.data.status === 'succeed') {
this.refreshContent(true);
} else {
swal({
swal.fire({
text: response.data.errors.join('\n'),
type: 'error',
icon: 'error',
});
}
});
Expand Down Expand Up @@ -150,9 +150,9 @@ export default class Cart extends PageManager {
const data = result.data || {};

if (err) {
swal({
swal.fire({
text: err,
type: 'error',
icon: 'error',
});
return false;
}
Expand Down Expand Up @@ -240,13 +240,15 @@ export default class Cart extends PageManager {
$('.cart-remove', this.$cartContent).on('click', event => {
const itemId = $(event.currentTarget).data('cartItemid');
const string = $(event.currentTarget).data('confirmDelete');
swal({
swal.fire({
text: string,
type: 'warning',
icon: 'warning',
showCancelButton: true,
}).then(() => {
// remove item from cart
cartRemoveItem(itemId);
}).then((result) => {
if (result.value) {
// remove item from cart
cartRemoveItem(itemId);
}
});
event.preventDefault();
});
Expand Down Expand Up @@ -289,19 +291,19 @@ export default class Cart extends PageManager {

// Empty code
if (!code) {
return swal({
return swal.fire({
text: $codeInput.data('error'),
type: 'error',
icon: 'error',
});
}

utils.api.cart.applyCode(code, (err, response) => {
if (response.data.status === 'success') {
this.refreshContent();
} else {
swal({
swal.fire({
text: response.data.errors.join('\n'),
type: 'error',
icon: 'error',
});
}
});
Expand Down Expand Up @@ -333,19 +335,19 @@ export default class Cart extends PageManager {
event.preventDefault();

if (!giftCertCheck(code)) {
return swal({
return swal.fire({
text: $certInput.data('error'),
type: 'error',
icon: 'error',
});
}

utils.api.cart.applyGiftCertificate(code, (err, resp) => {
if (resp.data.status === 'success') {
this.refreshContent();
} else {
swal({
swal.fire({
text: resp.data.errors.join('\n'),
type: 'error',
icon: 'error',
});
}
});
Expand Down
4 changes: 2 additions & 2 deletions assets/js/theme/cart/shipping-estimator.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export default class ShippingEstimator {
// Requests the states for a country with AJAX
stateCountry(this.$state, this.context, { useIdForStates: true }, (err, field) => {
if (err) {
swal({
swal.fire({
text: err,
type: 'error',
icon: 'error',
});

throw new Error(err);
Expand Down
10 changes: 6 additions & 4 deletions assets/js/theme/global/sweet-alert.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import sweetAlert from 'sweetalert2';

// Set defaults for sweetalert2 popup boxes
sweetAlert.setDefaults({
const Swal = sweetAlert.mixin({
buttonsStyling: false,
confirmButtonClass: 'button',
cancelButtonClass: 'button',
customClass: {
confirmButton: 'button',
cancelButton: 'button',
},
});

// Re-export
export default sweetAlert;
export default Swal;
Loading

0 comments on commit a90c867

Please sign in to comment.