Esempio n. 1
0
 /**
  * Write a <link ></link > element
  * @param   string   path to file
  * @param   string   library name
  * @param   string   library version
  * @param   boolean   library version
  * @return  nothing
  */
 public static function css($namespace, $path = FALSE, $version = '', $minified = NULL)
 {
     static $loaded = array();
     // Only load once
     // using of namespace assume same css have same namespace
     // loading 2 time css with this method simply return and do not load it the second time
     if (!empty($loaded[$namespace])) {
         return;
     }
     $file = vmJsApi::setPath($namespace, $path, $version = '', $minified, 'css');
     $document = JFactory::getDocument();
     $document->addStyleSheet($file);
     $loaded[$namespace] = TRUE;
 }
Esempio n. 2
0
    static function jDate($date = '', $name = "date", $id = NULL, $resetBt = TRUE, $yearRange = '')
    {
        if ($yearRange) {
            $yearRange = 'yearRange: "' . $yearRange . '",';
        }
        $test = (int) str_replace(array('-', ' ', ':'), '', $date);
        if (empty($test)) {
            $date = 0;
        }
        if (empty($id)) {
            $id = str_replace(array('[]', '[', ']'), '.', $name);
            $id = str_replace('..', '.', $id);
        }
        static $jDate;
        if (!class_exists('VmHtml')) {
            require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
        }
        $id = VmHtml::ensureUniqueId($id);
        $dateFormat = vmText::_('COM_VIRTUEMART_DATE_FORMAT_INPUT_J16');
        //="m/d/y"
        $search = array('m', 'd', 'Y');
        $replace = array('mm', 'dd', 'yy');
        $jsDateFormat = str_replace($search, $replace, $dateFormat);
        if ($date) {
            $formatedDate = JHtml::_('date', $date, $dateFormat);
        } else {
            $formatedDate = vmText::_('COM_VIRTUEMART_NEVER');
        }
        $display = '<input class="datepicker-db" id="' . $id . '" type="hidden" name="' . $name . '" value="' . $date . '" />';
        $display .= '<input id="' . $id . '_text" class="datepicker" type="text" value="' . $formatedDate . '" />';
        if ($resetBt) {
            $display .= '<span class="vmicon vmicon-16-logout icon-nofloat js-date-reset"></span>';
        }
        // If exist exit
        if ($jDate) {
            return $display;
        }
        self::addJScript('datepicker', '
			jQuery(document).ready( function($) {
			jQuery(document).on( "focus",".datepicker", function() {
				jQuery( this ).datepicker({
					changeMonth: true,
					changeYear: true,
					' . $yearRange . '
					dateFormat:"' . $jsDateFormat . '",
					altField: $(this).prev(),
					altFormat: "yy-mm-dd"
				});
			});
			jQuery(document).on( "click",".js-date-reset", function() {
				jQuery(this).prev("input").val("' . vmText::_('COM_VIRTUEMART_NEVER') . '").prev("input").val("0");
			});
		});
		');
        vmJsApi::css('ui/jquery.ui.all');
        $lg = JFactory::getLanguage();
        $lang = $lg->getTag();
        $vlePath = vmJsApi::setPath('i18n/jquery.ui.datepicker-' . $lang, FALSE, '', $minified = NULL, 'js', true);
        if (!file_exists($vlePath) or is_dir($vlePath)) {
            $lang = 'en-GB';
        }
        vmJsApi::addJScript('i18n/jquery.ui.datepicker-' . $lang);
        $jDate = TRUE;
        return $display;
    }
Esempio n. 3
0
 static function JvalideForm($name = '#adminForm')
 {
     static $jvalideForm;
     // If exist exit
     if ($jvalideForm === $name) {
         return;
     }
     $document = JFactory::getDocument();
     $document->addScriptDeclaration("\r\n//<![CDATA[\r\n\t\t\tjQuery(document).ready(function() {\r\n\t\t\t\tjQuery('" . $name . "').validationEngine();\r\n\t\t\t});\r\n//]]>\r\n");
     if ($jvalideForm) {
         return;
     }
     vmJsApi::js('jquery.validationEngine');
     $lg = JFactory::getLanguage();
     $lang = substr($lg->getTag(), 0, 2);
     /*$existingLang = array("cz", "da", "de", "en", "es", "fr", "it", "ja", "nl", "pl", "pt", "ro", "ru", "tr");
     		if (!in_array ($lang, $existingLang)) {
     			$lang = "en";
     		}*/
     $vlePath = vmJsApi::setPath('languages/jquery.validationEngine-' . $lang, FALSE, '', $minified = NULL, 'js', true);
     if (file_exists($vlePath) and !is_dir($vlePath)) {
         vmJsApi::js('languages/jquery.validationEngine-' . $lang);
     } else {
         vmJsApi::js('languages/jquery.validationEngine-en');
     }
     vmJsApi::css('validationEngine.template');
     vmJsApi::css('validationEngine.jquery');
     $jvalideForm = $name;
 }