Skip to content

Commit

Permalink
Refactor AJAX.scriptHandler.add() function
Browse files Browse the repository at this point in the history
Changes fire param to boolean and removes the return.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Feb 9, 2023
1 parent cc444d9 commit 3cb03e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 3 additions & 5 deletions js/src/modules/ajax.js
Expand Up @@ -663,10 +663,9 @@ const AJAX = {
* Records that a file has been downloaded
*
* @param {string} file The filename
* @param {string} fire Whether this file will be registering
* onload/teardown events
* @param {boolean} fire Whether this file will be registering onload/teardown events
*
* @return {self} For chaining
* @return {void}
*/
add: function (file, fire) {
this.scripts.push(file);
Expand All @@ -675,7 +674,6 @@ const AJAX = {
// This is necessary to correctly tear down the initial page
this.scriptsToBeFired.push(file);
}
return this;
},
/**
* Download a list of js files in one request
Expand Down Expand Up @@ -712,7 +710,7 @@ const AJAX = {
var script = files[i].name;
// Only for scripts that we don't already have
if ($.inArray(script, self.scripts) === -1) {
this.add(script);
this.add(script, false);
this.appendScript(script, callback);
} else {
self.done(script, callback);
Expand Down
5 changes: 2 additions & 3 deletions templates/scripts.twig
Expand Up @@ -8,11 +8,10 @@
// <![CDATA[
{{ code|raw }}
{% if files is not empty %}
window.AJAX.scriptHandler
{% for file in files %}
.add('{{ file.filename|escape('js') }}', {{ file.has_onload ? 1 : 0 }})
window.AJAX.scriptHandler.add('{{ file.filename|escape('js') }}', {{ file.has_onload ? 'true' : 'false' }});
{% endfor %}
;
$(function() {
{% for file in files %}
{% if file.has_onload %}
Expand Down

0 comments on commit 3cb03e6

Please sign in to comment.