Makes the editor focusable.

It's related to CachetHQ/Cachet#2749
On the incident template creation the editor was not focusable, now it
is.
The problem was the initialization of the editor that was done before
the DOM is fully loaded.
Using addEventListener and DOMContentListener fixes the problem and is
compatible from IE9.
This commit is contained in:
A
2018-01-12 15:27:57 +01:00
parent 42fd84ea79
commit c0e445ac51

View File

@@ -9,13 +9,14 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.8.0/mode/twig/twig.min.js"></script>
<script>
(function() {
var editor = CodeMirror.fromTextArea(document.getElementById('cm-editor'), {
lineNumbers: true,
mode: 'twig',
lineWrapping: true
});
}());
//Initializes the editor only once the DOM is loaded.
window.addEventListener("DOMContentLoaded", function(e) {
var editor = CodeMirror.fromTextArea(document.getElementById('cm-editor'), {
lineNumbers: true,
mode: 'twig',
lineWrapping: true
});
});
</script>
@stop