summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Peck2013-01-29 20:49:00 (GMT)
committer Jon Peck2013-01-29 20:49:00 (GMT)
commit794e64a1656643944465c70d1397405e5948afe9 (patch)
treee6d70b8a36759175cd8df7dcafc8c46a1283f07b
parent1688521cc1644c6bbc0eff19ba3031e1b3dbee20 (diff)
Consolidating code.
-rw-r--r--theme/views_timelinejs.theme.inc35
-rw-r--r--views_timelinejs.module7
2 files changed, 13 insertions, 29 deletions
diff --git a/theme/views_timelinejs.theme.inc b/theme/views_timelinejs.theme.inc
index 504496c..6164009 100644
--- a/theme/views_timelinejs.theme.inc
+++ b/theme/views_timelinejs.theme.inc
@@ -13,36 +13,11 @@ function template_preprocess_views_timelinejs(&$vars) {
// Load required libraries and styles.
views_timelinejs_load_libraries();
- switch ($vars['options']['timeline_config']['hash_bookmark']) {
- case 1:
- $bookmarks = TRUE;
- break;
-
- case 0:
- default:
- $bookmarks = FALSE;
- break;
-
- }
-
- switch ($vars['options']['timeline_config']['start_at_end']) {
- case 1:
- $start_at_end = TRUE;
- break;
-
- case 0:
- default:
- $start_at_end = FALSE;
- break;
- }
-
$view = $vars['view'];
$vars['timelinejs_id'] = 'timelinejs_' . $view->name . '_' . $view->current_display;
$settings = array(
'width' => '100%',
- 'hash_bookmark' => $bookmarks,
- 'start_at_end' => $start_at_end,
'height' => '500',
'source' => $vars['rows'],
'embed_id' => $vars['timelinejs_id'],
@@ -51,7 +26,15 @@ function template_preprocess_views_timelinejs(&$vars) {
'processed' => FALSE,
);
- // Include inline javascript.
+ if ($vars['options']['timeline_config']['hash_bookmark']) {
+ $settings['hash_bookmark'] = TRUE;
+ }
+
+ if ($vars['options']['timeline_config']['start_at_end']) {
+ $settings['start_at_end'] = TRUE;
+ }
+
+ // Add inline JavaScript.
drupal_add_js(array('timelineJS' => array($settings)), 'setting');
drupal_add_js(drupal_get_path('module', 'views_timelinejs') . '/js/views_timelinejs.js');
}
diff --git a/views_timelinejs.module b/views_timelinejs.module
index c53409a..c95d782 100644
--- a/views_timelinejs.module
+++ b/views_timelinejs.module
@@ -150,15 +150,16 @@ function views_timelinejs_convert_to_iso($value, $date_format, $timezone, $db_ti
$db_timezone = new DateTimezone($db_timezone);
switch ($date_format) {
case 'datestamp':
- case 'timestamp':
+ case 'timestamp':{
$date = new DateTime();
$date->setTimezone($db_timezone);
$date->setTimestamp($value);
break;
-
- default:
+ }
+ default:{
$date = new DateTime($value, $db_timezone);
break;
+ }
}
$date->setTimezone($timezone);
return $date->format('Y-m-d\TH:i:s\Z');