Skip to content

Instantly share code, notes, and snippets.

@beiyuu
Created January 13, 2014 04:48
Show Gist options
  • Save beiyuu/8394898 to your computer and use it in GitHub Desktop.
Save beiyuu/8394898 to your computer and use it in GitHub Desktop.
(function($){
$.fn.outside = function(ename, cb){
return this.each(function(){
var $this = $(this),
self = this;
$(document).bind(ename, function tempo(e){
if(e.target !== self && !$.contains(self, e.target)){
cb.apply(self, [e]);
if(!self.parentNode) $(document.body).unbind(ename, tempo);
}
});
});
};
}(jQuery));
$('.panel-tab').outside('click', function() {
$('#panel').stop(true, true).slideUp('slow');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment