diff --git a/dist/modal.min.js b/dist/modal.min.js index d15e499..631e25a 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),c.modal("show"),t.preventDefault()}function a(t){var o=new FormData(this);$(document).trigger("bsmodal.js-form.submitted",[$(this),o]),$.ajax({url:$(this).attr("action"),type:$(this).attr("method"),data:o,processData:!1,contentType:!1,success:function(t,o,a){$(document).trigger("bsmodal.js-form.success",[t,o,a])},complete:function(){$(document).trigger("bsmodal.js-form.completed")}}),t.preventDefault()}function d(t,o,a,d){201==d.status?(c.modal("hide"),o.redirect?window.location=o.redirect:window.location.reload()):s(o)}function n(t){var o=$(this).data("title")||"Delete",a=$(this).data("text")||"Are you sure you want to remove this item?",d=this;e($("#bsModalConfirmContent")),l.find("#bsModalTitle").html(o),l.find(".modal-body").html(a+$("#bsModalConfirmButtons").html()),c.modal("show"),l.find(".js-confirm-btn").off().on("click",function(){return $(d).data("no-ajax")||$(d).hasClass("js-no-ajax")?window.location.href=$(d).attr("href"):void $.ajax({url:$(d).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,c;$(document).ready(function(){t(),c=$("#modalHolder"),l=c.find(".modal-dialog"),$(document).on("click",".js-modal",o),$(document).on("submit",".js-form",a),$(document).on("click",".js-confirm",n),$(document).on("bsmodal.js-form.success",d)})}(); \ 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),c.modal("show"),t.preventDefault()}function d(t){var o=new FormData(this);$(document).trigger("bsmodal.js-form.submitted",[$(this),o]),$.ajax({url:$(this).attr("action"),type:$(this).attr("method"),data:o,processData:!1,contentType:!1,success:function(t,o,d){$(document).trigger("bsmodal.js-form.success",[t,o,d])},complete:function(){$(document).trigger("bsmodal.js-form.completed")}}),t.preventDefault()}function a(t,o,d,a){201==a.status?(c.modal("hide"),o.redirect?window.location=o.redirect:window.location.reload()):s(o)}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()),c.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,c;$(document).ready(function(){t(),c=$("#modalHolder"),l=c.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 469f829..7e524aa 100644 --- a/modal.js +++ b/modal.js @@ -104,11 +104,19 @@ var title = $(this).data('title') || 'Delete'; var text = $(this).data('text') || 'Are you sure you want to remove this item?'; var that = this; + var buttons = $('#bsModalConfirmButtons'); displayDefaultContent($('#bsModalConfirmContent')); modalContent.find('#bsModalTitle').html(title); - modalContent.find('.modal-body').html(text + $('#bsModalConfirmButtons').html()); + + if (buttons.data('append')) { + modalContent.find('.modal-body').html(text); + modalContent.find('.modal-content').append(buttons.html()); + } else { + modalContent.find('.modal-body').html(text + buttons.html()); + } + modal.modal('show'); modalContent.find('.js-confirm-btn').off().on('click', function() {