From 51b58fd9a695aa60652493ba8a4e8341895863d3 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 3 Aug 2023 11:29:44 +0100 Subject: [PATCH] Release 0.1.0.002 --- bsdialog4.js | 23 ++++++++++++++++------- bsdialog4.min.js | 11 ++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/bsdialog4.js b/bsdialog4.js index 3cab3e9..4659887 100644 --- a/bsdialog4.js +++ b/bsdialog4.js @@ -1,6 +1,6 @@ /** * BSDialog4 - * @version v0.1.0.001 (2019/12/27 0531) + * @version v0.1.0.002 (2021/04/25 1713) */ var BSDialog = { Create: function (id, title, url, size) { @@ -9,7 +9,16 @@ var BSDialog = { a.id = id; a.title = title; a.url = url; - a.size = ((typeof (size) == "undefined") ? "md" : size); + + if (typeof (size) == "undefined") { + a.size = "md"; + } else if (size === true) { + a.size = "lg"; + } else if (size === false) { + a.size = "md"; + } else { + a.size = size; + } if (!a.Exists(id)) { a.renderContent(null); @@ -22,7 +31,7 @@ var BSDialog = { xhrFields: { withCredentials:true }, - timeout: 20000, + timeout: 30000, success: function (result, status, xhr) { if ((xhr.status == 200) || (xhr.status == 302) || (xhr.status == 301)) { a.updateContentBody(id, result); @@ -78,7 +87,6 @@ var BSDialog = { html += " " + a.title + ""; html += " "; html += " "; - html += " "; if ($.trim(message).length <= 0) { @@ -140,12 +148,12 @@ var BSDialog = { $("body").off("mouseup"); $("body").on("mouseup", function() { - $("body").off("mousemove.draggable"); + $("body").off("mousemove.draggable"); }); $(dialog).off("bs.modal.hide"); $(dialog).on("bs.modal.hide", function() { - $("body").off("mousemove.draggable"); + $("body").off("mousemove.draggable"); }); }); }, @@ -173,7 +181,8 @@ var BSDialog = { $(div).addClass("modal-xl"); } else if ($(div).hasClass("modal-xl")) { $(div).removeClass("modal-xl"); - $(div).addClass("modal-sm"); +// $(div).addClass("modal-sm"); + $(div).addClass("modal-md"); } else if ($(div).hasClass("modal-sm")) { $(div).removeClass("modal-sm"); $(div).addClass("modal-md"); diff --git a/bsdialog4.min.js b/bsdialog4.min.js index 4de777d..b926c88 100644 --- a/bsdialog4.min.js +++ b/bsdialog4.min.js @@ -1,12 +1,5 @@ /** * BSDialog4 - * @version v0.1.0.001 (2019/12/27 0531) + * @version v0.1.0.002 (2021/04/25 1713) */ -var BSDialog={Create:function(id,title,url,size){var a=this;a.id=id;a.title=title;a.url=url;a.size=((typeof(size)=="undefined")?"md":size);if(!a.Exists(id)){a.renderContent(null)} -if(url!=null){$.ajax({url:url,cache:!1,xhrFields:{withCredentials:!0},timeout:20000,success:function(result,status,xhr){if((xhr.status==200)||(xhr.status==302)||(xhr.status==301)){a.updateContentBody(id,result)}else{a.updateContentBody(id,xhr.statusText+" ("+xhr.status+")")}},error:function(xhr){a.updateContentBody(id,xhr.statusText+" ("+xhr.status+")")},complete:function(xhr,status){}})} -a.initialiseComponents()},Close:function(id){$("#dlg"+id).modal('hide')},Clear:function(){$("body > div[class~='modal'][role='dialog']").remove();$("body > div[class~='modal-backdrop']").remove();$("body").removeClass("modal-open")},ShowToast:function(id,title,message,size){var a=this;if(a.Exists(id)){return} -a.id=id;a.title=title;a.url=null;a.size=((typeof(size)=="undefined")?"md":size);a.renderContent(message);a.initialiseComponents()},Exists:function(id){return($("body > div[id='dlg"+id+"']").length>0)},generateModalHtml:function(message){var a=this;var html="";html+="
";html+="
";html+="
";html+="
";html+=" "+a.title+"";html+=" ";html+=" ";html+="
";if($.trim(message).length<=0){html+="
";html+="
";html+="
";html+=" Loading...";html+="
";html+="
";html+="
"}else{html+="
"+message+"
"} -html+="
";html+=" ";html+="
";html+="
";html+="
";html+="
";return html},renderContent:function(content){$("body").append(this.generateModalHtml(content))},initialiseComponents:function(){var a=this;var dialog=a.getElement();var btnToggleSize=$(dialog).find("button[data-modal-action='restore']");if($(btnToggleSize).length>0){$(btnToggleSize).off('click');$(btnToggleSize).on('click',function(){a.toggleSize()})} -$(dialog).modal('show');$(dialog).off('hide.bs.modal');$(dialog).on('hide.bs.modal',function(){if($(dialog).next().is("div[class~='modal-backdrop']")){$(dialog).next().remove()} -$(dialog).remove()});$(dialog).find(".modal-header").off("mousedown");$(dialog).find(".modal-header").on("mousedown",function(e){var posX=e.pageX-$(this).offset().left;var posY=e.pageY-$(this).offset().top;$("body").off("mousemove.draggable");$("body").on("mousemove.draggable",function(e2){$(dialog).children(".modal-dialog").offset({"left":(e2.pageX-posX),"top":(e2.pageY-posY)})});$("body").off("mouseup");$("body").on("mouseup",function(){$("body").off("mousemove.draggable")});$(dialog).off("bs.modal.hide");$(dialog).on("bs.modal.hide",function(){$("body").off("mousemove.draggable")})})},updateContentBody:function(id,text){var body=$("#dlg"+id).find(".modal-body");if($(body).hasClass("custom-loading"))$(body).removeClass("custom-loading");$(body).html(text)},getElement:function(){return $("#dlg"+this.id)},toggleSize:function(){var div=$(this.getElement()).find("div[class^='modal-dialog']");if($(div).length<=0){return} -if($(div).hasClass("modal-md")){$(div).removeClass("modal-md");$(div).addClass("modal-lg")}else if($(div).hasClass("modal-lg")){$(div).removeClass("modal-lg");$(div).addClass("modal-xl")}else if($(div).hasClass("modal-xl")){$(div).removeClass("modal-xl");$(div).addClass("modal-sm")}else if($(div).hasClass("modal-sm")){$(div).removeClass("modal-sm");$(div).addClass("modal-md")}}} \ No newline at end of file +var BSDialog={Create:function(o,t,e,d){var a=this;a.id=o,a.title=t,a.url=e,a.size=void 0===d?"md":!0===d?"lg":!1===d?"md":d,a.Exists(o)||a.renderContent(null),null!=e&&$.ajax({url:e,cache:!1,xhrFields:{withCredentials:!0},timeout:3e4,success:function(t,e,d){200==d.status||302==d.status||301==d.status?a.updateContentBody(o,t):a.updateContentBody(o,d.statusText+" ("+d.status+")")},error:function(t){a.updateContentBody(o,t.statusText+" ("+t.status+")")},complete:function(o,t){}}),a.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,e,d){var a=this;a.Exists(o)||(a.id=o,a.title=t,a.url=null,a.size=void 0===d?"md":d,a.renderContent(e),a.initialiseComponents())},Exists:function(o){return $("body > div[id='dlg"+o+"']").length>0},generateModalHtml:function(o){var t=this,e="";return e+='"},renderContent:function(o){$("body").append(this.generateModalHtml(o))},initialiseComponents:function(){var o=this,t=o.getElement(),e=$(t).find("button[data-modal-action='restore']");$(e).length>0&&($(e).off("click"),$(e).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 e=o.pageX-$(this).offset().left,d=o.pageY-$(this).offset().top;$("body").off("mousemove.draggable"),$("body").on("mousemove.draggable",function(o){$(t).children(".modal-dialog").offset({left:o.pageX-e,top:o.pageY-d})}),$("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 e=$("#dlg"+o).find(".modal-body");$(e).hasClass("custom-loading")&&$(e).removeClass("custom-loading"),$(e).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-xl")):$(o).hasClass("modal-xl")?($(o).removeClass("modal-xl"),$(o).addClass("modal-md")):$(o).hasClass("modal-sm")&&($(o).removeClass("modal-sm"),$(o).addClass("modal-md")))}}; \ No newline at end of file