S2OJ/web/js/bootstrap-dialog.min.js

3 lines
30 KiB
JavaScript
Raw Normal View History

2023-02-05 11:58:30 +00:00
/*! Bootstrap5 Dialog | https://github.com/GedMarc/bootstrap4-dialog */
(function(root,factory){"use strict";if(typeof module!=="undefined"&&module.exports){module.exports=factory(require("jquery"),require("bootstrap"))}else if(typeof define==="function"&&define.amd){define("bootstrap-dialog",["jquery","bootstrap"],function($){return factory($)})}else{root.BootstrapDialog=factory(root.jQuery)}})(this?this:window,function($){"use strict";var Modal=bootstrap.Modal?bootstrap.Modal:$.fn.modal.Constructor;var BootstrapDialogModal=function(element,options){if(bootstrap&&bootstrap.Modal&&/^5\.[^\D0]\./.test(bootstrap.Modal.VERSION)){return new Modal(element,options)}else if(bootstrap&&bootstrap.Modal&&/^5\.0\.2/.test(bootstrap.Modal.VERSION)){return new Modal(element,options)}else if(/4\.1\.\d+/.test($.fn.modal.Constructor.VERSION)){return new Modal(element,options)}else{Modal.call(this,element,options)}};BootstrapDialogModal.getModalVersion=function(){var version=null;if(bootstrap&&bootstrap.Modal&&/^5\.[^\D0]\./.test(bootstrap.Modal.VERSION)){version="v5.1"}else if(bootstrap&&bootstrap.Modal&&/^5\.0\.[23456789]/.test(bootstrap.Modal.VERSION)){version="v5.1"}else if(typeof $.fn.modal.Constructor.VERSION==="undefined"){version="v3.1"}else if(/3\.2\.\d+/.test($.fn.modal.Constructor.VERSION)){version="v3.2"}else if(/3\.3\.[1,2]/.test($.fn.modal.Constructor.VERSION)){version="v3.3"}else if(/4\.\d\.\d+/.test($.fn.modal.Constructor.VERSION)){version="v4.1"}else{version="v3.3.4"}return version};BootstrapDialogModal.ORIGINAL_BODY_PADDING=parseInt($("body").css("padding-right")||0,10);BootstrapDialogModal.METHODS_TO_OVERRIDE={};BootstrapDialogModal.METHODS_TO_OVERRIDE["v3.1"]={};BootstrapDialogModal.METHODS_TO_OVERRIDE["v3.2"]={hide:function(e){if(e){e.preventDefault()}e=$.Event("hide.bs.modal");this.$element.trigger(e);if(!this.isShown||e.isDefaultPrevented()){return}this.isShown=false;var openedDialogs=this.getGlobalOpenedDialogs();if(openedDialogs.length===0){this.$body.removeClass("modal-open")}this.resetScrollbar();this.escape();$(document).off("focusin.bs.modal");this.$element.removeClass("in").attr("aria-hidden",true).off("click.dismiss.bs.modal");$.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",$.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal()}};BootstrapDialogModal.METHODS_TO_OVERRIDE["v3.3"]={setScrollbar:function(){var bodyPad=BootstrapDialogModal.ORIGINAL_BODY_PADDING;if(this.bodyIsOverflowing){this.$body.css("padding-right",bodyPad+this.scrollbarWidth)}},resetScrollbar:function(){var openedDialogs=this.getGlobalOpenedDialogs();if(openedDialogs.length===0){this.$body.css("padding-right",BootstrapDialogModal.ORIGINAL_BODY_PADDING)}},hideModal:function(){this.$element.hide();this.backdrop($.proxy(function(){var openedDialogs=this.getGlobalOpenedDialogs();if(openedDialogs.length===0){this.$body.removeClass("modal-open")}this.resetAdjustments();this.resetScrollbar();this.$element.trigger("hidden.bs.modal")},this))}};BootstrapDialogModal.METHODS_TO_OVERRIDE["v3.3.4"]=$.extend({},BootstrapDialogModal.METHODS_TO_OVERRIDE["v3.3"]);BootstrapDialogModal.METHODS_TO_OVERRIDE["v4.1"]=$.extend({},BootstrapDialogModal.METHODS_TO_OVERRIDE["v3.3"]);BootstrapDialogModal.METHODS_TO_OVERRIDE["v5.1"]=$.extend({},BootstrapDialogModal.METHODS_TO_OVERRIDE["v4.1"]);BootstrapDialogModal.prototype={constructor:BootstrapDialogModal,getGlobalOpenedDialogs:function(){var openedDialogs=[];$.each(BootstrapDialog.dialogs,function(id,dialogInstance){if(dialogInstance.isRealized()&&dialogInstance.isOpened()){openedDialogs.push(dialogInstance)}});return openedDialogs}};BootstrapDialogModal.prototype=$.extend(BootstrapDialogModal.prototype,Modal.prototype,BootstrapDialogModal.METHODS_TO_OVERRIDE[BootstrapDialogModal.getModalVersion()]);var BootstrapDialog=function(options){this.defaultOptions=$.extend(true,{id:BootstrapDialog.newGuid(),buttons:[],data:{},onshow:null,onshown:null,onhide:null,onhidden:null},BootstrapDialog.defaultOptions);this.indexedButtons={};this.registeredButtonHotkeys={};this.draggableData={isMouseDown:false,mouseOffset:{}};this.realized=false;this