jQuery(document).ready(function()
{
if (data_close_0.length == 0)
{
$('[id$=chart]', parent.document).hide();
return;
}
$('#loader').hide();
/*SCROLL*/
var a = 0; //flag left scroller
var b = 0; //flag left scroller
var ls = 0; //init pos left sc...
var rs = SymexChartGlobals.chart_width; //init pos right sc...
drawLine( 0, SymexChartGlobals.points_qty );
if ( SymexChartGlobals.period_type == 'intra' ) { labels_X_intra( 0, SymexChartGlobals.points_qty ); }
else if ( SymexChartGlobals.period_type == 'week' ) { labels_X_week( 0, SymexChartGlobals.points_qty ); }
labels_Y( 0, SymexChartGlobals.points_qty );
if (SymexChartGlobals.display_news == 1) { news( 0, SymexChartGlobals.points_qty ); }
if (SymexChartGlobals.display_volume == 1)
{
drawVolumes( 0, SymexChartGlobals.points_qty );
labels_volume_Y( 0, SymexChartGlobals.points_qty );
}
show_period( 0, SymexChartGlobals.points_qty );
show_header( 0, SymexChartGlobals.points_qty );
if ( SymexChartGlobals.chart_sum_height > 5 ) { drawLine_2(); labels_X_summary(); }
jQuery('#ie_mousemove_bug, #precCell').bind('mousemove touchmove', function(e)
{
// google.bg: jquery touchmove
// http://www.devinrolsen.com/basic-jquery-touchmove-event-setup/
if (e.originalEvent.touches)
{
// Case touch screen device
e.preventDefault();
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
var elm = jQuery(this).offset();
var x = touch.pageX - elm.left;
var x_orig = x; // Need for precission cell pointer
var y = touch.pageY - elm.top;
// Prevent touch devices bug -> touchmove event is keep outside the element!
if(x > jQuery(this).width() || x < 0 || y > jQuery(this).height() || y < 0){
return;
}
}
else
{
// Case PC
var x = e.pageX - jQuery(this).offset().left; //*new* this.offsetLeft;
var x_orig = x; // Need for precission cell pointer
var y = e.pageY - jQuery(this).offset().top;//*new* this.offsetTop;
}
//size of precission cell
var precCellH = jQuery('#precCell').height();
var precCellW = jQuery('#precCell').width();
if (x > SymexChartGlobals.chart_width || y > SymexChartGlobals.chart_height) return;
var next = 0;
//if (SymexChartGlobals.begin == 0) next = 1;
var curr_date = parseInt( x / SymexChartGlobals.stepX ) + next + SymexChartGlobals.begin;
if (curr_date > SymexChartGlobals.points_qty - 1) curr_date = SymexChartGlobals.points_qty - 1;
if ( x > (SymexChartGlobals.chart_width / 2) ) x = x - precCellW - 10;
else x += 10;
if ( y > (SymexChartGlobals.chart_height / 2) ) y = y - precCellH - 10;
else y += 10;
// Only for Coteboursiere Mobile Version !!!
if (y < -5) y = -5; // -5px - precission cell over price graph's margin top space (period info)
var y_max = SymexChartGlobals.chart_height + 20; // +20px - over labels X
if (y + precCellH > y_max) y = y_max - precCellH;
//if no quotations on current day
if ( ! data_close_0[curr_date] )
{
//SENSIBLE PRECISSION CELL (Show nearest quotes)
var flag_hide = true;
// old - 5, from 19.03.2013 - 50
for (var it = 1; it <= 50; it++)
{
if ( data_close_0[curr_date + it] )
{
curr_date += it;
flag_hide = false;
break;
}
}
if (flag_hide)
{
jQuery('#precCell').hide();
jQuery('#precCell_txt').hide();
jQuery('#precCellPointer').hide();
return;
}
}
// Here is case that we have quote on current mouse position or 2 position next
if ( SymexChartGlobals.tickers_qty == 1 && SymexChartGlobals.chart_height > 90)
{
var full = 5;
var text_precCell = SymexChartSettings.lang_array[30] + date_eu(data_date[curr_date]);
text_precCell += '
' + SymexChartSettings.lang_array[31] + format_price( data_close_0[curr_date] );
text_precCell += '
' + SymexChartSettings.lang_array[33] + format_price( data_open_0[curr_date] );
text_precCell += '
' + SymexChartSettings.lang_array[34] + format_price( data_high_0[curr_date] );
text_precCell += '
' + SymexChartSettings.lang_array[35] + format_price( data_low_0[curr_date] );
if ( data_vol_0[curr_date] > 0 )
{
text_precCell += '
' + SymexChartSettings.lang_array[32] + format_price( data_vol_0[curr_date], true );
full++;
}
var fontSize = parseInt( jQuery( "#precCell_txt" ).css( "font-size" ) );
var lineHeight = fontSize + 3;
jQuery("#precCell").css({
height: ( lineHeight * full ) + "px",
lineHeight: lineHeight + "px"
});
}
else if ( SymexChartGlobals.tickers_qty == 1)
{
// Case chart's height > 90
var full = 2;
var wordPrice = SymexChartSettings.lang_array[31];
if ( typeof SymexChartSettings.lang_array[36] != "undefined" ) {
wordPrice = SymexChartSettings.lang_array[36];
}
var text_precCell = SymexChartSettings.lang_array[30] + date_eu(data_date[curr_date]);
text_precCell += "
" + wordPrice + format_price( data_close_0[curr_date] );
var fontSize = parseInt( jQuery( "#precCell_txt" ).css( "font-size" ) );
var lineHeight = fontSize + 3;
jQuery("#precCell").css({
height: ( lineHeight * full ) + "px",
lineHeight: lineHeight + "px"
});
}
else
{
var text_precCell = SymexChartSettings.lang_array[30] + date_eu(data_date[curr_date]);
var full = 1;
for( var b = 0; b < SymexChartGlobals.tickers_qty; b++ )
{
if ( ! eval('data_close_' + b + '[curr_date]') ) continue;
text_precCell += '
' + SymexChartGlobals.ticker_symbol[b]+ ': ';
text_precCell += format_price( eval('data_close_' + b + '[curr_date]') );
full++;
}
var fontSize = parseInt( jQuery( "#precCell_txt" ).css( "font-size" ) );
var lineHeight = fontSize + 3;
jQuery("#precCell").css({
height: ( lineHeight * full ) + "px",
lineHeight: lineHeight + "px"
});
}
if(SymexChartGlobals.NoDisplayPrecell == 1){
jQuery('#precCell').hide();
jQuery('#precCell_txt').hide();
jQuery('#precCellPointer').hide();
}else{
jQuery('#precCell').show();
jQuery('#precCell_txt').show();
jQuery('#precCellPointer').show();
jQuery('#precCellPointer').css('left', x_orig);
jQuery('#precCell').css('left', x);
jQuery('#precCell').css('top', y);
jQuery('#precCell_txt').html(text_precCell);
}
});
/*SCROLL*/
jQuery('#summaryGraph').bind('mousemove touchmove', function(e)
{
if (e.originalEvent.touches)
{
// Case touch screen device
e.preventDefault();
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
var elm = jQuery(this).offset();
var scrollPosX = touch.pageX - elm.left;
}
else
{
var scrollPosX = e.pageX - jQuery(this).offset().left;
}
if( scrollPosX < 0 || scrollPosX > (SymexChartGlobals.chart_width - 6) ) {
return;
}
if( a == 5 ) {
ls = scrollPosX;
jQuery('#left_scroll').css('left', ls);
}
if(b == 5 ) {
rs = scrollPosX;
jQuery('#right_scroll').css('left', rs);
rs += 7;
}
});
jQuery('#left_scroll').bind('mousedown touchstart', function(e)
{
a = 5;
var target = e.target != null ? e.target : e.srcElement;
document.body.focus();
document.onselectstart = function () { return false; };
target.ondragstart = function() { return false; };
return false;
});
jQuery('#right_scroll').bind('mousedown touchstart', function(e)
{
b = 5;
var target = e.target != null ? e.target : e.srcElement;
document.body.focus();
document.onselectstart = function () { return false; };
target.ondragstart = function() { return false; };
return false;
});
jQuery(document).bind('mouseup touchend', function(e)
{
// We use document.mouseup only for scroller funcs => so if no need of them => exit
if ( a == 0 && b == 0 ) return;
document.onselectstart = null;
a = 0;
b = 0;
//original step 'X' => when show all points
var step_zoom = (SymexChartGlobals.chart_width - 1) / (data_date.length - 1);
//remove fron stage elements which will be redraw
clearLine();
//redraw stage
drawLine( parseInt( ls / step_zoom ), parseInt( rs / step_zoom ) );
if ( SymexChartGlobals.period_type == 'intra' )
{
labels_X_intra( parseInt( ls / step_zoom ), parseInt( rs / step_zoom ) );
}
else if ( SymexChartGlobals.period_type == 'week' )
{
labels_X_week( parseInt( ls / step_zoom ), parseInt( rs / step_zoom ) );
}
labels_Y( parseInt( ls / step_zoom ), parseInt( rs / step_zoom ) );
if (SymexChartGlobals.display_news == 1) { news( parseInt( ls / step_zoom ), parseInt( rs / step_zoom ) ); }
if (SymexChartGlobals.display_volume == 1)
{
drawVolumes( parseInt( ls / step_zoom ), parseInt( rs / step_zoom ) );
labels_volume_Y( parseInt( ls / step_zoom ), parseInt( rs / step_zoom ) );
}
show_period( parseInt( ls / step_zoom ), parseInt( rs / step_zoom ) );
});
});