Skip to content

Instantly share code, notes, and snippets.

@teejayvanslyke
Created August 21, 2008 12:53
Show Gist options
  • Save teejayvanslyke/6552 to your computer and use it in GitHub Desktop.
Save teejayvanslyke/6552 to your computer and use it in GitHub Desktop.
//
// pop! for jQuery
// v0.2 requires jQuery v1.2 or later
//
// Licensed under the MIT:
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright 2007,2008 SEAOFCLOUDS [http://seaofclouds.com]
//
(function($) {
$.fn.pop = function(options) {
var settings = $.extend({}, $.fn.pop.defaults, options);
var pops = [];
var zIndex = 1000;
$(this).each(function() {
var content = $(this).find(settings.content);
pops.push(content);
var trigger = $(this).find(settings.trigger);
content.hide();
$(content).css({ zIndex: zIndex-- });
$(trigger).click(function(e){
$(content).show();
$(content).addClass('active');
});
activePop = null;
$(document.body).click(function(){
$(pops).each(function(i) {
alert($(this).html());
if ($(this)!=activePop) {
$(this).removeClass('active');
$(this).hide();
}
});
return false;
});
$([content, trigger]).mouseover(function() {
activePop = $(content);
});
$([content, trigger]).mouseout(function() {
activePop = null;
});
});
}
$.fn.pop.defaults = {
content : '.pop_content',
trigger : '.pop_trigger'
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment