/** * List of core resources we add to every CiviCRM page. * * Note: non-compressed versions of .min files will be used in debug mode * * @param string $region * @return array */ public function coreResourceList($region) { $config = CRM_Core_Config::singleton(); // Scripts needed by everyone, everywhere // FIXME: This is too long; list needs finer-grained segmentation $items = array("bower_components/jquery/dist/jquery.min.js", "bower_components/jquery-ui/jquery-ui.min.js", "bower_components/jquery-ui/themes/smoothness/jquery-ui.min.css", "bower_components/lodash-compat/lodash.min.js", "packages/jquery/plugins/jquery.mousewheel.min.js", "bower_components/select2/select2.min.js", "bower_components/select2/select2.min.css", "packages/jquery/plugins/jquery.tableHeader.js", "packages/jquery/plugins/jquery.form.min.js", "packages/jquery/plugins/jquery.timeentry.min.js", "packages/jquery/plugins/jquery.blockUI.min.js", "bower_components/datatables/media/js/jquery.dataTables.min.js", "bower_components/datatables/media/css/jquery.dataTables.min.css", "bower_components/jquery-validation/dist/jquery.validate.min.js", "packages/jquery/plugins/jquery.ui.datepicker.validation.min.js", "js/Common.js", "js/crm.ajax.js"); // add wysiwyg editor $editor = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'editor_id'); $items[] = "js/wysiwyg/crm.wysiwyg.js"; if ($editor == "CKEditor") { $items[] = "bower_components/ckeditor/ckeditor.js"; $items[] = "js/wysiwyg/crm.ckeditor.js"; $ckConfig = CRM_Admin_Page_CKEditorConfig::getConfigUrl(); if ($ckConfig) { $items[] = array('config' => array('CKEditorCustomConfig' => $ckConfig)); } } // These scripts are only needed by back-office users if (CRM_Core_Permission::check('access CiviCRM')) { $items[] = "packages/jquery/plugins/jquery.menu.min.js"; $items[] = "css/navigation.css"; $items[] = "packages/jquery/plugins/jquery.jeditable.min.js"; $items[] = "packages/jquery/plugins/jquery.notify.min.js"; $items[] = "js/jquery/jquery.crmeditable.js"; } // JS for multilingual installations if (!empty($config->languageLimit) && count($config->languageLimit) > 1 && CRM_Core_Permission::check('translate CiviCRM')) { $items[] = "js/crm.multilingual.js"; } // Enable administrators to edit option lists in a dialog if (CRM_Core_Permission::check('administer CiviCRM') && $this->ajaxPopupsEnabled) { $items[] = "js/crm.optionEdit.js"; } // Add localized jQuery UI files if ($config->lcMessages && $config->lcMessages != 'en_US') { // Search for i18n file in order of specificity (try fr-CA, then fr) list($lang) = explode('_', $config->lcMessages); $path = "bower_components/jquery-ui/ui/i18n"; foreach (array(str_replace('_', '-', $config->lcMessages), $lang) as $language) { $localizationFile = "{$path}/datepicker-{$language}.js"; if ($this->getPath('civicrm', $localizationFile)) { $items[] = $localizationFile; break; } } } // Allow hooks to modify this list CRM_Utils_Hook::coreResourceList($items, $region); return $items; }
/** * List of core resources we add to every CiviCRM page. * * @param string $region * @return array */ public function coreResourceList($region) { $config = CRM_Core_Config::singleton(); // Use minified files for production, uncompressed in debug mode // Note, $this->addScriptFile would automatically search for the non-minified file in debug mode but this is probably faster $min = $config->debug ? '' : '.min'; // Scripts needed by everyone, everywhere // FIXME: This is too long; list needs finer-grained segmentation $items = array("bower_components/jquery/dist/jquery.min.js", "bower_components/jquery-ui/jquery-ui.min.js", "bower_components/jquery-ui/themes/smoothness/jquery-ui{$min}.css", "bower_components/lodash-compat/lodash.min.js", "packages/jquery/plugins/jquery.mousewheel{$min}.js", "bower_components/select2/select2{$min}.js", "bower_components/select2/select2{$min}.css", "packages/jquery/plugins/jquery.tableHeader.js", "packages/jquery/plugins/jquery.textarearesizer.js", "packages/jquery/plugins/jquery.form{$min}.js", "packages/jquery/plugins/jquery.timeentry{$min}.js", "packages/jquery/plugins/jquery.blockUI{$min}.js", "packages/jquery/plugins/DataTables/media/js/jquery.dataTables{$min}.js", "packages/jquery/plugins/DataTables/media/css/jquery.dataTables{$min}.css", "bower_components/jquery-validation/dist/jquery.validate{$min}.js", "packages/jquery/plugins/jquery.ui.datepicker.validation.pack.js", "js/Common.js", "js/crm.ajax.js"); // These scripts are only needed by back-office users if (CRM_Core_Permission::check('access CiviCRM')) { $items[] = "packages/jquery/plugins/jquery.menu{$min}.js"; $items[] = "css/navigation.css"; $items[] = "packages/jquery/plugins/jquery.jeditable{$min}.js"; $items[] = "packages/jquery/plugins/jquery.notify{$min}.js"; $items[] = "js/jquery/jquery.crmeditable.js"; } // JS for multilingual installations if (!empty($config->languageLimit) && count($config->languageLimit) > 1 && CRM_Core_Permission::check('translate CiviCRM')) { $items[] = "js/crm.multilingual.js"; } // Enable administrators to edit option lists in a dialog if (CRM_Core_Permission::check('administer CiviCRM') && $this->ajaxPopupsEnabled) { $items[] = "js/crm.optionEdit.js"; } // Add localized jQuery UI files if ($config->lcMessages && $config->lcMessages != 'en_US') { // Search for i18n file in order of specificity (try fr-CA, then fr) list($lang) = explode('_', $config->lcMessages); $path = "bower_components/jquery-ui/ui/i18n"; foreach (array(str_replace('_', '-', $config->lcMessages), $lang) as $language) { $localizationFile = "{$path}/datepicker-{$language}.js"; if ($this->getPath('civicrm', $localizationFile)) { $items[] = $localizationFile; break; } } } // Allow hooks to modify this list CRM_Utils_Hook::coreResourceList($items, $region); return $items; }