import Utils from '../Utils/Utils';
import EventBus, { Events, Event} from "./EventBus";

class GlobalEvents {
    static handleWindowResize() {

        const onResize = () => {
            EventBus.getInstance().triggerEvent(
                Events.WINDOW_RESIZE, {}
            );
        }
        const resizeCall = Utils.debounce(() => onResize(), 500);
        jQuery(window).on('resize', function () {
            resizeCall();
        });
    }

    static handleDocumentClick() {
        document.addEventListener('click', function(event) {
            EventBus.getInstance().triggerEvent(
                Events.DOCUMENT_CLICK, {}
            );
        });
    }

    static handleGlobalEvents() {
        GlobalEvents.handleWindowResize();
        GlobalEvents.handleDocumentClick();
    }
}
export default GlobalEvents;