From 55e56e9146c75d81be62d627d1faaadba84e0d14 Mon Sep 17 00:00:00 2001 From: John Griffey Date: Tue, 25 Oct 2011 18:27:20 -0600 Subject: [PATCH] Added callbacks for when a pop is made active/inactive --- javascripts/jquery.pop.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/javascripts/jquery.pop.js b/javascripts/jquery.pop.js index 750a99f..bdca1f7 100644 --- a/javascripts/jquery.pop.js +++ b/javascripts/jquery.pop.js @@ -10,8 +10,15 @@ (function($) { - $.pop = function(options){ - + $.pop = function(opts){ + // default options + var options = { + onPopActive: function() {}, + onPopInactive: function() {}, + }; + + $.extend(options, opts); + // settings var settings = { pop_class : '.pop', @@ -56,8 +63,14 @@ }); // toggle that pop $(".pop_toggle").click(function(){ - $(this).parent(settings.pop_class).toggleClass("active"); + var $popClass = $(this).parent(settings.pop_class); + $popClass.toggleClass("active"); + if ($popClass.hasClass('active')) { + options.onPopActive(); + } else { + options.onPopInactive(); + } }); } -})(jQuery); \ No newline at end of file +})(jQuery);