diff --git a/sweetalert/sweetalert-tests.ts b/sweetalert/sweetalert-tests.ts index ca0faacbf9..b6fa2aa1ad 100644 --- a/sweetalert/sweetalert-tests.ts +++ b/sweetalert/sweetalert-tests.ts @@ -91,8 +91,27 @@ swal({ } ); +// With a loader (for AJAX request for example) +swal({ + title: "Ajax request example", + text: "Submit to run ajax request", + type: "info", + showCancelButton: true, + closeOnConfirm: false, + showLoaderOnConfirm: true +}, + function () { + setTimeout(function () { + swal("Ajax request finished!"); + }, 2000); + }); + swal.setDefaults({ confirmButtonColor: "#000000" }); swal.close(); -swal.showInputError("Invalid email!"); \ No newline at end of file +swal.showInputError("Invalid email!"); + +swal.disableButtons(); + +swal.enableButtons(); \ No newline at end of file diff --git a/sweetalert/sweetalert.d.ts b/sweetalert/sweetalert.d.ts index 61b643c32a..ca48097f44 100644 --- a/sweetalert/sweetalert.d.ts +++ b/sweetalert/sweetalert.d.ts @@ -1,4 +1,4 @@ -// Type definitions for SweetAlert 1.0.1 +// Type definitions for SweetAlert 1.1.0 // Project: https://github.com/t4t5/sweetalert/ // Definitions by: Markus Peloso // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -62,7 +62,7 @@ declare module SweetAlert { /** * Use this to change the background color of the "Confirm"-button (must be a HEX value). - * Default: "#AEDEF4" + * Default: "#8CD4F5" */ confirmButtonColor?: string; @@ -131,6 +131,12 @@ declare module SweetAlert { * Default: null */ inputValue?: string; + + /** + * Set to true to disable the buttons and show that something is loading. + * Default: false + */ + showLoaderOnConfirm?: boolean; } interface Settings extends SettingsBase { @@ -195,5 +201,15 @@ declare module SweetAlert { * Show an error message after validating the input field, if the user's data is bad. */ showInputError(errorMessage: string): void; + + /** + * Enable the user to click on the cancel and confirm buttons. + */ + enableButtons(): void; + + /** + * Disable the user to click on the cancel and confirm buttons. + */ + disableButtons(): void; } } \ No newline at end of file