mttbernardini / dialog

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

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

License:MIT License


Languages

Language:JavaScript 52.5%Language:HTML 31.0%Language:CSS 16.5%