diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-07-01 15:37:10 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-07-01 15:37:10 +0000 |
commit | c11cb4ec24479e801076c094f043f2084b344d0c (patch) | |
tree | 5248d25917032a394ec350b65ebde88259168ffe /misc/collapse.js | |
parent | a3d75e547f62174fe9fa2b5c3f9684b620612b00 (diff) | |
download | brdo-c11cb4ec24479e801076c094f043f2084b344d0c.tar.gz brdo-c11cb4ec24479e801076c094f043f2084b344d0c.tar.bz2 |
- Patch #120360 by nedjo: enable AJAX by making all behaviours reattachable.
Diffstat (limited to 'misc/collapse.js')
-rw-r--r-- | misc/collapse.js | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/misc/collapse.js b/misc/collapse.js index c1fd3d4c3..7bff25397 100644 --- a/misc/collapse.js +++ b/misc/collapse.js @@ -20,10 +20,6 @@ Drupal.toggleFieldset = function(fieldset) { Drupal.collapseScrollIntoView(this.parentNode); } }); - if (typeof(Drupal.textareaAttach) != 'undefined') { - // Initialize resizable textareas that are now revealed - Drupal.textareaAttach(null, fieldset); - } } else { var content = $('> div', fieldset).slideUp('medium', function() { @@ -50,19 +46,17 @@ Drupal.collapseScrollIntoView = function (node) { } }; -// Global Killswitch -if (Drupal.jsEnabled) { - $(document).ready(function() { - $('fieldset.collapsible > legend').each(function() { - var fieldset = $(this.parentNode); - // Expand if there are errors inside - if ($('input.error, textarea.error, select.error', fieldset).size() > 0) { - fieldset.removeClass('collapsed'); - } +Drupal.behaviors.collapse = function (context) { + $('fieldset.collapsible > legend:not(.collapse-processed)', context).each(function() { + var fieldset = $(this.parentNode); + // Expand if there are errors inside + if ($('input.error, textarea.error, select.error', fieldset).size() > 0) { + fieldset.removeClass('collapsed'); + } - // Turn the legend into a clickable link and wrap the contents of the fieldset - // in a div for easier animation - var text = this.innerHTML; + // Turn the legend into a clickable link and wrap the contents of the fieldset + // in a div for easier animation + var text = this.innerHTML; $(this).empty().append($('<a href="#">'+ text +'</a>').click(function() { var fieldset = $(this).parents('fieldset:first')[0]; // Don't animate multiple times @@ -71,7 +65,9 @@ if (Drupal.jsEnabled) { Drupal.toggleFieldset(fieldset); } return false; - })).after($('<div class="fieldset-wrapper"></div>').append(fieldset.children(':not(legend)'))); - }); + })) + .after($('<div class="fieldset-wrapper"></div>') + .append(fieldset.children(':not(legend)'))) + .addClass('collapse-processed'); }); -} +}; |