Example #1
0
 static function StylesAndJS($params = array(), $css = array(), $js = array())
 {
     $document = JFactory::getDocument();
     $force_jquery = false;
     if (isset($params['force_jquery'])) {
         $force_jquery = true;
         unset($params['force_jquery']);
     }
     if (in_array('force_jquery', $params)) {
         $force_jquery = true;
         $key = array_search('force_jquery', $params);
         unset($params[$key]);
     }
     if (!self::$styles_incl) {
         // jquery with its various options
         self::IncludeJQuery($force_jquery);
         // bootstrap (css and javascript)
         self::Bootstrap();
         //$document->addStyleSheet(FSSRoute::_( "index.php?option=com_fss&view=css&layout=default&old=1" )); // Add old stylesheets to page
         FSS_CSSParse::OutputCSS('components/com_fss/assets/css/fss.less');
         if (!FSSJ3Helper::IsJ3()) {
             FSS_CSSParse::OutputCSS('components/com_fss/assets/css/fss_j25.less');
         }
         if (FSS_Settings::get('hide_warnings')) {
             $document->addScriptDeclaration('var fss_no_warn = true;');
         }
         $document->addScript(JURI::root(true) . '/components/com_fss/assets/js/main.js');
         if (FSS_Settings::get('bootstrap_v3')) {
             FSS_CSSParse::OutputCSS('components/com_fss/assets/css/bs3_fixes.less');
             $document->addScript(JURI::root(true) . '/components/com_fss/assets/js/bs3_fixes.js');
         }
         self::$styles_incl = true;
     }
     foreach ($params as $param) {
         if (array_key_exists($param, self::$styles_sub_incl)) {
             continue;
         }
         switch ($param) {
             case 'autoscroll':
                 $document->addScript(JURI::root(true) . '/components/com_fss/assets/js/jquery/jquery.autoscroll.js');
                 break;
             case 'tooltip':
                 $document->addScript(JURI::root(true) . '/components/com_fss/assets/js/fss_tooltip.js');
                 break;
             case 'glossary':
                 $document->addScript(JURI::root(true) . '/components/com_fss/assets/js/glossary.js');
                 break;
             case 'translate':
                 $document->addScript(JURI::root(true) . '/administrator/components/com_fss/assets/js/translate.js');
                 $document->addScript(JURI::root(true) . '/administrator/components/com_fss/assets/js/popup.js');
                 $document->addStyleSheet(JURI::root(true) . '/administrator/components/com_fss/assets/css/popup.css');
                 break;
             case 'csstest':
                 $document->addScript(JURI::root(true) . '/administrator/components/com_fss/assets/js/csstest.js');
                 break;
             case 'admin_css':
                 $document->addStyleSheet(JURI::root(true) . '/administrator/components/com_fss/assets/css/main.css');
                 break;
             case 'calendar':
                 $document->addStyleSheet(JURI::root(true) . '/components/com_fss/assets/css/calendar.css');
                 $document->addStyleSheet(JURI::root(true) . '/components/com_fss/assets/css/calendar_omega.css');
                 $document->addScript(JURI::root(true) . '/components/com_fss/assets/js/calendar.js');
                 break;
             case 'base64':
                 $document->addScript(JURI::root(true) . '/components/com_fss/assets/js/base64.js');
                 break;
             case 'ticket_list':
                 FSS_Translate_Helper::CalenderLocale();
                 $document->addScript(JURI::root(true) . '/components/com_fss/assets/js/ticket_list.js');
                 break;
             case 'cookie':
                 $document->addScript(JURI::root(true) . '/components/com_fss/assets/js/jquery/jquery.cookie.js');
                 break;
         }
         self::$styles_sub_incl[$param] = 1;
     }
     foreach ($css as $c) {
         if (array_key_exists($c, self::$styles_sub_incl)) {
             continue;
         }
         $document->addStyleSheet(JURI::root(true) . "/" . $c);
         self::$styles_sub_incl[$c] = 1;
     }
     foreach ($js as $j) {
         if (array_key_exists($j, self::$styles_sub_incl)) {
             continue;
         }
         $document->addScript(JURI::root(true) . "/" . $j);
         self::$styles_sub_incl[$j] = 1;
     }
     /* Joomla 3.4 fix for admin pagination problem */
     if (JFactory::getApplication()->isAdmin()) {
         $version = new JVersion();
         if ($version->RELEASE >= 3.4) {
             $script = "\n\t\t\t\tjQuery(document).ready( function () {\n\t\t\t\t\tjQuery('.pagination-list').removeClass('pagination');\n\t\t\t\t\tjQuery('.pagination-toolbar').addClass('pagination');\n\t\t\t\t});";
             $document->addScriptDeclaration($script);
         }
     }
 }