<?php
/**
 * @package 	JF Interface
 * @author		JoomForest.com
 * @email		support@joomforest.com
 * @website		http://www.joomforest.com
 * @copyright	Copyright (C) 2011-2016 JoomForest.com, All rights reserved.
 * @license		http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * field - <field type="jfinterface" name="jfinterface" addfieldpath="/modules/MODULE_NAME/admin/jf_interface/formfields" path="modules/MODULE_NAME/admin/jf_interface/" />
**/
// no direct access
defined('_JEXEC') or die('Restricted access');

// ini_set('display_errors', 'On');
// error_reporting(E_ALL | E_STRICT);

jimport('joomla.form.formfield');

class JFormFieldJfinterface extends JFormField {
    protected $type = 'Jfinterface';
    protected function getInput() {
        $jf_doc = JFactory::getDocument();
		$jf_doc->addStyleSheet(JURI::root().$this->element['path'].'css/jf_interface.min.css');
		$jf_doc->addStyleSheet('//fonts.googleapis.com/icon?family=Material+Icons');
		$jf_doc->addScript(JURI::root().$this->element['path'].'js/jf_interface_1.0.min.js');
		// Bootstrap MINICOLORS
			$jf_doc->addStyleSheet(JURI::root().$this->element['path'].'js/bscolorpicker/css/bootstrap-colorpicker.min.css');
			$jf_doc->addScript(JURI::root().$this->element['path'].'js/bscolorpicker/js/bootstrap-colorpicker.min.js');
			$jf_doc->addStyleDeclaration('
				.jf_minicolors_wrap{position:relative;display:inline-block!important;vertical-align:middle}
				.jf_minicolors_wrap input{padding:6px 6px 6px 32px!important;font-family:Monaco,Menlo,Consolas,"Courier New",monospace;font-size:14px;width:180px!important}
				.jf_minicolors_wrap.colorpicker-element i{position:absolute;z-index:9;left:5px;top:5px;width:20px;height:20px;border:1px solid #CCC;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}
				.jf_minicolors_wrap .input-group-addon{display:block;padding:0;border:0;background:0}
			');
			$jf_doc->addScriptDeclaration('
				(function($){$(window).load(function(){
					$(".jf_UC_input").attr("placeholder","#rrggbb").wrap("<div class=\"input-group jf_minicolors_wrap\"></div>");
					$(".jf_minicolors_wrap").append("<span class=\"input-group-addon\"><i></i></span>");
					$(".jf_minicolors_wrap").colorpicker();
				})})(jQuery);
			');
        return '<script>jQuery("#general > .row-fluid > .span9").prepend("<div class=\"jf_int_content_preload_wrapper\"><div class=\"jf_int_content_preload\"><div class=\"blue\"></div><div class=\"red\"></div><div class=\"yellow\"></div><div class=\"green\"></div></div></div>");</script><div id="jf_interface"></div>';
    }
}