diff --git a/bootstrap-confirmation.min.js b/bootstrap-confirmation.min.js index fa600d8..48e497a 100755 --- a/bootstrap-confirmation.min.js +++ b/bootstrap-confirmation.min.js @@ -2,4 +2,4 @@ * Bootstrap Confirmation v1.0.6 * https://github.com/tavicu/bs-confirmation */ -+function(a){"use strict";var b=!1,c=function(c,d){var e=this;this.init("confirmation",c,d),a(c).on("show.bs.confirmation",function(b){e.options.onShow(b,this),a(this).addClass("open");var c=e.options,d=c.all_selector;c.singleton&&a(d).not(e.$element).each(function(){a(this).hasClass("open")&&a(this).confirmation("hide")})}),a(c).on("hide.bs.confirmation",function(b){e.options.onHide(b,this),a(this).removeClass("open")}),a(c).on("shown.bs.confirmation",function(c){var d=e.options;d.all_selector;e.isPopout()&&(b||(b=a("body").on("click",function(c){e.$element.is(c.target)||e.$element.has(c.target).length||a(".popover").has(c.target).length||(e.hide(),e.inState.click=!1,a("body").unbind(c),b=!1)})))}),d.selector?a(c).on("click.bs.confirmation",d.selector,function(a){a.preventDefault()}):a(c).on("click.bs.confirmation",function(a){a.preventDefault()})};if(!a.fn.popover||!a.fn.tooltip)throw new Error("Confirmation requires popover.js and tooltip.js");c.VERSION="1.0.6",c.DEFAULTS=a.extend({},a.fn.popover.Constructor.DEFAULTS,{placement:"right",title:"Are you sure?",btnOkClass:"btn btn-sm btn-danger",btnOkLabel:"Delete",btnOkIcon:"glyphicon glyphicon-ok",btnCancelClass:"btn btn-sm btn-default",btnCancelLabel:"Cancel",btnCancelIcon:"glyphicon glyphicon-remove",href:"#",target:"_self",singleton:!0,popout:!0,onShow:function(a,b){},onHide:function(a,b){},onConfirm:function(a,b){},onCancel:function(a,b){},template:'

