diff --git a/dist/modal.min.js b/dist/modal.min.js index 339dd2c..5f6f97e 100644 --- a/dist/modal.min.js +++ b/dist/modal.min.js @@ -1 +1 @@ -!function(){function t(){var t='';$("#bsModalContent").length||(t+=''),$("#bsModalConfirmContent").length||(t+=''),$("#bsModalConfirmButtons").length||(t+=''),$("body").append(t)}function o(t){var o=$(this);$(document).trigger("bsmodal.js-modal.clicked",[o]),e($("#bsModalContent")),i(o),m.modal("show"),t.preventDefault()}function d(t){var o=$(this),d=new FormData(this);$(document).trigger("bsmodal.js-form.submitted",[$(this),d]),$.ajax({url:o.attr("action"),type:o.attr("method"),data:d,processData:!1,contentType:!1,success:function(t,d,a){$(document).trigger("bsmodal.js-form.success",[t,d,a,o])},complete:function(){$(document).trigger("bsmodal.js-form.completed",[o])}}),t.preventDefault()}function a(t,o,d,a,n){201==a.status?(m.modal("hide"),o.redirect?window.location=o.redirect:window.location.reload()):m.hasClass("in")&&m.find(".js-form")?s(o):n.attr("id")?n.html($(o).find("#"+n.attr("id")).html()):console.debug(".js-form must have an id attribute or be in modal window")}function n(t){var o=$(this).data("title")||"Delete",d=$(this).data("text")||"Are you sure you want to remove this item?",a=this,n=$("#bsModalConfirmButtons");e($("#bsModalConfirmContent")),l.find("#bsModalTitle").html(o),n.data("append")?(l.find(".modal-body").html(d),l.find(".modal-content").append(n.html())):l.find(".modal-body").html(d+n.html()),m.modal("show"),l.find(".js-confirm-btn").off().on("click",function(){return $(a).data("no-ajax")||$(a).hasClass("js-no-ajax")?window.location.href=$(a).attr("href"):void $.ajax({url:$(a).attr("href"),type:"GET",success:function(){window.location.reload()}})}),t.preventDefault()}function i(t){var o=t.data("url")||t.attr("href");$.get(o,function(t){s(t),$(document).trigger("bsmodal.js-modal.loaded",[t,o])})}function e(t){s(t?t.html():"")}function s(t){var o=$('');l.html(o.append(t))}var l,m;$(document).ready(function(){t(),m=$("#modalHolder"),l=m.find(".modal-dialog"),$(document).on("click",".js-modal",o),$(document).on("submit",".js-form",d),$(document).on("click",".js-confirm",n),$(document).on("bsmodal.js-form.success",a)})}(); \ No newline at end of file +!function(){function t(){var t='';$("#bsModalContent").length||(t+=''),$("#bsModalConfirmContent").length||(t+=''),$("#bsModalConfirmButtons").length||(t+=''),$("body").append(t)}function o(t){var o=$(this);$(document).trigger("bsmodal.js-modal.clicked",[o]),e($("#bsModalContent")),i(o),r.modal("show"),t.preventDefault()}function d(t){var o=$(this),d=new FormData(this);$(document).trigger("bsmodal.js-form.submitted",[$(this),d]),$.ajax({url:o.attr("action"),type:o.attr("method"),data:d,processData:!1,contentType:!1,success:function(t,d,a){$(document).trigger("bsmodal.js-form.success",[t,d,a,o])},complete:function(){$(document).trigger("bsmodal.js-form.completed",[o])}}),t.preventDefault()}function a(t,o,d,a,n){201==a.status?(r.modal("hide"),o.redirect?window.location=o.redirect:o.event?$(document).trigger(o.event,[o.data]):window.location.reload()):r.hasClass("in")&&r.find(".js-form")?s(o):n.attr("id")?n.html($(o).find("#"+n.attr("id")).html()):console.debug(".js-form must have an id attribute or be in modal window")}function n(t){var o=$(this).data("title")||"Delete",d=$(this).data("text")||"Are you sure you want to remove this item?",a=this,n=$("#bsModalConfirmButtons");e($("#bsModalConfirmContent")),l.find("#bsModalTitle").html(o),n.data("append")?(l.find(".modal-body").html(d),l.find(".modal-content").append(n.html())):l.find(".modal-body").html(d+n.html()),r.modal("show"),l.find(".js-confirm-btn").off().on("click",function(){return $(a).data("no-ajax")||$(a).hasClass("js-no-ajax")?window.location.href=$(a).attr("href"):void $.ajax({url:$(a).attr("href"),type:"GET",success:function(){window.location.reload()}})}),t.preventDefault()}function i(t){var o=t.data("url")||t.attr("href");$.get(o,function(t){s(t),$(document).trigger("bsmodal.js-modal.loaded",[t,o])})}function e(t){s(t?t.html():"")}function s(t){var o=$('');l.html(o.append(t))}var l,r;$(document).ready(function(){t(),r=$("#modalHolder"),l=r.find(".modal-dialog"),$(document).on("click",".js-modal",o),$(document).on("submit",".js-form",d),$(document).on("click",".js-confirm",n),$(document).on("bsmodal.js-form.success",a)})}(); \ No newline at end of file diff --git a/modal.js b/modal.js index 8949e29..44391f7 100644 --- a/modal.js +++ b/modal.js @@ -93,6 +93,8 @@ if (data.redirect) { window.location = data.redirect; + } else if (data.event) { + $(document).trigger(data.event, [data.data]); } else { window.location.reload(); }