Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

26

lib/dialog-promise.js

@@ -11,3 +11,6 @@ "use strict";

return new Promise(function(resolve, reject){
var modalBackground = document.createElement('div');
modalBackground.className='dialog-promise-background';
var dialogWindow = document.createElement('div');
dialogWindow.className='dialog-promise';
for(var attrName in opts.mainAttrs) if(opts.mainAttrs.hasOwnProperty(attrName)){

@@ -17,17 +20,16 @@ dialogWindow[attrName] = opts.mainAttrs[attrName];

var body = document.body;
var closeWindow = function closeWindow(){
var closeWindow = function closeWindow(senderAnswerFunction, answer){
dialogWindow.style.display = 'none';
body.removeChild(modalBackground);
body.removeChild(dialogWindow);
senderAnswerFunction(answer);
}
var doneWithGoodAnswer = function doneWithGoodAnswer(answer){
closeWindow();
resolve(answer)
};
var doneWithException = function doneWithException(answer){
closeWindow();
reject(answer)
};
dialogConstructor(dialogWindow, doneWithGoodAnswer, doneWithException);
dialogConstructor(dialogWindow, closeWindow.bind(null,resolve), closeWindow.bind(null,reject));
body.appendChild(modalBackground);
body.appendChild(dialogWindow);
dialogWindow.style.display='block';
modalBackground.style.display='block';
modalBackground.addEventListener('click', function(){
closeWindow(opts.reject?reject:resolve,opts.closeValue);
});
});

@@ -41,3 +43,3 @@ }

button.addEventListener('click', function(){
done();
done(true);
});

@@ -48,3 +50,3 @@ var div=document.createElement('div');

mainElement.appendChild(button);
},{mainAttrs:{className: 'alert-promise'}});
});
}
{
"name": "dialog-promise",
"description": "Dialog that returns promises",
"version": "0.0.1",
"version": "0.0.2",
"author": "Codenautas <codenautas@googlegroups.com>",

@@ -6,0 +6,0 @@ "repository": "codenautas/dialog-promise",

@@ -8,3 +8,2 @@ # dialog-promise

[![build](https://img.shields.io/travis/codenautas/dialog-promise/master.svg)](https://travis-ci.org/codenautas/dialog-promise)
[![coverage](https://img.shields.io/coveralls/codenautas/dialog-promise/master.svg)](https://coveralls.io/r/codenautas/dialog-promise)
[![climate](https://img.shields.io/codeclimate/github/codenautas/dialog-promise.svg)](https://codeclimate.com/github/codenautas/dialog-promise)

@@ -20,2 +19,16 @@ [![dependencies](https://img.shields.io/david/codenautas/dialog-promise.svg)](https://david-dm.org/codenautas/dialog-promise)

## Use
```html
<script src="dialog-promise.js"></script>
<button onclick='example2(this)'>example</button>
<script>
function example2(button){
alertPromise('the button becames red').then(function(){
button.style.backgroundColor='red';
});
}
</script>
```
## License

@@ -22,0 +35,0 @@

Sorry, the diff of this file is not supported yet

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