Fix inconsistent ordering of header elements CRM-12339
authorColeman Watts <coleman@civicrm.org>
Sat, 13 Apr 2013 23:31:47 +0000 (16:31 -0700)
committerColeman Watts <coleman@civicrm.org>
Sun, 14 Apr 2013 00:56:18 +0000 (17:56 -0700)
In D6 & D7 our header region seems to always render before drupal's scripts and styles,
whereas Joomla was the opposite. To fix this I have rolled-back the use of JFactory to add scripts,
and weighted our settings region so it will always be the first thing in the header.

CRM/Core/Resources.php
CRM/Utils/System/Joomla.php

index d5c39145e9e74244ee43cb5dfbdce20d26cf863b..5b247f00b0567e1c569a97cfd384d84698c6e1b8 100644 (file)
@@ -205,7 +205,8 @@ class CRM_Core_Resources {
       CRM_Core_Region::instance('html-header')->add(array(
         'callback' => function(&$snippet, &$html) use ($resources) {
           $html .= "\n" . $resources->renderSetting();
-        }
+        },
+        'weight' => -100000,
       ));
       $this->addedSettings = TRUE;
     }
@@ -261,7 +262,7 @@ class CRM_Core_Resources {
    * @return string
    */
   public function renderSetting() {
-    $js = 'var CRM = cj.extend(true, ' . json_encode($this->getSettings()) . ', CRM || {});';
+    $js = 'var CRM = ' . json_encode($this->getSettings()) . ';';
     return sprintf("<script type=\"text/javascript\">\n%s\n</script>\n", $js);
   }
 
index d644e1bbbc89d48ba24f5ae95c7c082e23d3557f..518d85f439c79ab9abbd660a86ad82323017fdf6 100644 (file)
@@ -261,11 +261,6 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
    * @access public
    */
   public function addScriptUrl($url, $region) {
-    if ($region == 'html-header') {
-      $document = JFactory::getDocument();
-      $document->addScript($url);
-      return TRUE;
-    }
     return FALSE;
   }
 
@@ -282,11 +277,6 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
    * @access public
    */
   public function addScript($code, $region) {
-    if ($region == 'html-header') {
-      $document = JFactory::getDocument();
-      $document->addScriptDeclaration($code);
-      return TRUE;
-    }
     return FALSE;
   }