YesNo
'}),c.prototype=a.extend({},a.fn.popover.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var b=this,c=this.tip(),d=this.getTitle(),e=c.find('[data-apply="confirmation"]'),f=c.find('[data-dismiss="confirmation"]'),g=this.options;e.addClass(this.getBtnOkClass()).html(this.getBtnOkLabel()).prepend(a("").addClass(this.getBtnOkIcon())," ").attr("href",this.getHref()).attr("target",this.getTarget()).off("click").on("click",function(a){g.onConfirm(a,b.$element),"submit"==b.$element.attr("type")&&b.$element.closest("form").first().submit(),b.hide(),b.inState.click=!1}),f.addClass(this.getBtnCancelClass()).html(this.getBtnCancelLabel()).prepend(a("").addClass(this.getBtnCancelIcon())," ").off("click").on("click",function(a){g.onCancel(a,b.$element),b.hide(),b.inState.click=!1}),c.find(".popover-title")[this.options.html?"html":"text"](d),c.removeClass("fade top bottom left right in"),c.find(".popover-title").html()||c.find(".popover-title").hide()},c.prototype.getBtnOkClass=function(){var a=this.$element,b=this.options;return a.attr("data-btnOkClass")||("function"==typeof b.btnOkClass?b.btnOkClass.call(this,a[0]):b.btnOkClass)},c.prototype.getBtnOkLabel=function(){var a=this.$element,b=this.options;return a.attr("data-btnOkLabel")||("function"==typeof b.btnOkLabel?b.btnOkLabel.call(this,a[0]):b.btnOkLabel)},c.prototype.getBtnOkIcon=function(){var a=this.$element,b=this.options;return a.attr("data-btnOkIcon")||("function"==typeof b.btnOkIcon?b.btnOkIcon.call(this,a[0]):b.btnOkIcon)},c.prototype.getBtnCancelClass=function(){var a=this.$element,b=this.options;return a.attr("data-btnCancelClass")||("function"==typeof b.btnCancelClass?b.btnCancelClass.call(this,a[0]):b.btnCancelClass)},c.prototype.getBtnCancelLabel=function(){var a=this.$element,b=this.options;return a.attr("data-btnCancelLabel")||("function"==typeof b.btnCancelLabel?b.btnCancelLabel.call(this,a[0]):b.btnCancelLabel)},c.prototype.getBtnCancelIcon=function(){var a=this.$element,b=this.options;return a.attr("data-btnCancelIcon")||("function"==typeof b.btnCancelIcon?b.btnCancelIcon.call(this,a[0]):b.btnCancelIcon)},c.prototype.getHref=function(){var a=this.$element,b=this.options;return a.attr("data-href")||("function"==typeof b.href?b.href.call(this,a[0]):b.href)},c.prototype.getTarget=function(){var a=this.$element,b=this.options;return a.attr("data-target")||("function"==typeof b.target?b.target.call(this,a[0]):b.target)},c.prototype.isPopout=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-popout")||("function"==typeof c.popout?c.popout.call(this,b[0]):c.popout),"false"==a&&(a=!1),a};var d=a.fn.confirmation;a.fn.confirmation=function(b){var d=this;return this.each(function(){var e=a(this),f=e.data("bs.confirmation"),g="object"==typeof b&&b;g=g||{},g.all_selector=d.selector,(f||"destroy"!=b)&&(f||e.data("bs.confirmation",f=new c(this,g)),"string"==typeof b&&f[b]())})},a.fn.confirmation.Constructor=c,a.fn.confirmation.noConflict=function(){return a.fn.confirmation=d,this}}(jQuery); ++function($){"use strict";var event_body=!1,Confirmation=function(t,n){var o=this;this.init("confirmation",t,n),n.selector?$(t).on("click.bs.confirmation",n.selector,function(t){t.preventDefault()}):$(t).on("show.bs.confirmation",function(t){o.runCallback(o.options.onShow,t,o.$element),o.$element.addClass("open"),o.options.singleton&&$(o.options.all_selector).not(o.$element).each(function(){$(this).hasClass("open")&&$(this).confirmation("hide")})}).on("hide.bs.confirmation",function(t){o.runCallback(o.options.onHide,t,o.$element),o.$element.removeClass("open")}).on("shown.bs.confirmation",function(t){(o.isPopout()||event_body)&&(event_body=$("body").on("click",function(t){o.$element.is(t.target)||o.$element.has(t.target).length||$(".popover").has(t.target).length||(o.hide(),o.inState.click=!1,$("body").unbind(t),event_body=!1)}))}).on("click.bs.confirmation",function(t){t.preventDefault()})};if(!$.fn.popover||!$.fn.tooltip)throw new Error("Confirmation requires popover.js and tooltip.js");Confirmation.VERSION="1.0.6",Confirmation.DEFAULTS=$.extend({},$.fn.popover.Constructor.DEFAULTS,{placement:"right",title:"Are you sure?",btnOkClass:"btn btn-sm btn-danger",btnOkLabel:"Delete",btnOkIcon:"glyphicon glyphicon-ok",btnCancelClass:"btn btn-sm btn-default",btnCancelLabel:"Cancel",btnCancelIcon:"glyphicon glyphicon-remove",href:"#",target:"_self",singleton:!0,popout:!0,onShow:function(t,n){},onHide:function(t,n){},onConfirm:function(t,n){},onCancel:function(t,n){},template:'

