Promise Confirmation Dialog In Pure JavaScript – ExConfirmBox

Category: Javascript , Modal & Popup | October 12, 2018
Author: azcpavel
Views Total: 151
Official Page: Go to website
Last Update: October 12, 2018
License: MIT

Preview:

Promise Confirmation Dialog In Pure JavaScript – ExConfirmBox

Description:

ExConfirmBox is a lightweight, zero-dependency JavaScript plugin to create custom promise confirmation dialogs on the webpage.

Fully customizable and easy-to-style in the JavaScript. Without any CSS.

How to use it:

Import the JavaScript file ‘exConfirm.js’ into the document and you’re ready to go.

<script src="exConfirm.js"></script>

Set the title & confirm message.

var configOpt = {
    title: "Sample Title!",
    message : "Sample Query?"
};

Activate the confirmation dialog with confirm/cancel callbacks.

exConfirmPromise.make(configOpt).then(function (e) {
  // do something
}).then(function () {
  exConfirmPromise.make(configOpt).then(function (e) {
    // do something
  });
});

Customize the appearance of the confirmation dialog.

var configOpt = {
    zIndex: 9999, //Integer
    overlayBackground: "rgba(255,255,255,0)", //String [HEX, RGB, RGBA]
    bodyBackground: "rgba(255,255,255,1)", //String [HEX, RGB, RGBA]
    bodyBorder: "2px solid #1c84ef", //String
    titleBackground: "rgb(28, 132, 239)", //String [HEX, RGB, RGBA]
    textColor: "#000000", //String [HEX, RGB, RGBA]
    titleColor: "#ffffff", //String [HEX, RGB, RGBA]
    btnPosition: "right", //String [left, center, right]
    top: "5%", //String [px, %]
    right: "38%", //String [px, %]
};

Enable/disable the animation.

var configOpt = {
    animation: true, //Bool
    animationTime: 500 //Integer        
};

Customize the confirm/cancel buttons.

var configOpt = {
    btnClassSuccess: "btn btn-default btn-sm btn-sm-25px", //String
    btnClassSuccessText: "Yes", //String
    btnClassFail: "btn btn-default btn-sm btn-sm-25px", //String
    btnClassFailText: "No", //String      
};

Leave a Reply