Skip to content

Commit

Permalink
use handlers for javascript and rename onload
Browse files Browse the repository at this point in the history
  • Loading branch information
TomCafferty committed Jul 15, 2013
1 parent 8128777 commit 1145fbb
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 32 deletions.
39 changes: 35 additions & 4 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,41 @@ function render($mode, &$R, $data) {
}

// onload invoke timeline javascript
$R->doc .='<script>window.onLoad = onLoad("'.$filePath.'" , '.$bubbleHeight.', '.$bubbleWidth.', "'.$mouse.'", "'.$center.'", "'
.$controls.'", "'.$bandPos.'", "'.$detailPercent.'", "'.$overPercent.'", "'.$detailPixels.'", "'.$overPixels.'", "'.$detailInterval.'",
"'.$overInterval.'", "'.$hotzone.'", "'.$hzStart.'", "'.$hzEnd.'", "'.$hzMagnify.'", "'.$hzUnit.'", "'.$hzStart2.'", "'.$hzEnd2.'", "'.$hzMagnify2.'", "'.$hzUnit2.'", "'.$hzStart3.'", "'.$hzEnd3.'", "'.$hzMagnify3.'", "'.$hzUnit3.'");</script>' . "\n";
$R->doc .='<script>window.onResize=onResize();</script> ';
$R->doc .= $this->_script($filePath, $bubbleHeight, $bubbleWidth, $mouse, $center, $controls, $bandPos, $detailPercent, $overPercent, $detailPixels, $overPixels, $detailInterval, $overInterval, $hotzone, $hzStart, $hzEnd, $hzMagnify, $hzUnit, $hzStart2, $hzEnd2, $hzMagnify2, $hzUnit2, $hzStart3, $hzEnd3, $hzMagnify3, $hzUnit3);
return true;
}

function _script($filePath, $bubbleHeight, $bubbleWidth, $mouse, $center, $controls, $bandPos, $detailPercent, $overPercent, $detailPixels, $overPixels, $detailInterval, $overInterval, $hotzone, $hzStart, $hzEnd, $hzMagnify, $hzUnit, $hzStart2, $hzEnd2, $hzMagnify2, $hzUnit2, $hzStart3, $hzEnd3, $hzMagnify3, $hzUnit3){
$str = '<script type="text/javascript" language="javascript">';
$str .= 'var plugin_eventline_filePath = "'.$filePath.'";';
$str .= 'var plugin_eventline_bubbleHeight = '.$bubbleHeight.';';
$str .= 'var plugin_eventline_bubbleWidth = '.$bubbleWidth.';';
$str .= 'var plugin_eventline_mouse = "'.$mouse.'";';
$str .= 'var plugin_eventline_center = "'.$center.'";';
$str .= 'var plugin_eventline_controls = "'.$controls.'";';
$str .= 'var plugin_eventline_bandPos = "'.$bandPos.'";';
$str .= 'var plugin_eventline_detailPercent = "'.$detailPercent.'";';
$str .= 'var plugin_eventline_overPercent = "'.$overPercent.'";';
$str .= 'var plugin_eventline_detailPixels = "'.$detailPixels.'";';
$str .= 'var plugin_eventline_overPixels = "'.$overPixels.'";';
$str .= 'var plugin_eventline_detailInterval = "'.$detailInterval.'";';
$str .= 'var plugin_eventline_overInterval = "'.$overInterval.'";';
$str .= 'var plugin_eventline_hotzone = "'.$hotzone.'";';
$str .= 'var plugin_eventline_hzStart = "'.$hzStart.'";';
$str .= 'var plugin_eventline_hzEnd = "'.$hzEnd.'";';
$str .= 'var plugin_eventline_hzMagnify = "'.$hzMagnify.'";';
$str .= 'var plugin_eventline_hzUnit = "'.$hzUnit.'";';
$str .= 'var plugin_eventline_hzStart2 = "'.$hzStart2.'";';
$str .= 'var plugin_eventline_hzEnd2 = "'.$hzEnd2.'";';
$str .= 'var plugin_eventline_hzMagnify2 = "'.$hzMagnify2.'";';
$str .= 'var plugin_eventline_hzUnit2 = "'.$hzUnit2.'";';
$str .= 'var plugin_eventline_hzStart3 = "'.$hzStart3.'";';
$str .= 'var plugin_eventline_hzEnd3 = "'.$hzEnd3.'";';
$str .= 'var plugin_eventline_hzMagnify3 = "'.$hzMagnify3.'";';
$str .= 'var plugin_eventline_hzUnit3 = "'.$hzUnit3.'";';
$str .= "jQuery('#plugin_eventline').bind('load', plugin_eventline());";
$str .= "jQuery('#plugin_eventline').bind('resize', plugin_eventline_onResize());";
$str .= '</script>';
return $str;
}
}
56 changes: 28 additions & 28 deletions timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@
*/
var tl;

function onLoad() {
function plugin_eventline() {

var theme = Timeline.ClassicTheme.create();
var filepath;

filepath = arguments[0];
bubbleH = arguments[1];
bubbleW = arguments[2];
mouse = arguments[3];
center = arguments[4];
controls = arguments[5];
bandPos = arguments[6];
detailPart = arguments[7];
overPart = arguments[8];
detailPixels = arguments[9];
overPixels = arguments[10];
detailInterval = arguments[11];
overInterval = arguments[12];
filepath = plugin_eventline_filePath;
bubbleH = plugin_eventline_bubbleHeight;
bubbleW = plugin_eventline_bubbleWidth;
mouse = plugin_eventline_mouse;
center = plugin_eventline_center;
controls = plugin_eventline_controls;
bandPos = plugin_eventline_bandPos;
detailPart = plugin_eventline_detailPercent;
overPart = plugin_eventline_overPercent;
detailPixels = plugin_eventline_detailPixels;
overPixels = plugin_eventline_overPixels;
detailInterval = plugin_eventline_detailInterval;
overInterval = plugin_eventline_overInterval;

hotzone = arguments[13];
hzStart = arguments[14];
hzEnd = arguments[15];
hzMagnify = arguments[16];
hzUnit = arguments[17];
hotzone = plugin_eventline_hotzone;
hzStart = plugin_eventline_hzStart;
hzEnd = plugin_eventline_hzEnd;
hzMagnify = plugin_eventline_hzMagnify;
hzUnit = plugin_eventline_hzUnit;

hzStart2 = arguments[18];
hzEnd2 = arguments[19];
hzMagnify2 = arguments[20];
hzUnit2 = arguments[21];
hzStart2 = plugin_eventline_hzStart2;
hzEnd2 = plugin_eventline_hzEnd2;
hzMagnify2 = plugin_eventline_hzMagnify2;
hzUnit2 = plugin_eventline_hzUnit2;

hzStart3 = arguments[22];
hzEnd3 = arguments[23];
hzMagnify3 = arguments[24];
hzUnit3 = arguments[25];
hzStart3 = plugin_eventline_hzStart3;
hzEnd3 = plugin_eventline_hzEnd3;
hzMagnify3 = plugin_eventline_hzMagnify3;
hzUnit3 = plugin_eventline_hzUnit3;

theme.mousewheel = mouse;
theme.event.label.width = 500;
Expand Down Expand Up @@ -147,7 +147,7 @@ function centerTimeline(dateStr) {
}

var resizeTimerID = null;
function onResize() {
function plugin_eventline_onResize() {
if (resizeTimerID == null) {
resizeTimerID = window.setTimeout(function() {
resizeTimerID = null;
Expand Down

0 comments on commit 1145fbb

Please sign in to comment.