Make the init process in editor_textarea.html more robust in cases where the ace.js isn't loaded in 300ms
This commit is contained in:
parent
b66b1f914d
commit
48e37e1c85
1 changed files with 14 additions and 6 deletions
|
|
@ -61,16 +61,24 @@ function inject() {
|
|||
});
|
||||
}
|
||||
|
||||
// Call the inject function to load the ace files.
|
||||
inject();
|
||||
|
||||
var textAce;
|
||||
|
||||
setTimeout(function() {
|
||||
var t = document.querySelector("textarea");
|
||||
function initAce() {
|
||||
var ace = window.__ace_shadowed__;
|
||||
textAce = ace.transformTextarea(t);
|
||||
textAce.setDisplaySettings(true);
|
||||
}, 300);
|
||||
// Check if the ace.js file was loaded already, otherwise check back later.
|
||||
if (ace && ace.transformTextarea) {
|
||||
var t = document.querySelector("textarea");
|
||||
textAce = ace.transformTextarea(t);
|
||||
textAce.setDisplaySettings(true);
|
||||
} else {
|
||||
setTimeout(initAce, 100);
|
||||
}
|
||||
}
|
||||
|
||||
// Transform the textarea on the page into an ace editor.
|
||||
initAce();
|
||||
|
||||
document.getElementById("buBuild").onclick = function() {
|
||||
var injectSrc = inject.toString().split("\n").join("");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue