-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbootstrap-confirm-button.min.js
More file actions
17 lines (17 loc) · 1.23 KB
/
Copy pathbootstrap-confirm-button.min.js
File metadata and controls
17 lines (17 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
* bootstrap-confirm-button v0.3.2 - 2018-04-03
*
* Copyright 2018 Stefano Cudini
* stefano.cudini@gmail.com
* https://opengeo.tech/
*
* Licensed under the MIT license.
*
* Demos:
* https://github.com/stefanocudini/bootstrap-confirm-button
*
* Source:
* git@github.com:stefanocudini/bootstrap-confirm-button.git
*
*/
jQuery.fn.btsConfirmButton=function(a,b){return"string"==typeof a?a={msg:a}:"function"==typeof a&&(b=a),b=b||$.noop,a=$.extend({msg:"I'm sure!",classname:"btn-danger",timeout:2e3},a),$(this).each(function(c,d){function e(){g.html(i).removeClass(j.classname).data("confirmed",!1)}var f,g=$(d),h=g.data(),i=g.html(),j=$.extend({},a);for(var k in h){var l,m,n=h[k];(l=k.match(/^confirm(.*)$/))&&(m=l[1].toLowerCase())&&(j[m]=n)}g.data("confirmed",!1),g.on("click.confirm",function(a){a.preventDefault(),g.data("confirmed")?($(a.target).trigger("confirm:after"),b.call(g,a),e()):(g.data("confirmed",!0),$(a.target).trigger("confirm:before",a.target),g.html(j.msg).addClass(j.classname).bind("mouseout.confirm",function(){f=setTimeout(function(){e(),$(a.target).trigger("confirm:expired",a.target)},parseInt(j.timeout))}).bind("mouseover.confirm",function(){clearTimeout(f)}))}).removeClass(j.classname)}),$(this)};