Index: timeline.theme.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/timeline/timeline.theme.inc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 timeline.theme.inc
--- timeline.theme.inc	21 Oct 2006 20:39:26 -0000	1.1.2.2
+++ timeline.theme.inc	1 Dec 2006 11:32:47 -0000
@@ -71,51 +71,66 @@
  *
  */
 function theme_timeline($timeline) {
-  global $base_url;
+global $base_url;
 
-  if (strpos(TIMELINE_WIDGET_URL, '://') === FALSE) { // relative URL
-    drupal_add_js(TIMELINE_WIDGET_URL);
-  }
-  else { // absolute URL
-    drupal_set_html_head('<script type="text/javascript" src="' . TIMELINE_WIDGET_URL . '"></script>');
-  }
+if (strpos(TIMELINE_WIDGET_URL, '://') === FALSE) { // relative URL
+drupal_add_js(TIMELINE_WIDGET_URL);
+}
+else { // absolute URL
+drupal_set_html_head('<script type="text/javascript" src="' . TIMELINE_WIDGET_URL . '"></script>');
+}
 
-  theme_add_style(drupal_get_path('module', 'timeline') . '/timeline.css');
-  drupal_add_js(drupal_get_path('module', 'timeline') . '/timeline.js');
+theme_add_style(drupal_get_path('module', 'timeline') . '/timeline.css');
+drupal_add_js(drupal_get_path('module', 'timeline') . '/timeline.js');
 
-  $timeline = (object)$timeline;
-  if (empty($timeline->class))       $timeline->class = 'timeline';
-  if (empty($timeline->width))       $timeline->width = TIMELINE_WIDTH;
-  if (empty($timeline->height))      $timeline->height = TIMELINE_HEIGHT;
-  if (empty($timeline->align))       $timeline->align = '';
-  if (empty($timeline->id))          $timeline->id = 'timeline';
-  if (empty($timeline->orientation)) $timeline->orientation = TIMELINE_ORIENTATION;
-  if (empty($timeline->start_date))  $timeline->start_date = date('D M d Y G:i:s') . ' GMT' . date('O');
-
-  // FIXME: timezone fiddling due to bug in the Timeline widget; see timeline_format_date().
-  //if (!isset($timeline->timezone)) $timeline->timezone = timeline_get_timezone() / 3600;
-  if (!isset($timeline->timezone)) $timeline->timezone = 0;
-
-  $style = array('width' => _timeline_to_dim($timeline->width), 'height' => _timeline_to_dim($timeline->height));
-  switch (strtolower($timeline->align)) {
-    case 'left':
-    case 'right':
-      $style['float']  = strtolower($timeline->align);
-      break;
-    case 'center':
-      $style += array('margin-left' => 'auto', 'margin-right' => 'auto');
-      break;
-  }
-  $style = implode('; ', array_map_assoc(create_function('$k, $v', 'return "$k: $v";'), $style));
-  $tag = _timeline_content_tag('div', '', array('id' => $timeline->id, 'class' => $timeline->class, 'style' => $style));
-  $output .= _timeline_content_tag('div', $tag, array('class' => $timeline->class . '-wrapper'));
-
-  $query = 'view=' . $timeline->view_name . (empty($timeline->view_args) ? '' : '&args=' . urlencode(serialize($timeline->view_args)));
-  $url = url('timeline/' . TIMELINE_FEED_TYPE, $query, NULL, FALSE);
-  $function = drupal_call_js('createTimelineWidget', $timeline->id , '%O', $timeline->start_date, $timeline->timezone, $url, TIMELINE_FEED_TYPE);
-  $output .= str_replace('"%O"', 'Timeline.' . $timeline->orientation, $function); // if only PHP had symbols...
+$timeline = (object)$timeline;
+if (empty($timeline->class)) $timeline->class = 'timeline';
+if (empty($timeline->width)) $timeline->width = TIMELINE_WIDTH;
+if (empty($timeline->height)) $timeline->height = TIMELINE_HEIGHT;
+if (empty($timeline->align)) $timeline->align = '';
+if (empty($timeline->id)) $timeline->id = 'timeline';
+if (empty($timeline->orientation)) $timeline->orientation = TIMELINE_ORIENTATION;
+if (empty($timeline->start_date)) $timeline->start_date = date('D M d Y G:i:s') . ' GMT' . date('O');
+
+// FIXME: timezone fiddling due to bug in the Timeline widget; see timeline_format_date().
+//if (!isset($timeline->timezone)) $timeline->timezone = timeline_get_timezone() / 3600;
+if (!isset($timeline->timezone)) $timeline->timezone = 0;
+
+$style = array('width' => _timeline_to_dim($timeline->width), 'height' => _timeline_to_dim($timeline->height));
+switch (strtolower($timeline->align)) {
+case 'left':
+case 'right':
+$style['float'] = strtolower($timeline->align);
+break;
+case 'center':
+$style += array('margin-left' => 'auto', 'margin-right' => 'auto');
+break;
+}
+$style = implode('; ', array_map_assoc(create_function('$k, $v', 'return "$k: $v";'), $style));
+$tag = _timeline_content_tag('div', '', array('id' => $timeline->id, 'class' => $timeline->class, 'style' => $style));
+$output .= _timeline_content_tag('div', $tag, array('class' => $timeline->class . '-wrapper'));
+
+$query = 'view=' . $timeline->view_name . (empty($timeline->view_args) ? '' : '&args=' . urlencode(serialize($timeline->view_args)));
+$url = url('timeline/' . TIMELINE_FEED_TYPE, $query, NULL, FALSE);
+
+$output = "
+
+<div id=\"$timeline->id\" class=\"timeline\" style=\"$style\">
+</div>
+
+<script type=\"text/javascript\">
+
+var createWidgetFunction = function() {
+return createTimelineWidget(\"$timeline->id\", Timeline.$timeline->orientation, \"$timeline->start_date\", 0, \"$url\", \"json\");
+}
+
+setTimeout( createWidgetFunction, 1);
+
+</script>
+
+";
 
-  return $output;
+return $output;
 }
 
 //////////////////////////////////////////////////////////////////////////////
