Remove HTML only used by the JavaScript

The `<div class="title-controls-wrap">` us only used if the JavaScript has loaded -its part of the controls used for the collapsible sections.

This PR removes this HTML from the templates and adds the JavaScript to build it after document.ready. This means if the JS hasn't loaded for whatever we don't have bits of HTML floating around that aren't used.