Skip to content

ℹ️ A simple JS library for minimal dialog boxes on webpages.

License

Notifications You must be signed in to change notification settings

mttbernardini/dialog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dialog.js

Codacy Badge

This project is a light JS library providing basic asynchronous modal dialogs for webpages, aiming to replace the built-in alert(), prompt() and confirm() which instead block JavaScript execution.

The library provides one function dialog() in the global namespace (window), taking as argument an object of properties and returning a Promise resolving to the result object.

prop = {
	type: "alert",
	title: "Message",
	content: "Hello, world!",
};

dialog(prop).then(myFunc);
// Shows the dialog box and calls `myFunc` after closing it

How to use

The inclusion on a project is straightforward and only consist of adding the script and the default stylesheet:

<link rel="stylesheet" type="text/css" href="/path/to/dialog_default.css">
<script type="text/javascript" src="/path/to/dialog.js"></script>

Documentation

A short and effective documentation for all the supported properties can be found at the beginning of the dialog.js file.

A more detailed documentation providing examples can be found in the wiki

Live demo

You can see three live examples here.

Compatibility

The software is compatible with all major browsers. A polyfill might be needed in order to support Promises, no other ES6 features are used.

The stylesheet is W3C valid. A prefixer (like -prefix-free) might be needed in order to add vendor prefixes.

License and sharing

© 2015 Matteo Bernardini, @mttbernardini.

This project is licensed under the MIT License.
Please refer to the LICENSE file for further information.