diff --git a/js/dropdown-widget.js b/js/dropdown-widget.js
index 9f75dee..8b4e71b 100644
--- a/js/dropdown-widget.js
+++ b/js/dropdown-widget.js
@@ -7,7 +7,6 @@
'use strict';
-
Drupal.facets = {};
Drupal.behaviors.facetsDropdownWidget = {
attach: function (context, settings) {
@@ -16,7 +15,7 @@
};
/**
- * Turns all facet links into options.
+ * Turns all facet links into a dropdown with options for every link.
*/
Drupal.facets.makeDropdown = function () {
// Find all dropdown facet links and turn them into an option.
@@ -27,7 +26,7 @@
// Add empty text option first.
var default_option_label = $(this).data('facet-default-option-label');
var $default_option = $('')
- .attr("value", '')
+ .attr('value', '')
.text(default_option_label);
var has_active = false;
@@ -35,14 +34,14 @@
var $link = $(this);
var active = $link.hasClass('is-active');
var $option = $('')
- .attr("value", $link.attr('href'));
- if(active){
+ .attr('value', $link.attr('href'));
+ if (active) {
has_active = true;
// Set empty text value to this link to unselect facet.
- $default_option.attr("value", $link.attr('href'));
+ $default_option.attr('value', $link.attr('href'));
$option.attr('selected', 'selected');
- $link.find('.facet-deactivate').remove()
+ $link.find('.facet-deactivate').remove();
}
$option.html($link.html());
$dropdown.append($option);
@@ -54,7 +53,7 @@
});
// Append empty text option.
- if(!has_active){
+ if (!has_active) {
$default_option.attr('selected', 'selected');
}
$dropdown.prepend($default_option);
diff --git a/src/Plugin/facets/widget/DropdownWidget.php b/src/Plugin/facets/widget/DropdownWidget.php
index d50e512..3062225 100644
--- a/src/Plugin/facets/widget/DropdownWidget.php
+++ b/src/Plugin/facets/widget/DropdownWidget.php
@@ -4,7 +4,6 @@ namespace Drupal\facets\Plugin\facets\widget;
use Drupal\Core\Form\FormStateInterface;
use Drupal\facets\FacetInterface;
-use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* The dropdown widget.
@@ -15,8 +14,7 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
* description = @Translation("A configurable widget that shows a dropdown."),
* )
*/
-
-class DropdownWidget extends LinksWidget{
+class DropdownWidget extends LinksWidget {
/**
* The facet the widget is being built for.
diff --git a/src/Tests/WidgetIntegrationTest.php b/src/Tests/WidgetIntegrationTest.php
index ed8dad2..b7a8fa7 100644
--- a/src/Tests/WidgetIntegrationTest.php
+++ b/src/Tests/WidgetIntegrationTest.php
@@ -2,8 +2,6 @@
namespace Drupal\facets\Tests;
-use Drupal\Core\Url;
-
/**
* Tests the overall functionality of the Facets admin UI.
*
diff --git a/tests/src/Unit/Plugin/widget/DropdownWidgetTest.php b/tests/src/Unit/Plugin/widget/DropdownWidgetTest.php
index b70f6c4..4eef01f 100644
--- a/tests/src/Unit/Plugin/widget/DropdownWidgetTest.php
+++ b/tests/src/Unit/Plugin/widget/DropdownWidgetTest.php
@@ -8,7 +8,6 @@ use Drupal\facets\Entity\Facet;
use Drupal\facets\Plugin\facets\widget\DropdownWidget;
use Drupal\facets\Result\Result;
use Drupal\Tests\UnitTestCase;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Unit test for widget.
@@ -109,5 +108,4 @@ class DropdownWidgetTest extends UnitTestCase {
return $text;
}
-
}