See https://www.drupal.org/project/jquery_ui_slider and https://www.drupal.org/project/jquery_ui_touch_punch.
The latter also requires the user to require furf/jquery-ui-touch-punch but composer couldn't find that for me.
The facets_range_widget.libraries.yml file needs to change references to core like so:
jquery_ui_slider/slider
jquery_ui_touch_punch/touch-punch
| Comment | File | Size | Author |
|---|---|---|---|
| #60 | facets-range-nouislider-3153622-58.patch | 7.05 KB | zubair-rana |
| #55 | facets-range-nouislider-3153622-55.patch | 7.7 KB | damiengr |
| #49 | issue-315622-nouislider_49.patch | 5.71 KB | webdrips |
| #45 | issue-315622-nouislider_25.patch | 5.7 KB | aminmetro |
| #44 | issue-3153622-nouislider.patch | 6.86 KB | alexp999 |
Issue fork facets-3153622
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mstrelan commentedAlternatively it may be better to look at alternatives like https://refreshless.com/nouislider/
Comment #3
netsliverAttached path resolved this issue
Comment #4
mstrelan commentedI would say these need to be added as dependencies in composer.json but that doesn't really work when this module is packaged as a submodule of facets. Perhaps it should be a separate project.
Ultimately I think the jquery plugin should be replaced with something more modern, but this patch would do the job in the interim.
Comment #6
borisson_I agree 100% with everything you said here. It should be seperate and more modern. The tests seem to fail now though, any clue why that is?
Comment #7
mstrelan commentedTest fails due to missing dependant module. Guess composer.json needs to be updated to make the tests pass. Creating this seperate module will solve it. Maybe 1.x feature parity, 2.x replace jQuery UI.
Comment #8
edysmpSo could we say this submodule isn't supported in Drupal 9? or is there a new project for it?
I think applying #3could work for now.
Comment #9
james.williamsFor what it's worth, I'm using https://github.com/IonDen/ion.rangeSlider for a replacement of jQuery UI's slider. If I get time, I'll try contributing back, but I suspect replacing the widget in use isn't going to go smoothly for anyone already using the jQuery UI slider - e.g. if they have added their own theming or JS etc on top of it. If we were to replace the widget for something more modern like this, would that mean we need to start a new major version of the module perhaps to signify the backwards-compatibility break?
Comment #10
nick hope commentedPatch #3 does not apply to 8.x-1.8.
Patch #8 on the other issue does apply but does not resolve the issue. Range slider does not appear.
One of these 2 issues should probably be closed as a duplicate.
Just in case, I also tried adding
"drupal/jquery_ui_slider": "^1.1"and"npm-asset/jquery-ui-slider": "^1.12.1"to composer.json in my home directory. They did install, but didn't help.Comment #11
seth.e.shaw commentedI was still having issues on my site even after using the dependencies patch, so I attempted to make a patch using nouislider.
Granted, I don't know JavaScript well and it took a lot of Google's help combined with liberal console logging and banging my head against my desk, so I'm sure there is room for improvement, but here it is for review.
Comment #12
nick hope commented@seth.e.shaw Good idea!
Which version of noUiSlider did you test it with, and how to install it? I see references to nouislider.min.js and nouislider.min.css in facets_range_widget.libraries.yml but I can't find those files in either the repository at https://refreshless.com/nouislider/ or at https://packagist.org/packages/leongersen/nouislider, which confused me. I did however find them from some obscure sources by Googling, and put them in /libraries/nouislider/distribute/
When I use the slider I just see a plain bar. I don't see any pips or text related to the min/max values. I can click on it, which gives me the green stripe, then my page refreshes and the bar is empty again.
Comment #13
seth.e.shaw commented@nick-hope, I used composer to get npm-asset/nouislider. Which reminded me, I should have updated the README, so here is another patch and interdiff.
Let me know if the npm-asset version fixes the issue. Otherwise, perhaps it is a difference in browser or Drupal theme? I was using Chrome and Bartik.
Comment #14
nick hope commentedcomposer require npm-asset/nouisliderwould only offer me version 14.6.3 at the highest, even though higher versions are seen at https://www.npmjs.com/package/nouislider. I tried a few times. So I installed 14.6.3 and now the pips are visible and slider is basically working.I still can't work out where the actual 15.1.1 nouislider.min.js and nouislider.min.css files are on https://www.npmjs.com/package/nouislider or https://github.com/leongersen/noUiSlider so I can't manually overwrite with that later version.
I have a lot of problems with actually using it on my development site, but some of that is probably due to the complexity of my facet logic. Feels like Ajax-related issues too. Some issues I had:
1. After making it a dependent facet, when I select the parent facet (that it depends on), the slider does not appear unless I refresh the page.
2. After adjusting the slider, the parent facet becomes deselected.
3. Sometimes when I release the mouse after sliding the pips, both pips illogically jump to a value such as 1 or 4.
4. I kept getting in a situation where the "reset facets" link from the facets summary was not visible, despite the URL showing that the slider facet had set values, and the only way I could reset this slider was by manually deleting the arguments in the URL.
Comment #15
seth.e.shaw commented@nick-hope,
Apologies, I did test with 14.6.3. I checked the wrong spot when I reported to you my version above.
I can't speak to the dependent or AJAX implications... I had focused on those facet settings items used the the original JS constructor. I might be able to take a look at what is happening there but, again, my JS skills are limited.
Comment #16
seth.e.shaw commentedWhich means I updated the README incorrectly... 🤦♂️
Comment #17
seth.e.shaw commentedAnother patch. This one adds the facet object to the window variable so that sites can add their own callbacks to the slider.
Comment #18
damienmckennaComment #19
webdrips commentedHi thanks for working on this. I ran into a few issues with #17:
This error appeared once in the console:
And this error repeated many times:
I have one faceted slider, and can share the site if needed in a DM.
Comment #20
james.williamsUnfortunately the SSL connection for asset-packagist uses a certificate which recently expired. There are fixes/workarounds that can be applied in the meantime (see https://github.com/hiqdev/asset-packagist/issues/140#issuecomment-932445671), though sadly this doesn't inspire confidence in the service, which has been great until now!
Comment #21
webdrips commentedAnother note about this is the new slider doesn't seem to play well with the other facets.
For example, if you add checkboxes for a taxonomy, check one of the checkboxes, the range slider goes wonky, with only the start year showing.
Comment #23
damiengr commentedIn order to fix the js errors replace
by
Comment #24
retrodans commentedI also had the js issue, so have reworked the patch from #17 to incorporate the suggestion in #23 which appears to work for me nicely now.
Comment #25
retrodans commentedSorry, previous commit was missing the readme work, have added this now to this patch
Comment #26
mkalkbrennerLet's get it tested.
Comment #27
aaronpinero commentedthe patch in #25 does not work for me. I am getting the following javascript error:
Uncaught ReferenceError: noUiSlider is not defined
addSlider https://-------/modules/composer/facets/modules/facets_range_widget/js/slider.js?v=9.2.8:26
attach https://-------/modules/composer/facets/modules/facets_range_widget/js/slider.js?v=9.2.8:18
etc.
I used composer to install the nouislider library; it installed v15.5.0. I am using Drupal v9.2.8 and the latest version of the Facets module (1.8.0).
Comment #28
orom commentedI tested #25 against 2.0.x and it seems to work fine for my use case.
However I also needed AJAX along with the range slider. Here is a patch that allows the change handler function to be updated as seen in Issue #3052574.
The most recent patch/MR (#124) in that issue updates the change handler function to work with views AJAX. This patch allows that change to be propagated to nouislider; but it the AJAX patch is not required.
Comment #29
orom commentedI update the patch from #28 to more appropriately configure nouislider so that it uses a true range setup with step. This should now allow it to work in conjunction with https://www.drupal.org/project/facets/issues/2898801#comment-13814446 which gives a single min/max value to improve performance.
Comment #32
hswong3i commentedRework #29 as https://git.drupalcode.org/project/facets/-/merge_requests/43
Comment #33
mkalkbrennerThe patch itself look good to me. But don't we need a kind of upgrade path? At least some documentation about the change in the README.
But to ease the process, I think we should add the dependency to facets' composer.json, even if people might not use the sub-module. That would eliminate the complexity about fetching assets. And it provides the upgrade path ;-)
What do you think?
Comment #34
alexp999 commented#29 and the merge request need more work.
I successfully applied the patch in #29, however the check in facets_range_widget.module needs to be updated to recognise nouislider otherwise it still throws an error that "The jquery ui slider pips library is not installed".
Also, with reference #33, I don't think you can just add nouislider as a dependency as it is an npm-asset and needs additional composer.json configuration as referenced in the readme. I assume that's why there wasn't a dependency originally.
Comment #35
mstrelan commentedI still think it makes sense to move this to a separate module/project.
Comment #36
nick hope commented#29 applied for me to 2.0.0 but will no longer apply to 2.0.1.
Comment #37
thenchev commentedRerolled patch #29
Please test, just did a quick fix
Comment #38
webdrips commented#37 works, but just make sure you have the latest version of nouislider.
Comment #39
alexp999 commented#37 still doesn't fix the check in facets_range_widget.module to recognise nouislider instead of slider pips, it still throws an error that "The jquery ui slider pips library is not installed".
People that are testing this must have both libraries installed?
I'll try and put an environment together so I can upload a patch.
Comment #40
marksmith commentedI can confirm that #37 basically works. Thou I had to uninstall and reinstall the module after applying the patch.
Comment #41
alexp999 commentedPatch based on #37 with the addition of changing the library check to nouislider, else it will give a warning as it currently checks for the old library.
Comment #42
alexp999 commentedUpdated the wording of the warning message, to say that it is noUiSlider which is missing
Comment #43
marksmith commentedPlease replace
$requirements['facets_range_widget_pips_slider'] = [with
$requirements['facets_range_widget_nouislider'] = [in facets_range_widget.install
Comment #44
alexp999 commented@marksmith
Comment #45
aminmetro commentedJust a reroll of patch from #25 for 2/28/2022 commit 8a9574df.
Comment #46
anybodyComment #47
mkalkbrennerIf #3186953: JS errors for slider facet solves the issue as well, I prefer to commit that one because its dependencies are easy to manage automatically.
The nouislider based alternative should be implemented as a new module instead.
Comment #48
mkalkbrennerComment #49
webdrips commentedReroll #45 against 2.0.2
Comment #50
anybodyComment #51
mkalkbrennerAs mentioned in #47, nouislider has to be provided as an alternative, not as replacement.
Comment #52
webdrips commentedSeems that nouislider is not accessible out of box. Not sure how difficult it is to make it compliant.
It would be nice if we had an alternate slider that was in fact accessible out of box.
Comment #53
trackleft2Possibly make https://www.drupal.org/project/nouislider a dependency, or an optional dependency.
Comment #54
damiengr commentedI don't understrand why #45 was a reroll of #25 instead of #44 ?
#44 was working but #45 (and subsequent patches) are not
#45 does not keep min, max and step settings
Comment #55
damiengr commentedSo here is a reroll of #44 against 2.0.5
Comment #56
alexp999 commentedThe facets range widget works on Drupal 9.4 with jQuery UI Slider & Touch punch since commit 768ed43.
I have already switched my dev site to this, however if we are pursuing nouislider, then as this issue has been updated to, it needs to be an option or sub module.
The patches should no longer replace the libraries that are now working.
Is it necessary to offer an alternative now that jQueryUI is being maintained again?
Comment #57
vasiliyrepin commentedSee this module implementation with many settings of NoUiSlider and input/inputs fields and keyboard interaction!
https://www.drupal.org/project/facets_range_nouislider
Comment #58
zubair-rana commentedHere is a reroll of #55 against 2.0.9
Comment #59
zubair-rana commentedComment #60
zubair-rana commented