mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Fix some js scripts being loaded before their dependencies in ajax calls
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{# @copyright Copyright (C) 2010-2023 Combodo SARL #}
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
{% apply spaceless %}
|
||||
{% set sId = oLayout.GetId() | sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) %}
|
||||
{% if bEscapeContent %}
|
||||
{{ render_block(oLayout, {aPage: aPage})|escape }}
|
||||
{% else %}
|
||||
@@ -16,33 +17,33 @@
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block iboPageJsInlineLive %}
|
||||
{% for sJsInline in aPage.aJsInlineLive %}
|
||||
{# We put each scripts in a dedicated script tag to prevent massive failure if 1 script is broken (eg. missing semi-colon or non closed multi-line comment) #}
|
||||
<script type="text/javascript">
|
||||
{{ sJsInline|raw }}
|
||||
</script>
|
||||
{% endfor %}
|
||||
{% for sJsInline in aPage.aJsInlineOnInit %}
|
||||
<script type="text/javascript">
|
||||
{{ sJsInline|raw }}
|
||||
</script>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% block iboPageJsInlineLive %}
|
||||
{% for sJsInline in aPage.aJsInlineLive %}
|
||||
{# We put each scripts in a dedicated script tag to prevent massive failure if 1 script is broken (eg. missing semi-colon or non closed multi-line comment) #}
|
||||
<script type="text/javascript">
|
||||
{{ sJsInline|raw }}
|
||||
</script>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
<script type="text/javascript">
|
||||
let fOnJsFilesLoaded{{ sId }} = function (fResolve) {
|
||||
{% for sJsInline in aPage.aJsInlineOnInit %}
|
||||
{{ sJsInline|raw }}
|
||||
{% endfor %}
|
||||
|
||||
{% for sJsInline in aPage.aJsInlineOnDomReady %}
|
||||
{{ sJsInline|raw }}
|
||||
{% endfor %}
|
||||
fResolve();
|
||||
}
|
||||
</script>
|
||||
|
||||
{% set sPromiseId = aPage.sPromiseId %}
|
||||
{% if aPage.aJsFiles is not empty %}
|
||||
{% set sId = oLayout.GetId() | sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) %}
|
||||
{% block iboPageJsFiles %}
|
||||
<script type="text/javascript">
|
||||
window['{{ sPromiseId }}'] = new Promise(function (resolve, reject) {
|
||||
let fInlineOnDomReadyScript{{ sId }} = function () {
|
||||
{% for sJsInlineOnDomReady in aPage.aJsInlineOnDomReady %}
|
||||
{{ sJsInlineOnDomReady|raw }}
|
||||
{% endfor %}
|
||||
resolve();
|
||||
}
|
||||
|
||||
window['{{ sPromiseId }}'] = new Promise(function (fAllJsFilesResolve, fAllJsFilesReject) {
|
||||
/**
|
||||
* @type {Array} aJsFilesToLoad Files required by the current \AjaxPage
|
||||
*
|
||||
@@ -117,7 +118,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
fInlineOnDomReadyScript{{ sId }}();
|
||||
fOnJsFilesLoaded{{ sId }}(fAllJsFilesResolve);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -125,21 +126,18 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
fInlineOnDomReadyScript{{ sId }}();
|
||||
fOnJsFilesLoaded{{ sId }}(fAllJsFilesResolve);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% else %}
|
||||
{% block iboPageJsInlineOnDomReady %}
|
||||
{% for sJsInlineOnDomReady in aPage.aJsInlineOnDomReady %}
|
||||
<script type="text/javascript">
|
||||
window['{{ sPromiseId }}'] = new Promise(function (resolve, reject) {
|
||||
{{ sJsInlineOnDomReady|raw }}
|
||||
resolve();
|
||||
<script type="text/javascript">
|
||||
window['{{ sPromiseId }}'] = new Promise(function (fNoJsFileResolve, fNoJsFileReject) {
|
||||
fOnJsFilesLoaded{{ sId }}(fNoJsFileResolve);
|
||||
});
|
||||
</script>
|
||||
{% endfor %}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user