/* ----------------------------------------------------------------
@name:     collapser - open and close boxes
@version:  0.4
@release:  2010-08-01
@type:     jQuery plugin
@author:   Jan Panschab
---------------------------------------------------------------- */
jQuery(document).ready(function () { jQuery.fn.collapser = function (h) { var a = jQuery.extend({}, jQuery.fn.collapser.defaults, h); return this.each(function () { var b = jQuery(this), f = a.triggerPosition == "prev" ? "next" : "prev", e = b.height(), g = (new Date).getTime(); b.attr({ height: e, group: g }); if (a.trigger != "") b[a.triggerPosition == "prev" ? "before" : "after"](jQuery(a.trigger)); e = b[a.triggerPosition](); b.hide().css({ height: 0 }); e.css("cursor", "pointer"); if (a.openOnLoad) { b = b.filter(a.openOnLoad); b.css("height", b.attr("height") + "px").show()[a.triggerPosition](a.trigger).addClass(a.openClass) } if (document.location.hash) { b = jQuery(document.location.hash); b.css("height", b.attr("height") + "px").show()[a.triggerPosition](a.trigger).addClass(a.openClass) } e.click(function (d) { d.preventDefault(); d = jQuery(this); var i = jQuery("*[group=" + g + "]")[a.triggerPosition](), c = d[f](), j = c.attr("height"); a.autoClose && i.removeClass(a.openClass)[f]().not(c).animate({ height: 0 }, a.duration, a.easing, function () { jQuery(this).hide() }); if (c.is(":visible")) { d.removeClass(a.openClass); c.animate({ height: 0 }, a.duration, a.easing, function () { c.hide() }); a.onClose.call(this) } else { d.addClass(a.openClass); c.show().animate({ height: j }, a.duration, a.easing); a.onOpen.call(this) } }) }) }; jQuery.fn.collapser.defaults = { trigger: "", triggerPosition: "prev", openClass: "topen", autoClose: false, openOnLoad: false, duration: 1500, easing: "linear", onOpen: function () { }, onClose: function () { } } });
