cloudcmd/modules/smalltalk/README.md
2017-10-09 11:08:13 +03:00

2.9 KiB

Smalltalk License NPM version Dependency Status Build Status Coverage

Simple Promise-based replacement of native Alert, Confirm and Prompt.

Install

With help of bower.

bower install smalltalk

Or npm:

npm i smalltalk

API

In every method of smalltalk last parameter options is optional and could be used for preventing of handling cancel event.

{
    cancel: true /* default */
}

smalltalk.alert(title, message)

Alert

smalltalk
    .alert('Error', 'There was an error!')
    .then(() => {
        console.log('ok');
    });

smalltalk.confirm(title, message [, options])

Confirm

smalltalk
    .confirm('Question', 'Are you sure?')
    .then(() => {
        console.log('yes');
    .catch(() => {
        console.log('no');
    });

smalltalk.prompt(title, message, value [, options])

Prompt

smalltalk
    .prompt('Question', 'How old are you?', '10')
    .then((value) => {
        console.log(value);
    .catch(() => {
        console.log('cancel');
    });

Use type='password' for password fields:

smalltalk
    .prompt('Question', 'How old are you?', '10', {
        type: 'password',
    })
    .then((value) => {
        console.log(value);
    .catch(() => {
        console.log('cancel');
    });

Bundlers

When webpack rollup or browserify used, you can import es5 version with:

import smalltalk from 'smalltalk/legacy';

License

MIT