diff --git a/README.md b/README.md index ce96e7d..f30df34 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# bootstrap-confirmation v1.0.4 +# bootstrap-confirmation v1.0.5 This is a fork of ethaizone's [original code](https://github.com/ethaizone/Bootstrap-Confirmation) diff --git a/bootstrap-confirmation.js b/bootstrap-confirmation.js index 23d692a..84c107d 100755 --- a/bootstrap-confirmation.js +++ b/bootstrap-confirmation.js @@ -1,5 +1,5 @@ /*! - * Bootstrap Confirmation v1.0.4 + * Bootstrap Confirmation v1.0.5 * https://github.com/tavicu/bs-confirmation */ +function ($) { @@ -65,14 +65,20 @@ } }); - $(element).on('click', function(e) { - e.preventDefault(); - }); + if(options.selector) { + $(element).on('click.bs.confirmation', options.selector, function(e) { + e.preventDefault(); + }); + } else { + $(element).on('click.bs.confirmation', function(e) { + e.preventDefault(); + }); + } } if (!$.fn.popover || !$.fn.tooltip) throw new Error('Confirmation requires popover.js and tooltip.js'); - Confirmation.VERSION = '1.0.4' + Confirmation.VERSION = '1.0.5' Confirmation.DEFAULTS = $.extend({}, $.fn.popover.Constructor.DEFAULTS, { placement : 'right', diff --git a/bootstrap-confirmation.min.js b/bootstrap-confirmation.min.js index 14a5d14..74ed607 100755 --- a/bootstrap-confirmation.min.js +++ b/bootstrap-confirmation.min.js @@ -1,5 +1,5 @@ /*! - * Bootstrap Confirmation v1.0.4 + * Bootstrap Confirmation v1.0.5 * 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)})))}),a(c).on("click",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.4",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); \ No newline at end of file ++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.5",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); \ No newline at end of file diff --git a/bower.json b/bower.json index 7a613a1..8cb36b1 100755 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bs-confirmation", - "version": "1.0.4", + "version": "1.0.5", "main": "bootstrap-confirmation.js", "keywords": [ "bootstrap", "confirm", "confirmation"], "description": "Confirmation plugin compatible with Twitter Bootstrap 3 extending Popover", diff --git a/composer.json b/composer.json index 4db289f..55f4875 100755 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "keywords": ["bootstrap", "bootstrap dialog", "bootstrap confirmation", "confirmation"], "description": "Confirmation plugin compatible with Twitter Bootstrap 3 extending Popover", "homepage": "https://github.com/tavicu/bs-confirmation", - "version": "1.0.4", + "version": "1.0.5", "authors": [ { "name": "Tavicu",