-
Notifications
You must be signed in to change notification settings - Fork 3
/
boot4alert.min.js
1 lines (1 loc) · 2.48 KB
/
boot4alert.min.js
1
"use strict";function Initial(o,a){var l="";if((void 0!=o.callback||o.confirm)&&!$.isFunction(o.callback))throw new Error("alert requires callback property to be a function");if(l=void 0!=o.msg?o.msg:void 0!=o.title?o.msg:o+modalTemplate.closeButton,void 0!=o.title&&0==dialog.find(".modal-header").length&&(body.before(modalTemplate.header),dialog.find(".modal-header").html(o.title+modalTemplate.closeButton)),void 0!=o.style&&dialog.find(".modal-header").css(o.style),0==dialog.find(".btn-primary").length&&(body.after(modalTemplate.footer),void 0!=o.confirmBox?dialog.find(".modal-footer").html(modalTemplate.buttonConfirm):(dialog.find(".modal-footer").html(modalTemplate.button),dialog.find(".btn").html(a))),dialog.find(".modal-body").html(l),void 0!=o.size)switch(o.size){case"sm":dialog.find(".modal-dialog").addClass("modal-sm");break;case"lg":dialog.find(".modal-dialog").addClass("modal-lg");break;case"xl":dialog.find(".modal-dialog").addClass("modal-xl")}}function processCallback(o,a,l,d){o.stopPropagation(),o.preventDefault();var t=$.isFunction(l)&&l.call(a,d,o)===!1;t||a.modal("hide")}"function"==typeof define&&define.amd?define(["jquery"]):"object"==typeof exports&&("undefined"==typeof $?module.exports=require("jquery"):module.exports=$);var modalTemplate={dialog:'<div id="boot4alert" class="modal fade"><div class="modal-dialog"><div class="modal-content"><div class="modal-body"></div></div></div></div>',header:'<div class="modal-header"><h5 class="modal-title"></h5></div>',footer:'<div class="modal-footer"></div>',closeButton:'<button class="close" style="margin-top: -15px;" data-dismiss="modal"><span>×</span></button>',button:'<button class="btn btn-primary boot4ok" data-dismiss="modal" type="button"></button>',buttonConfirm:'<button class="btn btn-secondary boot4cancel" data-dismiss="modal" type="button">Cancel</button><button class="btn btn-primary boot4ok" data-dismiss="modal" type="button">OK</button>'},dialog=$(modalTemplate.dialog),body=dialog.find(".modal-body"),callbacks={onEscape:""},boot4={alert:function(o,a,l){return Initial(o,a),$("body").append(dialog),void 0!=o.callback?($("#boot4alert").modal(l),callbacks.onEscape=o.callback):$("#boot4alert").modal(l)},confirm:function(o,a){return o.confirmBox=!0,Initial(o),$("body").append(dialog),$("#boot4alert").modal(a),callbacks.onEscape=o.callback}};dialog.on("click",".boot4ok",function(o){processCallback(o,dialog,callbacks.onEscape,!0)}),dialog.on("click",".boot4cancel",function(o){processCallback(o,dialog,callbacks.onEscape,!1)});