# popupS Native Javascript Module to display beautiful popups. With react support! Demo: http://chieforz.github.io/popupS ## Features * Native Javascript / No jQuery dependency * Built in CSS spinner for asynchronous dialogs * Smart focus on form elements * AMD support ******** ## Installation The plugin can be used as a Common JS module, an AMD module, or a global. ### Usage with Browserify Install with npm, use with [Browserify](http://browserify.org/) ``` > npm install popups ``` and in your code ```javascript var popupS = require('popups'); popupS.alert({ content: 'Hello World!' }); ``` For the basic styling and fade in and out to be working, you have to include the [popupS.css](css/popupS.css) in your header. ```html ``` ### Usage as browser global You can include [popupS.js](dist/popupS.js) directly in a script tag. For the basic styling and fade in and out to be working, you have to include the [popupS.css](css/popupS.css). ```html ``` > For both files `popupS.js` and `popupS.css` is a minified productive version in it's corresponding folder. ******** ## How to use Create a popup window: ```javascript popupS.window({ mode: 'alert', content: 'Hey' }); // or popupS.alert({ content: 'Hello' }); ``` Here are multiple ways to create popupS: ### Alerts ```javascript popupS.alert({ title: 'I am an', content: 'Alert' }); ``` ### Confirm Confirm configuration involves the use of callbacks to be applied. ```javascript popupS.confirm({ content: 'Do you like what you see?', labelOk: 'Yes', labelCancel: 'No', onSubmit: function() { console.log(':)'); }, onClose: function() { console.log(':('); } }); ``` ### Prompt Prompts are used for asking a single question. ```javascript popupS.prompt({ content: 'What is your name?', placeholder: '>>>', onSubmit: function(val) { if(val) { popupS.alert({ content: 'Hello, ' + val }); } else { popupS.alert({ content: ':(' }); } } }); ``` ### Modal With Modals you are in full control. ```javascript popupS.modal({ title: 'Himalaya', content: { tag: 'img#himalaya.picture', src: 'http://static.hdw.eweb4.com/media/wallpapers_1920x1080/nature/1/1/himalaya-nature-hd-wallpaper-1920x1080-6944.jpg' } }); ``` > there is some magic sugar involved. learn more about it [here](#dom-generation) ### Ajax It can also work in asynchronous mode and retrieve content from external pages. ```javascript popupS.ajax({ title: 'Himalaya', ajax: { url: 'http://static.hdw.eweb4.com/media/wallpapers_1920x1080/nature/1/1/himalaya-nature-hd-wallpaper-1920x1080-6944.jpg' } }); ``` ******** ## Options ```javascript popupS.window({ mode: 'alert'|'confirm'|'prompt'|'modal'|'modal-ajax', title: 'Title', content : 'Text'|'