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/images.js
define('images',[],function()
{
    return {
        initialize: function()
        {
            var t = this;

            t.initResizeVideos();
            t.initResizeInit();

            t.preload();
            t.fill();

            $(window).resize(function()
            {
                t.fill();
            });


        },

        fill : function()
        {
            $('img.fill').one('load',function()
            {
                // Sizes
                var w = $(this).width();
                var h = $(this).height();
                var pw = $(this).parent().width();
                var ph = $(this).parent().height();
                var ratio = w/h;

                var css = {};

                // Check new with
                if( ratio < (pw/ph))
                {
                    css.width = pw;
                    css.height = pw / ratio;
                }
                else
                {
                    css.height = ph;
                    css.width = ph * ratio;
                }

                css.marginLeft = (css.width / -2) + 'px';
                css.marginTop = (css.height / -2) + 'px';

                css.left = '50%';
                css.top = '50%';

                $(this).css(css);

            }).each(function()
            {
                if(this.complete) $(this).load();
            });
        },


        preload: function()
        {
            $('img.preload').one('load',function()
            {
                $(this).addClass('loaded');
            }).each(function()
            {
                if(this.complete) $(this).load();
            });
        },

        initResizeVideos: function()
        {
            if($('iframe.video').size() == 0) return false;

            var t = this;
            t.resizeVideos();
            $(window).resize(function()
            {
                t.resizeVideos();
            });
        },
        resizeVideos: function()
        {
            // Check padding
            var margin = 80;
            if($(window).width() <= 1030) margin = 40;

            // Resize video
            var $video = $('iframe.video');
            var w = $video.parent().width();
            var h = w / 16 * 9;
            $video.width(w);
            $video.height(h);
            $video.parent().parent().height(h + margin);
        },
        initResizeInit: function()
        {
            if($('.album-block').size() == 0) return false;

            var t = this;
            t.resizeImages();
            $(window).resize(function()
            {
                t.resizeImages();
            });
        },
        resizeImages: function()
        {
            // Check padding
            var margin = 80;
            if($(window).width() <= 1030) margin = 40;

            // Resize video
            var $image = $('.album-block');
            var w = $image.width();
            var h = w / 4 * 3;
            $image.height(h);
            $image.parent().height(h + margin);
        }

    }
});