Skip to content

Commit

Permalink
Merge pull request #18354 from totten/master-bs3b
Browse files Browse the repository at this point in the history
dev/user-interface#27 - Define a "bootstrap3" bundle (skeleton)
  • Loading branch information
eileenmcnaughton authored Sep 5, 2020
2 parents 0480742 + d853ede commit 587db57
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
1 change: 1 addition & 0 deletions CRM/Api4/Page/Api4Explorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function run() {
'groupOptions' => array_column((array) $groupOptions, 'options', 'name'),
];
Civi::resources()
->addBundle('bootstrap3')
->addVars('api4', $vars)
->addPermissions(['access debug output', 'edit groups', 'administer reserved groups'])
->addScriptFile('civicrm', 'js/load-bootstrap.js')
Expand Down
35 changes: 35 additions & 0 deletions CRM/Core/Resources/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,41 @@ class CRM_Core_Resources_Common {

const REGION = 'html-header';

/**
* The 'bundle.bootstrap3' service is a collection of resources which are
* loaded when a page needs to support Boostrap CSS v3.
*
* @param string $name
* i.e. 'bootstrap3'
* @return \CRM_Core_Resources_Bundle
*/
public static function createBootstrap3Bundle($name) {
$bundle = new CRM_Core_Resources_Bundle($name, ['script', 'scriptFile', 'scriptUrl', 'settings', 'style', 'styleFile', 'styleUrl', 'markup']);
// Leave it to the theme/provider to register specific resources.
// $bundle->addStyleFile('civicrm', 'css/bootstrap3.css');
// $bundle->addScriptFile('civicrm', 'js/bootstrap3.js', [
// 'translate' => FALSE,
//]);

// This warning will show if bootstrap is unavailable. Normally it will be hidden by the bootstrap .collapse class.
$bundle->addMarkup('
<div id="bootstrap-theme">
<div class="messages warning no-popup collapse">
<p>
<i class="crm-i fa-exclamation-triangle" aria-hidden="true"></i>
<strong>' . ts('Bootstrap theme not found.') . '</strong>
</p>
<p>' . ts('This screen may not work correctly without a bootstrap-based theme such as Shoreditch installed.') . '</p>
</div>
</div>',
['region' => 'page-header']
);

CRM_Utils_Hook::alterBundle($bundle);
self::useRegion($bundle, self::REGION);
return $bundle;
}

/**
* The 'bundle.coreStyles' service is a collection of resources used on some
* non-Civi pages (wherein Civi may be mixed-in).
Expand Down
3 changes: 3 additions & 0 deletions Civi/Core/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ public function createContainer() {
[]
))->setPublic(TRUE);

$container->setDefinition('bundle.bootstrap3', new Definition('CRM_Core_Resources_Bundle', ['bootstrap3']))
->setFactory('CRM_Core_Resources_Common::createBootstrap3Bundle');

$container->setDefinition('bundle.coreStyles', new Definition('CRM_Core_Resources_Bundle', ['coreStyles']))
->setFactory('CRM_Core_Resources_Common::createStyleBundle');

Expand Down
9 changes: 0 additions & 9 deletions ang/api4Explorer/Explorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ <h1 crm-page-title>
{{:: ts('CiviCRM APIv4') }}{{ entity ? (' (' + entity + '::' + action + ')') : '' }}
</h1>

<!--This warning will show if bootstrap is unavailable. Normally it will be hidden by the bootstrap .collapse class.-->
<div class="messages warning no-popup collapse">
<p>
<i class="crm-i fa-exclamation-triangle" aria-hidden="true"></i>
<strong>{{:: ts('Bootstrap theme not found.') }}</strong>
</p>
<p>{{:: ts('This screen may not work correctly without a bootstrap-based theme such as Shoreditch installed.') }}</p>
</div>

<div class="api4-explorer-row">
<form name="api4-explorer" class="panel panel-default explorer-params-panel">
<div class="panel-heading">
Expand Down

0 comments on commit 587db57

Please sign in to comment.