eesyphp/public_html/lib/bootstrap4dialog/dist/js/bootstrap4dialog.min.js
2022-04-24 16:52:44 +02:00

1 line
No EOL
4.4 KiB
JavaScript

!function(a,d){"use strict";"undefined"!=typeof module&&module.exports?module.exports=d(require("jquery"),require("bootstrap")):"function"==typeof define&&define.amd?define("bootstrap4dialog",["jquery","bootstrap"],function(a){return d(a)}):a.Bootstrap4Dialog=d(a.jQuery)}(this?this:window,function(a){var d=function(d){a.extend(!0,this.defaultOptions,d)};d.TYPE_PRIMARY="primary",d.TYPE_SECONDARY="secondary",d.TYPE_SUCCESS="success",d.TYPE_DANGER="danger",d.TYPE_WARNING="warning",d.TYPE_INFO="info",d.TYPE_LIGHT="light",d.TYPE_DARK="dark",d.SIZE_SMALL="modal-sm",d.SIZE_MEDIUM="",d.SIZE_LARGE="modal-lg",d.SIZE_EXTRA_LARGE="modal-xl",d.BACKDROP_YES="true",d.BACKDROP_NO="",d.BACKDROP_STATIC="static",d.defaultOptions={title:"",message:"",type:d.TYPE_PRIMARY,size:d.SIZE_MEDIUM,keyboard:!0,focus:!0,scrollable:!1,centered:!1,backdrop:d.BACKDROP_YES,duration:0,autodestroy:!0,open:null,close:null,buttons:[]},d.dialog=function(d){var t,o=a.extend(!1,this.defaultOptions,d);o.show=!1;try{if(!(o.title||o.message||o.buttons&&o.buttons.length))return!1;var s=o.id||"modalWindow_"+e(),n='<div id="'+s+'" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog" role="document"><div class="modal-content">';o.title&&(n+='<div class="modal-header rounded"><h6 class="modal-title"></h6><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>'),o.message&&(n+='<div class="modal-body"></div>'),o.buttons&&o.buttons.length&&(n+='<div class="modal-footer text-center"></div>'),a("body").append(n);var l=a("#"+s);switch(o.title&&o.title.length&&l.find(".modal-title").html(o.title),o.message&&o.message.length&&l.find(".modal-body").html(o.message),!o.title||o.message||o.buttons&&o.buttons.length||l.find(".modal-header").css({"border-bottom":"0px"}),!o.title&&!o.message&&o.buttons&&o.buttons.length&&l.find(".modal-footer").css({"border-top":"0px"}),o.size&&o.size.length&&l.find(".modal-dialog").addClass(o.size),o.centered&&l.find(".modal-dialog").addClass("modal-dialog-centered"),o.scrollable&&l.find(".modal-dialog").addClass("modal-dialog-scrollable"),!0){case"primary"==o.type:l.find(".modal-header").addClass("bg-primary").find(".modal-title").addClass("text-white"),l.find(".modal-body").addClass("text-primary");break;case"secondary"==o.type:l.find(".modal-header").addClass("bg-secondary").find(".modal-title").addClass("text-white"),l.find(".modal-body").addClass("text-secondary");break;case"success"==o.type:l.find(".modal-header").addClass("bg-success").find(".modal-title").addClass("text-white"),l.find(".modal-body").addClass("text-success");break;case"danger"==o.type:l.find(".modal-header").addClass("bg-danger").find(".modal-title").addClass("text-white"),l.find(".modal-body").addClass("text-danger");break;case"warning"==o.type:l.find(".modal-header").addClass("bg-warning"),l.find(".modal-body").addClass("text-warning");break;case"info"==o.type:l.find(".modal-header").addClass("bg-info").find(".modal-title").addClass("text-white"),l.find(".modal-body").addClass("text-info");break;case"light"==o.type:l.find(".modal-header").addClass("bg-light").find(".modal-title").addClass("text-black"),l.find(".modal-body").addClass("text-black");break;case"dark"==o.type:l.find(".modal-header").addClass("bg-dark").find(".modal-title").addClass("text-white"),l.find(".modal-body").addClass("text-dark")}t=l.modal(o);try{var r=l.find(".modal-footer");for(i in o.buttons){var c=o.buttons[i];r.append('<button class="btn" />');var m=r.find("button").eq(i);c.id&&m.attr("id",c.id),c.label&&m.html(c.label),c.cssClass&&m.addClass(c.cssClass),"function"==typeof c.action&&function(a,d,e){a.bind("click",function(){d(e,a)})}(m,c.action,t)}}catch(a){console.log(a.message)}return"function"==typeof o.open&&t.on("shown.bs.modal",o.open),"function"==typeof o.close&&t.on("hidden.bs.modal",o.close),o.autodestroy&&t.on("hidden.bs.modal",function(){destroy(t)}),o.duration&&t.on("shown.bs.modal",function(){setTimeout(function(){t.modal("hide")},1e3*parseFloat(o.duration))}),t}catch(a){console.warn(a.message)}},d.show=function(a){try{return this.dialog(a).modal("show")}catch(a){console.warn(a.message)}},destroy=function(a){try{setTimeout(function(){a.remove()},200)}catch(a){console.warn(a.message)}};var e=function(){for(var a=[],d=0;d<=15;d++)a[d]=d.toString(16);var e="";for(d=1;d<=36;d++)e+=9===d||14===d||19===d||24===d?"-":15===d?4:20===d?a[4*Math.random()|8]:a[16*Math.random()|0];return e};return d});