(function($) {
    "use strict";
    $(function() {
        /**
         * Initial Load
         */

        alert.setup();
        zender.active();
        zender.modals();
        zender.delete();
        zender.action();
        zender.build();

        $(window).scroll(() => {
            if ($(this).scrollTop() > 1)
                $(".header").addClass("animated slideInDown fixed"), 3000;
            else
                $(".header").removeClass("animated slideInDown fixed"), 3000;
        });

        /**
         * PJAX Handler
         */

        window.pjax = new Pjax({
            scrollTo: false,
            cacheBust: false,
            elements: "[zender-nav]",
            selectors: [
                "title",
                "[zender-navbar]",
                "[zender-avatar]",
                "[zender-wrapper]"
            ]
        });

        document.addEventListener("pjax:send", function() {
            topbar.show();
        });

        document.addEventListener("pjax:complete", function() {
            zender.active();
            zender.ripple();
            zender.iframe();
            zender.tabs(false);
            topbar.hide();
        });

        /**
         * Preloader
         */

        $("[zender-preloader]").fadeOut("fast", () => {
            zender.tabs();
            zender.ripple();
            zender.iframe();
            zender.translate();
            titansys.chat();
            titansys.forums();
        });
    });
})(jQuery);
