jonnybradley | 7 May 2012 16:57
Picon

[Tikiwiki-cvs/svn] SF.net SVN: tikiwiki:[41383] branches/9.x/lib

Revision: 41383
          http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=41383&view=rev
Author:   jonnybradley
Date:     2012-05-07 14:57:20 +0000 (Mon, 07 May 2012)
Log Message:
-----------
[FIX] trackertimeline: Avoid duplicate ids when more than one per page, also [ENH] add params for height
control to make it usable in more contexts (thanks xavi)

Modified Paths:
--------------
    branches/9.x/lib/simile_tiki/tiki-timeline.js
    branches/9.x/lib/wiki-plugins/wikiplugin_trackertimeline.php

Modified: branches/9.x/lib/simile_tiki/tiki-timeline.js
===================================================================
--- branches/9.x/lib/simile_tiki/tiki-timeline.js	2012-05-07 14:51:28 UTC (rev 41382)
+++ branches/9.x/lib/simile_tiki/tiki-timeline.js	2012-05-07 14:57:20 UTC (rev 41383)
 <at>  <at>  -30,12 +30,15  <at>  <at> 
  *  <at> param scale2		optional lower band scale
  */

-function ttlInit( elementId, dataSource, scale1, scale2 ) {
+function ttlInit( elementId, dataSource, scale1, scale2, band2_height ) {
 	ajaxLoadingShow(elementId);

 	if (typeof scale2 === 'undefined') {
 		scale2 = '';
 	}
+	if (typeof band2_height === 'undefined') {
+		band2_height = 30;
+	}
 	// wait for Timeline to be loaded
 	if (ttlInitCount < 30 && (
 			typeof window.SimileAjax === "undefined" ||
 <at>  <at>  -70,7 +73,7  <at>  <at> 

 	var bandInfos = [
 		window.Timeline.createBandInfo({
-			width:		  scale2 === "" ? "100%" : "70%",
+			width:		  scale2 === "" ? "100%" : (100 - band2_height) + "%",
 			intervalUnit:   window.Timeline.DateTime[scale1.toUpperCase()],
 			eventSource:	ttl_eventSource,
 			intervalPixels: 100
 <at>  <at>  -79,7 +82,7  <at>  <at> 
 	if (scale2) {
 		bandInfos.push(
 			window.Timeline.createBandInfo({
-				width:          "30%",
+				width:          band2_height + "%",
 				intervalUnit:   window.Timeline.DateTime[scale2.toUpperCase()],
 				eventSource:	ttl_eventSource,
 				intervalPixels: 200,

Modified: branches/9.x/lib/wiki-plugins/wikiplugin_trackertimeline.php
===================================================================
--- branches/9.x/lib/wiki-plugins/wikiplugin_trackertimeline.php	2012-05-07 14:51:28 UTC (rev 41382)
+++ branches/9.x/lib/wiki-plugins/wikiplugin_trackertimeline.php	2012-05-07 14:57:20 UTC (rev 41383)
 <at>  <at>  -76,7 +76,7  <at>  <at> 
 			'scale1' => array(
 				'required' => false,
 				'name' => tra('Primary Scale Unit'),
-				'description' => tra('Unit of time to use for the primary scale (default to hour - * denotes SIMILE only)'),
+				'description' => tra('Unit of time to use for the primary scale (default to hour - * SIMILE only)'),
 				'filter' => 'alpha',
 				'default' => 'hour',
 				'options' => array(
 <at>  <at>  -93,7 +93,7  <at>  <at> 
 			'scale2' => array(
 				'required' => false,
 				'name' => tra('Secondary Scale Unit'),
-				'description' => tra('Unit of time to use for the secondary scale (default to empty - * denotes SIMILE only)'),
+				'description' => tra('Unit of time to use for the secondary scale (default to empty - * SIMILE only)'),
 				'filter' => 'alpha',
 				'default' => '',
 				'options' => array(
 <at>  <at>  -107,6 +107,20  <at>  <at> 
 					array('text' => tra('Century *'), 'value' => 'century'),
 				)
 			),
+			'height' => array(
+				'required' => false,
+				'name' => tra('Timeline height'),
+				'description' => tra('Height of the timeline band as a CSS unit (default: 250px -  - * SIMILE only)'),
+				'filter' => 'text',
+				'default' => '250px',
+			),
+			'band2_height' => array(
+				'required' => false,
+				'name' => tra('Lower band height'),
+				'description' => tra('Height of the lower timeline band as a percentage (default: 30 -  - * SIMILE only)'),
+				'filter' => 'int',
+				'default' => '30',
+			),
 			'link_group' => array(
 				'required' => false,
 				'name' => tra('Link Group Name'),
 <at>  <at>  -114,8 +128,8  <at>  <at> 
 				'filter' => 'alpha',
 				'default' => '',
 				'options' => array(
-					array('text' => '', 'value' => ''), 
-					array('text' => tra('Yes'), 'value' => 'y'), 
+					array('text' => '', 'value' => ''),
+					array('text' => tra('Yes'), 'value' => 'y'),
 					array('text' => tra('No'), 'value' => 'n')
 				)
 			),
 <at>  <at>  -153,10 +167,13  <at>  <at> 
 	global $trklib, $smarty, $tikilib;
 	require_once 'lib/trackers/trackerlib.php';

+	static $instance = 0;
+	$instance++;
+
 	if ( ! isset( $params['tracker'] ) )
 		return "^" . tr("Missing parameter: %0", 'tracker') . "^";

-	$default = array('scale1' => 'hour', 'simile_timeline' => 'n');
+	$default = array('scale1' => 'hour', 'simile_timeline' => 'n', 'height' => '250px', 'band2_height'
=> 30);
 	$params = array_merge($default, $params);
 	$formats = array('hour'=>'H:i', 'day'=>'jS', 'week' => 'jS', 'month'=>'m', 'year'=>'y');

 <at>  <at>  -285,11 +302,11  <at>  <at> 
 		$js = 'var ttl_eventData = ' . json_encode($ttl_data) . ";\n";

 		$js .= '
-setTimeout( function(){ ttlInit("ttl_timeline",ttl_eventData,"' . $params['scale1'] . '","' .
$params['scale2'] . '"); }, 1000);
+setTimeout( function(){ ttlInit("ttl_timeline_' . $instance . '",ttl_eventData,"' .
$params['scale1'] . '","' . $params['scale2'] . '","' . $params['band2_height'] . '"); }, 1000);
 ';

 		$headerlib->add_jq_onready($js, 10);
-		$out = '<div id="ttl_timeline" style="height: 250px; border: 1px solid #aaa"></div>';
+		$out = '<div id="ttl_timeline_' . $instance . '" style="height: ' . $params['height'] . '; border: 1px
solid #aaa"></div>';
 		return $out;
 	}
 }

This was sent by the SourceForge.net collaborative development platform, the world's largest Open
Source development site.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

Gmane