When `window.location.hash` is pointing to a note, e.g. `#note_1234`,
`scrollToElement` would throw an error because a selector such as
`.commits #note_1234` doesn't exist, so `offset()` returned `undefined`.
This error would prevent subsequent calls from running, which caused the
loading spinner to never be hidden.
Now we ensure the selector returns a valid element before trying to
scroll to it.
Occasionally the loading spinner would stay visible after the tab
finished loading. This change makes the toggle explicit so that it's
always shown on `beforeSend`, and always hidden on `complete`.
Plus a bonus semi-colon eradication! 💥
On the first load, the merge request tabs would be requested in JSON format to render
the HTML. This would cause the "Reload with full diff" button to create a link to diff.json.
Closes#2041
The tab was being activated before we set the `[commits|diffs]Loaded`
variable, so even when the `/diffs` route is accessed directly, like
from the "Side-by-side" link, the tab was being loaded from its default
source.
Fixes#1887