Dialogs and Notification Logs using Jquery
Submitted by jaredgwapo on Thursday, December 31, 2015 - 03:41.
Language
In this tutorial, we are going to learn about dialogs and notification logs using jquery. You can use this in your systems or projects. just download the source code.
To try this tutorial just download and run this tutorial. If you have question, suggestion or anything, just leave comment and it's my pleasure to entertain your comments or email me at [email protected]
Instructions
Link the css and js scipts
Writing the javascript code
- <script>
- function reset () {
- $("#toggleCSS").attr("href", "../themes/alertify.bootstrap.css");
- alertify.set({
- labels : {
- ok : "OK",
- cancel : "Cancel"
- },
- delay : 5000,
- buttonReverse : false,
- buttonFocus : "ok"
- });
- }
- // ==============================
- // Standard Dialogs
- $("#alert").on( 'click', function () {
- reset();
- alertify.alert("This is an alert dialog");
- return false;
- });
- $("#confirm").on( 'click', function () {
- reset();
- alertify.confirm("This is a confirm dialog", function (e) {
- if (e) {
- alertify.success("You've clicked OK");
- } else {
- alertify.error("You've clicked Cancel");
- }
- });
- return false;
- });
- $("#prompt").on( 'click', function () {
- reset();
- alertify.prompt("This is a prompt dialog", function (e, str) {
- if (e) {
- alertify.success("You've clicked OK and typed: " + str);
- } else {
- alertify.error("You've clicked Cancel");
- }
- }, "Default Value");
- return false;
- });
- // ==============================
- // Ajax
- $("#ajax").on("click", function () {
- reset();
- alertify.confirm("Confirm?", function (e) {
- if (e) {
- alertify.alert("Successful AJAX after OK");
- } else {
- alertify.alert("Successful AJAX after Cancel");
- }
- });
- });
- // ==============================
- // Standard Dialogs
- $("#notification").on( 'click', function () {
- reset();
- alertify.log("Standard log message");
- return false;
- });
- $("#success").on( 'click', function () {
- reset();
- alertify.success("Success log message");
- return false;
- });
- $("#error").on( 'click', function () {
- reset();
- alertify.error("Error log message");
- return false;
- });
- // ==============================
- // Custom Properties
- $("#delay").on( 'click', function () {
- reset();
- alertify.set({ delay: 10000 });
- alertify.log("Hiding in 10 seconds");
- return false;
- });
- $("#forever").on( 'click', function () {
- reset();
- alertify.log("Will stay until clicked", "", 0);
- return false;
- });
- $("#labels").on( 'click', function () {
- reset();
- alertify.set({ labels: { ok: "Accept", cancel: "Deny" } });
- alertify.confirm("Confirm dialog with custom button labels", function (e) {
- if (e) {
- alertify.success("You've clicked OK");
- } else {
- alertify.error("You've clicked Cancel");
- }
- });
- return false;
- });
- $("#focus").on( 'click', function () {
- reset();
- alertify.set({ buttonFocus: "cancel" });
- alertify.confirm("Confirm dialog with cancel button focused", function (e) {
- if (e) {
- alertify.success("You've clicked OK");
- } else {
- alertify.error("You've clicked Cancel");
- }
- });
- return false;
- });
- $("#order").on( 'click', function () {
- reset();
- alertify.set({ buttonReverse: true });
- alertify.confirm("Confirm dialog with reversed button order", function (e) {
- if (e) {
- alertify.success("You've clicked OK");
- } else {
- alertify.error("You've clicked Cancel");
- }
- });
- return false;
- });
- // ==============================
- // Custom Log
- $("#custom").on( 'click', function () {
- reset();
- alertify.custom = alertify.extend("custom");
- alertify.custom("I'm a custom log message");
- return false;
- });
- // ==============================
- // Custom Themes
- $("#bootstrap").on( 'click', function () {
- reset();
- $("#toggleCSS").attr("href", "../themes/alertify.bootstrap.css");
- alertify.prompt("Prompt dialog with bootstrap theme", function (e) {
- if (e) {
- alertify.success("You've clicked OK");
- } else {
- alertify.error("You've clicked Cancel");
- }
- }, "Default Value");
- return false;
- });
- </script>
Writing the HTML code
Whole Source Code
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <link rel="stylesheet" href="../themes/alertify.core.css" />
- <link rel="stylesheet" href="../themes/alertify.bootstrap.css" id="toggleCSS" />
- <meta name="viewport" content="width=device-width">
- </head>
- <body>
- <center>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <table border="1px" cellpadding="10">
- <thead>
- </tr>
- </tr>
- <tr>
- <tr>
- </thead>
- <tbody>
- <tr>
- </tr>
- <tr>
- </tr>
- <tr>
- </tr>
- <tr>
- </tr>
- <tr>
- </tr>
- <tr>
- </tr>
- </tr>
- </tr>
- </tr>
- </tr>
- </tbody>
- </table>
- </center>
- <script>
- function reset () {
- $("#toggleCSS").attr("href", "../themes/alertify.bootstrap.css");
- alertify.set({
- labels : {
- ok : "OK",
- cancel : "Cancel"
- },
- delay : 5000,
- buttonReverse : false,
- buttonFocus : "ok"
- });
- }
- // ==============================
- // Standard Dialogs
- $("#alert").on( 'click', function () {
- reset();
- alertify.alert("This is an alert dialog");
- return false;
- });
- $("#confirm").on( 'click', function () {
- reset();
- alertify.confirm("This is a confirm dialog", function (e) {
- if (e) {
- alertify.success("You've clicked OK");
- } else {
- alertify.error("You've clicked Cancel");
- }
- });
- return false;
- });
- $("#prompt").on( 'click', function () {
- reset();
- alertify.prompt("This is a prompt dialog", function (e, str) {
- if (e) {
- alertify.success("You've clicked OK and typed: " + str);
- } else {
- alertify.error("You've clicked Cancel");
- }
- }, "Default Value");
- return false;
- });
- // ==============================
- // Ajax
- $("#ajax").on("click", function () {
- reset();
- alertify.confirm("Confirm?", function (e) {
- if (e) {
- alertify.alert("Successful AJAX after OK");
- } else {
- alertify.alert("Successful AJAX after Cancel");
- }
- });
- });
- // ==============================
- // Standard Dialogs
- $("#notification").on( 'click', function () {
- reset();
- alertify.log("Standard log message");
- return false;
- });
- $("#success").on( 'click', function () {
- reset();
- alertify.success("Success log message");
- return false;
- });
- $("#error").on( 'click', function () {
- reset();
- alertify.error("Error log message");
- return false;
- });
- // ==============================
- // Custom Properties
- $("#delay").on( 'click', function () {
- reset();
- alertify.set({ delay: 10000 });
- alertify.log("Hiding in 10 seconds");
- return false;
- });
- $("#forever").on( 'click', function () {
- reset();
- alertify.log("Will stay until clicked", "", 0);
- return false;
- });
- $("#labels").on( 'click', function () {
- reset();
- alertify.set({ labels: { ok: "Accept", cancel: "Deny" } });
- alertify.confirm("Confirm dialog with custom button labels", function (e) {
- if (e) {
- alertify.success("You've clicked OK");
- } else {
- alertify.error("You've clicked Cancel");
- }
- });
- return false;
- });
- $("#focus").on( 'click', function () {
- reset();
- alertify.set({ buttonFocus: "cancel" });
- alertify.confirm("Confirm dialog with cancel button focused", function (e) {
- if (e) {
- alertify.success("You've clicked OK");
- } else {
- alertify.error("You've clicked Cancel");
- }
- });
- return false;
- });
- $("#order").on( 'click', function () {
- reset();
- alertify.set({ buttonReverse: true });
- alertify.confirm("Confirm dialog with reversed button order", function (e) {
- if (e) {
- alertify.success("You've clicked OK");
- } else {
- alertify.error("You've clicked Cancel");
- }
- });
- return false;
- });
- // ==============================
- // Custom Log
- $("#custom").on( 'click', function () {
- reset();
- alertify.custom = alertify.extend("custom");
- alertify.custom("I'm a custom log message");
- return false;
- });
- // ==============================
- // Custom Themes
- $("#bootstrap").on( 'click', function () {
- reset();
- $("#toggleCSS").attr("href", "../themes/alertify.bootstrap.css");
- alertify.prompt("Prompt dialog with bootstrap theme", function (e) {
- if (e) {
- alertify.success("You've clicked OK");
- } else {
- alertify.error("You've clicked Cancel");
- }
- }, "Default Value");
- return false;
- });
- </script>
- </body>
- </html>
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Add new comment
- 111 views