From 391f692ed40f5c698b6e71f5a0b8a12919ef9276 Mon Sep 17 00:00:00 2001 From: Brijesh Bittu Date: Thu, 21 May 2015 10:50:11 +0530 Subject: [PATCH] added option to dismiss dialog when clicked on overlay --- bower.json | 2 +- js/msc-script.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index d26787f..1b2e7fc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "medium-style-confirm", - "version": "0.4.0", + "version": "0.4.1", "homepage": "http://bitwiser.i/medium-style-confirm/", "authors": [ "Brijesh Bittu " diff --git a/js/msc-script.js b/js/msc-script.js index fc0904c..9db4626 100644 --- a/js/msc-script.js +++ b/js/msc-script.js @@ -25,7 +25,8 @@ onCancel: null, okText: 'OK', cancelText: 'Cancel', - placeholder: 'Enter value' + placeholder: 'Enter value', + dismissOverlay: false }; if(typeof title === 'object') { @@ -55,6 +56,10 @@ closeBtn.innerHTML = '×'; overlay.appendChild(closeBtn); + if(options.dismissOverlay) { + overlay.addEventListener("click", destroy); + } + closeBtn.addEventListener('click', destroy); var content = ce('div', 'msc-content'), @@ -104,6 +109,9 @@ closeBtn.removeEventListener('click', destroy); okBtn.removeEventListener('click', ok); cancelbtn.removeEventListener('click', cancel); + if(options.dismissOverlay) { + overlay.removeEventListener("click", destroy); + } document.removeEventListener('keyup', _hide); document.body.removeChild(dialog); }