forked from gristmill/jquery-popbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopbox.min.js
1 lines (1 loc) · 856 Bytes
/
popbox.min.js
1
(function(){$.fn.popbox=function(a){var b=$.extend({selector:this.selector,open:".open",box:".box",arrow:".arrow",arrow_border:".arrow-border",close:".close"},a),c={open:function(a){a.preventDefault();var d=$(this),e=$(this).parent().find(b.box);e.find(b.arrow).css({left:e.width()/2-10}),e.find(b.arrow_border).css({left:e.width()/2-10}),e.css("display")=="block"?c.close():e.css({display:"block",top:10,left:d.parent().width()/2-e.width()/2})},close:function(){$(b.box).fadeOut("fast")}};return $(document).bind("keyup",function(a){a.keyCode==27&&c.close()}),$(document).bind("click",function(a){$(a.target).closest(b.selector).length||c.close()}),this.each(function(){$(this).css({width:$(b.box).width()}),$(b.open,this).bind("click",c.open),$(b.open,this).parent().find(b.close).bind("click",function(a){a.preventDefault(),c.close()})})}}).call(this);