From d08319ae7e2b45f66d945c2498d2b9396c334e28 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 19 Apr 2014 17:10:47 -0700 Subject: [PATCH] CRM-14481, CRM-14479 - Load CSS for Angular modules --- CRM/Case/Info.php | 6 +++++- CRM/Core/Page/Angular.php | 14 ++++++++------ CRM/Utils/Hook.php | 4 ++-- css/angular-crmCaseType.css | 0 .../extensions/org.civicrm.angularex/angularex.php | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 css/angular-crmCaseType.css diff --git a/CRM/Case/Info.php b/CRM/Case/Info.php index 4bef8ddd84..61ec823c25 100644 --- a/CRM/Case/Info.php +++ b/CRM/Case/Info.php @@ -57,7 +57,11 @@ class CRM_Case_Info extends CRM_Core_Component_Info { */ public function getAngularModules() { $result = array(); - $result['crmCaseType'] = array('ext' => 'civicrm', 'files' => array('js/angular-crmCaseType.js')); + $result['crmCaseType'] = array( + 'ext' => 'civicrm', + 'js' => array('js/angular-crmCaseType.js'), + 'css' => array('css/angular-crmCaseType.css'), + ); return $result; } diff --git a/CRM/Core/Page/Angular.php b/CRM/Core/Page/Angular.php index 0f380edbca..a6b2d2c67c 100644 --- a/CRM/Core/Page/Angular.php +++ b/CRM/Core/Page/Angular.php @@ -33,11 +33,13 @@ class CRM_Core_Page_Angular extends CRM_Core_Page { $res->addScriptFile('civicrm', 'packages/bower_components/angular/angular.js', 100, 'html-header', FALSE); $res->addScriptFile('civicrm', 'packages/bower_components/angular-route/angular-route.js', 110, 'html-header', FALSE); foreach ($modules as $module) { - if (!empty($module['file'])) { - $res->addScriptFile($module['ext'], $module['file'], self::DEFAULT_MODULE_WEIGHT, 'html-header', TRUE); + if (!empty($module['css'])) { + foreach ($module['css'] as $file) { + $res->addStyleFile($module['ext'], $file, self::DEFAULT_MODULE_WEIGHT, 'html-header', TRUE); + } } - if (!empty($module['files'])) { - foreach ($module['files'] as $file) { + if (!empty($module['js'])) { + foreach ($module['js'] as $file) { $res->addScriptFile($module['ext'], $file, self::DEFAULT_MODULE_WEIGHT, 'html-header', TRUE); } } @@ -47,11 +49,11 @@ class CRM_Core_Page_Angular extends CRM_Core_Page { /** * Get a list of AngularJS modules which should be autoloaded * - * @return array (string $name => array('ext' => string $key, 'file' => string $path)) + * @return array (string $name => array('ext' => string $key, 'js' => array $paths, 'css' => array $paths)) */ public static function getAngularModules() { $angularModules = array(); - $angularModules['ui.utils'] = array('ext' => 'civicrm', 'file' => 'packages/bower_components/angular-ui-utils/ui-utils.js'); + $angularModules['ui.utils'] = array('ext' => 'civicrm', 'js' => array('packages/bower_components/angular-ui-utils/ui-utils.js')); foreach (CRM_Core_Component::getEnabledComponents() as $component) { $angularModules = array_merge($angularModules, $component->getAngularModules()); } diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index dd4861fb6f..4024d2668d 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -1610,8 +1610,8 @@ abstract class CRM_Utils_Hook { * * @code * function mymod_civicrm_angularModules(&$angularModules) { - * $angularModules['myAngularModule'] = array('ext' => 'org.example.mymod', 'file' => 'js/myAngularModule.js'); - * $angularModules['myBigAngularModule'] = array('ext' => 'org.example.mymod', 'files' => array('js/part1.js', 'js/part2.js')); + * $angularModules['myAngularModule'] = array('ext' => 'org.example.mymod', 'js' => array('js/myAngularModule.js')); + * $angularModules['myBigAngularModule'] = array('ext' => 'org.example.mymod', 'js' => array('js/part1.js', 'js/part2.js'), 'css' => array('css/myAngularModule.css')); * } * @endcode */ diff --git a/css/angular-crmCaseType.css b/css/angular-crmCaseType.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/extensions/org.civicrm.angularex/angularex.php b/tools/extensions/org.civicrm.angularex/angularex.php index 642aeb29a7..5becbf12d2 100644 --- a/tools/extensions/org.civicrm.angularex/angularex.php +++ b/tools/extensions/org.civicrm.angularex/angularex.php @@ -108,5 +108,5 @@ function angularex_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) { } function angularex_civicrm_angularModules(&$angularModule) { - $angularModule['example'] = array('ext' => 'org.civicrm.angularex', 'file' => 'js/example.js'); + $angularModule['example'] = array('ext' => 'org.civicrm.angularex', 'js' => array('js/example.js')); } \ No newline at end of file -- 2.25.1