PageRenderTime 21ms CodeModel.GetById 10ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_easysocial/themes/default/easysocial/widget.registration.js

https://gitlab.com/vnsoftdev/swc
JavaScript | 117 lines | 99 code | 16 blank | 2 comment | 9 complexity | c9be87f6820ad0ce41f3008b0647f539 MD5 | raw file
  1
  2EasySocial.require()
  3.library( 'flot' )
  4.done(function($){
  5
  6	var data = new Array;
  7
  8	<?php for( $i = 0; $i < count($signupData->profiles ); $i++ ){ ?>
  9		var tmp = new Array;
 10
 11		<?php for($x = 0; $x < count( $signupData->profiles[ $i ]->items ); $x++ ){ ?>
 12			tmp.push( [<?php echo $x;?>, <?php echo $signupData->profiles[ $i ]->items[ $x ];?>] );
 13		<?php } ?>
 14
 15		var obj = {
 16					data 	: tmp,
 17					label	: "<?php echo $signupData->profiles[ $i ]->title;?>"
 18				};
 19
 20		data.push( obj );
 21	<?php } ?>
 22
 23	$( '[data-chart-registration]' ).plot( data ,
 24	{
 25		lines:
 26		{
 27			show			: true,
 28			fill			: true,
 29			lineWidth		: 2
 30		},
 31		legend:
 32		{
 33			sorted: "asc",
 34			noColumns: 7,
 35			container: $("[data-chart-registration-legend]" ),
 36			backgroundColor: "#fff",
 37			backgroundOpacity: 1
 38		},
 39		xaxis:
 40		{
 41			ticks:
 42			[
 43				<?php for( $i = 0; $i < count( $axes ); $i++ ){ ?>
 44				[ <?php echo $i;?> , '<?php echo $axes[ $i ];?>' ]<?php echo ($i + 1) != 7 ? ',' : '';?>
 45				<?php } ?>
 46			]
 47		},
 48		points:
 49		{
 50			show		: true,
 51			fill 		: true,
 52			lineWidth 	: 4
 53		},
 54
 55		grid:
 56		{
 57			clickable: true,
 58			hoverable: true,
 59			autoHighlight: true,
 60			mouseActiveRadius: 10,
 61			aboveData: true,
 62			backgroundColor: "#fff",
 63			borderWidth: 0,
 64			borderColor: "#fc0",
 65			minBorderMargin: 25,
 66		},
 67		// colors: [ "rgba(77,175,140,0.5)", "rgba(178,189,199,0.5)",  "#609", "#900"],
 68		shadowSize: 0
 69
 70	});
 71
 72	var previousPoint 	= null,
 73		previousLabel 	= null;
 74
 75	$( '[data-chart-registration]' ).bind( 'plothover' , function( event , pos , item )
 76	{
 77		if( item )
 78		{
 79			if( previousPoint != item.dataIndex || previousLabel != item.series.label )
 80			{
 81				previousPoint	= item.dataIndex;
 82				previousLabel 	= item.series.label;
 83
 84				$("#tooltip").remove();
 85
 86				var x 	= item.datapoint[0],
 87					y	= item.datapoint[1];
 88
 89				window.showTooltip( item.pageX, item.pageY, y + ' ' + '<?php echo JText::_('COM_EASYSOCIAL_USERS');?>' );
 90			}
 91		}
 92		else
 93		{
 94			$( '#tooltip' ).remove();
 95
 96			previousPoint 	= null;
 97		}
 98	}); 
 99
100	// Show tooltip
101	window.showTooltip = function( x , y , contents )
102	{
103		$( '<div id="tooltip">' + contents + '</div>' )
104			.css(
105			{
106				position: "absolute",
107				display: "none",
108				top: y + 5,
109				left: x + 5,
110				padding: "5px",
111				'background-color' : '#000',
112				'font-size'			: '10',
113				color: '#fff',
114				opacity: 0.80
115			}).appendTo( 'body' ).fadeIn( 200 );
116	};
117});