From 212c0484b9ffcd6b2c044f4539477b0d52be905f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Wed, 10 Oct 2007 10:24:25 +0000 Subject: #181741 by quicksketch: fix AHAH throbber/progress bar issues and generalize progress display configuration to allow module developers to choose from the throbber and progress bar --- includes/form.inc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'includes') diff --git a/includes/form.inc b/includes/form.inc index 3320b3e6a..87a0a762d 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -1616,7 +1616,6 @@ function form_expand_ahah($element) { if (isset($element['#ahah']['path']) && isset($element['#ahah']['event']) && !isset($js_added[$element['#id']])) { drupal_add_js('misc/jquery.form.js'); drupal_add_js('misc/ahah.js'); - drupal_add_js('misc/progress.js'); $ahah_binding = array( 'url' => url($element['#ahah']['path']), @@ -1625,8 +1624,23 @@ function form_expand_ahah($element) { 'selector' => empty($element['#ahah']['selector']) ? '#'. $element['#id'] : $element['#ahah']['selector'], 'effect' => empty($element['#ahah']['effect']) ? 'none' : $element['#ahah']['effect'], 'method' => empty($element['#ahah']['method']) ? 'replace' : $element['#ahah']['method'], + 'progress' => empty($element['#ahah']['progress']) ? array('type' => 'throbber') : $element['#ahah']['progress'], ); + // Convert a simple #ahah[progress] type string into an array. + if (is_string($ahah_binding['progress'])) { + $ahah_binding['progress'] = array('type' => $ahah_binding['progress']); + } + // Change progress path to a full url. + if (isset($ahah_binding['progress']['path'])) { + $ahah_binding['progress']['url'] = url($ahah_binding['progress']['path']); + } + + // Add progress.js if we're doing a bar display. + if ($ahah_binding['progress']['type'] == 'bar') { + drupal_add_js('misc/progress.js'); + } + drupal_add_js(array('ahah' => array($element['#id'] => $ahah_binding)), 'setting'); $js_added[$element['#id']] = TRUE; -- cgit v1.2.3