source: public/assets/js/examples/sweet-alert.js@ ac3f217

develop
Last change on this file since ac3f217 was 194a359, checked in by beratkjufliju <kufliju@…>, 3 years ago

added departments, edited users and added user settings

  • Property mode set to 100644
File size: 2.7 KB
Line 
1'use strict';
2$(document).ready(function () {
3 $('.sweet-basic').on('click', function () {
4 swal('Hello world!');
5 });
6 $('.sweet-success').on('click', function () {
7 swal("Good job!", "You clicked the button!", "success");
8 });
9 $('.sweet-warning').on('click', function () {
10 swal("Good job!", "You clicked the button!", "warning");
11 });
12 $('.sweet-error').on('click', function () {
13 swal("Good job!", "You clicked the button!", "error");
14 });
15 $('.sweet-info').on('click', function () {
16 swal("Good job!", "You clicked the button!", "info");
17 });
18
19 $('.sweet-multiple').on('click', function () {
20 swal({
21 title: "Are you sure?",
22 text: "Once deleted, you will not be able to recover this imaginary file!",
23 icon: "warning",
24 buttons: true,
25 dangerMode: true,
26 })
27 .then((willDelete) => {
28 if (willDelete) {
29 swal("Poof! Your imaginary file has been deleted!", {
30 icon: "success",
31 });
32 } else {
33 swal("Your imaginary file is safe!", {
34 icon: "error",
35 });
36 }
37 });
38 });
39 $('.sweet-prompt').on('click', function () {
40 swal("Write something here:", {
41 content: "input",
42 })
43 .then((value) => {
44 swal(`You typed: ${value}`);
45 });
46 });
47 $('.sweet-ajax').on('click', function () {
48 swal({
49 text: 'Search for a movie. e.g. "La La Land".',
50 content: "input",
51 button: {
52 text: "Search!",
53 closeModal: false,
54 },
55 })
56 .then(name => {
57 if (!name) throw null;
58 return fetch(`https://itunes.apple.com/search?term=${name}&entity=movie`);
59 })
60 .then(results => {
61 return results.json();
62 })
63 .then(json => {
64 const movie = json.results[0];
65 if (!movie) {
66 return swal("No movie was found!");
67 }
68 const name = movie.trackName;
69 const imageURL = movie.artworkUrl100;
70 swal({
71 title: "Top result:",
72 text: name,
73 icon: imageURL,
74 });
75 })
76 .catch(err => {
77 if (err) {
78 swal("Oh noes!", "The AJAX request failed!", "error");
79 } else {
80 swal.stopLoading();
81 swal.close();
82 }
83 });
84 });
85});
Note: See TracBrowser for help on using the repository browser.