diff --git a/README.md b/README.md index f51354a..ce96e7d 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# bootstrap-confirmation v1.0.3 +# bootstrap-confirmation v1.0.4 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 1806f26..23d692a 100755 --- a/bootstrap-confirmation.js +++ b/bootstrap-confirmation.js @@ -1,3 +1,7 @@ +/*! + * Bootstrap Confirmation v1.0.4 + * https://github.com/tavicu/bs-confirmation + */ +function ($) { 'use strict'; @@ -68,7 +72,7 @@ if (!$.fn.popover || !$.fn.tooltip) throw new Error('Confirmation requires popover.js and tooltip.js'); - Confirmation.VERSION = '1.0.3' + Confirmation.VERSION = '1.0.4' Confirmation.DEFAULTS = $.extend({}, $.fn.popover.Constructor.DEFAULTS, { placement : 'right', @@ -154,56 +158,56 @@ var $e = this.$element; var o = this.options; - return $e.attr('data-btnOkClass') || (typeof o.btnOkClass == 'function' ? o.btnOkClass.call($e[0]) : o.btnOkClass); + return $e.attr('data-btnOkClass') || (typeof o.btnOkClass == 'function' ? o.btnOkClass.call(this, $e[0]) : o.btnOkClass); } Confirmation.prototype.getBtnOkLabel = function () { var $e = this.$element; var o = this.options; - return $e.attr('data-btnOkLabel') || (typeof o.btnOkLabel == 'function' ? o.btnOkLabel.call($e[0]) : o.btnOkLabel); + return $e.attr('data-btnOkLabel') || (typeof o.btnOkLabel == 'function' ? o.btnOkLabel.call(this, $e[0]) : o.btnOkLabel); } Confirmation.prototype.getBtnOkIcon = function () { var $e = this.$element; var o = this.options; - return $e.attr('data-btnOkIcon') || (typeof o.btnOkIcon == 'function' ? o.btnOkIcon.call($e[0]) : o.btnOkIcon); + return $e.attr('data-btnOkIcon') || (typeof o.btnOkIcon == 'function' ? o.btnOkIcon.call(this, $e[0]) : o.btnOkIcon); } Confirmation.prototype.getBtnCancelClass = function () { var $e = this.$element; var o = this.options; - return $e.attr('data-btnCancelClass') || (typeof o.btnCancelClass == 'function' ? o.btnCancelClass.call($e[0]) : o.btnCancelClass); + return $e.attr('data-btnCancelClass') || (typeof o.btnCancelClass == 'function' ? o.btnCancelClass.call(this, $e[0]) : o.btnCancelClass); } Confirmation.prototype.getBtnCancelLabel = function () { var $e = this.$element; var o = this.options; - return $e.attr('data-btnCancelLabel') || (typeof o.btnCancelLabel == 'function' ? o.btnCancelLabel.call($e[0]) : o.btnCancelLabel); + return $e.attr('data-btnCancelLabel') || (typeof o.btnCancelLabel == 'function' ? o.btnCancelLabel.call(this, $e[0]) : o.btnCancelLabel); } Confirmation.prototype.getBtnCancelIcon = function () { var $e = this.$element; var o = this.options; - return $e.attr('data-btnCancelIcon') || (typeof o.btnCancelIcon == 'function' ? o.btnCancelIcon.call($e[0]) : o.btnCancelIcon); + return $e.attr('data-btnCancelIcon') || (typeof o.btnCancelIcon == 'function' ? o.btnCancelIcon.call(this, $e[0]) : o.btnCancelIcon); } Confirmation.prototype.getHref = function () { var $e = this.$element; var o = this.options; - return $e.attr('data-href') || (typeof o.href == 'function' ? o.href.call($e[0]) : o.href); + return $e.attr('data-href') || (typeof o.href == 'function' ? o.href.call(this, $e[0]) : o.href); } Confirmation.prototype.getTarget = function () { var $e = this.$element; var o = this.options; - return $e.attr('data-target') || (typeof o.target == 'function' ? o.target.call($e[0]) : o.target); + return $e.attr('data-target') || (typeof o.target == 'function' ? o.target.call(this, $e[0]) : o.target); } Confirmation.prototype.isPopout = function () { @@ -211,7 +215,7 @@ var $e = this.$element; var o = this.options; - popout = $e.attr('data-popout') || (typeof o.popout == 'function' ? o.popout.call($e[0]) : o.popout); + popout = $e.attr('data-popout') || (typeof o.popout == 'function' ? o.popout.call(this, $e[0]) : o.popout); if(popout == 'false') popout = false; diff --git a/bootstrap-confirmation.min.js b/bootstrap-confirmation.min.js new file mode 100755 index 0000000..14a5d14 --- /dev/null +++ b/bootstrap-confirmation.min.js @@ -0,0 +1,5 @@ +/*! + * Bootstrap Confirmation v1.0.4 + * 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:'
'}),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 c93d276..7a613a1 100755 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bs-confirmation", - "version": "1.0.3", + "version": "1.0.4", "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 4814a10..4db289f 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.3", + "version": "1.0.4", "authors": [ { "name": "Tavicu", diff --git a/demo.html b/demo.html index 96b4c56..f47b2f5 100755 --- a/demo.html +++ b/demo.html @@ -33,7 +33,7 @@