Skip to content
Snippets Groups Projects
Commit d759bd10 authored by colemanw's avatar colemanw
Browse files

Move settings to html-header region CRM-12339

parent 8053ab8a
No related branches found
No related tags found
No related merge requests found
......@@ -202,7 +202,7 @@ class CRM_Core_Resources {
$this->settings = $this->mergeSettings($this->settings, $settings);
if (!$this->addedSettings) {
$resources = $this;
CRM_Core_Region::instance('settings')->add(array(
CRM_Core_Region::instance('html-header')->add(array(
'callback' => function(&$snippet, &$html) use ($resources) {
$html .= "\n" . $resources->renderSetting();
}
......@@ -219,7 +219,6 @@ class CRM_Core_Resources {
* @return CRM_Core_Resources
*/
public function addSettingsFactory($callable) {
$this->addSetting(array()); // ensure that 'settings' region is created, even if empty
$this->settingsFactories[] = $callable;
return $this;
}
......@@ -260,7 +259,8 @@ class CRM_Core_Resources {
* @return string
*/
public function renderSetting() {
return 'CRM = cj.extend(true, ' . json_encode($this->getSettings()) . ', CRM);';
$js = 'var CRM = cj.extend(true, ' . json_encode($this->getSettings()) . ', CRM || {});';
return sprintf("<script type=\"text/javascript\">\n%s\n</script>\n", $js);
}
/**
......@@ -450,6 +450,13 @@ class CRM_Core_Resources {
$js = "CRM.url('init', '$url');";
$this->addScript($js, $jsWeight++, $region);
// Add global settings
$settings = array(
'userFramework' => json_encode($config->userFramework),
'resourceBase' => json_encode($config->resourceBase),
);
$this->addSetting(array('config' => $settings));
// Give control of jQuery back to the CMS - this loads last
$this->addScriptFile('civicrm', 'js/noconflict.js', 9999, $region, FALSE);
......
......@@ -42,13 +42,8 @@
strings: {},
config: {{/literal}
urlIsPublic: {if $urlIsPublic}true{else}false{/if},
userFramework: '{$config->userFramework}',
resourceBase: '{$config->resourceBase}',
search_autocomplete_count: {crmSetting name="search_autocomplete_count" group="Search Preferences"}
{literal}},
}, CRM);
{/literal}
{* Dynamically add server-side variables to the CRM object *}
{crmRegion name='settings'}
{/crmRegion}
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment