Skip to content
Snippets Groups Projects
Commit 7357a430 authored by Ted Cooper's avatar Ted Cooper
Browse files

Fix indenting. Minor CS.

parent 9a9e6a99
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* Facets views AJAX handling. * Facets views AJAX handling.
*/ */
(function ($, Drupal, once) { (function ($, Drupal, once) {
'use strict'; 'use strict';
...@@ -39,7 +38,7 @@ ...@@ -39,7 +38,7 @@
return; return;
} }
// Update view on range slider stop event // Update view on range slider stop event.
if (typeof settings.facets !== "undefined" && settings.facets.sliders && settings.facets.sliders[facetId]) { if (typeof settings.facets !== "undefined" && settings.facets.sliders && settings.facets.sliders[facetId]) {
settings.facets.sliders[facetId].stop = function (e, ui) { settings.facets.sliders[facetId].stop = function (e, ui) {
const sliderSettings = settings.facets.sliders[facetId]; const sliderSettings = settings.facets.sliders[facetId];
...@@ -73,7 +72,7 @@ ...@@ -73,7 +72,7 @@
for (let paramName in newQueryParams) { for (let paramName in newQueryParams) {
if (paramName.substr(0, 1) === 'f') { if (paramName.substr(0, 1) === 'f') {
value = newQueryParams[paramName]; value = newQueryParams[paramName];
// replace // Replace.
facetKey = value.substr(0, value.indexOf(':')); facetKey = value.substr(0, value.indexOf(':'));
if (typeof facetPositions[facetKey] !== 'undefined') { if (typeof facetPositions[facetKey] !== 'undefined') {
paramKey = 'f[' + facetPositions[facetKey] + ']'; paramKey = 'f[' + facetPositions[facetKey] + ']';
......
...@@ -155,7 +155,7 @@ class FacetBlockAjaxController extends ControllerBase { ...@@ -155,7 +155,7 @@ class FacetBlockAjaxController extends ControllerBase {
$container = \Drupal::getContainer(); $container = \Drupal::getContainer();
$container->set('request_stack', $request_stack); $container->set('request_stack', $request_stack);
foreach ($facets_blocks as $block_selector => $block_id) { foreach ($facets_blocks as $block_selector => $block_id) {
// Facet block render array. // Facet block render array.
$block_view = NULL; $block_view = NULL;
// Re prepare from css standarts. // Re prepare from css standarts.
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
namespace Drupal\facets\Plugin\Block; namespace Drupal\facets\Plugin\Block;
use Drupal\Component\Utility\Html;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockBase; use Drupal\Core\Block\BlockBase;
use Drupal\Component\Utility\Html;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\facets\FacetInterface; use Drupal\facets\FacetInterface;
use Drupal\facets\FacetManager\DefaultFacetManager; use Drupal\facets\FacetManager\DefaultFacetManager;
...@@ -40,6 +40,8 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface { ...@@ -40,6 +40,8 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
protected $facetStorage; protected $facetStorage;
/** /**
* The facet entity.
*
* @var \Drupal\facets\FacetInterface * @var \Drupal\facets\FacetInterface
*/ */
protected $facet; protected $facet;
...@@ -93,56 +95,57 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface { ...@@ -93,56 +95,57 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
// Let the facet_manager build the facets. // Let the facet_manager build the facets.
$facet_build = $this->facetManager->build($facet); $facet_build = $this->facetManager->build($facet);
if ($facet_build) { if ($facet_build) {
CacheableMetadata::createFromObject($this)->applyTo($build); CacheableMetadata::createFromObject($this)->applyTo($build);
// Add extra elements from facet source, for example, ajax scripts. // Add extra elements from facet source, for example, ajax scripts.
// @see Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay // @see Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay
/** @var \Drupal\facets\FacetSource\FacetSourcePluginInterface $facet_source */ /** @var \Drupal\facets\FacetSource\FacetSourcePluginInterface $facet_source */
$facet_source = $facet->getFacetSource(); $facet_source = $facet->getFacetSource();
$facet_build += $facet_source->buildFacet(); $facet_build += $facet_source->buildFacet();
$build = [ $build = [
'#type' => 'container', '#type' => 'container',
'#contextual_links' => [ '#contextual_links' => [
'facets_facet' => [ 'facets_facet' => [
'route_parameters' => ['facets_facet' => $facet->id()], 'route_parameters' => ['facets_facet' => $facet->id()],
], ],
], ],
'#attributes' => [ '#attributes' => [
'class' => ['block-facet__wrapper'], 'class' => ['block-facet__wrapper'],
], ],
$facet_build, 0 => $facet_build,
]; ];
// Add css classes. // Add css classes.
if (!empty($facet_build[0]['#attributes']['class'])) { if (!empty($facet_build[0]['#attributes']['class'])) {
$css_classes = $facet_build[0]['#attributes']['class']; $css_classes = $facet_build[0]['#attributes']['class'];
// Active/inactive css classes. // Active/inactive css classes.
if (in_array('facet-active', $css_classes)) { if (in_array('facet-active', $css_classes)) {
$build['#attributes']['class'][] = 'facet-active'; $build['#attributes']['class'][] = 'facet-active';
} else {
$build['#attributes']['class'][] = 'facet-inactive';
}
// Whether it is necessary to add hide css class.
if (in_array('facet-hidden', $css_classes)) {
$build['#attributes']['class'][] = 'hidden';
}
} }
else {
// Add classes needed for ajax. $build['#attributes']['class'][] = 'facet-inactive';
if (!empty($facet_build['#use_ajax'])) {
$build['#attributes']['class'][] = 'block-facets-ajax';
$block_id = str_replace(':', '--', $this->pluginId);
$block_id = Html::cleanCssIdentifier($block_id);
$build['#attributes']['class'][] = 'js-facet-block-id-' . $block_id;
$build['#attributes']['id'] = Html::getUniqueId($block_id);
} }
// Whether it is necessary to add hide css class.
// To render correctly in different situations. if (in_array('facet-hidden', $css_classes)) {
$build = [ $build['#attributes']['class'][] = 'hidden';
'facet_block' => $build, }
]; }
// Add classes needed for ajax.
if (!empty($facet_build['#use_ajax'])) {
$build['#attributes']['class'][] = 'block-facets-ajax';
$block_id = str_replace(':', '--', $this->pluginId);
$block_id = Html::cleanCssIdentifier($block_id);
$build['#attributes']['class'][] = 'js-facet-block-id-' . $block_id;
$build['#attributes']['id'] = Html::getUniqueId($block_id);
}
// To render correctly in different situations.
$build = [
'facet_block' => $build,
];
} }
return $build; return $build;
} }
......
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