mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 17:05:17 +00:00
76 lines
2.2 KiB
Markdown
76 lines
2.2 KiB
Markdown
Smalltalk [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL]
|
|
====
|
|
|
|
Simple [Promise](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise)-based replacement of native Alert, Confirm and Prompt.
|
|
|
|
# Install
|
|
With help of [bower](http://bower.io "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.
|
|
|
|
```js
|
|
{
|
|
cancel: true /* default */
|
|
}
|
|
```
|
|
|
|
## smalltalk.alert(title, message [, options])
|
|
|
|

|
|
|
|
```js
|
|
smalltalk.alert('Error', 'There was an error!').then(function() {
|
|
console.log('ok');
|
|
}, function() {
|
|
console.log('cancel');
|
|
});
|
|
```
|
|
|
|
## smalltalk.confirm(title, message [, options])
|
|
|
|

|
|
|
|
```js
|
|
smalltalk.confirm('Question', 'Are you sure?').then(function() {
|
|
console.log('yes');
|
|
}, function() {
|
|
console.log('no');
|
|
});
|
|
```
|
|
|
|
## smalltalk.prompt(title, message, value [, options])
|
|
|
|

|
|
|
|
```js
|
|
smalltalk.prompt('Question', 'How old are you?', '10').then(function(value) {
|
|
console.log(value);
|
|
}, function() {
|
|
console.log('cancel');
|
|
});
|
|
```
|
|
|
|
#License
|
|
MIT
|
|
|
|
[NPMIMGURL]: https://img.shields.io/npm/v/smalltalk.svg?style=flat
|
|
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/smalltalk/master.svg?style=flat
|
|
[DependencyStatusIMGURL]: https://img.shields.io/gemnasium/coderaiser/smalltalk.svg?style=flat
|
|
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
|
|
[NPMURL]: https://npmjs.org/package/smalltalk "npm"
|
|
[BuildStatusURL]: https://travis-ci.org/coderaiser/smalltalk "Build Status"
|
|
[DependencyStatusURL]: https://gemnasium.com/coderaiser/smalltalk "Dependency Status"
|
|
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
|