diff --git a/plugins/facetapi/widget_links.inc b/plugins/facetapi/widget_links.inc index d3c4abd..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 @@ -137,7 +150,6 @@ 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; @@ -151,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) { @@ -212,19 +211,6 @@ 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. @@ -244,7 +230,6 @@ class FacetapiWidgetLinks extends FacetapiWidget { 'soft_limit' => 20, 'nofollow' => 1, 'show_expanded' => 0, - 'show_active_label' => 0, ); } } @@ -276,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, + ); + } }