diff --git a/2016/08/bshelper-modal-v0.1.0.023.js b/2016/08/bshelper-modal-v0.1.0.023.js new file mode 100644 index 0000000..e863980 --- /dev/null +++ b/2016/08/bshelper-modal-v0.1.0.023.js @@ -0,0 +1,116 @@ +/** + * BSHelper + * Bootstrap Helper + * @version v0.1.0.023 (2015/07/14 1157) + */ + + +/** + * BSDialog + * + */ +var BSDialog = { + Create:function(id, title, url, is_big){ + id = "dlg" + id; + if ($("#" + id).length <= 0) this.Add(id, title, ((is_big == undefined)? false : 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 += "
"; + html += "
"; + html += "
"; + html += "
"; + html += " "; + html += " " + title + ""; + html += "
"; + html += "
"; + html += "
"; + html += " "; + html += "
"; + html += "
"; + html += "
"; + html += "
"; + //-- + $("body").append(html); + }, + Close: function (id) { + if (typeof (id) == "object") + { + var sender = null; + + do + { + if (typeof (id.target) != "undefined") + { + sender = id.target; + break; + } + + if (typeof (id) != "undefined") + { + 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"); + } + }, + 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 += "
"; + html += "
"; + html += "
"; + html += "
"; + html += " "; + html += " " + title + ""; + html += "
"; + html += "
" + message + "
"; + html += "
"; + html += " "; + html += "
"; + html += "
"; + html += "
"; + html += "
"; + //-- + $("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"); + }); + } +};