From 888c8a53ef7a7dd01a3cdb68a1ba0fbf76d3c333 Mon Sep 17 00:00:00 2001
From: M Parker <mparker17@536298.no-reply.drupal.org>
Date: Thu, 10 Jul 2014 08:12:32 -0400
Subject: [PATCH] 1526020-29

---
 facetapi.admin.js                 | 11 +++++++++++
 facetapi.js                       |  2 +-
 plugins/facetapi/widget_links.inc | 15 +++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/facetapi.admin.js b/facetapi.admin.js
index 5f124c3..a20e6eb 100644
--- a/facetapi.admin.js
+++ b/facetapi.admin.js
@@ -19,6 +19,17 @@ Drupal.behaviors.facetapi = {
       }
     });
 
+    // Ensures ALL nofollow checkboxes are updated.
+    // @see http://drupal.org/node/735528
+    $('input[name="show_active_label"]').change(function() {
+      if ($(this).attr('checked')) {
+        $('input[name="show_active_label"]').attr('checked', 'checked');
+      }
+      else {
+        $('input[name="show_active_label"]').removeAttr('checked');
+      }
+    });
+
     // Ensures ALL show expanded checkboxes are updated.
     // @see http://drupal.org/node/735528
     $('input[name="show_expanded"]').change(function() {
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..9f7b6ae 100644
--- a/plugins/facetapi/widget_links.inc
+++ b/plugins/facetapi/widget_links.inc
@@ -137,6 +137,7 @@ class FacetapiWidgetLinks extends FacetapiWidget {
         }
       }
 
+      drupal_add_js(array('facetapi' => array('show_active_label' => $settings['show_active_label'])), 'setting');
       // Gets theme hook, adds last minute classes.
       $class = ($item['#active']) ? 'facetapi-active' : 'facetapi-inactive';
       $variables['options']['attributes']['class'][] = $class;
@@ -211,6 +212,19 @@ class FacetapiWidgetLinks extends FacetapiWidget {
       );
     }
 
+    // Allow users to choose whether the labels of active checkboxes are hidden.
+    $form['widget']['widget_settings']['links'][$this->id]['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(
+          'select[name="widget"]' => array('value' => $this->id),
+        ),
+      ),
+    );
+
     // Hides all but the last element. The #states system will override this,
     // however it is necessary if JavaScript is disabled so multiple elements
     // aren't displayed to the user.
@@ -230,6 +244,7 @@ class FacetapiWidgetLinks extends FacetapiWidget {
       'soft_limit' => 20,
       'nofollow' => 1,
       'show_expanded' => 0,
+      'show_active_label' => 1,
     );
   }
 }
-- 
2.0.0

