Skip to content

Commit

Permalink
Extract ajax.js side effects into main.js file
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Jun 28, 2022
1 parent db30a4b commit bdbf82b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
15 changes: 0 additions & 15 deletions js/src/ajax.js
Expand Up @@ -936,18 +936,3 @@ window.AJAX = {
};
}
};

window.AJAX.registerOnload('functions.js', function () {
window.AJAX.removeSubmitEvents();
});

$(window.AJAX.loadEventHandler());

/**
* Attach a generic event handler to clicks
* on pages and submissions of forms
*/
$(document).on('click', 'a', window.AJAX.requestHandler);
$(document).on('submit', 'form', window.AJAX.requestHandler);

$(document).on('ajaxError', window.AJAX.getFatalErrorHandler());
10 changes: 10 additions & 0 deletions js/src/main.js
@@ -0,0 +1,10 @@
window.AJAX.registerOnload('functions.js', () => window.AJAX.removeSubmitEvents());
$(window.AJAX.loadEventHandler());

/**
* Attach a generic event handler to clicks on pages and submissions of forms.
*/
$(document).on('click', 'a', window.AJAX.requestHandler);
$(document).on('submit', 'form', window.AJAX.requestHandler);

$(document).on('ajaxError', window.AJAX.getFatalErrorHandler());
1 change: 1 addition & 0 deletions libraries/classes/Header.php
Expand Up @@ -132,6 +132,7 @@ private function addDefaultScripts(): void
$this->scripts->addFile('vendor/jquery/jquery-migrate.js');
$this->scripts->addFile('vendor/sprintf.js');
$this->scripts->addFile('ajax.js');
$this->scripts->addFile('main.js');
$this->scripts->addFile('keyhandler.js');
$this->scripts->addFile('vendor/jquery/jquery-ui.min.js');
$this->scripts->addFile('name-conflict-fixes.js');
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Expand Up @@ -49,6 +49,7 @@ module.exports = [
'jqplot/plugins/jqplot.byteFormatter': './js/src/jqplot/plugins/jqplot.byteFormatter.js',
'jquery.sortable-table': './js/src/jquery.sortable-table.js',
'keyhandler': './js/src/keyhandler.js',
'main': './js/src/main.js',
'makegrid': './js/src/makegrid.js',
'menu_resizer': './js/src/menu_resizer.js',
'multi_column_sort': './js/src/multi_column_sort.js',
Expand Down

0 comments on commit bdbf82b

Please sign in to comment.