Release 0.1.0.024
This commit is contained in:
parent
d6067a2cce
commit
f33b751090
176
bsdialog.js
176
bsdialog.js
@ -1,116 +1,112 @@
|
|||||||
/**
|
|
||||||
* BSHelper
|
|
||||||
* Bootstrap Helper
|
|
||||||
* @version v0.1.0.023 (2015/07/14 1157)
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BSDialog
|
* BSDialog
|
||||||
*
|
* @version v0.1.0.024 (2019/07/05 2210)
|
||||||
*/
|
*/
|
||||||
var BSDialog = {
|
var BSDialog = {
|
||||||
Create:function(id, title, url, is_big){
|
Create: function(id, title, url, is_big, update_body) {
|
||||||
id = "dlg" + id;
|
var a = this;
|
||||||
if ($("#" + id).length <= 0) this.Add(id, title, ((is_big == undefined)? false : is_big));
|
var isBig = ((typeof(is_big) == "undefined") ? false : (is_big == true) ? true : false);
|
||||||
//--
|
var updateBody = ((typeof(update_body) == "undefined") ? false : (update_body == true) ? true : false);
|
||||||
$("#" + id).find(".modal-content").load(url);
|
|
||||||
$("#" + id).modal('show');
|
|
||||||
$("#" + id).on('hide.bs.modal', function(){
|
|
||||||
$("body > div[id='" + id + "']").remove();
|
|
||||||
$("body > div[class~='modal-backdrop']").remove();
|
|
||||||
$("body").removeClass("modal-open");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
Add:function(id, title, is_big){
|
|
||||||
if ($("body > div#" + id).length > 0) return;
|
|
||||||
//--
|
|
||||||
var html = "";
|
|
||||||
html += "<div class=\"modal fade\" id=\"" + id + "\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"" + id + "Label\" aria-hidden=\"true\">";
|
|
||||||
html += " <div class=\"modal-dialog" + ((is_big)? " modal-lg" : "") + "\">";
|
|
||||||
html += " <div class=\"modal-content\">";
|
|
||||||
html += " <div class=\"modal-header\">";
|
|
||||||
html += " <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>";
|
|
||||||
html += " <strong class=\"modal-title\" id=\"" + id + "Label\">" + title + "</strong>";
|
|
||||||
html += " </div>";
|
|
||||||
html += " <div class=\"modal-body custom-loading\"></div>";
|
|
||||||
html += " <div class=\"modal-footer\">";
|
|
||||||
html += " <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>";
|
|
||||||
html += " </div>";
|
|
||||||
html += " </div>";
|
|
||||||
html += " </div>";
|
|
||||||
html += "</div>";
|
|
||||||
//--
|
|
||||||
$("body").append(html);
|
|
||||||
},
|
|
||||||
Close: function (id) {
|
|
||||||
if (typeof (id) == "object")
|
|
||||||
{
|
|
||||||
var sender = null;
|
|
||||||
|
|
||||||
do
|
if (!a.hasDialog(id)) {
|
||||||
{
|
var html = a.generateModalHtml(id, title, null, isBig);
|
||||||
if (typeof (id.target) != "undefined")
|
|
||||||
{
|
|
||||||
sender = id.target;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof (id) != "undefined")
|
$("body").append(html);
|
||||||
{
|
|
||||||
sender = id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while (false);
|
|
||||||
|
|
||||||
if (sender == null) return;
|
|
||||||
|
|
||||||
var panel = $(sender).parentsUntil("div[id^='dlg']").parent();
|
|
||||||
if ($(panel).length > 0)
|
|
||||||
{
|
|
||||||
var dialogID = $(panel).attr("id").substr(3);
|
|
||||||
|
|
||||||
this.Close(dialogID);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($("body > div#dlg" + id).length <= 0) return;
|
|
||||||
|
|
||||||
$("body > div#dlg" + id).remove();
|
|
||||||
$("body > div[class~='modal-backdrop']").remove();
|
|
||||||
$("body").removeClass("modal-open");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
cache: false,
|
||||||
|
timeout: 10000,
|
||||||
|
success: function(result, status, xhr){
|
||||||
|
if ((xhr.status == 200) || (xhr.status == 302) || (xhr.status == 301))
|
||||||
|
{
|
||||||
|
if (updateBody)
|
||||||
|
{
|
||||||
|
a.updateContentBody(id, result);
|
||||||
|
} else {
|
||||||
|
$("#dlg" + id).find(".modal-content").html(result);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
a.updateContentBody(id, xhr.statusText + " (" + xhr.status + ")");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr){
|
||||||
|
a.updateContentBody(id, xhr.statusText + " (" + xhr.status + ")");
|
||||||
|
},
|
||||||
|
complete: function(xhr, status){
|
||||||
|
// do nothing yet
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
a.show(id);
|
||||||
},
|
},
|
||||||
Clear:function(){
|
Close: function(id) {
|
||||||
|
if (!this.hasDialog(id)) return;
|
||||||
|
|
||||||
|
$("#dlg" + id).modal('hide');
|
||||||
|
},
|
||||||
|
Clear: function() {
|
||||||
$("body > div[class~='modal'][role='dialog']").remove();
|
$("body > div[class~='modal'][role='dialog']").remove();
|
||||||
$("body > div[class~='modal-backdrop']").remove();
|
$("body > div[class~='modal-backdrop']").remove();
|
||||||
$("body").removeClass("modal-open");
|
$("body").removeClass("modal-open");
|
||||||
},
|
},
|
||||||
ShowToast:function(id, title, message, is_big){
|
ShowToast: function(id, title, message, is_big) {
|
||||||
if ($("body > div#" + id).length > 0) return;
|
if (this.hasDialog(id)) return;
|
||||||
//--
|
|
||||||
|
var html = this.generateModalHtml(id, title, message, is_big);
|
||||||
|
$("body").append(html);
|
||||||
|
|
||||||
|
this.show(id);
|
||||||
|
},
|
||||||
|
hasDialog: function(id) {
|
||||||
|
return ($("body > div[id='dlg" + id + "']").length > 0);
|
||||||
|
},
|
||||||
|
generateModalHtml: function(id, title, message, is_big) {
|
||||||
|
var size = ((typeof(is_big) == "undefined") ? "sm" : (is_big == true ? "lg" : "sm"));
|
||||||
|
|
||||||
var html = "";
|
var html = "";
|
||||||
html += "<div class=\"modal fade\" id=\"" + id + "\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"" + id + "Label\" aria-hidden=\"true\">";
|
html += "<div class=\"modal fade\" id=\"dlg" + id + "\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"dlg" + id + "Label\" aria-hidden=\"true\">";
|
||||||
html += " <div class=\"modal-dialog" + ((is_big)? " modal-lg" : "") + "\">";
|
html += " <div class=\"modal-dialog modal-" + size + "\">";
|
||||||
html += " <div class=\"modal-content\">";
|
html += " <div class=\"modal-content\">";
|
||||||
html += " <div class=\"modal-header\">";
|
html += " <div class=\"modal-header\">";
|
||||||
html += " <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>";
|
html += " <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>";
|
||||||
html += " <strong class=\"modal-title\" id=\"" + id + "Label\">" + title + "</strong>";
|
html += " <strong class=\"modal-title\">" + title + "</strong>";
|
||||||
html += " </div>";
|
html += " </div>";
|
||||||
html += " <div class=\"modal-body\">" + message + "</div>";
|
|
||||||
|
if ($.trim(message).length <= 0)
|
||||||
|
{
|
||||||
|
html += " <div class=\"modal-body custom-loading\"></div>";
|
||||||
|
} else {
|
||||||
|
html += " <div class=\"modal-body\">" + message + "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
html += " <div class=\"modal-footer\">";
|
html += " <div class=\"modal-footer\">";
|
||||||
html += " <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>";
|
html += " <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>";
|
||||||
html += " </div>";
|
html += " </div>";
|
||||||
html += " </div>";
|
html += " </div>";
|
||||||
html += " </div>";
|
html += " </div>";
|
||||||
html += "</div>";
|
html += "</div>";
|
||||||
//--
|
|
||||||
$("body").append(html);
|
return html;
|
||||||
//--
|
},
|
||||||
$("#" + id).modal('show');
|
show: function(id) {
|
||||||
$("#" + id).on('hide.bs.modal', function(){
|
$("#dlg" + id).modal('show');
|
||||||
$("body > div[id='" + id + "']").remove();
|
$("#dlg" + id).off('hide.bs.modal');
|
||||||
$("body > div[class~='modal-backdrop']").remove();
|
$("#dlg" + id).on('hide.bs.modal', function() {
|
||||||
$("body").removeClass("modal-open");
|
if ($("body > div[id='dlg" + id + "']").next().is("div[class~='modal-backdrop']")) {
|
||||||
|
$("body > div[id='dlg" + id + "']").next().remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
$("body > div[id='dlg" + id + "']").remove();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
updateContentBody: function(id, text) {
|
||||||
|
var body = $("#dlg" + id).find(".modal-body");
|
||||||
|
|
||||||
|
if ($(body).hasClass("custom-loading")) $(body).removeClass("custom-loading");
|
||||||
|
|
||||||
|
$(body).html(text);
|
||||||
}
|
}
|
||||||
};
|
};
|
11
bsdialog.min.js
vendored
11
bsdialog.min.js
vendored
@ -1,7 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* BSHelper
|
* BSDialog
|
||||||
* Bootstrap Helper
|
* @version v0.1.0.024 (2019/07/05 2210)
|
||||||
* @version v0.1.0.023 (2015/07/14 1157)
|
|
||||||
*/
|
*/
|
||||||
var BSDialog={Create:function(id,title,url,is_big){id="dlg"+id;if($("#"+id).length<=0)this.Add(id,title,((is_big==undefined)?!1:is_big));$("#"+id).find(".modal-content").load(url);$("#"+id).modal('show');$("#"+id).on('hide.bs.modal',function(){$("body > div[id='"+id+"']").remove();$("body > div[class~='modal-backdrop']").remove();$("body").removeClass("modal-open")})},Add:function(id,title,is_big){if($("body > div#"+id).length>0)return;var html="";html+="<div class=\"modal fade\" id=\""+id+"\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\""+id+"Label\" aria-hidden=\"true\">";html+=" <div class=\"modal-dialog"+((is_big)?" modal-lg":"")+"\">";html+=" <div class=\"modal-content\">";html+=" <div class=\"modal-header\">";html+=" <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>";html+=" <strong class=\"modal-title\" id=\""+id+"Label\">"+title+"</strong>";html+=" </div>";html+=" <div class=\"modal-body custom-loading\"></div>";html+=" <div class=\"modal-footer\">";html+=" <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>";html+=" </div>";html+=" </div>";html+=" </div>";html+="</div>";$("body").append(html)},Close:function(id){if(typeof(id)=="object"){var sender=null;do{if(typeof(id.target)!="undefined"){sender=id.target;break}
|
var BSDialog={Create:function(id,title,url,is_big,update_body){var a=this;var isBig=((typeof(is_big)=="undefined")?!1:(is_big==!0)?!0:!1);var updateBody=((typeof(update_body)=="undefined")?!1:(update_body==!0)?!0:!1);if(!a.hasDialog(id)){var html=a.generateModalHtml(id,title,null,isBig);$("body").append(html)}
|
||||||
if(typeof(id)!="undefined"){sender=id;break}}while(!1);if(sender==null)return;var panel=$(sender).parentsUntil("div[id^='dlg']").parent();if($(panel).length>0){var dialogID=$(panel).attr("id").substr(3);this.Close(dialogID)}}else{if($("body > div#dlg"+id).length<=0)return;$("body > div#dlg"+id).remove();$("body > div[class~='modal-backdrop']").remove();$("body").removeClass("modal-open")}},Clear:function(){$("body > div[class~='modal'][role='dialog']").remove();$("body > div[class~='modal-backdrop']").remove();$("body").removeClass("modal-open")},ShowToast:function(id,title,message,is_big){if($("body > div#"+id).length>0)return;var html="";html+="<div class=\"modal fade\" id=\""+id+"\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\""+id+"Label\" aria-hidden=\"true\">";html+=" <div class=\"modal-dialog"+((is_big)?" modal-lg":"")+"\">";html+=" <div class=\"modal-content\">";html+=" <div class=\"modal-header\">";html+=" <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>";html+=" <strong class=\"modal-title\" id=\""+id+"Label\">"+title+"</strong>";html+=" </div>";html+=" <div class=\"modal-body\">"+message+"</div>";html+=" <div class=\"modal-footer\">";html+=" <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>";html+=" </div>";html+=" </div>";html+=" </div>";html+="</div>";$("body").append(html);$("#"+id).modal('show');$("#"+id).on('hide.bs.modal',function(){$("body > div[id='"+id+"']").remove();$("body > div[class~='modal-backdrop']").remove();$("body").removeClass("modal-open")})}}
|
$.ajax({url:url,cache:!1,timeout:10000,success:function(result,status,xhr){if((xhr.status==200)||(xhr.status==302)||(xhr.status==301)){if(updateBody){a.updateContentBody(id,result)}else{$("#dlg"+id).find(".modal-content").html(result)}}else{a.updateContentBody(id,xhr.statusText+" ("+xhr.status+")")}},error:function(xhr){a.updateContentBody(id,xhr.statusText+" ("+xhr.status+")")},complete:function(xhr,status){}});a.show(id)},Close:function(id){if(!this.hasDialog(id))return;$("#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,is_big){if(this.hasDialog(id))return;var html=this.generateModalHtml(id,title,message,is_big);$("body").append(html);this.show(id)},hasDialog:function(id){return($("body > div[id='dlg"+id+"']").length>0)},generateModalHtml:function(id,title,message,is_big){var size=((typeof(is_big)=="undefined")?"sm":(is_big==!0?"lg":"sm"));var html="";html+="<div class=\"modal fade\" id=\"dlg"+id+"\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"dlg"+id+"Label\" aria-hidden=\"true\">";html+=" <div class=\"modal-dialog modal-"+size+"\">";html+=" <div class=\"modal-content\">";html+=" <div class=\"modal-header\">";html+=" <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>";html+=" <strong class=\"modal-title\">"+title+"</strong>";html+=" </div>";if($.trim(message).length<=0){html+=" <div class=\"modal-body custom-loading\"></div>"}else{html+=" <div class=\"modal-body\">"+message+"</div>"}
|
||||||
|
html+=" <div class=\"modal-footer\">";html+=" <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>";html+=" </div>";html+=" </div>";html+=" </div>";html+="</div>";return html},show:function(id){$("#dlg"+id).modal('show');$("#dlg"+id).off('hide.bs.modal');$("#dlg"+id).on('hide.bs.modal',function(){if($("body > div[id='dlg"+id+"']").next().is("div[class~='modal-backdrop']")){$("body > div[id='dlg"+id+"']").next().remove()}
|
||||||
|
$("body > div[id='dlg"+id+"']").remove()})},updateContentBody:function(id,text){var body=$("#dlg"+id).find(".modal-body");if($(body).hasClass("custom-loading"))$(body).removeClass("custom-loading");$(body).html(text)}}
|
Loading…
Reference in New Issue
Block a user