From 6755f62a7ec426cb201ecd0e7f78e274eeadd084 Mon Sep 17 00:00:00 2001
From: M Parker <mparker17@536298.no-reply.drupal.org>
Date: Thu, 10 Jul 2014 09:15:49 -0400
Subject: [PATCH] 1526020-32

---
 facetapi.js                       |  2 +-
 plugins/facetapi/widget_links.inc | 67 +++++++++++++++++++++++++++++++--------
 2 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/facetapi.js b/facetapi.js
index 85d941e..44cd4d4 100644
--- a/facetapi.js
+++ b/facetapi.js
@@ -130,7 +130,7 @@ Drupal.facetapi.makeCheckbox = function() {
     redirect.gotoHref();
   });
 
-  if (active) {
+  if (active && !Drupal.settings.facetapi.show_active_label) {
     checkbox.attr('checked', true);
     // Add the checkbox and label, hide the link.
     $link.before(label).before(checkbox).hide();
diff --git a/plugins/facetapi/widget_links.inc b/plugins/facetapi/widget_links.inc
index 0ae49b3..929c1ce 100644
--- a/plugins/facetapi/widget_links.inc
+++ b/plugins/facetapi/widget_links.inc
@@ -74,6 +74,19 @@ class FacetapiWidgetLinks extends FacetapiWidget {
   }
 
   /**
+   * Gets the base class array for a facet item.
+   *
+   * Classes that extend FacetapiWidgetLinks will often overide this method to
+   * alter the link displays via CSS without having to touch the render array.
+   *
+   * @return array
+   *   An array of classes.
+   */
+  function getItemClasses() {
+    return array();
+  }
+
+  /**
    * Transforms the render array for use with theme_item_list().
    *
    * The recursion allows this function to act on the various levels of a
@@ -150,19 +163,6 @@ class FacetapiWidgetLinks extends FacetapiWidget {
   }
 
   /**
-   * Gets the base class array for a facet item.
-   *
-   * Classes that extend FacetapiWidgetLinks will often overide this method to
-   * alter the link displays via CSS without having to touch the render array.
-   *
-   * @return array
-   *   An array of classes.
-   */
-  function getItemClasses() {
-    return array();
-  }
-
-  /**
    * Overrides FacetapiWidget::settingsForm().
    */
   function settingsForm(&$form, &$form_state) {
@@ -261,4 +261,45 @@ class FacetapiWidgetCheckboxLinks extends FacetapiWidgetLinks {
   public function getItemClasses() {
     return array('facetapi-checkbox');
   }
+
+  /**
+   * {@inheritdoc}
+   */
+  function buildListItems($build) {
+    // Pass some of this facet's settings to the front-end.
+    drupal_add_js(array('facetapi' => array(
+      'show_active_label' => $this->settings->settings['show_active_label'],
+    )), 'setting');
+
+    return parent::buildListItems($build);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  function settingsForm(&$form, &$form_state) {
+    parent::settingsForm($form, $form_state);
+
+    // Allow users to choose whether the labels of active checkboxes are hidden.
+    $form['widget']['widget_settings']['links']['facetapi_checkbox_links']['show_active_label'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Show the labels of active checkboxes'),
+      '#default_value' => !empty($this->settings->settings['show_active_label']),
+      '#description' => t('Displays an active item as a checkbox followed by a link.'),
+      '#states' => array(
+        'visible' => array(
+          ':input[name="widget"]' => array('value' => 'facetapi_checkbox_links'),
+        ),
+      ),
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  function getDefaultSettings() {
+    return parent::getDefaultSettings() + array(
+      'show_active_label' => 0,
+    );
+  }
 }
-- 
2.0.0

