import FormsModule from './module/module';

class HelloPlusApp {
	constructor() {
		this.modules = {};
		this.ajax = {
            prepareArgs(args) {
                args[0] = 'ehp_' + args[0]; 
                return args;
            },
            send() {
                return elementorCommon.ajax.send.apply(elementorCommon.ajax, this.prepareArgs(arguments));
            },
            addRequest() {
                return elementorCommon.ajax.addRequest.apply(elementorCommon.ajax, this.prepareArgs(arguments));
            }
        };
	}

	start() {
		jQuery(window).on('elementor:init', () => this.onElementorInit());
	}

	onElementorInit() {
		this.modules.forms = new FormsModule();
		this.modules.forms.onElementorInit(); 
        jQuery(document).trigger('coolformkit:helloplus_app_init');   
	}
}

window.HelloPlusApp = new HelloPlusApp();
window.HelloPlusApp.start();

