jquery.makeCollapsible: Clean up issues caused by wrong nesting
The way it was done - switching first on action (expand/collapse), then on
elements - caused the logic to be split all over the file.
This caused:
* code duplication (e.g. computing the elements to be acted upon in
the same way for expanding and collapsing, repeated same comments)
* regressions when the logic was changed for one but not for the other
(this was the case e.g. with table expanding/collapsing).
As for the second, I fixed all spotted inconsistencies; as for the
first, I'll let the diffstat speak for itself.
Change-Id: I2d2592b4d00424f0c23c493f6de6c824d0714dfc