// $Id: collapsiblock.js,v 1.17 2007/08/08 21:07:01 nedjo Exp $ Drupal.behaviors.collapsiblock = function (context) { $('div.block:not(.cb-p)', context).addClass('cb-p').each(function () { var selector = Drupal.settings.collapsiblock && Drupal.settings.collapsiblock.titleSelector ? Drupal.settings.collapsiblock.titleSelector : 'h2'; var id = this.id; var titleElt = $(selector +':first', this); if (titleElt.size()) { titleElt = titleElt[0]; // Status values: 1 = not collapsible, 2 = collapsible and expanded, 3 = collapsible and collapsed //alert(this.id); var status = Drupal.settings.collapsiblock.blocks[this.id] ? Drupal.settings.collapsiblock.blocks[this.id] : Drupal.settings.collapsiblock.default_state; //alert(this.id + ' ' + status); if (status == 1) { return; } titleElt.target = $(this).find('div.content'); $(titleElt) .addClass('cb') .click(function () { var st = $.cookie('cb-' + id); $.cookie('cb-' + id, st == 0 ? 1 : 0, {path: Drupal.settings.jstools.basePath}); if ($(this).is(".cb-c")) { $(this).removeClass('cb-c'); $(this.target).slideDown(200); } else { $(this).addClass('cb-c'); $(this.target).slideUp(200); } }); if (status == 3 || $.cookie('cb-' + id) == 1) { $(titleElt).addClass('cb-c'); $(titleElt.target).hide(); } else { $.cookie('cb-' + id, 0, {path: Drupal.settings.jstools.basePath}); } } }); };