From 050e31640b6424d8a58fe002ae73fb44e7e754ee Mon Sep 17 00:00:00 2001
From: M Parker <mparker17@536298.no-reply.drupal.org>
Date: Tue, 24 Jun 2014 17:32:38 -0400
Subject: [PATCH] 1526020-25

---
 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 e2c5b69..2353141 100644
--- a/facetapi.js
+++ b/facetapi.js
@@ -99,7 +99,7 @@ Drupal.facetapi.makeCheckbox = function() {
     var href = $link.attr('href');
     redirect = new Drupal.facetapi.Redirect(href);
     checkbox.click($.proxy(redirect, 'gotoHref'));
-    if (active) {
+    if (active && !Drupal.settings.facetapi.active_link) {
       // 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 81075b2..3bea0da 100644
--- a/plugins/facetapi/widget_links.inc
+++ b/plugins/facetapi/widget_links.inc
@@ -133,6 +133,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;
@@ -207,6 +208,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.
@@ -226,6 +240,7 @@ class FacetapiWidgetLinks extends FacetapiWidget {
       'soft_limit' => 20,
       'nofollow' => 1,
       'show_expanded' => 0,
+      'active_link' => 1,
     );
   }
 }
-- 
2.0.0

