summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/form.inc42
1 files changed, 42 insertions, 0 deletions
diff --git a/includes/form.inc b/includes/form.inc
index 608fe755e..f135e685b 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -1383,6 +1383,48 @@ function expand_radios($element) {
}
/**
+ * Add AHAH information about a form element to the page to communicate with
+ * javascript. If #ahah_path is set on an element, this additional javascript is
+ * added to the page header to attach the AHAH behaviors. See ahah.js for more
+ * information.
+ *
+ * @param $element
+ * An associative array containing the properties of the element.
+ * Properties used: ahah_event, ahah_path, ahah_wrapper, ahah_parameters,
+ * ahah_effect.
+ * @return
+ * None. Additional code is added to the header of the page using
+ * drupal_add_js.
+ */
+function form_expand_ahah($element) {
+ static $js_added = array();
+
+ // Adding the same javascript settings twice will cause a recursion error,
+ // we avoid the problem by checking if the javascript has already been added.
+ if (!isset($js_added[$element['#id']]) && isset($element['#ahah_event']) && isset($element['#ahah_path'])) {
+ drupal_add_js('misc/ahah.js');
+ drupal_add_js('misc/progress.js');
+
+ $ahah_binding = array(
+ 'id' => $element['#id'],
+ 'uri' => url($element['#ahah_path']),
+ 'event' => $element['#ahah_event'],
+ 'effect' => empty($element['#ahah_effect']) ? 'none' : $element['#ahah_effect'],
+ 'method' => empty($element['#ahah_method']) ? 'replace' : $element['#ahah_method'],
+ );
+
+ if (!empty($element['#ahah_wrapper'])) {
+ $ahah_binding['wrapper'] = $element['#ahah_wrapper'];
+ }
+
+ drupal_add_js(array('ahah' => array($element['#id'] => $ahah_binding)), 'setting');
+
+ $js_added[$element['#id']] = TRUE;
+ }
+ return $element;
+}
+
+/**
* Format a form item.
*
* @param $element