summaryrefslogtreecommitdiff
path: root/misc/collapse.js
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-08-31 05:51:08 +0000
committerDries Buytaert <dries@buytaert.net>2009-08-31 05:51:08 +0000
commite6e29ac1b0d6780241ced3d5ebcb0558e219e468 (patch)
treea6bdbf6b69ab26e54295d8063e7d1c839cd42f3a /misc/collapse.js
parent41dca3c4e0ec3d355977735f74af2e49ea0eedd7 (diff)
downloadbrdo-e6e29ac1b0d6780241ced3d5ebcb0558e219e468.tar.gz
brdo-e6e29ac1b0d6780241ced3d5ebcb0558e219e468.tar.bz2
- Patch #444344 by kkaefer, sun, Rob Loach: this change introduces a jQuery .once() method which streamlines the way behavior functions work. Previously, we had to manually ensure that an element is only initialized once. Usually, this happens by adding classes and selecting only those elements which do not have that class. However, this process can be separated out into a jQuery ‘filtering’ function which does all the grunt work.
Diffstat (limited to 'misc/collapse.js')
-rw-r--r--misc/collapse.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/misc/collapse.js b/misc/collapse.js
index c4fac9be3..741f4b0ba 100644
--- a/misc/collapse.js
+++ b/misc/collapse.js
@@ -53,7 +53,7 @@ Drupal.collapseScrollIntoView = function (node) {
Drupal.behaviors.collapse = {
attach: function (context, settings) {
- $('fieldset.collapsible > legend:not(.collapse-processed)', context).each(function () {
+ $('fieldset.collapsible > legend', context).once('collapse', function () {
var fieldset = $(this.parentNode);
// Expand if there are errors inside
if ($('input.error, textarea.error, select.error', fieldset).size() > 0) {
@@ -81,9 +81,10 @@ Drupal.behaviors.collapse = {
return false;
}))
.append(summary)
- .after($('<div class="fieldset-wrapper"></div>')
- .append(fieldset.children(':not(legend):not(.action)'))
- ).addClass('collapse-processed');
+ .after(
+ $('<div class="fieldset-wrapper"></div>')
+ .append(fieldset.children(':not(legend):not(.action)'))
+ );
});
}
};