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

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

            $(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 cssSize = {};

                // Check new with
                if( ratio < (pw/ph))
                {
                    //w = '100%';
                    //h = w / ratio;
                    cssSize.width = '100%';
                    cssSize.height = '';
                }
                else
                {
                    //h = ph;
                    //w = h * ratio;
                    cssSize.width = '';
                    cssSize.height = '100%';
                }

                $(this).css(cssSize);

                var cssPos = {};

                // Check origin
                var origins = $(this).attr('data-origin').split(' ');
                var originY = origins[0];
                var originX = origins[1];

                switch(originX)
                {
                    case 'center':
                        cssPos.left = '50%';
                        cssPos.marginLeft = ($(this).width() / -2) + 'px';
                        break;
                    case 'right':
                        cssPos.right = 0;
                        break;
                }

                switch(originY)
                {
                    case 'center':
                        cssPos.top = '50%';
                        cssPos.marginTop = ($(this).height() / -2) + 'px';
                        break;
                    case 'top':
                        cssPos.top = 0;
                        break;
                }

                //css.width = w+'px';
                //css.height = h+'px';

                $(this).css(cssPos);

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


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

    }
});