Last active
December 15, 2020 00:21
-
-
Save paulsheldrake/0235db71aa4269228f0be16548470bc6 to your computer and use it in GitHub Desktop.
disable the jquery slider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sites/all/modules/contrib/facetapi_slider/plugins/facetapi/widget_slider.inc b/sites/all/modules/contrib/facetapi_slider/plugins/facetapi/widget_slider.inc | |
index 47d176f4a..1e9d2d9ea 100644 | |
--- a/sites/all/modules/contrib/facetapi_slider/plugins/facetapi/widget_slider.inc | |
+++ b/sites/all/modules/contrib/facetapi_slider/plugins/facetapi/widget_slider.inc | |
@@ -61,6 +61,9 @@ class FacetapiWidgetSlider extends FacetapiWidget { | |
$slider['#range_max'] = isset($slider['#range_max']) ? $slider['#range_max'] : $slider['#global_range_max']; | |
} | |
// Kanopi patch end | |
+ $this->build[$this->facet['field alias']][$this->facet['field']] = $slider; | |
+ | |
+ | |
$slider_min = $slider['#range_min']; | |
$slider_max = $slider['#range_max']; | |
@@ -114,23 +117,36 @@ class FacetapiWidgetSlider extends FacetapiWidget { | |
if (isset($build['#facet']) && isset($build[$build['#facet']['field alias']]) && isset($build[$build['#facet']['field alias']][$build['#facet']['field']])) { | |
$slider = $build[$build['#facet']['field alias']][$build['#facet']['field']]; | |
} | |
+ | |
+ $global_range = variable_get('mises_date_slider_global_range'); | |
+ | |
+ // Hack to get set values. | |
+ $range = []; | |
+ if (isset($slider["#markup"])) { | |
+ $range['min'] = substr($slider["#markup"], 0, 4);; | |
+ $range['max'] = substr($slider["#markup"], -4);; | |
+ } | |
+ | |
+ | |
$form['slider']['min'] = array( | |
'#type' => 'textfield', | |
- '#title' => t('Min'), | |
+ '#title' => t('From'), | |
'#size' => 5, | |
- '#default_value' => isset($slider['#range_min']) ? $slider['#range_min'] : 0, | |
+ '#default_value' => isset($range['min']) ? $range['min'] : $global_range['min'], | |
'#attributes' => array( | |
'class' => array('facetapi-slider-min'), | |
+ 'placeholder' => $global_range['min'], | |
), | |
); | |
$form['slider']['max'] = array( | |
'#type' => 'textfield', | |
- '#title' => t('Max'), | |
+ '#title' => t('To'), | |
'#size' => 5, | |
- '#default_value' => isset($slider['#range_max']) ? $slider['#range_max'] : 0, | |
+ '#default_value' => isset($range['max']) ? $range['max'] : $global_range['max'], | |
'#attributes' => array( | |
'class' => array('facetapi-slider-max'), | |
+ 'placeholder' => $global_range['max'], | |
), | |
); | |
$form['slider']['submit'] = array( | |
@@ -160,15 +176,32 @@ class FacetapiWidgetSlider extends FacetapiWidget { | |
// Only add JS if we are on the actual search page. | |
if (isset($build['#attributes'])) { | |
$form['#attributes'] = $build['#attributes']; | |
- $form['slider']['#attached']['library'][] = array('system', 'ui.slider'); | |
- $form['slider']['#attached']['js'][] = drupal_get_path('module', 'facetapi_slider') . '/facetapi_slider.js'; | |
+// $form['slider']['#attached']['library'][] = array('system', 'ui.slider'); | |
+// $form['slider']['#attached']['js'][] = drupal_get_path('module', 'facetapi_slider') . '/facetapi_slider.js'; | |
} | |
$form['#action'] = url('facetapi/widget/submit/' . $form_id . '/' . $adapter->getSearcher()); | |
return $form; | |
} | |
public static function widgetFormValidate($form, &$form_state) { | |
- //Nothing to do... | |
+ // Validate the basics. | |
+ $min = $form_state["values"]["min"]; | |
+ $max = $form_state["values"]["max"]; | |
+ $global_range = variable_get('mises_date_slider_global_range'); | |
+ | |
+ if (!filter_var($min, FILTER_VALIDATE_INT)) { | |
+ form_set_error('min', t('Please use a proper number for the year')); | |
+ } | |
+ elseif ($min < $global_range['min']) { | |
+ form_set_error('min', t('Enter a year greater than the minimum')); | |
+ } | |
+ | |
+ if (!filter_var($max, FILTER_VALIDATE_INT)) { | |
+ form_set_error('max', t('Please use a proper number for the year')); | |
+ } | |
+ elseif ($max > $global_range['max']) { | |
+ form_set_error('max', t('Enter a year less than the maximum')); | |
+ } | |
} | |
public static function widgetFormSubmit($form, &$form_state) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment