Make expand/collapse-all button resilient to history changes #285
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #284.
This updates logic for the expand/collapse-all button to update
showtechniques
in the query string and synchronize the button's state with that query parameter. (This matches the existing behavior of expanding all, then collapsing a single technique, which evidently already has this effect.) This resolves the issue of browser back/forward buttons or links to anchors withinmain
immediately losing the expand-all state.Also in this PR, some cleanup:
geturi
which seemed to be completely unused, which further enabled removing everything related tolocalStorage
new URI
boilerplate to a single functionnoAddToHistory
to a local variable at the top level of the jQuery ready functionNote that one particular detail of this implementation causes the expand/collapse-all button to no longer expand/collapse the "Show About & How to Use" button above the main area; I figured this is a net positive, as that would cause the button you just clicked to move, and it's another area that would end up in an inconsistent layout state as a result of the expand/collapse-all button.
Also note that the expand/collapse-all feature is still far from perfect; in particular, it is possible to get the show/hide description buttons out of sync with their state via a mix of direct interactions and interacting with the expand-all button. This is due to naive use of jQuery's
toggle
API; I'd like to think we shouldn't need that at all and should be able to tweakdisplay
based on CSS for the elements in question, but didn't want to open another entire can of worms right now.