Added: BSDialog 27 minified

This commit is contained in:
Ray 2019-09-19 00:14:30 +01:00
parent e9fa5a7f4b
commit 90e17767c0

5
2019/09/bsdialog-v0.1.0.027.min.js vendored Normal file
View File

@ -0,0 +1,5 @@
/**
* BSDialog
* @version v0.1.0.027 (2019/09/19 0002)
*/
var BSDialog={Create:function(o,t,d,e,a){var s=this;s.id=o,s.title=t,s.url=d,s.isBig=void 0!==e&&1==e;var l=void 0===a||1==a;s.Exists(o)||s.renderContent(null),null!=d&&$.ajax({url:d,cache:!1,timeout:6e4,success:function(t,d,e){200==e.status||302==e.status||301==e.status?l?s.updateContentBody(o,t):$("#dlg"+o).find(".modal-content").html(t):s.updateContentBody(o,e.statusText+" ("+e.status+")")},error:function(t){s.updateContentBody(o,t.statusText+" ("+t.status+")")},complete:function(o,t){}}),s.initialiseComponents()},Close:function(o){$("#dlg"+o).modal("hide")},Clear:function(){$("body > div[class~='modal'][role='dialog']").remove(),$("body > div[class~='modal-backdrop']").remove(),$("body").removeClass("modal-open")},ShowToast:function(o,t,d,e){var a=this;a.Exists(o)||(a.id=o,a.title=t,a.url=null,a.isBig=void 0!==e&&1==e,a.renderContent(d),a.initialiseComponents())},Exists:function(o){return $("body > div[id='dlg"+o+"']").length>0},generateModalHtml:function(o){var t=this,d=void 0===t.isBig?"md":1==t.isBig?"lg":"md",e="";return e+='<div class="modal fade" id="dlg'+t.id+'" tabindex="-1" role="dialog" aria-labelledby="dlg'+t.id+'Label" aria-hidden="true">',e+=' <div class="modal-dialog modal-'+d+'">',e+=' <div class="modal-content">',e+=' <div class="modal-header">',e+=' <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>',e+=' <span class="close">&nbsp;</span>',e+=' <button type="button" class="close" data-modal-action="restore" aria-hidden="true">&#8722;</button>',e+=' <strong class="modal-title" style="cursor:default; ">'+t.title+"</strong>",e+=" </div>",$.trim(o).length<=0?e+=' <div class="modal-body custom-loading"></div>':e+=' <div class="modal-body">'+o+"</div>",e+=' <div class="modal-footer">',e+=' <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>',e+=" </div>",e+=" </div>",e+=" </div>",e+="</div>"},renderContent:function(o){$("body").append(this.generateModalHtml(o))},initialiseComponents:function(){var o=this,t=o.getElement(),d=$(t).find("button[data-modal-action='restore']");$(d).length>0&&($(d).off("click"),$(d).on("click",function(){o.toggleSize()})),$(t).modal("show"),$(t).off("hide.bs.modal"),$(t).on("hide.bs.modal",function(){$(t).next().is("div[class~='modal-backdrop']")&&$(t).next().remove(),$(t).remove()}),$(t).find(".modal-header").off("mousedown"),$(t).find(".modal-header").on("mousedown",function(o){var d=o.pageX-$(this).offset().left,e=o.pageY-$(this).offset().top;$("body").off("mousemove.draggable"),$("body").on("mousemove.draggable",function(o){$(t).children(".modal-dialog").offset({left:o.pageX-d,top:o.pageY-e})}),$("body").off("mouseup"),$("body").on("mouseup",function(){$("body").off("mousemove.draggable")}),$(t).off("bs.modal.hide"),$(t).on("bs.modal.hide",function(){$("body").off("mousemove.draggable")})})},updateContentBody:function(o,t){var d=$("#dlg"+o).find(".modal-body");$(d).hasClass("custom-loading")&&$(d).removeClass("custom-loading"),$(d).html(t)},getElement:function(){return $("#dlg"+this.id)},toggleSize:function(){var o=$(this.getElement()).find("div[class^='modal-dialog']");$(o).length<=0||($(o).hasClass("modal-md")?($(o).removeClass("modal-md"),$(o).addClass("modal-lg")):$(o).hasClass("modal-lg")&&($(o).removeClass("modal-lg"),$(o).addClass("modal-md")))}};