Yes No
'}),Confirmation.prototype=$.extend({},$.fn.popover.Constructor.prototype),Confirmation.prototype.constructor=Confirmation,Confirmation.prototype.getDefaults=function(){return Confirmation.DEFAULTS},Confirmation.prototype.setContent=function(){var t=this,n=this.tip(),o=this.getTitle(),e=n.find('[data-apply="confirmation"]'),i=n.find('[data-dismiss="confirmation"]');this.options;e.addClass(this.getBtnOkClass()).html(this.getBtnOkLabel()).prepend($("").addClass(this.getBtnOkIcon())," ").attr("href",this.getHref()).attr("target",this.getTarget()).off("click").on("click",function(n){if(t.runCallback(t.options.onConfirm,n,t.$element),"submit"==t.$element.attr("type")){var o=t.$element.closest("form"),e=void 0!==o.attr("novalidate");(e||o[0].checkValidity())&&o.submit()}t.hide(),t.inState.click=!1,t.$element.trigger($.Event("confirm.bs.confirmation"))}),i.addClass(this.getBtnCancelClass()).html(this.getBtnCancelLabel()).prepend($("").addClass(this.getBtnCancelIcon())," ").off("click").on("click",function(n){t.runCallback(t.options.onCancel,n,t.$element),t.hide(),t.inState.click=!1,t.$element.trigger($.Event("cancel.bs.confirmation"))}),n.find(".popover-title")[this.options.html?"html":"text"](o),n.removeClass("fade top bottom left right in"),n.find(".popover-title").html()||n.find(".popover-title").hide()},Confirmation.prototype.getBtnOkClass=function(){return this.$element.data("btnOkClass")||("function"==typeof this.options.btnOkClass?this.options.btnOkClass.call(this,this.$element):this.options.btnOkClass)},Confirmation.prototype.getBtnOkLabel=function(){return this.$element.data("btnOkLabel")||("function"==typeof this.options.btnOkLabel?this.options.btnOkLabel.call(this,this.$element):this.options.btnOkLabel)},Confirmation.prototype.getBtnOkIcon=function(){return this.$element.data("btnOkIcon")||("function"==typeof this.options.btnOkIcon?this.options.btnOkIcon.call(this,this.$element):this.options.btnOkIcon)},Confirmation.prototype.getBtnCancelClass=function(){return this.$element.data("btnCancelClass")||("function"==typeof this.options.btnCancelClass?this.options.btnCancelClass.call(this,this.$element):this.options.btnCancelClass)},Confirmation.prototype.getBtnCancelLabel=function(){return this.$element.data("btnCancelLabel")||("function"==typeof this.options.btnCancelLabel?this.options.btnCancelLabel.call(this,this.$element):this.options.btnCancelLabel)},Confirmation.prototype.getBtnCancelIcon=function(){return this.$element.data("btnCancelIcon")||("function"==typeof this.options.btnCancelIcon?this.options.btnCancelIcon.call(this,this.$element):this.options.btnCancelIcon)},Confirmation.prototype.getTitle=function(){return this.$element.data("confirmation-title")||this.$element.data("title")||this.$element.attr("title")||("function"==typeof this.options.title?this.options.title.call(this,this.$element):this.options.title)},Confirmation.prototype.getHref=function(){return this.$element.data("href")||this.$element.attr("href")||("function"==typeof this.options.href?this.options.href.call(this,this.$element):this.options.href)},Confirmation.prototype.getTarget=function(){return this.$element.data("target")||this.$element.attr("target")||("function"==typeof this.options.target?this.options.target.call(this,this.$element):this.options.target)},Confirmation.prototype.isPopout=function(){var t=this.$element.data("popout")||("function"==typeof this.options.popout?this.options.popout.call(this,this.$element):this.options.popout);return"false"==t&&(t=!1),t},Confirmation.prototype.runCallback=function(callback,event,element){"function"==typeof callback?callback.call(this,event,element):"string"==typeof callback&&eval(callback)};var old=$.fn.confirmation;$.fn.confirmation=function(t){var n=this;return this.each(function(){var o=$(this),e=o.data("bs.confirmation"),i="object"==typeof t&&t;i=i||{},i.all_selector=n.selector,(e||"destroy"!=t)&&(e||o.data("bs.confirmation",e=new Confirmation(this,i)),"string"==typeof t&&e[t]())})},$.fn.confirmation.Constructor=Confirmation,$.fn.confirmation.noConflict=function(){return $.fn.confirmation=old,this}}(jQuery); diff --git a/demo.html b/demo.html index 38be2da..2a9a6b0 100755 --- a/demo.html +++ b/demo.html @@ -33,7 +33,7 @@

With callback functions

- +