Skip to content

Instantly share code, notes, and snippets.

@TavaresDylan
Last active September 25, 2019 06:40
Show Gist options
  • Select an option

  • Save TavaresDylan/cd3a2024150ce3b508802a04e69d3075 to your computer and use it in GitHub Desktop.

Select an option

Save TavaresDylan/cd3a2024150ce3b508802a04e69d3075 to your computer and use it in GitHub Desktop.
Toastr : Messages Flash

Toastr: Messages Flash

TOASTR

Toastr est une bibliothèque Javascript nous permettant d'envoyer des "flash messages" c'est à dire des messages d'action qui apparaîtrons quand par exemple l'utilisateur se connectera pour le notifier de sa connection.

CDN

Link :

  • Css <link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet" />

(avant la fermeture de la balise <head>)

Scripts :

  • Jquery <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
  • toastr <script src="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>

( avant la fermeture de la balise </body>)

Un Fichier Javascript ou en raw dans le fichier php :

$(function(){

            toastr.options = {
                "closeButton": true,
                "debug": false,
                "newestOnTop": false,
                "progressBar": true,
                "positionClass": "toast-top-right",
                "preventDuplicates": false,
                "onclick": null,
                "showDuration": "300",
                "hideDuration": "1000",
                "timeOut": "5000",
                "extendedTimeOut": "1000",
                "showEasing": "swing",
                "hideEasing": "linear",
                "showMethod": "fadeIn",
                "hideMethod": "fadeOut"
            }
            toastr['success']("Success");
            toastr['info']("Infos");
            toastr['warning']("Warning");
            toastr['error']("Error");
        })
        ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment