summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-06-21 09:45:45 +0000
committerDries Buytaert <dries@buytaert.net>2005-06-21 09:45:45 +0000
commite550f8416210489aedd88a73cdc3c5b614edc574 (patch)
tree4bfe99c1e26afb24555e144a284abb67fae52df8 /misc
parente16e048d577236daded1ad13a3913ba202d7db0f (diff)
downloadbrdo-e550f8416210489aedd88a73cdc3c5b614edc574.tar.gz
brdo-e550f8416210489aedd88a73cdc3c5b614edc574.tar.bz2
- Patch #16204 by Thox: committed the collapsible form elements patch.
NOTE: this patch works well, but the improved node edit form still has some rough edges. It is important that we continue to improve usability. Give it a try.
Diffstat (limited to 'misc')
-rw-r--r--misc/collapse.js48
-rw-r--r--misc/drupal.css28
-rw-r--r--misc/drupal.js3
3 files changed, 78 insertions, 1 deletions
diff --git a/misc/collapse.js b/misc/collapse.js
new file mode 100644
index 000000000..a689b1fd4
--- /dev/null
+++ b/misc/collapse.js
@@ -0,0 +1,48 @@
+if (isJsEnabled()) {
+ addLoadEvent(collapseAutoAttach);
+}
+
+function collapseAutoAttach() {
+ var fieldsets = document.getElementsByTagName('fieldset');
+ var legend, fieldset;
+ for (var i = 0; fieldset = fieldsets[i]; i++) {
+ if (!hasClass(fieldset, 'collapsible')) {
+ continue;
+ }
+ legend = fieldset.getElementsByTagName('legend');
+ if (legend.length == 0) {
+ continue;
+ }
+ legend = legend[0];
+ var a = document.createElement('a');
+ a.href = '#';
+ a.onclick = function() {
+ toggleClass(this.parentNode.parentNode, 'collapsed');
+ this.blur();
+ return false;
+ };
+ a.innerHTML = legend.innerHTML;
+ while (legend.hasChildNodes()) {
+ removeNode(legend.childNodes[0]);
+ }
+ legend.appendChild(a);
+ collapseEnsureErrorsVisible(fieldset);
+ }
+}
+
+function collapseEnsureErrorsVisible(fieldset) {
+ if (!hasClass(fieldset, 'collapsed')) {
+ return;
+ }
+ var inputs = [];
+ inputs = inputs.concat(fieldset.getElementsByTagName('input'));
+ inputs = inputs.concat(fieldset.getElementsByTagName('textarea'));
+ inputs = inputs.concat(fieldset.getElementsByTagName('select'));
+ for (var j = 0; j<3; j++) {
+ for (var i = 0; i < inputs[j].length; i++) {
+ if (hasClass(inputs[j][i], 'error')) {
+ return removeClass(fieldset, 'collapsed');
+ }
+ }
+ }
+}
diff --git a/misc/drupal.css b/misc/drupal.css
index 41db26667..f60033dbb 100644
--- a/misc/drupal.css
+++ b/misc/drupal.css
@@ -586,3 +586,31 @@ input.form-autocomplete {
input.throbbing {
background-position: 100% -18px;
}
+
+/*
+** Collapsing fieldsets
+*/
+html.js fieldset.collapsed {
+ border-bottom-width: 0;
+ border-left-width: 0;
+ border-right-width: 0;
+ margin-bottom: 0;
+}
+
+html.js fieldset.collapsed * {
+ display: none;
+}
+
+html.js fieldset.collapsed legend,
+html.js fieldset.collapsed legend * {
+ display: inline;
+}
+
+html.js fieldset.collapsible legend a {
+ padding-left: 15px;
+ background: url('menu-expanded.png') 5px 50% no-repeat;
+}
+
+html.js fieldset.collapsed legend a {
+ background-image: url('menu-collapsed.png');
+}
diff --git a/misc/drupal.js b/misc/drupal.js
index 7a726c2a8..4e56fabd3 100644
--- a/misc/drupal.js
+++ b/misc/drupal.js
@@ -8,6 +8,7 @@ function isJsEnabled() {
!document.getElementsByTagName ||
!document.createElement ||
!document.createTextNode ||
+ !document.documentElement ||
!document.getElementById);
}
return document.jsEnabled;
@@ -15,7 +16,7 @@ function isJsEnabled() {
// Global Killswitch
if (isJsEnabled()) {
-
+ document.documentElement.className = 'js';
}
/**