Giter VIP home page Giter VIP logo

dialog-js's Introduction

Dialog-JS library

Dialog-JS is a lightweight JavaScript library for creating customizable dialog boxes to replace standard JavaScript dialogs (alert, prompt, confirm) with more flexible and styled options. It provides easy-to-use methods to create dialogs with custom titles, messages, buttons, and callbacks.

Dialog-JS also allows developers to integrate their own CSS styles to customize the appearance of the dialogs according to their project needs.

Please visit Dialog-JS website for a quick testing.

Table of Contents

  1. Setup the library
  2. CSS Styles
  3. About

Setup the library

To use Dialog-JS in your project, you can simply include the Dialog-JS.1.0.0.min.js and dialogjs-default-1.0.0.min.css files in your HTML file as part of the <head> HTML document section. Remember to fix the route of the files in the path.

<link rel="stylesheet" href="dialogjs-default-1.0.0.min.css">
<script src="Dialog-JS.1.0.0.min.js"></script>

If you want to optimize the HTML loading time โณ you can add the defer attribute in the scriptdeclaration without moving this line to the bottom of a HTML page.

PS: Check in the CSS Styles section another couple of styles available as a replace of the default CSS style of this JS Library.

Dialog.alert()

It creates an alert dialog with a custom title, message, and button text by passing a literal object with each property expected. Do not forget to declare any property.

Dialog.alert({
  title: "Alert",
  text: "This is an alert message.",
  buttonText: "OK"
});

Dialog.confirm()

It creates a confirmation dialog with a custom title, message, and the text of the buttons for confirmation and cancellation. You can also specify a callback function to execute when the confirmation button is clicked.

Dialog.confirm({
  title: "Confirmation",
  text: "Are you sure you want to proceed?",
  defaultButtonText: "Yes",
  cancelButtonText: "No",
  callBackFn: () => {
    console.log("Confirmed");   //this callback is executed when pressing confirmButton
  }
});

Dialog.prompt()

It creates a prompt dialog with a custom title, message, input placeholder, and buttons for confirmation and cancellation. You can also specify a callback function to receive the input value when confirmed.

Dialog.prompt({
  title: "Prompt",
  text: "Please enter your name:",
  placeholderInput: "Your Name",
  confirmButtonText: "Submit",
  cancelButtonText: "Cancel",
  callBackFn: (inputValue) => {
    console.log("Submitted: ", inputValue);   //this callback is executed when pressing confirmButton
  }
});

CSS Styles

The CSS file linked to this JS library has a couple of alternatives to implement with the Dialog windows CSS styles similar to another frameworks or operating systems.

  • dialogjs-bootstrap-1.0.0.min.css
  • dialogjs-material-1.0.0.min.css
  • dialogjs-ios-1.0.0.min.css

About

Dialog-JS is a simple yet effective JavaScript library developed by Fernando Omar Luna ๐Ÿ‡ฆ๐Ÿ‡ท. It aims to provide developers with an easy way to create customizable dialog boxes for their web projects.

Feel free to follow Fernando on (X) @mobilepadawan to say hi or send feedback about Dialog-JS.

dialog-js's People

Contributors

mobilepadawan avatar

Stargazers

 avatar

Watchers

jQueryScript avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.