From b83daed6c496d742c9a0332fb4e6cdf4c2f881a1 Mon Sep 17 00:00:00 2001
From: M Parker <mparker17@536298.no-reply.drupal.org>
Date: Tue, 8 Jul 2014 18:44:27 -0400
Subject: [PATCH] 1526020-27

---
 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..0970a21 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="active_link"]').change(function() {
+      if ($(this).attr('checked')) {
+        $('input[name="active_link"]').attr('checked', 'checked');
+      }
+      else {
+        $('input[name="active_link"]').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..c02e8fd 100644
--- a/facetapi.js
+++ b/facetapi.js
@@ -130,7 +130,7 @@ Drupal.facetapi.makeCheckbox = function() {
     redirect.gotoHref();
   });
 
-  if (active) {
+  if (active && !Drupal.settings.facetapi.active_link) {
     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..f91f26a 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('active_link' => $settings['active_link'])), '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 {
       );
     }
 
+    // Active facets is a link.
+    $form['widget']['widget_settings']['links'][$this->id]['active_link'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Active facet is a link'),
+      '#default_value' => !empty($this->settings->settings['active_link']),
+      '#description' => t('The active facet is a link. The javascript will not disable the 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,
+      'active_link' => 1,
     );
   }
 }
-- 
2.0.0

