Your IP : 216.73.216.240


Current Path : /home/j/u/v/juvelize/www/modules/mod_jts_counterstats/admin/
Upload File :
Current File : /home/j/u/v/juvelize/www/modules/mod_jts_counterstats/admin/colorpicker.php

<?php
/**
 * @version		$Id: colorpicker.php 2011-06-21 15:38:03Z $
 * @license		GNU General Public License version 2 or later;
 * @author		Velmurugan K
 * @authoremail	vkuberan@gmail.com 
 */

// no direct access
defined('_JEXEC') or die;

jimport('joomla.form.formfield');

/**
 * Renders an an input into an color picker
 *
 */
class JFormFieldColorPicker extends JFormField 
{
	/**
	 * Element name
	 *
	 * @var		string
	 */
	protected $type = 'ColorPicker';
	
	/**
	 * Method to get the field input markup.
	 *
	 * @return	string	The field input markup.
	 *
	 */
	protected function getInput()
	{
		
		$js_jquery	= JURI::root(true)."/modules/mod_jts_counterstats/admin/js/jquery.min.js";
		$js_file	= JURI::root(true)."/modules/mod_jts_counterstats/admin/js/jquery.miniColors.min.js";
		$css_file	= JURI::root(true)."/modules/mod_jts_counterstats/admin/jquery.miniColors.css";
		
		
		//add the javascript and its css to the header
		$document	 = JFactory::getDocument();		
		
		$document->addScript( $js_jquery );
		
		$document->addCustomTag( '<script type="text/javascript">jQuery.noConflict();</script>' );
		
		$document->addScript( $js_file );
		
		$document->addStyleSheet( $css_file );
		
		$script		 = ' <script type="text/javascript"> ';
		$script		.= '	jQuery(document).ready( function() { ';
		$script		.= '		jQuery(".colors").miniColors();	';
		$script		.= '	}); ';		
		$script		.= ' </script>';
		
		
		$document->addCustomTag($script);

		$onchange	= " onchange = initColorPicker(this) ";
		$onclick	= " onclick  = initColorPicker(this) ";
		$onfocus	= " onfocus  = initColorPicker(this) ";
		
		$class		= ' class="colors"';

		return '<input type="text" name="'.$this->name.'" id="'.$this->id.'"' . 
		       ' value="'.htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8').
		       '"' . $class.' />'; 
		
		
	}
	
}