HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/ijzerenman.komma.pro/wwwroot/js/app/core/history.js
define('core/history',
    [
        'core/pageAnimator',
        'core/pageNavigator',
        'nProgress',
        'swiper',
        'header',
        'images',
        'navigationBar',
        'mobileNavigation',
        'historySrc'
    ],function(pageAnimator, pageNavigator, nProcess, swiper, images, header, navigationBar)
{
    // Bind to State Change
    History.Adapter.bind(window,'statechange',function()
    {
        // Save old page
        var currentPage = $('body').attr('class');

        // Get history state
        var state = History.getState();

        // Start progress bar
        nProcess.start();

        // Fade out current page
        pageAnimator.fadeOut(function()
        {
            // Todo: clean up
            var url = state.url;
            if(state.data.global)
            {
                $.ajax({
                    url: '/updateMenu?global=' + state.data.global,
                    success: function(data)
                    {
                        $('#pageNavigation').html(data);
                    }
                });
            }

            if(state.data.color)
            {
                $('body').attr('data-color',state.data.color);
            }

            // Make ajax call for content
            $.ajax({
                url: url,
                success: function(data)
                {
                    // Add some progress (temp)
                    nProcess.inc();

                    // Adjust the title
                    document.title = data.title;
                    pageNavigator.updateBodyClass(data.name);

                    pageAnimator.animateIn();

                    if(typeof(ga) != "undefined")
                    {
                        // Update google analytics
                        ga('send', 'pageview', {
                            'page': state.url,
                            'title': data.title
                        });
                    }

                    // Load view
                    nProcess.done();

                    //$('html,body').animate({ scrollTop: 0 },400);
                    pageAnimator.fadeIn(data, function()
                    {
                        init();
                    });
                }
            });
        }); 
    });

    init();

    // Initialise functions
    function init()
    {
        // Initialise click event
        //initialiseHistoryClickEvent();
        header.initialize();

        images.initialize();
        swiper.initialize();

        $(window).scroll(function()
        {
            navigationBar.checkFixed();
        })
    }

    // Functions
    function initialiseHistoryClickEvent()
    {
        var $target = $('a[target!="_blank"]');
        var currentPage = $('body').attr('class');

        // Unbind existing click events
        $target.unbind('click');

        // Initialise click ev ent
        $target.bind('click',function(event)
        {
            if (Modernizr.history) {
                // Stop the url from following the link
                event.preventDefault();

                // Push a new state
                var $this = $(this);
                var pageName = $this.attr('data-state');
                if(currentPage != pageName)
                {
                    pageNavigator.updateActive(pageName);
                    pageAnimator.animateOut();

                    History.pushState(
                        {
                            state: pageName,
                            global: $this.attr('data-global'),
                            color: $this.attr('data-color')
                        },
                        null,
                        $this.attr('href'));
                }
            }
        });
    }
});