(bug 25830) fix JS preview causing the page to "jump"
Originally a patch by DieBuche <diebuche@gmail.com>, fixed to apply on
master (only whitespace changes were needed), with multiple new tweaks and
fixes.
The patch introduces fadeTo(..., 0.4) instead of fadeIn/fadeOut, causing
the preview not to be removed, but only faded out slightly. The reason
for this change is twofold:
* We do not want to completely remove the elements, which is what the old
version did. This causes the edit field to jump up and then back down
when the preview is reinserted.
* We do not want to display a huge blank white space where the preview
used to be before it disappeared.
Instead of scrolling to the top, we scroll straight to the preview. This
works when the preview is set to appear below edit field and possibly with
non-default skins. (And also is much neater.) Thanks to Jdlrobson for
noticing this issue.
We also separately handle first preview and all the following ones to
further reduce jumping. Thanks to MarkTraceur and Kaldari for noticing the
problem and to Kaldari for a patch.
Change-Id: I743ed45e039445242a99a23cad719a75731c5562