From 4b7c457b856748d9d9bc2cbacaddde317bd78377 Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Tue, 18 Nov 2008 15:36:19 -0500 Subject: [PATCH] Added jquery toggler plugin for using links to easily toggle content --- jquery.toggler.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 jquery.toggler.js diff --git a/jquery.toggler.js b/jquery.toggler.js new file mode 100644 index 0000000..fce5c8d --- /dev/null +++ b/jquery.toggler.js @@ -0,0 +1,19 @@ +// Example html file: http://gist.github.com/26239 +(function($) { + $.fn.toggler = function(options) { + + var opts = $.extend({}, $.fn.toggler.defaults, options); + + return this.each(function() { + this.togglee = $($(this).attr('href')).hide(); + $(this).click(onClick); + }); + + function onClick() { + this.togglee[opts.animate ? 'slideToggle' : 'toggle'](); + return false; + } + } + + $.fn.toggler.defaults = {animate: false} +})(jQuery); \ No newline at end of file