Socket
Socket
Sign inDemoInstall

dialog-promise

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dialog-promise

Dialog that returns promises


Version published
Weekly downloads
1
decreased by-95.83%
Maintainers
1
Weekly downloads
 
Created
Source

dialog-promise

Dialog that returns promises

extending npm-version downloads build climate dependencies qa-control

language: English also available in: Spanish

API

alertPromise, confirmPromise & promptPromise

Implements alert, confirm & prompt functions with Promises

Use

<link rel="stylesheet" type="text/css" href="dialog-promise.css">
<script src="dialog-promise.js"></script>
<button onclick='example2(this)'>example</button>
<script>
function example2(button){
    var theName = "previous Name";
    promptPromise("What's your name?", theName).then(function(name){
        theName = name;
        return confirmPromise("Do you want to know my name?");
    }).then(function(result){
        return alertPromise("Hi "+theName+". My name is DialogPromise");
    }).then(function(){
        button.textContent='try again!';
    },function(err){
        console.log("User Escapes. Don't insist.")
    });
}
</script>

alertPromise, confirmPromise, promptPromise

Recives a mensage (and an object with options). These are versions of the native funcions alert, confirm y prompt

functionreturned value
alerttrue
confirmtrue or false
prompta string with the entered text

If Escape is pressed or the mouse clicked outside the dialog the function returns a rejected promise.

Options

The options could be passed to all of these functions

optiondefuse
underElementnullthe dialog apears below this element. If no element is passed the dialog apears in the center of the window
withCloseButtontruedisplay the close button
mainAttrs{}attributes for main dialog window
rejecttruetrue if rejects the promise when close by the close button, Esc key or clicking outside of the dialog
closeValueundefinedvalue if rejects the promise when close by the close button, Esc key or clicking outside of the dialog
buttonDef{label:'Ok', value:true}main button of the alertPromise dialog
askForNoRepeatfalseid (or object) to permits the user to ask to remember de answer

miniMenuPromise(elementsList[, opts])

Display a menu

<script src="dialog-promise.js"></script>
<button id=theButton onclick='example3(this)'>example</button>
<script>
function example3(button){
    miniMenuPromise([
        {value:'ar', img:'ar.png', label:'Argentina'},
        {value:'cl', img:'cl.png', label:'Chile'},
        {value:'uy', img:'uy.png', label:'Uruguay'},
    ], {underElement: theButton}).then(function(option){
        return alertPromise("val = "+option);
    });
}
</script>

miniMenuPromise elementList

The options could be passed to all of these functions

optionuse
labeltext to show
valuevalue when click. If not set the row is not clickeable.
imgimage url
startGroupif it starts a group (puts a little line)
imgStyleobject with style attributes for the image
displayFunalternate function to create cells of the row
doneFunalternate function to callback when the option was selected instead of resolving the promise
labelsarray of texts to show (in table)

License

MIT

FAQs

Package last updated on 16 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc