summaryrefslogtreecommitdiff
path: root/misc/collapse.js
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-10-29 10:01:28 +0000
committerDries Buytaert <dries@buytaert.net>2008-10-29 10:01:28 +0000
commit5371104a2d10889c532bb5d345fa6d71c0a897d1 (patch)
treebbef382cea55823195e0cb7469074b743913bc74 /misc/collapse.js
parent068febde425f4521d61f863ffaca76da65916449 (diff)
downloadbrdo-5371104a2d10889c532bb5d345fa6d71c0a897d1.tar.gz
brdo-5371104a2d10889c532bb5d345fa6d71c0a897d1.tar.bz2
- Patch #316225 by sun et al: allow behaviors to detach from AHAH/AJAX.
Diffstat (limited to 'misc/collapse.js')
-rw-r--r--misc/collapse.js48
1 files changed, 25 insertions, 23 deletions
diff --git a/misc/collapse.js b/misc/collapse.js
index 5628c4b9a..4626b4519 100644
--- a/misc/collapse.js
+++ b/misc/collapse.js
@@ -50,28 +50,30 @@ Drupal.collapseScrollIntoView = function (node) {
}
};
-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');
- }
+Drupal.behaviors.collapse = {
+ attach: 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;
- $(this).empty().append($('<a href="#">'+ text +'</a>').click(function() {
- var fieldset = $(this).parents('fieldset:first')[0];
- // Don't animate multiple times
- if (!fieldset.animating) {
- fieldset.animating = true;
- Drupal.toggleFieldset(fieldset);
- }
- return false;
- }))
- .after($('<div class="fieldset-wrapper"></div>')
- .append(fieldset.children(':not(legend):not(.action)')))
- .addClass('collapse-processed');
- });
+ // 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
+ if (!fieldset.animating) {
+ fieldset.animating = true;
+ Drupal.toggleFieldset(fieldset);
+ }
+ return false;
+ }))
+ .after($('<div class="fieldset-wrapper"></div>')
+ .append(fieldset.children(':not(legend):not(.action)')))
+ .addClass('collapse-processed');
+ });
+ }
};